fix(poly): fixed -M bug in form
MFEM MixedVectorWeakDivergenceIntegrator is actually already -M in our derivation, I have negated this so that Mform -> M directly
This commit is contained in:
@@ -22,8 +22,11 @@
|
||||
#include <cmath>
|
||||
|
||||
#include "integrators.h"
|
||||
#include <string>
|
||||
|
||||
|
||||
// static std::ofstream debugOut("gradient.csv", std::ios::trunc);
|
||||
|
||||
namespace polyMFEMUtils {
|
||||
NonlinearPowerIntegrator::NonlinearPowerIntegrator(const double n) :
|
||||
m_polytropicIndex(n) {}
|
||||
@@ -40,11 +43,10 @@ namespace polyMFEMUtils {
|
||||
elvect = 0.0;
|
||||
|
||||
mfem::Vector shape(dof);
|
||||
|
||||
for (int iqp = 0; iqp < ir->GetNPoints(); iqp++) {
|
||||
mfem::IntegrationPoint ip = ir->IntPoint(iqp);
|
||||
Trans.SetIntPoint(&ip);
|
||||
double weight = ip.weight * Trans.Weight();
|
||||
const double weight = ip.weight * Trans.Weight();
|
||||
|
||||
el.CalcShape(ip, shape);
|
||||
|
||||
@@ -52,10 +54,10 @@ namespace polyMFEMUtils {
|
||||
for (int j = 0; j < dof; j++) {
|
||||
u_val += elfun(j) * shape(j);
|
||||
}
|
||||
double u_safe = std::max(u_val, 0.0);
|
||||
double u_nl = std::pow(u_safe, m_polytropicIndex);
|
||||
|
||||
double x2_u_nl = u_nl;
|
||||
const double u_safe = std::max(u_val, 0.0);
|
||||
const double u_nl = std::pow(u_safe, m_polytropicIndex);
|
||||
|
||||
const double x2_u_nl = u_nl;
|
||||
|
||||
for (int i = 0; i < dof; i++){
|
||||
elvect(i) += shape(i) * x2_u_nl * weight;
|
||||
@@ -71,18 +73,23 @@ namespace polyMFEMUtils {
|
||||
mfem::DenseMatrix &elmat) {
|
||||
|
||||
const mfem::IntegrationRule *ir = &mfem::IntRules.Get(el.GetGeomType(), 2 * el.GetOrder() + 3);
|
||||
int dof = el.GetDof();
|
||||
const int dof = el.GetDof();
|
||||
elmat.SetSize(dof);
|
||||
elmat = 0.0;
|
||||
mfem::Vector shape(dof);
|
||||
|
||||
mfem::DenseMatrix dshape(dof, 3);
|
||||
mfem::DenseMatrix invJ(3, 3);
|
||||
mfem::Vector gradPhys(3);
|
||||
mfem::Vector physCoord(3);
|
||||
|
||||
for (int iqp = 0; iqp < ir->GetNPoints(); iqp++) {
|
||||
const mfem::IntegrationPoint &ip = ir->IntPoint(iqp);
|
||||
Trans.SetIntPoint(&ip);
|
||||
double weight = ip.weight * Trans.Weight();
|
||||
const double weight = ip.weight * Trans.Weight();
|
||||
|
||||
|
||||
el.CalcShape(ip, shape);
|
||||
|
||||
|
||||
double u_val = 0.0;
|
||||
|
||||
for (int j = 0; j < dof; j++) {
|
||||
@@ -90,16 +97,37 @@ namespace polyMFEMUtils {
|
||||
}
|
||||
|
||||
// Calculate the Jacobian
|
||||
double u_safe = std::max(u_val, 0.0);
|
||||
double d_u_nl = m_polytropicIndex * std::pow(u_safe, m_polytropicIndex - 1);
|
||||
double x2_d_u_nl = d_u_nl;
|
||||
const double u_safe = std::max(u_val, 0.0);
|
||||
const double d_u_nl = m_polytropicIndex * std::pow(u_safe, m_polytropicIndex - 1);
|
||||
const double x2_d_u_nl = d_u_nl;
|
||||
|
||||
for (int i = 0; i < dof; i++) {
|
||||
for (int j = 0; j < dof; j++) {
|
||||
elmat(i, j) += shape(i) * x2_d_u_nl * shape(j) * weight;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// // --- Debug Code to write out gradient ---
|
||||
// Trans.Transform(ip,physCoord);
|
||||
// el.CalcDShape(ip, dshape);
|
||||
//
|
||||
// mfem::CalcInverse(Trans.Jacobian(), invJ);
|
||||
//
|
||||
// mfem::DenseMatrix dshapePhys;
|
||||
// dshapePhys.SetSize(dof, physCoord.Size());
|
||||
// mfem::Mult(dshape, invJ, dshapePhys);
|
||||
//
|
||||
// gradPhys = 0.0;
|
||||
// for (int j = 0; j < dof; j++) {
|
||||
// for (int d = 0; d < gradPhys.Size(); d++) {
|
||||
// gradPhys(d) += elfun(j)*dshapePhys(j, d);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// debugOut
|
||||
// << physCoord(0) << ", " << physCoord(1) << ", " << physCoord(2)
|
||||
// << ", " << gradPhys(0) << ", " << gradPhys(1) << ", " << gradPhys(2) << '\n';
|
||||
}
|
||||
// debugOut.flush();
|
||||
}
|
||||
} // namespace polyMFEMUtils
|
||||
Reference in New Issue
Block a user