37 use json_module,
only : json_file
52 use mpi_f08,
only : mpi_wtime, mpi_barrier
66 real(kind=
rp) :: start_time
68 character(len=:),
allocatable :: base_filename
71 generic :: init_from_components => &
72 init_from_components_alphat, &
73 init_from_components_nut
77 procedure, pass(this) :: init_from_components_alphat => &
80 procedure, pass(this) :: init_from_components_nut => &
99 type(json_file),
intent(inout) :: json
100 class(
case_t),
intent(inout),
target :: case
101 type(json_file) :: json_subdict
102 character(len=:),
allocatable :: filename
103 character(len=NEKO_VARNAME_LEN),
allocatable :: fields(:)
104 character(len=:),
allocatable :: hom_dir
105 character(len=:),
allocatable :: sname
106 character(len=:),
allocatable :: name
107 real(kind=
rp) :: start_time
108 type(
coef_t),
pointer :: coef
109 character(len=:),
allocatable :: alphat_field, nut_field
110 real(kind=
rp) :: pr_turb
111 logical :: nut_dependency
116 name,
"scalar_sgs_stats_" // trim(sname))
118 call this%init_base(json,
case)
124 call json_get(json,
'alphat', json_subdict)
125 call json_get(json_subdict,
'nut_dependency', nut_dependency)
126 if (nut_dependency)
then
128 call json_get(json_subdict,
'nut_field', nut_field)
130 call json_get(json_subdict,
'alphat_field', alphat_field)
133 coef =>
case%fluid%c_Xh
136 if (json%valid_path(
"output_filename"))
then
137 call json_get(json,
"output_filename", filename)
138 if (nut_dependency)
then
139 call this%init_from_components(name, sname, coef, &
140 start_time, hom_dir, nut_field, pr_turb, filename)
142 call this%init_from_components(name, sname, coef, &
143 start_time, hom_dir, alphat_field, filename)
146 if (nut_dependency)
then
147 call this%init_from_components(name, sname, coef, &
148 start_time, hom_dir, nut_field, pr_turb, &
149 "scalar_sgs_stats_"//trim(sname))
151 call this%init_from_components(name, sname, coef, &
152 start_time, hom_dir, alphat_field, &
153 "scalar_sgs_stats_"//trim(sname))
167 name, sname, coef, start_time, hom_dir, alphat_field, fname)
169 character(len=*),
intent(in) :: name
170 character(len=*),
intent(in) :: sname
171 character(len=*),
intent(in) :: hom_dir
172 real(kind=
rp),
intent(in) :: start_time
173 type(
coef_t),
intent(in),
target :: coef
174 character(len=*),
intent(in) :: alphat_field
175 character(len=*),
intent(in) :: fname
176 character(len=NEKO_FNAME_LEN) :: stats_fname
177 character(len=LOG_SIZE) :: log_buf
178 character(len=5) :: prefix
180 call neko_log%section(
'Scalar SGS stats')
181 write(log_buf,
'(A,A)')
'Scalar field: ', trim(sname)
183 write(log_buf,
'(A,A)')
'Eddy diffusivity field: ', trim(alphat_field)
185 write(log_buf,
'(A,E15.7)')
'Start time: ', start_time
187 write(log_buf,
'(A,A)')
'Averaging in direction: ', trim(hom_dir)
190 call this%stats%init(coef, sname, alphat_field)
193 this%start_time = start_time
194 this%time = start_time
195 this%base_filename = fname
196 stats_fname = trim(fname) //
"0"
198 call this%stats_output%init(this%stats, this%start_time, &
199 hom_dir = hom_dir, name = stats_fname, &
200 path = this%case%output_directory)
202 call this%case%output_controller%add(this%stats_output, &
203 this%output_controller%control_value, &
204 this%output_controller%control_mode)
220 name, sname, coef, start_time, hom_dir, nut_field, pr_turb, fname)
222 character(len=*),
intent(in) :: name
223 character(len=*),
intent(in) :: sname
224 character(len=*),
intent(in) :: hom_dir
225 real(kind=
rp),
intent(in) :: start_time
226 type(
coef_t),
intent(in),
target :: coef
227 character(len=*),
intent(in) :: nut_field
228 real(kind=
rp),
intent(in) :: pr_turb
229 character(len=*),
intent(in),
optional :: fname
230 character(len=NEKO_FNAME_LEN) :: stats_fname
231 character(len=LOG_SIZE) :: log_buf
232 character(len=5) :: prefix
234 call neko_log%section(
'scalar stats')
235 write(log_buf,
'(A,A)')
'Scalar field: ', trim(sname)
237 write(log_buf,
'(A,A)')
'Eddy viscosity field: ', trim(nut_field)
239 write(log_buf,
'(A,E15.7)')
'Turbulent Prandtl number: ', pr_turb
241 write(log_buf,
'(A,E15.7)')
'Start time: ', start_time
243 write(log_buf,
'(A,A)')
'Averaging in direction: ', trim(hom_dir)
247 call this%stats%init(coef, sname, nut_field, pr_turb)
250 this%start_time = start_time
251 this%time = start_time
252 this%base_filename = fname
253 stats_fname = trim(fname) //
"0"
255 call this%stats_output%init(this%stats, this%start_time, &
256 hom_dir = hom_dir, name = stats_fname, &
257 path = this%case%output_directory)
259 call this%case%output_controller%add(this%stats_output, &
260 this%output_controller%control_value, &
261 this%output_controller%control_mode)
270 call this%free_base()
271 call this%stats%free()
272 call this%stats_output%free()
278 character(len=NEKO_FNAME_LEN) :: fname
279 character(len=5) :: prefix, suffix
280 integer :: last_slash_pos
282 character(len=NEKO_FNAME_LEN) :: basename
286 if (t .gt. this%time) this%time = t
288 fname = this%stats_output%file_%get_base_fname()
289 write (prefix,
'(I5)') &
290 this%stats_output%file_%file_type%get_start_counter()
295 if (last_slash_pos .ne. 0)
then
297 trim(fname(1:last_slash_pos))// &
298 trim(this%base_filename)// &
299 trim(adjustl(prefix))//
"."//suffix
301 fname = trim(this%base_filename)// &
302 trim(adjustl(prefix))//
"."//suffix
304 call this%stats_output%init_base(fname)
312 real(kind=
rp) :: delta_t, t
313 real(kind=
rp) :: sample_start_time, sample_time
314 character(len=LOG_SIZE) :: log_buf
317 if (time%start_time .gt. this%start_time)
then
318 write(log_buf,
'(A)')
'Simulation start time is later than the ' &
319 //
'scalar stats start time.'
321 write(log_buf,
'(A,E15.7)')
'Simulation start time:', time%start_time
323 write(log_buf,
'(A,E15.7)')
'scalar stats start time:', this%start_time
325 write(log_buf,
'(A)')
'Assigning the statistics start time to ' &
326 //
'the simulation start time.'
328 this%start_time = time%start_time
329 this%time = time%start_time
334 if (t .ge. this%start_time)
then
335 delta_t = t - this%time
339 sample_start_time = mpi_wtime()
341 call this%stats%update(delta_t)
345 sample_time = mpi_wtime() - sample_start_time
347 call neko_log%section(
'scalar stats')
348 write(log_buf,
'(A,E15.7)')
'Sampling at time:', t
350 write(log_buf,
'(A33,E15.7)')
'Simulation time since last sample:', &
353 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_alphat(this, name, sname, coef, start_time, hom_dir, alphat_field, fname)
Actual constructor using directly the alphat field.
subroutine scalar_sgs_stats_simcomp_init_from_components_nut(this, name, sname, 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_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.
subroutine, public filename_name(fname, name)
Extract the base name of a file (without path and suffix)
integer, parameter, public neko_fname_len
subroutine, public filename_suffix(fname, suffix)
Extract a filename's suffix.
integer, parameter, public neko_varname_len
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.