NeoPZ
TPZTriangleSphere.cpp
Go to the documentation of this file.
1 //
2 // TPZTriangleSphere.cpp
3 // PZ
4 //
5 // Created by Philippe Devloo on 3/21/14.
6 //
7 //
8 
9 #include "TPZTriangleSphere.h"
10 #include "tpzgeomid.h"
11 #include "tpzgeoelmapped.h"
12 #include "tpzgeoelrefpattern.h"
13 #include "tpzgeoblend.h"
14 
15 #include "pzlog.h"
16 
17 #ifdef LOG4CXX
18 static log4cxx::LoggerPtr logger(Logger::getLogger("pz.geom.pzgeotriangle"));
19 #endif
20 
21 namespace pzgeom {
22 
23  // template< class GeomTriang>
24  // TPZGeoEl *TPZTriangleSphere<GeomTriang>::CreateBCGeoEl(TPZGeoEl *orig, int side,int bc)
25  // {
26 
27  // int ns = orig->NSideNodes(side);
28  // TPZManVector<int64_t> nodeindices(ns);
29  // int in;
30  // for(in=0; in<ns; in++)
31  // {
32  // nodeindices[in] = orig->SideNodeIndex(side,in);
33  // }
34  // int64_t index;
35 
36  // TPZGeoMesh *mesh = orig->Mesh();
37  // MElementType type = orig->Type(side);
38 
39  // TPZGeoEl *newel = mesh->CreateGeoBlendElement(type, nodeindices, bc, index);
40  // TPZGeoElSide me(orig,side);
41  // TPZGeoElSide newelside(newel,newel->NSides()-1);
42 
43  // newelside.InsertConnectivity(me);
44  // newel->Initialize();
45 
46  // return newel;
47  // }
48 
49  template<class GeomTriang>
51  {
52  TPZManVector<REAL,3> center(lowercorner);
53  REAL radius = 1.;
54  center[0] += radius/2.;
55  center[1] += radius/2.;
56  center[2] += radius/2.;
57  for (int i=0; i<3; i++) {
58  sz[i] = 2.*radius;
59  }
60  REAL coords[4][3] = {
61  {-1,-1,-0.1},
62  { 1,-1,-0.1},
63  { 1, 1,-0.1}
64  };
65  for (int i=0; i<4; i++) {
66  REAL norm = sqrt(coords[i][0]*coords[i][0]+coords[i][1]*coords[i][1]+coords[i][2]*coords[i][2]);
67  for(int j=0; j<3; j++) coords[i][j] *= radius/norm;
68  }
69  TPZManVector<int64_t,3> indices(3);
70  for (int i=0; i<3; i++) {
71  indices[i] = gmesh.NodeVec().AllocateNewElement();
72  TPZManVector<REAL,3> xco(3);
73  for (int j=0; j<3; j++) {
74  xco[j] = coords[i][j]+center[j];
75  }
76  gmesh.NodeVec()[indices[i]].Initialize(xco, gmesh);
77  }
79  gel->Geom().SetData(radius, center);
80  }
81 
82  // /**
83  // * Creates a geometric element according to the type of the father element
84  // */
85  // /** @brief Creates a geometric element according to the type of the father element */
86  // template< class GeomTriang>
87  // TPZGeoEl *TPZTriangleSphere<GeomTriang>::CreateGeoElement(TPZGeoMesh &mesh, MElementType type,
88  // TPZVec<int64_t>& nodeindexes,
89  // int matid,
90  // int64_t& index)
91 
92  // {
93  // return CreateGeoElementMapped(mesh,type,nodeindexes,matid,index);
94  // }
95 
96  template< class GeomTriang>
98  {
99  return false;
100  }
101 
103  template<>
105  {
106  return true;
107  }
108 
109 
110  /* @brief Computes the jacobian of the map between the master element and deformed element */
111 // void TPZTriangleSphere::Jacobian(const TPZGeoEl &gel,TPZVec<REAL> &param,TPZFMatrix<REAL> &jacobian,TPZFMatrix<REAL> &axes,REAL &detjac,TPZFMatrix<REAL> &jacinv) const
112 // {
113 // TPZVec<REAL> XTriangle(3,0.0);
114 // TPZFNMatrix<9,REAL> GradOneoverNorm(3,1,0.0);
115 // TPZFNMatrix<9,REAL> TensorXtGradX(3,2,0.0);
116 // TPZFNMatrix<9,REAL> GradXtScaled(3,3,0.0);
117 //
118 // TPZFNMatrix<3*NNodes> coord(3,NNodes);
119 // CornerCoordinates(gel, coord);
120 // TPZGeoTriangle::X(coord,param,XTriangle);
121 // TPZFMatrix<REAL> XtminusXc(3,1,0.0);
122 // TPZVec<REAL> Xc= fXc;
123 //
124 // for (int i = 0; i < XTriangle.size(); i++) { XtminusXc(i,0)= XTriangle[i] - Xc[i]; }
125 // REAL NormValue = Norm(XtminusXc);
126 //
127 // TPZGeoTriangle::Jacobian(gel, param, jacobian , axes, detjac, jacinv);
128 // TPZFNMatrix<6> axest(3,2);
129 // axes.Transpose(&axest);
130 //
131 // TPZFNMatrix<9,REAL> GradXt;
132 // axest.Multiply(jacobian, GradXt);
133 //
134 // GradOneoverNorm(0,0) = XtminusXc(0,0)*GradXt(0,0)+XtminusXc(1,0)*GradXt(1,0)+XtminusXc(2,0)*GradXt(2,0);
135 // GradOneoverNorm(1,0) = XtminusXc(0,0)*GradXt(0,1)+XtminusXc(1,0)*GradXt(1,1)+XtminusXc(2,0)*GradXt(2,1);
136 // GradOneoverNorm = -(fR/(NormValue*NormValue*NormValue))*GradOneoverNorm;
137 //
138 // TensorXtGradX(0,0)= XtminusXc(0,0)*GradOneoverNorm(0,0);
139 // TensorXtGradX(0,1)= XtminusXc(0,0)*GradOneoverNorm(1,0);
140 // TensorXtGradX(1,0)= XtminusXc(1,0)*GradOneoverNorm(0,0);
141 // TensorXtGradX(1,1)= XtminusXc(1,0)*GradOneoverNorm(1,0);
142 // TensorXtGradX(2,0)= XtminusXc(2,0)*GradOneoverNorm(0,0);
143 // TensorXtGradX(2,1)= XtminusXc(2,0)*GradOneoverNorm(1,0);
144 //
145 // TPZFNMatrix<9,REAL> VecMatrix;
146 // VecMatrix=((fR/(NormValue))*GradXt)+TensorXtGradX;
147 //
148 // TPZManVector<REAL,3> minx(3,0.),maxx(3,0.);
149 //
150 // int spacedim = coord.Rows();
151 //
152 // for (int j=0; j<spacedim; j++) { minx[j] = coord.GetVal(j,0); maxx[j] = coord.GetVal(j,0);}
153 //
154 // for(int i = 0; i < 3; i++) {
155 // for(int j = 0; j < spacedim; j++) {
156 // minx[j] = minx[j] < coord.GetVal(j,i) ? minx[j]:coord.GetVal(j,i);
157 // maxx[j] = maxx[j] > coord.GetVal(j,i) ? maxx[j]:coord.GetVal(j,i);
158 // }
159 // }
160 // REAL delx = 0.;
161 // for (int j=0; j<spacedim; j++) {
162 // delx = delx > (maxx[j]-minx[j]) ? delx : (maxx[j]-minx[j]);
163 // }
164 //
165 // VecMatrix *= 1./delx;
166 // VecMatrix.GramSchmidt(axest,jacobian);
167 // axest.Transpose(&axes);
168 // detjac = jacobian(0,0)*jacobian(1,1) - jacobian(1,0)*jacobian(0,1);
169 //
170 // if(IsZero(detjac))
171 // {
172 //#ifdef PZDEBUG
173 // std::stringstream sout;
174 // sout << "Singular Jacobian " << detjac;
175 // LOGPZ_ERROR(logger, sout.str())
176 //#endif
177 // detjac = ZeroTolerance();
178 // }
179 //
180 // jacinv(0,0) = jacobian(1,1)/detjac;
181 // jacinv(1,1) = jacobian(0,0)/detjac;
182 // jacinv(0,1) = -jacobian(0,1)/detjac;
183 // jacinv(1,0) = -jacobian(1,0)/detjac;
184 // jacobian *= delx;
185 // jacinv *= 1./delx;
186 // detjac *= (delx*delx);
187 //
188 //
189 // }
190 
191 // void TPZTriangleSphere::X(const TPZFMatrix<REAL> &nodes,TPZVec<REAL> &loc,TPZVec<REAL> &result) const
192 // {
193 //
194 // TPZGeoTriangle::X(nodes,loc,result);
195 // TPZFMatrix<REAL> XtminusXc(3,1,0.0);
196 // TPZVec<REAL> Xc= fXc;
197 //
198 // XtminusXc(0,0)= result[0] - Xc[0];
199 // XtminusXc(1,0)= result[1] - Xc[1];
200 // XtminusXc(2,0)= result[2] - Xc[2];
201 // REAL NormValue = Norm(XtminusXc);
202 //
203 // TPZVec<REAL> Xsphere(3,0.0);
204 // Xsphere[0] = (fR/NormValue)*(XtminusXc(0,0)+Xc[0]);
205 // Xsphere[1] = (fR/NormValue)*(XtminusXc(1,0)+Xc[1]);
206 // Xsphere[2] = (fR/NormValue)*(XtminusXc(2,0)+Xc[2]);
207 // result=Xsphere;
208 //
209 // }
210 
211 }
212 
214 
216 
218 
220 
222 
224 
225 
226 
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.
Implements the mapping between the master element and deformed element. Geometry. ...
bool IsGeoBlendEl() const
declare geometry as blended element
Contains declaration of TPZGeoElMapped class which implements a geometric element using its ancestral...
Implements a generic geometric element which is refined according to a generic refinement pattern...
Definition: pzgmesh.h:35
Contains the TPZGeoBlend class which implements a blending map from curved boundaries to the interior...
TPZAdmChunkVector< TPZGeoNode > & NodeVec()
Definition: pzgmesh.h:140
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ sqrt
Definition: tfadfunc.h:120
Contains declaration of TPZGeoElRefPattern class which implements a generic geometric element which i...
This class implements a geometric mesh for the pz environment. Geometry.
Definition: pzgmesh.h:48
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
static void InsertExampleElement(TPZGeoMesh &gmesh, int matid, TPZVec< REAL > &lowercorner, TPZVec< REAL > &size)