Neko 1.99.3
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 use utils, only : neko_varname_len
51 implicit none
52 private
53
54 type, public, extends(simulation_component_t) :: lambda2_t
56 type(field_t), pointer :: u
58 type(field_t), pointer :: v
60 type(field_t), pointer :: w
61
63 type(field_t), pointer :: lambda2
64
66 type(field_t) :: temp1
67 type(field_t) :: temp2
68
70 type(field_writer_t) :: writer
71
72 contains
74 procedure, pass(this) :: init => lambda2_init_from_json
76 generic :: init_from_components => &
77 init_from_controllers, init_from_controllers_properties
79 procedure, pass(this) :: init_from_controllers => &
83 procedure, pass(this) :: init_from_controllers_properties => &
86 procedure, private, pass(this) :: init_common => lambda2_init_common
88 procedure, pass(this) :: free => lambda2_free
90 procedure, pass(this) :: compute_ => lambda2_compute
91 end type lambda2_t
92
93contains
94
96 subroutine lambda2_init_from_json(this, json, case)
97 class(lambda2_t), intent(inout), target :: this
98 type(json_file), intent(inout) :: json
99 class(case_t), intent(inout), target ::case
100 character(len=:), allocatable :: name
101 character(len=NEKO_VARNAME_LEN) :: fields(1)
102 type(field_t), pointer :: u, v, w, lambda2
103
104 call json_get_or_default(json, "name", name, "lambda2")
105 ! Add fields keyword to the json so that the field_writer picks it up.
106 ! Will also add fields to the registry.
107 fields(1) = "lambda2"
108 call json%add("fields", fields)
109
110 call this%init_base(json, case)
111 call this%writer%init(json, case)
112
113 call this%init_common(name)
114 end subroutine lambda2_init_from_json
115
118 subroutine lambda2_init_common(this, name)
119 class(lambda2_t), intent(inout) :: this
120 character(len=*), intent(in) :: name
121
122 this%name = name
123 this%u => neko_registry%get_field("u")
124 this%v => neko_registry%get_field("v")
125 this%w => neko_registry%get_field("w")
126 this%lambda2 => neko_registry%get_field("lambda2")
127
128 end subroutine lambda2_init_common
129
140 subroutine lambda2_init_from_controllers(this, name, case, order, &
141 preprocess_controller, compute_controller, output_controller, &
142 filename, precision)
143 class(lambda2_t), intent(inout) :: this
144 character(len=*), intent(in) :: name
145 class(case_t), intent(inout), target :: case
146 integer :: order
147 type(time_based_controller_t), intent(in) :: preprocess_controller
148 type(time_based_controller_t), intent(in) :: compute_controller
149 type(time_based_controller_t), intent(in) :: output_controller
150 character(len=*), intent(in), optional :: filename
151 integer, intent(in), optional :: precision
152
153 character(len=NEKO_VARNAME_LEN) :: fields(1)
154 fields(1) = "lambda2"
155
156 call this%init_base_from_components(case, order, preprocess_controller, &
157 compute_controller, output_controller)
158 call this%writer%init_from_components("field_writer", case, order, &
159 preprocess_controller, compute_controller, output_controller, fields, &
160 filename, precision)
161 call this%init_common(name)
162
163 end subroutine lambda2_init_from_controllers
164
181 case, order, preprocess_control, preprocess_value, compute_control, &
182 compute_value, output_control, output_value, filename, precision)
183 class(lambda2_t), intent(inout) :: this
184 character(len=*), intent(in) :: name
185 class(case_t), intent(inout), target :: case
186 integer :: order
187 character(len=*), intent(in) :: preprocess_control
188 real(kind=rp), intent(in) :: preprocess_value
189 character(len=*), intent(in) :: compute_control
190 real(kind=rp), intent(in) :: compute_value
191 character(len=*), intent(in) :: output_control
192 real(kind=rp), intent(in) :: output_value
193 character(len=*), intent(in), optional :: filename
194 integer, intent(in), optional :: precision
195
196 character(len=NEKO_VARNAME_LEN) :: fields(1)
197 fields(1) = "lambda2"
198
199 call this%init_base_from_components(case, order, preprocess_control, &
200 preprocess_value, compute_control, compute_value, output_control, &
201 output_value)
202 call this%writer%init_from_components("field_writer", case, order, &
203 preprocess_control, preprocess_value, compute_control, compute_value, &
204 output_control, output_value, fields, filename, precision)
205 call this%init_common(name)
206
208
210 subroutine lambda2_free(this)
211 class(lambda2_t), intent(inout) :: this
212 call this%free_base()
213
214 nullify(this%u)
215 nullify(this%v)
216 nullify(this%w)
217 nullify(this%lambda2)
218 end subroutine lambda2_free
219
222 subroutine lambda2_compute(this, time)
223 class(lambda2_t), intent(inout) :: this
224 type(time_state_t), intent(in) :: time
225
226 call lambda2op(this%lambda2, this%u, this%v, this%w, this%case%fluid%c_Xh)
227
228 end subroutine lambda2_compute
229
230end 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:143
subroutine lambda2_init_common(this, name)
Common part of constructors.
Definition lambda2.f90:119
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:183
subroutine lambda2_init_from_json(this, json, case)
Constructor from json.
Definition lambda2.f90:97
subroutine lambda2_compute(this, time)
Compute the lambda2 field.
Definition lambda2.f90:223
subroutine lambda2_free(this)
Destructor.
Definition lambda2.f90:211
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:144
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.
Utilities.
Definition utils.f90:35
integer, parameter, public neko_varname_len
Definition utils.f90:42
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.