24 MFEM_VERIFY(order > 0,
"Invalid input");
30 MFEM_VERIFY(order > 0,
"Invalid input");
39 Init(order, levelset, lsO);
118 Mat.SetCol(ip, shape);
147 for (
int face = 0; face < me->
GetNFaces(); face++)
160 pointA(d) = (mesh->
GetVertex(verts[0]))[d];
161 pointB(d) = (mesh->
GetVertex(verts[1]))[d];
162 pointC(d) = (mesh->
GetVertex(verts[2]))[d];
163 pointD(d) = (mesh->
GetVertex(verts[3]))[d];
167 Mesh local_mesh(2,4,1,0,3);
184 for (
int ip = 0; ip < FaceRule.
GetNPoints(); ip++)
200 for (
int ip = 0; ip < FaceRule.
GetNPoints(); ip++)
235 ip2.
x = (ip1.
x + ip0.
x) / 2.;
325 bool element_int =
false;
326 bool interior =
true;
337 for (
int edge = 0; edge < me->
GetNEdges(); edge++)
339 enum class Layout {inside, intersected, outside};
352 edgelength(edge) = edgevec.
Norml2();
368 layout = Layout::inside;
373 layout = Layout::intersected;
378 layout = Layout::intersected;
386 layout = Layout::outside;
390 if (layout == Layout::intersected)
421 PointA.
SetRow(edge, pointA);
422 PointB.
SetRow(edge, pointB);
424 if ((layout == Layout::inside || layout == Layout::intersected))
435 for (
int edge = 0; edge < me->
GetNEdges(); edge++)
437 if (edge_int[edge] && !interior)
441 PointA.
GetRow(edge, point0);
442 PointB.
GetRow(edge, point1);
451 if (edge == 0 || edge == 2)
455 if (edge == 1 || edge == 3)
459 if (edge == 0 || edge == 3)
464 for (
int ip = 0; ip < ir2->
GetNPoints(); ip++)
482 for (
int dof = 0; dof <
nBasis; dof++)
486 * dist.
Norml2() / edgelength(edge);
493 if (element_int && !interior)
514 for (
int dof = 0; dof < fe->
GetDof(); dof++)
516 dshape.
GetRow(dof, gradi);
517 gradi *= LevelSet(dofs[dof]);
520 normal *= (-1. / normal.
Norml2());
525 for (
int dof = 0; dof <
nBasis; dof++)
529 Mat(dof, ip) = (grad * normal);
540 for (
int i = 0; i <
nBasis; i++)
554 intp.
weight = ElemWeights(ip);
575 bool element_int =
false;
576 bool interior =
true;
587 for (
int edge = 0; edge < me->
GetNEdges(); edge++)
589 enum class Layout {inside, intersected, outside};
602 edgelength(edge) = edgevec.
Norml2();
618 layout = Layout::inside;
623 layout = Layout::intersected;
628 layout = Layout::intersected;
636 layout = Layout::outside;
639 if (layout == Layout::intersected)
671 PointA.
SetRow(edge, pointA);
672 PointB.
SetRow(edge, pointB);
674 if ((layout == Layout::inside || layout == Layout::intersected))
685 for (
int edge = 0; edge < me->
GetNEdges(); edge++)
687 if (edge_int[edge] && !interior)
691 PointA.
GetRow(edge, point0);
692 PointB.
GetRow(edge, point1);
700 if (edge == 0 || edge == 2)
704 if (edge == 1 || edge == 3)
708 if (edge == 0 || edge == 3)
713 for (
int ip = 0; ip < ir2->
GetNPoints(); ip++)
734 * dist.
Norml2() / edgelength(edge);
742 if (element_int && !interior)
757 for (
int ip = 0; ip < sir->
GetNPoints(); ip++)
763 for (
int dof = 0; dof < fe->
GetDof(); dof++)
765 dshape.
GetRow(dof, gradi);
766 gradi *= LevelSet(dofs[dof]);
769 normal *= (-1. / normal.
Norml2());
800 intp.
weight = ElemWeights(ip);
837 bool element_int =
false;
839 bool interior =
true;
844 for (
int face = 0; face < me->
GetNFaces(); face++)
895 if (face == 0 || face == 5)
899 if (face == 1 || face == 3)
903 if (face == 2 || face == 4)
907 if (face == 0 || face == 1 || face == 4)
921 for (
int dof = 0; dof <
nBasis; dof++)
925 RHS(dof) -= (grad * normal) *
FaceWeights(ip, faces[face]);
931 if (element_int && !interior)
953 for (
int dof = 0; dof < fe->
GetDof(); dof++)
955 dshape.
GetRow(dof, gradi);
956 gradi *= LevelSet(dofs[dof]);
959 normal *= (-1. / normal.
Norml2());
964 for (
int dof = 0; dof <
nBasis; dof++)
968 Mat(dof, ip) = (grad * normal);
979 for (
int i = 0; i <
nBasis; i++)
993 intp.
weight = ElemWeights(ip);
1019 bool element_int =
false;
1021 bool interior =
true;
1026 for (
int face = 0; face < me->
GetNFaces(); face++)
1078 if (face == 0 || face == 5)
1082 if (face == 1 || face == 3)
1086 if (face == 2 || face == 4)
1090 if (face == 0 || face == 1 || face == 4)
1108 RHS(dof) += (adiv * normal) *
FaceWeights(ip, faces[face]);
1115 if (element_int && !interior)
1131 for (
int ip = 0; ip < sir->
GetNPoints(); ip++)
1137 for (
int dof = 0; dof < fe->
GetDof(); dof++)
1139 dshape.
GetRow(dof, gradi);
1140 gradi *= LevelSet(dofs[dof]);
1143 normal *= (-1. / normal.
Norml2());
1151 shapes.
GetRow(dof, adiv);
1173 intp.
weight = ElemWeights(ip);
1198 X(0) = -1. + 2. * ip.
x;
1199 X(1) = -1. + 2. * ip.
y;
1201 for (
int c = 0; c <=
Order; c++)
1205 a(1) = pow(X(0), (
real_t)(c));
1209 b(0) = pow(X(1), (
real_t)(c));
1216 int count = 2 *
Order+ 2;
1217 for (
int c = 1; c <=
Order; c++)
1219 const int* factorial = poly.
Binom(c);
1220 for (
int expo = c; expo > 0; expo--)
1223 a(0) = (
real_t)(factorial[expo]) * pow(X(0), (
real_t)(expo))
1224 * pow(X(1), (
real_t)(c - expo));
1225 a(1) = -1. * (
real_t)(factorial[expo - 1])
1226 * pow(X(0), (
real_t)(expo - 1))
1227 * pow(X(1), (
real_t)(c - expo + 1));
1252 for (
int i = 0; i <
nBasis; i++)
1253 for (
int j = 0; j < 2; j++)
1255 shapeMFN(i, j,
p) = shapeN(i, j);
1260 for (
int count = 1; count <
nBasis; count++)
1262 mGSStep(shape, shapeMFN, count);
1270 X(0) = -1. + 2. * ip.
x;
1271 X(1) = -1. + 2. * ip.
y;
1272 X(2) = -1. + 2. * ip.
z;
1282 for (
int count = step; count < shape.
Height(); count++)
1287 for (
int ip = 0; ip < ir_->
GetNPoints(); ip++)
1292 shapeMFN(ip).GetRow(count,
u);
1293 shapeMFN(ip).GetRow(step - 1, v);
1299 real_t coeff = num / den;
1309 for (
int ip = 0; ip < ir_->
GetNPoints(); ip++)
1311 shapeMFN(ip).GetRow(step - 1,
s);
1312 shapeMFN(ip).GetRow(count,
t);
1315 shapeMFN(ip).SetRow(count,
t);
1325 X(0) = -1. + 2. * ip.
x;
1326 X(1) = -1. + 2. * ip.
y;
1329 for (
int c = 0; c <=
Order; c++)
1331 for (
int expo = 0; expo <= c; expo++)
1333 shape(count) = pow(X(0), (
real_t)(expo))
1334 * pow(X(1), (
real_t)(c - expo));
1346 X(0) = -1. + 2. * ip.
x;
1347 X(1) = -1. + 2. * ip.
y;
1350 for (
int c = 0; c <=
Order; c++)
1352 for (
int expo = 0; expo <= c; expo++)
1354 shape(count, 0) = .25 * pow(X(0), (
real_t)(expo + 1))
1355 * pow(X(1), (
real_t)(c - expo))
1357 shape(count, 1) = .25 * pow(X(0), (
real_t)(expo))
1358 * pow(X(1), (
real_t)(c - expo + 1))
1359 / (
real_t)(c - expo + 1);
1370 X(0) = -1. + 2. * ip.
x;
1371 X(1) = -1. + 2. * ip.
y;
1372 X(2) = -1. + 2. * ip.
z;
1375 for (
int c = 0; c <=
Order; c++)
1376 for (
int expo = 0; expo <= c; expo++)
1377 for (
int expo2 = 0; expo2 <= c - expo; expo2++)
1379 shape(count) = pow(X(0), (
real_t)(expo))
1380 * pow(X(1), (
real_t)(expo2))
1381 * pow(X(2), (
real_t)(c - expo - expo2));
1392 X(0) = -1. + 2. * ip.
x;
1393 X(1) = -1. + 2. * ip.
y;
1394 X(2) = -1. + 2. * ip.
z;
1397 for (
int c = 0; c <=
Order; c++)
1398 for (
int expo = 0; expo <= c; expo++)
1399 for (
int expo2 = 0; expo2 <= c - expo; expo2++)
1401 shape(count, 0) = pow(X(0), (
real_t)(expo + 1))
1402 * pow(X(1), (
real_t)(expo2))
1403 * pow(X(2), (
real_t)(c - expo - expo2))
1404 / (6. * (
real_t)(expo + 1));
1405 shape(count, 1) = pow(X(0), (
real_t)(expo))
1406 * pow(X(1), (
real_t)(expo2 + 1))
1407 * pow(X(2), (
real_t)(c - expo - expo2))
1408 / (6. * (
real_t)(expo2 + 1));;
1409 shape(count, 2) = pow(X(0), (
real_t)(expo))
1410 * pow(X(1), (
real_t)(expo2))
1411 * pow(X(2), (
real_t)(c - expo - expo2 + 1))
1412 / (6. * (
real_t)(c - expo + expo2 + 1));;
1549 bool computeweights =
false;
1550 for (
int ip = 0; ip < sir.
GetNPoints(); ip++)
1554 computeweights =
true;
1578 for (
int ip = 0; ip < sir.
GetNPoints(); ip++)
1586 for (
int dof = 0; dof < fe->
GetDof(); dof++)
1588 dshape.
GetRow(dof, gradi);
1589 gradi *= LevelSet(dofs[dof]);
1593 normal *= (-1. / normal.
Norml2());
1595 weights(ip) = normphys / normref;
void SetSize(int nsize)
Change the logical size of the array, keep existing entries.
int Size() const
Return the logical size of the array.
void DeleteAll()
Delete the whole array.
int Append(const T &el)
Append element 'el' to array, resize if necessary.
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.
virtual void SetLevelSetProjectionOrder(int order)
Coefficient * LvlSet
The zero level set of this Coefficient defines the cut surface.
int lsOrder
Space order for the LS projection.
int Order
Order of the IntegrationRule.
virtual void SetOrder(int order)
Change the order of the constructed IntegrationRule.
Class for Singular Value Decomposition of a DenseMatrix.
DenseMatrix & RightSingularvectors()
Return right singular vectors.
DenseMatrix & LeftSingularvectors()
Return left singular vectors.
real_t Singularvalue(int i)
Return specific singular value.
void Eval(DenseMatrix &M)
Evaluate the SVD.
Data type dense matrix using column-major storage.
void MultTranspose(const real_t *x, real_t *y) const
Multiply a vector with the transpose matrix.
void SetRow(int r, const real_t *row)
void SetSize(int s)
Change the size of the DenseMatrix to s x s.
void GetRow(int r, Vector &row) const
Rank 3 tensor (array of matrices)
Abstract data type element.
virtual MFEM_DEPRECATED int GetNFaces(int &nFaceVertices) const =0
virtual const int * GetFaceVertices(int fi) const =0
virtual int GetNEdges() const =0
virtual const int * GetEdgeVertices(int) const =0
Class FiniteElementSpace - responsible for providing FEM view of the mesh, mainly managing the set of...
DofTransformation * GetElementDofs(int elem, Array< int > &dofs) const
Returns indices of degrees of freedom of element 'elem'. The returned indices are offsets into an ldo...
virtual const FiniteElement * GetFE(int i) const
Returns pointer to the FiniteElement in the FiniteElementCollection associated with i'th element in t...
Abstract class for all finite elements.
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...
int GetDof() const
Returns the number of degrees of freedom in the finite element.
Class for grid function - Vector with associated FE space.
virtual void ProjectCoefficient(Coefficient &coeff)
Project coeff Coefficient to this GridFunction. The projection computation depends on the choice of t...
void GetGradient(ElementTransformation &tr, Vector &grad) const
Gradient of a scalar function at a quadrature point.
Arbitrary order H1-conforming (continuous) finite elements.
Class for integration point with weight.
Class for an integration rule - an Array of IntegrationPoint.
int GetOrder() const
Returns the order of the integration rule.
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.
Container class for integration rules.
const IntegrationRule & Get(int GeomType, int Order)
Returns an integration rule for given GeomType and Order.
virtual FaceElementTransformations * GetFaceElementTransformations(int FaceNo, int mask=31)
void GetElementVertices(int i, Array< int > &v) const
Returns the indices of the vertices of element i.
int AddQuad(int v1, int v2, int v3, int v4, int attr=1)
Adds a quadrilateral to the mesh given by 4 vertices v1 through v4.
const Element * GetElement(int i) const
Return pointer to the i'th element object.
int GetNFaces() const
Return the number of faces in a 3D mesh.
int AddVertex(real_t x, real_t y=0.0, real_t z=0.0)
void GetElementTransformation(int i, IsoparametricTransformation *ElTr) const
Builds the transformation defining the i-th element in ElTr. ElTr must be allocated in advance and wi...
void FinalizeQuadMesh(int generate_edges=0, int refine=0, bool fix_orientation=true)
Finalize the construction of a quadrilateral Mesh.
void GetElementFaces(int i, Array< int > &faces, Array< int > &ori) const
Return the indices and the orientations of all faces of element i.
int SpaceDimension() const
Dimension of the physical space containing the mesh.
void GetFaceVertices(int i, Array< int > &vert) const
Returns the indices of the vertices of face i.
const real_t * GetVertex(int i) const
Return pointer to vertex i's coordinates.
Class for subdomain IntegrationRules by means of moment-fitting.
void BasisAD2D(const IntegrationPoint &ip, DenseMatrix &shape)
Antiderivatives of the monomial basis on the element [-1,1]^2.
void mGSStep(DenseMatrix &shape, DenseTensor &shapeMFN, int step)
A step of the modified Gram-Schmidt algorithm.
void OrthoBasis3D(const IntegrationPoint &ip, DenseMatrix &shape)
A orthogonalized divergence free basis on the element [-1,1]^3.
Vector FaceWeightsComp
Indicates the already computed face IntegrationRules.
Array< IntegrationPoint > FaceIP
Array of face integration points.
int nBasis
Number of divergence-free basis functions for surface integration.
void ComputeSurfaceWeights2D(ElementTransformation &Tr)
Compute 2D quadrature weights.
void Init(int order, Coefficient &levelset, int lsO)
Initialize the MomentFittingIntRules.
void Basis2D(const IntegrationPoint &ip, Vector &shape)
Monomial basis on the element [-1,1]^2.
void InitSurface(int order, Coefficient &levelset, int lsO, ElementTransformation &Tr)
Initialization for surface IntegrationRule.
void InitVolume(int order, Coefficient &levelset, int lsO, ElementTransformation &Tr)
Initialization for volume IntegrationRule.
DenseMatrix FaceWeights
Column-wise Matrix for the face quadrature weights.
void ComputeSurfaceWeights1D(ElementTransformation &Tr)
Compute 1D quadrature weights.
void SetOrder(int order) override
Change the order of the constructed IntegrationRule.
int dim
Space Dimension of the element.
void OrthoBasis2D(const IntegrationPoint &ip, DenseMatrix &shape)
A orthogonalized divergence free basis on the element [-1,1]^2.
void ComputeVolumeWeights1D(ElementTransformation &Tr, const IntegrationRule *sir)
Compute the 1D quadrature weights.
void ComputeVolumeWeights2D(ElementTransformation &Tr, const IntegrationRule *sir)
Compute the 2D quadrature weights.
DenseMatrixSVD * VolumeSVD
SVD of the matrix for volumetric IntegrationRules.
void Basis3D(const IntegrationPoint &ip, Vector &shape)
Monomial basis on the element [-1,1]^3.
void ComputeFaceWeights(ElementTransformation &Tr)
Compute the IntegrationRules on the faces.
void GetSurfaceIntegrationRule(ElementTransformation &Tr, IntegrationRule &result) override
Construct a cut-surface IntegrationRule.
void GetSurfaceWeights(ElementTransformation &Tr, const IntegrationRule &sir, Vector &weights) override
Compute transformation quadrature weights for surface integration.
void ComputeSurfaceWeights3D(ElementTransformation &Tr)
Compute 2D quadrature weights.
void DivFreeBasis2D(const IntegrationPoint &ip, DenseMatrix &shape)
A divergence free basis on the element [-1,1]^2.
IntegrationRule ir
IntegrationRule representing the reused IntegrationPoints.
int nBasisVolume
Number of basis functions for volume integration.
void Clear()
Clear stored data of the MomentFittingIntRules.
void BasisAD3D(const IntegrationPoint &ip, DenseMatrix &shape)
Antiderivatives of the monomial basis on the element [-1,1]^3.
void GetVolumeIntegrationRule(ElementTransformation &Tr, IntegrationRule &result, const IntegrationRule *sir=nullptr) override
Construct a cut-volume IntegrationRule.
void ComputeVolumeWeights3D(ElementTransformation &Tr, const IntegrationRule *sir)
Compute the 3D quadrature weights.
int Height() const
Get the height (size of output) of the Operator. Synonym with NumRows().
Class for computing 1D special polynomials and their associated basis functions.
static const int * Binom(const int p)
Get a pointer to an array containing the binomial coefficients "pchoose k" for k=0,...
real_t Norml2() const
Returns the l2 norm of the vector.
int Size() const
Returns the size of the vector.
void SetSize(int s)
Resize the vector to size s.
void GetDivFree3DBasis(const Vector &X, DenseMatrix &shape, int Order)
3 dimensional divergence free basis functions on [-1,1]^3
real_t u(const Vector &xvec)
void subtract(const Vector &x, const Vector &y, Vector &z)
IntegrationRules IntRules(0, Quadrature1D::GaussLegendre)
A global object with all integration rules (defined in intrules.cpp)
real_t p(const Vector &x, real_t t)