feat(poly): refactoring PolytropeOperator to work on the reduced system so as to avoid rank deficiencies

This commit is contained in:
2025-06-05 12:37:00 -04:00
parent 4eb8b71271
commit a31c966146
7 changed files with 272 additions and 113 deletions

View File

@@ -70,28 +70,34 @@ public:
std::unique_ptr<mfem::MixedBilinearForm> Q,
std::unique_ptr<mfem::BilinearForm> D,
std::unique_ptr<mfem::NonlinearForm> f,
const mfem::Array<int> &blockOffsets,
const double index);
const mfem::Array<int> &blockOffsets);
void populate_free_dof_array();
~PolytropeOperator() override = default;
void Mult(const mfem::Vector &x, mfem::Vector &y) const override;
void Mult(const mfem::Vector &xFree, mfem::Vector &yFree) const override;
mfem::Operator& GetGradient(const mfem::Vector &x) const override;
mfem::Operator& GetGradient(const mfem::Vector &xFree) const override;
void SetEssentialTrueDofs(const SSE::MFEMArrayPair& theta_ess_tdofs, const SSE::MFEMArrayPair& phi_ess_tdofs);
void SetEssentialTrueDofs(const SSE::MFEMArrayPairSet& ess_tdof_pair_set);
void set_essential_true_dofs(const SSE::MFEMArrayPair& theta_ess_tdofs, const SSE::MFEMArrayPair& phi_ess_tdofs);
void set_essential_true_dofs(const SSE::MFEMArrayPairSet& ess_tdof_pair_set);
SSE::MFEMArrayPairSet GetEssentialTrueDofs() const;
SSE::MFEMArrayPairSet get_essential_true_dofs() const;
bool isFinalized() const { return m_isFinalized; }
void finalize(const mfem::Vector &initTheta);
const mfem::Array<int>& GetBlockOffsets() const { return m_blockOffsets; }
const mfem::Array<int>& get_block_offsets() const { return m_blockOffsets; }
const mfem::Array<int>& get_reduced_block_offsets() const {return m_reducedBlockOffsets; }
const mfem::BlockOperator &GetJacobianOperator() const;
const mfem::BlockOperator &get_jacobian_operator() const;
mfem::BlockDiagonalPreconditioner &GetPreconditioner() const;
mfem::BlockDiagonalPreconditioner &get_preconditioner() const;
int get_reduced_system_size() const;
private:
@@ -102,26 +108,24 @@ private:
std::unique_ptr<mfem::BilinearForm> m_D;
std::unique_ptr<mfem::NonlinearForm> m_f;
// These are used to store the matrix representations
// for the bi-linear forms. This might seem counterintuitive
// for a matrix-free approach. However, these will be computed
// regardless due to MFEM's implementation of these operators.
// Further since these do not change it is not a performance issue.
// We need to store these separately because the jacobian and preconditioner
// must be computed from the boundary aware operators (which will be these
// matrices) whereas the residuals must be computed from the raw, physical,
// operators
std::unique_ptr<mfem::SparseMatrix> m_Mmat;
std::unique_ptr<mfem::SparseMatrix> m_Qmat;
std::unique_ptr<mfem::SparseMatrix> m_Dmat;
mutable mfem::Vector m_state;
mfem::Array<int> m_freeDofs;
// These are used to store the reduced system matrices after essential dofs have been eliminated
std::unique_ptr<mfem::SparseMatrix> m_MReduced;
std::unique_ptr<mfem::SparseMatrix> m_QReduced;
std::unique_ptr<mfem::SparseMatrix> m_DReduced;
const mfem::Array<int> m_blockOffsets;
mfem::Array<int> m_reducedBlockOffsets;
SSE::MFEMArrayPair m_theta_ess_tdofs;
SSE::MFEMArrayPair m_phi_ess_tdofs;
std::unique_ptr<mfem::ScaledOperator> m_negM_mat;
std::unique_ptr<mfem::ScaledOperator> m_negQ_mat;
mutable std::unique_ptr<mfem::BlockOperator> m_jacobian;
@@ -134,8 +138,12 @@ private:
bool m_isFinalized = false;
private:
void updateInverseNonlinearJacobian(const mfem::Operator &grad) const;
void updateInverseSchurCompliment() const;
void updatePreconditioner(const mfem::Operator &grad) const;
void update_inverse_nonlinear_jacobian(const mfem::Operator &grad) const;
void update_inverse_schur_compliment() const;
void update_preconditioner(const mfem::Operator &grad) const;
void scatter_boundary_conditions();
void construct_matrix_representations();
void construct_reduced_block_offsets();
void construct_jacobian_constant_terms();
};