40 use json_module,
only : json_file
68 type(
field_t),
pointer :: max_wave_speed => null()
71 real(kind=
rp) :: gamma
74 integer(kind=i8) :: glb_n_points
76 integer(kind=i8) :: glb_unique_points
87 procedure, pass(this) :: compute_cfl &
93 procedure, pass(this) :: compute_entropy => &
96 procedure, pass(this) :: compute_max_wave_speed => &
99 procedure, pass(this) :: log_solver_info => &
114 type(
mesh_t),
target,
intent(inout) :: msh
115 integer,
intent(in) :: lx
116 character(len=*),
intent(in) :: scheme
117 type(json_file),
target,
intent(inout) :: params
118 type(
user_t),
target,
intent(in) :: user
126 if (msh%gdim .eq. 2)
then
127 call this%Xh%init(
gll, lx, lx)
129 call this%Xh%init(
gll, lx, lx, lx)
132 call this%dm_Xh%init(msh, this%Xh)
134 call this%gs_Xh%init(this%dm_Xh)
136 call this%c_Xh%init(this%gs_Xh)
142 this%params => params
149 call neko_registry%add_field(this%dm_Xh, this%name //
"_rho")
161 call this%m_x%init(this%dm_Xh,
"m_x")
162 call this%m_y%init(this%dm_Xh,
"m_y")
163 call this%m_z%init(this%dm_Xh,
"m_z")
168 call this%E%init(this%dm_Xh,
"E")
172 this%max_wave_speed =>
neko_registry%get_field(
"max_wave_speed")
173 call this%max_wave_speed%init(this%dm_Xh,
"max_wave_speed")
178 call this%S%init(this%dm_Xh,
"S")
187 call this%u%init(this%dm_Xh,
"u")
188 call this%v%init(this%dm_Xh,
"v")
189 call this%w%init(this%dm_Xh,
"w")
192 call this%p%init(this%dm_Xh,
"p")
200 call this%f_x%init(this%dm_Xh, fld_name =
"fluid_rhs_x")
201 call this%f_y%init(this%dm_Xh, fld_name =
"fluid_rhs_y")
202 call this%f_z%init(this%dm_Xh, fld_name =
"fluid_rhs_z")
208 this%glb_n_points = int(this%msh%glb_nelv,
i8)*int(this%Xh%lxyz,
i8)
209 this%glb_unique_points = int(
glsum(this%c_Xh%mult, this%dm_Xh%size()),
i8)
214 call this%log_solver_info(params, scheme, lx)
221 call this%dm_Xh%free()
222 call this%gs_Xh%free()
223 call this%c_Xh%free()
226 if (
associated(this%m_x))
then
230 if (
associated(this%m_y))
then
234 if (
associated(this%m_z))
then
238 if (
associated(this%E))
then
242 if (
associated(this%max_wave_speed))
then
243 call this%max_wave_speed%free()
246 if (
associated(this%S))
then
250 if (
associated(this%f_x))
then
255 if (
associated(this%f_y))
then
260 if (
associated(this%f_z))
then
273 nullify(this%max_wave_speed)
291 integer :: temp_indices(1)
293 n = this%dm_Xh%size()
303 call field_cmult2(this%E, this%p, 1.0_rp/(this%gamma - 1.0_rp), n)
314 call this%compute_max_wave_speed()
324 real(kind=
rp),
intent(in) :: dt
328 associate(u => this%u, v => this%v, w => this%w, p => this%p, &
329 rho => this%rho, xh => this%Xh, c_xh => this%c_Xh, &
330 msh => this%msh, gamma => this%gamma, &
331 max_wave_speed => this%max_wave_speed)
333 n = xh%lx * xh%ly * xh%lz * msh%nelv
345 type(time_state_t),
intent(in) :: time
354 n = this%S%dof%size()
357 if (neko_bcknd_device .eq. 1)
then
358 call compressible_ops_device_compute_entropy(this%S, this%p, this%rho, this%gamma, n)
360 call compressible_ops_cpu_compute_entropy(this%S%x, this%p%x, this%rho%x, this%gamma, n)
371 n = this%u%dof%size()
374 if (neko_bcknd_device .eq. 1)
then
375 call compressible_ops_device_compute_max_wave_speed(this%max_wave_speed, &
376 this%u, this%v, this%w, this%gamma, this%p, this%rho, n)
378 call compressible_ops_cpu_compute_max_wave_speed(this%max_wave_speed%x, &
379 this%u%x, this%v%x, this%w%x, this%gamma, this%p%x, this%rho%x, n)
391 type(json_file),
intent(inout) :: params
392 character(len=*),
intent(in) :: scheme
393 integer,
intent(in) :: lx
394 character(len=LOG_SIZE) :: log_buf
395 logical :: logical_val
396 real(kind=rp) :: real_val
397 integer :: integer_val
399 call neko_log%section(
'Fluid')
400 write(log_buf,
'(A, A)')
'Type : ', trim(scheme)
401 call neko_log%message(log_buf)
402 write(log_buf,
'(A, A)')
'Name : ', trim(this%name)
403 call neko_log%message(log_buf)
407 write(log_buf,
'(A, I1)')
'Poly order : ', lx-1
408 else if (lx .ge. 10)
then
409 write(log_buf,
'(A, I2)')
'Poly order : ', lx-1
411 write(log_buf,
'(A, I3)')
'Poly order : ', lx-1
413 call neko_log%message(log_buf)
416 write(log_buf,
'(A, I0)')
'GLL points : ', this%glb_n_points
417 call neko_log%message(log_buf)
418 write(log_buf,
'(A, I0)')
'Unique pts.: ', this%glb_unique_points
419 call neko_log%message(log_buf)
422 write(log_buf,
'(A,ES13.6)')
'gamma :', this%gamma
423 call neko_log%message(log_buf)
426 call json_get_or_default(params,
'case.numerics.c_avisc_low', real_val, 0.5_rp)
427 write(log_buf,
'(A,ES13.6)')
'c_avisc_low:', real_val
428 call neko_log%message(log_buf)
430 call json_get_or_default(params,
'case.numerics.time_order', integer_val, 4)
431 write(log_buf,
'(A, I0)')
'RK order : ', integer_val
432 call neko_log%message(log_buf)
Abstract interface to sets rho and mu.
Retrieves a parameter by name or assigns a provided default value. In the latter case also adds the m...
CPU implementation of compressible flow operations.
subroutine, public compressible_ops_cpu_compute_entropy(s, p, rho, gamma, n)
Compute entropy field S = 1/(gamma-1) * rho * (log(p) - gamma * log(rho)) on CPU.
subroutine, public compressible_ops_cpu_compute_max_wave_speed(max_wave_speed, u, v, w, gamma, p, rho, n)
Compute maximum wave speed for compressible flows on CPU.
Device implementation of compressible flow operations.
subroutine, public compressible_ops_device_compute_entropy(s, p, rho, gamma, n)
Compute entropy field S = 1/(gamma-1) * rho * (log(p) - gamma * log(rho)) on device.
subroutine, public compressible_ops_device_compute_max_wave_speed(max_wave_speed, u, v, w, gamma, p, rho, n)
Compute maximum wave speed for compressible flows on device.
subroutine, public field_col2(a, b, n)
Vector multiplication .
subroutine, public field_cmult2(a, b, c, n)
Multiplication by constant c .
subroutine, public field_cfill(a, c, n)
Set all elements to a constant c .
subroutine, public field_addcol3(a, b, c, n)
Returns .
subroutine, public field_add2(a, b, n)
Vector addition .
subroutine, public field_col3(a, b, c, n)
Vector multiplication with 3 vectors .
subroutine, public field_cmult(a, c, n)
Multiplication by constant c .
subroutine fluid_scheme_compressible_log_solver_info(this, params, scheme, lx)
Log comprehensive solver information.
subroutine fluid_scheme_compressible_free(this)
Free allocated memory and cleanup resources.
subroutine fluid_scheme_compressible_update_material_properties(this, time)
Set rho and mu.
subroutine fluid_scheme_compressible_init(this, msh, lx, params, scheme, user)
Initialize common data for compressible fluid scheme.
real(kind=rp) function fluid_scheme_compressible_compute_cfl(this, dt)
Compute CFL number.
subroutine fluid_scheme_compressible_compute_max_wave_speed(this)
Compute maximum wave speed for compressible flows.
subroutine fluid_scheme_compressible_validate(this)
Validate field initialization and compute derived quantities.
subroutine fluid_scheme_compressible_compute_entropy(this)
Compute entropy field S = 1/(gamma-1) * rho * (log(p) - gamma * log(rho))
Utilities for retrieving parameters from the case files.
type(log_t), public neko_log
Global log stream.
integer, parameter, public log_size
real(kind=rp) function, public glsum(a, n)
Sum a vector of length n.
integer, parameter neko_bcknd_device
integer, parameter, public i8
integer, parameter, public rp
Global precision used in computations.
real(kind=rp) function, public cfl_compressible(dt, max_wave_speed, xh, coef, nelv, gdim)
Defines a registry for storing solution fields.
type(registry_t), target, public neko_registry
Global field registry.
Defines a registry for storing and requesting temporary objects This can be used when you have a func...
type(scratch_registry_t), target, public neko_scratch_registry
Global scratch registry.
Defines a function space.
integer, parameter, public gll
Module with things related to the simulation time.
Interfaces for user interaction with NEKO.
Base type of all fluid formulations.
Base type of compressible fluid formulations.
A struct that contains all info about the time, expand as needed.
A type collecting all the overridable user routines and flag to suppress type injection from custom m...