Loading [MathJax]/extensions/tex2jax.js
Neko 0.9.99
A portable framework for high-order spectral element flow simulations
All Classes Namespaces Files Functions Variables Typedefs Enumerator Macros Pages
simulation_component_fctry.f90
Go to the documentation of this file.
1! Copyright (c) 2024, 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
36 use vorticity, only : vorticity_t
39 use lambda2, only : lambda2_t
40 use probes, only : probes_t
41 use les_simcomp, only : les_simcomp_t
44 use weak_grad, only : weak_grad_t
45 use derivative, only : derivative_t
47 use utils, only : neko_type_error
48
49 ! List of all possible types created by the factory routine
50 character(len=20) :: SIMCOMPS_KNOWN_TYPES(9) = [character(len=20) :: &
51 "vorticity", &
52 "lambda2", &
53 "probes", &
54 "les_model", &
55 "field_writer", &
56 "fluid_stats", &
57 "weak_grad", &
58 "force_torque", &
59 "spectral_error"]
60
61contains
62
67 module subroutine simulation_component_factory(object, json, case)
68 class(simulation_component_t), allocatable, intent(inout) :: object
69 type(json_file), intent(inout) :: json
70 class(case_t), intent(inout), target :: case
71 character(len=:), allocatable :: type_name
72 character(len=:), allocatable :: type_string
73 logical :: is_user
74
75 ! Check if this is a user-defined component
76 call json_get_or_default(json, "is_user", is_user, .false.)
77 if (is_user) return
78
79 ! Get the type name
80 call json_get(json, "type", type_name)
81
82 ! Allocate
83 call simulation_component_allocator(object, type_name)
84
85 ! Initialize
86 call object%init(json, case)
87
88 end subroutine simulation_component_factory
89
93 module subroutine simulation_component_allocator(object, type_name)
94 class(simulation_component_t), allocatable, intent(inout) :: object
95 character(len=*), intent(in):: type_name
96
97 select case (trim(type_name))
98 case ("vorticity")
99 allocate(vorticity_t::object)
100 case ("lambda2")
101 allocate(lambda2_t::object)
102 case ("probes")
103 allocate(probes_t::object)
104 case ("les_model")
105 allocate(les_simcomp_t::object)
106 case ("field_writer")
107 allocate(field_writer_t::object)
108 case ("weak_grad")
109 allocate(weak_grad_t::object)
110 case ("derivative")
111 allocate(derivative_t::object)
112 case ("force_torque")
113 allocate(force_torque_t::object)
114 case ("fluid_stats")
115 allocate(fluid_stats_simcomp_t::object)
116 case ("spectral_error")
117 allocate(spectral_error_t::object)
118 case default
119 do i = 1, simcomp_registry_size
120 if (trim(type_name) == &
121 trim(simcomp_registry(i)%type_name)) then
122 call simcomp_registry(i)%allocator(object)
123 return
124 end if
125 end do
126 call neko_type_error("simulation component", trim(type_name), &
127 simcomps_known_types)
128 end select
129
130 end subroutine simulation_component_allocator
131
136 module subroutine register_simulation_component(type_name, allocator)
137 character(len=*), intent(in) :: type_name
138 procedure(simulation_component_allocate), pointer, intent(in) :: allocator
139 type(allocator_entry), allocatable :: temp(:)
140
141 ! Expand registry
142 if (simcomp_registry_size == 0) then
143 allocate(simcomp_registry(1))
144 else
145 allocate(temp(simcomp_registry_size + 1))
146 temp(1:simcomp_registry_size) = simcomp_registry
147 call move_alloc(temp, simcomp_registry)
148 end if
149
150 simcomp_registry_size = simcomp_registry_size + 1
151 simcomp_registry(simcomp_registry_size)%type_name = type_name
152 simcomp_registry(simcomp_registry_size)%allocator => allocator
153 end subroutine register_simulation_component
154
155end submodule simulation_component_fctry
Defines a simulation case.
Definition case.f90:34
Implements the derivative_t type.
Implements the field_writer_t type.
Implements the fluid_stats_simcomp_t type.
Implements the force_torque_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.
Implements probes.
Definition probes.F90:37
Simulation components are objects that encapsulate functionality that can be fit to a particular comp...
Implements type spectral_error_t.
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:276
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:250
Implements the vorticity_t type.
Definition vorticity.f90:36
Implements the weak_grad_t type.
Definition weak_grad.f90:36
A simulation component that computes a derivative of a field. Wraps the duxyz operator.
A simulation component that writes a 3d field to a file.
A simulation component that computes the velocity and pressure statistics up to 4th order....
A simulation component that computes the force_torque field. Added to the field registry as omega_x,...
A simulation component that drives the computation of the SGS viscosity.
Provides tools to calculate the spectral error indicator.
A simulation component that computes the vorticity field. Added to the field registry as omega_x,...
Definition vorticity.f90:54
A simulation component that computes the weak gradient of a field. Wraps the opgrad operator.
Definition weak_grad.f90:53