42 use json_module,
only : json_file
76 type(
field_t),
pointer :: temperature => null()
77 type(
field_t),
pointer :: max_wave_speed => null()
78 type(
field_t),
pointer :: artificial_visc => null()
81 real(kind=
rp) :: gamma
84 real(kind=
rp) :: mu_amax = 0.0_rp
86 real(kind=
rp) :: kappa_amax = 0.0_rp
89 logical :: add_physical_flux = .false.
91 logical :: add_physical_stress = .false.
94 logical :: variable_material_properties = .false.
97 integer(kind=i8) :: glb_n_points
99 integer(kind=i8) :: glb_unique_points
110 procedure, pass(this) :: compute_cfl &
113 procedure, pass(this) :: set_material_properties => &
119 procedure, pass(this) :: update_physical_flux => &
122 procedure, pass(this) :: compute_max_wave_speed => &
125 procedure, pass(this) :: log_solver_info => &
140 type(
mesh_t),
target,
intent(inout) :: msh
141 integer,
intent(in) :: lx
142 character(len=*),
intent(in) :: scheme
143 type(json_file),
target,
intent(inout) :: params
144 type(
user_t),
target,
intent(in) :: user
145 logical :: compress_geo
146 real(kind=
rp) :: compress_tol
154 if (msh%gdim .eq. 2)
then
155 call this%Xh%init(
gll, lx, lx)
157 call this%Xh%init(
gll, lx, lx, lx)
160 call this%dm_Xh%init(msh, this%Xh)
162 call this%gs_Xh%init(this%dm_Xh)
164 call this%c_Xh%init(this%gs_Xh)
170 this%params => params
176 call neko_registry%add_field(this%dm_Xh, this%name //
"_rho")
186 call this%m_x%init(this%dm_Xh,
"m_x")
187 call this%m_y%init(this%dm_Xh,
"m_y")
188 call this%m_z%init(this%dm_Xh,
"m_z")
193 call this%E%init(this%dm_Xh,
"E")
198 call this%temperature%init(this%dm_Xh,
"temperature")
202 this%max_wave_speed =>
neko_registry%get_field(
"max_wave_speed")
203 call this%max_wave_speed%init(this%dm_Xh,
"max_wave_speed")
207 this%artificial_visc =>
neko_registry%get_field(
"artificial_visc")
208 call this%artificial_visc%init(this%dm_Xh,
"artificial_visc")
217 call this%u%init(this%dm_Xh,
"u")
218 call this%v%init(this%dm_Xh,
"v")
219 call this%w%init(this%dm_Xh,
"w")
222 call this%p%init(this%dm_Xh,
"p")
230 call this%f_x%init(this%dm_Xh, fld_name =
"fluid_rhs_x")
231 call this%f_y%init(this%dm_Xh, fld_name =
"fluid_rhs_y")
232 call this%f_z%init(this%dm_Xh, fld_name =
"fluid_rhs_z")
235 call this%set_material_properties(params,
user)
241 this%glb_n_points = int(this%msh%glb_nelv,
i8)*int(this%Xh%lxyz,
i8)
242 this%glb_unique_points = int(
glsum(this%c_Xh%mult, this%dm_Xh%size()),
i8)
247 call this%log_solver_info(params, scheme, lx)
251 'case.numerics.compress_geometric_factors', compress_geo, .false.)
252 if (compress_geo)
then
253 if (params%valid_path( &
254 'case.numerics.compress_geometric_factors_tolerance'))
then
256 'case.numerics.compress_geometric_factors_tolerance', &
258 call this%c_Xh%enable_geo_compression(compress_tol)
260 call this%c_Xh%enable_geo_compression()
269 class(
bc_t),
pointer :: bc
272 do i = 1, this%bcs_vel%size()
273 bc => this%bcs_vel%get(i)
274 if (
associated(
bc))
then
279 call this%bcs_vel%free()
281 do i = 1, this%bcs_prs%size()
282 bc => this%bcs_prs%get(i)
283 if (
associated(
bc))
then
288 call this%bcs_prs%free()
290 call this%dm_Xh%free()
291 call this%gs_Xh%free()
292 call this%c_Xh%free()
295 if (
associated(this%m_x))
then
299 if (
associated(this%m_y))
then
303 if (
associated(this%m_z))
then
307 if (
associated(this%E))
then
311 if (
associated(this%temperature))
then
312 call this%temperature%free()
315 if (
associated(this%max_wave_speed))
then
316 call this%max_wave_speed%free()
319 if (
associated(this%f_x))
then
324 if (
associated(this%f_y))
then
329 if (
associated(this%f_z))
then
342 nullify(this%temperature)
343 nullify(this%max_wave_speed)
353 call this%material_properties%free()
363 integer :: temp_indices(1)
365 n = this%dm_Xh%size()
375 call field_cmult2(this%E, this%p, 1.0_rp/(this%gamma - 1.0_rp), n)
385 this%temperature%x(i,1,1,1) = this%p%x(i,1,1,1) / &
386 (this%rho%x(i,1,1,1) * (this%gamma - 1.0_rp))
392 call this%compute_max_wave_speed()
402 real(kind=
dp),
intent(in) :: dt
406 associate(u => this%u, v => this%v, w => this%w, p => this%p, &
407 rho => this%rho, xh => this%Xh, c_xh => this%c_Xh, &
408 msh => this%msh, gamma => this%gamma, &
409 max_wave_speed => this%max_wave_speed)
411 n = xh%lx * xh%ly * xh%lz * msh%nelv
426 type(json_file),
intent(inout) :: params
427 type(user_t),
target,
intent(in) :: user
428 procedure(user_material_properties_intf),
pointer :: dummy_mp_ptr
429 type(time_state_t) :: dummy_time_state
430 real(kind=rp) :: const_mu, const_kappa
432 dummy_mp_ptr => dummy_user_material_properties
434 call neko_registry%add_field(this%dm_Xh, this%name //
"_mu")
435 this%mu => neko_registry%get_field(this%name //
"_mu")
437 call neko_registry%add_field(this%dm_Xh, this%name //
"_kappa")
438 this%kappa => neko_registry%get_field(this%name //
"_kappa")
440 call this%material_properties%init(3)
441 call this%material_properties%assign(1, this%rho)
442 call this%material_properties%assign(2, this%mu)
443 call this%material_properties%assign(3, this%kappa)
445 if (.not.
associated(
user%material_properties, dummy_mp_ptr))
then
446 this%user_material_properties =>
user%material_properties
447 this%variable_material_properties = .true.
448 call user%material_properties(this%name, this%material_properties, &
451 this%variable_material_properties = .false.
452 this%user_material_properties => dummy_user_material_properties
453 call json_get_or_lookup_or_default(params,
'case.fluid.mu', const_mu, &
455 call json_get_or_lookup_or_default(params,
'case.fluid.kappa', &
458 call field_cfill(this%mu, const_mu)
459 call field_cfill(this%kappa, const_kappa)
463 call this%update_physical_flux()
473 type(time_state_t),
intent(in) :: time
475 if (.not. this%variable_material_properties)
return
477 call this%user_material_properties(this%name, this%material_properties, &
480 call this%update_physical_flux()
501 real(kind=rp) :: mu_amax, kappa_amax
504 n = this%dm_Xh%size()
506 if (neko_bcknd_device .eq. 1)
then
507 mu_amax = device_glamax(this%mu%x_d, n)
508 kappa_amax = device_glamax(this%kappa%x_d, n)
510 mu_amax = glamax(this%mu%x, n)
511 kappa_amax = glamax(this%kappa%x, n)
514 this%mu_amax = mu_amax
515 this%kappa_amax = kappa_amax
517 this%add_physical_stress = (mu_amax .ne. 0.0_rp)
518 this%add_physical_flux = this%add_physical_stress .or. &
519 (kappa_amax .ne. 0.0_rp)
521 call compressible_rhs_set_physical_flux(this%add_physical_flux, &
522 this%add_physical_stress)
532 n = this%u%dof%size()
535 if (neko_bcknd_device .eq. 1)
then
536 call compressible_ops_device_compute_max_wave_speed( &
537 this%max_wave_speed, this%u, this%v, this%w, this%gamma, this%p, &
540 call compressible_ops_cpu_compute_max_wave_speed(this%max_wave_speed%x, &
541 this%u%x, this%v%x, this%w%x, this%gamma, this%p%x, this%rho%x, n)
553 type(json_file),
intent(inout) :: params
554 character(len=*),
intent(in) :: scheme
555 integer,
intent(in) :: lx
556 character(len=LOG_SIZE) :: log_buf
557 logical :: logical_val
558 integer :: integer_val
560 call neko_log%section(
'Fluid')
561 write(log_buf,
'(A, A)')
'Type : ', trim(scheme)
562 call neko_log%message(log_buf)
563 write(log_buf,
'(A, A)')
'Name : ', trim(this%name)
564 call neko_log%message(log_buf)
568 write(log_buf,
'(A, I1)')
'Poly order : ', lx-1
569 else if (lx .ge. 10)
then
570 write(log_buf,
'(A, I2)')
'Poly order : ', lx-1
572 write(log_buf,
'(A, I3)')
'Poly order : ', lx-1
574 call neko_log%message(log_buf)
577 write(log_buf,
'(A, I0)')
'GLL points : ', this%glb_n_points
578 call neko_log%message(log_buf)
579 write(log_buf,
'(A, I0)')
'Unique pts.: ', this%glb_unique_points
580 call neko_log%message(log_buf)
583 write(log_buf,
'(A,ES13.6)')
'gamma :', this%gamma
584 call neko_log%message(log_buf)
586 call json_get_or_default(params,
'case.numerics.time_order', integer_val, 4)
587 write(log_buf,
'(A, I0)')
'RK order : ', integer_val
588 call neko_log%message(log_buf)
590 call json_get_or_default(params, &
591 'case.numerics.compress_geometric_factors', logical_val, .false.)
592 write(log_buf,
'(A, L1)')
'Compress G : ', logical_val
593 call neko_log%message(log_buf)
597 if (this%variable_material_properties)
then
598 write(log_buf,
'(A,ES13.6,A)')
'mu :', this%mu_amax, &
600 call neko_log%message(log_buf)
601 write(log_buf,
'(A,ES13.6,A)')
'kappa :', this%kappa_amax, &
603 call neko_log%message(log_buf)
605 write(log_buf,
'(A,ES13.6)')
'mu :', this%mu_amax
606 call neko_log%message(log_buf)
607 write(log_buf,
'(A,ES13.6)')
'kappa :', this%kappa_amax
608 call neko_log%message(log_buf)
611 if (this%add_physical_flux)
then
612 write(log_buf,
'(A, A)')
'NS fluxes : ',
'enabled'
614 write(log_buf,
'(A, A)')
'NS fluxes : ', &
615 'disabled (mu = kappa = 0, Euler)'
617 call neko_log%message(log_buf)
619 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_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_max_wave_speed(max_wave_speed, u, v, w, gamma, p, rho, n)
Compute maximum wave speed for compressible flows on device.
real(kind=rp) function, public device_glamax(a_d, n, strm)
Max of the absolute value of a vector of length n.
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.
real(kind=dp) function fluid_scheme_compressible_compute_cfl(this, dt)
Compute CFL number.
subroutine fluid_scheme_compressible_init(this, msh, lx, params, scheme, user)
Initialize common data for compressible fluid scheme.
subroutine fluid_scheme_compressible_update_physical_flux(this)
Refresh the physical-flux switches from the current material properties.
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.
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 glamax(a, n)
Max of the absolute value of a vector of length n.
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 dp
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...