Preconditioned Conjugate Gradient (PCG) linear solver and operators.
This module houses the pure numerical and linear algebra routines used by the LowMachReact-Hex framework. It manages the static Poisson matrix cache, temporary workspace allocations, Preconditioned Conjugate Gradient (PCG) solver loop, sparse matrix-vector products, and zero-mean gauge projections for pure Neumann systems.
| Type | Visibility | Attributes | Name | Initial | |||
|---|---|---|---|---|---|---|---|
| type(pressure_operator_cache_t), | public, | save | :: | pressure_cache | |||
| type(projection_workspace_t), | public, | save | :: | projection_work | |||
| integer, | private, | parameter | :: | pcg_nullspace_projection_interval | = | 50 |
Variable-density pure-Neumann pressure systems use an explicit zero-mean projection to control the constant nullspace. |
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 | ||
| real(kind=rk), | public, | allocatable | :: | var_coeff(:,:) | |||
| real(kind=rk), | public, | allocatable | :: | var_diag(:) |
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(:) |
Dummy/diagnostic solver statistics structure mirroring the one in flow. Keeping structural declarations isolated or shared if needed.
| 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 | ||
| real(kind=rk), | public | :: | pressure_residual_abs | = | 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 |
Calculates the distance between cell and neighbor center along face normal.
| 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 |
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 |
Expose Dirichlet flag from cache.
Expose Neumann outlet flag from cache.
Face-centered inverse density coefficient for variable-density projection.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(transport_properties_t), | intent(in) | :: | transport | |||
| integer, | intent(in) | :: | owner | |||
| integer, | intent(in) | :: | nb |
Select the active diagonal used by the pressure PCG preconditioner.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(case_params_t), | intent(in) | :: | params | |||
| integer, | intent(in) | :: | c |
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 |
Allocate persistent solver workspace.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(mesh_t), | intent(in) | :: | mesh |
Deallocate temporary work arrays.
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 | |||
| type(transport_properties_t), | intent(in) | :: | transport | |||
| real(kind=rk), | intent(in) | :: | rhs(:) | |||
| real(kind=rk), | intent(inout) | :: | phi(:) | |||
| type(solver_stats_t), | intent(inout) | :: | stats |
Remove the constant nullspace component from an owned-cell scalar.
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| type(flow_mpi_t), | intent(in) | :: | flow | |||
| real(kind=rk), | intent(inout) | :: | scalar(:) |
Rebuild per-step variable-density pressure coefficients.
| 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(transport_properties_t), | intent(in) | :: | transport |
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 | |||
| type(case_params_t), | intent(in) | :: | params | |||
| real(kind=rk), | intent(in) | :: | x(:) | |||
| real(kind=rk), | intent(out) | :: | local_ax(:) |