Neko 1.99.11
A portable framework for high-order spectral element flow simulations
Loading...
Searching...
No Matches
fluid_pnpn.f90
Go to the documentation of this file.
1! Copyright (c) 2022-2026, The Neko Authors
2! All rights reserved.
3!
4! Redistribution and use in source and binary forms, with or without
5! modification, are permitted provided that the following conditions
6! are met:
7!
8! * Redistributions of source code must retain the above copyright
9! notice, this list of conditions and the following disclaimer.
10!
11! * Redistributions in binary form must reproduce the above
12! copyright notice, this list of conditions and the following
13! disclaimer in the documentation and/or other materials provided
14! with the distribution.
15!
16! * Neither the name of the authors nor the names of its
17! contributors may be used to endorse or promote products derived
18! from this software without specific prior written permission.
19!
20! THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21! "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22! LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23! FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24! COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25! INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
26! BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27! LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
28! CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29! LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
30! ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
31! POSSIBILITY OF SUCH DAMAGE.
32!
33!> Modular version of the Classic Nek5000 Pn/Pn formulation for fluids
35 use coefs, only : coef_t
36 use registry, only : neko_registry
37 use logger, only : neko_log, log_size
38 use num_types, only : rp, dp
39 use krylov, only : ksp_monitor_t
41 pnpn_prs_res_factory, pnpn_vel_res_factory, &
42 pnpn_prs_res_stress_factory, pnpn_vel_res_stress_factory
44 rhs_maker_oifs_t, rhs_maker_sumab_fctry, rhs_maker_bdf_fctry, &
45 rhs_maker_ext_fctry, rhs_maker_oifs_fctry
50 use fluid_aux, only : fluid_step_info
51 use projection, only : projection_t
54 use advection, only : advection_t, advection_factory
55 use adv_oifs, only : adv_oifs_t
57 use json_module, only : json_file, json_core, json_value
60 use ax_product, only : ax_t, ax_helm_allocator
61 use ax_helm_svv, only : ax_helm_svv_t
63 use field, only : field_t
64 use dirichlet, only : dirichlet_t
69 use non_normal, only : non_normal_t
71 use symmetry, only : symmetry_t
72 use checkpoint, only : chkp_t
74 use mesh, only : mesh_t
75 use user_intf, only : user_t
77 use gs_ops, only : gs_op_add
79 use mathops, only : opadd2cm, opcolv
83 use bc, only : bc_t, bc_dirichlet
84 use mixed_bc, only : mixed_bc_t
88 use file, only : file_t
89 use operators, only : ortho, rotate_cyc
90 use opr_device, only : device_ortho
91 use time_state, only : time_state_t
92 use comm, only : neko_comm
93 use ale_manager, only : ale_manager_t
95 use mpi_f08, only : mpi_allreduce, mpi_in_place, mpi_max, mpi_lor, &
96 mpi_integer, mpi_logical
97 implicit none
98 private
99
100
101
103
104 !> Number of schwarz-like iterations to perform each time step.
105 !! Set to 0 for no iterations.
106 integer :: schwarz_iterations = 0
107
108 !> The right-hand sides in the linear solves.
109 type(field_t) :: p_res, u_res, v_res, w_res
110
111 !> The unknowns in the linear solves, i.e. the solution increments with
112 !! respect to the previous time-step.
113 type(field_t) :: dp, du, dv, dw
114
115 !> ALE Manager
116 type(ale_manager_t) :: ale
117
118 ! ! Implicit operators, i.e. the left-hand-side of the Helmholz problem.
119 !
120
121 ! Coupled Helmholz operator for velocity
122 class(ax_t), allocatable :: ax_vel
123 ! Helmholz operator for pressure
124 class(ax_t), allocatable :: ax_prs
125
126 !
127 ! Projections for solver speed-up
128 !
129
130 !> Pressure projection
131 type(projection_t) :: proj_prs
132 type(projection_vel_t) :: proj_vel
133
134 !
135 ! Special Karniadakis scheme boundary conditions in the pressure equation
136 !
137
138 !> Surface term in pressure rhs. Masks all strong velocity bcs.
139 type(facet_normal_t) :: bc_prs_surface
140
141 !> Surface term in pressure rhs. Masks symmetry bcs.
142 type(facet_normal_t) :: bc_sym_surface
143
144 !> Boundary conditions projector for velocity constraints.
145 class(vector_bc_projector_t), allocatable :: bcs_vel_projector
146 !> Boundary conditions projector for pressure constraints.
147 type(scalar_bc_projector_t) :: bcs_prs_projector
148
149
150 ! Checker for wether we have a strong pressure bc. If not, the pressure
151 ! is demeaned at every time step.
152 logical :: prs_dirichlet = .false.
153
154
155 ! The advection operator.
156 class(advection_t), allocatable :: adv
157
158 ! Time OIFS interpolation scheme for advection.
159 logical :: oifs
160
161 ! Time variables
162 type(field_t) :: abx1, aby1, abz1
163 type(field_t) :: abx2, aby2, abz2
164
165 ! Advection terms for the oifs method
166 type(field_t) :: advx, advy, advz
167
168 !> Pressure residual equation for computing `p_res`.
169 class(pnpn_prs_res_t), allocatable :: prs_res
170
171 !> Velocity residual equation for computing `u_res`, `v_res`, `w_res`.
172 class(pnpn_vel_res_t), allocatable :: vel_res
173
174 !> Summation of AB/BDF contributions
175 class(rhs_maker_sumab_t), allocatable :: sumab
176
177 !> Contributions to kth order extrapolation scheme
178 class(rhs_maker_ext_t), allocatable :: makeabf
179
180 !> Contributions to F from lagged BD terms
181 class(rhs_maker_bdf_t), allocatable :: makebdf
182
183 !> Contributions to the RHS from the OIFS method
184 class(rhs_maker_oifs_t), allocatable :: makeoifs
185
186 !> Adjust flow volume
187 type(fluid_volflow_t) :: vol_flow
188
189 !> Whether to use the full formulation of the viscous stress term
190 logical :: full_stress_formulation = .false.
191
192 contains
193 !> Constructor.
194 procedure, pass(this) :: init => fluid_pnpn_init
195 !> Destructor.
196 procedure, pass(this) :: free => fluid_pnpn_free
197 !> Perform a single time-step of the scheme.
198 procedure, pass(this) :: step => fluid_pnpn_step
199 !> Assemble the explicit part of the right-hand side.
200 procedure, pass(this) :: assemble_rhs => fluid_pnpn_assemble_rhs
201 !> Recompute geometry-dependent quantities after the mesh has moved.
202 procedure, pass(this) :: recompute_metrics => &
204 !> Shift the velocity history by one time step.
205 procedure, pass(this) :: update_velocity_lags => &
207 !> Solve for the pressure and velocity.
208 procedure, pass(this) :: solve => fluid_pnpn_solve
209 !> Restart from a previous solution.
210 procedure, pass(this) :: restart => fluid_pnpn_restart
211 !> Set the initial condition, the lagged velocity fields and the ALE
212 !! mesh velocity.
213 procedure, pass(this) :: set_initial_condition => &
215 !> Set up boundary conditions.
216 procedure, pass(this) :: setup_bcs => fluid_pnpn_setup_bcs
217 !> Write a field with boundary condition specifications.
218 procedure, pass(this) :: write_boundary_conditions => &
220 end type fluid_pnpn_t
221
222 interface
223 !> Split a boundary condition entry of the case file into a velocity
224 !! part and a pressure part.
225 !! @param[inout] json The boundary condition entry.
226 !! @param[inout] velocity_json The velocity part, valid if `has_velocity`.
227 !! @param[inout] pressure_json The pressure part, valid if `has_pressure`.
228 !! @param[out] has_velocity Whether the entry defines a velocity condition.
229 !! @param[out] has_pressure Whether the entry defines a pressure condition.
230 module subroutine fluid_pnpn_bc_split(json, velocity_json, &
231 pressure_json, has_velocity, has_pressure)
232 type(json_file), intent(inout) :: json
233 type(json_file), intent(inout) :: velocity_json
234 type(json_file), intent(inout) :: pressure_json
235 logical, intent(out) :: has_velocity
236 logical, intent(out) :: has_pressure
237 end subroutine fluid_pnpn_bc_split
238 end interface
239
240 interface
241 !> Boundary condition factory for pressure.
242 !! @details Will mark a mesh zone for the bc and finalize.
243 !! @param[inout] object The object to be allocated.
244 !! @param[in] scheme The `fluid_pnpn` scheme.
245 !! @param[inout] json The pressure part of the boundary condition entry.
246 !! @param[in] coef SEM coefficients.
247 !! @param[in] user The user interface.
248 module subroutine pressure_bc_factory(object, scheme, json, coef, user)
249 class(bc_t), pointer, intent(inout) :: object
250 type(fluid_pnpn_t), intent(in) :: scheme
251 type(json_file), intent(inout) :: json
252 type(coef_t), target, intent(in) :: coef
253 type(user_t), target, intent(in) :: user
254 end subroutine pressure_bc_factory
255 end interface
256
257 interface
258 !> Boundary condition factory for velocity
259 !! @details Will mark a mesh zone for the bc and finalize.
260 !! @param[inout] object The object to be allocated.
261 !! @param[in] scheme The `fluid_pnpn` scheme.
262 !! @param[inout] json The velocity part of the boundary condition entry.
263 !! @param[in] coef SEM coefficients.
264 !! @param[in] user The user interface.
265 module subroutine velocity_bc_factory(object, scheme, json, coef, user)
266 class(bc_t), pointer, intent(inout) :: object
267 type(fluid_pnpn_t), intent(in) :: scheme
268 type(json_file), intent(inout) :: json
269 type(coef_t), target, intent(in) :: coef
270 type(user_t), target, intent(in) :: user
271 end subroutine velocity_bc_factory
272 end interface
273
274 interface
275 !> Velocity boundary condition allocator.
276 !! @param[inout] object The object to be allocated.
277 !! @param[in] type_name The name of the boundary condition type.
278 !! @param[in] full_stress_formulation Whether the scheme uses the full
279 !! viscous stress formulation.
280 module subroutine fluid_pnpn_velocity_bc_allocator(object, type_name, &
281 full_stress_formulation)
282 class(bc_t), pointer, intent(inout) :: object
283 character(len=*), intent(in) :: type_name
284 logical, intent(in) :: full_stress_formulation
285 end subroutine fluid_pnpn_velocity_bc_allocator
286 end interface
287
288 interface
289 !> Pressure boundary condition allocator.
290 !! @param[inout] object The object to be allocated.
291 !! @param[in] type_name The name of the boundary condition type.
292 module subroutine fluid_pnpn_pressure_bc_allocator(object, type_name)
293 class(bc_t), pointer, intent(inout) :: object
294 character(len=*), intent(in) :: type_name
295 end subroutine fluid_pnpn_pressure_bc_allocator
296 end interface
297
298 !
299 ! Machinery for injecting user-defined types
300 !
301
302 !> Interface for a fluid Pn/Pn boundary condition allocator.
303 !! Implemented in user modules, it should allocate `obj` to the custom user
304 !! type.
305 abstract interface
306 subroutine fluid_pnpn_bc_allocate(obj)
307 import bc_t
308 class(bc_t), pointer, intent(inout) :: obj
309 end subroutine fluid_pnpn_bc_allocate
310 end interface
311
312 interface
313 !> Called in user modules to add an allocator for custom velocity
314 !! boundary condition types.
315 !! @param[in] type_name The name of the boundary condition type.
316 !! @param[in] allocator The allocator for the custom user type.
317 module subroutine register_fluid_pnpn_velocity_bc(type_name, allocator)
318 character(len=*), intent(in) :: type_name
319 procedure(fluid_pnpn_bc_allocate), pointer, intent(in) :: allocator
320 end subroutine register_fluid_pnpn_velocity_bc
321 end interface
322
323 interface
324 !> Called in user modules to add an allocator for custom pressure
325 !! boundary condition types.
326 !! @param[in] type_name The name of the boundary condition type.
327 !! @param[in] allocator The allocator for the custom user type.
328 module subroutine register_fluid_pnpn_pressure_bc(type_name, allocator)
329 character(len=*), intent(in) :: type_name
330 procedure(fluid_pnpn_bc_allocate), pointer, intent(in) :: allocator
331 end subroutine register_fluid_pnpn_pressure_bc
332 end interface
333
334 !> A name-allocator pair for user-defined fluid Pn/Pn boundary conditions.
335 type fluid_pnpn_bc_allocator_entry
336 character(len=NEKO_TYPENAME_LEN) :: type_name
337 procedure(fluid_pnpn_bc_allocate), pointer, nopass :: allocator => null()
338 end type fluid_pnpn_bc_allocator_entry
339
340 !> Registry of user-defined velocity boundary condition allocators.
341 type(fluid_pnpn_bc_allocator_entry), allocatable, private :: &
342 fluid_pnpn_velocity_bc_registry(:)
343
344 !> The size of `fluid_pnpn_velocity_bc_registry`.
345 integer, private :: fluid_pnpn_velocity_bc_registry_size = 0
346
347 !> Registry of user-defined pressure boundary condition allocators.
348 type(fluid_pnpn_bc_allocator_entry), allocatable, private :: &
349 fluid_pnpn_pressure_bc_registry(:)
350
351 !> The size of `fluid_pnpn_pressure_bc_registry`.
352 integer, private :: fluid_pnpn_pressure_bc_registry_size = 0
353
354 public :: fluid_pnpn_bc_split, fluid_pnpn_bc_allocate, &
355 fluid_pnpn_velocity_bc_allocator, fluid_pnpn_pressure_bc_allocator, &
356 register_fluid_pnpn_velocity_bc, register_fluid_pnpn_pressure_bc
357
358contains
359
360 !> Initialize the Pn/Pn fluid scheme
361 !! @param msh The mesh.
362 !! @param lx The number of GLL points in each direction.
363 !! @param params The fluid parameters, i.e. `case.fluid`.
364 !! @param numerics_params The numerical parameters, i.e. `case.numerics`.
365 !! @param user Type with user-defined procedures.
366 !! @param chkp Checkpoint for restarts.
367 !! @param output_boundary Whether to write the boundary condition markers
368 !! to file.
369 subroutine fluid_pnpn_init(this, msh, lx, params, numerics_params, user, &
370 chkp, output_boundary)
371 class(fluid_pnpn_t), target, intent(inout) :: this
372 type(mesh_t), target, intent(inout) :: msh
373 integer, intent(in) :: lx
374 type(json_file), target, intent(inout) :: params
375 type(json_file), target, intent(inout) :: numerics_params
376 type(user_t), target, intent(in) :: user
377 type(chkp_t), target, intent(inout) :: chkp
378 logical, intent(in) :: output_boundary
379 character(len=15), parameter :: scheme = 'Modular (Pn/Pn)'
380 integer :: i
381 class(bc_t), pointer :: bc_i, vel_bc
382 real(kind=rp) :: abs_tol
383 character(len=LOG_SIZE) :: log_buf
384 integer :: ierr, integer_val
385 character(len=:), allocatable :: solver_type, precon_type
386 logical :: advection
387 type(json_file) :: precon_params, solver_params
388 type(checkpoint_payload_t), pointer :: payload
389 real(kind=dp), pointer :: tlag(:), dtlag(:)
390
391 call this%free()
392
393 ! Initialize base class
394 call this%init_base(msh, lx, params, numerics_params, scheme, user, &
395 .true., output_boundary)
396
397 ! Add pressure field to the registry. For this scheme it is in the same
398 ! Xh as the velocity
399 call neko_registry%add_field(this%dm_Xh, 'p')
400 this%p => neko_registry%get_field('p')
401
402 !
403 ! Select governing equations via associated residual and Ax types
404 !
405
406 call json_get_or_lookup(numerics_params, 'time_order', integer_val)
407 allocate(this%ext_bdf)
408 call this%ext_bdf%init(integer_val)
409
410 call json_get_or_default(params, "full_stress_formulation", &
411 this%full_stress_formulation, .false.)
412
413 call json_get_or_default(params, "cyclic", this%c_Xh%cyclic, &
414 .false.)
415 call this%c_Xh%generate_cyclic_bc()
416
417 ! Setup backend dependent Ax routines for the velocity
418 call fluid_pnpn_ax_vel_factory(this)
419
420 if (this%full_stress_formulation) then
421 ! Setup backend dependent prs residual routines
422 call pnpn_prs_res_stress_factory(this%prs_res)
423
424 ! Setup backend dependent vel residual routines
425 call pnpn_vel_res_stress_factory(this%vel_res)
426
427 ! Allocate coupled projector for velocity boundary conditions
428 allocate(coupled_vector_bc_projector_t :: this%bcs_vel_projector)
429 else
430 ! Setup backend dependent prs residual routines
431 call pnpn_prs_res_factory(this%prs_res)
432
433 ! Setup backend dependent vel residual routines
434 call pnpn_vel_res_factory(this%vel_res)
435
436 ! Allocate segregated projector for velocity boundary conditions
437 allocate(segregated_vector_bc_projector_t :: this%bcs_vel_projector)
438 end if
439
440 ! Initialize the velocity bc projector
441 call this%bcs_vel_projector%init(this%c_Xh)
442
443 if (params%valid_path('nut_field')) then
444 if (.not. this%full_stress_formulation) then
445 call neko_error("You need to set full_stress_formulation to " // &
446 "true for the fluid to have a spatially varying " // &
447 "viscocity field.")
448 end if
449 call json_get(params, 'nut_field', this%nut_field_name)
450 else
451 this%nut_field_name = ""
452 end if
453
454 ! Setup Ax for the pressure
455 if (this%c_Xh%geo_compression) then
456 call ax_helm_allocator(this%Ax_prs, type_name = "standard_compr")
457 else
458 call ax_helm_allocator(this%Ax_prs, type_name = "standard")
459 end if
460
461
462 ! Setup backend dependent summation of AB/BDF
463 call rhs_maker_sumab_fctry(this%sumab)
464
465 ! Setup backend dependent summation of extrapolation scheme
466 call rhs_maker_ext_fctry(this%makeabf)
467
468 ! Setup backend depenent contributions to F from lagged BD terms
469 call rhs_maker_bdf_fctry(this%makebdf)
470
471 ! Setup backend dependent summations of the OIFS method
472 call rhs_maker_oifs_fctry(this%makeoifs)
473
474 ! Initialize variables specific to this plan
475 associate(xh_lx => this%Xh%lx, xh_ly => this%Xh%ly, xh_lz => this%Xh%lz, &
476 dm_xh => this%dm_Xh, nelv => this%msh%nelv)
477
478 call this%p_res%init(dm_xh, "p_res")
479 call this%u_res%init(dm_xh, "u_res")
480 call this%v_res%init(dm_xh, "v_res")
481 call this%w_res%init(dm_xh, "w_res")
482 call this%abx1%init(dm_xh, "abx1")
483 call this%aby1%init(dm_xh, "aby1")
484 call this%abz1%init(dm_xh, "abz1")
485 call this%abx2%init(dm_xh, "abx2")
486 call this%aby2%init(dm_xh, "aby2")
487 call this%abz2%init(dm_xh, "abz2")
488 call this%advx%init(dm_xh, "advx")
489 call this%advy%init(dm_xh, "advy")
490 call this%advz%init(dm_xh, "advz")
491 end associate
492
493 call this%du%init(this%dm_Xh, 'du')
494 call this%dv%init(this%dm_Xh, 'dv')
495 call this%dw%init(this%dm_Xh, 'dw')
496 call this%dp%init(this%dm_Xh, 'dp')
497 ! Initialize ALE
498 call this%ale%init(this%c_Xh, params, numerics_params, user, chkp)
499
500 call neko_log%section("Fluid boundary conditions")
501 ! Set up boundary conditions
502 call this%setup_bcs(user, params)
503
504 ! Check if we need to output boundaries
505 if (output_boundary) call this%write_boundary_conditions()
506 call neko_log%end_section()
507
508 call this%proj_prs%init(this%dm_Xh%size(), this%pr_projection_dim, &
509 this%pr_projection_activ_step, &
510 this%pr_projection_reorthogonalize_basis)
511
512 call this%proj_vel%init(this%dm_Xh%size(), this%vel_projection_dim, &
513 this%vel_projection_activ_step)
514
515
516
517 ! Determine the time-interpolation scheme
518 call json_get_or_default(numerics_params, 'oifs', this%oifs, .false.)
519 if (params%valid_path('flow_rate_force')) then
520 call this%vol_flow%init(this%dm_Xh, params)
521 end if
522
523 ! Setup pressure solver
524 call neko_log%section("Pressure solver")
525
526 call json_get(params, 'pressure_solver', solver_params)
527 call json_get(params, 'pressure_solver.type', solver_type)
528 call json_get(params, 'pressure_solver.preconditioner.type', &
529 precon_type)
530 call json_get(params, &
531 'pressure_solver.preconditioner', precon_params)
532 call json_get_or_lookup(params, &
533 'pressure_solver.absolute_tolerance', &
534 abs_tol)
535 call neko_log%message('Type : ('// trim(solver_type) // &
536 ', ' // trim(precon_type) // ')')
537 write(log_buf, '(A,ES13.6)') 'Abs tol :', abs_tol
538 call neko_log%message(log_buf)
539
540 call this%solver_factory(this%ksp_prs, this%dm_Xh%size(), solver_params)
541 call this%precon_factory_(this%pc_prs, this%ksp_prs, &
542 this%c_Xh, this%bcs_prs, &
543 precon_type, precon_params)
544 call neko_log%end_section()
545
546 ! Initialize the advection factory
547 call json_get_or_default(params, 'advection', advection, .true.)
548 ! OIFS integrates the advection term. With advection disabled, fall back to
549 ! the standard BDF history assembly.
550 this%oifs = this%oifs .and. advection
551 call chkp%get_time_history(tlag, dtlag)
552 call advection_factory(this%adv, numerics_params, this%c_Xh, &
553 this%ulag, this%vlag, this%wlag, &
554 dtlag, tlag, this%ext_bdf, &
555 .not. advection)
556 ! Should be in init_base maybe?
557 this%chkp => chkp
558 ! Register the scheme state for checkpointing.
559 payload => this%chkp%add_payload("fluid")
560 call payload%add_field(this%u)
561 call payload%add_field(this%v)
562 call payload%add_field(this%w)
563 call payload%add_field(this%p)
564 call payload%add_field(this%abx1)
565 call payload%add_field(this%abx2)
566 call payload%add_field(this%aby1)
567 call payload%add_field(this%aby2)
568 call payload%add_field(this%abz1)
569 call payload%add_field(this%abz2)
570 call payload%add_series(this%ulag)
571 call payload%add_series(this%vlag)
572 call payload%add_series(this%wlag)
573
574 !> Set the number of schwarz iterations to perform each time step.
575 call json_get_or_default(params, 'schwarz_iterations', &
576 this%schwarz_iterations, 0)
577
578 call neko_log%end_section()
579
580 nullify(bc_i, vel_bc)
581
582 end subroutine fluid_pnpn_init
583
584 !> Allocate and configure the Helmholtz matrix-vector product for the
585 !! velocity, `this%Ax_vel`.
586 subroutine fluid_pnpn_ax_vel_factory(this)
587 class(fluid_pnpn_t), target, intent(inout) :: this
588
589 if (this%full_stress_formulation) then
590 if (this%svv_enabled) then
591 if (this%svv%formulation .eq. "factorized") then
592 call ax_helm_allocator(this%Ax_vel, &
593 type_name = "full_factorized_svv")
594 else
595 call ax_helm_allocator(this%Ax_vel, &
596 type_name = "full_one_sided_svv")
597 end if
598 select type (operator => this%Ax_vel)
599 class is (ax_helm_svv_full_t)
600 operator%svv => this%svv
601 end select
602 else
603 call ax_helm_allocator(this%Ax_vel, type_name = "full")
604 end if
605 else
606 if (this%svv_enabled) then
607 if (this%svv%formulation .eq. "factorized") then
608 call ax_helm_allocator(this%Ax_vel, type_name = "factorized_svv")
609 else
610 call ax_helm_allocator(this%Ax_vel, type_name = "one_sided_svv")
611 end if
612 select type (operator => this%Ax_vel)
613 class is (ax_helm_svv_t)
614 operator%svv => this%svv
615 end select
616 else if (this%c_Xh%geo_compression) then
617 call ax_helm_allocator(this%Ax_vel, &
618 type_name = "standard_compr")
619 else
620 call ax_helm_allocator(this%Ax_vel, type_name = "standard")
621 end if
622 end if
623
624 end subroutine fluid_pnpn_ax_vel_factory
625
626 subroutine fluid_pnpn_restart(this, chkp)
627 class(fluid_pnpn_t), target, intent(inout) :: this
628 type(chkp_t), intent(inout) :: chkp
629 integer :: i, j, n
630 class(bc_t), pointer :: bc_i
631
632 n = this%u%dof%size()
633 if (allocated(chkp%previous_mesh%elements) .or. &
634 chkp%previous_Xh%lx .ne. this%Xh%lx) then
635 associate(u => this%u, v => this%v, w => this%w, p => this%p, &
636 c_xh => this%c_Xh, ulag => this%ulag, vlag => this%vlag, &
637 wlag => this%wlag)
638 do concurrent(j = 1:n)
639 u%x(j,1,1,1) = u%x(j,1,1,1) * c_xh%mult(j,1,1,1)
640 v%x(j,1,1,1) = v%x(j,1,1,1) * c_xh%mult(j,1,1,1)
641 w%x(j,1,1,1) = w%x(j,1,1,1) * c_xh%mult(j,1,1,1)
642 p%x(j,1,1,1) = p%x(j,1,1,1) * c_xh%mult(j,1,1,1)
643 end do
644 do i = 1, this%ulag%size()
645 do concurrent(j = 1:n)
646 ulag%lf(i)%x(j,1,1,1) = ulag%lf(i)%x(j,1,1,1) &
647 * c_xh%mult(j,1,1,1)
648 vlag%lf(i)%x(j,1,1,1) = vlag%lf(i)%x(j,1,1,1) &
649 * c_xh%mult(j,1,1,1)
650 wlag%lf(i)%x(j,1,1,1) = wlag%lf(i)%x(j,1,1,1) &
651 * c_xh%mult(j,1,1,1)
652 end do
653 end do
654 end associate
655 end if
656
657 if (neko_bcknd_device .eq. 1) then
658 associate(u => this%u, v => this%v, w => this%w, &
659 ulag => this%ulag, vlag => this%vlag, wlag => this%wlag,&
660 p => this%p)
661 call device_memcpy(u%x, u%x_d, u%dof%size(), &
662 host_to_device, sync = .false.)
663 call device_memcpy(v%x, v%x_d, v%dof%size(), &
664 host_to_device, sync = .false.)
665 call device_memcpy(w%x, w%x_d, w%dof%size(), &
666 host_to_device, sync = .false.)
667 call device_memcpy(p%x, p%x_d, p%dof%size(), &
668 host_to_device, sync = .false.)
669 call device_memcpy(ulag%lf(1)%x, ulag%lf(1)%x_d, &
670 u%dof%size(), host_to_device, sync = .false.)
671 call device_memcpy(ulag%lf(2)%x, ulag%lf(2)%x_d, &
672 u%dof%size(), host_to_device, sync = .false.)
673
674 call device_memcpy(vlag%lf(1)%x, vlag%lf(1)%x_d, &
675 v%dof%size(), host_to_device, sync = .false.)
676 call device_memcpy(vlag%lf(2)%x, vlag%lf(2)%x_d, &
677 v%dof%size(), host_to_device, sync = .false.)
678
679 call device_memcpy(wlag%lf(1)%x, wlag%lf(1)%x_d, &
680 w%dof%size(), host_to_device, sync = .false.)
681 call device_memcpy(wlag%lf(2)%x, wlag%lf(2)%x_d, &
682 w%dof%size(), host_to_device, sync = .false.)
683 call device_memcpy(this%abx1%x, this%abx1%x_d, &
684 w%dof%size(), host_to_device, sync = .false.)
685 call device_memcpy(this%abx2%x, this%abx2%x_d, &
686 w%dof%size(), host_to_device, sync = .false.)
687 call device_memcpy(this%aby1%x, this%aby1%x_d, &
688 w%dof%size(), host_to_device, sync = .false.)
689 call device_memcpy(this%aby2%x, this%aby2%x_d, &
690 w%dof%size(), host_to_device, sync = .false.)
691 call device_memcpy(this%abz1%x, this%abz1%x_d, &
692 w%dof%size(), host_to_device, sync = .false.)
693 call device_memcpy(this%abz2%x, this%abz2%x_d, &
694 w%dof%size(), host_to_device, sync = .false.)
695 call device_memcpy(this%advx%x, this%advx%x_d, &
696 w%dof%size(), host_to_device, sync = .false.)
697 call device_memcpy(this%advy%x, this%advy%x_d, &
698 w%dof%size(), host_to_device, sync = .false.)
699 call device_memcpy(this%advz%x, this%advz%x_d, &
700 w%dof%size(), host_to_device, sync = .false.)
701 end associate
702 end if
703 ! Make sure that continuity is maintained (important for interpolation)
704 ! Do not do this for lagged rhs
705 ! (derivatives are not necessairly coninous across elements)
706
707 if (allocated(chkp%previous_mesh%elements) &
708 .or. chkp%previous_Xh%lx .ne. this%Xh%lx) then
709
710 call rotate_cyc(this%u, this%v, this%w, 1, this%c_Xh)
711 call this%gs_Xh%op(this%u, gs_op_add)
712 call this%gs_Xh%op(this%v, gs_op_add)
713 call this%gs_Xh%op(this%w, gs_op_add)
714 call this%gs_Xh%op(this%p, gs_op_add)
715 call rotate_cyc(this%u, this%v, this%w, 0, this%c_Xh)
716
717 do i = 1, this%ulag%size()
718 call rotate_cyc(this%ulag%lf(i), this%vlag%lf(i), &
719 this%wlag%lf(i), 1, this%c_Xh)
720 call this%gs_Xh%op(this%ulag%lf(i), gs_op_add)
721 call this%gs_Xh%op(this%vlag%lf(i), gs_op_add)
722 call this%gs_Xh%op(this%wlag%lf(i), gs_op_add)
723 call rotate_cyc(this%ulag%lf(i), this%vlag%lf(i), &
724 this%wlag%lf(i), 0, this%c_Xh)
725 end do
726 end if
727
728 call this%ale%sync_chkp(this%c_Xh, this%Xh, this%adv, chkp, this%gs_Xh)
729 if (this%ale%active) then
730 call this%bc_prs_surface%recompute_normals()
731 call this%bc_sym_surface%recompute_normals()
732 end if
733
734 ! Restore velocity bcs that need it (overset mostly)
735 do i = 1, this%bcs_vel%size()
736 bc_i => this%bcs_vel%get(i)
737 call bc_i%restart(this%u, this%v, this%w, &
738 this%ulag, this%vlag, this%wlag)
739 end do
740
741 ! Restore pressure bcs that need it (overset mostly)
742 do i = 1, this%bcs_prs%size()
743 bc_i => this%bcs_prs%get(i)
744 call bc_i%restart(this%p)
745 end do
746
747 nullify(bc_i)
748
749 ! The OIFS convecting field series is not in the checkpoint, rebuild it
750 ! from the restored velocity lags.
751 select type (adv => this%adv)
752 type is (adv_oifs_t)
753 call adv%restart()
754 end select
755
756 end subroutine fluid_pnpn_restart
757
758 !> Set the initial condition of the velocity and pressure, copy the initial
759 !! velocity to the lagged velocity fields, and set the initial ALE mesh
760 !! velocity.
761 !! @param params The fluid parameters, i.e. `case.fluid`.
762 !! @param user Type with user-defined procedures.
763 !! @param is_restart Whether the case is restarting from a checkpoint.
764 subroutine fluid_pnpn_set_initial_condition(this, params, user, is_restart)
765 class(fluid_pnpn_t), intent(inout) :: this
766 type(json_file), intent(inout) :: params
767 type(user_t), intent(in) :: user
768 logical, intent(in) :: is_restart
769
770 ! Set before the IC
771 if (.not. is_restart) then
772 call this%ale%set_initial_mesh_velocity(this%c_Xh)
773 end if
774
775 call this%set_initial_condition_base(params, user, is_restart)
776
777 if (.not. is_restart) then
778 call this%ulag%set(this%u)
779 call this%vlag%set(this%v)
780 call this%wlag%set(this%w)
781 end if
782
783 end subroutine fluid_pnpn_set_initial_condition
784
785 subroutine fluid_pnpn_free(this)
786 class(fluid_pnpn_t), intent(inout) :: this
787
788 if (allocated(this%Ax_vel)) then
789 call this%Ax_vel%free()
790 deallocate(this%Ax_vel)
791 end if
792
793 if (allocated(this%Ax_prs)) then
794 call this%Ax_prs%free()
795 deallocate(this%Ax_prs)
796 end if
797
798 !Deallocate velocity and pressure fields
799 call this%scheme_free()
800
801 if (allocated(this%ext_bdf)) then
802 call this%ext_bdf%free()
803 deallocate(this%ext_bdf)
804 end if
805
806 call this%bc_prs_surface%free()
807 call this%bc_sym_surface%free()
808 if (allocated(this%bcs_vel_projector)) then
809 call this%bcs_vel_projector%free()
810 deallocate(this%bcs_vel_projector)
811 end if
812 call this%bcs_prs_projector%free()
813 call this%proj_prs%free()
814 call this%proj_vel%free()
815
816 call this%p_res%free()
817 call this%u_res%free()
818 call this%v_res%free()
819 call this%w_res%free()
820
821 call this%ale%free()
822
823 call this%du%free()
824 call this%dv%free()
825 call this%dw%free()
826 call this%dp%free()
827
828 call this%abx1%free()
829 call this%aby1%free()
830 call this%abz1%free()
831
832 call this%abx2%free()
833 call this%aby2%free()
834 call this%abz2%free()
835
836 call this%advx%free()
837 call this%advy%free()
838 call this%advz%free()
839
840 if (allocated(this%adv)) then
841 call this%adv%free()
842 deallocate(this%adv)
843 end if
844
845 if (allocated(this%prs_res)) then
846 deallocate(this%prs_res)
847 end if
848
849 if (allocated(this%vel_res)) then
850 deallocate(this%vel_res)
851 end if
852
853 if (allocated(this%sumab)) then
854 deallocate(this%sumab)
855 end if
856
857 if (allocated(this%makeabf)) then
858 deallocate(this%makeabf)
859 end if
860
861 if (allocated(this%makebdf)) then
862 deallocate(this%makebdf)
863 end if
864
865 if (allocated(this%makeoifs)) then
866 deallocate(this%makeoifs)
867 end if
868
869 if (allocated(this%ext_bdf)) then
870 deallocate(this%ext_bdf)
871 end if
872
873 call this%vol_flow%free()
874
875 end subroutine fluid_pnpn_free
876
877 !> Advance fluid simulation in time.
878 !! @param t The time value.
879 !! @param tstep The current interation.
880 !! @param dt The timestep
881 !! @param ext_bdf Time integration logic.
882 !! @param dt_controller timestep controller
883 subroutine fluid_pnpn_step(this, time, dt_controller)
884 class(fluid_pnpn_t), target, intent(inout) :: this
885 type(time_state_t), intent(in) :: time
886 type(time_step_controller_t), intent(in) :: dt_controller
887
888 if (this%freeze) return
889
890 call profiler_start_region('Fluid', 1)
891
892 call this%assemble_rhs(time)
893
894 if (this%ale%active) then
895 ! Advance Mesh (Moves points, updates B history, updates wm_lags)
896 call this%ale%advance_mesh(this%c_Xh, time, this%ext_bdf%nadv)
897 call this%recompute_metrics()
898 end if
899
900 call this%update_velocity_lags()
901
902 call this%solve(time, dt_controller, this%proj_prs, this%proj_vel)
903
904 ! Update mesh velocities for ALE
905 ! We update them here (end of step) for the next step.
906 if (this%ale%active) then
907 call this%ale%update_mesh_velocity(this%c_Xh, time)
908 end if
909
910 call profiler_end_region('Fluid', 1)
911 end subroutine fluid_pnpn_step
912
913 !> Assemble the explicit part of the right-hand side and extrapolate the
914 !! velocity.
915 !! @param time The time state.
916 subroutine fluid_pnpn_assemble_rhs(this, time)
917 class(fluid_pnpn_t), target, intent(inout) :: this
918 type(time_state_t), intent(in) :: time
919 ! number of degrees of freedom
920 integer :: n
921
922 n = this%dm_Xh%size()
923
924 associate(u => this%u, v => this%v, w => this%w, &
925 u_e => this%u_e, v_e => this%v_e, w_e => this%w_e, &
926 xh => this%Xh, &
927 c_xh => this%c_Xh, dm_xh => this%dm_Xh, &
928 ulag => this%ulag, vlag => this%vlag, wlag => this%wlag, &
929 sumab => this%sumab, makeoifs => this%makeoifs, &
930 makeabf => this%makeabf, makebdf => this%makebdf, &
931 oifs => this%oifs, &
932 rho => this%rho, &
933 f_x => this%f_x, f_y => this%f_y, f_z => this%f_z, &
934 dt => time%dt, &
935 ext_bdf => this%ext_bdf, &
936 ale => this%ale)
937
938 ! Extrapolate the velocity if it's not done in nut_field estimation
939 call sumab%compute_fluid(u_e, v_e, w_e, u, v, w, &
940 ulag, vlag, wlag, ext_bdf%advection_coeffs%x, ext_bdf%nadv)
941
942 ! Compute the source terms that are extrapolated in time below
943 call this%source_term%compute(time, extrapolate = .true.)
944
945 ! Add Neumann bc contributions to the RHS
946 call this%bcs_vel%apply_vector(f_x%x, f_y%x, f_z%x, &
947 this%dm_Xh%size(), time, strong = .false.)
948
949 if (this%ale%active) then
950 if (oifs) then
951 call neko_error("ALE is not yet supported " // &
952 "with OIFS time integration.")
953 end if
954 !> adds div.(u_i*wm) to RHS
955 call this%adv%compute_ale(u, v, w, &
956 ale%wm_x, ale%wm_y, ale%wm_z, &
957 f_x, f_y, f_z, &
958 xh, c_xh, dm_xh%size())
959 end if
960
961
962 if (oifs) then
963 ! Add the advection operators to the right-hand-side.
964 call this%adv%compute(u, v, w, &
965 this%advx, this%advy, this%advz, &
966 xh, this%c_Xh, dm_xh%size(), real(dt, kind=rp))
967
968 ! At this point the RHS contains the sum of the advection operator and
969 ! additional source terms, evaluated using the velocity field from the
970 ! previous time-step. Now, this value is used in the explicit time
971 ! scheme to advance both terms in time.
972
973 call makeabf%compute_fluid(this%abx1, this%aby1, this%abz1,&
974 this%abx2, this%aby2, this%abz2, &
975 f_x%x, f_y%x, f_z%x, &
976 rho%x(1,1,1,1), ext_bdf%advection_coeffs%x, n)
977
978 ! Now, the source terms from the previous time step are added to the
979 ! RHS.
980 call makeoifs%compute_fluid(this%advx%x, this%advy%x, this%advz%x, &
981 f_x%x, f_y%x, f_z%x, &
982 rho%x(1,1,1,1), real(dt, kind=rp), n)
983 else
984 ! Add the advection operators to the right-hand-side.
985 call this%adv%compute(u, v, w, &
986 f_x, f_y, f_z, &
987 xh, this%c_Xh, dm_xh%size())
988
989 ! At this point the RHS contains the sum of the advection operator and
990 ! additional source terms, evaluated using the velocity field from the
991 ! previous time-step. Now, this value is used in the explicit time
992 ! scheme to advance both terms in time.
993
994 call makeabf%compute_fluid(this%abx1, this%aby1, this%abz1,&
995 this%abx2, this%aby2, this%abz2, &
996 f_x%x, f_y%x, f_z%x, &
997 rho%x(1,1,1,1), ext_bdf%advection_coeffs%x, n)
998
999 ! Add the RHS contributions coming from the BDF scheme.
1000 ! Blag and Blaglag are history of B matrices, mainly used for ALE.
1001 ! For a normal simulation (no moving mesh), Blag and Blaglag
1002 ! are just the initial B matrix, filled at initialization.
1003 call makebdf%compute_fluid(ulag, vlag, wlag, f_x%x, f_y%x, f_z%x, &
1004 u, v, w, c_xh%B, c_xh%Blag, c_xh%Blaglag, rho%x(1,1,1,1), &
1005 real(dt, kind=rp), &
1006 ext_bdf%diffusion_coeffs%x, ext_bdf%ndiff, n)
1007
1008 end if
1009
1010 ! Source terms that must not be extrapolated in time are added as
1011 ! computed, weighted by the mass matrix and the density like the
1012 ! extrapolated terms above.
1013 call this%source_term%compute(time, extrapolate = .false., scale = rho)
1014
1015 end associate
1016 end subroutine fluid_pnpn_assemble_rhs
1017
1018 !> Recompute geometry-dependent quantities after the mesh has moved.
1019 subroutine fluid_pnpn_recompute_metrics(this)
1020 class(fluid_pnpn_t), target, intent(inout) :: this
1021
1022 call profiler_start_region('ALE recompute metrics')
1023 ! Update Metrics
1024 call this%c_Xh%recompute_metrics()
1025 ! Update the metrics used by the adv operator for delaiasing (coef_GL)
1026 ! Maps the updated coef_GLL to coef_GL.
1027 call this%adv%recompute_metrics(this%c_Xh, .true.)
1028
1029 call this%bc_prs_surface%recompute_normals()
1030 call this%bc_sym_surface%recompute_normals()
1031 call profiler_end_region('ALE recompute metrics')
1032 end subroutine fluid_pnpn_recompute_metrics
1033
1034 !> Shift the velocity history by one time step. Called once per step,
1035 !! after the right-hand side is assembled and before the velocity is
1036 !! overwritten.
1037 subroutine fluid_pnpn_update_velocity_lags(this)
1038 class(fluid_pnpn_t), intent(inout) :: this
1039
1040 call this%ulag%update()
1041 call this%vlag%update()
1042 call this%wlag%update()
1043 end subroutine fluid_pnpn_update_velocity_lags
1044
1045 !> Solve for the pressure and velocity, given an assembled right-hand side.
1046 !! @param time The time state.
1047 !! @param dt_controller timestep controller
1048 !! @param proj_prs Projection space for the pressure solve.
1049 !! @param proj_vel Projection space for the velocity solve.
1050 !! @note A solve is done without projection when its projection space is
1051 !! not passed.
1052 subroutine fluid_pnpn_solve(this, time, dt_controller, proj_prs, proj_vel)
1053 class(fluid_pnpn_t), target, intent(inout) :: this
1054 type(time_state_t), intent(in) :: time
1055 type(time_step_controller_t), intent(in) :: dt_controller
1056 type(projection_t), intent(inout), optional :: proj_prs
1057 type(projection_vel_t), intent(inout), optional :: proj_vel
1058 ! number of degrees of freedom
1059 integer :: n
1060 ! Solver results monitors (pressure + 3 velocity)
1061 type(ksp_monitor_t) :: ksp_results(4)
1062 integer :: iter
1063
1064 n = this%dm_Xh%size()
1065
1066 associate(u => this%u, v => this%v, w => this%w, p => this%p, &
1067 u_e => this%u_e, v_e => this%v_e, w_e => this%w_e, &
1068 du => this%du, dv => this%dv, dw => this%dw, dp => this%dp, &
1069 u_res => this%u_res, v_res => this%v_res, w_res => this%w_res, &
1070 p_res => this%p_res, ax_vel => this%Ax_vel, ax_prs => this%Ax_prs, &
1071 xh => this%Xh, &
1072 c_xh => this%c_Xh, dm_xh => this%dm_Xh, gs_xh => this%gs_Xh, &
1073 msh => this%msh, prs_res => this%prs_res, &
1074 vel_res => this%vel_res, &
1075 rho => this%rho, mu_tot => this%mu_tot, &
1076 f_x => this%f_x, f_y => this%f_y, f_z => this%f_z, &
1077 tstep => time%tstep, dt => time%dt, &
1078 ext_bdf => this%ext_bdf, event => glb_cmd_event)
1079
1080 ! Update material properties if necessary
1081 call this%update_material_properties(time)
1082
1083 ! Update the SVV coefficient if necessary
1084 if (this%svv_enabled) then
1085 call this%svv%update(rho, tstep)
1086 end if
1087
1088 do iter = 1, 1 + this%schwarz_iterations
1089
1090 call this%bc_apply_vel(time, strong = .true.)
1091 call this%bc_apply_prs(time)
1092
1093 ! Compute pressure residual.
1094 call profiler_start_region('Pressure_residual', 18)
1095 call prs_res%compute(p, p_res,&
1096 u, v, w, &
1097 u_e, v_e, w_e, &
1098 f_x, f_y, f_z, &
1099 c_xh, gs_xh, &
1100 this%bc_prs_surface, this%bc_sym_surface,&
1101 ax_prs, ext_bdf%diffusion_coeffs%x(1), real(dt, kind=rp), &
1102 mu_tot, rho, event)
1103
1104
1105 ! De-mean the pressure residual when no strong pressure boundaries present
1106 if (.not. this%prs_dirichlet .and. neko_bcknd_device .eq. 1) then
1107 call device_ortho(p_res%x_d, this%glb_n_points, n)
1108 else if (.not. this%prs_dirichlet) then
1109 call ortho(p_res%x, this%glb_n_points, n)
1110 end if
1111
1112 call gs_xh%op(p_res, gs_op_add, event)
1113
1114 ! Set the residual to zero at strong pressure boundaries.
1115 call this%bcs_prs_projector%apply(p_res%x, p%dof%size())
1116
1117
1118 call profiler_end_region('Pressure_residual', 18)
1119
1120 ! Do projections only on the actual solutions of the tstep
1121 ! not intermediate solutions from the subiterations.
1122 if (iter .eq. 1 .and. present(proj_prs)) then
1123 call proj_prs%pre_solving(p_res%x, tstep, c_xh, n, &
1124 dt_controller, ax = ax_prs, gs_h = gs_xh, &
1125 bclst = this%bcs_prs_projector, string = 'Pressure')
1126 end if
1127
1128 call this%pc_prs%update()
1129
1130 call profiler_start_region('Pressure_solve', 3)
1131
1132 ! Solve for the pressure increment.
1133 ksp_results(1) = &
1134 this%ksp_prs%solve(ax_prs, dp, p_res%x, n, c_xh, &
1135 this%bcs_prs_projector, gs_xh)
1136 ksp_results(1)%name = 'Pressure'
1137
1138
1139 call profiler_end_region('Pressure_solve', 3)
1140
1141 if (iter .eq. 1 .and. present(proj_prs)) then
1142 call proj_prs%post_solving(dp%x, ax_prs, c_xh, &
1143 this%bcs_prs_projector, gs_xh, n, tstep, dt_controller)
1144 end if
1145
1146 ! Update the pressure with the increment. Demean if necessary.
1147 call field_add2(p, dp, n)
1148 if (.not. this%prs_dirichlet .and. neko_bcknd_device .eq. 1) then
1149 call device_ortho(p%x_d, this%glb_n_points, n)
1150 else if (.not. this%prs_dirichlet) then
1151 call ortho(p%x, this%glb_n_points, n)
1152 end if
1153
1154 ! Compute velocity residual.
1155 call profiler_start_region('Velocity_residual', 19)
1156 call vel_res%compute(ax_vel, u, v, w, &
1157 u_res, v_res, w_res, &
1158 p, &
1159 f_x, f_y, f_z, &
1160 c_xh, msh, xh, &
1161 mu_tot, rho, ext_bdf%diffusion_coeffs%x(1), &
1162 real(dt, kind=rp), dm_xh%size())
1163
1164 call rotate_cyc(u_res, v_res, w_res, 1, c_xh)
1165 call gs_xh%op(u_res%x, v_res%x, w_res%x, dm_xh%size(), &
1166 gs_op_add, event)
1167 call rotate_cyc(u_res, v_res, w_res, 0, c_xh)
1168
1169 ! Set residual to zero at strong velocity boundaries.
1170 call this%bcs_vel_projector%apply(u_res%x, v_res%x, w_res%x, &
1171 dm_xh%size())
1172
1173
1174 call profiler_end_region('Velocity_residual', 19)
1175
1176 if (iter .eq. 1 .and. present(proj_vel)) then
1177 call proj_vel%pre_solving(u_res%x, v_res%x, w_res%x, &
1178 tstep, c_xh, n, dt_controller, 'Velocity')
1179 end if
1180
1181 call this%pc_vel%update()
1182
1183 call profiler_start_region("Velocity_solve", 4)
1184 ksp_results(2:4) = this%ksp_vel%solve_coupled(ax_vel, du, dv, dw, &
1185 u_res%x, v_res%x, w_res%x, n, c_xh, &
1186 this%bcs_vel_projector, gs_xh, &
1187 this%ksp_vel%max_iter)
1188 call profiler_end_region("Velocity_solve", 4)
1189 if (this%full_stress_formulation) then
1190 ksp_results(2)%name = 'Momentum'
1191 else
1192 ksp_results(2)%name = 'X-Velocity'
1193 ksp_results(3)%name = 'Y-Velocity'
1194 ksp_results(4)%name = 'Z-Velocity'
1195 end if
1196
1197 if (iter .eq. 1 .and. present(proj_vel)) then
1198 call proj_vel%post_solving(du%x, dv%x, dw%x, ax_vel, c_xh, &
1199 this%bcs_vel_projector, gs_xh, n, tstep, &
1200 dt_controller)
1201 end if
1202
1203 if (neko_bcknd_device .eq. 1) then
1204 call device_opadd2cm(u%x_d, v%x_d, w%x_d, &
1205 du%x_d, dv%x_d, dw%x_d, 1.0_rp, n, msh%gdim)
1206 else
1207 call opadd2cm(u%x, v%x, w%x, du%x, dv%x, dw%x, 1.0_rp, n, msh%gdim)
1208 end if
1209
1210 call fluid_step_info(time, ksp_results, &
1211 this%full_stress_formulation, this%strict_convergence, &
1212 this%allow_stabilization, iter)
1213
1214 end do
1215
1216 if (this%forced_flow_rate) then
1217 ! Horrible mu hack?!
1218 call this%vol_flow%adjust( u, v, w, p, u_res, v_res, w_res, p_res, &
1219 c_xh, gs_xh, ext_bdf, rho%x(1,1,1,1), mu_tot, &
1220 real(dt, kind=rp), time, this%bcs_prs_projector, &
1221 this%bcs_vel_projector, ax_vel, ax_prs, this%ksp_prs, &
1222 this%ksp_vel, this%pc_prs, this%pc_vel, this%ksp_prs%max_iter, &
1223 this%ksp_vel%max_iter)
1224 end if
1225
1226 end associate
1227 end subroutine fluid_pnpn_solve
1228
1229 !> Sets up the boundary conditions for the scheme.
1230 !! @details Each entry of `case.fluid.boundary_conditions` is split into a
1231 !! velocity part and a pressure part by `fluid_pnpn_bc_split`. The parts are
1232 !! passed to `velocity_bc_factory` and `pressure_bc_factory`, and the
1233 !! resulting objects are appended to `bcs_vel` and `bcs_prs` and marked in
1234 !! the residual projectors. The `facet_type` array of the mesh, used by the
1235 !! FDM preconditioner, is set to 1 on the zones of an entry with a Dirichlet
1236 !! pressure condition and to 2 otherwise.
1237 !! @param user The user interface.
1238 !! @param params The case file parameters.
1239 subroutine fluid_pnpn_setup_bcs(this, user, params)
1240 class(fluid_pnpn_t), target, intent(inout) :: this
1241 type(user_t), target, intent(in) :: user
1242 type(json_file), intent(inout) :: params
1243 integer :: i, n_bcs, j, k, l, zone_size, global_zone_size, ierr
1244 integer :: facet_value
1245 class(bc_t), pointer :: bc_i
1246 type(json_core) :: core
1247 type(json_value), pointer :: bc_object
1248 type(json_file) :: bc_subdict, velocity_subdict, pressure_subdict
1249 logical :: moving_, has_velocity, has_pressure, pressure_dirichlet
1250 logical :: found
1251 ! Monitor which boundary zones have been marked
1252 logical, allocatable :: marked_zones(:)
1253 integer, allocatable :: zone_indices(:)
1254 character(len=256) :: error_msg
1255 character(len=:), allocatable :: bc_type_str
1256
1257 this%ale%has_moving_boundary = .false.
1258
1259 ! Special PnPn boundary conditions for pressure
1260 call this%bc_prs_surface%init_from_components(this%c_Xh)
1261 call this%bc_sym_surface%init_from_components(this%c_Xh)
1262
1263 ! Populate bcs_vel and bcs_prs based on the case file
1264 if (params%valid_path('boundary_conditions')) then
1265 call params%info('boundary_conditions', n_children = n_bcs)
1266 call params%get_core(core)
1267 call params%get('boundary_conditions', bc_object, found)
1268
1269 call this%bcs_vel%init(n_bcs)
1270 call this%bcs_prs%init(n_bcs)
1271
1272 allocate(marked_zones(size(this%msh%labeled_zones)))
1273 marked_zones = .false.
1274
1275 do i = 1, n_bcs
1276 ! Create a new json containing just the subdict for this bc
1277 call json_extract_item(core, bc_object, i, bc_subdict)
1278
1279 call json_get_or_lookup(bc_subdict, "zone_indices", zone_indices)
1280
1281 ! Check that we are not trying to assing a bc to zone, for which one
1282 ! has already been assigned and that the zone has more than 0 size
1283 ! in the mesh.
1284 do j = 1, size(zone_indices)
1285 zone_size = this%msh%labeled_zones(zone_indices(j))%size
1286 call mpi_allreduce(zone_size, global_zone_size, 1, &
1287 mpi_integer, mpi_max, neko_comm, ierr)
1288
1289 if (global_zone_size .eq. 0) then
1290 write(error_msg, '(A, I0, A, A, I0, A)') &
1291 "Zone index ", zone_indices(j), &
1292 " is invalid as this zone has 0 size, meaning it ", &
1293 "is not in the mesh. Check fluid boundary condition ", &
1294 i, "."
1295 call neko_error(error_msg)
1296 end if
1297
1298 if (marked_zones(zone_indices(j))) then
1299 write(error_msg, '(A, I0, A, A, A, A)') &
1300 "Zone with index ", zone_indices(j), &
1301 " has already been assigned a boundary condition. ", &
1302 "Please check your boundary_conditions entry for the ", &
1303 "fluid and make sure that each zone index appears only ", &
1304 "in a single boundary condition."
1305 call neko_error(error_msg)
1306 else
1307 marked_zones(zone_indices(j)) = .true.
1308 end if
1309 end do
1310
1311 call fluid_pnpn_bc_split(bc_subdict, velocity_subdict, &
1312 pressure_subdict, has_velocity, has_pressure)
1313
1314 !
1315 ! Velocity
1316 !
1317 bc_i => null()
1318 if (has_velocity) then
1319 ! Set the ALE flag to true if there is any moving no_slip wall
1320 call json_get(velocity_subdict, "type", bc_type_str)
1321 if (trim(bc_type_str) .eq. "no_slip") then
1322 call json_get_or_default(velocity_subdict, "moving", moving_, &
1323 .false.)
1324 if (moving_) this%ale%has_moving_boundary = .true.
1325 end if
1326
1327 call velocity_bc_factory(bc_i, this, velocity_subdict, &
1328 this%c_Xh, user)
1329 end if
1330
1331 ! A homogeneous Neumann condition for velocity does not create an
1332 ! object, so we check.
1333 if (associated(bc_i)) then
1334
1335 select type (bc_i)
1336 type is (symmetry_aligned_t)
1337 ! In this case we need to tell the segregated projector where
1338 ! we have the dirichlet dofs component-wise. This is stored
1339 ! in the nested bcs. Of course, we rely on axis-alignment of
1340 ! the geometry.
1341 call this%bcs_vel_projector%mark(bc_i%bc_x, component = 'x')
1342 call this%bcs_vel_projector%mark(bc_i%bc_y, component = 'y')
1343 call this%bcs_vel_projector%mark(bc_i%bc_z, component = 'z')
1344 call this%bcs_vel%append(bc_i)
1345 call this%bc_sym_surface%mark_facets(bc_i%marked_facet)
1346 type is (symmetry_t)
1347 ! In this case we add the bc itself to the projector, which
1348 ! should be coupled.
1349 if (.not. this%full_stress_formulation) then
1350 call neko_error("The symmetry boundary condition " // &
1351 "requires the full stress formulation to be enabled.")
1352 end if
1353 call this%bcs_vel_projector%mark(bc_i)
1354 call this%bcs_vel%append(bc_i)
1355 call this%bc_sym_surface%mark_facets(bc_i%marked_facet)
1356 type is (non_normal_aligned_t)
1357 ! The situation is the same as symmetry.
1358 call this%bcs_vel_projector%mark(bc_i%bc_x, component = 'x')
1359 call this%bcs_vel_projector%mark(bc_i%bc_y, component = 'y')
1360 call this%bcs_vel_projector%mark(bc_i%bc_z, component = 'z')
1361 call this%bcs_vel%append(bc_i)
1362 type is (non_normal_t)
1363 call this%bcs_vel_projector%mark(bc_i)
1364 call this%bcs_vel%append(bc_i)
1365 type is (shear_stress_t)
1366 if (.not. this%full_stress_formulation) then
1367 call neko_error("The shear_stress boundary condition " // &
1368 "requires the full stress formulation to be enabled.")
1369 end if
1370 call this%bcs_vel_projector%mark(bc_i)
1371 call this%bcs_vel%append(bc_i)
1372 type is (wall_model_bc_t)
1373 if (.not. this%full_stress_formulation) then
1374 call neko_error("The wall_model boundary condition " // &
1375 "requires the full stress formulation to be enabled.")
1376 end if
1377 call this%bcs_vel_projector%mark(bc_i)
1378 call this%bcs_vel%append(bc_i)
1379 class is (mixed_bc_t)
1380 ! User-defined mixed conditions, resolved by the coupled
1381 ! projector.
1382 if (.not. this%full_stress_formulation) then
1383 call neko_error("The " // trim(bc_i%name) // &
1384 " boundary condition is a mixed condition and " // &
1385 "requires the full stress formulation to be enabled.")
1386 end if
1387 call this%bcs_vel_projector%mark(bc_i)
1388 call this%bcs_vel%append(bc_i)
1389 class default
1390
1391 ! Additionally we mark the special PnPn pressure bc.
1392 if (bc_i%bc_type .eq. bc_dirichlet) then
1393 call this%bc_prs_surface%mark_labeled_zones( &
1394 bc_i%zone_indices)
1395 if (this%full_stress_formulation) then
1396 call this%bcs_vel_projector%mark(bc_i)
1397 else
1398 call this%bcs_vel_projector%mark(bc_i, component = 'x')
1399 call this%bcs_vel_projector%mark(bc_i, component = 'y')
1400 call this%bcs_vel_projector%mark(bc_i, component = 'z')
1401 end if
1402 end if
1403
1404 call this%bcs_vel%append(bc_i)
1405 end select
1406 end if
1407
1408 !
1409 ! Pressure
1410 !
1411 bc_i => null()
1412 pressure_dirichlet = .false.
1413 if (has_pressure) then
1414 call pressure_bc_factory(bc_i, this, pressure_subdict, &
1415 this%c_Xh, user)
1416 end if
1417
1418 ! The natural pressure condition does not create an object, so we
1419 ! check.
1420 if (associated(bc_i)) then
1421 call this%bcs_prs%append(bc_i)
1422
1423 ! Mark strong pressure bcs in the projector to force zero change.
1424 if (bc_i%bc_type .eq. bc_dirichlet) then
1425 call this%bcs_prs_projector%mark(bc_i)
1426 pressure_dirichlet = .true.
1427 end if
1428 end if
1429
1430 ! Mark the facets of the zones for the FDM preconditioner: 1 where
1431 ! the pressure is strongly imposed, 2 otherwise.
1432 if (pressure_dirichlet) then
1433 facet_value = 1
1434 else
1435 facet_value = 2
1436 end if
1437
1438 do j = 1, size(zone_indices)
1439 do k = 1, this%msh%nelv
1440 do l = 1, 2 * this%msh%gdim
1441 if (this%msh%facet_type(l, k) .eq. -zone_indices(j)) then
1442 this%msh%facet_type(l, k) = facet_value
1443 end if
1444 end do
1445 end do
1446 end do
1447 end do
1448
1449 call velocity_subdict%destroy()
1450 call pressure_subdict%destroy()
1451
1452 if (this%ale%active .and. (.not. this%ale%has_moving_boundary)) then
1453 call neko_error("Case file error: ALE is active, " // &
1454 "but no moving wall was found. " // &
1455 "Use type = 'no_slip' with 'moving': true in case file.")
1456 end if
1457
1458 ! Make sure all labeled zones with non-zero size have been marked
1459 do i = 1, size(this%msh%labeled_zones)
1460 if ((this%msh%labeled_zones(i)%size .gt. 0) .and. &
1461 (.not. marked_zones(i))) then
1462 write(error_msg, '(A, I0)') &
1463 "No fluid boundary condition assigned to zone ", i
1464 call neko_error(error_msg)
1465 end if
1466 end do
1467 else
1468 ! Check that there are no labeled zones, i.e. all are periodic.
1469 do i = 1, size(this%msh%labeled_zones)
1470 if (this%msh%labeled_zones(i)%size .gt. 0) then
1471 call neko_error("No boundary_conditions entry in the case file!")
1472 end if
1473 end do
1474
1475 ! For a pure periodic case, we still need to initilise the bc lists
1476 ! to a zero size to avoid issues with apply() in step()
1477 call this%bcs_vel%init()
1478 call this%bcs_prs%init()
1479
1480 end if
1481
1482 call this%bc_prs_surface%finalize()
1483 call this%bc_sym_surface%finalize()
1484 call this%bcs_vel_projector%finalize(rebuild_mask = .true.)
1485
1486 ! If we have no strong pressure bcs, we will demean the pressure
1487 this%prs_dirichlet = this%bcs_prs_projector%dof_mask%is_set()
1488 call mpi_allreduce(mpi_in_place, this%prs_dirichlet, 1, &
1489 mpi_logical, mpi_lor, neko_comm)
1490
1491 if (allocated(marked_zones)) then
1492 deallocate(marked_zones)
1493 end if
1494
1495 if (allocated(zone_indices)) then
1496 deallocate(zone_indices)
1497 end if
1498
1499 nullify(bc_i, bc_object)
1500
1501 end subroutine fluid_pnpn_setup_bcs
1502
1503 !> Write a field with boundary condition specifications
1504 subroutine fluid_pnpn_write_boundary_conditions(this)
1505 use inflow, only : inflow_t
1507 use blasius, only : blasius_t
1509 use dong_outflow, only : dong_outflow_t
1510 use no_slip, only : no_slip_t
1511 class(fluid_pnpn_t), target, intent(inout) :: this
1512 type(dirichlet_t) :: bdry_mask
1513 type(field_t), pointer :: bdry_field
1514 type(file_t) :: bdry_file
1515 integer :: temp_index, i
1516 class(bc_t), pointer :: bci
1517 character(len=LOG_SIZE) :: log_buf
1518
1519 write(log_buf, '(A)') 'Marking using integer keys in bdry0.f00000'
1520 call neko_log%message(log_buf)
1521 write(log_buf, '(A)') 'Condition-value pairs: '
1522 call neko_log%message(log_buf)
1523 write(log_buf, '(A)') ' no_slip (stationary wall) = 1'
1524 call neko_log%message(log_buf)
1525 write(log_buf, '(A)') ' velocity_value = 2'
1526 call neko_log%message(log_buf)
1527 write(log_buf, '(A)') ' outflow, normal_outflow (+dong) = 3'
1528 call neko_log%message(log_buf)
1529 write(log_buf, '(A)') ' symmetry = 4'
1530 call neko_log%message(log_buf)
1531 write(log_buf, '(A)') ' periodic = 6'
1532 call neko_log%message(log_buf)
1533 write(log_buf, '(A)') ' user_velocity = 7'
1534 call neko_log%message(log_buf)
1535 write(log_buf, '(A)') ' user_pressure = 8'
1536 call neko_log%message(log_buf)
1537 write(log_buf, '(A)') ' shear_stress = 9'
1538 call neko_log%message(log_buf)
1539 write(log_buf, '(A)') ' wall_modelling = 10'
1540 call neko_log%message(log_buf)
1541 write(log_buf, '(A)') ' blasius_profile = 11'
1542 call neko_log%message(log_buf)
1543 write(log_buf, '(A)') ' no_slip (moving wall) = 12'
1544 call neko_log%message(log_buf)
1545
1546 call neko_scratch_registry%request_field(bdry_field, temp_index, .true.)
1547
1548
1549
1550 call bdry_mask%init_from_components(this%c_Xh, 6.0_rp)
1551 call bdry_mask%mark_zone(this%msh%periodic)
1552 call bdry_mask%finalize()
1553 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1554 call bdry_mask%free()
1555
1556 do i = 1, this%bcs_prs%size()
1557 bci => this%bcs_prs%get(i)
1558 select type (bc => bci)
1559 type is (zero_dirichlet_t)
1560 call bdry_mask%init_from_components(this%c_Xh, 3.0_rp)
1561 call bdry_mask%mark_facets(bci%marked_facet)
1562 call bdry_mask%finalize()
1563 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1564 call bdry_mask%free()
1565 type is (dong_outflow_t)
1566 call bdry_mask%init_from_components(this%c_Xh, 3.0_rp)
1567 call bdry_mask%mark_facets(bci%marked_facet)
1568 call bdry_mask%finalize()
1569 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1570 call bdry_mask%free()
1571 type is (field_dirichlet_t)
1572 call bdry_mask%init_from_components(this%c_Xh, 8.0_rp)
1573 call bdry_mask%mark_facets(bci%marked_facet)
1574 call bdry_mask%finalize()
1575 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1576 call bdry_mask%free()
1577 end select
1578 end do
1579
1580 do i = 1, this%bcs_vel%size()
1581 bci => this%bcs_vel%get(i)
1582 select type (bc => bci)
1583 type is (no_slip_t)
1584 if (bc%is_moving) then
1585 ! moving wall
1586 call bdry_mask%init_from_components(this%c_Xh, 12.0_rp)
1587 else
1588 ! stationary wall
1589 call bdry_mask%init_from_components(this%c_Xh, 1.0_rp)
1590 end if
1591 call bdry_mask%mark_facets(bci%marked_facet)
1592 call bdry_mask%finalize()
1593 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1594 call bdry_mask%free()
1595 type is (inflow_t)
1596 call bdry_mask%init_from_components(this%c_Xh, 2.0_rp)
1597 call bdry_mask%mark_facets(bci%marked_facet)
1598 call bdry_mask%finalize()
1599 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1600 call bdry_mask%free()
1601 type is (symmetry_aligned_t)
1602 call bdry_mask%init_from_components(this%c_Xh, 4.0_rp)
1603 call bdry_mask%mark_facets(bci%marked_facet)
1604 call bdry_mask%finalize()
1605 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1606 call bdry_mask%free()
1607 type is (symmetry_t)
1608 call bdry_mask%init_from_components(this%c_Xh, 4.0_rp)
1609 call bdry_mask%mark_facets(bci%marked_facet)
1610 call bdry_mask%finalize()
1611 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1612 call bdry_mask%free()
1613 type is (field_dirichlet_vector_t)
1614 call bdry_mask%init_from_components(this%c_Xh, 7.0_rp)
1615 call bdry_mask%mark_facets(bci%marked_facet)
1616 call bdry_mask%finalize()
1617 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1618 call bdry_mask%free()
1619 type is (shear_stress_t)
1620 call bdry_mask%init_from_components(this%c_Xh, 9.0_rp)
1621 call bdry_mask%mark_facets(bci%marked_facet)
1622 call bdry_mask%finalize()
1623 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1624 call bdry_mask%free()
1625 type is (wall_model_bc_t)
1626 call bdry_mask%init_from_components(this%c_Xh, 10.0_rp)
1627 call bdry_mask%mark_facets(bci%marked_facet)
1628 call bdry_mask%finalize()
1629 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1630 call bdry_mask%free()
1631 type is (blasius_t)
1632 call bdry_mask%init_from_components(this%c_Xh, 11.0_rp)
1633 call bdry_mask%mark_facets(bci%marked_facet)
1634 call bdry_mask%finalize()
1635 call bdry_mask%apply_scalar(bdry_field%x, this%dm_Xh%size())
1636 call bdry_mask%free()
1637 end select
1638 end do
1639
1640
1641 call bdry_file%init('bdry.fld')
1642 call bdry_file%write(bdry_field)
1643
1644 call neko_scratch_registry%relinquish_field(temp_index)
1645
1646 nullify(bdry_field, bci)
1647
1648 end subroutine fluid_pnpn_write_boundary_conditions
1649
1650end module fluid_pnpn
__device__ T solve(const T u, const T y, const T guess, const T nu, const T kappa, const T B)
double real
Copy data between host and device (or device and device).
Definition device.F90:72
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.
Apply cyclic boundary condition to a vector field.
Subroutines to add advection terms to the RHS of a transport equation.
Definition adv_oifs.f90:34
Subroutines to add advection terms to the RHS of a transport equation.
Definition advection.f90:34
ALE Manager: Handles Mesh Motion.
Defines the full-stress SVV Helmholtz operator.
Base type for an SVV Helmholtz operator.
Defines a Matrix-vector product.
Definition ax.f90:34
Defines a boundary condition.
Definition bc.f90:34
integer, parameter, public bc_dirichlet
Supported boundary condition types. The values are set in order of precedence for global resolution....
Definition bc.f90:67
Defines a Blasius profile dirichlet condition.
Definition blasius.f90:34
Format-independent checkpoint payloads.
Defines format-independent checkpoint registration and restart state.
Coefficients.
Definition coef.f90:34
Definition comm.F90:1
type(mpi_comm), public neko_comm
MPI communicator.
Definition comm.F90:46
subroutine, public device_opadd2cm(a1_d, a2_d, a3_d, b1_d, b2_d, b3_d, c, n, gdim)
subroutine, public device_opcolv(a1_d, a2_d, a3_d, c_d, gdim, n)
Device abstraction, common interface for various accelerators.
Definition device.F90:34
integer, parameter, public host_to_device
Definition device.F90:48
type(c_ptr), bind(C), public glb_cmd_event
Event for the global command queue.
Definition device.F90:63
Defines a dirichlet boundary condition.
Definition dirichlet.f90:34
Defines a dong outflow condition.
Dirichlet condition applied in the facet normal direction.
Defines inflow dirichlet conditions.
Defines user dirichlet condition for a scalar field.
subroutine, public field_add2(a, b, n)
Vector addition .
subroutine, public field_copy(a, b, n)
Copy a vector .
Contains the field_serties_t type.
Defines a field.
Definition field.f90:34
Module for file I/O operations.
Definition file.f90:34
Auxiliary routines for fluid solvers.
Definition fluid_aux.f90:34
subroutine, public fluid_step_info(time, ksp_results, full_stress_formulation, strict_convergence, allow_stabilization, iteration)
Prints for prs, velx, vely, velz the following: Number of iterations, start residual,...
Definition fluid_aux.f90:54
Modular version of the Classic Nek5000 Pn/Pn formulation for fluids.
subroutine fluid_pnpn_setup_bcs(this, user, params)
Sets up the boundary conditions for the scheme.
subroutine fluid_pnpn_recompute_metrics(this)
Recompute geometry-dependent quantities after the mesh has moved.
subroutine fluid_pnpn_restart(this, chkp)
subroutine fluid_pnpn_set_initial_condition(this, params, user, is_restart)
Set the initial condition of the velocity and pressure, copy the initial velocity to the lagged veloc...
subroutine fluid_pnpn_init(this, msh, lx, params, numerics_params, user, chkp, output_boundary)
Initialize the Pn/Pn fluid scheme.
subroutine fluid_pnpn_write_boundary_conditions(this)
Write a field with boundary condition specifications.
subroutine fluid_pnpn_step(this, time, dt_controller)
Advance fluid simulation in time.
subroutine fluid_pnpn_assemble_rhs(this, time)
Assemble the explicit part of the right-hand side and extrapolate the velocity.
subroutine fluid_pnpn_free(this)
subroutine fluid_pnpn_update_velocity_lags(this)
Shift the velocity history by one time step. Called once per step, after the right-hand side is assem...
subroutine fluid_pnpn_solve(this, time, dt_controller, proj_prs, proj_vel)
Solve for the pressure and velocity, given an assembled right-hand side.
Defines Gather-scatter operations.
Definition gs_ops.f90:34
integer, parameter, public gs_op_add
Definition gs_ops.f90:36
Defines inflow dirichlet conditions.
Definition inflow.f90:34
Utilities for retrieving parameters from the case files.
Implements the base abstract type for Krylov solvers plus helper types.
Definition krylov.f90:34
Logging routines.
Definition log.f90:34
type(log_t), public neko_log
Global log stream.
Definition log.f90:92
integer, parameter, public log_size
Definition log.f90:46
Collection of vector field operations operating on and . Note that in general the indices and ....
Definition mathops.f90:67
subroutine, public opcolv(a1, a2, a3, c, gdim, n)
Definition mathops.f90:103
subroutine, public opadd2cm(a1, a2, a3, b1, b2, b3, c, n, gdim)
Definition mathops.f90:156
Defines a mesh.
Definition mesh.f90:34
Implements mixed_bc_t.
Definition mixed_bc.f90:31
Build configurations.
integer, parameter neko_bcknd_device
Defines no-slip boundary condition (extends zero_dirichlet).
Definition no_slip.f90:34
Implements non_normal_aligned_t.
Implements non_normal_t.
integer, parameter, public dp
Definition num_types.f90:10
integer, parameter, public rp
Global precision used in computations.
Definition num_types.f90:14
Operators.
Definition operators.f90:34
subroutine, public ortho(x, glb_n_points, n)
Othogonalize with regard to vector (1,1,1,1,1,1...,1)^T.
Operators accelerator backends.
subroutine, public device_ortho(x_d, glb_n_points, n)
Othogonalize with regard to vector (1,1,1,1,1,1...,1)^T.
Defines Pressure and velocity residuals in the Pn-Pn formulation.
Definition pnpn_res.f90:34
Profiling interface.
Definition profiler.F90:34
subroutine, public profiler_start_region(name, region_id)
Started a named (name) profiler region.
Definition profiler.F90:79
subroutine, public profiler_end_region(name, region_id)
End the most recently started profiler region.
Definition profiler.F90:116
Project x onto X , the space of old solutions and back again Couple projections for velocity.
Project x onto X, the space of old solutions and back again.
Defines a registry for storing solution fields.
Definition registry.f90:34
type(registry_t), target, public neko_registry
Global field registry.
Definition registry.f90:158
Routines to generate the right-hand sides for the convection-diffusion equation. Employs the EXT/BDF ...
Definition rhs_maker.f90:38
Implements scalar_projector_t.
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 shear stress boundary condition for a vector field. Maintainer: Timofey Mukha.
Implements symmetry_aligned_t.
Implements symmetry_t.
Definition symmetry.f90:34
Module with things related to the simulation time.
Implements type time_step_controller.
Interfaces for user interaction with NEKO.
Definition user_intf.f90:34
Utilities.
Definition utils.f90:35
integer, parameter, public neko_typename_len
Definition utils.f90:44
subroutine, public neko_type_error(base_type, wrong_type, known_types)
Reports an error allocating a type for a particular base pointer class.
Definition utils.f90:415
Implements boundary condition projectors for vector fields. Two types concrete types are provided: se...
Defines the wall_model_bc_t type. Maintainer: Timofey Mukha.
Defines a zero-valued Dirichlet boundary condition.
Base abstract type for computing the advection operator.
Definition advection.f90:46
Helmholtz operator carrying a non-owning SVV object.
Matrix-vector product for a Helmholtz problem.
Base type for a matrix-vector product providing .
Definition ax.f90:44
Base type for a boundary condition.
Definition bc.f90:73
Blasius profile for inlet (vector valued).
Definition blasius.f90:55
Collection of live simulation data registered for checkpointing.
A named collection of live fields to checkpoint together.
Coefficients defined on a given (mesh, ) tuple. Arrays use indices (i,j,k,e): element e,...
Definition coef.f90:136
Generic Dirichlet boundary condition on .
Definition dirichlet.f90:49
Dong outflow condition Follows "A Convective-like Energy-Stable Open Boundary Condition forSimulation...
Dirichlet condition in facet normal direction.
User defined dirichlet condition, for which the user can work with an entire field....
Extension of the user defined dirichlet condition field_dirichlet.
Stores a series (sequence) of fields, logically connected to a base field, and arranged according to ...
A wrapper around a polymorphic generic_file_t that handles its init. This is essentially a factory fo...
Definition file.f90:56
Dirichlet condition for inlet (vector valued).
Definition inflow.f90:48
Type for storing initial and final residuals in a Krylov solver.
Definition krylov.f90:60
Base type for mixed boundary conditions that need projector-provided local-basis data on the physical...
Definition mixed_bc.f90:50
Mixed Dirichlet condition constraining the tangential vector components.
Axis-aligned mixed Dirichlet condition in the non-normal direction.
Abstract type to compute pressure residual.
Definition pnpn_res.f90:48
Abstract type to compute velocity residual.
Definition pnpn_res.f90:54
Abstract type to add contributions to F from lagged BD terms.
Definition rhs_maker.f90:59
Abstract type to sum up contributions to kth order extrapolation scheme.
Definition rhs_maker.f90:52
Abstract type to add contributions of kth order OIFS scheme.
Definition rhs_maker.f90:66
Abstract type to compute extrapolated velocity field for the pressure equation.
Definition rhs_maker.f90:46
Projector for scalar boundary conditions.
A shear stress boundary condition.
Symmetry boundary condition constraining the normal vector component.
Definition symmetry.f90:50
Axis-aligned symmetry boundary condition.
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...
A coupled projector for vector fields, suitable for mixed boundary conditions.
A projector for vector fields that acts component-wise.
Abstract type for resolving vector boundary conditions.
A shear stress boundary condition, computing the stress values using a wall model.
Zero-valued Dirichlet boundary condition. Used for no-slip walls, but also for various auxillary cond...