Neko  0.8.99
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 lambda2, only : lambda2_t
38  use probes, only : probes_t
39  use les_simcomp, only : les_simcomp_t
41  use field_writer, only : field_writer_t
42  use weak_grad, only : weak_grad_t
43  use derivative, only : derivative_t
44 
45  ! List of all possible types created by the factory routine
46  character(len=20) :: SIMCOMPS_KNOWN_TYPES(5) = [character(len=20) :: &
47  "vorticity", &
48  "lambda2", &
49  "probes", &
50  "les_model", &
51  "field_writer"]
52 
53 contains
54 
59  module subroutine simulation_component_factory(object, json, case)
60  class(simulation_component_t), allocatable, intent(inout) :: object
61  type(json_file), intent(inout) :: json
62  class(case_t), intent(inout), target :: case
63  character(len=:), allocatable :: type_name
64  character(len=:), allocatable :: type_string
65  logical :: is_user
66 
67  ! Check if this is a user-defined component
68  call json_get_or_default(json, "is_user", is_user, .false.)
69  if (is_user) return
70 
71  call json_get(json, "type", type_name)
72 
73  if (trim(type_name) .eq. "vorticity") then
74  allocate(vorticity_t::object)
75  else if (trim(type_name) .eq. "lambda2") then
76  allocate(lambda2_t::object)
77  else if (trim(type_name) .eq. "probes") then
78  allocate(probes_t::object)
79  else if (trim(type_name) .eq. "les_model") then
80  allocate(les_simcomp_t::object)
81  else if (trim(type_name) .eq. "field_writer") then
82  allocate(field_writer_t::object)
83  else if (trim(type_name) .eq. "weak_grad") then
84  allocate(weak_grad_t::object)
85  else if (trim(type_name) .eq. "derivative") then
86  allocate(derivative_t::object)
87  else
88  type_string = concat_string_array(simcomps_known_types, &
89  new_line('A') // "- ", .true.)
90  call neko_error("Unknown simulation component type: " &
91  // trim(type_name) // ". Known types are: " &
92  // type_string)
93  stop
94  end if
95 
96  ! Initialize
97  call object%init(json, case)
98 
99  end subroutine simulation_component_factory
100 
101 
102 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.
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...
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:208
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 drives the computation of the SGS viscosity.
Definition: les_simcomp.f90:49
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