Xfem
The Xfem Plugin
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
XfemMeshCopier Class Reference

Basic class for copying an XFEM mesh into an empty element mesh, transforming sub-elements into elements. More...

#include <xfemMeshCopier.h>

Collaboration diagram for XfemMeshCopier:
Collaboration graph
[legend]

Classes

struct  NewNodesData
 Aux structure to store coordinates for newly created nodes. More...
 
struct  SplitEdgeData
 Type storing data for an edge incident to a node 'n'. More...
 
struct  SplitNodeData
 Type storing per node data for the splitting operation. More...
 
struct  SubElementNodeData
 Aux structure to store a node list for each sub-element in the mesh. More...
 

Public Member Functions

 XfemMeshCopier (const XfemMesh *srcMesh, GmElementMesh *newMesh, XfemSolver *solver, const GmLogCategory &logger)
 Creates the mesh copier object. Copies will be made with calls to copy(). More...
 
virtual ~XfemMeshCopier ()
 Destructor.
 
bool copy (bool splitFractures)
 Overload of XfemMeshCopier::copy(const QStringList&, const QStringList&, bool) passing as first and second parameters lists filled with every node/cell attribute in the destination mesh.
 
bool copy (const QStringList &nodeAttributes, const QStringList &elementAttributes, bool createMissingAttributes, bool splitFractures)
 Given a src mesh and an an empty element mesh, passed as parameters to the object constructor, fills the empty mesh with a copy of the source mesh where all enriched sub-elements have been transformed into elements. More...
 

Private Types

typedef QPair< int, int > SubElementId
 Type storing an element Id + sub-element Id (or -1 for a whole element reference)
 
typedef QPair< const XfemFracture *, int > FractureEdgeId
 Type stroring a reference for a fracture segment.
 

Private Member Functions

bool copyAux (const QStringList &nodeAttributes, const QStringList &elementAttributes, bool createMissingAttributes, bool splitFractures)
 Helper function for copy() to allow for easier mesh cleanup on errors. More...
 
bool setupAccessors (const QStringList &nodeAttributes, const QStringList &elementAttributes, bool createMissingAttributes)
 Grab needed accessors, filling the object accessor lists (_nodeAcList, newNodeAcList, ...) and coordinate accessors (_ccordAc and _newCoordAc). Returns true on success, false on errors. More...
 
bool setupNodeAccessors (const QStringList &nodeAttributes, bool createMissingAttributes)
 Aux function to setupAccessors to grab/create if needed node data accessors.
 
bool setupElementAccessors (const QStringList &elementAttributes, bool createMissingAttributes)
 Aux function to setupAccessors to grab/create if needed node data caessors.
 
bool setupEnrichedAccessors ()
 Setup enriched data acessors corresponding to node accessors.
 
bool setupPropertyMap (QList< int > &psIndex)
 Setup psIndex, an index storing for each property set in the destination mesh its index in the source mesh.
 
bool buildSubElementNodeLists (QList< SubElementNodeData > &nodeDataList, QList< NewNodesData > &newNodesList)
 Traverses sub-elements building a list with its nodes + any needed new nodes.
 
bool setNodeData (const QList< NewNodesData > &newNodesList, bool updateGhostNodes)
 Copy node coordinates & values from one mesh to the other. It also initializes values for newlly created nodes.
 
bool setElementData (const QList< SubElementNodeData > &nodeDataList, const QList< int > &psIndex, const int *typeIndexMap)
 Copy node coordinates & values from one mesh to the other. It also initializes values for newlly created nodes. More...
 
bool splitMesh (const int *typeIndexMap)
 Splits the destination mesh along fractures. More...
 
void fillSplitInfoMaps (const int *typeIndexMap, QMap< int, SplitNodeData > &nodeInfo, QMap< SubElementId, int > &elementTranslationMap) const
 Build info maps described in steps 1 & 2 for the splitMesh() function.
 
void fillEdgeList (int node, const QList< SubElementId > &elements, const QList< FractureEdgeId > &fractures, const QMap< SubElementId, int > &elementTranslationMap, QList< SplitEdgeData > &edges) const
 Builds the list of incident edges to the given node, filling 'edges'. More...
 
int sortEdgeList (int node, QList< SplitEdgeData > &edges, int *lastEdge) const
 Sorts the edge list according to CCW angles between adges and the first list fracture. Returns the number of fractures in the edge list. If the edge set has only one fracture, returns in the lastEdge parameter the index of the last edge to fall in the interval between the first fracture and the 180 dgerees angle. If the edge set has several fractures, lastEdge is left unchanged.
 
void replaceElementNode (int node, int newNode, const QList< int > &elements)
 Replaces node by newNode in the mesh node list of the given elements.
 
void addEdgeInfo (int node, int srcNode, bool incoming, int elemIndex, const QList< FractureEdgeId > &fractures, QList< SplitEdgeData > &edges) const
 Aux function to add a new edge or update an exsting edge in the 'edges' list.
 
void addNodeInfo (QMap< int, SplitNodeData > &nodeInfo, QMap< SubElementId, int > &elementTranslationMap, const XfemFracture *f, int fractureSegment, const XfemElement *e, int node, int nodeEdge) const
 Aux function used by fillSplitInfoMaps() to add information about a node in a fracture segment to the info maps.
 
const XfemElementsegmentInfo (const XfemFracture *f, int segment, int *n1, int *n2, int *e1=NULL, int *e2=NULL) const
 Returns element, first node and second node information about the given fracture segment.
 
void updateNodeAttributes (int srcNode, int newNode, const FractureEdgeId &fracture, const SubElementId *nodeElement, const SubElementId *otherElement)
 Calculates and fills all node values associated with the given newNode. More...
 
void interpolateSplittedNodeValue (GmValueAccessor *ac, QList< GmValueAccessor * > eacList, int srcNode, int newNode, const FractureEdgeId &fracture, const SubElementId *nodeElement, const SubElementId *otherElement, GmVector &result) const
 Calculates and fills all node values associated with the given newNode. More...
 
void interpolateInternalNodeValue (const XfemElement *e, GmValueAccessor *ac, QList< GmValueAccessor * > eacList, const GmVector &naturalCoord, GmVector &result) const
 Fills result with the interpolated value for the ac attribute on the given new splitted node. More...
 
void polygonCentroid (GmMatrix polygonCoords, GmVector &Xcg) const
 
void fillNodalLevelSetMatrix (GmMatrix X, GmMatrix Xg, GmMatrix &H) const
 Compute levelset function (H) The minimum distance between a point(nodes or integration point) and a segment (fracture) is determined. This function returns the signed distance function used to enrich the element for XFEM. More...
 
void fillGaussLevelSetMatrix (GmMatrix X, GmMatrix Xg, GmMatrix &H) const
 Compute levelset function (H) The minimum distance between a point(nodes or integration point) and a segment (fracture) is determined. This function returns the signed distance function used to enrich the element for XFEM. More...
 
void fillInteractingCraksNodalLevelSets (const XfemElement *e, XfemEnrichedElementData *exData, int nEnrich, int nCracks, QList< double >crackIndex, QList< GmMatrix > &nodalLevelSet) const
 computation of Additional enrichment fuctions for cracks intersection considering element nodes and integration point
 
void fillInteractingCraksGaussLevelSets (const XfemElement *e, XfemEnrichedElementData *exData, int nEnrich, int nCracks, QList< double >crackIndex, QList< GmMatrix > &gaussLevelSet) const
 computation of Additional enrichment fuctions for cracks intersection considering element nodes and integration point
 

Private Attributes

const XfemMesh_srcMesh
 The source mesh storing the elements to be copied.
 
GmElementMesh_newMesh
 The empty destination mesh.
 
XfemSolver_solver
 The xfem solver, needed for interpolations.
 
const GmLogCategory_logger
 The logger used to produce error messages.
 
QList< GmValueAccessor * > _nodeAcList
 The set of node accessors in the source mesh.
 
QList< QList< GmValueAccessor * > > _enrichedAcList
 The set of corresponding enriched node accessors for each entrie in _nodeAcList (or NULL)
 
QList< GmValueAccessor * > _newNodeAcList
 The set of node accessors in the destination mesh.
 
QList< GmCellAccessor * > _cellAcList
 The set of cell accessors in the source mesh.
 
QList< GmCellAccessor * > _newCellAcList
 The set of cell accessors in the destination mesh.
 
QList< GmGaussAccessor * > _gaussAcList
 The set of Gauss accessors in the source mesh.
 
QList< GmGaussAccessor * > _newGaussAcList
 The set of Gauss accessors in the destination mesh.
 
GmValueAccessor_coordAc
 The accessor used to get node coordinates in the source mesh.
 
GmValueAccessor_newCoordAc
 The accessor used to get node coordinates in the destination mesh.
 

Detailed Description

Basic class for copying an XFEM mesh into an empty element mesh, transforming sub-elements into elements.

Constructor & Destructor Documentation

◆ XfemMeshCopier()

XfemMeshCopier::XfemMeshCopier ( const XfemMesh srcMesh,
GmElementMesh newMesh,
XfemSolver solver,
const GmLogCategory logger 
)

Creates the mesh copier object. Copies will be made with calls to copy().

The destination, empty, mesh should have no nodes or cells, but it should already be filled with its basic stucture, i.e, node dimension, attributes, property sets, etc.

Parameters
srcMeshThe mesh storing the elements/values that will be copied to the destination mesh
newMeshThe empty mesh to be filled. Its implementation type should support adding nodes and cells.
solverThe xfem solver used for interpolations. Can be NULL. in which case interpolations will not consider enrichments.
loggerThe logger used to emit error messages / warnings

Member Function Documentation

◆ copy()

bool XfemMeshCopier::copy ( const QStringList nodeAttributes,
const QStringList elementAttributes,
bool  createMissingAttributes,
bool  splitFractures 
)

Given a src mesh and an an empty element mesh, passed as parameters to the object constructor, fills the empty mesh with a copy of the source mesh where all enriched sub-elements have been transformed into elements.

The destination, empty, mesh should have no nodes or cells, but it should already be filled with its basic stucture, i.e, node dimension, attributes, property sets, etc.

The new mesh will have all nodes marked as geometry nodes, and no ghost nodes.

Data values are copied according to the attribute sets passed on nodeAttributes and elementAttributes. For enriched Gauss attributes, the integration rule used by each sub-element must match the integration rule for the sub-element type on the destination empty mesh. Src mesh and destination mesh attributes can have different units provided that they are compatible.

Parameters
nodeAttributesA list with state vars / node attribute names whose values should be copied from the current mesh to the destination mesh.
elementAttributesA list with cell / gauss attribute names whose values should be copied from the current mesh to the destination mesh.
createMissingAttributesWhen set to true, if an attribute in nodeAttributes or in elementAttributes exists in the source mesh but not in the destination mesh, a new attribute will be created.
splitFracturesIf set to true, the mesh will be splitted along fractures so that elements that are separated by a fracture edge do not share the same nodes.

◆ copyAux()

bool XfemMeshCopier::copyAux ( const QStringList nodeAttributes,
const QStringList elementAttributes,
bool  createMissingAttributes,
bool  splitFractures 
)
private

Helper function for copy() to allow for easier mesh cleanup on errors.

< An index storing for each property set in the destination mesh its index in the source mesh

◆ fillEdgeList()

void XfemMeshCopier::fillEdgeList ( int  node,
const QList< SubElementId > &  elements,
const QList< FractureEdgeId > &  fractures,
const QMap< SubElementId, int > &  elementTranslationMap,
QList< SplitEdgeData > &  edges 
) const
private

Builds the list of incident edges to the given node, filling 'edges'.

Finds all the edges that are incident to 'node'. An edge is represented by a structure that stores the src node and the elements that share that edge (1 or 2), with the element that has an 'incoming' half-edge first and 'outcoming' second (the incoming half-edge will be the edge where the src node comes before 'nn' in the element when traversed in CCW mode). It also stores an index to identify the fracture associated with the edge (if one exists).

◆ fillGaussLevelSetMatrix()

void XfemMeshCopier::fillGaussLevelSetMatrix ( GmMatrix  X,
GmMatrix  Xg,
GmMatrix H 
) const
private

Compute levelset function (H) The minimum distance between a point(nodes or integration point) and a segment (fracture) is determined. This function returns the signed distance function used to enrich the element for XFEM.

Param X The integration point coordinates matrix (xi,yi) Param Xg The ghost nodal coordinates matrix (xi,yi) Param H The level set vector (xi,yi)

◆ fillNodalLevelSetMatrix()

void XfemMeshCopier::fillNodalLevelSetMatrix ( GmMatrix  X,
GmMatrix  Xg,
GmMatrix H 
) const
private

Compute levelset function (H) The minimum distance between a point(nodes or integration point) and a segment (fracture) is determined. This function returns the signed distance function used to enrich the element for XFEM.

Param X The nodal coordinates matrix (xi,yi) Param Xg The ghost nodal coordinates matrix (xi,yi) Param H The level set vector (xi,yi)

◆ interpolateInternalNodeValue()

void XfemMeshCopier::interpolateInternalNodeValue ( const XfemElement e,
GmValueAccessor ac,
QList< GmValueAccessor * >  eacList,
const GmVector naturalCoord,
GmVector result 
) const
private

Fills result with the interpolated value for the ac attribute on the given new splitted node.

Parameters
acThe accessor for the attribute to be filled
eacThe enriched accessor corresponding to ac or NULL if the attribute does not have an enriched part
srcNodeThe original node in the src mesh
newNodeThe new node that should have its attributes filled in the new mesh. Its value will be equal to srcNode when updating the values of the 'reused' node in a split process.
fractureThe fracture segment that caused the split
nodeElementA reference to the sub-element in the src mesh that contains newNode. Can be NULL in rare situations associated with fractures along edges and non-conformant meshes ('T' junctions inside an edge without a proper sub-element).
otherElementA reference to the element on the other side of the fracture. Can also be NULL in the same circumstances of nodeElement.
resultVector that should be filled with the interpolation resultFills result with the interpolated value for the ac attribute on the given natural coordinate of the given element

◆ interpolateSplittedNodeValue()

void XfemMeshCopier::interpolateSplittedNodeValue ( GmValueAccessor ac,
QList< GmValueAccessor * >  eacList,
int  srcNode,
int  newNode,
const FractureEdgeId fracture,
const SubElementId nodeElement,
const SubElementId otherElement,
GmVector result 
) const
private

Calculates and fills all node values associated with the given newNode.

When a node is splitted in the mesh to represent a fracture, this function is called for setting node values for the newlly created node. It is also called for the old node to update its values.

Parameters
srcNodeThe original node in the src mesh
newNodeThe new node that should have its attributes filled in the new mesh. Its value will be equal to srcNode when updating the values of the 'reused' node in a split process.
fractureThe fracture segment that caused the split
nodeElementA reference to the sub-element in the src mesh that contains newNode. Can be NULL in rare situations associated with fractures along edges and non-conformant meshes ('T' junctions inside an edge without a proper sub-element).
otherElementA reference to the element on the other side of the fracture. Can also be NULL in the same circumstances of nodeElement.

Fills result with the interpolated value for the ac attribute on the given new splitted node.

Parameters
acThe accessor for the attribute to be filled
eacThe enriched accessor corresponding to ac or NULL if the attribute does not have an enriched part
srcNodeThe original node in the src mesh
newNodeThe new node that should have its attributes filled in the new mesh. Its value will be equal to srcNode when updating the values of the 'reused' node in a split process.
fractureThe fracture segment that caused the split
nodeElementA reference to the sub-element in the src mesh that contains newNode. Can be NULL in rare situations associated with fractures along edges and non-conformant meshes ('T' junctions inside an edge without a proper sub-element).
otherElementA reference to the element on the other side of the fracture. Can also be NULL in the same circumstances of nodeElement.
resultVector that should be filled with the interpolation result

◆ setElementData()

bool XfemMeshCopier::setElementData ( const QList< SubElementNodeData > &  nodeDataList,
const QList< int > &  psIndex,
const int *  typeIndexMap 
)
private

Copy node coordinates & values from one mesh to the other. It also initializes values for newlly created nodes.

Copy element node + element property set + element values from one mesh to the other.

Parameters
nodeDataListA vector storing, for each _srcMesh subelement, its identification + node list. Ordered by element id and by sub-elemnt id inside elements.
psIndexMap returned by setupPropertyMap() relating property sets in both meshes
typeIndexMapVector with size equal to GM_NUM_CELL_TYPES storing the the index of the first cell for the given type.

Returns true on success, false on errors.

◆ setupAccessors()

bool XfemMeshCopier::setupAccessors ( const QStringList nodeAttributes,
const QStringList elementAttributes,
bool  createMissingAttributes 
)
private

Grab needed accessors, filling the object accessor lists (_nodeAcList, newNodeAcList, ...) and coordinate accessors (_ccordAc and _newCoordAc). Returns true on success, false on errors.

See the copy() function documentation for a description of input parameters.

◆ splitMesh()

bool XfemMeshCopier::splitMesh ( const int *  typeIndexMap)
private

Splits the destination mesh along fractures.

This function expects every fracture segment to be a mesh edge, so every segment is either in the mesh border or on an edge separating two mesh elements.

The applied algorithm consists on the following steps:

1 - For each node in the src mesh, collect which fracture segments start or end in that node. This is achieved by simply traversing the fracture list. For each node, collect also the <element, sub-element> pairs that includes that node. For geometry nodes this can be done by a topological query. For ghost nodes, the fracture segment contains the element. The sub-element must be found by traversing the element. Also, add an entry for the <e, se> pair into a translation map with a -1 value.

2 - By using the typeIndexMap information and traversing the mesh in element order, fill the translation map with the index of each sub-element in the new mesh.

3 - For each source node 'n' that has more than one incident fracture, do: 3.1 - Find the equivalent node number in the new mesh 'nn' 3.2 - From the element/sub-element information associated to the node and the translation map built in step 2, create a set 'nes' with the elements in the new mesh that include 'nn' 3.3 - From 'nes', find all the edges that are incident to 'nn'. An edge is represented by a structure that stores the src node and the elements that share that edge (1 or 2), with the element that has an 'incoming' half-edge first and 'outgoing' second (the incoming half-edge will be the edge where the src node comes before 'nn' in the element when traversed in CCW mode). It also stores a flag to identify if that edge is a fracture or not. 3.4 - Select the first fracture incident to 'nn' and calculate the angle between each other edge and the fracture. Order those edges in trigonometric order by that angle. 3.5 - For every element from the outgoing element of that first fracture until the ingoing element of the next fracture (and edges in between), or until finding a border (edge with only one element), replace node 'nn' by a new node. 3.6 - Repeat step 3.5 until reaching the last fracture. If node 'nn' has X incident fractures, step 3.5 will be executed X-1 times.

4 - For each node 'n' that has only one incident fracture do: 4.1 - Execute steps 3.1 to 3.4 4.2 - Virtually extending the fracture past 'nn' by a new segment, the position in which that segment would fall in the ordered segment set lies in the 180 degrees border. Apply step 3.5 for edges between the fracture and this extended segment.

Parameters
typeIndexMapVector with size equal to GM_NUM_CELL_TYPES storing the the index of the first cell for the given type.

◆ updateNodeAttributes()

void XfemMeshCopier::updateNodeAttributes ( int  srcNode,
int  newNode,
const FractureEdgeId fracture,
const SubElementId nodeElement,
const SubElementId otherElement 
)
private

Calculates and fills all node values associated with the given newNode.

When a node is splitted in the mesh to represent a fracture, this function is called for setting node values for the newlly created node. It is also called for the old node to update its values.

Parameters
srcNodeThe original node in the src mesh
newNodeThe new node that should have its attributes filled in the new mesh. Its value will be equal to srcNode when updating the values of the 'reused' node in a split process.
fractureThe fracture segment that caused the split
nodeElementA reference to the sub-element in the src mesh that contains newNode. Can be NULL in rare situations associated with fractures along edges and non-conformant meshes ('T' junctions inside an edge without a proper sub-element).
otherElementA reference to the element on the other side of the fracture. Can also be NULL in the same circumstances of nodeElement.

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