NeoPZ
TPZMHMeshControl.h
Go to the documentation of this file.
1 //
2 // TPZMHMeshControl.h
3 // PZ
4 //
5 // Created by Philippe Devloo on 5/3/14.
6 //
7 //
8 
9 #ifndef __PZ__TPZMHMeshControl__
10 #define __PZ__TPZMHMeshControl__
11 
12 #include <iostream>
13 
14 #include "pzgmesh.h"
15 #include "pzcmesh.h"
16 #include "pzcompel.h"
17 
20 {
21 
22 public:
23 
26 
27 protected:
30 
33 
36 
39 
41  // this mesh is the same as fCMesh if there are no lagrange multipliers assocated with the average pressure
43 
46 
48  int fNState = 1;
49 
50 public:
52  int fSkeletonMatId = 4;
53 
56 
59 
62 
64  std::set<int> fMaterialIds;
65 
67  std::set<int> fMaterialBCIds;
68 
69 protected:
70 
72  int fpOrderInternal = 1;
73 
75  int fpOrderSkeleton = 1;
76 
77  //internal order for enrichement spaces
78 
79  int fHdivmaismais = 0;
80 
82  int fSkeletonWrapMatId = 500;
83 
85  int fBoundaryWrapMatId = 502;
86 
88  int fInternalWrapMatId = 501;
89 
92 
94  std::map<int64_t,int64_t> fMHMtoSubCMesh;
95 
97  // if fInterfaces[index].second == index, then the skeleton is boundary skeleton
98  std::map<int64_t, std::pair<int64_t,int64_t> > fInterfaces;
99 
101  std::map<TPZCompMesh *,TPZManVector<int64_t> > fConnectToSubDomainIdentifier;
102 
104 
108 
110  bool fHybridize = false;
111 
113  bool fSwitchLagrangeSign = false;
114 
115 public:
118 
121 
123  int64_t fNumeq;
124 public:
125  TPZMHMeshControl() : fProblemType(EScalar), fNState(1), fGeoToMHMDomain(), fMHMtoSubCMesh(),
126  fLagrangeAveragePressure(false),
127  fHybridize(false), fSwitchLagrangeSign(false), fGlobalSystemSize(-1), fGlobalSystemWithLocalCondensationSize(-1), fNumeq(-1)
128  {
129 
130  }
131 
132  TPZMHMeshControl(int dimension) : fProblemType(EScalar), fNState(1), fGeoToMHMDomain(), fMHMtoSubCMesh(),
133  fLagrangeAveragePressure(false),
134  fHybridize(false), fSwitchLagrangeSign(false), fGlobalSystemSize(-1), fGlobalSystemWithLocalCondensationSize(-1), fNumeq(-1)
135  {
136  fGMesh = new TPZGeoMesh;
137  fGMesh->SetDimension(dimension);
138  fCMesh = new TPZCompMesh(fGMesh);
139  fPressureFineMesh = new TPZCompMesh(fGMesh);
140  }
141 
143  // TPZMHMeshControl(TPZAutoPointer<TPZGeoMesh> gmesh, std::set<int64_t> &coarseindices);
144 
146 
149 
150  TPZMHMeshControl(const TPZMHMeshControl &copy);
151 
152  virtual ~TPZMHMeshControl();
153 
155 
157  {
158  return fCMesh;
159  }
160 
162  {
163  return fGMesh;
164  }
165 
167  {
168  return fPressureFineMesh;
169  }
170 
172  void DefinePartitionbyCoarseIndices(TPZVec<int64_t> &coarseindices);
173 
174  void DefineSkeleton(std::map<int64_t,std::pair<int64_t,int64_t> > &skeleton)
175  {
176  fInterfaces = skeleton;
177 #ifdef PZDEBUG
178  // the skeleton elements link MHM domain indices (which need to exist)
179  for (auto it = fInterfaces.begin(); it != fInterfaces.end(); it++) {
180  if (fMHMtoSubCMesh.find(it->second.first) == fMHMtoSubCMesh.end()) {
181  DebugStop();
182  }
183  if (it->second.second != it->first && fMHMtoSubCMesh.find(it->second.second) == fMHMtoSubCMesh.end()) {
184  DebugStop();
185  }
186  }
187 #endif
188  }
189 
191  void DefinePartition(TPZVec<int64_t> &partitionindex, std::map<int64_t,std::pair<int64_t,int64_t> > &skeleton);
192 
194  // This method calculates the skeleton indexes
195  void DefinePartition(TPZVec<int64_t> &partitionindex);
196 
199  {
200  fProblemType = problem;
201  switch(problem)
202  {
203  case EScalar:
204  fNState = 1;
205  break;
206  case EElasticity2D:
207  fNState = 2;
208  break;
209  case EElasticity3D:
210  fNState = 3;
211  break;
212  default:
213  DebugStop();
214  }
215  }
217  void SetInternalPOrder(int order)
218  {
219  fpOrderInternal = order;
220  if(fCMesh) fCMesh->SetDefaultOrder(order);
221  }
222 
223  void SetSkeletonPOrder(int order)
224  {
225  fpOrderSkeleton = order;
226  }
227 
228 
229  void SetHdivmaismaisPOrder(int order)
230  {
231  fHdivmaismais = order;
232  }
233 
234 
237  {
238  fLagrangeAveragePressure = flag;
239  }
240 
242  virtual void SetHybridize(bool flag = true)
243  {
244  fHybridize = flag;
245  }
246 
247  virtual bool GetHybridize() {
248  return fHybridize;
249  }
251  virtual void BuildComputationalMesh(bool usersubstructure);
252 
253 protected:
255  virtual void CreateSkeletonElements();
256 
258  virtual void InsertPeriferalMaterialObjects();
259 public:
261  void DivideSkeletonElements(int ndivide);
262 
265 
268  {
269  fSwitchLagrangeSign = sw;
270  }
271 
273  void Print(std::ostream &out);
274 
276  void PrintDiagnostics(std::ostream &out);
277 
280  {
281  if (fCMeshLagrange)
282  {
283  meshvec.Resize(3);
284  meshvec[0] = fPressureFineMesh.operator->();
285  meshvec[1] = fCMeshLagrange.operator->();
286  meshvec[2] = fCMeshConstantPressure.operator->();
287  }
288  else
289  {
290  meshvec.resize(0);
291  }
292  }
293 
295  {
297  if (fCMeshLagrange)
298  {
299  result.Resize(3);
300  result[0] = fPressureFineMesh;
301  result[1] = fCMeshLagrange;
302  result[2] = fCMeshConstantPressure;
303  }
304  else
305  {
306  result.resize(0);
307  }
308  return result;
309  }
310 
312  return fGeoToMHMDomain;
313  }
314 
316  std::map<int64_t,int64_t> &Coarse_to_Submesh()
317  {
318  return fMHMtoSubCMesh;
319  }
320 
322  // only implemented in the hybrid Hdiv version
323  virtual void CheckMeshConsistency()
324  {
325 
326  }
327 
328 protected:
331 
333  void CreateInternalElements();
334 
336  void AddBoundaryElements();
337 
340 
342  void CreateSkeleton();
343 
347 
350  virtual void HybridizeSkeleton(int skeletonmatid, int pressurematid);
351 
353  bool IsSibling(int64_t son, int64_t father);
354 
356  void AddElementBoundaries(int64_t elseed, int64_t compelindex, TPZStack<TPZCompElSide> &result);
357 
359  void TransferToMultiphysics();
360 
362  void SubStructure();
363  void SubStructure2();
364 
366  void BuildWrapMesh(int dim);
367 
369  int HasWrapNeighbour(TPZGeoElSide gelside);
370 
374 
376  int WrapMaterialId(TPZGeoElSide gelside);
377 
379  virtual bool IsSkeletonMatid(int matid)
380  {
381  return matid == fSkeletonMatId;
382  }
383 
385  virtual bool IsBoundaryMatid(int matid)
386  {
387  return fMaterialBCIds.find(matid) != fMaterialBCIds.end();
388  }
389 
391  void CreateWrap(TPZGeoElSide gelside);
392 
394  void CreateWrap(TPZGeoElSide gelside, int wrapmaterial);
395 
397  void DivideWrap(TPZGeoEl *wrapelement);
398 
399 protected:
402 
404  void SetSubdomain(TPZCompEl *cel, int64_t subdomain);
405 
407  void SetSubdomain(TPZCompMesh *cmesh, int64_t connectindex, int64_t subdomain);
408 
410  // this method calls debugstop if the element beint64_ts to two subdomains
411  int64_t WhichSubdomain(TPZCompEl *cel);
412 
414  // the subdomain indices of the connects to the multi physics mesh
415  void JoinSubdomains(TPZVec<TPZCompMesh *> &meshvec, TPZCompMesh *multiphysicsmesh);
416 
418  void PrintSubdomain(int64_t elindex, std::ostream &out);
419 
421  void PrintBoundaryInfo(std::ostream &out);
422 
424  // the computational mesh is determined by the element pointed to by the geometric element
425  void ConnectedElements(int64_t skeleton, std::pair<int64_t,int64_t> &leftright, std::map<int64_t, std::list<TPZCompElSide> > &ellist);
426 
428  // the computational mesh is determined by the element pointed to by the geometric element
429  void ConnectedInterfaceElements(int64_t skeleton, std::pair<int64_t,int64_t> &leftright, std::map<int64_t, std::list<TPZInterfaceElement *> > &ellist);
430 };
431 
432 #endif /* defined(__PZ__TPZMHMeshControl__) */
void CheckDivisionConsistency(TPZGeoElSide gelside)
void AddElementBoundaries(int64_t elseed, int64_t compelindex, TPZStack< TPZCompElSide > &result)
put the element side which face the boundary on the stack
bool fLagrangeAveragePressure
flag to determine whether a lagrange multiplier is included to force zero average pressures in the su...
void ConnectedInterfaceElements(int64_t skeleton, std::pair< int64_t, int64_t > &leftright, std::map< int64_t, std::list< TPZInterfaceElement *> > &ellist)
identify interface elements connected to the skeleton elements
TPZAutoPointer< TPZCompMesh > fCMeshLagrange
computational mesh to represent the distributed flux in each subdomain
TPZAutoPointer< TPZCompMesh > PressureMesh()
MProblemType
Specify the type of differential equation.
TPZAutoPointer< TPZCompMesh > fCMesh
computational MHM mesh being built by this class
bool IsSibling(int64_t son, int64_t father)
verify if the element is a sibling of
TPZVec< TPZAutoPointer< TPZCompMesh > > GetMeshes()
void CreateSkeleton()
will create the elements on the skeleton
void DefineSkeleton(std::map< int64_t, std::pair< int64_t, int64_t > > &skeleton)
virtual void resize(const int64_t newsize)
Definition: pzvec.h:213
TPZManVector< int64_t > GetGeoToMHMDomain()
virtual void SetHybridize(bool flag=true)
Set the hybridization to true.
TPZAutoPointer< TPZGeoMesh > GMesh() const
clarg::argInt dimension("-d", "Matrices dimension M x M", 1000)
virtual bool GetHybridize()
Contains declaration of TPZCompEl class which defines the interface of a computational element...
int fSecondSkeletonMatId
material id associated with the skeleton elements
int fSkeletonMatId
material id associated with the skeleton elements
TPZMHMeshControl & operator=(const TPZMHMeshControl &cp)
int64_t fGlobalSystemSize
number of equations when not condensing anything
void PrintBoundaryInfo(std::ostream &out)
print the indices of the boundary elements and interfaces
void BuildWrapMesh(int dim)
Create the wrap elements.
int64_t WhichSubdomain(TPZCompEl *cel)
returns to which subdomain a given element beint64_ts
std::set< int > fMaterialIds
materials used for modeling the differential equation
bool fHybridize
flag to indicate whether we create a hybridized mesh
std::set< int > fMaterialBCIds
materials for boundary conditions
Utility class which represents an element with its side. The Geometric approximation classes Geometry...
Definition: pzgeoelside.h:83
void DivideBoundarySkeletonElements()
divide the boundary skeleton elements
void DivideSkeletonElements(int ndivide)
divide the skeleton elements
int fpOrderInternal
interpolation order of the internal elements
void DefinePartition(TPZVec< int64_t > &partitionindex, std::map< int64_t, std::pair< int64_t, int64_t > > &skeleton)
Define the partitioning information of the MHM mesh.
int WrapMaterialId(TPZGeoElSide gelside)
Return the wrap material id (depends on being boundary, neighbour of skeleton or interior.
int fSkeletonWrapMatId
material index of the skeleton wrap
std::map< TPZCompMesh *, TPZManVector< int64_t > > fConnectToSubDomainIdentifier
geometric index of the connects - subdomain where the connect will be internal
void CreateInternalElements()
will create the internal elements, one coarse element at a time
void TransferToMultiphysics()
transform the computational mesh into a multiphysics mesh
void SetDimension(int dim)
Set Dimension.
Definition: pzgmesh.h:285
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object.
Definition: pzmanvector.h:426
virtual bool IsSkeletonMatid(int matid)
Return true if the material id is related to a skeleton.
void SetProblemType(MProblemType problem)
Set the problem type of the simulation.
void SetDefaultOrder(int order)
Definition: pzcmesh.h:403
TPZManVector< int64_t > fGeoToMHMDomain
vector of coarse domain index associated with each geometric element
void SetHdivmaismaisPOrder(int order)
int fPressureSkeletonMatId
material id associated with the skeleton elements in a hybrid context
void SetSkeletonPOrder(int order)
std::map< int64_t, int64_t > & Coarse_to_Submesh()
return the coarseindex to submesh index data structure
void SwitchLagrangeMultiplierSign(bool sw)
switch the sign of the lagrange multipliers
int fInternalWrapMatId
material index of the internal wrap
virtual void Resize(const int64_t newsize, const T &object)
Resizes the vector object reallocating the necessary storage, copying the existing objects to the new...
Definition: pzvec.h:373
void CreateInterfaceElements2()
void AddBoundaryInterfaceElements()
Add the boundary interface elements to the computational mesh.
int fLagrangeMatIdLeft
material id associated with the lagrange multiplier elements
Contains declaration of TPZMesh class which defines a geometrical mesh and contains a corresponding l...
virtual void BuildComputationalMesh(bool usersubstructure)
Create all data structures for the computational mesh.
bool fSwitchLagrangeSign
flag to indicate whether the lagrange multipliers should switch signal
void PrintDiagnostics(std::ostream &out)
Print diagnostics.
virtual void CheckMeshConsistency()
verify the consistency of the datastructure
virtual void InsertPeriferalMaterialObjects()
Insert material objects that do not perform any actual computation.
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
Definition: pzgeoel.h:43
void PrintSubdomain(int64_t elindex, std::ostream &out)
print the diagnostics for a subdomain
int fBoundaryWrapMatId
material index of the boundary wrap
#define DebugStop()
Returns a message to user put a breakpoint in.
Definition: pzerror.h:20
void DivideWrap(TPZGeoEl *wrapelement)
Divide the wrap element while it has divided neighbours.
void AddBoundaryElements()
Add the boundary elements to the computational mesh.
void DefinePartitionbyCoarseIndices(TPZVec< int64_t > &coarseindices)
Define the MHM partition by the coarse element indices.
void CreateInterfaceElements()
will create the interface elements between the internal elements and the skeleton ...
void SetInternalPOrder(int order)
Set the porder for the internal elements.
TPZAutoPointer< TPZCompMesh > fCMeshConstantPressure
computational mesh to represent the constant states
void GetMeshVec(TPZVec< TPZCompMesh *> &meshvec)
Put the pointers to the meshes in a vector.
TPZAutoPointer< TPZCompMesh > fPressureFineMesh
computational mesh to contain the pressure elements
std::map< int64_t, int64_t > fMHMtoSubCMesh
indices of the geometric elements which define the skeleton mesh and their corresponding subcmesh ind...
void Print(std::ostream &out)
print the data structure
TPZAutoPointer< TPZGeoMesh > fGMesh
geometric mesh used to create the computational mesh
Contains declaration of TPZCompMesh class which is a repository for computational elements...
virtual void CreateSkeletonElements()
will create dim-1 geometric elements on the interfaces between the coarse element indices ...
void CreateLagrangeMultiplierMesh()
create the lagrange multiplier mesh, one element for each subdomain
void ConnectedElements(int64_t skeleton, std::pair< int64_t, int64_t > &leftright, std::map< int64_t, std::list< TPZCompElSide > > &ellist)
identify connected elements to the skeleton elements
virtual void HybridizeSkeleton(int skeletonmatid, int pressurematid)
int fNState
number of state variables
class oriented towards the creation of multiscale hybrid meshes - YES
void SetSubdomain(TPZCompEl *cel, int64_t subdomain)
associates the connects of an element with a subdomain
int64_t fGlobalSystemWithLocalCondensationSize
number of equations considering local condensation
This class implements a geometric mesh for the pz environment. Geometry.
Definition: pzgmesh.h:48
MProblemType fProblemType
Variable defining the type of problem.
Implements computational mesh. Computational Mesh.
Definition: pzcmesh.h:47
virtual bool IsBoundaryMatid(int matid)
return true if the material id is related to a boundary
TPZCompMesh * CriaMalhaTemporaria()
will create a computational mesh using the coarse element indexes and its interface elements ...
void CreateWrap(TPZGeoElSide gelside)
CreateWrapMesh of a given material id.
TPZAutoPointer< TPZCompMesh > CMesh() const
int fpOrderSkeleton
interpolation order of the skeleton elements
int64_t fNumeq
number of equations of the global system
void JoinSubdomains(TPZVec< TPZCompMesh *> &meshvec, TPZCompMesh *multiphysicsmesh)
Subdomains are identified by computational mesh, this method will join.
std::map< int64_t, std::pair< int64_t, int64_t > > fInterfaces
indices of the skeleton elements and their left/right partition indexes
Defines the interface of a computational element. Computational Element.
Definition: pzcompel.h:59
TPZMHMeshControl(int dimension)
int HasWrapNeighbour(TPZGeoElSide gelside)
Verify if the element side contains a wrap neighbour.
void SubStructure()
substructure the mesh
void SetLagrangeAveragePressure(bool flag)
Set the flag for creating Lagrange Dofs for the average pressure.