35 use,
intrinsic :: iso_fortran_env, only: error_unit
52 use json_module,
only : json_file, json_core, json_value
78 type(
field_t) :: rho_res, m_x_res, m_y_res, m_z_res, m_e_res
79 type(
field_t) :: drho, dm_x, dm_y, dm_z, de
81 real(kind=
rp) :: c_avisc_low
83 class(
ax_t),
allocatable :: ax
95 procedure, pass(this) :: setup_bcs &
108 module subroutine density_bc_factory(object, scheme, json, coef, user)
109 class(
bc_t),
pointer,
intent(inout) :: object
110 type(fluid_scheme_compressible_euler_t),
intent(in) :: scheme
111 type(json_file),
intent(inout) :: json
112 type(
coef_t),
intent(in) :: coef
113 type(
user_t),
intent(in) :: user
114 end subroutine density_bc_factory
125 module subroutine pressure_bc_factory(object, scheme, json, coef, user)
126 class(
bc_t),
pointer,
intent(inout) :: object
127 type(fluid_scheme_compressible_euler_t),
intent(in) :: scheme
128 type(json_file),
intent(inout) :: json
129 type(
coef_t),
intent(in) :: coef
130 type(
user_t),
intent(in) :: user
131 end subroutine pressure_bc_factory
142 module subroutine velocity_bc_factory(object, scheme, json, coef, user)
143 class(
bc_t),
pointer,
intent(inout) :: object
144 type(fluid_scheme_compressible_euler_t),
intent(in) :: scheme
145 type(json_file),
intent(inout) :: json
146 type(
coef_t),
intent(in) :: coef
147 type(
user_t),
intent(in) :: user
148 end subroutine velocity_bc_factory
159 subroutine fluid_scheme_compressible_euler_init(this, msh, lx, params, user, &
161 class(fluid_scheme_compressible_euler_t),
target,
intent(inout) :: this
162 type(
mesh_t),
target,
intent(inout) :: msh
163 integer,
intent(in) :: lx
164 type(json_file),
target,
intent(inout) :: params
165 type(
user_t),
target,
intent(in) :: user
166 type(
chkp_t),
target,
intent(inout) :: chkp
167 character(len=12),
parameter :: scheme =
'compressible'
173 call this%scheme_init(msh, lx, params, scheme, user)
175 call euler_rhs_factory(this%euler_rhs)
177 associate(xh_lx => this%Xh%lx, xh_ly => this%Xh%ly, xh_lz => this%Xh%lz, &
178 dm_xh => this%dm_Xh, nelv => this%msh%nelv)
180 call this%drho%init(dm_xh,
'drho')
181 call this%dm_x%init(dm_xh,
'dm_x')
182 call this%dm_y%init(dm_xh,
'dm_y')
183 call this%dm_z%init(dm_xh,
'dm_z')
184 call this%dE%init(dm_xh,
'dE')
185 call this%h%init(dm_xh,
'h')
190 associate(p => this%p, rho_field => this%rho_field, &
191 u => this%u, v => this%v, w => this%w, &
192 m_x => this%m_x, m_y => this%m_y, m_z => this%m_z)
195 call device_memcpy(rho_field%x, rho_field%x_d, rho_field%dof%size(), &
213 call ax_helm_factory(this%Ax, full_formulation = .false.)
216 call this%compute_h()
217 call json_get_or_default(params,
'case.numerics.c_avisc_low', &
218 this%c_avisc_low, 0.5_rp)
221 call json_get_or_default(params,
'case.numerics.time_order', rk_order, 4)
222 call this%rk_scheme%init(rk_order)
225 call this%setup_bcs(user, params)
159 subroutine fluid_scheme_compressible_euler_init(this, msh, lx, params, user, &
…
227 end subroutine fluid_scheme_compressible_euler_init
231 subroutine fluid_scheme_compressible_euler_free(this)
232 class(fluid_scheme_compressible_euler_t),
intent(inout) :: this
234 if (
allocated(this%Ax))
then
238 call this%drho%free()
239 call this%dm_x%free()
240 call this%dm_y%free()
241 call this%dm_z%free()
231 subroutine fluid_scheme_compressible_euler_free(this)
…
245 end subroutine fluid_scheme_compressible_euler_free
254 subroutine fluid_scheme_compressible_euler_step(this, t, tstep, dt, &
255 ext_bdf, dt_controller)
256 class(fluid_scheme_compressible_euler_t),
target,
intent(inout) :: this
257 real(kind=rp),
intent(in) :: t
258 integer,
intent(in) :: tstep
259 real(kind=rp),
intent(in) :: dt
260 type(time_scheme_controller_t),
intent(in) :: ext_bdf
261 type(time_step_controller_t),
intent(in) :: dt_controller
262 type(field_t),
pointer :: temp
263 integer :: temp_indices(1)
267 n = this%dm_Xh%size()
268 call this%scratch%request_field(temp, temp_indices(1))
270 call profiler_start_region(
'Fluid compressible', 1)
271 associate(u => this%u, v => this%v, w => this%w, p => this%p, &
272 m_x=> this%m_x, m_y => this%m_y, m_z => this%m_z, &
273 xh => this%Xh, msh => this%msh, ax => this%Ax, &
274 c_xh => this%c_Xh, dm_xh => this%dm_Xh, gs_xh => this%gs_Xh, &
275 rho => this%rho, mu => this%mu, e => this%E, &
276 rho_field => this%rho_field, mu_field => this%mu_field, &
277 ulag => this%ulag, vlag => this%vlag, wlag => this%wlag, &
278 f_x => this%f_x, f_y => this%f_y, f_z => this%f_z, &
279 drho => this%drho, dm_x => this%dm_x, dm_y => this%dm_y, &
280 dm_z => this%dm_z, de => this%dE, &
281 euler_rhs => this%euler_rhs, h => this%h, &
282 c_avisc_low => this%c_avisc_low, rk_scheme => this%rk_scheme)
287 call euler_rhs%step(rho_field, m_x, m_y, m_z, e, &
289 c_xh, gs_xh, h, c_avisc_low, &
293 call this%bcs_density%apply(rho_field, t, tstep)
297 call field_copy(u, m_x, n)
298 call field_invcol2(u, rho_field, n)
299 call field_copy(v, m_y, n)
300 call field_invcol2(v, rho_field, n)
301 call field_copy(w, m_z, n)
302 call field_invcol2(w, rho_field, n)
305 call this%bcs_vel%apply_vector(u%x, v%x, w%x, &
306 dm_xh%size(), t, tstep, strong = .true.)
307 call field_copy(m_x, u, n)
308 call field_col2(m_x, rho_field, n)
309 call field_copy(m_y, v, n)
310 call field_col2(m_y, rho_field, n)
311 call field_copy(m_z, w, n)
312 call field_col2(m_z, rho_field, n)
315 call field_col3(temp, u, u, n)
316 call field_addcol3(temp, v, v, n)
317 call field_addcol3(temp, w, w, n)
318 call field_col2(temp, rho_field, n)
319 call field_cmult(temp, 0.5_rp, n)
320 call field_copy(p, e, n)
321 call field_sub2(p, temp, n)
322 call field_cmult(p, this%gamma - 1.0_rp, n)
325 call this%bcs_prs%apply(p, t, tstep)
328 call field_copy(e, p, n)
329 call field_cmult(e, 1.0_rp / (this%gamma - 1.0_rp), n)
331 call field_add2(e, temp, n)
339 call profiler_end_region(
'Fluid compressible', 1)
341 call this%scratch%relinquish_field(temp_indices)
254 subroutine fluid_scheme_compressible_euler_step(this, t, tstep, dt, &
…
343 end subroutine fluid_scheme_compressible_euler_step
349 subroutine fluid_scheme_compressible_euler_setup_bcs(this, user, params)
350 class(fluid_scheme_compressible_euler_t),
intent(inout) :: this
351 type(user_t),
target,
intent(in) :: user
352 type(json_file),
intent(inout) :: params
353 integer :: i, n_bcs, zone_index, j, zone_size, global_zone_size, ierr
354 class(bc_t),
pointer :: bc_i
355 type(json_core) :: core
356 type(json_value),
pointer :: bc_object
357 type(json_file) :: bc_subdict
359 integer,
allocatable :: zone_indices(:)
360 character(len=LOG_SIZE) :: log_buf
363 if (params%valid_path(
'case.fluid.boundary_conditions'))
then
364 call params%info(
'case.fluid.boundary_conditions', n_children = n_bcs)
365 call params%get_core(core)
366 call params%get(
'case.fluid.boundary_conditions', bc_object, found)
371 call this%bcs_vel%init(n_bcs)
375 call json_extract_item(core, bc_object, i, bc_subdict)
376 call json_get(bc_subdict,
"zone_indices", zone_indices)
379 do j = 1,
size(zone_indices)
380 zone_size = this%msh%labeled_zones(zone_indices(j))%size
381 call mpi_allreduce(zone_size, global_zone_size, 1, &
382 mpi_integer, mpi_max, neko_comm, ierr)
384 if (global_zone_size .eq. 0)
then
385 write(error_unit,
'(A,I0,A)')
"Error: Zone ", zone_indices(j), &
393 call velocity_bc_factory(bc_i, this, bc_subdict, this%c_Xh, user)
396 if (
associated(bc_i))
then
397 call this%bcs_vel%append(bc_i)
404 call this%bcs_prs%init(n_bcs)
408 call json_extract_item(core, bc_object, i, bc_subdict)
410 call pressure_bc_factory(bc_i, this, bc_subdict, this%c_Xh, user)
414 if (
associated(bc_i))
then
415 call this%bcs_prs%append(bc_i)
422 call this%bcs_density%init(n_bcs)
426 call json_extract_item(core, bc_object, i, bc_subdict)
428 call density_bc_factory(bc_i, this, bc_subdict, this%c_Xh, user)
432 if (
associated(bc_i))
then
433 call this%bcs_density%append(bc_i)
349 subroutine fluid_scheme_compressible_euler_setup_bcs(this, user, params)
…
437 end subroutine fluid_scheme_compressible_euler_setup_bcs
443 subroutine compute_h(this)
444 class(fluid_scheme_compressible_euler_t),
intent(inout) :: this
445 integer :: e, i, j, k
446 integer :: im, ip, jm, jp, km, kp
447 real(kind=rp) :: di, dj, dk, ndim_inv
448 integer :: lx_half, ly_half, lz_half
450 lx_half = this%c_Xh%Xh%lx / 2
451 ly_half = this%c_Xh%Xh%ly / 2
452 lz_half = this%c_Xh%Xh%lz / 2
454 do e = 1, this%c_Xh%msh%nelv
455 do k = 1, this%c_Xh%Xh%lz
457 kp = min(this%c_Xh%Xh%lz, k+1)
459 do j = 1, this%c_Xh%Xh%ly
461 jp = min(this%c_Xh%Xh%ly, j+1)
463 do i = 1, this%c_Xh%Xh%lx
465 ip = min(this%c_Xh%Xh%lx, i+1)
467 di = (this%c_Xh%dof%x(ip, j, k, e) - &
468 this%c_Xh%dof%x(im, j, k, e))**2 &
469 + (this%c_Xh%dof%y(ip, j, k, e) - &
470 this%c_Xh%dof%y(im, j, k, e))**2 &
471 + (this%c_Xh%dof%z(ip, j, k, e) - &
472 this%c_Xh%dof%z(im, j, k, e))**2
474 dj = (this%c_Xh%dof%x(i, jp, k, e) - &
475 this%c_Xh%dof%x(i, jm, k, e))**2 &
476 + (this%c_Xh%dof%y(i, jp, k, e) - &
477 this%c_Xh%dof%y(i, jm, k, e))**2 &
478 + (this%c_Xh%dof%z(i, jp, k, e) - &
479 this%c_Xh%dof%z(i, jm, k, e))**2
481 dk = (this%c_Xh%dof%x(i, j, kp, e) - &
482 this%c_Xh%dof%x(i, j, km, e))**2 &
483 + (this%c_Xh%dof%y(i, j, kp, e) - &
484 this%c_Xh%dof%y(i, j, km, e))**2 &
485 + (this%c_Xh%dof%z(i, j, kp, e) - &
486 this%c_Xh%dof%z(i, j, km, e))**2
488 di = sqrt(di) / (ip - im)
489 dj = sqrt(dj) / (jp - jm)
490 dk = sqrt(dk) / (kp - km)
491 this%h%x(i,j,k,e) = (di * dj * dk)**(1.0_rp / 3.0_rp)
498 if (neko_bcknd_device .eq. 1)
then
499 call device_memcpy(this%h%x, this%h%x_d, this%h%dof%size(),&
500 host_to_device, sync = .false.)
501 call this%gs_Xh%op(this%h, gs_op_add)
502 call device_col2(this%h%x_d, this%c_Xh%mult_d, this%h%dof%size())
504 call this%gs_Xh%op(this%h, gs_op_add)
505 call col2(this%h%x, this%c_Xh%mult, this%h%dof%size())
443 subroutine compute_h(this)
…
508 end subroutine compute_h
514 subroutine fluid_scheme_compressible_euler_restart(this, chkp)
515 class(fluid_scheme_compressible_euler_t),
target,
intent(inout) :: this
516 type(chkp_t),
intent(inout) :: chkp
514 subroutine fluid_scheme_compressible_euler_restart(this, chkp)
…
517 end subroutine fluid_scheme_compressible_euler_restart
Copy data between host and device (or device and device)
Abstract interface to evaluate rhs.
Retrieves a parameter by name or assigns a provided default value. In the latter case also adds the m...
Retrieves a parameter by name or throws an error.
Subroutines to add advection terms to the RHS of a transport equation.
Defines a Matrix-vector product.
Defines a boundary condition.
subroutine, public device_col2(a_d, b_d, n)
Vector multiplication .
Device abstraction, common interface for various accelerators.
integer, parameter, public host_to_device
Defines a mapping of the degrees of freedom.
Defines inflow dirichlet conditions.
Defines user dirichlet condition for a scalar field.
subroutine, public field_invcol2(a, b, n)
Vector division .
subroutine, public field_cadd(a, s, n)
Add a scalar to vector .
subroutine, public field_col2(a, b, n)
Vector multiplication .
subroutine, public field_sub2(a, b, n)
Vector substraction .
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_copy(a, b, n)
Copy a vector .
subroutine, public field_cmult(a, c, n)
Multiplication by constant c .
subroutine compute_h(this)
Copied from les_model_compute_delta in les_model.f90 TODO: move to a separate module Compute characte...
subroutine fluid_scheme_compressible_euler_init(this, msh, lx, params, user, chkp)
Boundary condition factory for density.
subroutine fluid_scheme_compressible_euler_step(this, t, tstep, dt, ext_bdf, dt_controller)
Advance the fluid simulation one timestep.
subroutine fluid_scheme_compressible_euler_free(this)
Free allocated memory and cleanup.
subroutine fluid_scheme_compressible_euler_restart(this, chkp)
Restart the simulation from saved state.
subroutine fluid_scheme_compressible_euler_setup_bcs(this, user, params)
Set up boundary conditions for the fluid scheme.
Defines Gather-scatter operations.
integer, parameter, public gs_op_add
Utilities for retrieving parameters from the case files.
integer, parameter, public log_size
subroutine, public subcol3(a, b, c, n)
Returns .
subroutine, public addcol3(a, b, c, n)
Returns .
subroutine, public col2(a, b, n)
Vector multiplication .
subroutine, public copy(a, b, n)
Copy a vector .
subroutine, public col3(a, b, c, n)
Vector multiplication with 3 vectors .
integer, parameter neko_bcknd_device
integer, parameter, public rp
Global precision used in computations.
subroutine, public div(res, ux, uy, uz, coef)
Compute the divergence of a vector field.
subroutine, public grad(ux, uy, uz, u, coef)
Compute the gradient of a scalar field.
subroutine, public profiler_start_region(name, region_id)
Started a named (name) profiler region.
subroutine, public profiler_end_region(name, region_id)
End the most recently started profiler region.
Defines a function space.
Compound scheme for the advection and diffusion operators in a transport equation.
Implements type time_step_controller.
Interfaces for user interaction with NEKO.
subroutine, public neko_warning(warning_msg)
Reports a warning to standard output.
Defines a zero-valued Dirichlet boundary condition.
Base abstract type for computing the advection operator.
Base type for a matrix-vector product providing .
Base type for a boundary condition.
A list of allocatable `bc_t`. Follows the standard interface of lists.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Abstract type to compute rhs.
User defined dirichlet condition, for which the user can work with an entire field....
Extension of the user defined dirichlet condition field_dirichlet
field_list_t, To be able to group fields together
Base type of compressible fluid formulations.
The function space for the SEM solution fields.
Implements the logic to compute the time coefficients for the advection and diffusion operators in a ...
Provides a tool to set time step dt.
A type collecting all the overridable user routines.
Zero-valued Dirichlet boundary condition. Used for no-slip walls, but also for various auxillary cond...