42 use json_module,
only : json_file
75 type(
field_t),
pointer :: temperature => null()
76 type(
field_t),
pointer :: max_wave_speed => null()
77 type(
field_t),
pointer :: artificial_visc => null()
80 real(kind=
rp) :: gamma
83 real(kind=
rp) :: mu_amax = 0.0_rp
85 real(kind=
rp) :: kappa_amax = 0.0_rp
88 logical :: add_physical_flux = .false.
90 logical :: add_physical_stress = .false.
93 logical :: variable_material_properties = .false.
96 integer(kind=i8) :: glb_n_points
98 integer(kind=i8) :: glb_unique_points
109 procedure, pass(this) :: compute_cfl &
112 procedure, pass(this) :: set_material_properties => &
118 procedure, pass(this) :: update_physical_flux => &
121 procedure, pass(this) :: compute_max_wave_speed => &
124 procedure, pass(this) :: log_solver_info => &
139 type(
mesh_t),
target,
intent(inout) :: msh
140 integer,
intent(in) :: lx
141 character(len=*),
intent(in) :: scheme
142 type(json_file),
target,
intent(inout) :: params
143 type(
user_t),
target,
intent(in) :: user
151 if (msh%gdim .eq. 2)
then
152 call this%Xh%init(
gll, lx, lx)
154 call this%Xh%init(
gll, lx, lx, lx)
157 call this%dm_Xh%init(msh, this%Xh)
159 call this%gs_Xh%init(this%dm_Xh)
161 call this%c_Xh%init(this%gs_Xh)
167 this%params => params
173 call neko_registry%add_field(this%dm_Xh, this%name //
"_rho")
183 call this%m_x%init(this%dm_Xh,
"m_x")
184 call this%m_y%init(this%dm_Xh,
"m_y")
185 call this%m_z%init(this%dm_Xh,
"m_z")
190 call this%E%init(this%dm_Xh,
"E")
195 call this%temperature%init(this%dm_Xh,
"temperature")
199 this%max_wave_speed =>
neko_registry%get_field(
"max_wave_speed")
200 call this%max_wave_speed%init(this%dm_Xh,
"max_wave_speed")
204 this%artificial_visc =>
neko_registry%get_field(
"artificial_visc")
205 call this%artificial_visc%init(this%dm_Xh,
"artificial_visc")
214 call this%u%init(this%dm_Xh,
"u")
215 call this%v%init(this%dm_Xh,
"v")
216 call this%w%init(this%dm_Xh,
"w")
219 call this%p%init(this%dm_Xh,
"p")
227 call this%f_x%init(this%dm_Xh, fld_name =
"fluid_rhs_x")
228 call this%f_y%init(this%dm_Xh, fld_name =
"fluid_rhs_y")
229 call this%f_z%init(this%dm_Xh, fld_name =
"fluid_rhs_z")
232 call this%set_material_properties(params,
user)
238 this%glb_n_points = int(this%msh%glb_nelv,
i8)*int(this%Xh%lxyz,
i8)
239 this%glb_unique_points = int(
glsum(this%c_Xh%mult, this%dm_Xh%size()),
i8)
244 call this%log_solver_info(params, scheme, lx)
251 class(
bc_t),
pointer :: bc
254 do i = 1, this%bcs_vel%size()
255 bc => this%bcs_vel%get(i)
256 if (
associated(
bc))
then
261 call this%bcs_vel%free()
263 do i = 1, this%bcs_prs%size()
264 bc => this%bcs_prs%get(i)
265 if (
associated(
bc))
then
270 call this%bcs_prs%free()
272 call this%dm_Xh%free()
273 call this%gs_Xh%free()
274 call this%c_Xh%free()
277 if (
associated(this%m_x))
then
281 if (
associated(this%m_y))
then
285 if (
associated(this%m_z))
then
289 if (
associated(this%E))
then
293 if (
associated(this%temperature))
then
294 call this%temperature%free()
297 if (
associated(this%max_wave_speed))
then
298 call this%max_wave_speed%free()
301 if (
associated(this%f_x))
then
306 if (
associated(this%f_y))
then
311 if (
associated(this%f_z))
then
324 nullify(this%temperature)
325 nullify(this%max_wave_speed)
335 call this%material_properties%free()
345 integer :: temp_indices(1)
347 n = this%dm_Xh%size()
357 call field_cmult2(this%E, this%p, 1.0_rp/(this%gamma - 1.0_rp), n)
367 this%temperature%x(i,1,1,1) = this%p%x(i,1,1,1) / &
368 (this%rho%x(i,1,1,1) * (this%gamma - 1.0_rp))
374 call this%compute_max_wave_speed()
384 real(kind=
dp),
intent(in) :: dt
388 associate(u => this%u, v => this%v, w => this%w, p => this%p, &
389 rho => this%rho, xh => this%Xh, c_xh => this%c_Xh, &
390 msh => this%msh, gamma => this%gamma, &
391 max_wave_speed => this%max_wave_speed)
393 n = xh%lx * xh%ly * xh%lz * msh%nelv
408 type(json_file),
intent(inout) :: params
409 type(user_t),
target,
intent(in) :: user
410 procedure(user_material_properties_intf),
pointer :: dummy_mp_ptr
411 type(time_state_t) :: dummy_time_state
412 real(kind=rp) :: const_mu, const_kappa
414 dummy_mp_ptr => dummy_user_material_properties
416 call neko_registry%add_field(this%dm_Xh, this%name //
"_mu")
417 this%mu => neko_registry%get_field(this%name //
"_mu")
419 call neko_registry%add_field(this%dm_Xh, this%name //
"_kappa")
420 this%kappa => neko_registry%get_field(this%name //
"_kappa")
422 call this%material_properties%init(3)
423 call this%material_properties%assign(1, this%rho)
424 call this%material_properties%assign(2, this%mu)
425 call this%material_properties%assign(3, this%kappa)
427 if (.not.
associated(
user%material_properties, dummy_mp_ptr))
then
428 this%user_material_properties =>
user%material_properties
429 this%variable_material_properties = .true.
430 call user%material_properties(this%name, this%material_properties, &
433 this%variable_material_properties = .false.
434 this%user_material_properties => dummy_user_material_properties
435 call json_get_or_lookup_or_default(params,
'case.fluid.mu', const_mu, &
437 call json_get_or_lookup_or_default(params,
'case.fluid.kappa', &
440 call field_cfill(this%mu, const_mu)
441 call field_cfill(this%kappa, const_kappa)
445 call this%update_physical_flux()
455 type(time_state_t),
intent(in) :: time
457 if (.not. this%variable_material_properties)
return
459 call this%user_material_properties(this%name, this%material_properties, &
462 call this%update_physical_flux()
483 real(kind=rp) :: mu_amax, kappa_amax
486 n = this%dm_Xh%size()
488 if (neko_bcknd_device .eq. 1)
then
489 mu_amax = device_glamax(this%mu%x_d, n)
490 kappa_amax = device_glamax(this%kappa%x_d, n)
492 mu_amax = glamax(this%mu%x, n)
493 kappa_amax = glamax(this%kappa%x, n)
496 this%mu_amax = mu_amax
497 this%kappa_amax = kappa_amax
499 this%add_physical_stress = (mu_amax .ne. 0.0_rp)
500 this%add_physical_flux = this%add_physical_stress .or. &
501 (kappa_amax .ne. 0.0_rp)
503 call compressible_rhs_set_physical_flux(this%add_physical_flux, &
504 this%add_physical_stress)
514 n = this%u%dof%size()
517 if (neko_bcknd_device .eq. 1)
then
518 call compressible_ops_device_compute_max_wave_speed( &
519 this%max_wave_speed, this%u, this%v, this%w, this%gamma, this%p, &
522 call compressible_ops_cpu_compute_max_wave_speed(this%max_wave_speed%x, &
523 this%u%x, this%v%x, this%w%x, this%gamma, this%p%x, this%rho%x, n)
535 type(json_file),
intent(inout) :: params
536 character(len=*),
intent(in) :: scheme
537 integer,
intent(in) :: lx
538 character(len=LOG_SIZE) :: log_buf
539 logical :: logical_val
540 integer :: integer_val
542 call neko_log%section(
'Fluid')
543 write(log_buf,
'(A, A)')
'Type : ', trim(scheme)
544 call neko_log%message(log_buf)
545 write(log_buf,
'(A, A)')
'Name : ', trim(this%name)
546 call neko_log%message(log_buf)
550 write(log_buf,
'(A, I1)')
'Poly order : ', lx-1
551 else if (lx .ge. 10)
then
552 write(log_buf,
'(A, I2)')
'Poly order : ', lx-1
554 write(log_buf,
'(A, I3)')
'Poly order : ', lx-1
556 call neko_log%message(log_buf)
559 write(log_buf,
'(A, I0)')
'GLL points : ', this%glb_n_points
560 call neko_log%message(log_buf)
561 write(log_buf,
'(A, I0)')
'Unique pts.: ', this%glb_unique_points
562 call neko_log%message(log_buf)
565 write(log_buf,
'(A,ES13.6)')
'gamma :', this%gamma
566 call neko_log%message(log_buf)
568 call json_get_or_default(params,
'case.numerics.time_order', integer_val, 4)
569 write(log_buf,
'(A, I0)')
'RK order : ', integer_val
570 call neko_log%message(log_buf)
574 if (this%variable_material_properties)
then
575 write(log_buf,
'(A,ES13.6,A)')
'mu :', this%mu_amax, &
577 call neko_log%message(log_buf)
578 write(log_buf,
'(A,ES13.6,A)')
'kappa :', this%kappa_amax, &
580 call neko_log%message(log_buf)
582 write(log_buf,
'(A,ES13.6)')
'mu :', this%mu_amax
583 call neko_log%message(log_buf)
584 write(log_buf,
'(A,ES13.6)')
'kappa :', this%kappa_amax
585 call neko_log%message(log_buf)
588 if (this%add_physical_flux)
then
589 write(log_buf,
'(A, A)')
'NS fluxes : ',
'enabled'
591 write(log_buf,
'(A, A)')
'NS fluxes : ', &
592 'disabled (mu = kappa = 0, Euler)'
594 call neko_log%message(log_buf)
596 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...