OpenImpala
Image-based parallel transport property solver
Loading...
Searching...
No Matches
OpenImpala::TortuosityHypre Class Reference

#include <TortuosityHypre.H>

Inheritance diagram for OpenImpala::TortuosityHypre:
[legend]
Collaboration diagram for OpenImpala::TortuosityHypre:
[legend]

Public Types

using SolverType = OpenImpala::SolverType
 Alias for the shared HYPRE solver type enum (defined in Tortuosity.H).

Public Member Functions

amrex::iMultiFab buildTraversableMask ()
bool checkMatrixProperties ()
 Performs mathematical checks on the assembled HYPRE matrix and RHS vector.
void computePlaneFluxes (const amrex::MultiFab &mf_soln)
void generateActivityMask (const amrex::iMultiFab &phaseFab, int phaseID, OpenImpala::Direction dir)
amrex::Real getActiveVolumeFraction () const
void getCellTypes (amrex::MultiFab &phi, int ncomp=1)
amrex::Real getEffectiveDiffusivity () const
amrex::Real getFluxIn () const
amrex::Real getFluxOut () const
const amrex::Geometry & getGeometry () const
BCType getInletOutletBCType () const
 Returns the inlet/outlet BC type.
const std::map< int, amrex::Real > & getPhaseCoeffMap () const
 Returns the phase-to-coefficient mapping.
const std::vector< amrex::Real > & getPlaneFluxes () const
 Returns the per-plane flux profile computed after solving.
amrex::Real getPlaneFluxMaxDeviation () const
 Maximum relative deviation across interior plane fluxes.
BCType getSidesBCType () const
 Returns the lateral (sides) BC type.
void getSolution (amrex::MultiFab &soln, int ncomp=0)
const amrex::MultiFab & getSolutionField () const
void global_fluxes ()
void initializeDiffCoeff ()
bool isMultiPhase () const
 Returns true if multi-phase transport coefficients are configured.
TortuosityHypre & operator= (const TortuosityHypre &)=delete
void preconditionPhaseFab ()
void setupMatrixEquation ()
bool solve ()
 TortuosityHypre (const amrex::Geometry &geom, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm, const amrex::iMultiFab &mf_phase_input, const amrex::Real vf, const int phase, const OpenImpala::Direction dir, const SolverType solvertype, const std::string &resultspath, const amrex::Real vlo=0.0, const amrex::Real vhi=1.0, int verbose=0, bool write_plotfile=false, const PrecondType precond_type=PrecondType::SMG, const std::map< int, amrex::Real > &phase_coeffs={})
 TortuosityHypre (const TortuosityHypre &)=delete
amrex::Real value (const bool refresh=false) override
virtual ~TortuosityHypre () override=default
Public Member Functions inherited from OpenImpala::Tortuosity
virtual ~Tortuosity ()=default
 Virtual destructor (essential for base classes with virtual functions). Ensures proper cleanup when derived classes are deleted via a base class pointer.
Public Member Functions inherited from OpenImpala::HypreStructSolver
amrex::Real getFinalRelativeResidualNorm () const
bool getSolverConverged () const
int getSolverIterations () const
 HypreStructSolver (const HypreStructSolver &)=delete
HypreStructSolver & operator= (const HypreStructSolver &)=delete
virtual ~HypreStructSolver ()
 Virtual destructor. Cleans up HYPRE resources safely (guards against post-MPI_Finalize).

Static Public Member Functions

static amrex::Array< HYPRE_Int, 3 > hiV (const amrex::Box &b)
static amrex::Array< HYPRE_Int, 3 > loV (const amrex::Box &b)
Static Public Member Functions inherited from OpenImpala::HypreStructSolver
static amrex::Array< HYPRE_Int, 3 > hiV (const amrex::Box &b)
 Convert AMReX Box upper corner to HYPRE_Int array.
static amrex::Array< HYPRE_Int, 3 > loV (const amrex::Box &b)
 Convert AMReX Box lower corner to HYPRE_Int array.

Additional Inherited Members

Protected Member Functions inherited from OpenImpala::Tortuosity
 Tortuosity ()=default
Protected Member Functions inherited from OpenImpala::HypreStructSolver
void assembleSystem ()
 Assemble HYPRE matrix and vectors after box values have been set.
void createMatrixAndVectors ()
 Create and initialize HYPRE matrix and vectors (A, b, x). Must be called after setupGrid() and setupStencil().
 HypreStructSolver (const amrex::Geometry &geom, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm, SolverType solvertype, amrex::Real eps, int maxiter, int verbose)
 Construct base solver with configuration. Does NOT call any HYPRE functions.
bool runSolver (PrecondType precond_type=PrecondType::SMG)
 Run the HYPRE solver specified by m_solvertype.
void setupGrid (bool periodic=false)
 Create HYPRE structured grid from AMReX BoxArray.
void setupStencil ()
 Create 7-point stencil (center + 6 face neighbours).
Protected Attributes inherited from OpenImpala::HypreStructSolver
HYPRE_StructMatrix m_A = nullptr
HYPRE_StructVector m_b = nullptr
amrex::BoxArray m_ba
bool m_converged = false
amrex::DistributionMapping m_dm
amrex::Real m_eps
amrex::Real m_final_res_norm = std::numeric_limits<amrex::Real>::quiet_NaN()
amrex::Geometry m_geom
HYPRE_StructGrid m_grid = nullptr
int m_maxiter
HYPRE_Int m_num_iterations = -1
const SolverType m_solvertype
HYPRE_StructStencil m_stencil = nullptr
int m_verbose
HYPRE_StructVector m_x = nullptr
Static Protected Attributes inherited from OpenImpala::HypreStructSolver
static constexpr int STENCIL_SIZE = 7

Detailed Description

Computes the tortuosity of a porous structure using HYPRE.

Solves a diffusion equation (-Div(Grad(phi)) = 0 with Dirichlet BCs) on a masked subset of the domain derived from phase data, using HYPRE's structured-grid solvers (PFMG, SMG, Krylov methods) to find the potential field. Tortuosity is calculated from the resulting flux and active volume fraction, including checks for solver convergence and flux conservation.

Inherits HYPRE grid/stencil/solver infrastructure from HypreStructSolver.

Member Typedef Documentation

◆ SolverType

Alias for the shared HYPRE solver type enum (defined in Tortuosity.H).

Constructor & Destructor Documentation

◆ TortuosityHypre() [1/2]

OpenImpala::TortuosityHypre::TortuosityHypre ( const amrex::Geometry & geom,
const amrex::BoxArray & ba,
const amrex::DistributionMapping & dm,
const amrex::iMultiFab & mf_phase_input,
const amrex::Real vf,
const int phase,
const OpenImpala::Direction dir,
const SolverType solvertype,
const std::string & resultspath,
const amrex::Real vlo = 0.0,
const amrex::Real vhi = 1.0,
int verbose = 0,
bool write_plotfile = false,
const PrecondType precond_type = PrecondType::SMG,
const std::map< int, amrex::Real > & phase_coeffs = {} )

Construct new Tortuosity solver using HYPRE.

Parameters
geomAMReX Geometry object defining the domain.
baAMReX BoxArray defining the distribution of grid patches.
dmAMReX DistributionMapping defining processor assignments.
mf_phase_inputInput iMultiFab containing phase IDs (expects 1 component, >=1 ghost cell).
vfVolume fraction of the phase of interest (total VF, passed for potential reference).
phasePhase ID to calculate tortuosity for.
dirDirection across which to apply potential difference (X, Y, or Z).
solvertypeSolver type to use (from SolverType enum).
resultspathPath to directory for writing output files (e.g., plotfiles).
vloPotential value applied at the low boundary in the specified direction. Default 0.0.
vhiPotential value applied at the high boundary in the specified direction. Default 1.0.
verboseVerbosity level (0=silent, 1=basic, 2=detailed HYPRE output). Default 0.
write_plotfileIf true, write a plotfile of the solution potential field. Default false.
precond_typePreconditioner used by Krylov solvers (PCG/GMRES/FlexGMRES/BiCGSTAB). Ignored when solvertype is a standalone multigrid (SMG/PFMG) or Jacobi. Default SMG — robust on masked porous-media inputs where PFMG's semicoarsening fails to converge on the decoupled inactive rows.

◆ ~TortuosityHypre()

virtual OpenImpala::TortuosityHypre::~TortuosityHypre ( )
overridevirtualdefault

Destructor. Base class handles HYPRE resource cleanup.

◆ TortuosityHypre() [2/2]

OpenImpala::TortuosityHypre::TortuosityHypre ( const TortuosityHypre & )
delete

Member Function Documentation

◆ buildTraversableMask()

amrex::iMultiFab OpenImpala::TortuosityHypre::buildTraversableMask ( )

◆ checkMatrixProperties()

bool OpenImpala::TortuosityHypre::checkMatrixProperties ( )

Performs mathematical checks on the assembled HYPRE matrix and RHS vector.

Returns
True if all checks pass on all ranks, False otherwise.

◆ computePlaneFluxes()

void OpenImpala::TortuosityHypre::computePlaneFluxes ( const amrex::MultiFab & mf_soln)

◆ generateActivityMask()

void OpenImpala::TortuosityHypre::generateActivityMask ( const amrex::iMultiFab & phaseFab,
int phaseID,
OpenImpala::Direction dir )

◆ getActiveVolumeFraction()

amrex::Real OpenImpala::TortuosityHypre::getActiveVolumeFraction ( ) const
inline

◆ getCellTypes()

void OpenImpala::TortuosityHypre::getCellTypes ( amrex::MultiFab & phi,
int ncomp = 1 )

◆ getEffectiveDiffusivity()

amrex::Real OpenImpala::TortuosityHypre::getEffectiveDiffusivity ( ) const
inline

◆ getFluxIn()

amrex::Real OpenImpala::TortuosityHypre::getFluxIn ( ) const
inline

◆ getFluxOut()

amrex::Real OpenImpala::TortuosityHypre::getFluxOut ( ) const
inline

◆ getGeometry()

const amrex::Geometry & OpenImpala::TortuosityHypre::getGeometry ( ) const
inline

◆ getInletOutletBCType()

BCType OpenImpala::TortuosityHypre::getInletOutletBCType ( ) const
inline

Returns the inlet/outlet BC type.

◆ getPhaseCoeffMap()

const std::map< int, amrex::Real > & OpenImpala::TortuosityHypre::getPhaseCoeffMap ( ) const
inline

Returns the phase-to-coefficient mapping.

◆ getPlaneFluxes()

const std::vector< amrex::Real > & OpenImpala::TortuosityHypre::getPlaneFluxes ( ) const
inline

Returns the per-plane flux profile computed after solving.

◆ getPlaneFluxMaxDeviation()

amrex::Real OpenImpala::TortuosityHypre::getPlaneFluxMaxDeviation ( ) const
inline

Maximum relative deviation across interior plane fluxes.

◆ getSidesBCType()

BCType OpenImpala::TortuosityHypre::getSidesBCType ( ) const
inline

Returns the lateral (sides) BC type.

◆ getSolution()

void OpenImpala::TortuosityHypre::getSolution ( amrex::MultiFab & soln,
int ncomp = 0 )

◆ getSolutionField()

const amrex::MultiFab & OpenImpala::TortuosityHypre::getSolutionField ( ) const
inline

◆ global_fluxes()

void OpenImpala::TortuosityHypre::global_fluxes ( )

◆ hiV()

amrex::Array< HYPRE_Int, 3 > OpenImpala::TortuosityHypre::hiV ( const amrex::Box & b)
inlinestatic

◆ initializeDiffCoeff()

void OpenImpala::TortuosityHypre::initializeDiffCoeff ( )

◆ isMultiPhase()

bool OpenImpala::TortuosityHypre::isMultiPhase ( ) const
inline

Returns true if multi-phase transport coefficients are configured.

◆ loV()

amrex::Array< HYPRE_Int, 3 > OpenImpala::TortuosityHypre::loV ( const amrex::Box & b)
inlinestatic

◆ operator=()

TortuosityHypre & OpenImpala::TortuosityHypre::operator= ( const TortuosityHypre & )
delete

◆ preconditionPhaseFab()

void OpenImpala::TortuosityHypre::preconditionPhaseFab ( )

◆ setupMatrixEquation()

void OpenImpala::TortuosityHypre::setupMatrixEquation ( )

◆ solve()

bool OpenImpala::TortuosityHypre::solve ( )

◆ value()

amrex::Real OpenImpala::TortuosityHypre::value ( const bool refresh = false)
overridevirtual

Calculate or retrieve the tortuosity value.

Solves the underlying diffusion equation using HYPRE if not already solved or if refresh is requested. Checks solver convergence and flux conservation. Calculates flux and computes tortuosity using the average flux magnitude and the active volume fraction if checks pass. Returns NaN if the solver fails to converge, if flux is not conserved, or if calculation leads to invalid states (e.g., zero active VF or Deff).

Parameters
refreshIf true, forces recalculation by running the solver again. Default false.
Returns
Tortuosity value (ActiveVF / (Deff/D0)), or NaN on failure.

Implements OpenImpala::Tortuosity.


The documentation for this class was generated from the following files: