fix(poly): bug fixing in block form
currently derivitive constraint is not working
This commit is contained in:
@@ -60,7 +60,8 @@ namespace polyMFEMUtils {
|
||||
double u_safe = std::max(u_val, 0.0);
|
||||
double u_nl = std::pow(u_safe, m_polytropicIndex);
|
||||
|
||||
double coeff_val = m_coeff.Eval(Trans, ip);
|
||||
// double coeff_val = m_coeff.Eval(Trans, ip);
|
||||
double coeff_val = 1.0;
|
||||
double x2_u_nl = coeff_val * u_nl;
|
||||
|
||||
for (int i = 0; i < dof; i++){
|
||||
@@ -94,7 +95,8 @@ namespace polyMFEMUtils {
|
||||
for (int j = 0; j < dof; j++) {
|
||||
u_val += elfun(j) * shape(j);
|
||||
}
|
||||
double coeff_val = m_coeff.Eval(Trans, ip);
|
||||
// double coeff_val = m_coeff.Eval(Trans, ip);
|
||||
double coeff_val = 1.0;
|
||||
|
||||
|
||||
// Calculate the Jacobian
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include "linalg/vector.hpp"
|
||||
#include <memory>
|
||||
|
||||
#include "debug.h"
|
||||
|
||||
PolytropeOperator::PolytropeOperator(
|
||||
|
||||
std::unique_ptr<mfem::MixedBilinearForm> M,
|
||||
@@ -19,8 +21,12 @@ PolytropeOperator::PolytropeOperator(
|
||||
m_Q = std::move(Q);
|
||||
m_D = std::move(D);
|
||||
m_f = std::move(f);
|
||||
}
|
||||
|
||||
|
||||
void PolytropeOperator::finalize() {
|
||||
if (m_isFinalized) {
|
||||
return;
|
||||
}
|
||||
m_Mmat = std::make_unique<mfem::SparseMatrix>(m_M->SpMat());
|
||||
m_Qmat = std::make_unique<mfem::SparseMatrix>(m_Q->SpMat());
|
||||
m_Dmat = std::make_unique<mfem::SparseMatrix>(m_D->SpMat());
|
||||
@@ -28,14 +34,14 @@ PolytropeOperator::PolytropeOperator(
|
||||
m_negM_op = std::make_unique<mfem::ScaledOperator>(m_Mmat.get(), -1.0);
|
||||
m_negQ_op = std::make_unique<mfem::ScaledOperator>(m_Qmat.get(), -1.0);
|
||||
|
||||
MFEM_ASSERT(m_Mmat.get() != nullptr, "Matrix m_Mmat is null in PolytropeOperator constructor");
|
||||
MFEM_ASSERT(m_Qmat.get() != nullptr, "Matrix m_Qmat is null in PolytropeOperator constructor");
|
||||
MFEM_ASSERT(m_Dmat.get() != nullptr, "Matrix m_Dmat is null in PolytropeOperator constructor");
|
||||
MFEM_ASSERT(m_f.get() != nullptr, "NonlinearForm m_f is null in PolytropeOperator constructor");
|
||||
m_isFinalized = true;
|
||||
}
|
||||
|
||||
|
||||
void PolytropeOperator::Mult(const mfem::Vector &x, mfem::Vector &y) const {
|
||||
if (!m_isFinalized) {
|
||||
MFEM_ABORT("PolytropeOperator::Mult called before finalize");
|
||||
}
|
||||
// -- Create BlockVector views for input x and output y
|
||||
mfem::BlockVector x_block(const_cast<mfem::Vector&>(x), m_blockOffsets);
|
||||
mfem::BlockVector y_block(y, m_blockOffsets);
|
||||
@@ -89,6 +95,9 @@ void PolytropeOperator::Mult(const mfem::Vector &x, mfem::Vector &y) const {
|
||||
|
||||
}
|
||||
mfem::Operator& PolytropeOperator::GetGradient(const mfem::Vector &x) const {
|
||||
if (!m_isFinalized) {
|
||||
MFEM_ABORT("PolytropeOperator::GetGradient called before finalize");
|
||||
}
|
||||
// -- Get the gradient of f --
|
||||
mfem::BlockVector x_block(const_cast<mfem::Vector&>(x), m_blockOffsets);
|
||||
const mfem::Vector& x_theta = x_block.GetBlock(0);
|
||||
@@ -111,6 +120,7 @@ mfem::Operator& PolytropeOperator::GetGradient(const mfem::Vector &x) const {
|
||||
|
||||
void PolytropeOperator::SetEssentialTrueDofs(const mfem::Array<int> &theta_ess_tofs,
|
||||
const mfem::Array<int> &phi_ess_tofs) {
|
||||
m_isFinalized = false;
|
||||
m_theta_ess_tofs = theta_ess_tofs;
|
||||
m_phi_ess_tofs = phi_ess_tofs;
|
||||
|
||||
|
||||
@@ -20,13 +20,19 @@ public:
|
||||
void SetEssentialTrueDofs(const mfem::Array<int> &theta_ess_tofs,
|
||||
const mfem::Array<int> &phi_ess_tofs);
|
||||
|
||||
bool isFinalized() const { return m_isFinalized; }
|
||||
|
||||
void finalize();
|
||||
|
||||
const mfem::Array<int>& GetBlockOffsets() const { return m_blockOffsets; }
|
||||
|
||||
private:
|
||||
std::unique_ptr<mfem::MixedBilinearForm> m_M;
|
||||
std::unique_ptr<mfem::MixedBilinearForm> m_Q;
|
||||
std::unique_ptr<mfem::BilinearForm> m_D;
|
||||
std::unique_ptr<mfem::NonlinearForm> m_f;
|
||||
|
||||
const mfem::Array<int> &m_blockOffsets;
|
||||
const mfem::Array<int> m_blockOffsets;
|
||||
|
||||
mfem::Array<int> m_theta_ess_tofs;
|
||||
mfem::Array<int> m_phi_ess_tofs;
|
||||
@@ -39,6 +45,8 @@ private:
|
||||
std::unique_ptr<mfem::ScaledOperator> m_negM_op;
|
||||
std::unique_ptr<mfem::ScaledOperator> m_negQ_op;
|
||||
mutable std::unique_ptr<mfem::BlockOperator> m_jacobian;
|
||||
|
||||
bool m_isFinalized = false;
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user