Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
scalar_pnpn_bc_fctry.f90
Go to the documentation of this file.
1! Copyright (c) 2024-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!
33!
36submodule(scalar_pnpn) scalar_pnpn_bc_fctry
37 use dirichlet, only : dirichlet_t
38 use neumann, only : neumann_t
39 use user_intf, only : user_t
45 implicit none
46
47 ! List of all possible types created by the boundary condition factories
48 character(len=25), parameter :: SCALAR_PNPN_KNOWN_BCS(6) = [ &
49 character(len=25) :: &
50 "dirichlet", &
51 "expression_dirichlet", &
52 "user_dirichlet", &
53 "user_neumann", &
54 "neumann", &
55 "overset_interface"]
56
57contains
58
62 module subroutine scalar_pnpn_bc_allocator(object, type_name)
63 class(bc_t), pointer, intent(inout) :: object
64 character(len=*), intent(in) :: type_name
65 integer :: i
66
67 if (associated(object)) then
68 call object%free()
69 deallocate(object)
70 end if
71
72 select case (trim(type_name))
73 case ("user_dirichlet")
74 allocate(field_dirichlet_t::object)
75 case ("dirichlet")
76 allocate(dirichlet_t::object)
77 case ("expression_dirichlet")
78 allocate(expression_dirichlet_t::object)
79 case ("user_neumann")
80 allocate(field_neumann_t::object)
81 case ("neumann")
82 allocate(neumann_t::object)
83 case ("overset_interface")
84 allocate(overset_interface_t::object)
85 case default
86 do i = 1, scalar_pnpn_bc_registry_size
87 if (trim(type_name) .eq. &
88 trim(scalar_pnpn_bc_registry(i)%type_name)) then
89 call scalar_pnpn_bc_registry(i)%allocator(object)
90 return
91 end if
92 end do
93
94 call neko_type_error("scalar_pnpn boundary conditions", type_name, &
95 scalar_pnpn_known_bcs)
96 end select
97 end subroutine scalar_pnpn_bc_allocator
98
104 module subroutine register_scalar_pnpn_bc(type_name, allocator)
105 character(len=*), intent(in) :: type_name
106 procedure(scalar_pnpn_bc_allocate), pointer, intent(in) :: allocator
107 type(scalar_pnpn_bc_allocator_entry), allocatable :: temp(:)
108 integer :: i
109
110 do i = 1, size(scalar_pnpn_known_bcs)
111 if (trim(type_name) .eq. trim(scalar_pnpn_known_bcs(i))) then
112 call neko_type_registration_error("scalar_pnpn boundary condition", &
113 type_name, .true.)
114 end if
115 end do
116
117 do i = 1, scalar_pnpn_bc_registry_size
118 if (trim(type_name) .eq. &
119 trim(scalar_pnpn_bc_registry(i)%type_name)) then
120 call neko_type_registration_error("scalar_pnpn boundary condition", &
121 type_name, .false.)
122 end if
123 end do
124
125 if (scalar_pnpn_bc_registry_size .eq. 0) then
126 allocate(scalar_pnpn_bc_registry(1))
127 else
128 allocate(temp(scalar_pnpn_bc_registry_size + 1))
129 temp(1:scalar_pnpn_bc_registry_size) = scalar_pnpn_bc_registry
130 call move_alloc(temp, scalar_pnpn_bc_registry)
131 end if
132
133 scalar_pnpn_bc_registry_size = scalar_pnpn_bc_registry_size + 1
134 scalar_pnpn_bc_registry(scalar_pnpn_bc_registry_size)%type_name = type_name
135 scalar_pnpn_bc_registry(scalar_pnpn_bc_registry_size)%allocator => allocator
136 end subroutine register_scalar_pnpn_bc
137
145 module subroutine scalar_pnpn_bc_factory(object, scheme, json, coef, user)
146 class(bc_t), pointer, intent(inout) :: object
147 type(scalar_pnpn_t), intent(in) :: scheme
148 type(json_file), intent(inout) :: json
149 type(coef_t), target, intent(in) :: coef
150 type(user_t), intent(in) :: user
151 character(len=:), allocatable :: type
152 integer :: i
153 integer, allocatable :: zone_indices(:)
154 character(len=:), allocatable :: default_name
155 character(len=64) :: buf
156
157 call json_get(json, "type", type)
158 call scalar_pnpn_bc_allocator(object, type)
159
160 select case (trim(type))
161 case ("user_dirichlet")
162 select type (obj => object)
163 type is (field_dirichlet_t)
164 obj%update => user%dirichlet_conditions
165 ! Add the name of the dummy field in the bc, matching the scalar
166 ! solved for.
167 call json%add("field_name", scheme%s%name)
168 end select
169 case ("user_neumann")
170 select type (obj => object)
171 type is (field_neumann_t)
172 obj%update => user%neumann_conditions
173 ! Add the name of the dummy field in the bc, matching the scalar
174 ! solved for.
175 call json%add("field_name", scheme%s%name)
176 end select
177 case ("overset_interface")
178 select type (obj => object)
179 type is (overset_interface_t)
180 call json%add("field_name", scheme%s%name)
181 end select
182 end select
183
184 call json_get(json, "zone_indices", zone_indices)
185 call object%init(coef, json)
186 do i = 1, size(zone_indices)
187 call object%mark_labeled_zone(zone_indices(i))
188 end do
189
190 write(buf,'("scalar_bc_",I0)') zone_indices(1)
191 default_name = trim(buf)
192 call json_get_or_default(json, "name", object%name, default_name)
193 object%zone_indices = zone_indices
194 call object%finalize()
195
196 deallocate(type)
197 deallocate(zone_indices)
198 deallocate(default_name)
199
200 end subroutine scalar_pnpn_bc_factory
201
202
203end submodule scalar_pnpn_bc_fctry
Defines a dirichlet boundary condition.
Definition dirichlet.f90:34
Defines a Dirichlet condition prescribed by a mathematical expression.
Defines user dirichlet condition for a scalar field.
Defines user neumann condition for a scalar field.
Defines a Neumann boundary condition.
Definition neumann.f90:34
Defines overset interface scalar boundary conditions.
Contains the scalar_pnpn_t type.
Interfaces for user interaction with NEKO.
Definition user_intf.f90:34
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
Generic Dirichlet boundary condition on .
Definition dirichlet.f90:49
Dirichlet condition on , where is a mathematical expression given in the case file.
User defined dirichlet condition, for which the user can work with an entire field....
User defined neumann condition, for which the user can work with an entire field. The type stores a s...
A Neumann boundary condition. Sets the flux of the field to the chosen values.
Definition neumann.f90:60
Overset interface BC for a scalar field.
A type collecting all the overridable user routines and flag to suppress type injection from custom m...