38 use json_module,
only : json_file
57 character(len=20),
private :: default_name =
"field_writer"
58 character(len=20),
private :: default_precision =
"single"
59 character(len=20),
private :: default_filename =
""
60 character(len=20),
private :: default_format =
"nek5000"
61 logical,
private :: default_subdivide = .false.
67 generic :: init_from_components => &
68 init_from_controllers, init_from_controllers_properties
70 procedure, pass(this) :: init_from_controllers => &
74 procedure, pass(this) :: init_from_controllers_properties => &
91 type(json_file),
intent(inout) :: json
92 class(
case_t),
intent(inout),
target :: case
93 character(len=:),
allocatable :: filename
94 character(len=:),
allocatable :: name
95 character(len=:),
allocatable :: precision
96 character(len=:),
allocatable :: format
97 character(len=20),
allocatable :: fields(:)
98 integer :: precision_value
101 call this%init_base(json,
case)
102 call json_get(json,
"fields", fields)
105 this%default_filename)
107 this%default_precision)
110 if (precision .eq.
"single")
then
112 else if (precision .eq.
"double")
then
115 call neko_error(
"Invalid precision specified for field_writer: " &
120 this%default_subdivide)
122 call this%init_common(name, fields, filename, precision_value,
format, &
143 preprocess_controller, compute_controller, output_controller, &
144 fields, filename, precision, format, subdivide)
146 character(len=*),
intent(in) :: name
147 class(
case_t),
intent(inout),
target :: case
152 character(len=20),
intent(in) :: fields(:)
153 character(len=*),
intent(in),
optional :: filename
154 integer,
intent(in),
optional :: precision
155 character(len=20),
intent(in),
optional :: format
156 logical,
intent(in),
optional :: subdivide
158 call this%init_base_from_components(
case, order, preprocess_controller, &
160 call this%init_common(name, fields, filename, precision,
format, subdivide)
185 case, order, preprocess_control, preprocess_value, compute_control, &
186 compute_value, output_control, output_value, fields, filename, &
187 precision, format, subdivide)
189 character(len=*),
intent(in) :: name
190 class(
case_t),
intent(inout),
target :: case
192 character(len=*),
intent(in) :: preprocess_control
193 real(kind=
rp),
intent(in) :: preprocess_value
194 character(len=*),
intent(in) :: compute_control
195 real(kind=
rp),
intent(in) :: compute_value
196 character(len=*),
intent(in) :: output_control
197 real(kind=
rp),
intent(in) :: output_value
198 character(len=20),
intent(in) :: fields(:)
199 character(len=*),
intent(in),
optional :: filename
200 integer,
intent(in),
optional :: precision
201 character(len=*),
intent(in),
optional :: format
202 logical,
intent(in),
optional :: subdivide
204 call this%init_base_from_components(
case, order, preprocess_control, &
205 preprocess_value, compute_control, compute_value, output_control, &
207 call this%init_common(name, fields, filename, precision,
format, subdivide)
225 character(len=*),
intent(in) :: name
226 character(len=20),
intent(in) :: fields(:)
227 character(len=*),
intent(in),
optional :: filename
228 integer,
intent(in),
optional :: precision
229 character(len=*),
intent(in),
optional :: format
230 logical,
intent(in),
optional :: subdivide
231 character(len=20) :: fieldi
232 logical :: filename_provided
233 character(len=120) :: message
238 do i = 1,
size(fields)
239 fieldi = trim(fields(i))
240 call neko_registry%add_field(this%case%fluid%dm_Xh, fieldi, &
241 ignore_existing = .true.)
244 filename_provided = .false.
245 if (
present(filename))
then
246 if (len_trim(filename) .ne. 0)
then
247 filename_provided = .true.
248 call this%output%init(trim(filename),
size(fields), &
249 precision = precision,
format = format)
251 if (
present(subdivide))
then
252 call this%output%file_%set_subdivide(subdivide)
255 do i = 1,
size(fields)
256 fieldi = trim(fields(i))
257 call this%output%fields%assign(i, &
261 call this%case%output_controller%add(this%output, &
262 this%output_controller%control_value, &
263 this%output_controller%control_mode)
268 if (.not. filename_provided)
then
269 do i = 1,
size(fields)
270 fieldi = trim(fields(i))
271 call this%case%f_out%fluid%append( &
281 call this%free_base()
282 call this%output%free()
Retrieves a parameter by name or assigns a provided default value. In the latter case also adds the m...
Retrieves a parameter by name or throws an error.
Defines a simulation case.
Implements field_output_t.
Implements the field_writer_t type.
subroutine field_writer_compute(this, time)
Here to comply with the interface, does nothing.
subroutine field_writer_free(this)
Destructor.
subroutine field_writer_init_from_controllers(this, name, case, order, preprocess_controller, compute_controller, output_controller, fields, filename, precision, format, subdivide)
Constructor from components, passing controllers.
subroutine field_writer_init_from_json(this, json, case)
Constructor from json.
subroutine field_writer_init_common(this, name, fields, filename, precision, format, subdivide)
Common part of both constructors.
subroutine field_writer_init_from_controllers_properties(this, name, case, order, preprocess_control, preprocess_value, compute_control, compute_value, output_control, output_value, fields, filename, precision, format, subdivide)
Constructor from components, passing properties to the time_based_controllercomponents in the base ty...
Utilities for retrieving parameters from the case files.
type(log_t), public neko_log
Global log stream.
integer, parameter, public dp
integer, parameter, public sp
integer, parameter, public rp
Global precision used in computations.
Implements output_controller_t
Defines a registry for storing solution fields.
type(registry_t), target, public neko_registry
Global field registry.
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 simple output saving a list of fields to a file.
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.