13 #include "../general/forall.hpp"
20 mfem_error (
"NonlinearFormIntegrator::AssemblePA(...)\n"
21 " is not implemented for this class.");
27 mfem_error (
"NonlinearFormIntegrator::AssemblePA(...)\n"
28 " is not implemented for this class.");
33 mfem_error (
"NonlinearFormIntegrator::AddMultPA(...)\n"
34 " is not implemented for this class.");
41 mfem_error(
"NonlinearFormIntegrator::AssembleElementVector"
42 " is not overloaded!");
49 mfem_error(
"NonlinearFormIntegrator::AssembleFaceVector"
50 " is not overloaded!");
57 mfem_error(
"NonlinearFormIntegrator::AssembleElementGrad"
58 " is not overloaded!");
66 mfem_error(
"NonlinearFormIntegrator::AssembleFaceGrad"
67 " is not overloaded!");
73 mfem_error(
"NonlinearFormIntegrator::GetElementEnergy"
74 " is not overloaded!");
85 mfem_error(
"BlockNonlinearFormIntegrator::AssembleElementVector"
86 " is not overloaded!");
96 mfem_error(
"BlockNonlinearFormIntegrator::AssembleFaceVector"
97 " is not overloaded!");
106 mfem_error(
"BlockNonlinearFormIntegrator::AssembleElementGrad"
107 " is not overloaded!");
117 mfem_error(
"BlockNonlinearFormIntegrator::AssembleFaceGrad"
118 " is not overloaded!");
126 mfem_error(
"BlockNonlinearFormIntegrator::GetElementEnergy"
127 " is not overloaded!");
136 return 0.5*(
Z*
Z)/J.
Det();
149 for (
int i = 0; i <
dim; i++)
182 for (
int i = 0; i < dof; i++)
183 for (
int j = 0; j <= i; j++)
186 for (
int d = 0; d <
dim; d++)
191 for (
int k = 0; k <
dim; k++)
192 for (
int l = 0; l <= k; l++)
195 A(i+k*dof,j+l*dof) +=
b;
198 A(j+k*dof,i+l*dof) +=
b;
202 A(i+l*dof,j+k*dof) +=
b;
205 A(j+l*dof,i+k*dof) +=
b;
212 for (
int i = 1; i < dof; i++)
213 for (
int j = 0; j < i; j++)
215 for (
int k = 1; k <
dim; k++)
216 for (
int l = 0; l < k; l++)
219 weight*(
C(i,l)*
G(j,k) -
C(i,k)*
G(j,l) +
220 C(j,k)*
G(i,l) -
C(j,l)*
G(i,k) +
221 t*(
G(i,k)*
G(j,l) -
G(i,l)*
G(j,k)));
223 A(i+k*dof,j+l*dof) +=
a;
224 A(j+l*dof,i+k*dof) +=
a;
226 A(i+l*dof,j+k*dof) -=
a;
227 A(j+k*dof,i+l*dof) -=
a;
254 double bI1 = pow(dJ, -2.0/dim)*(J*J);
256 return 0.5*(
mu*(bI1 -
dim) +
K*(sJ - 1.0)*(sJ - 1.0));
272 double a =
mu*pow(dJ, -2.0/dim);
273 double b =
K*(dJ/
g - 1.0)/
g - a*(J*J)/(dim*dJ);
296 double a =
mu*pow(dJ, -2.0/
dim);
297 double bc = a*(J*J)/
dim;
298 double b = bc -
K*sJ*(sJ - 1.0);
299 double c = 2.0*bc/
dim +
K*sJ*(2.0*sJ - 1.0);
312 for (
int i = 0; i < dof; i++)
313 for (
int k = 0; k <= i; k++)
316 for (
int d = 0; d <
dim; d++)
318 s += DS(i,d)*DS(k,d);
322 for (
int d = 0; d <
dim; d++)
324 A(i+d*dof,k+d*dof) += s;
328 for (
int d = 0; d <
dim; d++)
330 A(k+d*dof,i+d*dof) += s;
337 for (
int i = 0; i < dof; i++)
338 for (
int j = 0; j <
dim; j++)
339 for (
int k = 0; k < dof; k++)
340 for (
int l = 0; l <
dim; l++)
342 A(i+j*dof,k+l*dof) +=
343 a*(
C(i,j)*
G(k,l) +
G(i,j)*
C(k,l)) +
344 b*
G(i,l)*
G(k,j) + c*
G(i,j)*
G(k,l);
419 model->
EvalP(Jpt, P);
469 mfem_error(
"IncompressibleNeoHookeanIntegrator::GetElementEnergy"
470 " has incorrect block finite element space size!");
473 int dof_u = el[0]->GetDof();
474 int dim = el[0]->GetDim();
482 int intorder = 2*el[0]->GetOrder() + 3;
494 el[0]->CalcDShape(ip, DSh_u);
498 mu = c_mu->
Eval(Tr, ip);
514 mfem_error(
"IncompressibleNeoHookeanIntegrator::AssembleElementVector"
515 " has finite element space of incorrect block number");
518 int dof_u = el[0]->GetDof();
519 int dof_p = el[1]->GetDof();
521 int dim = el[0]->GetDim();
526 mfem_error(
"IncompressibleNeoHookeanIntegrator::AssembleElementVector"
527 " is not defined on manifold meshes");
544 int intorder = 2*el[0]->GetOrder() + 3;
556 el[0]->CalcDShape(ip, DSh_u);
557 Mult(DSh_u, J0i, DS_u);
560 el[1]->CalcShape(ip, Sh_p);
562 double pres = Sh_p * *elfun[1];
563 double mu = c_mu->
Eval(Tr, ip);
570 P.
Add(-1.0 * pres * dJ, FinvT);
575 elvec[1]->Add(ip.
weight * Tr.
Weight() * (dJ - 1.0), Sh_p);
586 int dof_u = el[0]->GetDof();
587 int dof_p = el[1]->GetDof();
589 int dim = el[0]->GetDim();
591 elmats(0,0)->
SetSize(dof_u*dim, dof_u*dim);
592 elmats(0,1)->
SetSize(dof_u*dim, dof_p);
593 elmats(1,0)->
SetSize(dof_p, dof_u*dim);
594 elmats(1,1)->
SetSize(dof_p, dof_p);
611 int intorder = 2*el[0]->GetOrder() + 3;
620 el[0]->CalcDShape(ip, DSh_u);
621 Mult(DSh_u, J0i, DS_u);
624 el[1]->CalcShape(ip, Sh_p);
625 double pres = Sh_p * *elfun[1];
626 double mu = c_mu->
Eval(Tr, ip);
633 for (
int i_u = 0; i_u < dof_u; ++i_u)
635 for (
int i_dim = 0; i_dim <
dim; ++i_dim)
637 for (
int j_u = 0; j_u < dof_u; ++j_u)
639 for (
int j_dim = 0; j_dim <
dim; ++j_dim)
645 for (
int n=0; n<
dim; ++n)
647 for (
int l=0; l<
dim; ++l)
649 (*elmats(0,0))(i_u + i_dim*dof_u, j_u + j_dim*dof_u) +=
650 dJ * (mu * F(i_dim, l) - pres * FinvT(i_dim,l)) *
651 FinvT(j_dim,n) * DS_u(i_u,l) * DS_u(j_u, n) *
654 if (j_dim == i_dim && n==l)
656 (*elmats(0,0))(i_u + i_dim*dof_u, j_u + j_dim*dof_u) +=
657 dJ * mu * DS_u(i_u, l) * DS_u(j_u,n) *
663 (*elmats(0,0))(i_u + i_dim*dof_u, j_u + j_dim*dof_u) +=
664 dJ * pres * FinvT(i_dim, n) *
665 FinvT(j_dim,l) * DS_u(i_u,l) * DS_u(j_u,n) *
675 for (
int i_p = 0; i_p < dof_p; ++i_p)
677 for (
int j_u = 0; j_u < dof_u; ++j_u)
679 for (
int dim_u = 0; dim_u <
dim; ++dim_u)
681 for (
int l=0; l<
dim; ++l)
683 dJ_FinvT_DS = dJ * FinvT(dim_u,l) * DS_u(j_u, l) * Sh_p(i_p) *
685 (*elmats(1,0))(i_p, j_u + dof_u * dim_u) += dJ_FinvT_DS;
686 (*elmats(0,1))(j_u + dof_u * dim_u, i_p) -= dJ_FinvT_DS;
710 const int nd = el.
GetDof();
711 const int dim = el.
GetDim();
721 Vector vec1(dim), vec2(dim);
731 if (Q) { w *= Q->
Eval(T, ip); }
734 gradEF.
Mult(vec1, vec2);
759 Vector vec1(dim), vec2(dim), vec3(nd);
783 w *= Q->
Eval(trans, ip);
792 dshape.
Mult(vec2, vec3);
793 MultVWt(shape, vec3, elmat_comp);
795 for (
int i = 0; i < dim; i++)
797 elmat.
AddMatrix(elmat_comp, i * nd, i * nd);
804 w *= Q->
Eval(trans, ip);
806 for (
int i = 0; i < dim; i++)
808 for (
int j = 0; j < dim; j++)
810 elmat.
AddMatrix(w * gradEF(i, j), elmat_comp, i * nd, j * nd);
int GetNPoints() const
Returns the number of the points in the integration rule.
Abstract class for all finite elements.
void MultABt(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &ABt)
Multiply a matrix A with the transpose of a matrix B: A*Bt.
int Size() const
Return the logical size of the array.
virtual void EvalP(const DenseMatrix &J, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
virtual double EvalW(const DenseMatrix &J) const
Evaluate the strain energy density function, W = W(Jpt).
int GetDim() const
Returns the reference space dimension for the finite element.
void trans(const Vector &u, Vector &x)
virtual void AssembleElementGrad(const Array< const FiniteElement * > &el, ElementTransformation &Tr, const Array< const Vector * > &elfun, const Array2D< DenseMatrix * > &elmats)
Assemble the local gradient matrix.
void AddMultVWt(const Vector &v, const Vector &w, DenseMatrix &VWt)
VWt += v w^t.
Class for an integration rule - an Array of IntegrationPoint.
void MultVWt(const Vector &v, const Vector &w, DenseMatrix &VWt)
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
void SetSize(int s)
Resize the vector to size s.
virtual void AssembleH(const DenseMatrix &J, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols().
int GetOrder() const
Returns the order of the finite element. In the case of anisotropic orders, returns the maximum order...
Data type dense matrix using column-major storage.
virtual double EvalW(const DenseMatrix &Jpt) const =0
Evaluate the strain energy density function, W = W(Jpt).
virtual void AssembleElementVector(const FiniteElement &el, ElementTransformation &trans, const Vector &elfun, Vector &elvect)
Perform the local action of the NonlinearFormIntegrator.
virtual void EvalP(const DenseMatrix &J, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
double * GetData() const
Return a pointer to the beginning of the Vector data.
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const =0
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
virtual void AssembleElementGrad(const FiniteElement &el, ElementTransformation &trans, const Vector &elfun, DenseMatrix &elmat)
Assemble the local gradient matrix.
Geometry::Type GetGeomType() const
Returns the Geometry::Type of the reference element.
void SetSize(int m, int n)
IntegrationPoint & IntPoint(int i)
Returns a reference to the i-th integration point.
void MultTranspose(const double *x, double *y) const
Multiply a vector with the transpose matrix.
void CalcAdjugateTranspose(const DenseMatrix &a, DenseMatrix &adjat)
Calculate the transposed adjugate of a matrix (for NxN matrices, N=1,2,3)
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
void Add(const double c, const DenseMatrix &A)
Adds the matrix A multiplied by the number c to the matrix.
void mfem_error(const char *msg)
Function called when an error is encountered. Used by the macros MFEM_ABORT, MFEM_ASSERT, MFEM_VERIFY.
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...
virtual double GetElementEnergy(const Array< const FiniteElement * > &el, ElementTransformation &Tr, const Array< const Vector * > &elfun)
Compute the local energy.
void CalcPhysDShape(ElementTransformation &Trans, DenseMatrix &dshape) const
Evaluate the gradients of all shape functions of a scalar finite element in physical space at the poi...
virtual void AssembleElementGrad(const FiniteElement &el, ElementTransformation &Ttr, const Vector &elfun, DenseMatrix &elmat)
Assemble the local gradient matrix.
virtual double GetElementEnergy(const FiniteElement &el, ElementTransformation &Ttr, const Vector &elfun)
Computes the integral of W(Jacobian(Trt)) over a target zone.
Dynamic 2D array using row-major layout.
void SetTransformation(ElementTransformation &_Ttr)
void CalcInverse(const DenseMatrix &a, DenseMatrix &inva)
void MultVVt(const Vector &v, DenseMatrix &vvt)
Make a matrix from a vector V.Vt.
double Trace() const
Trace of a square matrix.
void AddMultABt(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &ABt)
ABt += A * B^t.
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
int GetDof() const
Returns the number of degrees of freedom in the finite element.
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
void MultAAt(const DenseMatrix &a, DenseMatrix &aat)
Calculate the matrix A.At.
void AddMatrix(DenseMatrix &A, int ro, int co)
Perform (ro+i,co+j)+=A(i,j) for 0<=i<A.Height, 0<=j<A.Width.
void CalcInverseTranspose(const DenseMatrix &a, DenseMatrix &inva)
Calculate the inverse transpose of a matrix (for NxN matrices, N=1,2,3)
ElementTransformation * Ttr
virtual void AssembleH(const DenseMatrix &J, const DenseMatrix &DS, const double weight, DenseMatrix &A) const
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
Class for integration point with weight.
virtual double EvalW(const DenseMatrix &J) const
Evaluate the strain energy density function, W = W(Jpt).
virtual void AssembleH(const DenseMatrix &Jpt, const DenseMatrix &DS, const double weight, DenseMatrix &A) const =0
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
virtual void AssembleElementVector(const Array< const FiniteElement * > &el, ElementTransformation &Tr, const Array< const Vector * > &elfun, const Array< Vector * > &elvec)
Perform the local action of the NonlinearFormIntegrator.
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)=0
Evaluate the coefficient in the element described by T at the point ip.
virtual void AssembleElementVector(const FiniteElement &el, ElementTransformation &Ttr, const Vector &elfun, Vector &elvect)
Perform the local action of the NonlinearFormIntegrator.
void MultAtB(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &AtB)
Multiply the transpose of a matrix A with a matrix B: At*B.
void Mult(const double *x, double *y) const
Matrix vector multiplication.
void UseExternalData(double *d, int h, int w)
Change the data array and the size of the DenseMatrix.
void SetSize(int s)
Change the size of the DenseMatrix to s x s.
static const IntegrationRule & GetRule(const FiniteElement &fe, ElementTransformation &T)
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...
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)