38 use json_module,
only : json_file
60 character(len=20),
private :: default_name =
"field_writer"
61 character(len=20),
private :: default_precision =
"single"
62 character(len=20),
private :: default_filename =
""
63 character(len=20),
private :: default_format =
"nek5000"
64 logical,
private :: default_subdivide = .false.
70 generic :: init_from_components => &
71 init_from_controllers, init_from_controllers_properties
73 procedure, pass(this) :: init_from_controllers => &
77 procedure, pass(this) :: init_from_controllers_properties => &
94 type(json_file),
intent(inout) :: json
95 class(
case_t),
intent(inout),
target :: case
96 character(len=:),
allocatable :: filename
97 character(len=:),
allocatable :: name
98 character(len=:),
allocatable :: precision
99 character(len=:),
allocatable :: format
100 character(len=:),
allocatable :: point_zone_name
101 character(len=20),
allocatable :: fields(:)
102 integer :: precision_value
106 call this%init_base(json,
case)
107 call json_get(json,
"fields", fields)
110 this%default_filename)
112 this%default_precision)
115 if (precision .eq.
"single")
then
117 else if (precision .eq.
"double")
then
120 call neko_error(
"Invalid precision specified for field_writer: " &
125 this%default_subdivide)
127 if (json%valid_path(
'point_zone'))
then
128 call json_get(json,
'point_zone', point_zone_name)
130 call this%init_common(name, fields, filename, precision_value,
format, &
133 call this%init_common(name, fields, filename, precision_value,
format, &
156 preprocess_controller, compute_controller, output_controller, &
157 fields, filename, precision, format, subdivide, point_zone)
159 character(len=*),
intent(in) :: name
160 class(
case_t),
intent(inout),
target :: case
165 character(len=20),
intent(in) :: fields(:)
166 character(len=*),
intent(in),
optional :: filename
167 integer,
intent(in),
optional :: precision
168 character(len=20),
intent(in),
optional :: format
169 logical,
intent(in),
optional :: subdivide
170 class(
point_zone_t),
intent(inout),
optional :: point_zone
172 call this%init_base_from_components(
case, order, preprocess_controller, &
174 call this%init_common(name, fields, filename, precision,
format, &
200 case, order, preprocess_control, preprocess_value, compute_control, &
201 compute_value, output_control, output_value, fields, filename, &
202 precision, format, subdivide, point_zone)
204 character(len=*),
intent(in) :: name
205 class(
case_t),
intent(inout),
target :: case
207 character(len=*),
intent(in) :: preprocess_control
208 real(kind=
rp),
intent(in) :: preprocess_value
209 character(len=*),
intent(in) :: compute_control
210 real(kind=
rp),
intent(in) :: compute_value
211 character(len=*),
intent(in) :: output_control
212 real(kind=
rp),
intent(in) :: output_value
213 character(len=20),
intent(in) :: fields(:)
214 character(len=*),
intent(in),
optional :: filename
215 integer,
intent(in),
optional :: precision
216 character(len=*),
intent(in),
optional :: format
217 logical,
intent(in),
optional :: subdivide
218 class(
point_zone_t),
intent(inout),
optional :: point_zone
220 call this%init_base_from_components(
case, order, preprocess_control, &
221 preprocess_value, compute_control, compute_value, output_control, &
223 call this%init_common(name, fields, filename, precision,
format, &
240 format, subdivide, point_zone)
242 character(len=*),
intent(in) :: name
243 character(len=20),
intent(in) :: fields(:)
244 character(len=*),
intent(in),
optional :: filename
245 integer,
intent(in),
optional :: precision
246 character(len=*),
intent(in),
optional :: format
247 logical,
intent(in),
optional :: subdivide
248 class(
point_zone_t),
intent(inout),
optional :: point_zone
250 character(len=20) :: fieldi
251 logical :: filename_provided
252 character(len=120) :: message
257 do i = 1,
size(fields)
258 fieldi = trim(fields(i))
259 call neko_registry%add_field(this%case%fluid%dm_Xh, fieldi, &
260 ignore_existing = .true.)
266 (.not.
present(filename) .or. len_trim(filename) .eq. 0 ) )
then
267 call neko_error(
"Please provide a filename for the " // &
268 "field_writer when using a point_zone with the key " // &
269 "'output_filename'.")
272 filename_provided = .false.
273 if (
present(filename))
then
274 if (len_trim(filename) .ne. 0)
then
275 filename_provided = .true.
276 call this%output%init(trim(filename),
size(fields), &
277 precision = precision,
format = format)
279 if (
present(subdivide))
then
280 call this%output%file_%set_subdivide(subdivide)
283 do i = 1,
size(fields)
284 fieldi = trim(fields(i))
285 call this%output%fields%assign(i, &
289 call this%case%output_controller%add(this%output, &
290 this%output_controller%control_value, &
291 this%output_controller%control_mode)
296 if (.not. filename_provided)
then
297 do i = 1,
size(fields)
298 fieldi = trim(fields(i))
299 call this%case%f_out%fluid%append( &
309 select type (ft => this%output%file_%file_type)
313 call neko_error(
"point_zone can only be used with nek5000/fld files")
322 call this%free_base()
323 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_json(this, json, case)
Constructor from json.
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, point_zone)
Constructor from components, passing properties to the time_based_controllercomponents in the base ty...
subroutine field_writer_init_common(this, name, fields, filename, precision, format, subdivide, point_zone)
Common part of both constructors.
subroutine field_writer_init_from_controllers(this, name, case, order, preprocess_controller, compute_controller, output_controller, fields, filename, precision, format, subdivide, point_zone)
Constructor from components, passing controllers.
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
type(point_zone_registry_t), target, public neko_point_zone_registry
Global point_zone registry.
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.
Interface for NEKTON fld files.
Base abstract type for point zones.
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.