46 const mfem::SparseMatrix &QOp,
47 const mfem::SparseMatrix &DOp,
48 const mfem::SparseMatrix &MOp,
49 const mfem::Solver &GradInvOp
60 const mfem::SparseMatrix &QOp,
61 const mfem::SparseMatrix &DOp,
62 const mfem::SparseMatrix &MOp
75 void Mult(
const mfem::Vector &x, mfem::Vector &y)
const override;
84 void SetOperator(
const mfem::SparseMatrix &QOp,
const mfem::SparseMatrix &DOp,
const mfem::SparseMatrix &MOp,
const mfem::Solver &GradInvOp);
99 void updateConstantTerms(
const mfem::SparseMatrix &QOp,
const mfem::SparseMatrix &DOp,
const mfem::SparseMatrix &MOp);
103 const mfem::SparseMatrix*
m_QOp =
nullptr;
104 const mfem::SparseMatrix*
m_DOp =
nullptr;
105 const mfem::SparseMatrix*
m_MOp =
nullptr;
137 void Mult(
const mfem::Vector &x, mfem::Vector &y)
const override;
163 std::unique_ptr<mfem::MixedBilinearForm> M,
164 std::unique_ptr<mfem::MixedBilinearForm> Q,
165 std::unique_ptr<mfem::BilinearForm> D,
166 std::unique_ptr<mfem::BilinearForm> S,
167 std::unique_ptr<mfem::NonlinearForm> f,
168 const mfem::Array<int> &blockOffsets);
181 void Mult(
const mfem::Vector &xFree, mfem::Vector &yFree)
const override;
192 mfem::Operator&
GetGradient(
const mfem::Vector &xFree)
const override;
200 void finalize(
const mfem::Vector &initTheta);
298 std::unique_ptr<mfem::MixedBilinearForm>
m_M;
299 std::unique_ptr<mfem::MixedBilinearForm>
m_Q;
300 std::unique_ptr<mfem::BilinearForm>
m_D;
301 std::unique_ptr<mfem::BilinearForm>
m_S;
302 std::unique_ptr<mfem::NonlinearForm>
m_f;
305 std::unique_ptr<mfem::SparseMatrix>
m_Mmat;
306 std::unique_ptr<mfem::SparseMatrix>
m_Qmat;
307 std::unique_ptr<mfem::SparseMatrix>
m_Dmat;
308 std::unique_ptr<mfem::SparseMatrix>
m_Smat;
const SchurCompliment & m_op
Reference to the SchurCompliment operator to be inverted.
GMRESInverter(const SchurCompliment &op)
Constructs a GMRESInverter.
mfem::GMRESSolver m_solver
GMRES solver instance.
void Mult(const mfem::Vector &x, mfem::Vector &y) const override
Applies the GMRES solver to approximate op^-1 * x.
~GMRESInverter() override=default
Destructor.
std::unique_ptr< mfem::BilinearForm > m_S
Bilinear form S, used for least squares stabilization.
mfem::Array< int > m_freeDofs
Array of indices for free (non-essential) DOFs.
std::unique_ptr< mfem::MixedBilinearForm > m_Q
Bilinear form Q, coupling φ and θ.
quill::Logger * m_logger
Pointer to the specific logger instance.
std::unique_ptr< mfem::BlockDiagonalPreconditioner > m_schurPreconditioner
Block diagonal preconditioner for the system.
std::unique_ptr< mfem::SparseMatrix > m_Qmat
Sparse matrix representation of Q.
std::unique_ptr< SchurCompliment > m_schurCompliment
Schur complement S = D_reduced - Q_reduced * G_inv_reduced * M_reduced.
const mfem::BlockVector reconstruct_full_block_state_vector(const mfem::Vector &reducedState) const
void finalize(const mfem::Vector &initTheta)
Finalizes the operator setup. This must be called after setting essential true DOFs and before using ...
std::unique_ptr< mfem::SparseMatrix > m_QScaledReduced
Scaled Q matrix (free DOFs only, scaled by stabilization coefficient).
~PolytropeOperator() override=default
Destructor.
std::unique_ptr< mfem::MixedBilinearForm > m_M
Bilinear form M, coupling θ and φ.
void Mult(const mfem::Vector &xFree, mfem::Vector &yFree) const override
Applies the PolytropeOperator: y = F(x). This computes the residual of the nonlinear system.
void populate_free_dof_array()
Populates the internal array of free (non-essential) degree of freedom indices. This is called during...
std::unique_ptr< mfem::SparseMatrix > m_DScaledReduced
Scaled D matrix (free DOFs only, scaled by stabilization coefficient).
std::unique_ptr< mfem::NonlinearForm > m_f
Nonlinear form f, acting on θ.
void construct_reduced_block_offsets()
Constructs the block offsets for the reduced system. Called during finalize().
std::unique_ptr< mfem::SparseMatrix > m_MScaledReduced
Scaled M matrix (free DOFs only, scaled by stabilization coefficient).
mfem::Operator & GetGradient(const mfem::Vector &xFree) const override
Computes the Jacobian of the PolytropeOperator at a given state xFree. The Jacobian is of the form: J...
std::unique_ptr< mfem::SparseMatrix > m_ScaledSReduced
Scaled S matrix (free DOFs only, scaled by stabilization coefficient).
std::unique_ptr< mfem::SparseMatrix > m_gradReduced
Reduced gradient operator (G) for the nonlinear part f(θ).
const mfem::Array< int > & get_free_dofs() const
— Getters for information on internal state —
PolytropeOperator(std::unique_ptr< mfem::MixedBilinearForm > M, std::unique_ptr< mfem::MixedBilinearForm > Q, std::unique_ptr< mfem::BilinearForm > D, std::unique_ptr< mfem::BilinearForm > S, std::unique_ptr< mfem::NonlinearForm > f, const mfem::Array< int > &blockOffsets)
Constructs the PolytropeOperator.
void update_preconditioner(const mfem::Operator &grad) const
Updates the preconditioner components. This involves updating the inverse nonlinear Jacobian and then...
mfem::Vector m_state
Full state vector [θ, φ]^T, including essential DOFs.
void set_essential_true_dofs(const serif::types::MFEMArrayPair &theta_ess_tdofs, const serif::types::MFEMArrayPair &phi_ess_tdofs)
Sets the essential true degrees of freedom for both θ and φ variables. Marks the operator as not fina...
const mfem::BlockOperator & get_jacobian_operator() const
— Getters for key internal state and operators —
mfem::Array< int > m_reducedBlockOffsets
Block offsets for the reduced system (free DOFs).
const mfem::Array< int > m_blockOffsets
Block offsets for the full system [0, size(θ), size(θ)+size(φ)].
serif::types::MFEMArrayPairSet get_essential_true_dofs() const
Gets the currently set essential true degrees of freedom.
const mfem::Vector & reconstruct_full_state_vector(const mfem::Vector &reducedState) const
Reconstructs the full state vector (including essential DOFs) from a reduced state vector (free DOFs)...
void scatter_boundary_conditions()
Scatters the values of essential boundary conditions into the full state vector. Called during finali...
int get_reduced_system_size() const
Gets the size of the reduced system (number of free DOFs). Asserts that the operator is finalized.
const mfem::Array< int > & get_block_offsets() const
Gets the block offsets for the full (unreduced) system.
bool isFinalized() const
Checks if the operator has been finalized.
std::unique_ptr< GMRESInverter > m_invSchurCompliment
Approximate inverse of the Schur complement.
void construct_matrix_representations()
Constructs the sparse matrix representations of M, Q, and D, and their reduced forms....
serif::types::MFEMArrayPair m_phi_ess_tdofs
Essential true DOFs for φ (indices and values).
std::unique_ptr< mfem::SparseMatrix > m_MReduced
Reduced M matrix (free DOFs only).
static constexpr double m_stabilizationCoefficient
Stabilization coefficient for the system, used to more tightly couple ∇θ and φ.
serif::types::MFEMArrayPair m_theta_ess_tdofs
Essential true DOFs for θ (indices and values).
const mfem::Array< int > & get_reduced_block_offsets() const
Gets the block offsets for the reduced system (after eliminating essential DOFs).
std::unique_ptr< mfem::SparseMatrix > m_Smat
std::unique_ptr< mfem::Solver > m_invNonlinearJacobian
Solver for the inverse of the G block (gradient of f(θ)_reduced).
std::unique_ptr< mfem::SparseMatrix > m_Dmat
Sparse matrix representation of D.
std::unique_ptr< mfem::SparseMatrix > m_Mmat
Sparse matrix representation of M.
void update_inverse_schur_compliment() const
Updates the inverse Schur complement operator and its components. This is typically called after the ...
static constexpr double m_IncrementedStabilizationCoefficient
1 + Stabilization coefficient for the system, used to more tightly couple ∇θ and φ.
bool m_isFinalized
Flag indicating if finalize() has been called.
mfem::BlockDiagonalPreconditioner & get_preconditioner() const
Gets the block diagonal preconditioner for the Schur complement system. Asserts that the operator is ...
std::unique_ptr< mfem::SparseMatrix > m_SReduced
Reduced S matrix (free DOFs only, used for least squares stabilization).
serif::probe::LogManager & m_logManager
Reference to the global log manager.
void construct_jacobian_constant_terms()
Constructs the constant terms of the Jacobian operator (M, -Q, D). The (0,0) block (gradient of f) is...
std::unique_ptr< mfem::SparseMatrix > m_DReduced
Reduced D matrix (free DOFs only).
std::unique_ptr< mfem::ScaledOperator > m_negQ_mat
Scaled operator for -Q_reduced.
void update_inverse_nonlinear_jacobian(const mfem::Operator &grad) const
Updates the solver for the inverse of the nonlinear Jacobian block (G_00).
std::unique_ptr< mfem::BlockOperator > m_jacobian
Jacobian operator J = [G M; -Q D]_reduced.
std::unique_ptr< mfem::SparseMatrix > m_QReduced
Reduced Q matrix (free DOFs only).
std::unique_ptr< mfem::BilinearForm > m_D
Bilinear form D, acting on φ.
Represents the Schur complement operator used in the solution process.
SchurCompliment(const mfem::SparseMatrix &QOp, const mfem::SparseMatrix &DOp, const mfem::SparseMatrix &MOp, const mfem::Solver &GradInvOp)
Constructs a SchurCompliment operator.
const mfem::Solver * m_GradInvOp
Pointer to the inverse of the gradient operator.
~SchurCompliment() override=default
Destructor.
int m_nPhi
Dimension related to the phi variable (typically number of rows/cols of D).
void updateInverseNonlinearJacobian(const mfem::Solver &gradInv)
Updates the inverse of the nonlinear Jacobian (GradInv).
void Mult(const mfem::Vector &x, mfem::Vector &y) const override
Applies the Schur complement operator: y = (D - Q * GradInv * M) * x.
int m_nTheta
Dimension related to the theta variable (typically number of rows of M).
const mfem::SparseMatrix * m_QOp
Pointer to the Q matrix operator.
const mfem::SparseMatrix * m_DOp
Pointer to the D matrix operator.
std::unique_ptr< mfem::SparseMatrix > m_matrixForm
Optional: if a matrix representation is ever explicitly formed.
const mfem::SparseMatrix * m_MOp
Pointer to the M matrix operator.
void updateConstantTerms(const mfem::SparseMatrix &QOp, const mfem::SparseMatrix &DOp, const mfem::SparseMatrix &MOp)
Updates the constant matrix terms (Q, D, M).
void SetOperator(const mfem::SparseMatrix &QOp, const mfem::SparseMatrix &DOp, const mfem::SparseMatrix &MOp, const mfem::Solver &GradInvOp)
Sets all operators for the Schur complement.
Class to manage logging operations.
static LogManager & getInstance()
Get the singleton instance of LogManager.
std::pair< mfem::Array< int >, mfem::Array< double > > MFEMArrayPair
std::pair< MFEMArrayPair, MFEMArrayPair > MFEMArrayPairSet