Neko 1.99.9
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
simulation_component_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!
35submodule(simulation_component) simulation_component_fctry
41 use lpt_simcomp, only : lpt_simcomp_t
45 use user_stats, only : user_stats_t
46 use lambda2, only : lambda2_t
47 use probes, only : probes_t
48 use les_simcomp, only : les_simcomp_t
51 use curl_simcomp, only : curl_t
59 use avm_simcomp, only : avm_simcomp_t
63 implicit none
64
65 ! List of all possible types created by the factory routine
66 character(len=30) :: SIMCOMPS_KNOWN_TYPES(25) = [character(len=30) :: &
67 "boundary_operation", &
68 "boundary_flux", &
69 "lagrangian_particles", &
70 "lambda2", &
71 "probes", &
72 "les_model", &
73 "field_writer", &
74 "fluid_stats", &
75 "fluid_sgs_stats", &
76 "scalar_stats", &
77 "scalar_sgs_stats", &
78 "gradient", &
79 "divergence", &
80 "curl", &
81 "derivative", &
82 "weak_gradient", &
83 "force_torque", &
84 "spatial_average", &
85 "user_stats", &
86 "spectral_error", &
87 "data_streamer", &
88 "field_subsampler", &
89 "artificial_viscosity_model", &
90 "wall_shear_stress", &
91 "boundary_data_writer"]
92
93contains
94
99 module subroutine simulation_component_factory(object, json, case)
100 class(simulation_component_t), allocatable, intent(inout) :: object
101 type(json_file), intent(inout) :: json
102 class(case_t), intent(inout), target :: case
103 character(len=:), allocatable :: type_name
104 character(len=:), allocatable :: type_string
105 logical :: is_user
106
107 ! Check if this is a user-defined component
108 call json_get_or_default(json, "is_user", is_user, .false.)
109 if (is_user) return
110
111 ! Get the type name
112 call json_get(json, "type", type_name)
113
114 ! Allocate
115 call simulation_component_allocator(object, type_name)
116
117 ! Initialize
118 call object%init(json, case)
119
120 end subroutine simulation_component_factory
121
125 module subroutine simulation_component_allocator(object, type_name)
126 class(simulation_component_t), allocatable, intent(inout) :: object
127 character(len=*), intent(in):: type_name
128 integer :: i
129
130 if (allocated(object)) then
131 call object%free()
132 deallocate(object)
133 end if
134
135 select case (trim(type_name))
136 case ("boundary_operation")
137 allocate(boundary_operation_t::object)
138 case ("boundary_flux")
139 allocate(boundary_flux_t::object)
140 case ("lagrangian_particles")
141 allocate(lpt_simcomp_t::object)
142 case ("lambda2")
143 allocate(lambda2_t::object)
144 case ("probes")
145 allocate(probes_t::object)
146 case ("les_model")
147 allocate(les_simcomp_t::object)
148 case ("field_writer")
149 allocate(field_writer_t::object)
150 case ("weak_gradient")
151 allocate(weak_gradient_t::object)
152 case ("gradient")
153 allocate(gradient_t::object)
154 case ("derivative")
155 allocate(derivative_t::object)
156 case ("curl")
157 allocate(curl_t::object)
158 case ("divergence")
159 allocate(divergence_t::object)
160 case ("force_torque")
161 allocate(force_torque_t::object)
162 case ("spatial_average")
163 allocate(spatial_average_t::object)
164 case ("fluid_stats")
165 allocate(fluid_stats_simcomp_t::object)
166 case ("fluid_sgs_stats")
167 allocate(fluid_sgs_stats_simcomp_t::object)
168 case ("scalar_stats")
169 allocate(scalar_stats_simcomp_t::object)
170 case ("scalar_sgs_stats")
171 allocate(scalar_sgs_stats_simcomp_t::object)
172 case ("user_stats")
173 allocate(user_stats_t::object)
174 case ("spectral_error")
175 allocate(spectral_error_t::object)
176 case ("data_streamer")
177 allocate(data_streamer_simcomp_t::object)
178 case ("field_subsampler")
179 allocate(field_subsampler_t::object)
180 case ("artificial_viscosity_model")
181 allocate(avm_simcomp_t::object)
182 case ("wall_shear_stress")
183 allocate(wall_shear_stress_t::object)
184 case ("boundary_data_writer")
185 allocate(boundary_data_writer_t::object)
186 case default
187 do i = 1, simcomp_registry_size
188 if (trim(type_name) == &
189 trim(simcomp_registry(i)%type_name)) then
190 call simcomp_registry(i)%allocator(object)
191 return
192 end if
193 end do
194 call neko_type_error("simulation component", trim(type_name), &
195 simcomps_known_types)
196 end select
197
198 end subroutine simulation_component_allocator
199
205 module subroutine register_simulation_component(type_name, allocator)
206 character(len=*), intent(in) :: type_name
207 procedure(simulation_component_allocate), pointer, intent(in) :: allocator
208 type(allocator_entry), allocatable :: temp(:)
209 integer :: i
210
211 do i = 1, size(simcomps_known_types)
212 if (trim(type_name) .eq. trim(simcomps_known_types(i))) then
213 call neko_type_registration_error("simulation component", type_name, &
214 .true.)
215 end if
216 end do
217
218 do i = 1, simcomp_registry_size
219 if (trim(type_name) .eq. &
220 trim(simcomp_registry(i)%type_name)) then
221 call neko_type_registration_error("simulation component", type_name, &
222 .false.)
223 end if
224 end do
225
226 ! Expand registry
227 if (simcomp_registry_size == 0) then
228 allocate(simcomp_registry(1))
229 else
230 allocate(temp(simcomp_registry_size + 1))
231 temp(1:simcomp_registry_size) = simcomp_registry
232 call move_alloc(temp, simcomp_registry)
233 end if
234
235 simcomp_registry_size = simcomp_registry_size + 1
236 simcomp_registry(simcomp_registry_size)%type_name = type_name
237 simcomp_registry(simcomp_registry_size)%allocator => allocator
238 end subroutine register_simulation_component
239
240end submodule simulation_component_fctry
Implements the avm_simcomp_t type.
Implements the boundary_data_writer_t type.
Implements boundary_flux_t.
Implements boundary_operation_t.
Defines a simulation case.
Definition case.f90:34
Implements the curl_t type.
A simulation component that streams data using ADIOS2.
Implements the derivative_t type.
Implements the divergence_t type.
Implements type field_subsampler_t.
Implements the field_writer_t type.
Implements the fluid_sgs_stats_simcomp_t type.
Implements the fluid_stats_simcomp_t type.
Implements the force_torque_t type.
Implements the gradient_t type.
A simulation component that computes lambda2 The values are stored in the field registry under the na...
Definition lambda2.f90:37
Implements the les_simcomp_t type.
Simulation-component handler for Lagrangian particle tracking.
Implements probes.
Definition probes.F90:37
Implements the scalar_sgs_stats_simcomp_t type.
Implements the scalar_stats_simcomp_t type.
Simulation components are objects that encapsulate functionality that can be fit to a particular comp...
Implements the spatial_average_t type.
Implements type spectral_error_t.
Implements the user_stats_t type.
Utilities.
Definition utils.f90:35
character(:) function, allocatable, public concat_string_array(array, sep, prepend)
Concatenate an array of strings into one string with array items separated by spaces.
Definition utils.f90:466
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
Implements the wall_shear_stress_t type.
Implements the weak_gradient_t type.
A simulation component that drives the computation of the artificial viscosity method.
A simulation component that writes registry fields sampled on labelled boundary zones....
A simulation component for total vector flux through labelled zones.
A simulation component for boundary reductions on labelled zones.
A simulation component that computes the curl of a vector field. Added to the field registry as curl_...
A simulation component that computes a derivative of a field. Wraps the duxyz operator.
A simulation component that computes the divergence of a vector field. Added to the field registry as...
Implements the field_subsampler_t simulation components, which allows for masking regions of the doma...
A simulation component that writes a 3d field to a file.
A simulation component that computes the subgrid-scale contributions to the Reynolds stresses in LES.
A simulation component that computes the velocity and pressure statistics up to 4th order....
A simulation component that computes the force and torque on a given boundary zone.
A simulation component that computes the gradient of a field. Wraps the gradient operator.
A simulation component that drives the computation of the SGS viscosity.
A simulation component that drives passive Lagrangian particle tracking.
A simulation component that computes the subgrid-scale contributions to the Reynolds stresses in LES.
A simulation component that computes the scalar statistics for the skewness, kurtosis,...
A simulation component that writes spatial averages of registry fields.
Provides tools to calculate the spectral error indicator.
A simulation component that computes the averages of fields in the registry.
A simulation component that computes the wall shear stress on one or more labelled boundary zones and...
A simulation component that computes the weak gradient of a field. Wraps the opgradient operator.