NeoPZ
pzgeoquad.cpp
Go to the documentation of this file.
1 
6 #include "pzgeoquad.h"
7 #include "pzfmatrix.h"
8 #include "pzgeoel.h"
9 #include "pzquad.h"
10 #include "tpzgeoelrefpattern.h"
11 
12 #include "pzlog.h"
13 
14 #ifdef LOG4CXX
15 static log4cxx::LoggerPtr logger(Logger::getLogger("pz.geom.pzgeoquad"));
16 #endif
17 
18 using namespace std;
19 
20 namespace pzgeom {
21  const REAL tol = pzgeom_TPZNodeRep_tol;
22 
23  void TPZGeoQuad::VectorialProduct(TPZVec<REAL> &v1, TPZVec<REAL> &v2,TPZVec<REAL> &result){
24  if(v1.NElements()!=3||v2.NElements()!=3)
25  {
26  cout << " o tamanho do vetores eh diferente de 3"<< endl;
27  }
28  REAL x1=v1[0], y1=v1[1],z1=v1[2];
29  REAL x2=v2[0], y2=v2[1],z2=v2[2];
30  result.Resize(v1.NElements());
31  result[0]=y1*z2-z1*y2;
32  result[1]=z1*x2-x1*z2;
33  result[2]=x1*y2-y1*x2;
34  }
35 
36  void TPZGeoQuad::ComputeNormal(TPZVec<REAL> &p1, TPZVec<REAL> &p2,TPZVec<REAL> &p3,TPZVec<REAL> &result){
37  TPZVec<REAL> v1(3);
38  TPZVec<REAL> v2(3);
39  TPZVec<REAL> normal(3);
40  v1[0]=p1[0]-p2[0];
41  v1[1]=p1[1]-p2[1];
42  v1[2]=p1[2]-p2[2];
43  v2[0]=p2[0]-p3[0];
44  v2[1]=p2[1]-p3[1];
45  v2[2]=p2[2]-p3[2];
46  VectorialProduct(v1,v2,normal);
47  VectorialProduct(v1,normal,result);
48  }
49 
50 
51  // TPZGeoEl *TPZGeoQuad::CreateBCGeoEl(TPZGeoEl *orig,int side,int bc) {
52  // if(side==8) {//8
53  // TPZManVector<int64_t> nodes(4);
54  // int i;
55  // for (i=0;i<4;i++) {
56  // nodes[i] = orig->SideNodeIndex(side,i);
57  // }
58  // int64_t index;
59  // TPZGeoEl *gel = orig->CreateGeoElement(EQuadrilateral,nodes,bc,index);
60  // int iside;
61  // for (iside = 0; iside <8; iside++){
62  // TPZGeoElSide(gel,iside).SetConnectivity(TPZGeoElSide(orig,pztopology::TPZQuadrilateral::ContainedSideLocId(side,iside)));
63  // }
64  // TPZGeoElSide(gel,8).SetConnectivity(TPZGeoElSide(orig,side));
65  // return gel;
66  // }
67  // else if(side>-1 && side<4) {//side = 0,1,2,3
68  // TPZManVector<int64_t> nodeindexes(1);
69  // nodeindexes[0] = orig->SideNodeIndex(side,0);
70  // int64_t index;
71  // TPZGeoEl *gel = orig->CreateGeoElement(EPoint,nodeindexes,bc,index);
72  // TPZGeoElSide(gel,0).SetConnectivity(TPZGeoElSide(orig,side));
73  // return gel;
74  // }
75  // else if(side>3 && side<8) {
76  // TPZManVector<int64_t> nodes(2);
77  // nodes[0] = orig->SideNodeIndex(side,0);
78  // nodes[1] = orig->SideNodeIndex(side,1);
79  // int64_t index;
80  // TPZGeoEl *gel = orig->CreateGeoElement(EOned,nodes,bc,index);
81  // TPZGeoElSide(gel,0).SetConnectivity(TPZGeoElSide(orig,pztopology::TPZQuadrilateral::ContainedSideLocId(side,0)));
82  // TPZGeoElSide(gel,1).SetConnectivity(TPZGeoElSide(orig,pztopology::TPZQuadrilateral::ContainedSideLocId(side,1)));
83  // TPZGeoElSide(gel,2).SetConnectivity(TPZGeoElSide(orig,side));
84  // return gel;
85  // }
86  // else PZError << "TPZGeoQuad::CreateBCCompEl has no bc.\n";
87  // return 0;
88  // }
89 
90  void TPZGeoQuad::InsertExampleElement(TPZGeoMesh &gmesh, int matid, TPZVec<REAL> &lowercorner, TPZVec<REAL> &size)
91  {
92  TPZManVector<int64_t,4> nodeindexes(4);
93  TPZManVector<REAL,3> co(lowercorner);
94  for (int i=0; i<3; i++) {
95  co[i] += 0.2*size[i];
96  }
97 
98  nodeindexes[0] = gmesh.NodeVec().AllocateNewElement();
99  gmesh.NodeVec()[nodeindexes[0]].Initialize(co, gmesh);
100  co[0] += 0.6 * size[0];
101  nodeindexes[1] = gmesh.NodeVec().AllocateNewElement();
102  gmesh.NodeVec()[nodeindexes[1]].Initialize(co, gmesh);
103  co[1] += 0.6 * size[0];
104  co[0] += 0.1 * size[0];
105  co[2] += 0.3 * size[0];
106  nodeindexes[2] = gmesh.NodeVec().AllocateNewElement();
107  gmesh.NodeVec()[nodeindexes[2]].Initialize(co, gmesh);
108  for (int i = 0; i < 3; i++) co[i] = lowercorner[i] + 0.2 * size[i];
109  co[1] += 0.4 * size[1];
110  co[2] -= 0.2 * size[2];
111  nodeindexes[3] = gmesh.NodeVec().AllocateNewElement();
112  gmesh.NodeVec()[nodeindexes[3]].Initialize(co, gmesh);
113  int64_t index;
114  gmesh.CreateGeoElement(EQuadrilateral, nodeindexes, matid, index);
115  }
116 
117 
118  int TPZGeoQuad::ClassId() const{
119  return Hash("TPZGeoQuad") ^ TPZNodeRep<4, pztopology::TPZQuadrilateral>::ClassId() << 1;
120  }
121 
122  void TPZGeoQuad::Read(TPZStream &buf, void *context) {
124  }
125 
126  void TPZGeoQuad::Write(TPZStream &buf, int withclassid) const {
128  }
129 
130 };
int AllocateNewElement()
Makes more room for new elements.
Definition: pzadmchunk.h:184
Contains the TPZInt1d, TPZIntTriang, TPZIntQuad, TPZIntCube3D, TPZIntTetra3D, TPZIntPyram3D and TPZIn...
Contains definitions to LOGPZ_DEBUG, LOGPZ_INFO, LOGPZ_WARN, LOGPZ_ERROR and LOGPZ_FATAL, and the implementation of the inline InitializePZLOG(string) function using log4cxx library or not. It must to be called out of "#ifdef LOG4CXX" scope.
Implements a vector class which allows to use external storage provided by the user. Utility.
Definition: pzquad.h:16
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
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
static const double tol
Definition: pzgeoprism.cpp:23
Contains TPZMatrixclass which implements full matrix (using column major representation).
const double pzgeom_TPZNodeRep_tol
Initializing tolerance to TPZNodeRep.
Definition: pznoderep.h:32
TPZAdmChunkVector< TPZGeoNode > & NodeVec()
Definition: pzgmesh.h:140
Contains declaration of TPZGeoElRefPattern class which implements a generic geometric element which i...
REAL co[8][3]
Coordinates of the eight nodes.
Implements ... Geometry Topology.
Definition: pznoderep.h:40
int32_t Hash(std::string str)
Definition: TPZHash.cpp:10
This class implements a geometric mesh for the pz environment. Geometry.
Definition: pzgmesh.h:48
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
Groups all classes which model the geometry.
Definition: pzgeopoint.cpp:18