37 use json_module,
only : json_file
69 real(kind=
rp) :: start_time
71 logical :: default_fname = .true.
77 procedure, pass(this) :: init_from_components => &
96 type(json_file),
intent(inout) :: json
97 class(
case_t),
intent(inout),
target :: case
98 character(len=:),
allocatable :: filename
99 character(len=20),
allocatable :: fields(:)
100 character(len=:),
allocatable :: hom_dir
101 character(len=:),
allocatable :: stat_set
102 real(kind=
rp) :: start_time
103 type(
field_t),
pointer :: u, v, w, p
104 type(
coef_t),
pointer :: coef
106 call this%init_base(json,
case)
119 coef =>
case%fluid%c_Xh
121 if (json%valid_path(
"output_filename"))
then
122 call json_get(json,
"output_filename", filename)
124 start_time, hom_dir, stat_set,filename)
127 start_time, hom_dir, stat_set)
141 start_time, hom_dir, stat_set, fname)
143 character(len=*),
intent(in) :: hom_dir
144 character(len=*),
intent(in) :: stat_set
145 real(kind=
rp),
intent(in) :: start_time
146 type(
field_t),
intent(in) :: u, v, w, p
147 type(
coef_t),
intent(in) :: coef
148 character(len=*),
intent(in),
optional :: fname
149 character(len=NEKO_FNAME_LEN) :: stats_fname
150 character(len=LOG_SIZE) :: log_buf
151 character(len=5) :: prefix
153 call neko_log%section(
'Fluid stats')
154 write(log_buf,
'(A,E15.7)')
'Start time: ', start_time
156 write(log_buf,
'(A,A)')
'Set of statistics: ', trim(stat_set)
158 write(log_buf,
'(A,A)')
'Averaging in direction: ', trim(hom_dir)
162 call this%stats%init(coef, u, v, w, p, stat_set)
164 this%start_time = start_time
165 this%time = start_time
166 if (
present(fname))
then
167 this%default_fname = .false.
170 stats_fname =
"fluid_stats0"
171 this%default_fname = .true.
174 call this%stats_output%init(this%stats, this%start_time, &
175 hom_dir = hom_dir,name = stats_fname, &
176 path = this%case%output_directory)
178 call this%case%output_controller%add(this%stats_output, &
179 this%output_controller%control_value, &
180 this%output_controller%control_mode)
189 call this%free_base()
190 call this%stats%free()
196 character(len=NEKO_FNAME_LEN) :: fname
197 character(len=5) :: prefix,suffix
198 integer :: last_slash_pos
201 if (t .gt. this%time) this%time = t
202 if (this%default_fname)
then
203 write (prefix,
'(I5)') this%stats_output%file_%get_counter()
207 if (last_slash_pos .ne. 0)
then
209 trim(this%stats_output%file_%file_type%fname(1:last_slash_pos))// &
210 "fluid_stats"//trim(adjustl(prefix))//
"."//suffix
212 fname =
"fluid_stats"// &
213 trim(adjustl(prefix))//
"."//suffix
215 call this%stats_output%init_base(fname)
225 real(kind=
rp) :: delta_t, t
226 real(kind=
rp) :: sample_start_time, sample_time
227 character(len=LOG_SIZE) :: log_buf
232 if (t .ge. this%start_time)
then
233 delta_t = t - this%time
237 sample_start_time = mpi_wtime()
239 call this%stats%update(delta_t)
243 sample_time = mpi_wtime() - sample_start_time
245 call neko_log%section(
'Fluid stats')
246 write(log_buf,
'(A,E15.7)')
'Sampling at time:', t
248 write(log_buf,
'(A33,E15.7)')
'Simulationtime since last sample:', &
251 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) neko_comm
MPI communicator.
Defines a registry for storing solution fields.
type(field_registry_t), target, public neko_field_registry
Global field registry.
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, 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.
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.