28template<
typename TDataType,
typename TParamVector,
typename TStateVector,
29 int residual_size,
int state_size,
int param_size>
37 void operator()(TParamVector &vparam, TStateVector &uu, TStateVector &rr)
39 MFEM_ASSERT(residual_size==4,
40 "PLaplacianResidual residual_size should be equal to 4!");
50 TDataType norm2 = uu[0] * uu[0] + uu[1] * uu[1] + uu[2] * uu[2];
51 TDataType tvar = pow(ee * ee + norm2, (pp - 2.0) / 2.0);
70template<
typename TDataType,
typename TParamVector,
typename TStateVector
71 ,
int state_size,
int param_size>
77 TDataType
operator()(TParamVector &vparam, TStateVector &uu)
79 MFEM_ASSERT(state_size==4,
"MyEnergyFunctor state_size should be equal to 4!");
80 MFEM_ASSERT(param_size==3,
"MyEnergyFunctor param_size should be equal to 3!");
86 TDataType norm2 = uu[0] * uu[0] + uu[1] * uu[1] + uu[2] * uu[2];
88 TDataType rez = pow(ee * ee + norm2, pp / 2.0) / pp - ff *
u;
103template<
class CQVectAutoDiff>
151 const int ndof = el.
GetDof();
152 const int ndim = el.
GetDim();
153 const int spaceDim =
trans.GetSpaceDim();
154 bool square = (ndim == spaceDim);
178 trans.SetIntPoint(&ip);
180 detJ = (square ? w : w * w);
187 Mult(dshape_iso,
trans.AdjugateJacobian(), dshape_xyz);
199 if (
coeff !=
nullptr)
209 for (
int jj = 0; jj < spaceDim; jj++)
211 uu[jj] = grad[jj] / detJ;
213 uu[3] = shapef * elfun;
215 energy = energy + w * qfunc(vparam,uu);
225 MFEM_PERF_BEGIN(
"AssembleElementVector");
226 const int ndof = el.
GetDof();
227 const int ndim = el.
GetDim();
228 const int spaceDim =
trans.GetSpaceDim();
249 trans.SetIntPoint(&ip);
255 Mult(dshape_iso,
trans.InverseJacobian(), dshape_xyz);
258 for (
int jj = 0; jj < spaceDim; jj++)
270 if (
coeff !=
nullptr)
283 rdf.VectorFunc(vparam,uu,du);
287 MFEM_PERF_END(
"AssembleElementVector");
295 MFEM_PERF_BEGIN(
"AssembleElementGrad");
296 const int ndof = el.
GetDof();
297 const int ndim = el.
GetDim();
298 const int spaceDim =
trans.GetSpaceDim();
320 trans.SetIntPoint(&ip);
326 Mult(dshape_iso,
trans.InverseJacobian(), dshape_xyz);
329 for (
int jj = 0; jj < spaceDim; jj++)
341 if (
coeff !=
nullptr)
354 rdf.Jacobian(vparam,uu,duu);
359 MFEM_PERF_END(
"AssembleElementGrad");
397 const int ndof = el.
GetDof();
398 const int ndim = el.
GetDim();
399 const int spaceDim =
trans.GetSpaceDim();
400 bool square = (ndim == spaceDim);
418 trans.SetIntPoint(&ip);
420 detJ = (square ? w : w * w);
427 Mult(dshape_iso,
trans.AdjugateJacobian(), dshape_xyz);
431 nrgrad2 = grad * grad / (detJ * detJ);
440 if (
coeff !=
nullptr)
445 energy = energy + w * std::pow(nrgrad2 + eee * eee, ppp / 2.0) / ppp;
450 energy = energy - w * (shapef * elfun) *
load->
Eval(
trans, ip);
461 MFEM_PERF_BEGIN(
"AssembleElementVector");
462 const int ndof = el.
GetDof();
463 const int ndim = el.
GetDim();
464 const int spaceDim =
trans.GetSpaceDim();
465 bool square = (ndim == spaceDim);
487 trans.SetIntPoint(&ip);
489 detJ = (square ? w : w * w);
496 Mult(dshape_iso,
trans.AdjugateJacobian(), dshape_xyz);
501 nrgrad = grad.
Norml2() / detJ;
511 if (
coeff !=
nullptr)
516 aa = nrgrad * nrgrad + eee * eee;
517 aa = std::pow(aa, (ppp - 2.0) / 2.0);
518 dshape_xyz.
Mult(grad, lvec);
519 elvect.
Add(w * aa / (detJ * detJ), lvec);
527 MFEM_PERF_END(
"AssembleElementVector");
535 MFEM_PERF_BEGIN(
"AssembleElementGrad");
536 const int ndof = el.
GetDof();
537 const int ndim = el.
GetDim();
538 const int spaceDim =
trans.GetSpaceDim();
539 bool square = (ndim == spaceDim);
562 trans.SetIntPoint(&ip);
564 detJ = (square ? w : w * w);
570 Mult(dshape_iso,
trans.AdjugateJacobian(), dshape_xyz);
580 if (
coeff !=
nullptr)
587 nrgrad = grad.
Norml2() / detJ;
589 aa0 = nrgrad * nrgrad + eee * eee;
590 aa1 = std::pow(aa0, (ppp - 2.0) / 2.0);
591 aa0 = (ppp - 2.0) * std::pow(aa0, (ppp - 4.0) / 2.0);
592 dshape_xyz.
Mult(grad, lvec);
593 w = w / (detJ * detJ);
598 MFEM_PERF_END(
"AssembleElementGrad");
608template<
int sizeres=10>
637 const int ndof = el.
GetDof();
638 const int ndim = el.
GetDim();
639 const int spaceDim =
trans.GetSpaceDim();
640 bool square = (ndim == spaceDim);
658 trans.SetIntPoint(&ip);
660 detJ = (square ? w : w * w);
667 Mult(dshape_iso,
trans.AdjugateJacobian(), dshape_xyz);
671 nrgrad2 = grad * grad / (detJ * detJ);
680 if (
coeff !=
nullptr)
685 energy = energy + w * std::pow(nrgrad2 + eee * eee, ppp / 2.0) / ppp;
690 energy = energy - w * (shapef * elfun) *
load->
Eval(
trans, ip);
701 MFEM_PERF_BEGIN(
"AssembleElementVector");
702 const int ndof = el.
GetDof();
703 const int ndim = el.
GetDim();
704 const int spaceDim =
trans.GetSpaceDim();
705 bool square = (ndim == spaceDim);
727 trans.SetIntPoint(&ip);
729 detJ = (square ? w : w * w);
736 Mult(dshape_iso,
trans.AdjugateJacobian(), dshape_xyz);
741 nrgrad = grad.
Norml2() / detJ;
751 if (
coeff !=
nullptr)
756 aa = nrgrad * nrgrad + eee * eee;
757 aa = std::pow(aa, (ppp - 2.0) / 2.0);
758 dshape_xyz.
Mult(grad, lvec);
759 elvect.
Add(w * aa / (detJ * detJ), lvec);
767 MFEM_PERF_END(
"AssembleElementVector");
775 MFEM_PERF_BEGIN(
"AssembleElementGrad");
776 const int ndof = el.
GetDof();
777 const int ndim = el.
GetDim();
778 const int spaceDim =
trans.GetSpaceDim();
779 bool square = (ndim == spaceDim);
801 vres.
SetSize(uu.Size()); vres=0.0;
812 trans.SetIntPoint(&ip);
814 detJ = (square ? w : w * w);
820 Mult(dshape_iso,
trans.AdjugateJacobian(), dshape_xyz);
830 if (
coeff !=
nullptr)
837 for (
int i=0; i<spaceDim; i++)
839 for (
int j=0; j<ndof; j++)
841 grad[i]= grad[i]+ dshape_xyz(j,i)*uu[j];
846 nrgrad= (grad*grad)/(detJ*detJ);
848 aa = nrgrad + eee * eee;
849 aa = pow(aa, (ppp - 2.0) / 2.0);
851 for (
int i=0; i<spaceDim; i++)
853 for (
int j=0; j<ndof; j++)
855 lvec[j] = lvec[j] + dshape_xyz(j,i) * grad[i];
859 for (
int j=0; j<ndof; j++)
861 vres[j]=vres[j] + lvec[j] * (w*aa/(detJ*detJ));
870 MFEM_PERF_END(
"AssembleElementGrad");
Base class Coefficients that optionally depend on space and time. These are used by the BilinearFormI...
virtual real_t Eval(ElementTransformation &T, const IntegrationPoint &ip)=0
Evaluate the coefficient in the element described by T at the point ip.
Data type dense matrix using column-major storage.
void Mult(const real_t *x, real_t *y) const
Matrix vector multiplication.
void MultTranspose(const real_t *x, real_t *y) const
Multiply a vector with the transpose matrix.
void SetSize(int s)
Change the size of the DenseMatrix to s x s.
void SetCol(int c, const real_t *col)
void GetColumn(int c, Vector &col) const
Abstract class for all finite elements.
int GetOrder() const
Returns the order of the finite element. In the case of anisotropic orders, returns the maximum order...
int GetDim() const
Returns the reference space dimension for the finite element.
virtual void CalcDShape(const IntegrationPoint &ip, DenseMatrix &dshape) const =0
Evaluate the gradients of all shape functions of a scalar finite element in reference space at the gi...
Geometry::Type GetGeomType() const
Returns the Geometry::Type of the reference element.
virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const =0
Evaluate the values of all shape functions of a scalar finite element in reference space at the given...
int GetDof() const
Returns the number of degrees of freedom in the finite element.
Class for integration point with weight.
Class for an integration rule - an Array of IntegrationPoint.
int GetNPoints() const
Returns the number of the points in the integration rule.
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
TDataType operator()(TParamVector &vparam, TStateVector &uu)
void operator()(TParamVector &vparam, TStateVector &uu, TStateVector &rr)
Templated vector data type.
void Jacobian(mfem::Vector &vparam, mfem::Vector &vstate, mfem::DenseMatrix &jac)
real_t Norml2() const
Returns the l2 norm of the vector.
void SetSize(int s)
Resize the vector to size s.
Vector & Add(const real_t a, const Vector &Va)
(*this) += a * Va
virtual real_t GetElementEnergy(const FiniteElement &el, ElementTransformation &trans, const Vector &elfun)
Compute the local energy.
virtual void AssembleElementGrad(const FiniteElement &el, ElementTransformation &trans, const Vector &elfun, DenseMatrix &elmat)
Assemble the local gradient matrix.
pLaplaceAD(Coefficient &pp_)
virtual void AssembleElementVector(const FiniteElement &el, ElementTransformation &trans, const Vector &elfun, Vector &elvect)
Perform the local action of the NonlinearFormIntegrator.
pLaplaceAD(Coefficient &pp_, Coefficient &q, Coefficient &ld_)
virtual void AssembleElementGrad(const FiniteElement &el, ElementTransformation &trans, const Vector &elfun, DenseMatrix &elmat)
Assemble the local gradient matrix.
pLaplaceSL(Coefficient &pp_, Coefficient &q, Coefficient &ld_)
virtual real_t GetElementEnergy(const FiniteElement &el, ElementTransformation &trans, const Vector &elfun)
Compute the local energy.
virtual void AssembleElementVector(const FiniteElement &el, ElementTransformation &trans, const Vector &elfun, Vector &elvect)
Perform the local action of the NonlinearFormIntegrator.
pLaplaceSL(Coefficient &pp_)
virtual void AssembleElementGrad(const FiniteElement &el, ElementTransformation &trans, const Vector &elfun, DenseMatrix &elmat)
Assemble the local gradient matrix.
virtual real_t GetElementEnergy(const FiniteElement &el, ElementTransformation &trans, const Vector &elfun)
Compute the local energy.
pLaplace(Coefficient &pp_)
pLaplace(Coefficient &pp_, Coefficient &q, Coefficient &ld_)
virtual void AssembleElementVector(const FiniteElement &el, ElementTransformation &trans, const Vector &elfun, Vector &elvect)
Perform the local action of the NonlinearFormIntegrator.
void trans(const Vector &u, Vector &x)
codi::RealForward ADFloatType
Forward AD type declaration.
void AddMult_a_ABt(real_t a, const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &ABt)
ABt += a * A * B^t.
real_t u(const Vector &xvec)
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
void AddMult_a_VVt(const real_t a, const Vector &v, DenseMatrix &VVt)
VVt += a * v v^t.
void AddMult_a_AAt(real_t a, const DenseMatrix &A, DenseMatrix &AAt)
AAt += a * A * A^t.
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)