NeoPZ
pzrefpoint.cpp
Go to the documentation of this file.
1 
6 #include "pzrefpoint.h"
7 #include "pzgeopoint.h"
8 #include "pzshapelinear.h"
9 #include "TPZGeoElement.h"
10 #include "pzgeoel.h"
11 #include "pzgmesh.h"
12 
13 using namespace std;
14 
15 namespace pzrefine {
16  static int subeldata[1][1][2] =
17  {
18  {{0}}
19  };
20 
21  static int nsubeldata[1] = {1};
22 
23 
24  void TPZRefPoint::Divide(TPZGeoEl *geo,TPZVec<TPZGeoEl *> &SubElVec) {
25  int i;
26  if(geo->HasSubElement()) {
27  SubElVec.Resize(NSubEl);
28  for(i=0;i<NSubEl;i++)
29  SubElVec[i] = geo->SubElement(i);
30  return;//If exist fSubEl return this sons
31  }
32  //int j,index;
33  int sub,matid = geo->MaterialId();
34  int np[1];
35  np[0] = geo->NodeIndex(0);
36  // creating new subelements
37  TPZGeoEl *pt0d = geo;
38  //for(i=0;i<TPZShapeLinear::NNodes;i++) {
39  TPZManVector<int64_t> cornerindexes(1/*TPZShapeLinear::NNodes*/);
40  cornerindexes[0]=np[0];
41  //for(int j=0;j<TPZShapeLinear::NNodes;j++)
42  // cornerindexes[j] = np[CornerSons[i][j]];
43  int64_t index;
44  TPZGeoEl *npt = geo->Mesh()->CreateGeoElement(EPoint,cornerindexes,matid,index);
45  // TPZGeoElPoint *npt = new TPZGeoElPoint(cornerindexes,matid,*geo->Mesh());
46  pt0d->SetSubElement(/*i*/0 , npt);
47  //}
48 
49  SubElVec.Resize(NSubEl);
50  for(sub=0;sub<NSubEl;sub++) {
51  SubElVec[sub] = geo->SubElement(sub);
52  SubElVec[sub]->SetFather(geo);
53  SubElVec[sub]->SetFatherIndex(geo->Index());
54  }
56  }
57 
58  void TPZRefPoint::MidSideNodeIndex(const TPZGeoEl *gel,int side,int64_t &index){
59  index = -1;
60  if(side != 0) {
61  PZError << "TPZRefCube::MidSideNodeIndex. Bad parameter side = " << side << endl;
62  return;
63  }
64  //sides 0
65  //if(side<TPZShapeLinear::NNodes) {//o nó medio do lado 0 é o 0 etc.
66  index = (gel)->NodeIndex(side);
67  return;
68  //}
69  //o nó medio da face é o centro e o nó medio do centro é o centro
70  //como nó de algum filho se este existir
71  //caso tenha filhos é o canto de algum filho, se não tiver filhos retorna -1
72  // if(gel->HasSubElement()) {
73  // side-=TPZShapeLinear::NNodes;
74  // index=(gel->SubElement(MidSideNodes[side][0]))->NodeIndex(MidSideNodes[side][1]);
75  // }
76  }
77  void TPZRefPoint::NewMidSideNode(TPZGeoEl *gel,int side,int64_t &index) {
78 
79  MidSideNodeIndex(gel,side,index);
80  if(index < 0) {
81  TPZGeoElSide gelside = gel->Neighbour(side);
82  if(gelside.Element()) {
83  while(gelside.Element() != gel) {
84  gelside.Element()->MidSideNodeIndex(gelside.Side(),index);
85  if(index!=-1) return;
86  gelside = gelside.Neighbour();
87  }
88  }
89  TPZVec<REAL> par(3,0.);
90  TPZVec<REAL> coord(3,0.);
91  if(side == 0) {
92  index = gel->NodeIndex(side);
93  return;
94  }
95  //aqui side = 8 a 26
96  // side-=TPZShapeLinear::NNodes;//0,1,..,18
97  // par[0] = MidCoord[side][0];
98  // gel->X(par,coord);
99  // index = gel->Mesh()->NodeVec().AllocateNewElement();
100  // gel->Mesh()->NodeVec()[index].Initialize(coord,*gel->Mesh());
101  }
102 
103  }
104 
105  void TPZRefPoint::GetSubElements(const TPZGeoEl *father,int side, TPZStack<TPZGeoElSide> &subel) {
106 // subel.Resize(0);
107  if(side<0 || side>1 || !father->HasSubElement()){
108  PZError << "TPZRefPoint::GetSubElements called with bad arguments\n";
109  return;
110  }
111  int nsub = NSideSubElements(side);//nsubeldata[side];
112  for(int i=0;i<nsub;i++)
113  subel.Push(TPZGeoElSide(father->SubElement(subeldata[side][i][0]),subeldata[side][i][1]));
114 
115  }
116  int TPZRefPoint::NSideSubElements(int side) {
117  if(side<0 || side>1){
118  PZError << "TPZRefPoint::NSideSubelements called with error arguments\n";
119  return -1;
120  }
121  return nsubeldata[side];
122  }
123 
124  TPZTransform<> TPZRefPoint::GetTransform(int side,int whichsubel) {
125  return TPZTransform<> (0,0);
126  }
127 
128  int TPZRefPoint::FatherSide(int side,int whichsubel) {
129  if(side<0 || side>1){
130  PZError << "TPZRefPoint::FatherSide called error" << endl;
131  return -1;
132  }
133  return 0;//fatherside[whichsubel][side];
134  }
135 
136  int TPZRefPoint::ClassId() const{
137  return Hash("TPZRefPoint");
138  }
139 };
int MaterialId() const
Returns the material index of the element.
Definition: pzgeoel.h:250
virtual TPZGeoEl * CreateGeoElement(MElementType type, TPZVec< int64_t > &cornerindexes, int matid, int64_t &index, int reftype=1)
Generic method for creating a geometric element. Putting this method centrally facilitates the modifi...
Definition: pzgmesh.cpp:1296
clarg::argInt nsub("-nsub", "number of substructs", 4)
Utility class which represents an element with its side. The Geometric approximation classes Geometry...
Definition: pzgeoelside.h:83
This class implements a simple vector storage scheme for a templated class T. Utility.
Definition: pzgeopoint.h:19
TPZGeoElSide Neighbour() const
Definition: pzgeoel.h:754
TPZGeoMesh * Mesh() const
Returns the mesh to which the element belongs.
Definition: pzgeoel.h:220
virtual int64_t NodeIndex(int i) const =0
Returns the index of the ith node the index is the location of the node in the nodevector of the mesh...
Contains TPZShapeLinear class which implements the shape functions of a linear one-dimensional elemen...
virtual TPZGeoEl * SubElement(int is) const =0
Returns a pointer to the subelement is.
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...
void Push(const T object)
Pushes a copy of the object on the stack.
Definition: pzstack.h:80
Defines the behaviour of all geometric elements. GeometryTPZGeoEl is the common denominator for all g...
Definition: pzgeoel.h:43
int64_t Index() const
Returns the index of the element within the element vector of the mesh.
Definition: pzgeoel.h:730
static int subeldata[1][1][2]
Definition: pzrefpoint.cpp:16
Groups all classes which model the h refinement These classes are used as template arguments of...
Definition: pzrefpoint.cpp:15
virtual TPZGeoElSide Neighbour(int side)=0
Returns a pointer to the neighbour and the neighbourside along side of the current element...
static int nsubeldata[1]
Definition: pzrefpoint.cpp:21
int32_t Hash(std::string str)
Definition: TPZHash.cpp:10
Contains the TPZGeoPoint class which implements the geometry of a point element or 0-D element...
virtual void SetSubElement(int i, TPZGeoEl *gel)=0
Sets the subelement of index i.
virtual int HasSubElement() const =0
Return 1 if the element has subelements.
TPZGeoEl * Element() const
Definition: pzgeoelside.h:162
This class implements a stack object. Utility.
Definition: pzcheckmesh.h:14
int Side() const
Definition: pzgeoelside.h:169
Implements an affine transformation between points in parameter space. Topology Utility.
Definition: pzmganalysis.h:14
Contains declaration of TPZGeoElement class which implements a generic geometric element with a unifo...
virtual void SetSubElementConnectivities()
Initializes the external connectivities of the subelements.
Definition: pzgeoel.cpp:563
Contains the TPZRefPoint class which implements the uniform refinement of a geometric point element...
#define PZError
Defines the output device to error messages and the DebugStop() function.
Definition: pzerror.h:15
virtual void MidSideNodeIndex(int side, int64_t &index) const =0
Returns the midside node index along a side of the element.