38 use json_module,
only : json_file
57 real(kind=
rp) :: start_time
63 integer :: n_avg_fields = 0
65 character(len=NEKO_VARNAME_LEN),
allocatable :: field_names(:)
73 generic :: init_from_components => &
74 init_from_controllers, init_from_controllers_properties
76 procedure, pass(this) :: init_from_controllers => &
80 procedure, pass(this) :: init_from_controllers_properties => &
98 type(json_file),
intent(inout) :: json
99 class(
case_t),
intent(inout),
target :: case
100 character(len=:),
allocatable :: filename
101 character(len=:),
allocatable :: avg_dir
102 character(len=:),
allocatable :: name
105 call this%init_base(json,
case)
108 call json%info(
'fields', n_children = this%n_avg_fields)
109 call json_get(json,
'fields', this%field_names)
115 case%fluid%c_Xh, avg_dir, filename = filename)
122 if (time%t .gt. this%time) this%time = time%t
139 preprocess_controller, compute_controller, output_controller, &
140 start_time, coef, avg_dir, filename, precision)
142 character(len=*),
intent(in) :: name
143 class(
case_t),
intent(inout),
target :: case
148 real(kind=
rp),
intent(in) :: start_time
149 character(len=*),
intent(in) :: avg_dir
150 type(
coef_t),
intent(inout) :: coef
151 character(len=*),
intent(in),
optional :: filename
152 integer,
intent(in),
optional :: precision
154 call this%init_base_from_components(
case, order, preprocess_controller, &
156 call this%init_common(name, start_time, coef, avg_dir, filename, precision)
179 case, order, preprocess_control, preprocess_value, compute_control, &
180 compute_value, output_control, output_value, start_time, coef, avg_dir, &
183 character(len=*),
intent(in) :: name
184 class(
case_t),
intent(inout),
target :: case
186 character(len=*),
intent(in) :: preprocess_control
187 real(kind=
rp),
intent(in) :: preprocess_value
188 character(len=*),
intent(in) :: compute_control
189 real(kind=
rp),
intent(in) :: compute_value
190 character(len=*),
intent(in) :: output_control
191 real(kind=
rp),
intent(in) :: output_value
192 real(kind=
rp),
intent(in) :: start_time
193 character(len=*),
intent(in) :: avg_dir
194 type(
coef_t),
intent(inout) :: coef
195 character(len=*),
intent(in),
optional :: filename
196 integer,
intent(in),
optional :: precision
198 call this%init_base_from_components(
case, order, preprocess_control, &
199 preprocess_value, compute_control, compute_value, output_control, &
201 call this%init_common(name, start_time, coef, avg_dir, filename, precision)
214 character(len=*),
intent(in) :: name
215 character(len=*),
intent(in) :: filename
216 integer,
intent(in),
optional :: precision
217 real(kind=
rp),
intent(in) :: start_time
218 character(len=*),
intent(in) :: avg_dir
219 type(
coef_t),
intent(inout) :: coef
221 type(
field_t),
pointer :: field_to_avg
223 character(len=1024) :: unique_name
224 unique_name = name //
"/"
227 this%start_time = start_time
228 this%time = start_time
231 allocate(this%mean_fields(this%n_avg_fields))
232 do i = 1, this%n_avg_fields
233 field_to_avg =>
neko_registry%get_field(trim(this%field_names(i)))
234 call this%mean_fields(i)%init(field_to_avg, trim(unique_name) // &
235 "mean_" // trim(this%field_names(i)))
238 call this%output%init(this%mean_fields, this%n_avg_fields, &
239 this%start_time, coef, avg_dir, name = filename)
240 call this%case%output_controller%add(this%output, &
241 this%output_controller%control_value, &
242 this%output_controller%control_mode)
250 call this%free_base()
252 if (
allocated(this%mean_fields))
then
253 do i = 1, this%n_avg_fields
254 call this%mean_fields(i)%free()
256 deallocate(this%mean_fields)
259 if (
allocated(this%field_names))
then
260 deallocate(this%field_names)
273 if (time%t .ge. this%start_time)
then
274 do i = 1, this%n_avg_fields
275 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_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.