Xfem
The Xfem Plugin
xfemMeshCopier.h
Go to the documentation of this file.
1 /************************************************************************
2 **
3 ** Copyright (C) 2014 by Carlos Augusto Teixera Mendes
4 ** All rights reserved.
5 **
6 ** This file is part of the "GeMA" software. It's use should respect
7 ** the terms in the license agreement that can be found together
8 ** with this source code.
9 ** It is provided AS IS, with NO WARRANTY OF ANY KIND,
10 ** INCLUDING THE WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR
11 ** A PARTICULAR PURPOSE.
12 **
13 ************************************************************************/
14 
24 #ifndef _GEMA_XFEM_MESH_COPIER_H_
25 #define _GEMA_XFEM_MESH_COPIER_H_
26 
27 class XfemMesh;
28 class XfemFracture;
29 class XfemElement;
30 class XfemSolver;
31 
32 class GmCell;
33 class GmElementMesh;
34 class GmLogCategory;
35 
36 class GmValueAccessor;
37 class GmCellAccessor;
38 class GmGaussAccessor;
39 
40 #include <QVector>
41 #include <gmVector.h>
42 #include <gmMatrix.h>
44 
49 {
50 public:
51  XfemMeshCopier(const XfemMesh* srcMesh, GmElementMesh* newMesh, XfemSolver* solver, const GmLogCategory& logger);
52 
53  virtual ~XfemMeshCopier();
54 
55  bool copy(bool splitFractures);
56  bool copy(const QStringList& nodeAttributes, const QStringList& elementAttributes,
57  bool createMissingAttributes, bool splitFractures);
58 
59 private:
60  bool copyAux(const QStringList& nodeAttributes, const QStringList& elementAttributes,
61  bool createMissingAttributes, bool splitFractures);
62 
63  bool setupAccessors(const QStringList& nodeAttributes, const QStringList& elementAttributes, bool createMissingAttributes);
64  bool setupNodeAccessors (const QStringList& nodeAttributes, bool createMissingAttributes);
65  bool setupElementAccessors(const QStringList& elementAttributes, bool createMissingAttributes);
67 
68  bool setupPropertyMap(QList<int>& psIndex);
69 
72  {
73  int _elem;
74  int _subElem;
76 
77  SubElementNodeData(int e, int se) : _elem(e), _subElem(se) {}
78  };
79 
81  struct NewNodesData
82  {
83  int _elem;
85 
86  NewNodesData(int e, const GmVector& coord) : _elem(e), _naturalCoord(coord) {}
87  };
88 
90 
91  bool setNodeData(const QList<NewNodesData>& newNodesList, bool updateGhostNodes);
92  bool setElementData(const QList<SubElementNodeData>& nodeDataList, const QList<int>& psIndex, const int* typeIndexMap);
93 
96 
99 
102  {
103  int _srcNode;
107 
108  SplitEdgeData(int srcNode) { _srcNode = srcNode; _inElementIndex = _outElementIndex = -1; _fractureIndex = -1; }
109  };
110 
113  {
114  bool _borderNode;
118 
119  SplitNodeData() { _borderNode = false; }
120  };
121 
122  bool splitMesh(const int* typeIndexMap);
123 
124  void fillSplitInfoMaps(const int* typeIndexMap, QMap<int, SplitNodeData>& nodeInfo,
125  QMap<SubElementId, int>& elementTranslationMap) const;
126 
127  void fillEdgeList(int node, const QList<SubElementId>& elements, const QList<FractureEdgeId>& fractures,
128  const QMap<SubElementId, int>& elementTranslationMap, QList<SplitEdgeData>& edges) const;
129  int sortEdgeList(int node, QList<SplitEdgeData>& edges, int* lastEdge) const;
130 
131  void replaceElementNode(int node, int newNode, const QList<int>& elements);
132 
133  void addEdgeInfo(int node, int srcNode, bool incoming, int elemIndex, const QList<FractureEdgeId>& fractures, QList<SplitEdgeData>& edges) const;
134 
135  void addNodeInfo(QMap<int, SplitNodeData>& nodeInfo, QMap<SubElementId, int>& elementTranslationMap,
136  const XfemFracture* f, int fractureSegment, const XfemElement* e, int node, int nodeEdge) const;
137 
138  const XfemElement* segmentInfo(const XfemFracture* f, int segment, int* n1, int* n2, int* e1 = NULL, int* e2 = NULL) const;
139 
140  void updateNodeAttributes(int srcNode, int newNode, const FractureEdgeId& fracture,
141  const SubElementId* nodeElement, const SubElementId* otherElement);
142 
143  void interpolateSplittedNodeValue(GmValueAccessor* ac, QList<GmValueAccessor*> eacList, int srcNode, int newNode, const FractureEdgeId& fracture,
144  const SubElementId* nodeElement, const SubElementId* otherElement, GmVector& result) const;
145 
146  //void interpolateSplittedNodeValue(GmValueAccessor* ac, GmValueAccessor* eAc, int srcNode, int newNode, const FractureEdgeId& fracture,
147  // const SubElementId* nodeElement, const SubElementId* otherElement, GmVector& result) const;
148 
150  const GmVector& naturalCoord, GmVector& result) const;
151 
152  //void interpolateInternalNodeValue(const XfemElement* e, GmValueAccessor* ac, GmValueAccessor* eAc,
153  // const GmVector& naturalCoord, GmVector& result) const;
154 
155  void polygonCentroid(GmMatrix polygonCoords, GmVector& Xcg) const;
156 
157  void fillNodalLevelSetMatrix(GmMatrix X, GmMatrix Xg, GmMatrix& H) const;
158 
159  void fillGaussLevelSetMatrix(GmMatrix X, GmMatrix Xg, GmMatrix& H) const;
160 
161  void fillInteractingCraksNodalLevelSets(const XfemElement* e, XfemEnrichedElementData* exData, int nEnrich, int nCracks, QList<double>crackIndex, QList<GmMatrix>& nodalLevelSet)const;
162 
163  void fillInteractingCraksGaussLevelSets(const XfemElement* e, XfemEnrichedElementData* exData, int nEnrich, int nCracks, QList<double>crackIndex, QList<GmMatrix>& gaussLevelSet)const;
164 
166  //XfemMesh* _srcMesh; //!< The source mesh storing the elements to be copied
170 
173  //QList<GmValueAccessor*> _enrichedAcList; //!< The set of corresponding enriched node accessors for each entrie in _nodeAcList (or NULL)
179 
182 };
183 
184 #endif
185 
XfemSolver * _solver
The xfem solver, needed for interpolations.
Definition: xfemMeshCopier.h:168
QList< GmGaussAccessor * > _newGaussAcList
The set of Gauss accessors in the destination mesh.
Definition: xfemMeshCopier.h:178
QList< GmCellAccessor * > _cellAcList
The set of cell accessors in the source mesh.
Definition: xfemMeshCopier.h:175
bool splitMesh(const int *typeIndexMap)
Splits the destination mesh along fractures.
Definition: xfemMeshCopier.cpp:1125
bool setNodeData(const QList< NewNodesData > &newNodesList, bool updateGhostNodes)
Copy node coordinates & values from one mesh to the other. It also initializes values for newlly crea...
Definition: xfemMeshCopier.cpp:683
int _fractureIndex
If this edge is a fracture edge, stores the index in SplitNodeData._fractures of the fracture....
Definition: xfemMeshCopier.h:106
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 i...
Definition: xfemMeshCopier.cpp:2655
bool setupElementAccessors(const QStringList &elementAttributes, bool createMissingAttributes)
Aux function to setupAccessors to grab/create if needed node data caessors.
Definition: xfemMeshCopier.cpp:412
virtual ~XfemMeshCopier()
Destructor.
Definition: xfemMeshCopier.cpp:71
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.
Definition: xfemMeshCopier.cpp:2357
QList< SplitEdgeData > _edgeList
The list of edges in the new mesh that include this node as a vertex.
Definition: xfemMeshCopier.h:117
QPair< const XfemFracture *, int > FractureEdgeId
Type stroring a reference for a fracture segment.
Definition: xfemMeshCopier.h:98
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 i...
Definition: xfemMeshCopier.cpp:2576
Type storing per node data for the splitting operation.
Definition: xfemMeshCopier.h:112
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'.
Definition: xfemMeshCopier.cpp:1303
bool setupPropertyMap(QList< int > &psIndex)
Setup psIndex, an index storing for each property set in the destination mesh its index in the source...
Definition: xfemMeshCopier.cpp:596
bool buildSubElementNodeLists(QList< SubElementNodeData > &nodeDataList, QList< NewNodesData > &newNodesList)
Traverses sub-elements building a list with its nodes + any needed new nodes.
Definition: xfemMeshCopier.cpp:625
Aux structure to store coordinates for newly created nodes.
Definition: xfemMeshCopier.h:81
GmVector _naturalCoord
The node natural coordinate in the father reference.
Definition: xfemMeshCopier.h:84
void replaceElementNode(int node, int newNode, const QList< int > &elements)
Replaces node by newNode in the mesh node list of the given elements.
Definition: xfemMeshCopier.cpp:1427
QList< GmCellAccessor * > _newCellAcList
The set of cell accessors in the destination mesh.
Definition: xfemMeshCopier.h:176
int _elem
The father element for the new node.
Definition: xfemMeshCopier.h:83
Basic interface for an XFEM element.
Definition: xfemElement.h:43
QList< FractureEdgeId > _fractures
The list of src mesh fracture segments that are incident to this node.
Definition: xfemMeshCopier.h:115
Basic class for a XFEM mesh. This is the basic mesh interface for xfem problems adding enrichment cap...
Definition: xfemMesh.h:49
GmValueAccessor * _newCoordAc
The accessor used to get node coordinates in the destination mesh.
Definition: xfemMeshCopier.h:181
int _srcNode
The other node of the edge, different from 'n'.
Definition: xfemMeshCopier.h:103
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 ...
Definition: xfemMeshCopier.cpp:2798
bool setupAccessors(const QStringList &nodeAttributes, const QStringList &elementAttributes, bool createMissingAttributes)
Grab needed accessors, filling the object accessor lists (_nodeAcList, newNodeAcList,...
Definition: xfemMeshCopier.cpp:301
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....
Definition: xfemMeshCopier.cpp:1344
QVector< int > _nodes
The sub-element node list.
Definition: xfemMeshCopier.h:75
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.
Definition: xfemMeshCopier.cpp:1238
XfemMeshCopier(const XfemMesh *srcMesh, GmElementMesh *newMesh, XfemSolver *solver, const GmLogCategory &logger)
Creates the mesh copier object. Copies will be made with calls to copy().
Definition: xfemMeshCopier.cpp:56
A simple class to represent a natural fracture.
Definition: xfemFracture.h:34
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...
Definition: xfemMeshCopier.cpp:1505
bool _borderNode
Does this node belong to the mesh border?
Definition: xfemMeshCopier.h:114
bool copyAux(const QStringList &nodeAttributes, const QStringList &elementAttributes, bool createMissingAttributes, bool splitFractures)
Helper function for copy() to allow for easier mesh cleanup on errors.
Definition: xfemMeshCopier.cpp:161
QList< GmValueAccessor * > _newNodeAcList
The set of node accessors in the destination mesh.
Definition: xfemMeshCopier.h:174
QPair< int, int > SubElementId
Type storing an element Id + sub-element Id (or -1 for a whole element reference)
Definition: xfemMeshCopier.h:95
Extension of the FEM linear solver for the XFEM method.
Definition: xfemSolver.h:34
QList< GmGaussAccessor * > _gaussAcList
The set of Gauss accessors in the source mesh.
Definition: xfemMeshCopier.h:177
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 crea...
Definition: xfemMeshCopier.cpp:993
QList< GmValueAccessor * > _nodeAcList
The set of node accessors in the source mesh.
Definition: xfemMeshCopier.h:171
int _subElem
The sub-element number.
Definition: xfemMeshCopier.h:74
Declaration of the XfemEnrichedElementData class.
int _inElementIndex
The element in the incoming side (_srcNode to 'n') in the element orientation. -1 if nonexistant....
Definition: xfemMeshCopier.h:104
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.
Definition: xfemMeshCopier.cpp:1645
bool copy(bool splitFractures)
Overload of XfemMeshCopier::copy(const QStringList&, const QStringList&, bool) passing as first and s...
Definition: xfemMeshCopier.cpp:94
QList< QList< GmValueAccessor * > > _enrichedAcList
The set of corresponding enriched node accessors for each entrie in _nodeAcList (or NULL)
Definition: xfemMeshCopier.h:172
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.
Definition: xfemMeshCopier.cpp:1457
const XfemMesh * _srcMesh
The source mesh storing the elements to be copied.
Definition: xfemMeshCopier.h:165
Aux structure to store a node list for each sub-element in the mesh.
Definition: xfemMeshCopier.h:71
const GmLogCategory & _logger
The logger used to produce error messages.
Definition: xfemMeshCopier.h:169
GmElementMesh * _newMesh
The empty destination mesh.
Definition: xfemMeshCopier.h:167
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 ...
Definition: xfemMeshCopier.cpp:2739
arma::vec GmVector
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.
Definition: xfemMeshCopier.cpp:1796
QList< SubElementId > _elements
The list of src mesh elements/subelements that include this node in their geometry.
Definition: xfemMeshCopier.h:116
int _elem
The element number.
Definition: xfemMeshCopier.h:73
A class used to store per element data needed only in enriched elements.
Definition: xfemEnrichedElementData.h:37
arma::mat GmMatrix
bool setupNodeAccessors(const QStringList &nodeAttributes, bool createMissingAttributes)
Aux function to setupAccessors to grab/create if needed node data accessors.
Definition: xfemMeshCopier.cpp:332
bool setupEnrichedAccessors()
Setup enriched data acessors corresponding to node accessors.
Definition: xfemMeshCopier.cpp:509
Basic class for copying an XFEM mesh into an empty element mesh, transforming sub-elements into eleme...
Definition: xfemMeshCopier.h:48
int _outElementIndex
The element in the outgoing side ('n' to _srcNode) in the element orientation. -1 if nonexistant....
Definition: xfemMeshCopier.h:105
GmValueAccessor * _coordAc
The accessor used to get node coordinates in the source mesh.
Definition: xfemMeshCopier.h:180
const XfemElement * segmentInfo(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.
Definition: xfemMeshCopier.cpp:1581
Type storing data for an edge incident to a node 'n'.
Definition: xfemMeshCopier.h:101