Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
avm_fctry.f90
Go to the documentation of this file.
1! Copyright (c) 2026, The Neko Authors
2! All rights reserved.
3!
4! Redistribution and use in source and binary forms, with or without
5! modification, are permitted provided that the following conditions
6! are met:
7!
8! * Redistributions of source code must retain the above copyright
9! notice, this list of conditions and the following disclaimer.
10!
11! * Redistributions in binary form must reproduce the above
12! copyright notice, this list of conditions and the following
13! disclaimer in the documentation and/or other materials provided
14! with the distribution.
15!
16! * Neither the name of the authors nor the names of its
17! contributors may be used to endorse or promote products derived
18! from this software without specific prior written permission.
19!
20! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23! FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24! COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25! INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26! BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30! ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31! POSSIBILITY OF SUCH DAMAGE.
32!
34submodule(artificial_viscosity_model) artificial_viscosity_model_fctry
35 use case, only : case_t
38 implicit none
39
41 character(len=20) :: AVM_KNOWN_TYPES(1) = [character(len=20) :: &
42 "entropy_viscosity"]
43
44contains
50 module subroutine avm_factory(object, type_name, case, json)
51 class(avm_t), allocatable, intent(inout) :: object
52 character(len=*), intent(in) :: type_name
53 class(case_t), intent(inout), target :: case
54 type(json_file), intent(inout) :: json
55 character(len=:), allocatable :: type_string
56
57 call avm_allocator(object, type_name)
58 call object%init(case, json)
59 end subroutine avm_factory
60
64 module subroutine avm_allocator(object, type_name)
65 class(avm_t), allocatable, intent(inout) :: object
66 character(len=*), intent(in) :: type_name
67 integer :: i
68
69 if (allocated(object)) then
70 call object%free()
71 deallocate(object)
72 end if
73
74 select case (trim(type_name))
75 case ('entropy_viscosity')
76 allocate(entropy_viscosity_t::object)
77 case default
78 do i = 1, avm_registry_size
79 if (trim(type_name) == trim(avm_registry(i)%type_name)) then
80 call avm_registry(i)%allocator(object)
81 return
82 end if
83 end do
84
85 call neko_type_error("artificial viscosity model", &
86 type_name, avm_known_types)
87 end select
88
89 end subroutine avm_allocator
90
96 module subroutine register_avm(type_name, allocator)
97 character(len=*), intent(in) :: type_name
98 procedure(avm_allocate), pointer, intent(in) :: allocator
99 type(allocator_entry), allocatable :: temp(:)
100 integer :: i
101
102 do i = 1, size(avm_known_types)
103 if (trim(type_name) .eq. trim(avm_known_types(i))) then
104 call neko_type_registration_error("artificial viscosity model", &
105 type_name, .true.)
106 end if
107 end do
108
109 do i = 1, avm_registry_size
110 if (trim(type_name) .eq. trim(avm_registry(i)%type_name)) then
111 call neko_type_registration_error("artificial viscosity model", &
112 type_name, .false.)
113 end if
114 end do
115
116 ! Expand registry
117 if (avm_registry_size == 0) then
118 allocate(avm_registry(1))
119 else
120 allocate(temp(avm_registry_size + 1))
121 temp(1:avm_registry_size) = avm_registry
122 call move_alloc(temp, avm_registry)
123 end if
124
125 avm_registry_size = avm_registry_size + 1
126 avm_registry(avm_registry_size)%type_name = type_name
127 avm_registry(avm_registry_size)%allocator => allocator
128 end subroutine register_avm
129
130end submodule artificial_viscosity_model_fctry
Implements avm_t.
Definition avm.f90:35
Defines a simulation case.
Definition case.f90:34
Implements the entropy-based artificial viscosity model.
Utilities.
Definition utils.f90:35
subroutine, public neko_type_registration_error(base_type, wrong_type, known)
Definition utils.f90:431
subroutine, public neko_type_error(base_type, wrong_type, known_types)
Reports an error allocating a type for a particular base pointer class.
Definition utils.f90:413
Entropy-based artificial viscosity model for compressible flow.