NeoPZ
TPZRefPattern.h
Go to the documentation of this file.
1 
5 #ifndef PZREFPATTERNH
6 #define PZREFPATTERNH
7 
8 #include "pzvec.h"
9 #include "pztrnsform.h"
10 #include "pzgeoelside.h"
11 #include "pzgmesh.h"
12 #include "tpzpermutation.h"
13 
14 // #include <iostream>
15 // #include <string>
16 // #include <map>
17 // #include <list>
18 // #include <set>
19 // #include "TPZRefPatternDataBase.h"
20 // #include "TPZRefPatternTools.h"
21 
22 // class TPZGeoNode;
23 // class TPZCompMesh;
24 // //class TPZGeoElBC;
25 // class TPZGeoEl;
26 // class TPZGeoElSideIndex;
27 // class TPZGeoElSide;
28 
29 // /** \addtogroup refine
30 // @{
31 // */
32 // /// Id for non initialized pattern
33 // const int nonInitializedId = -50;
34 // /// Name for non initialized pattern
35 // const std::string nonInitializedName = "noname";
36 
77 class TPZRefPattern : public TPZSavable {
78 protected:
80  static const int fNonInitializedId;
82  static const std::string fNonInitializedName;
91 
100  SPZFatherSideInfo(const TPZVec<int> &sideNodes,
101  const TPZVec<TPZGeoElSide> &sideSons,
102  const int64_t &midSideIndex) :
103  fSideNodes(sideNodes), fSideSons(sideSons) {}
104  SPZFatherSideInfo() = default;
105  SPZFatherSideInfo(const SPZFatherSideInfo &) = default;
106  void Read(TPZStream &buf, void *context);
107 
108  void Write(TPZStream &buf, int withclassid) const;
109  ~SPZFatherSideInfo() = default;
110  };
116 
117 
118 
121  std::string fName;
122 
124  int fId;
125 
131 
138 
143 
147  int fNSubEl;
148 
149 
152  public:
155 
159  TPZRefPatternPermute(): fPermute(0)
160  {}
162  TPZRefPatternPermute(const TPZRefPatternPermute &copy) : fPermute(copy.fPermute), fTransform(copy.fTransform)
163  {
164  }
167  {
168  fPermute = copy.fPermute;
169  fTransform = copy.fTransform;
170  return *this;
171  }
172  int ClassId() const override;
173  void Read(TPZStream &buf, void *context) override;
174  void Write(TPZStream &buf, int withclassid) const override;
175  };
176 
180  static std::map<MElementType, std::list<TPZRefPatternPermute> > fPermutations;
181 
182 
183  friend class
186  friend class
188 
193  int FindSubEl(TPZGeoEl *) const;
194 
200  bool CheckSideConsistency(const int fatherSide) const;
201 
208  bool CheckSideAndSubElConsistency(const int fatherSide, const int subEl) const;
209 
214 
218  void GeneratePermutations(TPZGeoEl *gel);
219 
223  void ComputeTransforms();
224 
228  void ComputePartition();
229 
233  void BuildSideMesh(int side, TPZGeoMesh &SideRefPatternMesh);
234 
235  void BuildName();
236 
240  void PermuteMesh(const TPZPermutation &permute);
241 
246  void ReadAndCreateRefinementPattern(std::istream &file);
247 
253 
263  TPZTransform<> ComputeParamTransform(TPZGeoEl *geoElFrom, TPZGeoEl *geoElTo, int sideFrom, int sideTo);
264 public:
265 
266  TPZRefPattern();
271  TPZRefPattern(std::istream &file);
272 
277  TPZRefPattern(const std::string &file);
278 
282  TPZRefPattern(const TPZRefPattern &copy);
283 
290  explicit TPZRefPattern(TPZGeoMesh &gmesh);
291 
295  TPZRefPattern(const TPZRefPattern &copy, const TPZPermutation &permute);
296 
297  int operator==(const TPZAutoPointer<TPZRefPattern> compare) const;
298 
299  virtual ~TPZRefPattern() = default;
300 
305  void PrintMore(std::ostream &out = std::cout) const;
306 
307  void ShortPrint(std::ostream &out = std::cout) const;
308 
312  void Print(std::ostream &out = std::cout) const;
313 
314  void PrintVTK(std::ofstream &file, bool matColor = false) const;
315 
320  void ExportPattern(std::ostream &out) const;
321 
322  void WritePattern(std::ofstream &out) const;
323 
324  int ClassId() const override;
325 
326  void Read(TPZStream &buf, void *context) override;
327 
328  void Write(TPZStream &buf, int withclassid) const override;
329 
334  int NSubElements() const;
341  int FatherSide(int side, int sub) const;
342 
343 
347  int NSideSubGeoElSides(int fatherSide) const;
354  void SideSubGeoElSide(int fatherSide, int subElPos, TPZGeoElSide & subGeoEl) const;
355 
361  TPZTransform<> Transform(int subElSide, int sub);
362 
368  void SideNodes(int fatherSide, TPZVec<int> &vecNodes);
369 
373  int NSideNodes(int fatherSide) const;
374 
378  int NNodes() const;
379 
385  bool IsFatherNeighbour(TPZGeoElSide fatherSide,TPZGeoEl *son) const;
386 
391  TPZGeoEl *Element(int iel);
392 
393  /*
394  * @brief Fill a vector with TPZGeoElSideIndex_s with respect to internal
395  * subelements of zero dimension of a given side
396  * @param side - side of father element that will be searched for internal nodes (generated from subelements)
397  * @param nodeIndexes - vector of subelements index/Sides (stored as TPZGeoElSideIndex objects that have dimension = 0) that
398  * belongs to the interior of given side of father element.
399  */
400  void InternalNodesIndexes(int side, TPZVec<TPZGeoElSideIndex> &nodeIndexes);
401 
407  void InternalSidesIndexes(int side, TPZVec<TPZGeoElSideIndex> &sideIndexes);
408 
412  int Id() const{
413  return fId;
414  }
415 
420  bool IdInitialized(){
421  return (fId != fNonInitializedId);
422  }
423 
427  void SetId(int id) {
428  fId = id;
429 
430  TPZGeoEl *el = fRefPatternMesh.ElementVec()[0];
431  int nSides = el->NSides();
432  fSideRefPattern[nSides - 1] = id;
433  }
434 
435  bool NameInitialized(){
436  return (fName != fNonInitializedName);
437  }
438 
443  void SetName(std::string name){
444  fName = name;
445  }
446 
450  std::string Name(){
451  return fName;
452  }
460  int SidePartition(TPZVec<TPZGeoElSide> &gelvec, int side);
461 
469  void CreateNewNodes(TPZGeoEl *gel, TPZVec<int64_t> &newnodeindexes);
470 
480  void CreateMidSideNodes(TPZGeoEl *gel, int side, TPZVec<int64_t> &newnodeindexes);
481 
483 
488 
492  void InsertPermuted();
497 
499 
501  return fRefPatternMesh;
502  }
503 
504  MElementType Type(){
505  return Element(0)->Type();
506  }
507 };
508 
511 #endif
void PermuteMesh(const TPZPermutation &permute)
Copy the mesh structure applying the permutation on the nodenumbers of the first element.
TPZVec< TPZVec< std::pair< int, TPZTransform< REAL > > > > fSubElSideInfo
Data structure with sub element info.
Definition: TPZRefPattern.h:90
bool CheckSideConsistency(const int fatherSide) const
TPZVec< TPZGeoElSide > fSideSons
a vector of TPZGeoElSide relative to its sons
Definition: TPZRefPattern.h:99
TPZVec< int > fSideRefPattern
Refinement for elements associated with a certain side of the current element. Usually, this is used for boundary/interface elements.
TPZRefPatternPermute & operator=(const TPZRefPatternPermute &copy)
Contains declaration of TPZGeoElSide class which represents an element and its side, and TPZGeoElSideIndex class which represents an TPZGeoElSide index.
TPZRefPatternPermute()
Default constructor.
void ExportPattern(std::ostream &out) const
void ReadAndCreateRefinementPattern(std::istream &file)
static const int fNonInitializedId
Id for identifying a non initialized pattern.
Definition: TPZRefPattern.h:80
TPZRefPatternPermute(const TPZRefPatternPermute &copy)
Copy constructor.
bool IsFatherNeighbour(TPZGeoElSide fatherSide, TPZGeoEl *son) const
Verifies the neighbouring relationship between a son and a father&#39;s side.
TPZTransform fTransform
Transformation to the nodes.
MElementType Type()
TPZTransform ComputeParamTransform(TPZGeoEl *geoElFrom, TPZGeoEl *geoElTo, int sideFrom, int sideTo)
Templated vector implementation.
TPZGeoEl * Element(int iel)
It returns the element number iel from the stack of elements of the geometric mesh.
Contains declaration of the TPZPermutation class which generates all permutations of n values...
void SetId(int id)
Set the id of the refinement pattern.
void InsertPermuted()
Generate all permuted partitions and insert them in the mesh.
int operator==(const TPZAutoPointer< TPZRefPattern > compare) const
Utility class which represents an element with its side. The Geometric approximation classes Geometry...
Definition: pzgeoelside.h:83
TPZAutoPointer< TPZRefPattern > FindRefPattern(TPZTransform<> &trans)
This class implements a simple vector storage scheme for a templated class T. Utility.
Definition: pzgeopoint.h:19
virtual int NSides() const =0
Returns the number of connectivities of the element.
TPZTransform Transform(int subElSide, int sub)
It returns the TPZTransform associated with a certain sub-element&#39;s side to the father&#39;s coordinates...
void SetRefPatternMeshToMasterDomain()
Sets the RefPatternMesh in (x,y,z)_coordinates to (qsi,eta,zeta)_coordinates, always respecting the R...
void InternalNodesIndexes(int side, TPZVec< TPZGeoElSideIndex > &nodeIndexes)
TPZGeoMesh fRefPatternMesh
Geometric mesh which defines the topology of the current refinement pattern.
void CreateMidSideNodes(TPZGeoEl *gel, int side, TPZVec< int64_t > &newnodeindexes)
This method is used to create / identify the midside nodes for element elindex in its division proces...
Data structure for storage of refinement information for a father&#39;s side.
Definition: TPZRefPattern.h:95
int SidePartition(TPZVec< TPZGeoElSide > &gelvec, int side)
It returns a stack from sub-elements and its sides. This stack partitions side of the element father...
TPZAutoPointer< TPZRefPattern > SideRefPattern(int side)
void CreateNewNodes(TPZGeoEl *gel, TPZVec< int64_t > &newnodeindexes)
This method is used to create / identify the nodes of the refined elements.
bool NameInitialized()
void PrintVTK(std::ofstream &file, bool matColor=false) const
bool CheckSideAndSubElConsistency(const int fatherSide, const int subEl) const
Contains declaration of TPZMesh class which defines a geometrical mesh and contains a corresponding l...
void InternalSidesIndexes(int side, TPZVec< TPZGeoElSideIndex > &sideIndexes)
Fill a vector with TPZGeoElSideIndex_s with respect to internal subelements of a given side...
bool IdInitialized()
friend class TPZRefPatternDataBase
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
Definition: pzgeoel.h:43
int Id() const
Return the id of the refinement pattern.
virtual ~TPZRefPattern()=default
int FatherSide(int side, int sub) const
Returns the father side associated with a given side of a certain sub element.
int FindSubEl(TPZGeoEl *) const
void BuildSideMesh(int side, TPZGeoMesh &SideRefPatternMesh)
Build a geometric mesh associated with the side of the refinement pattern.
int fNSubEl
Number of subelements. Must be available before the mesh is generated.
virtual MElementType Type() const =0
Returns the element type acording to pzeltype.h.
std::string fName
Auxiliar structure to permute nodes.
void SideNodes(int fatherSide, TPZVec< int > &vecNodes)
It returns a TPZVec containing the nodes contained in a given father&#39;s side.
void Read(TPZStream &buf, void *context)
void SideSubGeoElSide(int fatherSide, int subElPos, TPZGeoElSide &subGeoEl) const
Gives information about the ith subelement contained in a given father&#39;s side.
static std::map< MElementType, std::list< TPZRefPatternPermute > > fPermutations
Map of all valid permutations.
SPZFatherSideInfo(const TPZVec< int > &sideNodes, const TPZVec< TPZGeoElSide > &sideSons, const int64_t &midSideIndex)
int NSideNodes(int fatherSide) const
Returns the number of internal nodes of side.
TPZVec< SPZFatherSideInfo > fFatherSideInfo
Data structure for storage of refinement information for each father&#39;s side fFatherSideInfo[i] will ...
std::string Name()
Returns the refinement pattern identifier.
int NSideSubGeoElSides(int fatherSide) const
Returns the number of TPZGeoElSides associated with a father&#39;s side.
int fId
id of the refinement pattern
Defines the topology of the current refinement pattern to a mesh. Refine.
Definition: TPZRefPattern.h:77
TPZVec< int > fSideNodes
a vector of nodes contained in the i-th side
Definition: TPZRefPattern.h:97
int NSubElements() const
This class implements a geometric mesh for the pz environment. Geometry.
Definition: pzgmesh.h:48
MElementType
Define the element types.
Definition: pzeltype.h:52
TPZGeoMesh & RefPatternMesh()
void Print(std::ostream &out=std::cout) const
Prints the useful information of a Refinement Pattern in a ostream file.
void SetName(std::string name)
Sets the name associated with the refinement pattern.
void PrintMore(std::ostream &out=std::cout) const
static const std::string fNonInitializedName
Name for identifying a non initialized pattern.
Definition: TPZRefPattern.h:82
void ComputeTransforms()
Calculates the transforms between the parametric coordinates of the sides of the son to the father&#39;s ...
void Write(TPZStream &buf, int withclassid) const
TPZVec< int > fPermutedRefPatterns
Vector containing refinement patterns for each permutation of the master element. ...
Contains the TPZTransform<> class which implements an affine transformation between points in paramet...
void GeneratePermutations(TPZGeoEl *gel)
Automatically generate all permuted numberings for the father element of RefPatternMesh.
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
void WritePattern(std::ofstream &out) const
Implements an affine transformation between points in parameter space. Topology Utility.
Definition: pzmganalysis.h:14
void GenerateSideRefPatterns()
Generate the refinement patterns associated with the sides of the father element. ...
This class defines the interface to save and restore objects from TPZStream objects. Persistency.
Definition: TPZSavable.h:67
void ShortPrint(std::ostream &out=std::cout) const
This class generates all permutations of n values. Utility.
friend class TPZRefPatternTools
void ComputePartition()
It computers the partition of the sides of the father element using the sides of the children...
void CreateRefinementPattern()
TPZPermutation fPermute
permutation of the nodes
TPZAdmChunkVector< TPZGeoEl * > & ElementVec()
Methods for handling pzlists.
Definition: pzgmesh.h:138
int ClassId() const override
Define the class id associated with the class.
int NNodes() const
Returns the number of nodes of the mesh.