96 const double c2 = weight*c1*c1;
174 const double c2 = weight*c1/2;
175 const double c3 = c1*c2;
191 return 0.5*I1b*I1b - 2.0;
249 return 0.5*(I2b + 1.0/I2b) - 1.0;
279 return I1b*(I1b - 1.0);
307 return 0.5*(I2*I2 + 1./(I2*I2) - 2.);
326 const double I2 =
ie.
Get_I2(), I2inv_sq = 1.0 / (I2 * I2);
337 return (I2b - 1.0)*(I2b - 1.0) - I2b + std::sqrt(I2b*I2b +
eps);
342 MFEM_ABORT(
"Metric not implemented yet. Use metric mu_55 instead.");
350 MFEM_ABORT(
"Metric not implemented yet. Use metric mu_55 instead.");
358 return 0.5*(I2b - 1.0)*(I2b - 1.0)/(I2b -
tau0);
369 const double c = (I2b - 1.0)/(I2b -
tau0);
385 const double c0 = 1.0/(I2b -
tau0);
386 const double c = c0*(I2b - 1.0);
431 double d_I1b_I2b_data[9];
435 const double a = weight/(6*std::sqrt(I1b_I2b));
469 const double c1 = weight/9;
531 return 0.5*(I3b + 1.0/I3b) - 1.0;
594 const double c1 = weight*c0*c0;
595 const double c2 = -2*c0*c1;
609 return 0.5*(I3b - 1.0)*(I3b - 1.0)/(I3b -
tau0);
620 const double c = (I3b - 1.0)/(I3b -
tau0);
641 const double c0 = 1.0/(I3b -
tau0);
642 const double c = c0*(I3b - 1.0);
650 MFEM_VERIFY(
nodes,
"Nodes are not given!");
651 MFEM_ASSERT(
avg_volume == 0.0,
"the average volume is already computed!");
654 const int NE = mesh->
GetNE();
658 for (
int i = 0; i < NE; i++)
678 area_NE[0] = volume; area_NE[1] = NE;
679 MPI_Allreduce(area_NE, area_NE + 2, 2, MPI_DOUBLE, MPI_SUM,
comm);
697 MFEM_ASSERT(Wideal.
Width() == Jtr.
SizeJ(),
"");
703 for (
int i = 0; i < ir.
GetNPoints(); i++) { Jtr(i) = Wideal; }
711 1./W.Height()), Wideal);
712 for (
int i = 0; i < ir.
GetNPoints(); i++) { Jtr(i) = W; }
734 const double det = Jtr(i).Det();
735 MFEM_VERIFY(det > 0.0,
"Initial mesh is inverted!");
736 Jtr(i).Set(std::pow(det / detW, 1./dim), Wideal);
742 MFEM_ABORT(
"invalid target type!");
802 const double weight = ip.
weight * Jtr_i.
Det();
818 energy += weight * val;
881 const double weight = ip.
weight * Jtr_i.
Det();
882 double weight_m = weight;
952 const double weight = ip.
weight * Jtr_i.
Det();
953 double weight_m = weight;
967 for (
int i = 0; i < dof; i++)
969 const double w_shape_i = weight_m * shape(i);
970 for (
int j = 0; j <= i; j++)
972 const double a = w_shape_i * shape(j);
973 for (
int d = 0; d <
dim; d++)
975 elmat(i+d*dof, j+d*dof) += a;
976 if (i != j) { elmat(j+d*dof, i+d*dof) += a; }
990 const int NE = mesh.
GetNE();
993 DenseMatrix Winv(dim), T(dim), A(dim), dshape, pos;
998 for (
int i = 0; i < NE; i++)
1015 for (
int j = 0; j < nsp; j++)
1026 metric_gf(gf_dofs[j]) = metric.
EvalW(T);
int GetNPoints() const
Returns the number of the points in the integration rule.
Abstract class for Finite Elements.
InvariantsEvaluator2D< double > ie
virtual void AssembleH(const DenseMatrix &Jpt, 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...
virtual void AssembleH(const DenseMatrix &Jpt, 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...
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
int GetDim() const
Returns the reference space dimension for the finite element.
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...
void AddMultVWt(const Vector &v, const Vector &w, DenseMatrix &VWt)
VWt += v w^t.
Class for an integration rule - an Array of IntegrationPoint.
const TargetType target_type
Class for grid function - Vector with associated FE space.
InvariantsEvaluator3D< double > ie
void Assemble_ddI2b(scalar_t w, scalar_t *A)
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
void Assemble_ddI2b(scalar_t w, scalar_t *A)
void SetDerivativeMatrix(int height, const scalar_t *Deriv)
The Deriv matrix is dof x 2, using column-major storage.
InvariantsEvaluator2D< double > ie
const scalar_t * Get_dI3b()
void SetSize(int s)
Resize the vector to size s.
void InterpolateTMOP_QualityMetric(TMOP_QualityMetric &metric, const TargetConstructor &tc, const Mesh &mesh, GridFunction &metric_gf)
Interpolates the metric's values at the nodes of metric_gf.
void GetElementVDofs(int i, Array< int > &vdofs) const
Returns indexes of degrees of freedom in array dofs for i'th element.
TMOP_QualityMetric * metric
InvariantsEvaluator2D< double > ie
virtual double EvalW(const DenseMatrix &Jpt) const =0
Evaluate the strain energy density function, W = W(Jpt).
void Mult(const Table &A, const Table &B, Table &C)
C = A * B (as boolean matrices)
virtual void AssembleH(const DenseMatrix &Jpt, 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...
int Width() const
Get the width (size of input) of the Operator. Synonym with NumCols().
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
virtual void ComputeElementTargets(int e_id, const FiniteElement &fe, const IntegrationRule &ir, DenseTensor &Jtr) const
Given an element and quadrature rule, computes ref->target transformation Jacobians for each quadratu...
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
void GetSubVector(const Array< int > &dofs, Vector &elemvect) const
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const =0
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
InvariantsEvaluator2D< double > ie
int GetOrder() const
Returns the order of the finite element.
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
Data type dense matrix using column-major storage.
void SetSize(int i, int j, int k)
int GetNE() const
Returns number of elements.
virtual void AssembleH(const DenseMatrix &Jpt, 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...
InvariantsEvaluator2D< double > ie
InvariantsEvaluator2D< double > ie
const GridFunction * nodes
void Assemble_TProd(scalar_t w, const scalar_t *X, const scalar_t *Y, scalar_t *A)
void Assemble_ddI1(scalar_t w, scalar_t *A)
double * GetData() const
Returns the matrix data array.
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
void Set(double alpha, const double *A)
Set the matrix to alpha * A, assuming that A has the same dimensions as the matrix and uses column-ma...
void Assemble_ddI2(scalar_t w, scalar_t *A)
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
const DenseMatrix & GetGeomToPerfGeomJac(int GeomType) const
void SetTargetJacobian(const DenseMatrix &_Jtr)
Specify the reference-element -> target-element Jacobian matrix for the point of interest.
virtual void AssembleH(const DenseMatrix &Jpt, 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...
virtual void AssembleH(const DenseMatrix &Jpt, 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 Add(const DenseMatrix &A, const DenseMatrix &B, double alpha, DenseMatrix &C)
C = A + alpha*B.
Abstract class for local mesh quality metrics in the target-matrix optimization paradigm (TMOP) by P...
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 SetJacobian(const scalar_t *Jac)
The Jacobian should use column-major storage.
void Assemble_ddI3b(scalar_t w, scalar_t *A)
InvariantsEvaluator3D< double > ie
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
virtual void AssembleH(const DenseMatrix &Jpt, 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...
Mesh * GetMesh() const
Returns the mesh.
virtual void AssembleH(const DenseMatrix &Jpt, 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...
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
InvariantsEvaluator2D< double > ie
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
const TargetConstructor * targetC
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
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...
const scalar_t * Get_dI2b()
virtual void GetElementDofs(int i, Array< int > &dofs) const
Returns indexes of degrees of freedom in array dofs for i'th element.
virtual void AssembleH(const DenseMatrix &Jpt, 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...
InvariantsEvaluator2D< double > ie
const IntegrationRule & GetNodes() const
void SetDerivativeMatrix(int height, const scalar_t *Deriv)
The Deriv matrix is dof x 3, using column-major storage.
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
InvariantsEvaluator2D< double > ie
virtual void AssembleElementVector(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, Vector &elvect)
Perform the local action of the NonlinearFormIntegrator.
int GetVDim() const
Returns vector dimension.
virtual void AssembleH(const DenseMatrix &Jpt, 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...
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
FiniteElementSpace * FESpace()
void Assemble_ddI1b(scalar_t w, scalar_t *A)
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
void ComputeAvgVolume() const
void CalcInverse(const DenseMatrix &a, DenseMatrix &inva)
int GetGeomType() const
Returns the Geometry::Type of the reference element.
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
double * Data() const
Returns the matrix data array.
void Transpose()
(*this) = (*this)^t
void AddMultABt(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &ABt)
ABt += A * B^t.
virtual void AssembleElementGrad(const FiniteElement &el, ElementTransformation &T, const Vector &elfun, DenseMatrix &elmat)
Assemble the local gradient matrix.
int GetDof() const
Returns the number of degrees of freedom in the finite element.
void Assemble_ddI2(scalar_t w, scalar_t *A)
const scalar_t * Get_dI1()
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
InvariantsEvaluator3D< double > ie
void subtract(const Vector &x, const Vector &y, Vector &z)
const scalar_t * Get_dI1()
InvariantsEvaluator2D< double > ie
virtual void AssembleH(const DenseMatrix &Jpt, 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...
double DistanceSquaredTo(const double *p) const
Compute the square of the Euclidean distance to another vector.
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
const scalar_t * Get_dI1b()
void SetDataAndSize(double *d, int s)
Set the Vector data and size.
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
const scalar_t * Get_dI1b()
int GetElementBaseGeometry(int i=0) const
virtual double EvalW(const DenseMatrix &Jpt) 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
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
virtual void AssembleH(const DenseMatrix &Jpt, 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...
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
InvariantsEvaluator3D< double > ie
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
const scalar_t * Get_dI2b()
Class for integration point with weight.
InvariantsEvaluator3D< double > ie
void Assemble_TProd(scalar_t w, const scalar_t *X, const scalar_t *Y, scalar_t *A)
const scalar_t * Get_dI2()
virtual void AssembleH(const DenseMatrix &Jpt, 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 GetElementTransformation(int i, IsoparametricTransformation *ElTr)
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
virtual double GetElementEnergy(const FiniteElement &el, ElementTransformation &T, const Vector &elfun)
Computes the integral of W(Jacobian(Trt)) over a target zone.
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
void Assemble_ddI1(scalar_t w, scalar_t *A)
const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement associated with i'th element.
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
InvariantsEvaluator2D< double > ie
virtual void AssembleH(const DenseMatrix &Jpt, 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...
InvariantsEvaluator2D< double > ie
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
virtual double Eval(ElementTransformation &T, const IntegrationPoint &ip)=0
const scalar_t * Get_dI2()
virtual void AssembleH(const DenseMatrix &Jpt, 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...
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
void MultAtB(const DenseMatrix &A, const DenseMatrix &B, DenseMatrix &AtB)
Multiply the transpose of a matrix A with a matrix B: At*B.
void GetNodes(Vector &node_coord) const
InvariantsEvaluator3D< double > ie
const GridFunction * nodes0
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
virtual void AssembleH(const DenseMatrix &Jpt, 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...
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
void UseExternalData(double *d, int h, int w)
Change the data array and the size of the DenseMatrix.
void Assemble_ddI1b(scalar_t w, scalar_t *A)
Base class representing target-matrix construction algorithms for mesh optimization via the target-ma...
void SetSize(int s)
Change the size of the DenseMatrix to s x s.
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
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...
Rank 3 tensor (array of matrices)
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
virtual double EvalW(const DenseMatrix &Jpt) const
Evaluate the strain energy density function, W = W(Jpt).
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
InvariantsEvaluator3D< double > ie
virtual void EvalP(const DenseMatrix &Jpt, DenseMatrix &P) const
Evaluate the 1st Piola-Kirchhoff stress tensor, P = P(Jpt).
virtual void AssembleH(const DenseMatrix &Jpt, 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...
virtual double EvalW(const DenseMatrix &Jpt) 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
Evaluate the derivative of the 1st Piola-Kirchhoff stress tensor and assemble its contribution to the...
void SetJacobian(const scalar_t *Jac)
The Jacobian should use column-major storage.