Xfem
The Xfem Plugin
Loading...
Searching...
No Matches
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
27class XfemMesh;
28class XfemFracture;
29class XfemElement;
30class XfemSolver;
31
32class GmCell;
33class GmElementMesh;
34class GmLogCategory;
35
36class GmValueAccessor;
37class GmCellAccessor;
38class GmGaussAccessor;
39
40#include <QVector>
41#include <gmVector.h>
42#include <gmMatrix.h>
44
49{
50public:
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
59private:
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;
76
77 SubElementNodeData(int e, int se) : _elem(e), _subElem(se) {}
78 };
79
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
110
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
158
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
Basic interface for an XFEM element.
Definition xfemElement.h:44
A class used to store per element data needed only in enriched elements.
Definition xfemEnrichedElementData.h:38
A simple class to represent a natural fracture.
Definition xfemFracture.h:35
Basic class for copying an XFEM mesh into an empty element mesh, transforming sub-elements into eleme...
Definition xfemMeshCopier.h:49
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:994
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:162
QList< QList< GmValueAccessor * > > _enrichedAcList
The set of corresponding enriched node accessors for each entrie in _nodeAcList (or NULL)
Definition xfemMeshCopier.h:172
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:1804
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:58
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:1508
QList< GmGaussAccessor * > _newGaussAcList
The set of Gauss accessors in the destination mesh.
Definition xfemMeshCopier.h:178
bool setupElementAccessors(const QStringList &elementAttributes, bool createMissingAttributes)
Aux function to setupAccessors to grab/create if needed node data caessors.
Definition xfemMeshCopier.cpp:413
GmValueAccessor * _coordAc
The accessor used to get node coordinates in the source mesh.
Definition xfemMeshCopier.h:180
bool setupEnrichedAccessors()
Setup enriched data acessors corresponding to node accessors.
Definition xfemMeshCopier.cpp:510
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:684
const XfemMesh * _srcMesh
The source mesh storing the elements to be copied.
Definition xfemMeshCopier.h:165
bool splitMesh(const int *typeIndexMap)
Splits the destination mesh along fractures.
Definition xfemMeshCopier.cpp:1128
XfemSolver * _solver
The xfem solver, needed for interpolations.
Definition xfemMeshCopier.h:168
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:2663
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:1648
QPair< const XfemFracture *, int > FractureEdgeId
Type stroring a reference for a fracture segment.
Definition xfemMeshCopier.h:98
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:1460
const GmLogCategory & _logger
The logger used to produce error messages.
Definition xfemMeshCopier.h:169
bool setupNodeAccessors(const QStringList &nodeAttributes, bool createMissingAttributes)
Aux function to setupAccessors to grab/create if needed node data accessors.
Definition xfemMeshCopier.cpp:333
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 split node.
Definition xfemMeshCopier.cpp:2365
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:1306
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:1241
QPair< int, int > SubElementId
Type storing an element Id + sub-element Id (or -1 for a whole element reference)
Definition xfemMeshCopier.h:95
bool buildSubElementNodeLists(QList< SubElementNodeData > &nodeDataList, QList< NewNodesData > &newNodesList)
Traverses sub-elements building a list with its nodes + any needed new nodes.
Definition xfemMeshCopier.cpp:626
bool copy(bool splitFractures)
Overload of XfemMeshCopier::copy(const QStringList&, const QStringList&, bool) passing as first and s...
Definition xfemMeshCopier.cpp:96
GmElementMesh * _newMesh
The empty destination mesh.
Definition xfemMeshCopier.h:167
QList< GmCellAccessor * > _newCellAcList
The set of cell accessors in the destination mesh.
Definition xfemMeshCopier.h:176
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:1347
bool setupAccessors(const QStringList &nodeAttributes, const QStringList &elementAttributes, bool createMissingAttributes)
Grab needed accessors, filling the object accessor lists (_nodeAcList, newNodeAcList,...
Definition xfemMeshCopier.cpp:302
QList< GmValueAccessor * > _newNodeAcList
The set of node accessors in the destination mesh.
Definition xfemMeshCopier.h:174
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:2806
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:1584
virtual ~XfemMeshCopier()
Destructor.
Definition xfemMeshCopier.cpp:73
QList< GmValueAccessor * > _nodeAcList
The set of node accessors in the source mesh.
Definition xfemMeshCopier.h:171
QList< GmCellAccessor * > _cellAcList
The set of cell accessors in the source mesh.
Definition xfemMeshCopier.h:175
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:2584
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:1430
QList< GmGaussAccessor * > _gaussAcList
The set of Gauss accessors in the source mesh.
Definition xfemMeshCopier.h:177
GmValueAccessor * _newCoordAc
The accessor used to get node coordinates in the destination mesh.
Definition xfemMeshCopier.h:181
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:597
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:2747
Basic class for a XFEM mesh. This is the basic mesh interface for xfem problems adding enrichment cap...
Definition xfemMesh.h:50
Extension of the FEM linear solver for the XFEM method.
Definition xfemSolver.h:36
arma::mat GmMatrix
arma::vec GmVector
Aux structure to store coordinates for newly created nodes.
Definition xfemMeshCopier.h:82
GmVector _naturalCoord
The node natural coordinate in the father reference.
Definition xfemMeshCopier.h:84
int _elem
The father element for the new node.
Definition xfemMeshCopier.h:83
Type storing data for an edge incident to a node 'n'.
Definition xfemMeshCopier.h:102
int _fractureIndex
If this edge is a fracture edge, stores the index in SplitNodeData._fractures of the fracture....
Definition xfemMeshCopier.h:106
int _outElementIndex
The element in the outgoing side ('n' to _srcNode) in the element orientation. -1 if nonexistant....
Definition xfemMeshCopier.h:105
int _srcNode
The other node of the edge, different from 'n'.
Definition xfemMeshCopier.h:103
int _inElementIndex
The element in the incoming side (_srcNode to 'n') in the element orientation. -1 if nonexistant....
Definition xfemMeshCopier.h:104
Type storing per node data for the splitting operation.
Definition xfemMeshCopier.h:113
QList< SplitEdgeData > _edgeList
The list of edges in the new mesh that include this node as a vertex.
Definition xfemMeshCopier.h:117
bool _borderNode
Does this node belong to the mesh border?
Definition xfemMeshCopier.h:114
QList< FractureEdgeId > _fractures
The list of src mesh fracture segments that are incident to this node.
Definition xfemMeshCopier.h:115
QList< SubElementId > _elements
The list of src mesh elements/subelements that include this node in their geometry.
Definition xfemMeshCopier.h:116
Aux structure to store a node list for each sub-element in the mesh.
Definition xfemMeshCopier.h:72
QVector< int > _nodes
The sub-element node list.
Definition xfemMeshCopier.h:75
int _elem
The element number.
Definition xfemMeshCopier.h:73
int _subElem
The sub-element number.
Definition xfemMeshCopier.h:74
Declaration of the XfemEnrichedElementData class.