www.mooseframework.org
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
XFEMCutElem Class Referenceabstract

#include <XFEMCutElem.h>

Inheritance diagram for XFEMCutElem:
[legend]

Public Member Functions

 XFEMCutElem (Elem *elem, unsigned int n_qpoints, unsigned int n_sides)
 Constructor initializes XFEMCutElem object. More...
 
virtual ~XFEMCutElem ()
 
void setQuadraturePointsAndWeights (const std::vector< Point > &qp_points, const std::vector< Real > &qp_weights)
 
virtual void computePhysicalVolumeFraction ()=0
 Computes the volume fraction of the element fragment. More...
 
Real getPhysicalVolumeFraction () const
 Returns the volume fraction of the element fragment. More...
 
virtual void computePhysicalFaceAreaFraction (unsigned int side)=0
 Computes the surface area fraction of the element side. More...
 
Real getPhysicalFaceAreaFraction (unsigned int side) const
 Returns the surface area fraction of the element side. More...
 
virtual void computeMomentFittingWeights ()=0
 
Real getMomentFittingWeight (unsigned int i_qp) const
 
virtual Point getCutPlaneOrigin (unsigned int plane_id, MeshBase *displaced_mesh=nullptr) const =0
 
virtual Point getCutPlaneNormal (unsigned int plane_id, MeshBase *displaced_mesh=nullptr) const =0
 
virtual void getCrackTipOriginAndDirection (unsigned tip_id, Point &origin, Point &direction) const =0
 
virtual void getFragmentFaces (std::vector< std::vector< Point >> &frag_faces, MeshBase *displaced_mesh=nullptr) const =0
 
virtual const EFAElementgetEFAElement () const =0
 
virtual unsigned int numCutPlanes () const =0
 
void getWeightMultipliers (MooseArray< Real > &weights, QBase *qrule, Xfem::XFEM_QRULE xfem_qrule, const MooseArray< Point > &q_points)
 
void getFaceWeightMultipliers (MooseArray< Real > &face_weights, QBase *qrule, Xfem::XFEM_QRULE xfem_qrule, const MooseArray< Point > &q_points, unsigned int side)
 
void computeXFEMWeights (QBase *qrule, Xfem::XFEM_QRULE xfem_qrule, const MooseArray< Point > &q_points)
 Computes integration weights for the cut element. More...
 
void computeXFEMFaceWeights (QBase *qrule, Xfem::XFEM_QRULE xfem_qrule, const MooseArray< Point > &q_points, unsigned int side)
 Computes face integration weights for the cut element side. More...
 
bool isPointPhysical (const Point &p) const
 
virtual void getIntersectionInfo (unsigned int plane_id, Point &normal, std::vector< Point > &intersectionPoints, MeshBase *displaced_mesh=nullptr) const =0
 

Protected Member Functions

virtual Point getNodeCoordinates (EFANode *node, MeshBase *displaced_mesh=nullptr) const =0
 

Protected Attributes

unsigned int _n_nodes
 
unsigned int _n_qpoints
 
unsigned int _n_sides
 
std::vector< Node * > _nodes
 
std::vector< Point_qp_points
 
std::vector< Real_qp_weights
 
Real _elem_volume
 
std::vector< Real_elem_side_area
 
Real _physical_volfrac
 
std::vector< Real_physical_areafrac
 
bool _have_weights
 
std::vector< bool > _have_face_weights
 
std::vector< Real_new_weights
 quadrature weights from volume fraction and moment fitting More...
 
std::vector< std::vector< Real > > _new_face_weights
 face quadrature weights from surface area fraction More...
 

Detailed Description

Definition at line 29 of file XFEMCutElem.h.

Constructor & Destructor Documentation

◆ XFEMCutElem()

XFEMCutElem::XFEMCutElem ( Elem *  elem,
unsigned int  n_qpoints,
unsigned int  n_sides 
)

Constructor initializes XFEMCutElem object.

Parameters
elemThe element on which XFEMCutElem is built
n_qpointsThe number of quadrature points
n_sidesThe number of sides which the element has

Definition at line 22 of file XFEMCutElem.C.

23  : _n_nodes(elem->n_nodes()),
24  _n_qpoints(n_qpoints),
25  _n_sides(n_sides),
26  _nodes(_n_nodes, nullptr),
27  _elem_side_area(n_sides),
28  _physical_areafrac(n_sides),
29  _have_weights(false),
30  _have_face_weights(n_sides),
31  _new_face_weights(n_sides)
32 {
33  for (unsigned int i = 0; i < _n_nodes; ++i)
34  _nodes[i] = elem->node_ptr(i);
35 
36  for (unsigned int i = 0; i < _n_sides; ++i)
37  {
38  _have_face_weights[i] = false;
39  _physical_areafrac[i] = 1.0;
40  // TODO: this line does not support RZ/RSpherical geoms
41  _elem_side_area[i] = elem->side_ptr(i)->volume();
42  }
43 
44  // TODO: this line does not support RZ/RSpherical geoms
45  _elem_volume = elem->volume();
46 }
std::vector< Real > _elem_side_area
Definition: XFEMCutElem.h:49
std::vector< std::vector< Real > > _new_face_weights
face quadrature weights from surface area fraction
Definition: XFEMCutElem.h:57
std::vector< bool > _have_face_weights
Definition: XFEMCutElem.h:53
unsigned int _n_sides
Definition: XFEMCutElem.h:44
unsigned int _n_qpoints
Definition: XFEMCutElem.h:43
bool _have_weights
Definition: XFEMCutElem.h:52
unsigned int _n_nodes
Definition: XFEMCutElem.h:42
std::vector< Node * > _nodes
Definition: XFEMCutElem.h:45
Real _elem_volume
Definition: XFEMCutElem.h:48
std::vector< Real > _physical_areafrac
Definition: XFEMCutElem.h:51

◆ ~XFEMCutElem()

XFEMCutElem::~XFEMCutElem ( )
virtual

Definition at line 48 of file XFEMCutElem.C.

48 {}

Member Function Documentation

◆ computeMomentFittingWeights()

virtual void XFEMCutElem::computeMomentFittingWeights ( )
pure virtual

Implemented in XFEMCutElem2D, and XFEMCutElem3D.

Referenced by computeXFEMWeights().

◆ computePhysicalFaceAreaFraction()

virtual void XFEMCutElem::computePhysicalFaceAreaFraction ( unsigned int  side)
pure virtual

Computes the surface area fraction of the element side.

Parameters
sideThe side of the element

Implemented in XFEMCutElem2D, and XFEMCutElem3D.

Referenced by computeXFEMFaceWeights().

◆ computePhysicalVolumeFraction()

virtual void XFEMCutElem::computePhysicalVolumeFraction ( )
pure virtual

Computes the volume fraction of the element fragment.

Implemented in XFEMCutElem2D, and XFEMCutElem3D.

Referenced by computeXFEMWeights(), and XFEM::getPhysicalVolumeFraction().

◆ computeXFEMFaceWeights()

void XFEMCutElem::computeXFEMFaceWeights ( QBase *  qrule,
Xfem::XFEM_QRULE  xfem_qrule,
const MooseArray< Point > &  q_points,
unsigned int  side 
)

Computes face integration weights for the cut element side.

Parameters
qruleThe standard MOOSE face quadrature rule
xfem_qruleThe integration scheme for the cut element (We use surface area fraction only)
q_pointsThe quadrature points for the element side
sideThe side of the element

Definition at line 92 of file XFEMCutElem.C.

Referenced by getFaceWeightMultipliers().

96 {
97  _new_face_weights[side].clear();
98  _new_face_weights[side].resize(qrule->n_points(), 1.0);
99 
101  Real surffrac = getPhysicalFaceAreaFraction(side);
102  for (unsigned qp = 0; qp < qrule->n_points(); ++qp)
103  _new_face_weights[side][qp] = surffrac;
104 
105  _have_face_weights[side] = true;
106 }
std::vector< std::vector< Real > > _new_face_weights
face quadrature weights from surface area fraction
Definition: XFEMCutElem.h:57
std::vector< bool > _have_face_weights
Definition: XFEMCutElem.h:53
virtual void computePhysicalFaceAreaFraction(unsigned int side)=0
Computes the surface area fraction of the element side.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
Real getPhysicalFaceAreaFraction(unsigned int side) const
Returns the surface area fraction of the element side.
Definition: XFEMCutElem.C:57

◆ computeXFEMWeights()

void XFEMCutElem::computeXFEMWeights ( QBase *  qrule,
Xfem::XFEM_QRULE  xfem_qrule,
const MooseArray< Point > &  q_points 
)

Computes integration weights for the cut element.

Parameters
qruleThe standard MOOSE quadrature rule
xfem_qruleThe integration scheme for the cut element
q_pointsThe quadrature points for the element

Definition at line 109 of file XFEMCutElem.C.

Referenced by getWeightMultipliers().

112 {
113  _new_weights.clear();
114 
115  _new_weights.resize(qrule->n_points(), 1.0);
116 
117  switch (xfem_qrule)
118  {
119  case Xfem::VOLFRAC:
120  {
122  Real volfrac = getPhysicalVolumeFraction();
123  for (unsigned qp = 0; qp < qrule->n_points(); ++qp)
124  _new_weights[qp] = volfrac;
125  break;
126  }
128  {
129  // These are the coordinates in parametric coordinates
130  _qp_points = qrule->get_points();
131  _qp_weights = qrule->get_weights();
132 
134 
135  // Blend weights from moment fitting and volume fraction to avoid negative weights
136  Real alpha = 1.0;
137  if (*std::min_element(_new_weights.begin(), _new_weights.end()) < 0.0)
138  {
139  // One or more of the weights computed by moment fitting is negative.
140  // Blend moment and volume fraction weights to keep them nonnegative.
141  // Find the largest value of alpha that will keep all of the weights nonnegative.
142  for (unsigned int i = 0; i < _n_qpoints; ++i)
143  {
144  const Real denominator = _physical_volfrac - _new_weights[i];
145  if (denominator > 0.0) // Negative values would give a negative value for alpha, which
146  // must be between 0 and 1.
147  {
148  const Real alpha_i = _physical_volfrac / denominator;
149  if (alpha_i < alpha)
150  alpha = alpha_i;
151  }
152  }
153  for (unsigned int i = 0; i < _n_qpoints; ++i)
154  {
155  _new_weights[i] = alpha * _new_weights[i] + (1.0 - alpha) * _physical_volfrac;
156  if (_new_weights[i] < 0.0) // We can end up with small (roundoff) negative weights
157  _new_weights[i] = 0.0;
158  }
159  }
160  break;
161  }
162  case Xfem::DIRECT: // remove q-points outside the partial element's physical domain
163  {
164  bool nonzero = false;
165  for (unsigned qp = 0; qp < qrule->n_points(); ++qp)
166  {
167  // q_points contains quadrature point locations in physical coordinates
168  if (isPointPhysical(q_points[qp]))
169  {
170  nonzero = true;
171  _new_weights[qp] = 1.0;
172  }
173  else
174  _new_weights[qp] = 0.0;
175  }
176  if (!nonzero)
177  {
178  // Set the weights to a small value (1e-3) to avoid having DOFs
179  // with zeros on the diagonal, which occurs for nodes that are
180  // connected to no physical material.
181  for (unsigned qp = 0; qp < qrule->n_points(); ++qp)
182  _new_weights[qp] = 1e-3;
183  }
184  break;
185  }
186  default:
187  mooseError("Undefined option for XFEM_QRULE");
188  }
189  _have_weights = true;
190 }
unsigned int _n_qpoints
Definition: XFEMCutElem.h:43
void mooseError(Args &&... args)
std::vector< Point > _qp_points
Definition: XFEMCutElem.h:46
Real getPhysicalVolumeFraction() const
Returns the volume fraction of the element fragment.
Definition: XFEMCutElem.C:51
Real _physical_volfrac
Definition: XFEMCutElem.h:50
std::vector< Real > _qp_weights
Definition: XFEMCutElem.h:47
std::vector< Real > _new_weights
quadrature weights from volume fraction and moment fitting
Definition: XFEMCutElem.h:55
bool _have_weights
Definition: XFEMCutElem.h:52
virtual void computePhysicalVolumeFraction()=0
Computes the volume fraction of the element fragment.
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
static const std::string alpha
Definition: NS.h:126
virtual void computeMomentFittingWeights()=0
bool isPointPhysical(const Point &p) const
Definition: XFEMCutElem.C:193

◆ getCrackTipOriginAndDirection()

virtual void XFEMCutElem::getCrackTipOriginAndDirection ( unsigned  tip_id,
Point origin,
Point direction 
) const
pure virtual

◆ getCutPlaneNormal()

virtual Point XFEMCutElem::getCutPlaneNormal ( unsigned int  plane_id,
MeshBase displaced_mesh = nullptr 
) const
pure virtual

Implemented in XFEMCutElem2D, and XFEMCutElem3D.

Referenced by XFEM::getCutPlane(), and isPointPhysical().

◆ getCutPlaneOrigin()

virtual Point XFEMCutElem::getCutPlaneOrigin ( unsigned int  plane_id,
MeshBase displaced_mesh = nullptr 
) const
pure virtual

Implemented in XFEMCutElem2D, and XFEMCutElem3D.

Referenced by XFEM::getCutPlane(), and isPointPhysical().

◆ getEFAElement()

virtual const EFAElement* XFEMCutElem::getEFAElement ( ) const
pure virtual

◆ getFaceWeightMultipliers()

void XFEMCutElem::getFaceWeightMultipliers ( MooseArray< Real > &  face_weights,
QBase *  qrule,
Xfem::XFEM_QRULE  xfem_qrule,
const MooseArray< Point > &  q_points,
unsigned int  side 
)

Definition at line 77 of file XFEMCutElem.C.

Referenced by XFEM::getXFEMFaceWeights().

82 {
83  if (!_have_face_weights[side])
84  computeXFEMFaceWeights(qrule, xfem_qrule, q_points, side);
85 
86  face_weights.resize(_new_face_weights[side].size());
87  for (unsigned int qp = 0; qp < _new_face_weights[side].size(); ++qp)
88  face_weights[qp] = _new_face_weights[side][qp];
89 }
std::vector< std::vector< Real > > _new_face_weights
face quadrature weights from surface area fraction
Definition: XFEMCutElem.h:57
std::vector< bool > _have_face_weights
Definition: XFEMCutElem.h:53
void computeXFEMFaceWeights(QBase *qrule, Xfem::XFEM_QRULE xfem_qrule, const MooseArray< Point > &q_points, unsigned int side)
Computes face integration weights for the cut element side.
Definition: XFEMCutElem.C:92
void resize(unsigned int size)

◆ getFragmentFaces()

virtual void XFEMCutElem::getFragmentFaces ( std::vector< std::vector< Point >> &  frag_faces,
MeshBase displaced_mesh = nullptr 
) const
pure virtual

Implemented in XFEMCutElem2D, and XFEMCutElem3D.

Referenced by XFEM::getFragmentFaces().

◆ getIntersectionInfo()

virtual void XFEMCutElem::getIntersectionInfo ( unsigned int  plane_id,
Point normal,
std::vector< Point > &  intersectionPoints,
MeshBase displaced_mesh = nullptr 
) const
pure virtual

Implemented in XFEMCutElem2D, and XFEMCutElem3D.

Referenced by XFEM::getXFEMIntersectionInfo().

◆ getMomentFittingWeight()

Real XFEMCutElem::getMomentFittingWeight ( unsigned int  i_qp) const

◆ getNodeCoordinates()

virtual Point XFEMCutElem::getNodeCoordinates ( EFANode node,
MeshBase displaced_mesh = nullptr 
) const
protectedpure virtual

Implemented in XFEMCutElem2D, and XFEMCutElem3D.

◆ getPhysicalFaceAreaFraction()

Real XFEMCutElem::getPhysicalFaceAreaFraction ( unsigned int  side) const

Returns the surface area fraction of the element side.

Parameters
sideThe side of the element

Definition at line 57 of file XFEMCutElem.C.

Referenced by computeXFEMFaceWeights().

58 {
59  return _physical_areafrac[side];
60 }
std::vector< Real > _physical_areafrac
Definition: XFEMCutElem.h:51

◆ getPhysicalVolumeFraction()

Real XFEMCutElem::getPhysicalVolumeFraction ( ) const

Returns the volume fraction of the element fragment.

Definition at line 51 of file XFEMCutElem.C.

Referenced by computeXFEMWeights(), and XFEM::getPhysicalVolumeFraction().

52 {
53  return _physical_volfrac;
54 }
Real _physical_volfrac
Definition: XFEMCutElem.h:50

◆ getWeightMultipliers()

void XFEMCutElem::getWeightMultipliers ( MooseArray< Real > &  weights,
QBase *  qrule,
Xfem::XFEM_QRULE  xfem_qrule,
const MooseArray< Point > &  q_points 
)

Definition at line 63 of file XFEMCutElem.C.

Referenced by XFEM::getXFEMWeights().

67 {
68  if (!_have_weights)
69  computeXFEMWeights(qrule, xfem_qrule, q_points);
70 
71  weights.resize(_new_weights.size());
72  for (unsigned int qp = 0; qp < _new_weights.size(); ++qp)
73  weights[qp] = _new_weights[qp];
74 }
std::vector< Real > _new_weights
quadrature weights from volume fraction and moment fitting
Definition: XFEMCutElem.h:55
bool _have_weights
Definition: XFEMCutElem.h:52
void computeXFEMWeights(QBase *qrule, Xfem::XFEM_QRULE xfem_qrule, const MooseArray< Point > &q_points)
Computes integration weights for the cut element.
Definition: XFEMCutElem.C:109
void resize(unsigned int size)

◆ isPointPhysical()

bool XFEMCutElem::isPointPhysical ( const Point &  p) const

Definition at line 193 of file XFEMCutElem.C.

Referenced by computeXFEMWeights(), XFEM::healMesh(), and XFEM::isPointInsidePhysicalDomain().

194 {
195  // determine whether the point is inside the physical domain of a partial element
196  bool physical_flag = true;
197  unsigned int n_cut_planes = numCutPlanes();
198  for (unsigned int plane_id = 0; plane_id < n_cut_planes; ++plane_id)
199  {
200  Point origin = getCutPlaneOrigin(plane_id);
201  Point normal = getCutPlaneNormal(plane_id);
202  Point origin2qp = p - origin;
203  if (origin2qp * normal > 0.0)
204  {
205  physical_flag = false; // Point outside pysical domain
206  break;
207  }
208  }
209  return physical_flag;
210 }
virtual unsigned int numCutPlanes() const =0
virtual Point getCutPlaneOrigin(unsigned int plane_id, MeshBase *displaced_mesh=nullptr) const =0
virtual Point getCutPlaneNormal(unsigned int plane_id, MeshBase *displaced_mesh=nullptr) const =0

◆ numCutPlanes()

virtual unsigned int XFEMCutElem::numCutPlanes ( ) const
pure virtual

Implemented in XFEMCutElem2D, and XFEMCutElem3D.

Referenced by isPointPhysical().

◆ setQuadraturePointsAndWeights()

void XFEMCutElem::setQuadraturePointsAndWeights ( const std::vector< Point > &  qp_points,
const std::vector< Real > &  qp_weights 
)

Member Data Documentation

◆ _elem_side_area

std::vector<Real> XFEMCutElem::_elem_side_area
protected

◆ _elem_volume

Real XFEMCutElem::_elem_volume
protected

◆ _have_face_weights

std::vector<bool> XFEMCutElem::_have_face_weights
protected

Definition at line 53 of file XFEMCutElem.h.

Referenced by computeXFEMFaceWeights(), getFaceWeightMultipliers(), and XFEMCutElem().

◆ _have_weights

bool XFEMCutElem::_have_weights
protected

Definition at line 52 of file XFEMCutElem.h.

Referenced by computeXFEMWeights(), and getWeightMultipliers().

◆ _n_nodes

unsigned int XFEMCutElem::_n_nodes
protected

Definition at line 42 of file XFEMCutElem.h.

Referenced by XFEMCutElem2D::computeMomentFittingWeights(), and XFEMCutElem().

◆ _n_qpoints

unsigned int XFEMCutElem::_n_qpoints
protected

◆ _n_sides

unsigned int XFEMCutElem::_n_sides
protected

Definition at line 44 of file XFEMCutElem.h.

Referenced by XFEMCutElem().

◆ _new_face_weights

std::vector<std::vector<Real> > XFEMCutElem::_new_face_weights
protected

face quadrature weights from surface area fraction

Definition at line 57 of file XFEMCutElem.h.

Referenced by computeXFEMFaceWeights(), and getFaceWeightMultipliers().

◆ _new_weights

std::vector<Real> XFEMCutElem::_new_weights
protected

quadrature weights from volume fraction and moment fitting

Definition at line 55 of file XFEMCutElem.h.

Referenced by XFEMCutElem2D::computeMomentFittingWeights(), XFEMCutElem3D::computeMomentFittingWeights(), computeXFEMWeights(), and getWeightMultipliers().

◆ _nodes

std::vector<Node *> XFEMCutElem::_nodes
protected

◆ _physical_areafrac

std::vector<Real> XFEMCutElem::_physical_areafrac
protected

◆ _physical_volfrac

Real XFEMCutElem::_physical_volfrac
protected

◆ _qp_points

std::vector<Point> XFEMCutElem::_qp_points
protected

Definition at line 46 of file XFEMCutElem.h.

Referenced by computeXFEMWeights(), and XFEMCutElem2D::solveMomentFitting().

◆ _qp_weights

std::vector<Real> XFEMCutElem::_qp_weights
protected

Definition at line 47 of file XFEMCutElem.h.

Referenced by computeXFEMWeights(), and XFEMCutElem2D::solveMomentFitting().


The documentation for this class was generated from the following files: