37 use json_module,
only : json_file
51 use mpi_f08,
only : mpi_wtime, mpi_barrier
69 real(kind=
dp) :: start_time
72 character(len=:),
allocatable :: base_filename
78 procedure, pass(this) :: init_from_components => &
97 type(json_file),
intent(inout) :: json
98 class(
case_t),
intent(inout),
target :: case
99 character(len=:),
allocatable :: filename
100 character(len=NEKO_VARNAME_LEN),
allocatable :: fields(:)
101 character(len=:),
allocatable :: hom_dir
102 character(len=:),
allocatable :: stat_set
103 character(len=:),
allocatable :: sname
104 character(len=:),
allocatable :: name
105 real(kind=
dp) :: start_time
106 type(
field_t),
pointer :: s, u, v, w, p
107 type(
coef_t),
pointer :: coef
112 name,
"scalar_stats_" // trim(sname))
114 call this%init_base(json,
case)
127 coef =>
case%fluid%c_Xh
130 if (json%valid_path(
"output_filename"))
then
131 call json_get(json,
"output_filename", filename)
133 p, coef, start_time, hom_dir, stat_set, filename)
136 p, coef, start_time, hom_dir, stat_set,
"scalar_stats_" // &
140 nullify(s, u, v, w, p, coef)
156 p, coef, start_time, hom_dir, stat_set, fname)
158 character(len=*),
intent(in) :: name
159 character(len=*),
intent(in) :: hom_dir
160 character(len=*),
intent(in) :: stat_set
161 real(kind=
dp),
intent(in) :: start_time
162 type(
field_t),
intent(in),
target :: s, u, v, w, p
163 type(
coef_t),
intent(in),
target :: coef
164 character(len=*),
intent(in) :: fname
165 character(len=NEKO_FNAME_LEN) :: stats_fname
166 character(len=LOG_SIZE) :: log_buf
167 character(len=5) :: prefix
170 call neko_log%section(
'Scalar stats')
171 write(log_buf,
'(A,A)')
'Scalar field: ', trim(s%name)
173 write(log_buf,
'(A,E15.7)')
'Start time: ', start_time
175 write(log_buf,
'(A,A)')
'Set of statistics: ', trim(stat_set)
177 write(log_buf,
'(A,A)')
'Averaging in direction: ', trim(hom_dir)
181 call this%stats%init(coef, s, u, v, w, p, stat_set, name)
183 this%start_time = start_time
184 this%time = start_time
185 this%base_filename = fname
186 stats_fname = trim(fname) //
"0"
188 call this%stats_output%init(this%stats, this%start_time, &
189 hom_dir = hom_dir, name = stats_fname, &
190 path = this%case%output_directory)
192 call this%case%output_controller%add(this%stats_output, &
193 this%output_controller%control_value, &
194 this%output_controller%control_mode)
203 call this%free_base()
204 call this%stats%free()
210 character(len=NEKO_FNAME_LEN) :: fname
211 character(len=5) :: prefix, suffix
215 if (t .gt. this%time) this%time = t
217 fname = this%stats_output%file_%get_base_fname()
218 write (prefix,
'(I0)') &
219 this%stats_output%file_%file_type%get_start_counter()
221 fname = trim(this%case%output_directory) // &
222 trim(this%base_filename) // trim(prefix) //
"." // trim(suffix)
223 call this%stats_output%init_base(fname)
232 real(kind=
rp) :: delta_t
233 real(kind=
dp) :: sample_start_time, sample_time, t
234 character(len=LOG_SIZE) :: log_buf
237 if (time%start_time .gt. this%start_time)
then
238 write(log_buf,
'(A)')
'Simulation start time is later than the ' &
239 //
'scalar stats start time.'
241 write(log_buf,
'(A,E15.7)')
'Simulation start time:', time%start_time
243 write(log_buf,
'(A,E15.7)')
'Scalar stats start time:', this%start_time
245 write(log_buf,
'(A)')
'Assigning the statistics start time to ' &
246 //
'the simulation start time.'
248 this%start_time = time%start_time
249 this%time = time%start_time
254 if (t .ge. this%start_time)
then
255 delta_t =
real(t - this%time, kind=
rp)
259 sample_start_time = mpi_wtime()
261 call this%stats%update(delta_t)
265 sample_time = mpi_wtime() - sample_start_time
267 call neko_log%section(
'Scalar stats')
268 write(log_buf,
'(A,E15.7)')
'Sampling at time:', t
270 write(log_buf,
'(A33,E15.7)')
'Simulationtime since last sample:', &
273 write(log_buf,
'(A,E15.7)')
'Sampling time (s):', sample_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.
type(mpi_comm), public neko_comm
MPI communicator.
Utilities for retrieving parameters from the case files.
type(log_t), public neko_log
Global log stream.
integer, parameter, public log_size
integer, parameter, public dp
integer, parameter, public sp
integer, parameter, public rp
Global precision used in computations.
Defines a registry for storing solution fields.
type(registry_t), target, public neko_registry
Global field registry.
Implements scalar_stats_ouput_t.
Implements the scalar_stats_simcomp_t type.
subroutine scalar_stats_simcomp_free(this)
Destructor.
subroutine scalar_stats_simcomp_init_from_json(this, json, case)
Constructor from json.
subroutine scalar_stats_simcomp_restart(this, time)
subroutine scalar_stats_simcomp_init_from_components(this, name, s, u, v, w, p, coef, start_time, hom_dir, stat_set, fname)
Actual constructor.
subroutine scalar_stats_simcomp_compute(this, time)
scalar_stats, called depending on compute_control and compute_value
Computes various statistics for the scalar fields. We use the Reynolds decomposition for a field u = ...
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.
Defines a container for all statistics.
Module with things related to the simulation time.
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,...
Defines an output for the scalar statistics computed using the scalar_stats_t object.
A simulation component that computes the scalar statistics for the skewness, kurtosis,...
Base abstract class for simulation components.
A struct that contains all info about the time, expand as needed.