Neko  0.9.0
A portable framework for high-order spectral element flow simulations
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 !
35 submodule(simulation_component) simulation_component_fctry
36  use vorticity, only : vorticity_t
37  use force_torque, only : force_torque_t
39  use lambda2, only : lambda2_t
40  use probes, only : probes_t
41  use les_simcomp, only : les_simcomp_t
43  use field_writer, only : field_writer_t
44  use weak_grad, only : weak_grad_t
45  use derivative, only : derivative_t
47 
48  ! List of all possible types created by the factory routine
49  character(len=20) :: SIMCOMPS_KNOWN_TYPES(8) = [character(len=20) :: &
50  "vorticity", &
51  "lambda2", &
52  "probes", &
53  "les_model", &
54  "field_writer", &
55  "fluid_stats", &
56  "force_torque", &
57  "spectral_error"]
58 
59 contains
60 
65  module subroutine simulation_component_factory(object, json, case)
66  class(simulation_component_t), allocatable, intent(inout) :: object
67  type(json_file), intent(inout) :: json
68  class(case_t), intent(inout), target :: case
69  character(len=:), allocatable :: type_name
70  character(len=:), allocatable :: type_string
71  logical :: is_user
72 
73  ! Check if this is a user-defined component
74  call json_get_or_default(json, "is_user", is_user, .false.)
75  if (is_user) return
76 
77  call json_get(json, "type", type_name)
78 
79  if (trim(type_name) .eq. "vorticity") then
80  allocate(vorticity_t::object)
81  else if (trim(type_name) .eq. "lambda2") then
82  allocate(lambda2_t::object)
83  else if (trim(type_name) .eq. "probes") then
84  allocate(probes_t::object)
85  else if (trim(type_name) .eq. "les_model") then
86  allocate(les_simcomp_t::object)
87  else if (trim(type_name) .eq. "field_writer") then
88  allocate(field_writer_t::object)
89  else if (trim(type_name) .eq. "weak_grad") then
90  allocate(weak_grad_t::object)
91  else if (trim(type_name) .eq. "derivative") then
92  allocate(derivative_t::object)
93  else if (trim(type_name) .eq. "force_torque") then
94  allocate(force_torque_t::object)
95  else if (trim(type_name) .eq. "fluid_stats") then
96  allocate(fluid_stats_simcomp_t::object)
97  else if (trim(type_name) .eq. "spectral_error") then
98  allocate(spectral_error_t::object)
99  else
100  type_string = concat_string_array(simcomps_known_types, &
101  new_line('A') // "- ", .true.)
102  call neko_error("Unknown simulation component type: " &
103  // trim(type_name) // ". Known types are: " &
104  // type_string)
105  stop
106  end if
107 
108  ! Initialize
109  call object%init(json, case)
110 
111  end subroutine simulation_component_factory
112 
113 
114 end submodule simulation_component_fctry
Defines a simulation case.
Definition: case.f90:34
Implements the derivative_t type.
Definition: derivative.f90:36
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.
Definition: les_simcomp.f90:36
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:255
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.
Definition: derivative.f90:53
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.
Definition: les_simcomp.f90:49
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:52
A simulation component that computes the weak gradient of a field. Wraps the opgrad operator.
Definition: weak_grad.f90:52