34 throw std::invalid_argument(
"Polytropic index must be non-negative.");
37 throw std::invalid_argument(
"Polytropic index must be less than 5.0.");
40 throw std::invalid_argument(
"Epsilon (Poly:Solver:Epsilon) must be positive non-zero.");
45 const mfem::FiniteElement &el,
46 mfem::ElementTransformation &Trans,
47 const mfem::Vector &elfun,
48 mfem::Vector &elvect) {
50 const mfem::IntegrationRule *ir = &mfem::IntRules.Get(el.GetGeomType(), 2 * el.GetOrder() + 3);
51 const int dof = el.GetDof();
55 mfem::Vector shape(dof);
56 mfem::Vector physCoord;
57 for (
int iqp = 0; iqp < ir->GetNPoints(); iqp++) {
58 mfem::IntegrationPoint ip = ir->IntPoint(iqp);
59 Trans.SetIntPoint(&ip);
60 const double weight = ip.weight * Trans.Weight();
62 el.CalcShape(ip, shape);
65 for (
int j = 0; j < dof; j++) {
66 u_val += elfun(j) * shape(j);
70 Trans.Transform(ip, physCoord);
71 const double r = physCoord.Norml2();
82 for (
int i = 0; i < dof; i++){
83 elvect(i) += shape(i) * u_nl * weight;
90 const mfem::FiniteElement &el,
91 mfem::ElementTransformation &Trans,
92 const mfem::Vector &elfun,
93 mfem::DenseMatrix &elmat) {
95 const mfem::IntegrationRule *ir = &mfem::IntRules.Get(el.GetGeomType(), 2 * el.GetOrder() + 3);
96 const int dof = el.GetDof();
99 mfem::Vector shape(dof);
100 mfem::DenseMatrix dshape(dof, 3);
101 mfem::DenseMatrix invJ(3, 3);
102 mfem::Vector physCoord;
104 for (
int iqp = 0; iqp < ir->GetNPoints(); iqp++) {
105 const mfem::IntegrationPoint &ip = ir->IntPoint(iqp);
106 Trans.SetIntPoint(&ip);
107 const double weight = ip.weight * Trans.Weight();
108 Trans.Transform(ip, physCoord);
109 double r = physCoord.Norml2();
111 el.CalcShape(ip, shape);
115 for (
int j = 0; j < dof; j++) {
116 u_val += elfun(j) * shape(j);
130 for (
int i = 0; i < dof; i++) {
131 for (
int j = 0; j < dof; j++) {
132 elmat(i, j) += shape(i) * d_u_nl * shape(j) * weight;
NonlinearPowerIntegrator(double n)
Constructor for NonlinearPowerIntegrator.
static constexpr double m_regularizationRadius
Regularization radius for the epsilon function, used to avoid singularities in the power law.
virtual void AssembleElementVector(const mfem::FiniteElement &el, mfem::ElementTransformation &Trans, const mfem::Vector &elfun, mfem::Vector &elvect) override
Assembles the element vector.
virtual void AssembleElementGrad(const mfem::FiniteElement &el, mfem::ElementTransformation &Trans, const mfem::Vector &elfun, mfem::DenseMatrix &elmat) override
Assembles the element gradient.
static constexpr double m_regularizationCoeff
Coefficient for the regularization term, used to ensure smoothness in the power law.
A collection of utilities for working with MFEM and solving the lane-emden equation.
double dfmod(const double epsilon, const double n)
double fmod(const double theta, const double n, const double epsilon)