docs(laneEmdenVariationalForm): updated to match MFEM sign convention more closley
This commit is contained in:
@@ -58,38 +58,50 @@ void PolytropeOperator::finalize(const mfem::Vector &initTheta) {
|
||||
m_Qmat = std::make_unique<mfem::SparseMatrix>(m_Q->SpMat());
|
||||
m_Dmat = std::make_unique<mfem::SparseMatrix>(m_D->SpMat());
|
||||
|
||||
saveSparseMatrixBinary(*m_Mmat, "MmatRawO2.bin");
|
||||
saveSparseMatrixBinary(*m_Qmat, "QmatRawO2.bin");
|
||||
saveSparseMatrixBinary(*m_Dmat, "DmatRawO2.bin");
|
||||
|
||||
// Remove the essential dofs from the constant matrices
|
||||
for (const auto& dof: m_theta_ess_tdofs.first) {
|
||||
std::cout << "Eliminating dof: " << dof << std::endl;
|
||||
m_Mmat->EliminateRow(dof);
|
||||
m_Qmat->EliminateCol(dof);
|
||||
}
|
||||
|
||||
saveSparseMatrixBinary(*m_Mmat, "MmatBCThetaO2.bin");
|
||||
saveSparseMatrixBinary(*m_Qmat, "QmatBCThetaO2.bin");
|
||||
saveSparseMatrixBinary(*m_Dmat, "DmatBCThetaO2.bin");
|
||||
|
||||
for (const auto& dof: m_phi_ess_tdofs.first) {
|
||||
m_Mmat->EliminateCol(dof);
|
||||
m_Qmat->EliminateRow(dof);
|
||||
m_Dmat->EliminateRowCol(dof);
|
||||
}
|
||||
saveSparseMatrixBinary(*m_Mmat, "MmatBCO2.bin");
|
||||
saveSparseMatrixBinary(*m_Qmat, "QmatBCO2.bin");
|
||||
saveSparseMatrixBinary(*m_Dmat, "DmatBCO2.bin");
|
||||
|
||||
m_negM_mat = std::make_unique<mfem::ScaledOperator>(m_Mmat.get(), -1.0);
|
||||
m_negQ_mat = std::make_unique<mfem::ScaledOperator>(m_Qmat.get(), -1.0);
|
||||
|
||||
m_schurCompliment = std::make_unique<SchurCompliment>(*m_Qmat, *m_Dmat, *m_Mmat);
|
||||
// m_schurCompliment = std::make_unique<SchurCompliment>(*m_Qmat, *m_Dmat, *m_Mmat);
|
||||
|
||||
// Set up the constant parts of the jacobian now
|
||||
|
||||
// We use the assembled matrices with their boundary conditions already removed for the jacobian
|
||||
m_jacobian = std::make_unique<mfem::BlockOperator>(m_blockOffsets);
|
||||
m_jacobian->SetBlock(0, 1, m_negM_mat.get()); //<- -M (constant)
|
||||
m_jacobian->SetBlock(0, 1, m_Mmat.get()); //<- M (constant)
|
||||
m_jacobian->SetBlock(1, 0, m_negQ_mat.get()); //<- -Q (constant)
|
||||
m_jacobian->SetBlock(1, 1, m_Dmat.get()); //<- D (constant)
|
||||
|
||||
m_invSchurCompliment = std::make_unique<GMRESInverter>(*m_schurCompliment);
|
||||
// m_invSchurCompliment = std::make_unique<GMRESInverter>(*m_schurCompliment);
|
||||
|
||||
m_isFinalized = true;
|
||||
|
||||
// Build the initial preconditioner based on some initial guess
|
||||
const auto &grad = m_f->GetGradient(initTheta);
|
||||
updatePreconditioner(grad);
|
||||
// updatePreconditioner(grad);
|
||||
|
||||
}
|
||||
|
||||
@@ -137,7 +149,7 @@ void PolytropeOperator::Mult(const mfem::Vector &x, mfem::Vector &y) const {
|
||||
mfem::Vector Qtheta_term(phi_size);
|
||||
|
||||
// Calculate R0 and R1 terms
|
||||
// R0 = f(θ) - Mɸ
|
||||
// R0 = f(θ) + Mɸ
|
||||
// R1 = Dɸ - Qθ
|
||||
|
||||
MFEM_ASSERT(m_f.get() != nullptr, "NonlinearForm m_f is null in PolytropeOperator::Mult");
|
||||
@@ -147,7 +159,7 @@ void PolytropeOperator::Mult(const mfem::Vector &x, mfem::Vector &y) const {
|
||||
m_D->Mult(x_phi, Dphi_term);
|
||||
m_Q->Mult(x_theta, Qtheta_term);
|
||||
|
||||
subtract(f_term, Mphi_term, y_R0);
|
||||
add(f_term, Mphi_term, y_R0);
|
||||
subtract(Dphi_term, Qtheta_term, y_R1);
|
||||
|
||||
// -- Apply essential boundary conditions --
|
||||
@@ -211,7 +223,7 @@ mfem::Operator& PolytropeOperator::GetGradient(const mfem::Vector &x) const {
|
||||
const mfem::Vector& x_theta = x_block.GetBlock(0);
|
||||
|
||||
auto &grad = m_f->GetGradient(x_theta);
|
||||
updatePreconditioner(grad);
|
||||
// updatePreconditioner(grad);
|
||||
|
||||
m_jacobian->SetBlock(0, 0, &grad);
|
||||
|
||||
5
src/poly/utils/private/utilities.cpp
Normal file
5
src/poly/utils/private/utilities.cpp
Normal file
@@ -0,0 +1,5 @@
|
||||
//
|
||||
// Created by Emily Boudreaux on 6/4/25.
|
||||
//
|
||||
|
||||
#include "utilities.h"
|
||||
Reference in New Issue
Block a user