NeoPZ
tpzcompmeshreferred.cpp
Go to the documentation of this file.
1 
6 #include "tpzcompmeshreferred.h"
7 #include "pzgmesh.h"
8 #include "pzcompel.h"
9 
10 void TPZCompMeshReferred::Print(std::ostream & out) const {
11  out << __PRETTY_FUNCTION__ << "\n";
12  TPZCompMesh::Print(out);
13  out << "ReferredMesh = " << this->ReferredMesh() << "\n";
14 }//void
15 
19 {
20 }
21 
22 
26 {
27 }
28 
32 {
33 }
34 
36 {
37 }
38 
39 
41 {
43  fReferred = mesh;
44  if(!mesh) return;
45  TPZGeoMesh *gmesh = mesh->Reference();
46  gmesh->ResetReference();
47  mesh->LoadReferences();
48  int64_t iel,nel = NElements();
49  for(iel=0; iel<nel; iel++)
50  {
51  TPZCompEl *cel = fElementVec[iel];
52  fReferredIndices[iel] = -1;
53  if (!cel) continue;
54  TPZGeoEl *gel = cel->Reference();
55  if(!gel)continue;
56  TPZCompEl *cel2 = gel->Reference();
57  if(!cel2) continue;
58  fReferredIndices[iel] = cel2->Index();
59  }
60 }
61 
63 {
65  fReferred = 0;
66 }
67 
69 {
70  if(!fReferred) return 0;
71  int64_t celindex = fReferredIndices[index];
72  if(celindex <0) return 0;
73  TPZCompEl *cel = fReferred->ElementVec()[celindex];
74  return cel;
75 }
76 
78  TPZCompMeshReferred * me = dynamic_cast<TPZCompMeshReferred*>(cmesh);
79  TPZCompMesh * other = NULL;
80  if (me) other = me->ReferredMesh();
81 
82  const int64_t nel2ref = WhichRefine.NElements();
83  TPZVec<TPZCompEl *> Other2Refine(nel2ref, NULL);
84  if (other){
85  for(int64_t i = 0; i < nel2ref; i++){
86  TPZCompEl * cel = WhichRefine[i];
87  if (!cel) continue;
88  Other2Refine[i] = me->ReferredEl(cel->Index());
89  }
90  }
91 
92  TPZGeoMesh * gmesh = me->Reference();
93  gmesh->ResetReference();
94  me->ResetReferred();
95  me->LoadReferences();
96  TPZVec<int64_t> filhos;
97  for ( int64_t iref = 0; iref < nel2ref; iref++ )
98  {
99  TPZCompEl * cel = WhichRefine[iref];
100  if (!cel) continue;
101  cel->Divide ( cel->Index(), filhos );
102  }
103  me->ExpandSolution();
104 
105  if (other){
106  TPZCompMeshReferred::DivideReferredEl(Other2Refine, other);
107  me->LoadReferred(other);
108  }
109 
110 }
111 
114  return Hash("TPZCompMeshReferred") ^ TPZCompMesh::ClassId() << 1;
115 }
117 void TPZCompMeshReferred::Write(TPZStream &buf, int withclassid) const {
118  TPZCompMesh::Write(buf, withclassid);
119  buf.Write(fReferredIndices);
121 }
122 
124 void TPZCompMeshReferred::Read(TPZStream &buf, void *context) {
125  TPZCompMesh::Read(buf, context);
126  buf.Read(fReferredIndices);
128 }
129 
131 
int64_t NElements() const
Number of computational elements allocated.
Definition: pzcmesh.h:169
TPZGeoMesh * Reference() const
Returns a pointer to the geometrical mesh associated.
Definition: pzcmesh.h:209
int ClassId() const override
Returns the unique identifier for reading/writing objects to streams.
TPZCompEl * ReferredEl(int64_t index)
TPZAdmChunkVector< TPZCompEl * > fElementVec
List of pointers to elements.
Definition: pzcmesh.h:60
void Read(TPZStream &buf, void *context) override
Read the element data from a stream.
void Write(TPZStream &buf, int withclassid) const override
Save the element data to a stream.
void LoadReferred(TPZCompMesh *mesh)
Contains declaration of TPZCompEl class which defines the interface of a computational element...
int ClassId() const override
Returns the unique identifier for reading/writing objects to streams.
Definition: pzcmesh.cpp:1969
static TPZSavable * GetInstance(const int64_t &objId)
void LoadReferences()
Map this grid in the geometric grid.
Definition: pzcmesh.cpp:482
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
Contains declaration of TPZMesh class which defines a geometrical mesh and contains a corresponding l...
virtual void Divide(int64_t index, TPZVec< int64_t > &subindex, int interpolate=0)
Divide the computational element. If interpolate = 1, the solution is interpolated to the sub element...
Definition: pzcompel.cpp:410
virtual void Write(const bool val)
Definition: TPZStream.cpp:8
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
Definition: pzgeoel.h:43
Contains declaration of TPZCompMeshReferred class which implements the structure to allow one mesh to...
virtual void Print(std::ostream &out=std::cout) const override
Prints mesh data.
void Read(TPZStream &buf, void *context) override
Read the element data from a stream.
Definition: pzcmesh.cpp:2006
virtual void ExpandSolution()
Adapt the solution vector to new block dimensions.
Definition: pzcmesh.cpp:396
TPZCompEl * Reference() const
Return a pointer to the element referenced by the geometric element.
Definition: pzgeoel.h:750
Implements the structure to allow one mesh to refer to the solution of another. Geometry.
int64_t Index() const
Returns element index of the mesh fELementVec list.
Definition: pzcompel.h:821
int32_t Hash(std::string str)
Definition: TPZHash.cpp:10
static void DivideReferredEl(TPZVec< TPZCompEl *> WhichRefine, TPZCompMesh *cmesh)
Divide computational element recursively over referred elements.
TPZCompMesh * ReferredMesh() const
TPZGeoEl * Reference() const
Return a pointer to the corresponding geometric element if such exists, return 0 otherwise.
Definition: pzcompel.cpp:1137
This class implements a geometric mesh for the pz environment. Geometry.
Definition: pzgmesh.h:48
Implements computational mesh. Computational Mesh.
Definition: pzcmesh.h:47
TPZAdmChunkVector< TPZCompEl * > & ElementVec()
Returns a reference to the element pointers vector.
Definition: pzcmesh.h:183
Defines the interface for saving and reading data. Persistency.
Definition: TPZStream.h:50
int64_t NElements() const
Returns the number of elements of the vector.
Definition: pzvec.h:190
void ResetReference()
Resets all load references in elements and nodes.
Definition: pzgmesh.cpp:197
Defines the interface of a computational element. Computational Element.
Definition: pzcompel.h:59
TPZVec< int64_t > fReferredIndices
static void WritePointer(const TPZSavable *obj, TPZStream *stream)
void Write(TPZStream &buf, int withclassid) const override
Save the element data to a stream.
Definition: pzcmesh.cpp:1975
Implements an interface to register a class id and a restore function. Persistence.
Definition: TPZSavable.h:150
virtual void Print(std::ostream &out=std::cout) const
Prints mesh data.
Definition: pzcmesh.cpp:236
virtual void Read(bool &val)
Definition: TPZStream.cpp:91