37 use json_module,
only : json_file
51 use mpi_f08,
only : mpi_wtime, mpi_barrier
71 real(kind=
rp) :: start_time
73 logical :: default_fname = .true.
79 procedure, pass(this) :: init_from_components => &
98 type(json_file),
intent(inout) :: json
99 class(
case_t),
intent(inout),
target :: case
100 character(len=:),
allocatable :: filename
101 character(len=20),
allocatable :: fields(:)
102 character(len=:),
allocatable :: hom_dir
103 character(len=:),
allocatable :: stat_set
104 character(len=:),
allocatable :: name
105 real(kind=
rp) :: start_time
106 type(
field_t),
pointer :: u, v, w, p
107 type(
coef_t),
pointer :: coef
110 call this%init_base(json,
case)
123 coef =>
case%fluid%c_Xh
126 if (json%valid_path(
"output_filename"))
then
127 call json_get(json,
"output_filename", filename)
129 coef, start_time, hom_dir, stat_set, filename)
132 coef, start_time, hom_dir, stat_set)
148 coef, start_time, hom_dir, stat_set, fname)
150 character(len=*),
intent(in) :: name
151 character(len=*),
intent(in) :: hom_dir
152 character(len=*),
intent(in) :: stat_set
153 real(kind=
rp),
intent(in) :: start_time
154 type(
field_t),
intent(in),
target :: u, v, w, p
155 type(
coef_t),
intent(in),
target :: coef
156 character(len=*),
intent(in),
optional :: fname
157 character(len=NEKO_FNAME_LEN) :: stats_fname
158 character(len=LOG_SIZE) :: log_buf
159 character(len=5) :: prefix
161 call neko_log%section(
'Fluid stats')
162 write(log_buf,
'(A,E15.7)')
'Start time: ', start_time
164 write(log_buf,
'(A,A)')
'Set of statistics: ', trim(stat_set)
166 write(log_buf,
'(A,A)')
'Averaging in direction: ', trim(hom_dir)
169 call this%stats%init(coef, u, v, w, p, stat_set, name)
172 this%start_time = start_time
173 this%time = start_time
174 if (
present(fname))
then
175 this%default_fname = .false.
178 stats_fname =
"fluid_stats0"
179 this%default_fname = .true.
182 call this%stats_output%init(this%stats, this%start_time, &
183 hom_dir = hom_dir, name = stats_fname, &
184 path = this%case%output_directory)
186 call this%case%output_controller%add(this%stats_output, &
187 this%output_controller%control_value, &
188 this%output_controller%control_mode)
197 call this%free_base()
198 call this%stats%free()
199 call this%stats_output%free()
205 character(len=NEKO_FNAME_LEN) :: fname
206 character(len=5) :: prefix, suffix
207 integer :: last_slash_pos
210 if (t .gt. this%time) this%time = t
211 if (this%default_fname)
then
212 fname = this%stats_output%file_%get_base_fname()
213 write (prefix,
'(I5)') this%stats_output%file_%get_counter()
217 if (last_slash_pos .ne. 0)
then
219 trim(fname(1:last_slash_pos))// &
220 "fluid_stats"//trim(adjustl(prefix))//
"."//suffix
222 fname =
"fluid_stats"// &
223 trim(adjustl(prefix))//
"."//suffix
225 call this%stats_output%init_base(fname)
234 real(kind=
rp) :: delta_t, t
235 real(kind=
rp) :: sample_start_time, sample_time
236 character(len=LOG_SIZE) :: log_buf
239 if (time%start_time .gt. this%start_time)
then
240 write(log_buf,
'(A)')
'Simulation start time is later than the ' &
241 //
'fluid stats start time.'
243 write(log_buf,
'(A,E15.7)')
'Simulation start time:', time%start_time
245 write(log_buf,
'(A,E15.7)')
'Fluid stats start time:', this%start_time
247 write(log_buf,
'(A)')
'Assigning the statistics start time to ' &
248 //
'the simulation start time.'
250 this%start_time = time%start_time
251 this%time = time%start_time
256 if (t .ge. this%start_time)
then
257 delta_t = t - this%time
261 sample_start_time = mpi_wtime()
263 call this%stats%update(delta_t)
267 sample_time = mpi_wtime() - sample_start_time
269 call neko_log%section(
'Fluid stats')
270 write(log_buf,
'(A,E15.7)')
'Sampling at time:', t
272 write(log_buf,
'(A33,E15.7)')
'Simulationtime since last sample:', &
275 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.
Implements fluid_stats_ouput_t.
Implements the fluid_stats_simcomp_t type.
subroutine fluid_stats_simcomp_free(this)
Destructor.
subroutine fluid_stats_simcomp_restart(this, time)
subroutine fluid_stats_simcomp_init_from_json(this, json, case)
Constructor from json.
subroutine fluid_stats_simcomp_compute(this, time)
fluid_stats, called depending on compute_control and compute_value
subroutine fluid_stats_simcomp_init_from_components(this, name, u, v, w, p, coef, start_time, hom_dir, stat_set, fname)
Actual constructor.
Computes various statistics for the fluid fields. We use the Reynolds decomposition for a field u = ...
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.
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.
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,...
Defines an output for the fluid statistics computed using the fluid_stats_t object.
A simulation component that computes the velocity and pressure statistics up to 4th order....
Base abstract class for simulation components.
A struct that contains all info about the time, expand as needed.