38 use json_module,
only : json_file
59 real(kind=
dp) :: start_time
65 integer :: n_avg_fields = 0
67 character(len=NEKO_VARNAME_LEN),
allocatable :: field_names(:)
71 character(len=:),
allocatable :: base_filename
77 generic :: init_from_components => &
78 init_from_controllers, init_from_controllers_properties
80 procedure, pass(this) :: init_from_controllers => &
84 procedure, pass(this) :: init_from_controllers_properties => &
102 type(json_file),
intent(inout) :: json
103 class(
case_t),
intent(inout),
target :: case
104 character(len=:),
allocatable :: filename
105 character(len=:),
allocatable :: avg_dir
106 character(len=:),
allocatable :: name
109 call this%init_base(json,
case)
112 call json%info(
'fields', n_children = this%n_avg_fields)
113 call json_get(json,
'fields', this%field_names)
118 if (json%valid_path(
'output_filename'))
then
119 call json_get(json,
'output_filename', filename)
121 case%fluid%c_Xh, avg_dir, filename = filename)
124 case%fluid%c_Xh, avg_dir)
132 character(len=NEKO_FNAME_LEN) :: fname
133 character(len=5) :: prefix, suffix
137 if (t .gt. this%time) this%time = t
139 fname = this%output%file_%get_base_fname()
140 write (prefix,
'(I0)') &
141 this%output%file_%file_type%get_start_counter()
143 fname = trim(this%case%output_directory) // &
144 trim(this%base_filename) // trim(prefix) //
"." // trim(suffix)
145 call this%output%init_base(fname)
163 preprocess_controller, compute_controller, output_controller, &
164 start_time, coef, avg_dir, filename, precision)
166 character(len=*),
intent(in) :: name
167 class(
case_t),
intent(inout),
target :: case
172 real(kind=
dp),
intent(in) :: start_time
173 character(len=*),
intent(in) :: avg_dir
174 type(
coef_t),
intent(inout) :: coef
175 character(len=*),
intent(in),
optional :: filename
176 integer,
intent(in),
optional :: precision
178 call this%init_base_from_components(
case, order, preprocess_controller, &
180 call this%init_common(name, start_time, coef, avg_dir, filename, precision)
203 case, order, preprocess_control, preprocess_value, compute_control, &
204 compute_value, output_control, output_value, start_time, coef, avg_dir, &
207 character(len=*),
intent(in) :: name
208 class(
case_t),
intent(inout),
target :: case
210 character(len=*),
intent(in) :: preprocess_control
211 real(kind=
dp),
intent(in) :: preprocess_value
212 character(len=*),
intent(in) :: compute_control
213 real(kind=
dp),
intent(in) :: compute_value
214 character(len=*),
intent(in) :: output_control
215 real(kind=
dp),
intent(in) :: output_value
216 real(kind=
dp),
intent(in) :: start_time
217 character(len=*),
intent(in) :: avg_dir
218 type(
coef_t),
intent(inout) :: coef
219 character(len=*),
intent(in),
optional :: filename
220 integer,
intent(in),
optional :: precision
222 call this%init_base_from_components(
case, order, preprocess_control, &
223 preprocess_value, compute_control, compute_value, output_control, &
225 call this%init_common(name, start_time, coef, avg_dir, filename, precision)
238 character(len=*),
intent(in) :: name
239 character(len=*),
intent(in),
optional :: filename
240 integer,
intent(in),
optional :: precision
241 real(kind=
dp),
intent(in) :: start_time
242 character(len=*),
intent(in) :: avg_dir
243 type(
coef_t),
intent(inout) :: coef
245 type(
field_t),
pointer :: field_to_avg
246 character(len=NEKO_FNAME_LEN) :: stats_fname
247 character(len=1024) :: unique_name
249 unique_name = name //
"/"
252 this%start_time = start_time
253 this%time = start_time
255 if (
present(filename))
then
256 this%base_filename = filename
258 this%base_filename =
"user_stats"
260 stats_fname = trim(this%base_filename) //
"0"
263 allocate(this%mean_fields(this%n_avg_fields))
264 do i = 1, this%n_avg_fields
265 field_to_avg =>
neko_registry%get_field(trim(this%field_names(i)))
266 call this%mean_fields(i)%init(field_to_avg, trim(unique_name) // &
267 "mean_" // trim(this%field_names(i)))
270 call this%output%init(this%mean_fields, this%n_avg_fields, &
271 this%start_time, coef, avg_dir, name = stats_fname, &
272 path = this%case%output_directory)
276 call this%case%output_controller%add(this%output, &
277 this%output_controller%control_value, &
278 this%output_controller%control_mode, &
279 start_time =
max(this%start_time, this%case%time%start_time), &
280 write_at_start = .false.)
282 nullify(field_to_avg)
291 call this%free_base()
293 if (
allocated(this%mean_fields))
then
294 do i = 1, this%n_avg_fields
295 call this%mean_fields(i)%free()
297 deallocate(this%mean_fields)
300 if (
allocated(this%field_names))
then
301 deallocate(this%field_names)
314 if (time%t .ge. this%start_time)
then
315 do i = 1, this%n_avg_fields
316 call this%mean_fields(i)%update(
real(time%t - this%time, kind=
rp) )
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.
Utilities for retrieving parameters from the case files.
Defines an output for a list of mean fields.
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 restart_(this, time)
Dummy restart function.
subroutine compute_(this, time)
Dummy compute function.
Contains the time_based_controller_t type.
Module with things related to the simulation time.
Implements the user_stats_t type.
subroutine user_stats_free(this)
Destructor.
subroutine user_stats_compute(this, time)
Update the running averages.
subroutine user_stats_restart(this, time)
subroutine user_stats_init_from_controllers_properties(this, name, case, order, preprocess_control, preprocess_value, compute_control, compute_value, output_control, output_value, start_time, coef, avg_dir, filename, precision)
Constructor from components, passing properties to the time_based_controller` components in the base ...
subroutine user_stats_init_from_json(this, json, case)
Constructor from json.
subroutine user_stats_init_common(this, name, start_time, coef, avg_dir, filename, precision)
Common part of constructors.
subroutine user_stats_init_from_controllers(this, name, case, order, preprocess_controller, compute_controller, output_controller, start_time, coef, avg_dir, filename, precision)
Constructor from components, passing controllers.
integer, parameter, public neko_fname_len
subroutine, public filename_suffix(fname, suffix)
Extract a filename's suffix.
integer, parameter, public neko_varname_len
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Computes the temporal mean of a field.
Output for a list of mean fields.
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.
A simulation component that computes the averages of fields in the registry.