42 use json_module,
only : json_file
75 type(
field_t),
pointer :: temperature => null()
76 type(
field_t),
pointer :: max_wave_speed => null()
78 type(
field_t),
pointer :: artificial_visc => null()
81 real(kind=
rp) :: gamma
84 integer(kind=i8) :: glb_n_points
86 integer(kind=i8) :: glb_unique_points
97 procedure, pass(this) :: compute_cfl &
100 procedure, pass(this) :: set_material_properties => &
106 procedure, pass(this) :: compute_entropy => &
109 procedure, pass(this) :: compute_max_wave_speed => &
112 procedure, pass(this) :: log_solver_info => &
127 type(
mesh_t),
target,
intent(inout) :: msh
128 integer,
intent(in) :: lx
129 character(len=*),
intent(in) :: scheme
130 type(json_file),
target,
intent(inout) :: params
131 type(
user_t),
target,
intent(in) :: user
139 if (msh%gdim .eq. 2)
then
140 call this%Xh%init(
gll, lx, lx)
142 call this%Xh%init(
gll, lx, lx, lx)
145 call this%dm_Xh%init(msh, this%Xh)
147 call this%gs_Xh%init(this%dm_Xh)
149 call this%c_Xh%init(this%gs_Xh)
155 this%params => params
161 call neko_registry%add_field(this%dm_Xh, this%name //
"_rho")
171 call this%m_x%init(this%dm_Xh,
"m_x")
172 call this%m_y%init(this%dm_Xh,
"m_y")
173 call this%m_z%init(this%dm_Xh,
"m_z")
178 call this%E%init(this%dm_Xh,
"E")
183 call this%temperature%init(this%dm_Xh,
"temperature")
187 this%max_wave_speed =>
neko_registry%get_field(
"max_wave_speed")
188 call this%max_wave_speed%init(this%dm_Xh,
"max_wave_speed")
193 call this%S%init(this%dm_Xh,
"S")
197 this%artificial_visc =>
neko_registry%get_field(
"artificial_visc")
198 call this%artificial_visc%init(this%dm_Xh,
"artificial_visc")
207 call this%u%init(this%dm_Xh,
"u")
208 call this%v%init(this%dm_Xh,
"v")
209 call this%w%init(this%dm_Xh,
"w")
212 call this%p%init(this%dm_Xh,
"p")
220 call this%f_x%init(this%dm_Xh, fld_name =
"fluid_rhs_x")
221 call this%f_y%init(this%dm_Xh, fld_name =
"fluid_rhs_y")
222 call this%f_z%init(this%dm_Xh, fld_name =
"fluid_rhs_z")
225 call this%set_material_properties(params,
user)
231 this%glb_n_points = int(this%msh%glb_nelv,
i8)*int(this%Xh%lxyz,
i8)
232 this%glb_unique_points = int(
glsum(this%c_Xh%mult, this%dm_Xh%size()),
i8)
237 call this%log_solver_info(params, scheme, lx)
244 class(
bc_t),
pointer :: bc
247 do i = 1, this%bcs_vel%size()
248 bc => this%bcs_vel%get(i)
249 if (
associated(
bc))
then
254 call this%bcs_vel%free()
256 do i = 1, this%bcs_prs%size()
257 bc => this%bcs_prs%get(i)
258 if (
associated(
bc))
then
263 call this%bcs_prs%free()
265 call this%dm_Xh%free()
266 call this%gs_Xh%free()
267 call this%c_Xh%free()
270 if (
associated(this%m_x))
then
274 if (
associated(this%m_y))
then
278 if (
associated(this%m_z))
then
282 if (
associated(this%E))
then
286 if (
associated(this%temperature))
then
287 call this%temperature%free()
290 if (
associated(this%max_wave_speed))
then
291 call this%max_wave_speed%free()
294 if (
associated(this%S))
then
298 if (
associated(this%f_x))
then
303 if (
associated(this%f_y))
then
308 if (
associated(this%f_z))
then
321 nullify(this%temperature)
322 nullify(this%max_wave_speed)
333 call this%material_properties%free()
343 integer :: temp_indices(1)
345 n = this%dm_Xh%size()
355 call field_cmult2(this%E, this%p, 1.0_rp/(this%gamma - 1.0_rp), n)
365 this%temperature%x(i,1,1,1) = this%p%x(i,1,1,1) / &
366 (this%rho%x(i,1,1,1) * (this%gamma - 1.0_rp))
372 call this%compute_max_wave_speed()
382 real(kind=
rp),
intent(in) :: dt
386 associate(u => this%u, v => this%v, w => this%w, p => this%p, &
387 rho => this%rho, xh => this%Xh, c_xh => this%c_Xh, &
388 msh => this%msh, gamma => this%gamma, &
389 max_wave_speed => this%max_wave_speed)
391 n = xh%lx * xh%ly * xh%lz * msh%nelv
406 type(json_file),
intent(inout) :: params
407 type(user_t),
target,
intent(in) :: user
408 procedure(user_material_properties_intf),
pointer :: dummy_mp_ptr
409 type(time_state_t) :: dummy_time_state
410 character(len=LOG_SIZE) :: log_buf
411 real(kind=rp) :: const_mu, const_kappa
413 dummy_mp_ptr => dummy_user_material_properties
415 call neko_registry%add_field(this%dm_Xh, this%name //
"_mu")
416 this%mu => neko_registry%get_field(this%name //
"_mu")
418 call neko_registry%add_field(this%dm_Xh, this%name //
"_kappa")
419 this%kappa => neko_registry%get_field(this%name //
"_kappa")
421 call this%material_properties%init(3)
422 call this%material_properties%assign(1, this%rho)
423 call this%material_properties%assign(2, this%mu)
424 call this%material_properties%assign(3, this%kappa)
426 if (.not.
associated(
user%material_properties, dummy_mp_ptr))
then
427 this%user_material_properties =>
user%material_properties
428 call user%material_properties(this%name, this%material_properties, &
431 this%user_material_properties => dummy_user_material_properties
432 call json_get_or_lookup_or_default(params,
'case.fluid.mu', const_mu, &
434 call json_get_or_lookup_or_default(params,
'case.fluid.kappa', &
437 call field_cfill(this%mu, const_mu)
438 call field_cfill(this%kappa, const_kappa)
440 write(log_buf,
'(A,ES13.6)')
'mu :', const_mu
441 call neko_log%message(log_buf)
442 write(log_buf,
'(A,ES13.6)')
'kappa :', const_kappa
443 call neko_log%message(log_buf)
446 if (neko_bcknd_device .eq. 1)
then
447 call device_memcpy(this%mu%x, this%mu%x_d, this%mu%size(), &
448 host_to_device, sync = .false.)
449 call device_memcpy(this%kappa%x, this%kappa%x_d, this%kappa%size(), &
450 host_to_device, sync = .false.)
461 type(time_state_t),
intent(in) :: time
463 call this%user_material_properties(this%name, this%material_properties, &
466 if (neko_bcknd_device .eq. 1)
then
469 call device_memcpy(this%kappa%x, this%kappa%x_d, this%kappa%size(), &
480 n = this%S%dof%size()
483 if (neko_bcknd_device .eq. 1)
then
484 call compressible_ops_device_compute_entropy(this%S, this%p, this%rho, &
487 call compressible_ops_cpu_compute_entropy(this%S%x, this%p%x, &
488 this%rho%x, this%gamma, n)
499 n = this%u%dof%size()
502 if (neko_bcknd_device .eq. 1)
then
503 call compressible_ops_device_compute_max_wave_speed( &
504 this%max_wave_speed, this%u, this%v, this%w, this%gamma, this%p, &
507 call compressible_ops_cpu_compute_max_wave_speed(this%max_wave_speed%x, &
508 this%u%x, this%v%x, this%w%x, this%gamma, this%p%x, this%rho%x, n)
520 type(json_file),
intent(inout) :: params
521 character(len=*),
intent(in) :: scheme
522 integer,
intent(in) :: lx
523 character(len=LOG_SIZE) :: log_buf
524 logical :: logical_val
525 real(kind=rp) :: real_val
526 integer :: integer_val
528 call neko_log%section(
'Fluid')
529 write(log_buf,
'(A, A)')
'Type : ', trim(scheme)
530 call neko_log%message(log_buf)
531 write(log_buf,
'(A, A)')
'Name : ', trim(this%name)
532 call neko_log%message(log_buf)
536 write(log_buf,
'(A, I1)')
'Poly order : ', lx-1
537 else if (lx .ge. 10)
then
538 write(log_buf,
'(A, I2)')
'Poly order : ', lx-1
540 write(log_buf,
'(A, I3)')
'Poly order : ', lx-1
542 call neko_log%message(log_buf)
545 write(log_buf,
'(A, I0)')
'GLL points : ', this%glb_n_points
546 call neko_log%message(log_buf)
547 write(log_buf,
'(A, I0)')
'Unique pts.: ', this%glb_unique_points
548 call neko_log%message(log_buf)
551 write(log_buf,
'(A,ES13.6)')
'gamma :', this%gamma
552 call neko_log%message(log_buf)
555 call json_get_or_default(params,
'case.numerics.c_avisc_low', real_val, &
557 write(log_buf,
'(A,ES13.6)')
'c_avisc_low:', real_val
558 call neko_log%message(log_buf)
560 call json_get_or_default(params,
'case.numerics.time_order', integer_val, 4)
561 write(log_buf,
'(A, I0)')
'RK order : ', integer_val
562 call neko_log%message(log_buf)
563 call neko_log%end_section()
Copy data between host and device (or device and device)
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...
Compute CFL condition for compressible flow.
Abstract interface for setting material properties.
Defines a boundary condition.
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.
Device abstraction, common interface for various accelerators.
integer, parameter, public host_to_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)
Update variable material properties.
subroutine fluid_scheme_compressible_set_material_properties(this, params, user)
Set material properties mu and rho.
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.
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.
subroutine, public dummy_user_material_properties(scheme_name, properties, time)
Base type for a boundary condition.
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...