NeoPZ
TPZQuadTorus.cpp
Go to the documentation of this file.
1 //
2 // TPZQuadTorus.cpp
3 // PZ
4 //
5 // Created by Philippe Devloo on 3/21/14.
6 //
7 //
8 
9 #include "TPZQuadTorus.h"
10 #include "tpzgeomid.h"
11 #include "tpzgeoelmapped.h"
12 #include "tpzgeoelrefpattern.h"
13 
14 #include "pzlog.h"
15 
16 #ifdef LOG4CXX
17 static log4cxx::LoggerPtr logger(Logger::getLogger("pz.geom.pzgeoquad0"));
18 #endif
19 
20 namespace pzgeom {
21 
22 // TPZGeoEl *TPZQuadTorus::CreateBCGeoEl(TPZGeoEl *orig, int side,int bc)
23 // {
24 
25 // int ns = orig->NSideNodes(side);
26 // TPZManVector<int64_t> nodeindices(ns);
27 // int in;
28 // for(in=0; in<ns; in++)
29 // {
30 // nodeindices[in] = orig->SideNodeIndex(side,in);
31 // }
32 // int64_t index;
33 
34 // TPZGeoMesh *mesh = orig->Mesh();
35 // MElementType type = orig->Type(side);
36 
37 // TPZGeoEl *newel = mesh->CreateGeoBlendElement(type, nodeindices, bc, index);
38 // TPZGeoElSide me(orig,side);
39 // TPZGeoElSide newelside(newel,newel->NSides()-1);
40 
41 // newelside.InsertConnectivity(me);
42 // newel->Initialize();
43 
44 // return newel;
45 // }
46 
47 
48  // /**
49  // * Creates a geometric element according to the type of the father element
50  // */
51  // /** @brief Creates a geometric element according to the type of the father element */
52  // TPZGeoEl *TPZQuadTorus::CreateGeoElement(TPZGeoMesh &mesh, MElementType type,
53  // TPZVec<int64_t>& nodeindexes,
54  // int matid,
55  // int64_t& index)
56 
57  // {
58  // return ::CreateGeoElementMapped(mesh,type,nodeindexes,matid,index);
59  // }
60 
61 
62 
63 
64 // void TPZQuadTorus::Jacobian(const TPZGeoEl &gel,TPZVec<REAL> &param,TPZFMatrix<REAL> &jacobian,TPZFMatrix<REAL> &axes,REAL &detjac,TPZFMatrix<REAL> &jacinv) const
65 // {
66 //
67 // TPZFNMatrix<9,REAL> GradPhi(3,3,0.);
68 // DebugStop();
69 // //TPZGeoQuad::Jacobian(fPhiTheta, param, jacobian, axes, detjac, jacinv);
70 // TPZFNMatrix<6> axest(3,2);
71 // axes.Transpose(&axest);
72 // axest.Multiply(jacobian, GradPhi);
73 // TPZFNMatrix<6,REAL> DxDphi(3,3,0.);
74 // TPZManVector<REAL,3> ft(3,0.);
75 // TPZGeoQuad::X(fPhiTheta,param,ft);
76 // DxDphi(0,0) = -cos(ft[1]) * sin(ft[0]);
77 // DxDphi(0,1) = -(3. + cos(ft[0])) * sin(ft[1]);
78 // DxDphi(1,0) = -sin(ft[1]) * sin(ft[0]);
79 // DxDphi(1,1) = cos(ft[1]) * (3. + cos(ft[0]));
80 // DxDphi(2,0) = cos(ft[0]);
81 // DxDphi(2,1) = 0.;
82 // TPZFMatrix<REAL> VecMatrix;
83 // DxDphi.Multiply(GradPhi, VecMatrix);
84 //
85 // TPZManVector<REAL,3> minx(3,0.),maxx(3,0.);
86 //
87 // int spacedim = fPhiTheta.Rows();
88 //
89 // for (int j=0; j<spacedim; j++) {
90 // minx[j] = fPhiTheta.GetVal(j,0);
91 // maxx[j] = fPhiTheta.GetVal(j,0);
92 // }
93 //
94 // for(int i = 0; i < 4; i++) {
95 // for(int j = 0; j < spacedim; j++) {
96 // minx[j] = minx[j] < fPhiTheta.GetVal(j,i) ? minx[j]:fPhiTheta.GetVal(j,i);
97 // maxx[j] = maxx[j] > fPhiTheta.GetVal(j,i) ? maxx[j]:fPhiTheta.GetVal(j,i);
98 // }
99 // }
100 // REAL delx = 0.;
101 // for (int j=0; j<spacedim; j++) {
102 // delx = delx > (maxx[j]-minx[j]) ? delx : (maxx[j]-minx[j]);
103 // }
104 // VecMatrix *= 1./delx;
105 //
106 // VecMatrix.GramSchmidt(axest,jacobian);
107 // axest.Transpose(&axes);
108 // detjac = jacobian(0,0)*jacobian(1,1) - jacobian(1,0)*jacobian(0,1);
109 //
110 // if(IsZero(detjac))
111 // {
112 //#ifdef PZDEBUG
113 // std::stringstream sout;
114 // sout << "Singular Jacobian " << detjac;
115 // LOGPZ_ERROR(logger, sout.str())
116 //#endif
117 // detjac = ZeroTolerance();
118 // }
119 //
120 // jacinv(0,0) = jacobian(1,1)/detjac;
121 // jacinv(1,1) = jacobian(0,0)/detjac;
122 // jacinv(0,1) = -jacobian(0,1)/detjac;
123 // jacinv(1,0) = -jacobian(1,0)/detjac;
124 //
125 // jacobian *= delx;
126 // jacinv *= 1./delx;
127 // detjac *= (delx*delx);
128 //
129 // }
130 
131  int TPZQuadTorus::ClassId() const {
132  return Hash("TPZQuadTorus") ^ TPZGeoQuad::ClassId() << 1;
133  }
134 
136  {
137  REAL R = 1., r = 0.8;
138  size[0] = 2.;
139  size[1] = 2.;
140  size[2] = 1.;
141  TPZManVector<REAL,3> origin(lowercorner);
142  origin[0] += 1.;
143  TPZQuadTorus torus;
144  torus.SetOrigin(origin);
145  torus.SetDataRadius(R, r);
146  TPZFNMatrix<12,REAL> phitheta(2,4,0.);
147  phitheta(0,0) = 0.;
148  phitheta(0,1) = M_PI/5.;
149  phitheta(0,2) = M_PI;
150  phitheta(0,3) = M_PI+M_PI/3.;
151 
152  phitheta(1,0) = M_PI;
153  phitheta(1,1) = 2*M_PI;
154  phitheta(1,2) = 2*M_PI-M_PI/5.;
155  phitheta(1,3) = M_PI;
156  torus.SetDataPhiTheta(phitheta);
157  TPZManVector<int64_t,4> indexes(4);
158  REAL coords[4][2] = {
159  {-1,-1},{1,-1},{1,1},{-1,1}
160  };
161  for (int i=0; i<4; i++) {
162  indexes[i] = gmesh.NodeVec().AllocateNewElement();
163  TPZManVector<REAL,3> xco(3), loc(2);
164  loc[0] = coords[i][0];
165  loc[1] = coords[i][1];
166 
167  torus.X(phitheta, loc, xco);
168  gmesh.NodeVec()[indexes[i]].Initialize(xco, gmesh);
169  }
171  gel->Geom().SetOrigin(origin);
172  gel->Geom().SetDataRadius(R, r);
173  gel->Geom().SetDataPhiTheta(phitheta);
174  }
175 
176 
177 }
178 
180 
void X(const TPZFMatrix< REAL > &nodes, TPZVec< T > &loc, TPZVec< T > &result) const
Definition: TPZQuadTorus.h:125
int AllocateNewElement()
Makes more room for new elements.
Definition: pzadmchunk.h:184
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.
void SetDataRadius(const REAL &R, const REAL &r)
Definition: TPZQuadTorus.h:79
Implements the mapping between the master element and deformed element. Geometry. ...
int ClassId() const override
Creates a geometric element according to the type of the father element.
void SetOrigin(TPZVec< REAL > &origin)
Definition: TPZQuadTorus.h:91
Contains declaration of TPZGeoElMapped class which implements a geometric element using its ancestral...
int ClassId() const override
Creates a geometric element according to the type of the father element.
Definition: pzgeoquad.cpp:118
Implements a generic geometric element which is refined according to a generic refinement pattern...
Definition: pzgmesh.h:35
TPZAdmChunkVector< TPZGeoNode > & NodeVec()
Definition: pzgmesh.h:140
Contains declaration of TPZGeoElRefPattern class which implements a generic geometric element which i...
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
void SetDataPhiTheta(const TPZFMatrix< REAL > &phitheta)
Definition: TPZQuadTorus.h:69
static void InsertExampleElement(TPZGeoMesh &gmesh, int matid, TPZVec< REAL > &lowercorner, TPZVec< REAL > &size)
Groups all classes which model the geometry.
Definition: pzgeopoint.cpp:18
Implements an interface to register a class id and a restore function. Persistence.
Definition: TPZSavable.h:150