feat(poly): added memory safty flags
This commit is contained in:
@@ -181,12 +181,24 @@ void PolySolver::solve() const {
|
||||
setInitialGuess();
|
||||
|
||||
setOperatorEssentialTrueDofs();
|
||||
const auto thetaVec = static_cast<mfem::Vector>(*m_theta); // NOLINT(*-slicing)
|
||||
const auto phiVec = static_cast<mfem::Vector>(*m_phi); // NOLINT(*-slicing)
|
||||
|
||||
// --- Finalize the operator ---
|
||||
// Finalize with the initial state of theta for the initial jacobian calculation
|
||||
m_polytropOperator->finalize(thetaVec);
|
||||
|
||||
if (!m_polytropOperator->isFinalized()) {
|
||||
LOG_ERROR(m_logger, "PolytropeOperator is not finalized. Cannot solve.");
|
||||
throw std::runtime_error("PolytropeOperator is not finalized. Cannot solve.");
|
||||
}
|
||||
|
||||
// It's safer to get the offsets directly from the operator after finalization
|
||||
const mfem::Array<int>& block_offsets = m_polytropOperator->GetBlockOffsets(); // Assuming a getter exists or accessing member if public/friend
|
||||
mfem::BlockVector state_vector(block_offsets);
|
||||
state_vector.GetBlock(0) = static_cast<mfem::Vector>(*m_theta); // NOLINT(*-slicing)
|
||||
state_vector.GetBlock(1) = static_cast<mfem::Vector>(*m_phi); // NOLINT(*-slicing)
|
||||
state_vector.GetBlock(0) = thetaVec; // NOLINT(*-slicing)
|
||||
state_vector.GetBlock(1) = phiVec; // NOLINT(*-slicing)
|
||||
|
||||
|
||||
mfem::Vector zero_rhs(block_offsets.Last());
|
||||
zero_rhs = 0.0;
|
||||
@@ -307,17 +319,8 @@ void PolySolver::saveAndViewSolution(const mfem::BlockVector& state_vector) cons
|
||||
}
|
||||
|
||||
void PolySolver::setOperatorEssentialTrueDofs() const {
|
||||
|
||||
SSE::MFEMArrayPairSet ess_tdof_pair_set = getEssentialTrueDof();
|
||||
const SSE::MFEMArrayPairSet ess_tdof_pair_set = getEssentialTrueDof();
|
||||
m_polytropOperator->SetEssentialTrueDofs(ess_tdof_pair_set);
|
||||
|
||||
// -- Finalize the operator --
|
||||
m_polytropOperator->finalize();
|
||||
|
||||
if (!m_polytropOperator->isFinalized()) {
|
||||
LOG_ERROR(m_logger, "PolytropeOperator is not finalized. Cannot solve.");
|
||||
throw std::runtime_error("PolytropeOperator is not finalized. Cannot solve.");
|
||||
}
|
||||
}
|
||||
|
||||
void PolySolver::LoadSolverUserParams(double &newtonRelTol, double &newtonAbsTol, int &newtonMaxIter, int &newtonPrintLevel, double &gmresRelTol, double &gmresAbsTol, int &gmresMaxIter, int &gmresPrintLevel) const {
|
||||
|
||||
Reference in New Issue
Block a user