Xfem
The Xfem Plugin
Loading...
Searching...
No Matches
xfemTools.h
Go to the documentation of this file.
1/************************************************************************
2**
3** Copyright (C) 2017 by Geomechanic group - Tecgraf/Puc-Rio
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_TOOLS_H_
25#define _GEMA_XFEM_TOOLS_H_
26
28#include <gmpFemPhysics.h>
29#include "xfemOptions.h"
30#include "xfemMesh.h"
31#include <assert.h>
32
33#ifndef _USE_MATH_DEFINES
34#define _USE_MATH_DEFINES // To enable M_PI in Visual Studio
35#endif
36#include <math.h>
37
40{
41public:
42 //XfemTools(XfemMesh* xmesh, XfemOptions& xfemOptions, GmSimulationData* simulation, const QList<GmpFemPhysics*>& physics, GmLogCategory& logger);
43 XfemTools(XfemMesh* xmesh, XfemOptions& xfemOptions, GmSimulationData* simulation, QVector<GmpFemPhysics*>& physics, const GmLogCategory& logger);
44
45 virtual ~XfemTools();
46
48 int pointDimension() const { return _ndim; }
49 //Compute Unit Vector
50 virtual bool unitVectSegment(GmMatrix Xg, GmMatrix& uVec) const;
51 //Compute Unit Vector of a plane
52 virtual bool unitVectPlane(const GmMatrix & Xg, GmMatrix & uVec, GmMatrix & uVec2, GmMatrix & uVec3, GmMatrix & ROT) const;
53 //Compute intersection of two planes
54 virtual bool intersect3D_2Planes(const GmMatrix& Xg, GmMatrix& uVec, const GmMatrix& uVec2, GmMatrix& uVec3, GmMatrix & ROT, int& inter, const double& characteristicLength) const;
55 //Compute intersection of a line with a plane
56 virtual bool intersect3D_SegmentPlane(const GmMatrix & P0, const GmMatrix & P1, const GmMatrix & Pn2, GmMatrix & n2, GmMatrix & Line, int & inter) const;
57 //Compute intersection of two planes
58 virtual bool testIntersect3D_2Planes(const GmMatrix & Pn1, GmMatrix & n1, const GmMatrix & Pn2, GmMatrix & n2, GmMatrix & Line, int & inter, XfemMesh* xmesh, XfemElement* xe, XfemElement* xe2) const;
60 // returns a vector containing the i
61 virtual bool intersectVolume(GmMatrix& nodes, QList<GmVector>& element, QList<GmVector>& fracData, GmMatrix& iNodes, QList<GmVector>& iData) const;
62 //Create Rectangular Region at the Crack Tip
63 virtual bool RectangularRegion(double Lch, GmMatrix Xg, GmMatrix uVec, GmMatrix& polygonVert) const;
64 //Checks point relative position with convex polygon
65 virtual bool pointInConvexPolygon(double tol, GmMatrix polygonVert, GmVector Xip, int& nIn) const;
67 virtual bool polygonCentroid(const GmMatrix& polygonVert, GmVector& Xc) const;
68 //Defines the integration points inside region to check propagation criterium
69 virtual bool defIPinRegion(XfemMesh* xmesh, GmMatrix polygonVert, QList<GmVector>& IPInfo, GmVector crackInfo) const;
70 //check and divide polygon if is cut by a segment
71 virtual bool CutPolygonWithPolyline(XfemMesh* xmesh, GmVector crackInfo, GmMatrix& polygonVert, int idCrack) const;
72 //Defines the integration points inside semicircle to check propagation criterion
73 virtual bool defIPinCircle(XfemMesh* xmesh, GmVector crackInfo, QList<GmVector>& IPInfo) const;
74 //Compute the cycle parameter
75 virtual bool cycInc(int iVert, int nVert, int& nCycInc) const;
76 //Compute the parametric position of line C (Seg1(xc1,yc1), Seg2(xc2,yc2)) on intersection with segment S(Node1(xs1, ys1), Node2(xs2, ys2))
77 virtual bool parametricDist(GmVector S1, GmVector S2, GmVector N1, GmVector N2, double tol, double& tValue, bool& bIntersects) const;
78 //Checks the intersection between Polyline A and B and cuts B
79 virtual bool CutPLineWithPLine(XfemMesh* xmesh, double tol, GmVector Seg1node1, GmVector Seg1node2, GmVector Seg2node1, GmVector Seg2node2,
80 GmVector& NewCrackTip, bool& bCut, bool& bCutHeadVertexA, bool& bCutTailVertexA, bool& bCutHeadVertexB, bool& bCutTailVertexB) const;
81 //Returns cartesian coordinates of parametric position (tValue) in segment(x1, y1), (x2, y2)
82 virtual bool CoordsFromParam(GmVector Seg2node1, GmVector Seg2node2, double tValue, GmVector& NewCrackTip) const;
83 //Principal stresses determination
84 virtual bool principalStresses2D(GmVector stress, GmVector& Ps) const;
85 //principal Stress Direction determination
86 virtual bool principalStressDirection2D(GmVector aStress, GmVector aPStress, int nPS, GmVector& uPs) const;
87 //For each region with propagation, computes new fracture paths
88 virtual bool compPropagExtension(XfemMesh* xmesh, XfemFracture* fracture, int nside, GmMatrix Xnodes, GmVector Xg, GmVector aPropDirection, QList<GmVector>& aCrack, bool isHead, GmMatrix crackInfo) const;
89 //For each region with propagation, computes new fracture paths
90 virtual bool testCompPropagExtension3D(XfemMesh* xmesh, XfemElement* xe, QList<int> elemList, GmVector v_n, GmMatrix planeCoord, GmMatrix Xg, QList<GmVector>& aCrack, int& elemId, bool& next) const;
91 //For each region with propagation, computes new fracture paths
92 virtual bool compPropagExtension3D(XfemMesh* xmesh, XfemElement* xe, QList<int> elemList, GmVector v_n, GmMatrix& planeCoord, GmMatrix Xg, QList<GmVector>& aCrack, int& elemId, bool& next) const;
93 //get caracteristic length
94 virtual bool caracteristiclength(GmMatrix Xnodes, double& Lch) const;
95 //set zero verifying tolerance
96 virtual bool setZeroVeriTol(GmMatrix & Xnodes, double & Lch) const;
97 //Checks the intersection between segment C {(xc1, yc1), (xc2, yc2)} and a regular xfemMesh
98 virtual bool parametricSegmentInMesh(XfemMesh* xmesh, XfemFracture* fracture, double tol) const;
99 //Define crack tips in tail and head values
100 virtual bool checkAndInsertTips(QList<double>& tVec) const;
101 // remove repeted values
102 virtual bool insertionSortWORepeated(QList<double>& a, double tol) const;
103 // Sort vector values
104 virtual bool insertionSort(QList<double>& tVec) const;
105 // remove repeted values
106 virtual bool insertionSortWORepeatedint(QList<int>& a, double tol) const;
107 // Sort vector values
108 virtual bool insertionSortint(QList<int>& tVec) const;
109 //Computes area of triangle defined by segment a,b and point c, The signal of the area indicates the position of the point relative to the segment
110 virtual bool orient2D(double xa, double ya, double xb, double yb, double xc, double yc, double& det) const ;
111 // define elements crossed by a crack
112 virtual bool defElemCuts(XfemMesh* xmesh) const;
113 // define elemCutInfo based on the number of fractures
114 virtual bool defElemSets(XfemMesh* xmesh) const;
115 // set integration points for each subelement
116 virtual bool setIntPoints(XfemMesh* xmesh, GmCell* e, QList<GmMatrix> subElem) const;
117 // create sub elements with TetGen Library
118 virtual bool createSubElem(XfemMesh* xmesh, GmCell* e, QList<GmMatrix>& subElem) const;
119 // set data for integration points for each subelement
120 virtual bool setEnrichedData(XfemMesh* xmesh, GmCell* e) const;
121 // set ghost nodes into xfemMesh
122 virtual bool setGhostNodes(XfemMesh* xmesh) const;
123 // set ghost nodes into xfemMesh
124 virtual bool setGhostNodes3D(XfemMesh* xmesh) const;
125 // loads subelements
126 virtual bool loadSubElement(XfemMesh* xmesh, GmCell* e, GmMatrix subElemNode, int type, int rule, bool isFracture) const;
127 //Set integration rule
128 void setIntegrationRule(int rule) { _ruleSet = rule; };
129 // Check the position of the crack points into the element
130 virtual bool checkSegmentInRegularMesh(XfemMesh* xmesh, GmMatrix segCrackCoord, GmVector& mElemCutPos,double tol) const;
131 //Compute the intersection between point crack (xc, yc) and segment S = node1(xs1, ys1), Node2(xs2, ys2)
132 virtual bool intPointLine(GmVector N1, GmVector N2, GmVector crack, double tol, int& nInter) const;
133 //Compute the intersection between point crack (xc, yc) and segment S = node1(xs1, ys1), Node2(xs2, ys2)
134 virtual bool intSegment(GmVector N1, GmVector N2, GmVector crack, double tol, int& nInter) const;
135 //define if a point is inside a sphere
136 virtual bool inSphere(GmMatrix crack, GmVector Ip, double characteristicLength, double tol, int& nInter) const;
137 // Divides polygon X by a segment S into two different polygons
138 virtual bool dividePolygonWithSegment(GmCell* e, GmMatrix S, QList<GmMatrix>& subElemData, double tol) const;
139 // Divides several Polygons by several segments for cases of multiple fractures in a element
140 virtual bool dividePolygonWithSeveralSegments(XfemMesh* xmesh, GmCell* e, QList<GmMatrix>& subElemData, double tol) const;
141 // Add enriched DOF due to cracks interaction
142 virtual bool addEnrichedDof(XfemMesh* xmesh, int numDof, const QString type) const;
143 // set Crack Front Data
144 virtual bool setCrackFrontData(XfemMesh * xmesh) const;
145 // Define DOF sets for intersected fractures
146 virtual bool defDofSets(XfemMesh* xmesh)const;
147 //Define DOF sets for Mechanic physics
148 virtual bool mechanicDofSets(XfemMesh* xmesh, int old, int& numDof, QList<GmVector> aCrack)const;
149 //Define DOF sets for HydroMechanic physics
150 virtual bool hydroMecDofSets(XfemMesh* xmesh, int old, int& numDof, QList<GmVector> aCrack)const;
151 // divide and add sub elements
152 virtual bool subElemDiv(XfemMesh* xmesh) const;
153 // divide and add sub elements
154 virtual bool subElemDiv3D(XfemMesh* xmesh) const;
155 //test with voro++ library
156 void test() const;
157 //test with TetGen library
158 void test2() const;
159 //Return the fracture rotation matrix
160 void fillFractureRotationMatrix(GmCell* e, const GmShape * shp, GmMatrix J, GmMatrix & R) const;
161 //void setAcc(GmValueAccessor* hnAcc) { _HNodeAcc = hnAcc; };
162 virtual bool pointOnSide(GmCell* e, GmMatrix xGhost, GmVector& xIp, int side) const;
163 //Indicates the relative location of the secondary crack respect to the main one
164 virtual bool fillInterCrackNodalLevelSet(GmVector Seg1node1, GmVector Seg1node2, GmVector Seg2node1, GmVector& interactingCraks) const;
165 //Compute nodal levelset function (H)
167 //Compute Gauss levelset function (H)
170 void fillInteractingCraksNodalLevelSets(GmCell* e, XfemEnrichedElementData* exData, int nEnrich, int nCracks, QList<double>crackIndex, QList<GmMatrix>& nodalLevelSet)const;
172 void fillInteractingCraksGaussLevelSets(GmCell* e, XfemEnrichedElementData* exData, int nEnrich, int nCracks, QList<double>crackIndex, QList<GmMatrix>& gaussLevelSet)const;
173 //Mix list with enrichment functions
174 //virtual bool mixList(XfemEnrichedElementData* exDatac, QList<GmMatrix>& nodalLevelSet, QList<double> crackIndex, double value, bool add, bool test, int type, int iSubCrack) const;
175 //Add DOFs to adjacent elements to an intersection
176 //virtual bool correctDOF(XfemMesh* xmesh, QList<GmVector>& aCrack, int& old) const;
177 virtual bool correctDOF(XfemMesh* xmesh, GmCell* e, XfemElement* xe, XfemEnrichedElementData* exData, QList<XfemFracture*> fractureData, QList<GmVector>& aCrack, int& old, bool& add) const;
178 //Delete old specific node DOF to be modified by the following subroutines
179 virtual bool deleteNodeDOF(XfemMesh* xmesh, double value) const;
180 //check DOFs to adjacent elements to an intersection
181 virtual bool checkDOF(XfemMesh* xmesh, double value, QList<int>& enrichList) const;
182 //Add adjacent elements to an intersection to the list to be updated for the assembler
183 virtual bool addChangedElem(XfemMesh* xmesh, double value, QList<int>& enrichList) const;
184 //fill Enrichment Functions
185 virtual bool saveEnrichmentFunctions(XfemMesh* xmesh, double value) const;
186 //alter Enrichment Functions
187 virtual bool alterEnrichmentFunctions(XfemMesh* xmesh, double value) const;
188 // Create global DOF list
189 virtual bool createDofList(XfemMesh* xmesh, const QString type) const;
190 // check DOFs and Enrichment Functions of adjacent elements to an intersection
191 virtual bool checkData(XfemMesh* xmesh) const;
192 //Transform stresses in global XY coordinate system to local crack plane coordinate system
193 virtual bool getCrackPlaneStresses(GmVector Sxy, GmMatrix ROT, GmVector& Stn) const;
194 //Transform Strains in global XY coordinate system to local crack plane coordinate system
195 virtual bool getCrackPlaneStrains(GmVector Exy, GmMatrix ROT, GmVector& Etn) const;
196 // Reorganize from vector to tensorial representation and vice versa
197 virtual bool vectorialToTensorial(GmVector& Av, GmMatrix& Am, unsigned sc, QString type = "strain", bool mode = true) const;
198
199protected:
207 QVector<GmpFemPhysics*> _physics; // physics data
208
209 //GmValueAccessor* _HNodeAcc;
210
211//private:
212 int _ndim;
214
215};
216
217#endif
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
The XfemGaussAccessor class is a proxy object to a value accesor implementing a more convenient inter...
Definition xfemGaussAccessor.h:41
Basic class for a XFEM mesh. This is the basic mesh interface for xfem problems adding enrichment cap...
Definition xfemMesh.h:50
Definition xfemOptions.h:30
A simple class to provide xfem tools.
Definition xfemTools.h:40
int pointDimension() const
Returns the dimension of each fracture point. Equal to the mesh dimension.
Definition xfemTools.h:48
void fillInteractingCraksGaussLevelSets(GmCell *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 xfemTools.cpp:9291
XfemGaussAccessor * _stressAcc
Sets enriched gauss accessor for stress.
Definition xfemTools.h:201
const GmLogCategory & _logger
The logger object used to emmit messages.
Definition xfemTools.h:213
virtual ~XfemTools()
Destructor.
Definition xfemTools.cpp:82
void fillGaussLevelSetMatrix(GmMatrix X, GmMatrix Xg, GmMatrix &H) const
Compute Gauss levelset function (H) The minimum distance between a point(integration point) and a seg...
Definition xfemTools.cpp:9107
GmSimulationData * _SimulationData
Simulation data.
Definition xfemTools.h:206
virtual bool setZeroVeriTol(GmMatrix &Xnodes, double &Lch) const
set zero verifying tolerance
Definition xfemTools.cpp:2418
virtual bool correctDOF(XfemMesh *xmesh, GmCell *e, XfemElement *xe, XfemEnrichedElementData *exData, QList< XfemFracture * > fractureData, QList< GmVector > &aCrack, int &old, bool &add) const
Add DOFs to adjacent elements to an intersection.
Definition xfemTools.cpp:7593
virtual bool intersect3D_2Planes(const GmMatrix &Xg, GmMatrix &uVec, const GmMatrix &uVec2, GmMatrix &uVec3, GmMatrix &ROT, int &inter, const double &characteristicLength) const
Definition xfemTools.cpp:206
virtual bool defDofSets(XfemMesh *xmesh) const
Define elements DOF.
Definition xfemTools.cpp:7415
virtual bool addChangedElem(XfemMesh *xmesh, double value, QList< int > &enrichList) const
Definition xfemTools.cpp:9825
virtual bool alterEnrichmentFunctions(XfemMesh *xmesh, double value) const
Definition xfemTools.cpp:10134
virtual bool intersectVolume(GmMatrix &nodes, QList< GmVector > &element, QList< GmVector > &fracData, GmMatrix &iNodes, QList< GmVector > &iData) const
returns the intersection between volume and fracture
Definition xfemTools.cpp:1086
virtual bool compPropagExtension(XfemMesh *xmesh, XfemFracture *fracture, int nside, GmMatrix Xnodes, GmVector Xg, GmVector aPropDirection, QList< GmVector > &aCrack, bool isHead, GmMatrix crackInfo) const
Definition xfemTools.cpp:2458
virtual bool deleteNodeDOF(XfemMesh *xmesh, double value) const
Definition xfemTools.cpp:9598
virtual bool unitVectPlane(const GmMatrix &Xg, GmMatrix &uVec, GmMatrix &uVec2, GmMatrix &uVec3, GmMatrix &ROT) const
Definition xfemTools.cpp:149
virtual bool getCrackPlaneStresses(GmVector Sxy, GmMatrix ROT, GmVector &Stn) const
Definition xfemTools.cpp:6054
virtual bool caracteristiclength(GmMatrix Xnodes, double &Lch) const
get caracteristic length
Definition xfemTools.cpp:2389
virtual bool setIntPoints(XfemMesh *xmesh, GmCell *e, QList< GmMatrix > subElem) const
Definition xfemTools.cpp:5210
XfemTools(XfemMesh *xmesh, XfemOptions &xfemOptions, GmSimulationData *simulation, QVector< GmpFemPhysics * > &physics, const GmLogCategory &logger)
Constructor for a Xfem tools used in Xfem process.
Definition xfemTools.cpp:66
virtual bool checkData(XfemMesh *xmesh) const
check DOFs and Enrichment Functions of adjacent elements to an intersection
Definition xfemTools.cpp:9475
GmValueAccessor * _nodeAcc
Node accessor.
Definition xfemTools.h:200
virtual bool polygonCentroid(const GmMatrix &polygonVert, GmVector &Xc) const
Computes the polygon centroid.
Definition xfemTools.cpp:1290
virtual bool unitVectSegment(GmMatrix Xg, GmMatrix &uVec) const
Definition xfemTools.cpp:95
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 xfemTools.cpp:9028
XfemOptions _xfemOptions
The set of xfem options.
Definition xfemTools.h:205
virtual bool getCrackPlaneStrains(GmVector Exy, GmMatrix ROT, GmVector &Etn) const
Definition xfemTools.cpp:6131
virtual bool intersect3D_SegmentPlane(const GmMatrix &P0, const GmMatrix &P1, const GmMatrix &Pn2, GmMatrix &n2, GmMatrix &Line, int &inter) const
Definition xfemTools.cpp:514
virtual bool saveEnrichmentFunctions(XfemMesh *xmesh, double value) const
Definition xfemTools.cpp:9958
int _ndim
The dimension of each coordinate.
Definition xfemTools.h:212
XfemGaussAccessor * _strainAcc
Sets enriched gauss accessor for strain.
Definition xfemTools.h:202
virtual bool testIntersect3D_2Planes(const GmMatrix &Pn1, GmMatrix &n1, const GmMatrix &Pn2, GmMatrix &n2, GmMatrix &Line, int &inter, XfemMesh *xmesh, XfemElement *xe, XfemElement *xe2) const
Definition xfemTools.cpp:600
virtual bool checkDOF(XfemMesh *xmesh, double value, QList< int > &enrichList) const
Definition xfemTools.cpp:9656
GmCellAccessor * _strengthAcc
Sets enriched gauss accessor for strength.
Definition xfemTools.h:203
virtual bool compPropagExtension3D(XfemMesh *xmesh, XfemElement *xe, QList< int > elemList, GmVector v_n, GmMatrix &planeCoord, GmMatrix Xg, QList< GmVector > &aCrack, int &elemId, bool &next) const
Definition xfemTools.cpp:2587
int _ruleSet
sets integration rule
Definition xfemTools.h:204
void fillInteractingCraksNodalLevelSets(GmCell *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 xfemTools.cpp:9168
virtual bool parametricSegmentInMesh(XfemMesh *xmesh, XfemFracture *fracture, double tol) const
\ class XfemTools Purpose : Checks the intersection between segment C {(xc1, yc1),...
Definition xfemTools.cpp:4401
virtual bool CutPolygonWithPolyline(XfemMesh *xmesh, GmVector crackInfo, GmMatrix &polygonVert, int idCrack) const
Definition xfemTools.cpp:1576
virtual bool pointOnSide(GmCell *e, GmMatrix xGhost, GmVector &xIp, int side) const
Definition xfemTools.cpp:9417
arma::mat GmMatrix
arma::vec GmVector
Declaration of the XfemEnrichedElementData class.
Declaration of the XfemMesh class.
Declaration of the xfemOptions class.