38 use json_module,
only : json_file
58 real(kind=
rp) :: start_time
64 integer :: n_avg_fields = 0
66 character(len=NEKO_VARNAME_LEN),
allocatable :: field_names(:)
69 logical :: default_fname = .true.
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 => &
100 type(json_file),
intent(inout) :: json
101 class(
case_t),
intent(inout),
target :: case
102 character(len=:),
allocatable :: filename
103 character(len=:),
allocatable :: avg_dir
104 character(len=:),
allocatable :: name
107 call this%init_base(json,
case)
110 call json%info(
'fields', n_children = this%n_avg_fields)
111 call json_get(json,
'fields', this%field_names)
115 if (json%valid_path(
'output_filename'))
then
116 call json_get(json,
'output_filename', filename)
118 case%fluid%c_Xh, avg_dir, filename = filename)
121 case%fluid%c_Xh, avg_dir)
129 character(len=NEKO_FNAME_LEN) :: fname
130 character(len=5) :: prefix, suffix
131 integer :: last_slash_pos
134 if (t .gt. this%time) this%time = t
135 if (this%default_fname)
then
136 fname = this%output%file_%get_base_fname()
137 write (prefix,
'(I5)') &
138 this%output%file_%file_type%get_start_counter()
142 if (last_slash_pos .ne. 0)
then
144 trim(fname(1:last_slash_pos))// &
145 "user_stats"//trim(adjustl(prefix))//
"."//suffix
147 fname =
"user_stats"// &
148 trim(adjustl(prefix))//
"."//suffix
150 call this%output%init_base(fname)
168 preprocess_controller, compute_controller, output_controller, &
169 start_time, coef, avg_dir, filename, precision)
171 character(len=*),
intent(in) :: name
172 class(
case_t),
intent(inout),
target :: case
177 real(kind=
rp),
intent(in) :: start_time
178 character(len=*),
intent(in) :: avg_dir
179 type(
coef_t),
intent(inout) :: coef
180 character(len=*),
intent(in),
optional :: filename
181 integer,
intent(in),
optional :: precision
183 call this%init_base_from_components(
case, order, preprocess_controller, &
185 call this%init_common(name, start_time, coef, avg_dir, filename, precision)
208 case, order, preprocess_control, preprocess_value, compute_control, &
209 compute_value, output_control, output_value, start_time, coef, avg_dir, &
212 character(len=*),
intent(in) :: name
213 class(
case_t),
intent(inout),
target :: case
215 character(len=*),
intent(in) :: preprocess_control
216 real(kind=
rp),
intent(in) :: preprocess_value
217 character(len=*),
intent(in) :: compute_control
218 real(kind=
rp),
intent(in) :: compute_value
219 character(len=*),
intent(in) :: output_control
220 real(kind=
rp),
intent(in) :: output_value
221 real(kind=
rp),
intent(in) :: start_time
222 character(len=*),
intent(in) :: avg_dir
223 type(
coef_t),
intent(inout) :: coef
224 character(len=*),
intent(in),
optional :: filename
225 integer,
intent(in),
optional :: precision
227 call this%init_base_from_components(
case, order, preprocess_control, &
228 preprocess_value, compute_control, compute_value, output_control, &
230 call this%init_common(name, start_time, coef, avg_dir, filename, precision)
243 character(len=*),
intent(in) :: name
244 character(len=*),
intent(in),
optional :: filename
245 integer,
intent(in),
optional :: precision
246 real(kind=
rp),
intent(in) :: start_time
247 character(len=*),
intent(in) :: avg_dir
248 type(
coef_t),
intent(inout) :: coef
250 type(
field_t),
pointer :: field_to_avg
251 character(len=NEKO_FNAME_LEN) :: stats_fname
253 character(len=1024) :: unique_name
254 unique_name = name //
"/"
257 this%start_time = start_time
258 this%time = start_time
260 if (
present(filename))
then
261 this%default_fname = .false.
262 stats_fname = filename
264 stats_fname =
"user_stats0"
265 this%default_fname = .true.
269 allocate(this%mean_fields(this%n_avg_fields))
270 do i = 1, this%n_avg_fields
271 field_to_avg =>
neko_registry%get_field(trim(this%field_names(i)))
272 call this%mean_fields(i)%init(field_to_avg, trim(unique_name) // &
273 "mean_" // trim(this%field_names(i)))
276 call this%output%init(this%mean_fields, this%n_avg_fields, &
277 this%start_time, coef, avg_dir, name = filename)
278 call this%case%output_controller%add(this%output, &
279 this%output_controller%control_value, &
280 this%output_controller%control_mode)
288 call this%free_base()
290 if (
allocated(this%mean_fields))
then
291 do i = 1, this%n_avg_fields
292 call this%mean_fields(i)%free()
294 deallocate(this%mean_fields)
297 if (
allocated(this%field_names))
then
298 deallocate(this%field_names)
311 if (time%t .ge. this%start_time)
then
312 do i = 1, this%n_avg_fields
313 call this%mean_fields(i)%update(time%t - this%time)
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
pure integer function, public filename_tslash_pos(fname)
Find position (in the string) of a filename's trailing slash.
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.