Neko 1.99.2
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
lambda2.f90
Go to the documentation of this file.
1! Copyright (c) 2023, 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!
36
37module lambda2
38 use num_types, only : rp
39 use json_module, only : json_file
42 use registry, only : neko_registry
43 use field, only : field_t
44 use time_state, only : time_state_t
45 use operators, only : lambda2op
46 use case, only : case_t
49 use device
50 implicit none
51 private
52
53 type, public, extends(simulation_component_t) :: lambda2_t
55 type(field_t), pointer :: u
57 type(field_t), pointer :: v
59 type(field_t), pointer :: w
60
62 type(field_t), pointer :: lambda2
63
65 type(field_t) :: temp1
66 type(field_t) :: temp2
67
69 type(field_writer_t) :: writer
70
71 contains
73 procedure, pass(this) :: init => lambda2_init_from_json
75 generic :: init_from_components => &
76 init_from_controllers, init_from_controllers_properties
78 procedure, pass(this) :: init_from_controllers => &
82 procedure, pass(this) :: init_from_controllers_properties => &
85 procedure, private, pass(this) :: init_common => lambda2_init_common
87 procedure, pass(this) :: free => lambda2_free
89 procedure, pass(this) :: compute_ => lambda2_compute
90 end type lambda2_t
91
92contains
93
95 subroutine lambda2_init_from_json(this, json, case)
96 class(lambda2_t), intent(inout), target :: this
97 type(json_file), intent(inout) :: json
98 class(case_t), intent(inout), target ::case
99 character(len=:), allocatable :: name
100 character(len=20) :: fields(1)
101 type(field_t), pointer :: u, v, w, lambda2
102
103 call json_get_or_default(json, "name", name, "lambda2")
104 ! Add fields keyword to the json so that the field_writer picks it up.
105 ! Will also add fields to the registry.
106 fields(1) = "lambda2"
107 call json%add("fields", fields)
108
109 call this%init_base(json, case)
110 call this%writer%init(json, case)
111
112 call this%init_common(name)
113 end subroutine lambda2_init_from_json
114
117 subroutine lambda2_init_common(this, name)
118 class(lambda2_t), intent(inout) :: this
119 character(len=*), intent(in) :: name
120
121 this%name = name
122 this%u => neko_registry%get_field("u")
123 this%v => neko_registry%get_field("v")
124 this%w => neko_registry%get_field("w")
125 this%lambda2 => neko_registry%get_field("lambda2")
126
127 end subroutine lambda2_init_common
128
139 subroutine lambda2_init_from_controllers(this, name, case, order, &
140 preprocess_controller, compute_controller, output_controller, &
141 filename, precision)
142 class(lambda2_t), intent(inout) :: this
143 character(len=*), intent(in) :: name
144 class(case_t), intent(inout), target :: case
145 integer :: order
146 type(time_based_controller_t), intent(in) :: preprocess_controller
147 type(time_based_controller_t), intent(in) :: compute_controller
148 type(time_based_controller_t), intent(in) :: output_controller
149 character(len=*), intent(in), optional :: filename
150 integer, intent(in), optional :: precision
151
152 character(len=20) :: fields(1)
153 fields(1) = "lambda2"
154
155 call this%init_base_from_components(case, order, preprocess_controller, &
156 compute_controller, output_controller)
157 call this%writer%init_from_components("field_writer", case, order, &
158 preprocess_controller, compute_controller, output_controller, fields, &
159 filename, precision)
160 call this%init_common(name)
161
162 end subroutine lambda2_init_from_controllers
163
180 case, order, preprocess_control, preprocess_value, compute_control, &
181 compute_value, output_control, output_value, filename, precision)
182 class(lambda2_t), intent(inout) :: this
183 character(len=*), intent(in) :: name
184 class(case_t), intent(inout), target :: case
185 integer :: order
186 character(len=*), intent(in) :: preprocess_control
187 real(kind=rp), intent(in) :: preprocess_value
188 character(len=*), intent(in) :: compute_control
189 real(kind=rp), intent(in) :: compute_value
190 character(len=*), intent(in) :: output_control
191 real(kind=rp), intent(in) :: output_value
192 character(len=*), intent(in), optional :: filename
193 integer, intent(in), optional :: precision
194
195 character(len=20) :: fields(1)
196 fields(1) = "lambda2"
197
198 call this%init_base_from_components(case, order, preprocess_control, &
199 preprocess_value, compute_control, compute_value, output_control, &
200 output_value)
201 call this%writer%init_from_components("field_writer", case, order, &
202 preprocess_control, preprocess_value, compute_control, compute_value, &
203 output_control, output_value, fields, filename, precision)
204 call this%init_common(name)
205
207
209 subroutine lambda2_free(this)
210 class(lambda2_t), intent(inout) :: this
211 call this%free_base()
212
213 nullify(this%u)
214 nullify(this%v)
215 nullify(this%w)
216 nullify(this%lambda2)
217 end subroutine lambda2_free
218
221 subroutine lambda2_compute(this, time)
222 class(lambda2_t), intent(inout) :: this
223 type(time_state_t), intent(in) :: time
224
225 call lambda2op(this%lambda2, this%u, this%v, this%w, this%case%fluid%c_Xh)
226
227 end subroutine lambda2_compute
228
229end module lambda2
Retrieves a parameter by name or assigns a provided default value. In the latter case also adds the m...
Defines a simulation case.
Definition case.f90:34
Device abstraction, common interface for various accelerators.
Definition device.F90:34
Implements the field_writer_t type.
Defines a field.
Definition field.f90:34
Utilities for retrieving parameters from the case files.
A simulation component that computes lambda2 The values are stored in the field registry under the na...
Definition lambda2.f90:37
subroutine lambda2_init_from_controllers(this, name, case, order, preprocess_controller, compute_controller, output_controller, filename, precision)
Constructor from components, passing controllers.
Definition lambda2.f90:142
subroutine lambda2_init_common(this, name)
Common part of constructors.
Definition lambda2.f90:118
subroutine lambda2_init_from_controllers_properties(this, name, case, order, preprocess_control, preprocess_value, compute_control, compute_value, output_control, output_value, filename, precision)
Constructor from components, passing properties to the time_based_controller` components in the base ...
Definition lambda2.f90:182
subroutine lambda2_init_from_json(this, json, case)
Constructor from json.
Definition lambda2.f90:96
subroutine lambda2_compute(this, time)
Compute the lambda2 field.
Definition lambda2.f90:222
subroutine lambda2_free(this)
Destructor.
Definition lambda2.f90:210
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:12
Operators.
Definition operators.f90:34
subroutine, public lambda2op(lambda2, u, v, w, coef)
Compute the Lambda2 field for a given velocity field.
Implements output_controller_t
Defines a registry for storing solution fields.
Definition registry.f90:34
type(registry_t), target, public neko_registry
Global field registry.
Definition registry.f90:149
Simulation components are objects that encapsulate functionality that can be fit to a particular comp...
subroutine compute_(this, time)
Dummy compute function.
Contains the time_based_controller_t type.
Module with things related to the simulation time.
A simulation component that writes a 3d field to a file.
Base abstract class for simulation components.
A utility type for determining whether an action should be executed based on the current time value....
A struct that contains all info about the time, expand as needed.