42 use json_module,
only : json_file
77 type(
field_t),
pointer :: temperature => null()
78 type(
field_t),
pointer :: max_wave_speed => null()
79 type(
field_t),
pointer :: artificial_visc => null()
82 real(kind=
rp) :: gamma
85 real(kind=
rp) :: mu_amax = 0.0_rp
87 real(kind=
rp) :: kappa_amax = 0.0_rp
90 logical :: add_physical_flux = .false.
92 logical :: add_physical_stress = .false.
95 logical :: variable_material_properties = .false.
98 integer(kind=i8) :: glb_n_points
100 integer(kind=i8) :: glb_unique_points
111 procedure, pass(this) :: set_user_initial_condition => &
114 procedure, pass(this) :: compute_cfl &
117 procedure, pass(this) :: set_material_properties => &
123 procedure, pass(this) :: update_physical_flux => &
126 procedure, pass(this) :: compute_max_wave_speed => &
129 procedure, pass(this) :: log_solver_info => &
144 type(
mesh_t),
target,
intent(inout) :: msh
145 integer,
intent(in) :: lx
146 character(len=*),
intent(in) :: scheme
147 type(json_file),
target,
intent(inout) :: params
148 type(
user_t),
target,
intent(in) :: user
149 logical :: compress_geo
150 real(kind=
rp) :: compress_tol
158 if (msh%gdim .eq. 2)
then
159 call this%Xh%init(
gll, lx, lx)
161 call this%Xh%init(
gll, lx, lx, lx)
164 call this%dm_Xh%init(msh, this%Xh)
166 call this%gs_Xh%init(this%dm_Xh)
168 call this%c_Xh%init(this%gs_Xh)
174 this%params => params
180 call neko_registry%add_field(this%dm_Xh, this%name //
"_rho")
190 call this%m_x%init(this%dm_Xh,
"m_x")
191 call this%m_y%init(this%dm_Xh,
"m_y")
192 call this%m_z%init(this%dm_Xh,
"m_z")
197 call this%E%init(this%dm_Xh,
"E")
202 call this%temperature%init(this%dm_Xh,
"temperature")
206 this%max_wave_speed =>
neko_registry%get_field(
"max_wave_speed")
207 call this%max_wave_speed%init(this%dm_Xh,
"max_wave_speed")
211 this%artificial_visc =>
neko_registry%get_field(
"artificial_visc")
212 call this%artificial_visc%init(this%dm_Xh,
"artificial_visc")
221 call this%u%init(this%dm_Xh,
"u")
222 call this%v%init(this%dm_Xh,
"v")
223 call this%w%init(this%dm_Xh,
"w")
226 call this%p%init(this%dm_Xh,
"p")
234 call this%f_x%init(this%dm_Xh, fld_name =
"fluid_rhs_x")
235 call this%f_y%init(this%dm_Xh, fld_name =
"fluid_rhs_y")
236 call this%f_z%init(this%dm_Xh, fld_name =
"fluid_rhs_z")
239 call this%set_material_properties(params,
user)
245 this%glb_n_points = int(this%msh%glb_nelv,
i8)*int(this%Xh%lxyz,
i8)
246 this%glb_unique_points = int(
glsum(this%c_Xh%mult, this%dm_Xh%size()),
i8)
251 call this%log_solver_info(params, scheme, lx)
255 'case.numerics.compress_geometric_factors', compress_geo, .false.)
256 if (compress_geo)
then
257 if (params%valid_path( &
258 'case.numerics.compress_geometric_factors_tolerance'))
then
260 'case.numerics.compress_geometric_factors_tolerance', &
262 call this%c_Xh%enable_geo_compression(compress_tol)
264 call this%c_Xh%enable_geo_compression()
273 class(
bc_t),
pointer :: bc
276 do i = 1, this%bcs_vel%size()
277 bc => this%bcs_vel%get(i)
278 if (
associated(
bc))
then
283 call this%bcs_vel%free()
285 do i = 1, this%bcs_prs%size()
286 bc => this%bcs_prs%get(i)
287 if (
associated(
bc))
then
292 call this%bcs_prs%free()
294 call this%dm_Xh%free()
295 call this%gs_Xh%free()
296 call this%c_Xh%free()
299 if (
associated(this%m_x))
then
303 if (
associated(this%m_y))
then
307 if (
associated(this%m_z))
then
311 if (
associated(this%E))
then
315 if (
associated(this%temperature))
then
316 call this%temperature%free()
319 if (
associated(this%max_wave_speed))
then
320 call this%max_wave_speed%free()
323 if (
associated(this%f_x))
then
328 if (
associated(this%f_y))
then
333 if (
associated(this%f_z))
then
346 nullify(this%temperature)
347 nullify(this%max_wave_speed)
357 call this%material_properties%free()
367 integer :: temp_indices(1)
369 n = this%dm_Xh%size()
379 call field_cmult2(this%E, this%p, 1.0_rp/(this%gamma - 1.0_rp), n)
389 this%temperature%x(i,1,1,1) = this%p%x(i,1,1,1) / &
390 (this%rho%x(i,1,1,1) * (this%gamma - 1.0_rp))
396 call this%compute_max_wave_speed()
405 type(
user_t),
intent(in) :: user
408 this%p, this%c_Xh, this%gs_Xh,
user%initial_conditions, this%name)
418 real(kind=
dp),
intent(in) :: dt
422 associate(u => this%u, v => this%v, w => this%w, p => this%p, &
423 rho => this%rho, xh => this%Xh, c_xh => this%c_Xh, &
424 msh => this%msh, gamma => this%gamma, &
425 max_wave_speed => this%max_wave_speed)
427 n = xh%lx * xh%ly * xh%lz * msh%nelv
442 type(json_file),
intent(inout) :: params
443 type(user_t),
target,
intent(in) :: user
444 procedure(user_material_properties_intf),
pointer :: dummy_mp_ptr
445 type(time_state_t) :: dummy_time_state
446 real(kind=rp) :: const_mu, const_kappa
448 dummy_mp_ptr => dummy_user_material_properties
450 call neko_registry%add_field(this%dm_Xh, this%name //
"_mu")
451 this%mu => neko_registry%get_field(this%name //
"_mu")
453 call neko_registry%add_field(this%dm_Xh, this%name //
"_kappa")
454 this%kappa => neko_registry%get_field(this%name //
"_kappa")
456 call this%material_properties%init(3)
457 call this%material_properties%assign(1, this%rho)
458 call this%material_properties%assign(2, this%mu)
459 call this%material_properties%assign(3, this%kappa)
461 if (.not.
associated(
user%material_properties, dummy_mp_ptr))
then
462 this%user_material_properties =>
user%material_properties
463 this%variable_material_properties = .true.
464 call user%material_properties(this%name, this%material_properties, &
467 this%variable_material_properties = .false.
468 this%user_material_properties => dummy_user_material_properties
469 call json_get_or_lookup_or_default(params,
'case.fluid.mu', const_mu, &
471 call json_get_or_lookup_or_default(params,
'case.fluid.kappa', &
474 call field_cfill(this%mu, const_mu)
475 call field_cfill(this%kappa, const_kappa)
479 call this%update_physical_flux()
489 type(time_state_t),
intent(in) :: time
491 if (.not. this%variable_material_properties)
return
493 call this%user_material_properties(this%name, this%material_properties, &
496 call this%update_physical_flux()
517 real(kind=rp) :: mu_amax, kappa_amax
520 n = this%dm_Xh%size()
522 if (neko_bcknd_device .eq. 1)
then
523 mu_amax = device_glamax(this%mu%x_d, n)
524 kappa_amax = device_glamax(this%kappa%x_d, n)
526 mu_amax = glamax(this%mu%x, n)
527 kappa_amax = glamax(this%kappa%x, n)
530 this%mu_amax = mu_amax
531 this%kappa_amax = kappa_amax
533 this%add_physical_stress = (mu_amax .ne. 0.0_rp)
534 this%add_physical_flux = this%add_physical_stress .or. &
535 (kappa_amax .ne. 0.0_rp)
537 call compressible_rhs_set_physical_flux(this%add_physical_flux, &
538 this%add_physical_stress)
548 n = this%u%dof%size()
551 if (neko_bcknd_device .eq. 1)
then
552 call compressible_ops_device_compute_max_wave_speed( &
553 this%max_wave_speed, this%u, this%v, this%w, this%gamma, this%p, &
556 call compressible_ops_cpu_compute_max_wave_speed(this%max_wave_speed%x, &
557 this%u%x, this%v%x, this%w%x, this%gamma, this%p%x, this%rho%x, n)
569 type(json_file),
intent(inout) :: params
570 character(len=*),
intent(in) :: scheme
571 integer,
intent(in) :: lx
572 character(len=LOG_SIZE) :: log_buf
573 logical :: logical_val
574 integer :: integer_val
576 call neko_log%section(
'Fluid')
577 write(log_buf,
'(A, A)')
'Type : ', trim(scheme)
578 call neko_log%message(log_buf)
579 write(log_buf,
'(A, A)')
'Name : ', trim(this%name)
580 call neko_log%message(log_buf)
584 write(log_buf,
'(A, I1)')
'Poly order : ', lx-1
585 else if (lx .ge. 10)
then
586 write(log_buf,
'(A, I2)')
'Poly order : ', lx-1
588 write(log_buf,
'(A, I3)')
'Poly order : ', lx-1
590 call neko_log%message(log_buf)
593 write(log_buf,
'(A, I0)')
'GLL points : ', this%glb_n_points
594 call neko_log%message(log_buf)
595 write(log_buf,
'(A, I0)')
'Unique pts.: ', this%glb_unique_points
596 call neko_log%message(log_buf)
599 write(log_buf,
'(A,ES13.6)')
'gamma :', this%gamma
600 call neko_log%message(log_buf)
602 call json_get_or_default(params,
'case.numerics.time_order', integer_val, 4)
603 write(log_buf,
'(A, I0)')
'RK order : ', integer_val
604 call neko_log%message(log_buf)
606 call json_get_or_default(params, &
607 'case.numerics.compress_geometric_factors', logical_val, .false.)
608 write(log_buf,
'(A, L1)')
'Compress G : ', logical_val
609 call neko_log%message(log_buf)
613 if (this%variable_material_properties)
then
614 write(log_buf,
'(A,ES13.6,A)')
'mu :', this%mu_amax, &
616 call neko_log%message(log_buf)
617 write(log_buf,
'(A,ES13.6,A)')
'kappa :', this%kappa_amax, &
619 call neko_log%message(log_buf)
621 write(log_buf,
'(A,ES13.6)')
'mu :', this%mu_amax
622 call neko_log%message(log_buf)
623 write(log_buf,
'(A,ES13.6)')
'kappa :', this%kappa_amax
624 call neko_log%message(log_buf)
627 if (this%add_physical_flux)
then
628 write(log_buf,
'(A, A)')
'NS fluxes : ',
'enabled'
630 write(log_buf,
'(A, A)')
'NS fluxes : ', &
631 'disabled (mu = kappa = 0, Euler)'
633 call neko_log%message(log_buf)
635 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, public set_flow_ic_user_compressible(rho, u, v, w, p, coef, gs, user_proc, scheme_name)
Set initial flow condition (user defined) for compressible flows.
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.
subroutine fluid_scheme_compressible_set_user_initial_condition(this, user)
Set the initial condition of the density, velocity and pressure with the user routine.
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...