Xfem
The Xfem Plugin
xfemMesh.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_H_
25 #define _GEMA_XFEM_MESH_H_
26 
27 #include <gmElementMesh.h>
28 
29 #include "xfemElement.h"
30 #include "xfemMeshLoader.h"
31 
32 #include "xfemLuaMesh.h"
33 #include "xfemLuaElement.h"
34 #include "xfemGaussAccessor.h"
35 
36 #include <gmpCellMeshBase.h>
37 #include <gmpGemaCellMeshData.h>
38 
41 class XfemSubElement;
42 class XfemFracture;
43 
49 class XfemMesh : public GmpMeshBaseDataInterface<GmElementMesh, GmpGemaMeshData<XfemVector>, GmpGemaCellMeshData<XfemVector>>
50 {
51 public:
52  XfemMesh(GmSimulationData* simulation, QString id, QString description, const GmLogCategory& logger);
53 
54  virtual ~XfemMesh();
55 
56  virtual void printValues(const GmLogCategory& logger, int options);
57 
59  virtual const XfemElement* element(int index) const { return (XfemElement*)cell(index); }
60 
62  virtual XfemElement* element(int index) { return (XfemElement*)cell(index); }
63 
64  virtual bool enrichElement(XfemElement* e);
65 
67 
70 
71  virtual int numRegularSubElements (const XfemElement* e) const;
72  virtual int numFractureSubElements(const XfemElement* e) const;
73  virtual const XfemSubElement* subElement (const XfemElement* e, int index) const;
74  virtual const XfemSubElement* fractureSubElement (const XfemElement* e, int index) const;
75  virtual void clearSubElements();
76  virtual void clearSubElements(XfemElement* e);
77  virtual int addSubElement (XfemElement* e, XfemSubElement* se, int ruleSet = 0);
78  virtual void removeSubElement(XfemElement* e, int index);
79  virtual void updateSubElementCoordinates(XfemElement* e, int index, const GmMatrix& seNaturalCoords,
80  int ruleSet = 0);
81 
82  const GmIntegrationRule* enrichedElementRegularIntegrationRule (const XfemElement* e, int ruleSet) const;
83  const GmIntegrationRule* enrichedElementFractureIntegrationRule(const XfemSubElement* se, int ruleSet) const;
84 
86  virtual XfemGaussAccessor* enrichedGaussAttributeAccessor(QString id, Unit desiredUnit, const GmLogCategory& logger) const
87  {
88  return enrichedGaussAttributeAccessor(id, 0, true, desiredUnit, logger);
89  }
90 
91  virtual XfemGaussAccessor* enrichedGaussAttributeAccessor(QString id, int snum, bool locked, Unit desiredUnit, const GmLogCategory& logger) const;
92 
94  virtual const QList<XfemFracture*>& naturalFractures() const { return _naturalFractures; }
95 
98 
100  virtual void clearNaturalFractures();
101 
103  virtual GmVector getElemCutInfo( int id) const { return _elemCutInfo.at(id); }
104 
106  virtual void addElemCutInfo(QList<GmVector> eCI) { _elemCutInfo.append(eCI); }
107 
109  virtual void deleteElemCutInfo() { _elemCutInfo.clear(); }
110 
112  virtual int sizeElemCutInfo() { return _elemCutInfo.size(); }
113 
115  virtual int getTotalNumDOF(int id) const { return _totalDofSet.at(id); }
116 
118  virtual void addTotalNumDOF(QList<int> eCI) { _totalDofSet.append(eCI); }
119 
121  virtual void deleteTotalNumDOF() { _totalDofSet.clear(); }
122 
124  virtual int sizeTotalNumDOF() { return _totalDofSet.size(); }
125 
127  virtual QString getNodeStateVarIds(int id) const { return _nodeStateVarIds.at(id); }
128 
130  virtual void addNodeStateVarIds(QStringList eCI) { _nodeStateVarIds.append(eCI); }
131 
133  virtual void deleteNodeStateVarIds() { _nodeStateVarIds.clear(); }
134 
136  virtual int sizeNodeStateVarIds() const { return _nodeStateVarIds.size(); }
137 
139  void setCubicLaw(bool cubicLaw) { _cubicLaw = cubicLaw; }
140 
142  virtual bool getCubicLaw() const { return _cubicLaw; }
143 
145  void setMultiPhasic(bool multiPhasic) { _multiPhasic = multiPhasic; }
146 
148  virtual bool getMultiPhasic() const { return _multiPhasic; }
149 
151  void setNonIsoThermal(bool nonIsoThermal) { _nonIsoThermal = nonIsoThermal; }
152 
154  virtual bool getNonIsoThermal() const { return _nonIsoThermal; }
155 
157  void setSaturationRelativePermeabilityModel(char nonIsoThermal) { _SaRelPer = nonIsoThermal; }
158 
160  virtual bool getSaturationRelativePermeabilityModel() const { return _SaRelPer; }
161 
163  virtual QList<int> getNodeTopologicalMap(int i) const { return _nodeTopologicalMap.at(i); }
164 
166  virtual void addNodeTopologicalMap(QList<int> eCI) { _nodeTopologicalMap.append(eCI); }
167 
169  virtual QList<int> getElemTopologicalMap(int i) const { return _elemTopologicalMap.at(i); }
170 
172  virtual void addElemTopologicalMap(QList<int> eCI) { _elemTopologicalMap.append(eCI); }
173 
175  virtual QList<QPair<int, QList<int>>> getfaceTopologicalMap(int i) const { return _faceTopologicalMap.at(i); }
176 
178  virtual void addFaceTopologicalMap(QList<QPair<int, QList<int>>> eCI) { _faceTopologicalMap.append(eCI); }
179 
180 
181 protected:
183 
184  virtual void clearXfemData();
185 
186 private:
191  QStringList _nodeStateVarIds; // list with the state variable ids in the model
192  bool _cubicLaw; // Boolean to define whether cubic law or constant fracture permeability is used
193  bool _multiPhasic; // Boolean to define whether multiphasic analysis is carried out
194  bool _nonIsoThermal; // Boolean to define whether non-isothermal analysis is carried out
195  char _SaRelPer; // Char defining the Saturation and Relative Permeability Model
196  QList<QList<int>> _nodeTopologicalMap;// Node list with element id who contain them
197  QList<QList<int>> _elemTopologicalMap;// list of element neighbors with element id who contain them
198  QList<QList<QPair<int, QList<int>>>>_faceTopologicalMap;// list of element neighbors for each face of the element
199 };
200 
201 
202 
208 
209 
215 {
216 public:
217  XfemGemaMesh(GmSimulationData* simulation, QString id, QString description, const GmLogCategory& logger)
218  : XfemGemaMeshBase(simulation, id, description, logger) {}
219 
220  // Comments on the base class
221  virtual const char* pluginName() const { return "Xfem"; }
222 
223  // Comments on the base class
224  virtual const char* pluginType() const { return "mesh"; }
225 
226  // Comments on the base class
227  virtual bool hasCapability(QString capabilityName) const
228  {
229  if(capabilityName == "stateDump")
230  return false;
231  return (capabilityName == "enrichment") || XfemGemaMeshBase::hasCapability(capabilityName);
232  }
233 
234  // Comments on the base class
235  virtual void pushProxy(lua_State* L, const GmLogCategory& logger) { LuaProxy::pushObject(L, new XfemLuaMesh(this, logger)); }
236 
237  virtual void clear();
238 
239  virtual GmpGemaMeshData<XfemVector>* theNodeData() { return &_nd; }
240  virtual GmpGemaCellMeshData<XfemVector>* theCellData() { return &_cd; }
241 
242 protected:
243 
245  virtual GmpMeshLoader<XfemVector>* meshLoader() { return new XfemMeshLoader(simulationData(), logger()); }
246 
252  virtual GmpMeshLoaderCellAllocator cellAllocator(bool ghostSupport, bool hSupport) const
253  {
254  Q_UNUSED(ghostSupport); Q_UNUSED(hSupport);
255  assert(!hSupport); // No support for XFEM hierarchical elements!!!!
256 
257  return GmpCellFactory<XfemGemaElement, XfemElement, XfemLuaElement, GmpGemaCellMeshData<XfemVector>>;
258  }
259 
260 #ifdef ENABLE_TESTS
261  friend Q_DECL_EXPORT XfemMesh* TEST_XfemBuildTestMesh(GmSimulationData*, const GmLogCategory&);
262 #endif
263 };
264 
265 
266 #endif
267 
The XfemGaussAccessor class is a proxy object to a value accesor implementing a more convenient inter...
Definition: xfemGaussAccessor.h:40
void clear()
void setNonIsoThermal(bool nonIsoThermal)
Set the nonIsoThermal Boolean to define whether nonIsoThermal analysis is carried out.
Definition: xfemMesh.h:151
virtual QString getNodeStateVarIds(int id) const
Returns the list with the state variable ids in the model.
Definition: xfemMesh.h:127
virtual void clearSubElements()
Clears all subelements from the mesh. This will automatically clear element integration rules and dat...
Definition: xfemMesh.cpp:140
virtual void addNodeTopologicalMap(QList< int > eCI)
Adds the list of element id who contain the node i.
Definition: xfemMesh.h:166
virtual XfemElement * element(int index)
Returns a mesh cell already converted to an XfemElement. Non const version.
Definition: xfemMesh.h:62
QList< GmVector > _elemCutInfo
vector with element information {iElem, # of fractures per element}
Definition: xfemMesh.h:189
virtual bool getMultiPhasic() const
Returns the Boolean to define whether multiPhasic analysis is carried out.
Definition: xfemMesh.h:148
GmCell *(* GmpMeshLoaderCellAllocator)(GmCellMesh *mesh, int meshId, GmCellType type, int hindex, int id, int offset)
virtual bool getSaturationRelativePermeabilityModel() const
Returns the Char defining the Saturation and Relative Permeability Model.
Definition: xfemMesh.h:160
XfemMesh(GmSimulationData *simulation, QString id, QString description, const GmLogCategory &logger)
Constructor. Will be called by the plugin loading code.
Definition: xfemMesh.cpp:44
void setMultiPhasic(bool multiPhasic)
Set the multiPhasic Boolean to define whether multiPhasic analysis is carried out.
Definition: xfemMesh.h:145
virtual int sizeTotalNumDOF()
Returns the size of elemCutInfo list.
Definition: xfemMesh.h:124
virtual int addSubElement(XfemElement *e, XfemSubElement *se, int ruleSet=0)
Adds a new sub-element to the xfem element. This addition will automatically trigger an update in the...
Definition: xfemMesh.cpp:207
QList< int > _totalDofSet
list with the total number of DOF in the model
Definition: xfemMesh.h:190
const T & at(int i) const const
void setSaturationRelativePermeabilityModel(char nonIsoThermal)
Set the Char defining the Saturation and Relative Permeability Model.
Definition: xfemMesh.h:157
virtual bool enrichElement(XfemElement *e)
Marks the given element as enriched.
Definition: xfemMesh.cpp:66
virtual void addNaturalFracture(XfemFracture *f)
Adds a new natural fracture to the mesh. The mesh takes ownership of the fracture object.
Definition: xfemMesh.h:97
const GmIntegrationRule * enrichedElementRegularIntegrationRule(const XfemElement *e, int ruleSet) const
Returns the elements regular integration rule with support for enriched elements.
Definition: xfemMesh.cpp:321
virtual void printValues(const GmLogCategory &logger, int options)
Overrides printValues to add subelement information.
Definition: xfemMesh.cpp:378
virtual int sizeNodeStateVarIds() const
Returns the size of list with the state variable ids in the model.
Definition: xfemMesh.h:136
virtual ~XfemMesh()
Destructor.
Definition: xfemMesh.cpp:50
int size() const const
Basic interface for an XFEM element.
Definition: xfemElement.h:43
virtual void addElemTopologicalMap(QList< int > eCI)
Adds the list of element neighborns of element id who contain the node i.
Definition: xfemMesh.h:172
const GmIntegrationRule * enrichedElementFractureIntegrationRule(const XfemSubElement *se, int ruleSet) const
Returns the integration rule for the given fracture sub-element.
Definition: xfemMesh.cpp:336
virtual void updateSubElementCoordinates(XfemElement *e, int index, const GmMatrix &seNaturalCoords, int ruleSet=0)
Updates the set of natural coordinates from a sub-element, provided that the sub-element type remains...
Definition: xfemMesh.cpp:296
QList< XfemFracture * > _naturalFractures
The set of mesh natural fractures.
Definition: xfemMesh.h:188
Declaration of the XfemLuaMesh class.
virtual int sizeElemCutInfo()
Returns the size of elemCutInfo list.
Definition: xfemMesh.h:112
Basic class for a XFEM mesh. This is the basic mesh interface for xfem problems adding enrichment cap...
Definition: xfemMesh.h:49
virtual void deleteTotalNumDOF()
delete element cut information
Definition: xfemMesh.h:121
void append(const T &value)
virtual XfemEnrichedElementData * enrichedElementData(const XfemElement *e) const
Returns the enriched element private data or NULL if the element has not been enriched.
Definition: xfemMesh.cpp:85
virtual QList< int > getElemTopologicalMap(int i) const
Returns the list of element neighborns of element id who contain the node i.
Definition: xfemMesh.h:169
virtual QList< int > getNodeTopologicalMap(int i) const
Returns the list of element id who contain the node i.
Definition: xfemMesh.h:163
#define XfemVector
XfemVector is a define and not an "using" clause to avoid linking errors arising from instancing Gema...
Definition: xfemConfig.h:43
A simple class to represent a natural fracture.
Definition: xfemFracture.h:34
A special integration rule for handling refined xfem elements.
Definition: xfemIntegrationRule.h:37
virtual GmpMeshLoader< XfemVector > * meshLoader()
Returns the custom mesh loader used to load XFem mesh data. This function should be replaced for usin...
Definition: xfemMesh.h:245
virtual const XfemSubElement * fractureSubElement(const XfemElement *e, int index) const
Returns a fracture sub-element with an indexing starting from zero for the first fracture sub-element...
Definition: xfemMesh.cpp:129
virtual int numRegularSubElements(const XfemElement *e) const
Returns the number of regular (non fracture) sub-elements of the given enriched element (0 for non en...
Definition: xfemMesh.cpp:92
virtual void clearXfemData()
Clears Xfem related data from the mesh.
Definition: xfemMesh.cpp:412
virtual QList< QPair< int, QList< int > > > getfaceTopologicalMap(int i) const
Returns the list of neighborn element for each face of the element i.
Definition: xfemMesh.h:175
Declaration of the XfemMeshLoader class.
virtual const QList< XfemFracture * > & naturalFractures() const
Returns the list of mesh natural fractures.
Definition: xfemMesh.h:94
virtual int numFractureSubElements(const XfemElement *e) const
Returns the number of fracture sub-elements of the given enriched element (0 for non enriched ones)
Definition: xfemMesh.cpp:100
virtual void addFaceTopologicalMap(QList< QPair< int, QList< int >>> eCI)
Adds the list of neighborn element for each face of the element i.
Definition: xfemMesh.h:178
virtual GmGaussValueSet * createGaussValueSet(GmValueInfo *info)
Overrides the standard GmElementMesh::createGaussValueSet() implementation to create XfemMGaussValueS...
Definition: xfemMesh.cpp:372
virtual void addNodeStateVarIds(QStringList eCI)
Adds list with the state variable ids in the model.
Definition: xfemMesh.h:130
virtual GmVector getElemCutInfo(int id) const
Returns the list with element information {iElem, # of fractures per element}.
Definition: xfemMesh.h:103
Declaration of the XfemGaussAccessor class.
virtual void addElemCutInfo(QList< GmVector > eCI)
Adds a vector with element cut information.
Definition: xfemMesh.h:106
virtual int getTotalNumDOF(int id) const
Returns the list with the total number of DOF at a specific position.
Definition: xfemMesh.h:115
virtual bool getNonIsoThermal() const
Returns the Boolean to define whether nonIsoThermal analysis is carried out.
Definition: xfemMesh.h:154
virtual const XfemSubElement * subElement(const XfemElement *e, int index) const
Returns a subelement of an enriched element.
Definition: xfemMesh.cpp:117
virtual void deleteElemCutInfo()
delete element cut information
Definition: xfemMesh.h:109
virtual void removeSubElement(XfemElement *e, int index)
Removes an existing sub-element from the enriched element. This removal will automatically trigger an...
Definition: xfemMesh.cpp:250
virtual void addTotalNumDOF(QList< int > eCI)
Adds a the list with the total number of DOF.
Definition: xfemMesh.h:118
A class used to represent an enriched element subelement, defining an integration region inside the e...
Definition: xfemSubElement.h:38
Class responsible for loading mesh data for an XFem mesh.
Definition: xfemMeshLoader.h:37
virtual void clearNaturalFractures()
Remove all natural fractures from the mesh.
Definition: xfemMesh.cpp:185
A proxy class to export XfemMesh methods to the Lua environment.
Definition: xfemLuaMesh.h:32
const QMap< int, XfemEnrichedElementData * > & enrichedElementMap() const
Returns the map storing data for every enriched element in the mesh. Use carefully.
Definition: xfemMesh.h:69
static void pushObject(lua_State *L, Base *obj)
Declaration of the XfemElement class.
Declaration of the XfemLuaElement class.
void setCubicLaw(bool cubicLaw)
Set the cubic Law Boolean to define whether cubic law or constant fracture permeability is used.
Definition: xfemMesh.h:139
virtual XfemGaussAccessor * enrichedGaussAttributeAccessor(QString id, Unit desiredUnit, const GmLogCategory &logger) const
Equivalent to call enrichedGaussAttributeAccessor(id, 0, true, desiredUnit, logger)
Definition: xfemMesh.h:86
arma::vec GmVector
A class used to store per element data needed only in enriched elements.
Definition: xfemEnrichedElementData.h:37
virtual void deleteNodeStateVarIds()
delete list with the state variable ids in the model
Definition: xfemMesh.h:133
arma::mat GmMatrix
GmpCellMeshBase< XfemMesh, GmpGemaMeshCoordAccessor< GmpGemaMeshData< XfemVector >, XfemVector >, GmpGemaMeshGhostCoordAccessor< GmpMeshData< XfemVector >, XfemVector >, GmpGemaMeshData< XfemVector >, GmpGemaCellMeshData< XfemVector >, XfemVector > XfemGemaMeshBase
Aux typedef for defining the base class for the XfemGemaMesh class.
Definition: xfemMesh.h:207
QMap< int, XfemEnrichedElementData * > _elementMap
Map storing individual data for enriched elements.
Definition: xfemMesh.h:187
Implementation of the XfemMesh interface based on the standard GeMA mesh plugin.
Definition: xfemMesh.h:214
virtual const XfemElement * element(int index) const
Returns a mesh cell already converted to an XfemElement.
Definition: xfemMesh.h:59
virtual GmpMeshLoaderCellAllocator cellAllocator(bool ghostSupport, bool hSupport) const
Returns the function responsible for allocating and initializing a new XFEM element.
Definition: xfemMesh.h:252
virtual bool getCubicLaw() const
Returns the Boolean to define whether cubic law or constant fracture permeability is used.
Definition: xfemMesh.h:142