37 use json_module,
only : json_file
50 use mpi_f08,
only : mpi_wtime, mpi_barrier
64 real(kind=
rp) :: start_time
66 logical :: default_fname = .true.
72 procedure, pass(this) :: init_from_components => &
91 type(json_file),
intent(inout) :: json
92 class(
case_t),
intent(inout),
target :: case
93 character(len=:),
allocatable :: filename
94 character(len=20),
allocatable :: fields(:)
95 character(len=:),
allocatable :: hom_dir
96 character(len=:),
allocatable :: nut_field
97 character(len=:),
allocatable :: name
98 real(kind=
rp) :: start_time
99 type(
field_t),
pointer :: u, v, w
100 type(
coef_t),
pointer :: coef
103 call this%init_base(json,
case)
115 coef =>
case%fluid%c_Xh
118 if (json%valid_path(
"output_filename"))
then
119 call json_get(json,
"output_filename", filename)
121 start_time, hom_dir, nut_field, filename)
124 start_time, hom_dir, nut_field)
139 start_time, hom_dir, nut_field, fname)
141 character(len=*),
intent(in) :: hom_dir
142 character(len=*),
intent(in) :: nut_field
143 real(kind=
rp),
intent(in) :: start_time
144 type(
field_t),
intent(in),
target :: u, v, w
145 type(
coef_t),
intent(in),
target :: coef
146 character(len=*),
intent(in),
optional :: fname
147 character(len=NEKO_FNAME_LEN) :: stats_fname
148 character(len=LOG_SIZE) :: log_buf
149 character(len=5) :: prefix
151 call neko_log%section(
'Fluid stats')
152 write(log_buf,
'(A,E15.7)')
'Start time: ', start_time
154 write(log_buf,
'(A,A)')
'Nut field name: ', trim(nut_field)
156 write(log_buf,
'(A,A)')
'Averaging in direction: ', trim(hom_dir)
160 call this%stats%init(coef, u, v, w, nut_field)
162 this%start_time = start_time
163 this%time = start_time
164 if (
present(fname))
then
165 this%default_fname = .false.
168 stats_fname =
"fluid_sgs_stats0"
169 this%default_fname = .true.
172 call this%stats_output%init(this%stats, this%start_time, &
173 hom_dir = hom_dir, name = stats_fname, &
174 path = this%case%output_directory)
176 call this%case%output_controller%add(this%stats_output, &
177 this%output_controller%control_value, &
178 this%output_controller%control_mode)
187 call this%free_base()
188 call this%stats%free()
189 call this%stats_output%free()
195 character(len=NEKO_FNAME_LEN) :: fname
196 character(len=5) :: prefix, suffix
197 integer :: last_slash_pos
200 if (t .gt. this%time) this%time = t
201 if (this%default_fname)
then
202 fname = this%stats_output%file_%get_base_fname()
203 write (prefix,
'(I5)') this%stats_output%file_%get_counter()
207 if (last_slash_pos .ne. 0)
then
209 trim(fname(1:last_slash_pos))// &
210 "fluid_sgs_stats"//trim(adjustl(prefix))//
"."//suffix
212 fname =
"fluid_sgs_stats"// &
213 trim(adjustl(prefix))//
"."//suffix
215 call this%stats_output%init_base(fname)
224 real(kind=
rp) :: delta_t, t
225 real(kind=
rp) :: sample_start_time, sample_time
226 character(len=LOG_SIZE) :: log_buf
229 if (time%start_time .gt. this%start_time)
then
230 write(log_buf,
'(A)')
'Simulation start time is later than the ' &
231 //
'fluid stats start time.'
233 write(log_buf,
'(A,E15.7)')
'Simulation start time:', time%start_time
235 write(log_buf,
'(A,E15.7)')
'Fluid stats start time:', this%start_time
237 write(log_buf,
'(A)')
'Assigning the statistics start time to ' &
238 //
'the simulation start time.'
240 this%start_time = time%start_time
241 this%time = time%start_time
246 if (t .ge. this%start_time)
then
247 delta_t = t - this%time
251 sample_start_time = mpi_wtime()
253 call this%stats%update(delta_t)
257 sample_time = mpi_wtime() - sample_start_time
259 call neko_log%section(
'Fluid SGS stats')
260 write(log_buf,
'(A,E15.7)')
'Sampling at time:', t
262 write(log_buf,
'(A33,E15.7)')
'Simulation time since last sample:', &
265 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_sgs_stats_ouput_t.
Implements the fluid_sgs_stats_simcomp_t type.
subroutine fluid_sgs_stats_simcomp_init_from_components(this, u, v, w, coef, start_time, hom_dir, nut_field, fname)
Actual constructor.
subroutine fluid_sgs_stats_simcomp_compute(this, time)
fluid_sgs_stats, called depending on compute_control and compute_value
subroutine fluid_sgs_stats_simcomp_restart(this, time)
subroutine fluid_sgs_stats_simcomp_free(this)
Destructor.
subroutine fluid_sgs_stats_simcomp_init_from_json(this, json, case)
Constructor from json.
Computes the subgrid-scale contributions for Reynolds stresses. We use the Reynolds decomposition for...
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 sgs statistics for fluid computed using the fluid_sgs_stats_t object.
A simulation component that computes the subgrid-scale contributions to the Reynolds stresses in LES.
Base abstract class for simulation components.
A struct that contains all info about the time, expand as needed.