Incompressible Navier-Stokes solver using the Fractional-Step Projection method.
This module implements the core hydrodynamic solver for the
LowMachReact-Hex framework. The current projection/momentum path is
constant-density, using params%rho for the pressure projection and
momentum update. It solves the incompressible Navier-Stokes equations using
a semi-implicit fractional-step approach:
Predictor Step: An intermediate velocity is calculated by advancing the momentum equation explicitly, excluding the new pressure gradient.
Poisson Solve: A pressure correction potential is found by solving the Poisson equation derived from the continuity constraint .
Corrector Step: The final velocity and pressure are updated using the potential gradient.
The linear system for the Poisson equation is solved using a Preconditioned Conjugate Gradient (PCG) method with a diagonal (Jacobi) preconditioner.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| type(pressure_operator_cache_t), | private, | save | :: | pressure_cache | |||
| type(projection_workspace_t), | private, | save | :: | projection_work |
Solver diagnostics and global physics statistics.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=rk), | public | :: | cfl | = | zero | ||
| real(kind=rk), | public | :: | kinetic_energy | = | zero | ||
| real(kind=rk), | public | :: | max_divergence | = | zero | ||
| real(kind=rk), | public | :: | max_velocity | = | zero | ||
| real(kind=rk), | public | :: | min_species_y | = | zero | ||
| real(kind=rk), | public | :: | net_boundary_flux | = | zero | ||
| integer, | public | :: | pressure_iterations | = | 0 | ||
| real(kind=rk), | public | :: | pressure_iterations_avg | = | zero | ||
| integer, | public | :: | pressure_iterations_max | = | 0 | ||
| integer, | public | :: | pressure_iterations_total | = | 0 | ||
| real(kind=rk), | public | :: | pressure_residual | = | zero | ||
| integer, | public | :: | pressure_solve_count | = | 0 | ||
| real(kind=rk), | public | :: | rms_divergence | = | zero | ||
| real(kind=rk), | public | :: | total_mass | = | zero | ||
| real(kind=rk), | public | :: | wall_time | = | zero |
Cached sparse matrix coefficients for the Pressure Poisson operator.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=rk), | public, | allocatable | :: | coeff(:,:) | |||
| real(kind=rk), | public, | allocatable | :: | diag(:) | |||
| logical, | public | :: | has_dirichlet_pressure | = | .false. | ||
| logical, | public | :: | has_neumann_outlet | = | .false. | ||
| logical, | public | :: | initialized | = | .false. | ||
| integer, | public | :: | max_faces | = | 0 | ||
| integer, | public, | allocatable | :: | nb(:,:) | |||
| integer, | public | :: | ncells | = | 0 |
Temporary workspace for projection step calculations.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| real(kind=rk), | public, | allocatable | :: | ap(:) | |||
| logical, | public | :: | initialized | = | .false. | ||
| real(kind=rk), | public, | allocatable | :: | local_ap(:) | |||
| real(kind=rk), | public, | allocatable | :: | local_face_flux(:) | |||
| real(kind=rk), | public, | allocatable | :: | local_scalar(:) | |||
| real(kind=rk), | public, | allocatable | :: | local_vec(:,:) | |||
| real(kind=rk), | public, | allocatable | :: | local_vec_star(:,:) | |||
| integer, | public | :: | ncells | = | 0 | ||
| integer, | public | :: | nfaces | = | 0 | ||
| real(kind=rk), | public, | allocatable | :: | predicted_face_flux(:) | |||
| real(kind=rk), | public, | allocatable | :: | pvec(:) | |||
| real(kind=rk), | public, | allocatable | :: | r(:) | |||
| real(kind=rk), | public, | allocatable | :: | rhs_poisson(:) | |||
| real(kind=rk), | public, | allocatable | :: | z(:) |
Calculates the normal distance between cell centers or cell-to-face.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_t), | intent(in) | :: | mesh |
The mesh. |
||
| type(bc_set_t), | intent(in) | :: | bc |
Boundary conditions. |
||
| integer, | intent(in) | :: | face_id |
Face index. |
||
| integer, | intent(in) | :: | cell_id |
Source cell index. |
||
| integer, | intent(in) | :: | nb |
Neighbor cell index (or 0 for boundaries). |
Linearly interpolates a scalar field to a face.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_t), | intent(in) | :: | mesh | |||
| type(bc_set_t), | intent(in) | :: | bc | |||
| integer, | intent(in) | :: | face_id | |||
| integer, | intent(in) | :: | cell_id | |||
| integer, | intent(in) | :: | nb | |||
| real(kind=rk), | intent(in) | :: | owner_value | |||
| real(kind=rk), | intent(in) | :: | neighbor_value |
Linearly interpolates a vector field to a face.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_t), | intent(in) | :: | mesh | |||
| type(bc_set_t), | intent(in) | :: | bc | |||
| integer, | intent(in) | :: | face_id | |||
| integer, | intent(in) | :: | cell_id | |||
| integer, | intent(in) | :: | nb | |||
| real(kind=rk), | intent(in) | :: | owner_value(3) | |||
| real(kind=rk), | intent(in) | :: | neighbor_value(3) |
Determines the outward unit normal relative to a specific cell.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_t), | intent(in) | :: | mesh | |||
| integer, | intent(in) | :: | face_id | |||
| integer, | intent(in) | :: | cell_id |
Orchestrates one full fractional-step iteration.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_t), | intent(in) | :: | mesh |
The computational mesh. |
||
| type(flow_mpi_t), | intent(inout) | :: | flow |
MPI decomposition context. |
||
| type(bc_set_t), | intent(in) | :: | bc |
Boundary condition set. |
||
| type(case_params_t), | intent(in) | :: | params |
Case parameters (dt, rho, etc). |
||
| type(transport_properties_t), | intent(in) | :: | transport |
Physical property fields. |
||
| type(flow_fields_t), | intent(inout) | :: | fields |
Flow field containers to be updated. |
||
| type(solver_stats_t), | intent(inout) | :: | stats |
Diagnostic stats to be populated. |
Calculates domain-wide CFL and optionally scales the timestep size.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_t), | intent(in) | :: | mesh | |||
| type(flow_mpi_t), | intent(in) | :: | flow | |||
| type(case_params_t), | intent(inout) | :: | params | |||
| type(flow_fields_t), | intent(in) | :: | fields | |||
| type(solver_stats_t), | intent(inout) | :: | stats |
Aggregates global residuals, kinetic energy, and mass balance data.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_t), | intent(in) | :: | mesh | |||
| type(flow_mpi_t), | intent(in) | :: | flow | |||
| type(bc_set_t), | intent(in) | :: | bc | |||
| type(case_params_t), | intent(in) | :: | params | |||
| type(flow_fields_t), | intent(in) | :: | fields | |||
| type(solver_stats_t), | intent(inout) | :: | stats |
Deallocate the persistent flow projection workspace.
Advances velocity using the 2nd-order Adams-Bashforth scheme.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_t), | intent(in) | :: | mesh | |||
| type(flow_mpi_t), | intent(in) | :: | flow | |||
| type(case_params_t), | intent(in) | :: | params | |||
| type(flow_fields_t), | intent(in) | :: | fields | |||
| real(kind=rk), | intent(in) | :: | rhs(:,:) | |||
| real(kind=rk), | intent(out) | :: | local_ustar(:,:) |
Adjusts flux at Neumann outlets to ensure strict global mass balance.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_t), | intent(in) | :: | mesh | |||
| type(flow_mpi_t), | intent(in) | :: | flow | |||
| type(bc_set_t), | intent(in) | :: | bc | |||
| real(kind=rk), | intent(inout) | :: | face_flux(:) |
Internal helper for MPI error checking.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| integer, | intent(in) | :: | ierr | |||
| character(len=*), | intent(in) | :: | where |
Helper to integrated boundary flux on MPI-owned partitions.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_t), | intent(in) | :: | mesh | |||
| type(flow_mpi_t), | intent(in) | :: | flow | |||
| type(bc_set_t), | intent(in) | :: | bc | |||
| real(kind=rk), | intent(in) | :: | face_flux(:) | |||
| real(kind=rk), | intent(out) | :: | local_flux |
Computes the discrete divergence of face fluxes for each cell.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_t), | intent(in) | :: | mesh | |||
| type(flow_mpi_t), | intent(in) | :: | flow | |||
| real(kind=rk), | intent(in) | :: | face_flux(:) | |||
| real(kind=rk), | intent(out) | :: | local_div(:) |
Evaluates the advective, diffusive, and pressure terms of the momentum equation.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_t), | intent(in) | :: | mesh | |||
| type(flow_mpi_t), | intent(in) | :: | flow | |||
| type(bc_set_t), | intent(in) | :: | bc | |||
| type(case_params_t), | intent(in) | :: | params | |||
| type(transport_properties_t), | intent(in) | :: | transport | |||
| real(kind=rk), | intent(in) | :: | u(:,:) | |||
| real(kind=rk), | intent(in) | :: | p(:) | |||
| real(kind=rk), | intent(out) | :: | local_rhs(:,:) |
Linearly interpolates cell-centered intermediate velocity to mesh faces.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_t), | intent(in) | :: | mesh | |||
| type(flow_mpi_t), | intent(in) | :: | flow | |||
| type(bc_set_t), | intent(in) | :: | bc | |||
| real(kind=rk), | intent(in) | :: | ustar(:,:) | |||
| real(kind=rk), | intent(out) | :: | face_flux(:) |
Updates cell-centered velocity using the pressure potential gradient.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_t), | intent(in) | :: | mesh | |||
| type(flow_mpi_t), | intent(in) | :: | flow | |||
| type(bc_set_t), | intent(in) | :: | bc | |||
| type(case_params_t), | intent(in) | :: | params | |||
| real(kind=rk), | intent(in) | :: | ustar(:,:) | |||
| real(kind=rk), | intent(in) | :: | phi(:) | |||
| real(kind=rk), | intent(out) | :: | local_u(:,:) |
Corrects face fluxes using the pressure potential gradient.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_t), | intent(in) | :: | mesh | |||
| type(flow_mpi_t), | intent(in) | :: | flow | |||
| type(bc_set_t), | intent(in) | :: | bc | |||
| type(case_params_t), | intent(in) | :: | params | |||
| real(kind=rk), | intent(in) | :: | predicted_flux(:) | |||
| real(kind=rk), | intent(in) | :: | phi(:) | |||
| real(kind=rk), | intent(out) | :: | face_flux(:) |
Pre-computes Laplacian coefficients for the Poisson operator.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_t), | intent(in) | :: | mesh | |||
| type(flow_mpi_t), | intent(in) | :: | flow | |||
| type(bc_set_t), | intent(in) | :: | bc |
Allocates and resets temporary solver vectors.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_t), | intent(in) | :: | mesh |
Calculates the pressure gradient at a cell center using Gauss's Theorem.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_t), | intent(in) | :: | mesh | |||
| type(bc_set_t), | intent(in) | :: | bc | |||
| real(kind=rk), | intent(in) | :: | p(:) | |||
| integer, | intent(in) | :: | cell_id | |||
| real(kind=rk), | intent(out) | :: | gradp(3) |
Sparse Matrix-Vector multiplication for the Laplacian operator.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_t), | intent(in) | :: | mesh | |||
| type(flow_mpi_t), | intent(in) | :: | flow | |||
| type(bc_set_t), | intent(in) | :: | bc | |||
| real(kind=rk), | intent(in) | :: | x(:) | |||
| real(kind=rk), | intent(out) | :: | local_ax(:) |
Iteratively solves the Pressure Poisson system using PCG.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_t), | intent(in) | :: | mesh | |||
| type(flow_mpi_t), | intent(inout) | :: | flow | |||
| type(bc_set_t), | intent(in) | :: | bc | |||
| type(case_params_t), | intent(in) | :: | params | |||
| real(kind=rk), | intent(in) | :: | rhs(:) | |||
| real(kind=rk), | intent(inout) | :: | phi(:) | |||
| type(solver_stats_t), | intent(inout) | :: | stats |