37 use json_module,
only : json_file
51 use mpi_f08,
only : mpi_wtime, mpi_barrier
65 real(kind=
rp) :: start_time
67 logical :: default_fname = .true.
70 generic :: init_from_components => &
71 init_from_components_alphat, &
72 init_from_components_nut
76 procedure, pass(this) :: init_from_components_alphat => &
79 procedure, pass(this) :: init_from_components_nut => &
98 type(json_file),
intent(inout) :: json
99 class(
case_t),
intent(inout),
target :: case
100 type(json_file) :: json_subdict
101 character(len=:),
allocatable :: filename
102 character(len=20),
allocatable :: fields(:)
103 character(len=:),
allocatable :: hom_dir
104 character(len=:),
allocatable :: s_name
105 character(len=:),
allocatable :: name
106 real(kind=
rp) :: start_time
107 type(
coef_t),
pointer :: coef
108 character(len=:),
allocatable :: alphat_field, nut_field
109 real(kind=
rp) :: pr_turb
110 logical :: nut_dependency
113 call this%init_base(json,
case)
121 call json_get(json,
'alphat', json_subdict)
122 call json_get(json_subdict,
'nut_dependency', nut_dependency)
123 if (nut_dependency)
then
125 call json_get(json_subdict,
'nut_field', nut_field)
127 call json_get(json_subdict,
'alphat_field', alphat_field)
130 coef =>
case%fluid%c_Xh
133 if (json%valid_path(
"output_filename"))
then
134 call json_get(json,
"output_filename", filename)
135 if (nut_dependency)
then
136 call this%init_from_components(s_name, coef, &
137 start_time, hom_dir, nut_field, pr_turb, filename)
139 call this%init_from_components(s_name, coef, &
140 start_time, hom_dir, alphat_field, filename)
143 if (nut_dependency)
then
144 call this%init_from_components(s_name, coef, &
145 start_time, hom_dir, nut_field, pr_turb)
147 call this%init_from_components(s_name, coef, &
148 start_time, hom_dir, alphat_field)
162 s_name, coef, start_time, hom_dir, alphat_field, fname)
164 character(len=*),
intent(in) :: s_name
165 character(len=*),
intent(in) :: hom_dir
166 real(kind=
rp),
intent(in) :: start_time
167 type(
coef_t),
intent(in),
target :: coef
168 character(len=*),
intent(in) :: alphat_field
169 character(len=*),
intent(in),
optional :: fname
170 character(len=NEKO_FNAME_LEN) :: stats_fname
171 character(len=LOG_SIZE) :: log_buf
172 character(len=5) :: prefix
174 call neko_log%section(
'scalar SGS stats')
175 write(log_buf,
'(A,A)')
'Scalar field: ', trim(s_name)
177 write(log_buf,
'(A,A)')
'Eddy diffusivity field: ', trim(alphat_field)
179 write(log_buf,
'(A,E15.7)')
'Start time: ', start_time
181 write(log_buf,
'(A,A)')
'Averaging in direction: ', trim(hom_dir)
185 call this%stats%init(coef, s_name, alphat_field)
187 this%start_time = start_time
188 this%time = start_time
189 if (
present(fname))
then
190 this%default_fname = .false.
193 stats_fname =
"scalar_sgs_stats0"
194 this%default_fname = .true.
197 call this%stats_output%init(this%stats, this%start_time, &
198 hom_dir = hom_dir, name = stats_fname, &
199 path = this%case%output_directory)
201 call this%case%output_controller%add(this%stats_output, &
202 this%output_controller%control_value, &
203 this%output_controller%control_mode)
219 s_name, coef, start_time, hom_dir, nut_field, pr_turb, fname)
221 character(len=*),
intent(in) :: s_name
222 character(len=*),
intent(in) :: hom_dir
223 real(kind=
rp),
intent(in) :: start_time
224 type(
coef_t),
intent(in),
target :: coef
225 character(len=*),
intent(in) :: nut_field
226 real(kind=
rp),
intent(in) :: pr_turb
227 character(len=*),
intent(in),
optional :: fname
228 character(len=NEKO_FNAME_LEN) :: stats_fname
229 character(len=LOG_SIZE) :: log_buf
230 character(len=5) :: prefix
232 call neko_log%section(
'scalar stats')
233 write(log_buf,
'(A,A)')
'Scalar field: ', trim(s_name)
235 write(log_buf,
'(A,A)')
'Eddy viscosity field: ', trim(nut_field)
237 write(log_buf,
'(A,E15.7)')
'Turbulent Prandtl number: ', pr_turb
239 write(log_buf,
'(A,E15.7)')
'Start time: ', start_time
241 write(log_buf,
'(A,A)')
'Averaging in direction: ', trim(hom_dir)
245 call this%stats%init(coef, s_name, nut_field, pr_turb)
247 this%start_time = start_time
248 this%time = start_time
249 if (
present(fname))
then
250 this%default_fname = .false.
253 stats_fname =
"scalar_sgs_stats0"
254 this%default_fname = .true.
257 call this%stats_output%init(this%stats, this%start_time, &
258 hom_dir = hom_dir, name = stats_fname, &
259 path = this%case%output_directory)
261 call this%case%output_controller%add(this%stats_output, &
262 this%output_controller%control_value, &
263 this%output_controller%control_mode)
272 call this%free_base()
273 call this%stats%free()
274 call this%stats_output%free()
280 character(len=NEKO_FNAME_LEN) :: fname
281 character(len=5) :: prefix, suffix
282 integer :: last_slash_pos
285 if (t .gt. this%time) this%time = t
286 if (this%default_fname)
then
287 fname = this%stats_output%file_%get_base_fname()
288 write (prefix,
'(I5)') this%stats_output%file_%get_counter()
292 if (last_slash_pos .ne. 0)
then
294 trim(fname(1:last_slash_pos))// &
295 "scalar_sgs_stats"//trim(adjustl(prefix))//
"."//suffix
297 fname =
"scalar_sgs_stats"// &
298 trim(adjustl(prefix))//
"."//suffix
300 call this%stats_output%init_base(fname)
309 real(kind=
rp) :: delta_t, t
310 real(kind=
rp) :: sample_start_time, sample_time
311 character(len=LOG_SIZE) :: log_buf
314 if (time%start_time .gt. this%start_time)
then
315 write(log_buf,
'(A)')
'Simulation start time is later than the ' &
316 //
'scalar stats start time.'
318 write(log_buf,
'(A,E15.7)')
'Simulation start time:', time%start_time
320 write(log_buf,
'(A,E15.7)')
'scalar stats start time:', this%start_time
322 write(log_buf,
'(A)')
'Assigning the statistics start time to ' &
323 //
'the simulation start time.'
325 this%start_time = time%start_time
326 this%time = time%start_time
331 if (t .ge. this%start_time)
then
332 delta_t = t - this%time
336 sample_start_time = mpi_wtime()
338 call this%stats%update(delta_t)
342 sample_time = mpi_wtime() - sample_start_time
344 call neko_log%section(
'scalar stats')
345 write(log_buf,
'(A,E15.7)')
'Sampling at time:', t
347 write(log_buf,
'(A33,E15.7)')
'Simulation time since last sample:', &
350 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_sgs_stats_ouput_t.
Implements the scalar_sgs_stats_simcomp_t type.
subroutine scalar_sgs_stats_simcomp_init_from_components_nut(this, s_name, coef, start_time, hom_dir, nut_field, pr_turb, fname)
Actual constructor using directly the nut field and the turbulent Prandtl number.
subroutine scalar_sgs_stats_simcomp_free(this)
Destructor.
subroutine scalar_sgs_stats_simcomp_init_from_components_alphat(this, s_name, coef, start_time, hom_dir, alphat_field, fname)
Actual constructor using directly the alphat field.
subroutine scalar_sgs_stats_simcomp_compute(this, time)
scalar_sgs_stats, called depending on compute_control and compute_value
subroutine scalar_sgs_stats_simcomp_init_from_json(this, json, case)
Constructor from json.
subroutine scalar_sgs_stats_simcomp_restart(this, time)
Computes the subgrid-scale contributions for the scalar fluxes. We use the Reynolds decomposition for...
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 scalar computed using the scalar_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.