OpenImpala
Image-based parallel transport property solver
Loading...
Searching...
No Matches
EffectiveDiffusivityHypre.H
Go to the documentation of this file.
1
4#ifndef EFFECTIVEDIFFUSIVITYHYPRE_H
5#define EFFECTIVEDIFFUSIVITYHYPRE_H
6
7#include <string>
8#include <vector>
9#include <limits>
10#include <map>
11
12#include <AMReX.H>
13#include <AMReX_iMultiFab.H>
14#include <AMReX_MultiFab.H>
15#include <AMReX_BoxArray.H>
16#include <AMReX_DistributionMapping.H>
17#include <AMReX_Geometry.H>
18#include <AMReX_Array.H>
19#include <AMReX_IntVect.H>
20#include <AMReX_RealVect.H> // For m_dx
21
22#include <HYPRE.h>
23#include <HYPRE_struct_ls.h>
24
25#include "HypreStructSolver.H"
26#include "Tortuosity.H" // For OpenImpala::Direction, SolverType
27
28namespace OpenImpala {
29
42
43public:
46
64 EffectiveDiffusivityHypre(const amrex::Geometry& geom, const amrex::BoxArray& ba,
65 const amrex::DistributionMapping& dm,
66 const amrex::iMultiFab& mf_phase_input, const int phase_id,
67 const OpenImpala::Direction dir_of_chi_k,
68 const SolverType solver_type, const std::string& resultspath,
69 int verbose_level = 1, bool write_plotfile_flag = false,
70 const std::map<int, amrex::Real>& phase_coeffs = {});
71
73 ~EffectiveDiffusivityHypre() override = default;
74
75 // Deleted Copy Operations
78
86 bool solve();
87
98 void getChiSolution(amrex::MultiFab& chi_field);
99
100
101 // --- Public for CUDA __device__ lambda compatibility ---
102 void initializeDiffCoeff();
103
104 // --- Public Getters for Status and Solver Information ---
105 // Solver statistics are inherited from HypreStructSolver:
106 // getSolverConverged(), getFinalRelativeResidualNorm(), getSolverIterations()
107
108 const amrex::iMultiFab& getActiveMask() const {
109 return m_mf_active_mask;
110 }
111 const amrex::MultiFab& getDiffCoeff() const {
112 return m_mf_diff_coeff;
113 }
114
115 // Static Helper Functions (delegate to base class)
116 static amrex::Array<HYPRE_Int, AMREX_SPACEDIM> loV(const amrex::Box& b) {
117 return HypreStructSolver::loV(b);
118 }
119 static amrex::Array<HYPRE_Int, AMREX_SPACEDIM> hiV(const amrex::Box& b) {
120 return HypreStructSolver::hiV(b);
121 }
122
123 // Implementation methods. They are nominally internal but must live in
124 // the public section because nvcc forbids extended __device__ lambdas in
125 // private/protected member functions (see CUDA Programming Guide §I.4.1).
126 // Compare TortuosityHypre.H, which exposes the same methods publicly for
127 // the same reason.
128 void setupMatrixEquation();
129 void generateActiveMask(); // Simpler version for D=0/1 based on phase_id
130 int buildCellTypeMask(amrex::iMultiFab& mf_cell_type) const;
131
132
133private:
134 // --- Member Variables ---
135 // Configuration (solver config m_solvertype/m_eps/m_maxiter/m_verbose are in base class)
136 std::string m_resultspath;
137 const int m_phase_id; // Phase ID where D=D_material
138 const OpenImpala::Direction m_dir_solve; // Direction k for current chi_k
139 bool m_write_plotfile;
140 amrex::RealVect m_dx; // Cell sizes [dx, dy, dz]
141
142 // AMReX Data (m_geom/m_ba/m_dm are in base class)
143 amrex::iMultiFab m_mf_phase_original; // Stores the input phase data
144 amrex::iMultiFab m_mf_active_mask; // Binary mask (1 for active phase, 0 otherwise)
145 amrex::MultiFab m_mf_diff_coeff; // Spatially varying transport coefficient D(x)
146 amrex::MultiFab m_mf_chi; // Stores the solved chi_k for internal use/plotting
147
148 // Multi-phase configuration
149 std::map<int, amrex::Real> m_phase_coeff_map; // Maps phase ID -> transport coefficient
150 bool m_is_multi_phase = false;
151
152 // Solver statistics and HYPRE Data Structures are in base class
153};
154
155
156} // namespace OpenImpala
157
158#endif // EFFECTIVEDIFFUSIVITYHYPRE_H
Base class providing shared HYPRE structured-grid solver infrastructure.
Abstract base class for tortuosity solvers and shared enums (Direction, CellType, SolverType).
void getChiSolution(amrex::MultiFab &chi_field)
Retrieves the solved corrector function χ_k.
Definition EffectiveDiffusivityHypre.cpp:869
const amrex::MultiFab & getDiffCoeff() const
Definition EffectiveDiffusivityHypre.H:111
EffectiveDiffusivityHypre & operator=(const EffectiveDiffusivityHypre &)=delete
EffectiveDiffusivityHypre(const amrex::Geometry &geom, const amrex::BoxArray &ba, const amrex::DistributionMapping &dm, const amrex::iMultiFab &mf_phase_input, const int phase_id, const OpenImpala::Direction dir_of_chi_k, const SolverType solver_type, const std::string &resultspath, int verbose_level=1, bool write_plotfile_flag=false, const std::map< int, amrex::Real > &phase_coeffs={})
Construct new solver for the effective diffusivity cell problem.
Definition EffectiveDiffusivityHypre.cpp:91
const amrex::iMultiFab & getActiveMask() const
Definition EffectiveDiffusivityHypre.H:108
EffectiveDiffusivityHypre(const EffectiveDiffusivityHypre &)=delete
void setupMatrixEquation()
Definition EffectiveDiffusivityHypre.cpp:628
OpenImpala::SolverType SolverType
Alias for the shared HYPRE solver type enum (defined in Tortuosity.H).
Definition EffectiveDiffusivityHypre.H:45
void initializeDiffCoeff()
Definition EffectiveDiffusivityHypre.cpp:228
static amrex::Array< HYPRE_Int, 3 > loV(const amrex::Box &b)
Definition EffectiveDiffusivityHypre.H:116
int buildCellTypeMask(amrex::iMultiFab &mf_cell_type) const
Definition EffectiveDiffusivityHypre.cpp:377
static amrex::Array< HYPRE_Int, 3 > hiV(const amrex::Box &b)
Definition EffectiveDiffusivityHypre.H:119
bool solve()
Solves the cell problem for the configured χ_k.
Definition EffectiveDiffusivityHypre.cpp:784
~EffectiveDiffusivityHypre() override=default
Destructor. Base class handles HYPRE resource cleanup.
void generateActiveMask()
Definition EffectiveDiffusivityHypre.cpp:254
HypreStructSolver(const HypreStructSolver &)=delete
static amrex::Array< HYPRE_Int, 3 > loV(const amrex::Box &b)
Convert AMReX Box lower corner to HYPRE_Int array.
Definition HypreStructSolver.cpp:24
static amrex::Array< HYPRE_Int, 3 > hiV(const amrex::Box &b)
Convert AMReX Box upper corner to HYPRE_Int array.
Definition HypreStructSolver.cpp:32
Definition CathodeWrite.cpp:12
SolverType
Specifies the HYPRE structured solver algorithm to use.
Definition Tortuosity.H:44
Direction
Defines cardinal directions for calculations.
Definition Tortuosity.H:13