38 rhs_maker_ext_fctry, rhs_maker_bdf_fctry, rhs_maker_oifs_fctry
64 use json_module,
only : json_file
83 class(
ax_t),
allocatable :: ax
141 material_properties, ulag, vlag, wlag, &
144 type(
mesh_t),
target,
intent(inout) :: msh
145 type(
coef_t),
target,
intent(inout) :: coef
146 type(
gs_t),
target,
intent(inout) :: gs
147 type(json_file),
target,
intent(inout) :: params
148 type(
user_t),
target,
intent(in) :: user
153 character(len=15),
parameter :: scheme =
'Modular (Pn/Pn)'
158 call this%scheme_init(msh, coef, gs, params, scheme, user, &
162 call ax_helm_factory(this%ax, full_formulation = .false.)
165 call scalar_residual_factory(this%res)
168 call rhs_maker_ext_fctry(this%makeext)
171 call rhs_maker_bdf_fctry(this%makebdf)
174 call rhs_maker_oifs_fctry(this%makeoifs)
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%s_res%init(dm_xh,
"s_res")
182 call this%abx1%init(dm_xh,
"abx1")
184 call this%abx2%init(dm_xh,
"abx2")
186 call this%advs%init(dm_xh,
"advs")
188 call this%ds%init(dm_xh,
'ds')
194 call this%bc_res%init_base(this%c_Xh)
195 do i = 1, this%n_dir_bcs
196 call this%bc_res%mark_facets(this%dir_bcs(i)%marked_facet)
200 if (this%user_bc%msk(0) .gt. 0)
then
201 call this%bc_res%mark_facets(this%user_bc%marked_facet)
204 call this%bc_res%mark_zones_from_list(msh%labeled_zones,
'd_s', &
206 call this%bc_res%finalize()
207 call this%bc_res%set_g(0.0_rp)
214 call this%proj_s%init(this%dm_Xh%size(), this%projection_dim, &
215 this%projection_activ_step)
225 call advection_factory(this%adv, params, this%c_Xh, &
226 ulag, vlag, wlag, this%chkp%dtlag, &
233 real(kind=rp) :: dtlag(10), tlag(10)
237 n = this%s%dof%size()
239 call col2(this%s%x, this%c_Xh%mult, n)
240 call col2(this%slag%lf(1)%x, this%c_Xh%mult, n)
241 call col2(this%slag%lf(2)%x, this%c_Xh%mult, n)
242 if (neko_bcknd_device .eq. 1)
then
243 call device_memcpy(this%s%x, this%s%x_d, &
244 n, host_to_device, sync = .false.)
245 call device_memcpy(this%slag%lf(1)%x, this%slag%lf(1)%x_d, &
246 n, host_to_device, sync = .false.)
247 call device_memcpy(this%slag%lf(2)%x, this%slag%lf(2)%x_d, &
248 n, host_to_device, sync = .false.)
249 call device_memcpy(this%abx1%x, this%abx1%x_d, &
250 n, host_to_device, sync = .false.)
251 call device_memcpy(this%abx2%x, this%abx2%x_d, &
252 n, host_to_device, sync = .false.)
253 call device_memcpy(this%advs%x, this%advs%x_d, &
254 n, host_to_device, sync = .false.)
257 call this%gs_Xh%op(this%s, gs_op_add)
258 call this%gs_Xh%op(this%slag%lf(1), gs_op_add)
259 call this%gs_Xh%op(this%slag%lf(2), gs_op_add)
267 call this%scheme_free()
269 call bc_list_free(this%bclst_ds)
270 call this%proj_s%free()
272 call this%s_res%free()
276 call this%abx1%free()
277 call this%abx2%free()
279 call this%advs%free()
281 if (
allocated(this%Ax))
then
285 if (
allocated(this%res))
then
289 if (
allocated(this%makeext))
then
290 deallocate(this%makeext)
293 if (
allocated(this%makebdf))
then
294 deallocate(this%makebdf)
297 if (
allocated(this%makeoifs))
then
298 deallocate(this%makeoifs)
305 real(kind=rp),
intent(inout) :: t
306 integer,
intent(inout) :: tstep
307 real(kind=rp),
intent(in) :: dt
308 type(time_scheme_controller_t),
intent(inout) :: ext_bdf
309 type(time_step_controller_t),
intent(in) :: dt_controller
313 type(ksp_monitor_t) :: ksp_results(1)
314 character(len=LOG_SIZE) :: log_buf
316 n = this%dm_Xh%size()
318 call profiler_start_region(
'Scalar', 2)
319 associate(u => this%u, v => this%v, w => this%w, s => this%s, &
320 cp => this%cp, rho => this%rho, &
322 s_res => this%s_res, &
323 ax => this%Ax, f_xh => this%f_Xh, xh => this%Xh, &
324 c_xh => this%c_Xh, dm_xh => this%dm_Xh, gs_xh => this%gs_Xh, &
325 slag => this%slag, oifs => this%oifs, &
326 lambda_field => this%lambda_field, &
327 projection_dim => this%projection_dim, &
328 msh => this%msh, res => this%res, makeoifs => this%makeoifs, &
329 makeext => this%makeext, makebdf => this%makebdf, &
330 if_variable_dt => dt_controller%if_variable_dt, &
331 dt_last_change => dt_controller%dt_last_change)
333 if (neko_log%level_ .ge. neko_log_debug)
then
334 write(log_buf,
'(A,A,E15.7,A,E15.7,A,E15.7)')
'Scalar debug', &
335 ' l2norm s', glsc2(this%s%x, this%s%x, n), &
336 ' slag1', glsc2(this%slag%lf(1)%x, this%slag%lf(1)%x, n), &
337 ' slag2', glsc2(this%slag%lf(2)%x, this%slag%lf(2)%x, n)
338 call neko_log%message(log_buf)
339 write(log_buf,
'(A,A,E15.7,A,E15.7)')
'Scalar debug2', &
340 ' l2norm abx1', glsc2(this%abx1%x, this%abx1%x, n), &
341 ' abx2', glsc2(this%abx2%x, this%abx2%x, n)
342 call neko_log%message(log_buf)
346 call this%source_term%compute(t, tstep)
349 if (neko_bcknd_device .eq. 1)
then
350 call device_col2(f_xh%x_d, c_xh%B_d, n)
352 call col2(f_xh%x, c_xh%B, n)
356 call bc_list_apply_scalar(this%bclst_neumann, this%f_Xh%x, dm_xh%size())
360 call this%adv%compute_scalar(u, v, w, s, this%advs, &
361 xh, this%c_Xh, dm_xh%size())
363 call makeext%compute_scalar(this%abx1, this%abx2, f_xh%x, rho, &
364 ext_bdf%advection_coeffs, n)
366 call makeoifs%compute_scalar(this%advs%x, f_xh%x, rho, dt, n)
369 call this%adv%compute_scalar(u, v, w, s, f_xh, &
370 xh, this%c_Xh, dm_xh%size())
376 call makeext%compute_scalar(this%abx1, this%abx2, f_xh%x, rho, &
377 ext_bdf%advection_coeffs, n)
380 call makebdf%compute_scalar(slag, f_xh%x, s, c_xh%B, rho, dt, &
381 ext_bdf%diffusion_coeffs, ext_bdf%ndiff, n)
389 call this%field_dir_bc%update(this%field_dir_bc%field_list, &
390 this%field_dirichlet_bcs, this%c_Xh, t, tstep,
"scalar")
391 call bc_list_apply_scalar(this%bclst_dirichlet, &
392 this%s%x, this%dm_Xh%size())
396 call this%update_material_properties()
399 call profiler_start_region(
'Scalar_residual', 20)
400 call res%compute(ax, s, s_res, f_xh, c_xh, msh, xh, lambda_field, &
401 rho*cp, ext_bdf%diffusion_coeffs(1), dt, dm_xh%size())
403 call gs_xh%op(s_res, gs_op_add)
406 call bc_list_apply_scalar(this%bclst_ds, s_res%x, dm_xh%size())
408 call profiler_end_region(
'Scalar_residual', 20)
410 call this%proj_s%pre_solving(s_res%x, tstep, c_xh, n, dt_controller)
412 call this%pc%update()
413 call profiler_start_region(
'Scalar_solve', 21)
414 ksp_results(1) = this%ksp%solve(ax, ds, s_res%x, n, &
415 c_xh, this%bclst_ds, gs_xh)
416 call profiler_end_region(
'Scalar_solve', 21)
418 call this%proj_s%post_solving(ds%x, ax, c_xh, &
419 this%bclst_ds, gs_xh, n, tstep, dt_controller)
422 if (neko_bcknd_device .eq. 1)
then
423 call device_add2s2(s%x_d, ds%x_d, 1.0_rp, n)
425 call add2s2(s%x, ds%x, 1.0_rp, n)
428 call scalar_step_info(tstep, t, dt, ksp_results)
431 call profiler_end_region(
'Scalar', 2)
Copy data between host and device (or device and device)
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 bc_list_add(bclst, bc)
Add a condition to a list of boundary conditions.
subroutine, public bc_list_init(bclst, size)
Constructor for a list of boundary conditions.
subroutine, public bc_list_free(bclst)
Destructor for a list of boundary conditions.
subroutine, public bc_list_apply_scalar(bclst, x, n, t, tstep)
Apply a list of boundary conditions to a scalar field.
subroutine, public device_col2(a_d, b_d, n)
Vector multiplication .
subroutine, public device_add2s2(a_d, b_d, c1, n)
Vector addition with scalar multiplication (multiplication on first argument)
Device abstraction, common interface for various accelerators.
integer, parameter, public host_to_device
Defines a dirichlet boundary condition.
Dirichlet condition applied in the facet normal direction.
Utilities for retrieving parameters from the case files.
Implements the base abstract type for Krylov solvers plus helper types.
integer, parameter, public neko_log_debug
Debug log level.
type(log_t), public neko_log
Global log stream.
integer, parameter, public log_size
Implements material_properties_t type.
real(kind=rp) function, public glsc2(a, b, n)
Weighted inner product .
subroutine, public col2(a, b, n)
Vector multiplication .
subroutine, public add2s2(a, b, c1, n)
Vector addition with scalar multiplication (multiplication on second argument)
integer, parameter neko_bcknd_device
Defines a Neumann boundary condition.
integer, parameter, public rp
Global precision used in computations.
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.
Project x onto X, the space of old solutions and back again.
Routines to generate the right-hand sides for the convection-diffusion equation. Employs the EXT/BDF ...
Auxiliary routines for fluid solvers.
subroutine scalar_step_info(step, t, dt, ksp_results)
Prints for prs, velx, vely, velz the following: Number of iterations, start residual,...
Containts the scalar_pnpn_t type.
subroutine scalar_pnpn_step(this, t, tstep, dt, ext_bdf, dt_controller)
subroutine scalar_pnpn_init(this, msh, coef, gs, params, user, material_properties, ulag, vlag, wlag, time_scheme)
Constructor.
subroutine scalar_pnpn_restart(this, dtlag, tlag)
I envision the arguments to this func might need to be expanded.
subroutine scalar_pnpn_free(this)
Defines the residual for the scalar transport equation.
Contains the scalar_scheme_t type.
Defines a registry for storing and requesting temporary fields This can be used when you have a funct...
type(scratch_registry_t), target, public neko_scratch_registry
Global scratch registry.
Compound scheme for the advection and diffusion operators in a transport equation.
Base class for time integration schemes.
Implements type time_step_controller.
Interfaces for user interaction with NEKO.
Base abstract type for computing the advection operator.
Base type for a matrix-vector product providing .
A list of boundary conditions.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Generic Dirichlet boundary condition on .
Dirichlet condition in facet normal direction.
Type for storing initial and final residuals in a Krylov solver.
Contains all the material properties necessary in the simulation.
Generic Neumann boundary condition. This sets the flux of the field to the chosen value.
Abstract type to add contributions to F from lagged BD terms.
Abstract type to sum up contributions to kth order extrapolation scheme.
Abstract type to add contributions of kth order OIFS scheme.
Abstract type to compute scalar residual.
Base type for a scalar advection-diffusion solver.
Implements the logic to compute the time coefficients for the advection and diffusion operators in a ...
Provides a tool to set time step dt.