NeoPZ
tpzblendnaca.cpp
Go to the documentation of this file.
1 
5 #include "tpzblendnaca.h"
6 
7 #include "pzreal.h"
8 #include "pzvec.h"
9 #include "TPZGeoElement.h"
10 #include "pzshapequad.h"
11 #include "pzrefquad.h"
12 #include "TPZGeoLinear.h"
13 
14 #include <iostream>
15 #include <fstream>
16 
17 using namespace pzgeom;
18 using namespace pzshape;
19 using namespace pzrefine;
20 
22 {
23 }
24 
25 TPZBlendNACA::TPZBlendNACA(REAL cord, int FourDigits, REAL angle, TPZVec<REAL> &x0) :
26 fCord(cord), fFourDigits(FourDigits), fAngle(angle)
27 {
28  fX0[0] = x0[0];
29  fX0[1] = x0[1];
30  fX0[2] = x0[2];
31  fP = P<REAL>();
32  fM = M<REAL>();
33  fTT = TT<REAL>();
34 }
35 
37 {
38 }
39 
40 template<class Type>
42 {
43  int aux = fFourDigits/100;
44  aux -= ((int)(aux/10))*10;
45  return (Type)(aux/10.);
46 }
47 //template<> REAL TPZBlendNACA::P();
48 
49 template<class Type>
51 {
52  int aux = fFourDigits/1000;
53  return (Type)(aux/100.)*fCord;
54 }
55 //template<> REAL TPZBlendNACA::M();
56 
57 
58 template<class Type>
60 {
61  int aux = fFourDigits - ((int)(fFourDigits/100))*100;
62  return (Type)(aux/100.)*fCord;
63 }
64 //template<> REAL TPZBlendNACA::TT();
65 
66 
67 template <class Type>
68 Type TPZBlendNACA::yc(Type x)
69 {
70  if(x/fCord<fP)
71  {
72  return fM/fP/fP*(2.*fP*x/fCord-x*x/fCord/fCord);
73  }
74  else
75  {
76  return fM/(1.-fP)/(1.-fP)*(1.-2.*fP+2.*fP*x/fCord-x*x/fCord/fCord);
77  }
78 }
79 
80 template<> REAL TPZBlendNACA::yc(REAL x);
81 
82 //*******
83 template <class Type>
84 Type TPZBlendNACA::dyc(Type x)
85 {
86  if(x/fCord<fP)
87  {
88  return 2.*fM/fP/fP*(fP-x/fCord)/fCord;
89  }
90  else
91  {
92  return 2.*fM/(1.-fP)/(1.-fP)*(fP-x/fCord)/fCord;
93  }
94 }
95 template<> REAL TPZBlendNACA::dyc(REAL x);
96 
97 //********
98 template <class Type>
99 Type TPZBlendNACA::yt(Type x)
100 {
101  REAL aux = x/fCord;
102  const REAL a0 = 1.4845,
103  a1 = -0.6300,
104  a2 = -1.7580,
105  a3 = 1.4215,
106  a4 = -0.5075;
107 
108  return fTT * (a0*sqrt(aux) + a1*aux + a2*aux*aux + a3*aux*aux*aux + a4*aux*aux*aux*aux);
109 }
110 
111 template<> REAL TPZBlendNACA::yt(REAL x);
112 
113 //********
114 template <class Type>
115 Type TPZBlendNACA::xu(Type x)
116 {
117  return x-yt(x)*sin(atan(dyc(x)));
118 }
119 
120 template <>REAL TPZBlendNACA::xu(REAL x);
121 //*********
122 
123 
124 template <class Type>
125 Type TPZBlendNACA::yu(Type x)
126 {
127  return yc(x) + yt(x)*cos(atan(dyc(x)));
128 }
129 template<> REAL TPZBlendNACA::yu(REAL x);
130 //********
131 
132 template <class Type>
133 Type TPZBlendNACA::xl(Type x)
134 {
135  return x+yt(x)*sin(atan(dyc(x)));
136 }
137 template<> REAL TPZBlendNACA::xl(REAL x);
138 
139 //********
140 template <class Type>
141 Type TPZBlendNACA::yl(Type x)
142 {
143  return yc(x) - yt(x)*cos(atan(dyc(x)));
144 }
145 template<> REAL TPZBlendNACA::yl(REAL x);
146 
147 
148 //********
149 
150 template<class Type>
151 void TPZBlendNACA::NearestParameter(TPZVec<REAL> &pt, int &uplow, int maxPt,Type& Result)
152 {
153  REAL distminlow = 20.*fCord;
154  REAL distminup = 20.*fCord;
155  REAL distlow,distup;
156  REAL ptl[2],ptu[2];
157  int ip,maxp=maxPt;
158  REAL par,parlow = (REAL)0.0;
159  REAL parup = (REAL)0.0;
160  for(ip=0; ip<=maxp; ip++)
161  {
162  par = ip*fCord/maxp;
163  ptu[0] = xua(par);
164  ptu[1] = yua(par);
165  ptl[0] = xla(par);
166  ptl[1] = yla(par);
167  distlow = (ptl[0]-pt[0])*(ptl[0]-pt[0])+(ptl[1]-pt[1])*(ptl[1]-pt[1]);
168  distup = (ptu[0]-pt[0])*(ptu[0]-pt[0])+(ptu[1]-pt[1])*(ptu[1]-pt[1]);
169  if(distlow < distminlow) parlow = par;
170  if(distup < distminup) parup = par;
171  distminlow = distminlow < distlow ? distminlow : distlow;
172  distminup = distminup < distup ? distminup : distup;
173  }
174  REAL delpar = (0.1L)/maxp;
175  if(distminlow < distminup)
176  {
177  uplow = 0;
178  REAL distprev = distminlow;
179  par = parlow;
180  while(fabs(delpar) > 0.00001/maxp)
181  {
182  ptl[0] = xla(par+delpar);
183  ptl[1] = yla(par+delpar);
184  distlow = (ptl[0]-pt[0])*(ptl[0]-pt[0])+(ptl[1]-pt[1])*(ptl[1]-pt[1]);
185  if(distlow < distprev)
186  {
187  par += delpar;
188  distprev = distlow;
189  }
190  else if (delpar > 0.)
191  {
192  delpar *= -1.;
193  }
194  else
195  {
196  delpar *= -0.1;
197  }
198  }
199  }
200  else
201  {
202  uplow = 1;
203  REAL distprev = distminup;
204  par = parup;
205  while(fabs(delpar) > 0.001/maxp)
206  {
207  ptu[0] = xua(par+delpar);
208  ptu[1] = yua(par+delpar);
209  distup = (ptu[0]-pt[0])*(ptu[0]-pt[0])+(ptu[1]-pt[1])*(ptu[1]-pt[1]);
210  if(distup < distprev)
211  {
212  par += delpar;
213  distprev = distup;
214  }
215  else if (delpar > 0.)
216  {
217  delpar *= -1.;
218  }
219  else
220  {
221  delpar *= -0.1;
222  }
223  }
224  }
225  Result = par;
226 }
227 template<> void TPZBlendNACA::NearestParameter(TPZVec<REAL> &pt, int &uplow, int maxPt,REAL& Result);
228 
230 template <class Type>
231 Type TPZBlendNACA::xua(Type x)
232 {
233  return fX0[0]+(xu(x)-fCord/2.)*cos(fAngle) + yu(x) * sin(fAngle) + fCord/2.;
234 }
235 template<> REAL TPZBlendNACA::xua(REAL x);
236 
237 //***************
238 
239 template <class Type>
240 Type TPZBlendNACA::yua(Type x)
241 {
242  return fX0[1]+yu(x)*cos(fAngle) - (xu(x)-fCord/2.) * sin(fAngle);
243 }
244 template<> REAL TPZBlendNACA::yua(REAL x);
245 
246 //************
247 template <class Type>
248 Type TPZBlendNACA::xla(Type x)
249 {
250  return fX0[0]+(xl(x)-fCord/2.)*cos(fAngle) + yl(x) * sin(fAngle) + fCord/2.;
251 }
252 template<> REAL TPZBlendNACA::xla(REAL x);
253 
254 //************
255 template <class Type>
256 Type TPZBlendNACA::yla(Type x)
257 {
258  return fX0[1]+yl(x)*cos(fAngle) - (xl(x)-fCord/2.) * sin(fAngle);
259 }
260 template<> REAL TPZBlendNACA::yla(REAL x);
261 
263 template <class Type>
265 {
266  int uplow;
267 
268  Type par;
269  NearestParameter(pt,uplow, maxPt,par);
270 
271  if(uplow == 0)
272  {
273  pt[0] = xla(par);
274  pt[1] = yla(par);
275  }
276  else
277  {
278  pt[0] = xua(par);
279  pt[1] = yua(par);
280  }
281 }
282 template<> void TPZBlendNACA::ProjectPoint(TPZVec<REAL> &pt, int maxPt);
283 
284 #include "tpzgeoelmapped.h"
285 
290 // TPZGeoEl *TPZBlendNACA::CreateGeoElement(TPZGeoMesh &mesh, MElementType type,
291 // TPZVec<int64_t>& nodeindexes,
292 // int matid,
293 // int64_t& index)
294 // {
295 // return CreateGeoElementMapped(mesh,type,nodeindexes,matid,index);
296 // }
297 
298 
299 
Type yu(Type x)
TPZBlendNACA()
Default constructor.
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ fabs
Definition: tfadfunc.h:140
Type dyc(Type x)
REAL fX0[3]
Definition: tpzblendnaca.h:99
Templated vector implementation.
groups all classes dedicated to the computation of shape functions
Definition: pzshapeextend.h:16
Contains the TPZRefQuad class which implements the uniform refinement of a geometric quadrilateral el...
~TPZBlendNACA()
Default destructor.
Type yua(Type x)
Contains declaration of TPZGeoElMapped class which implements a geometric element using its ancestral...
Type yc(Type x)
Mean line for the wing.
sin
Definition: fadfunc.h:63
void ProjectPoint(TPZVec< Type > &pt, int maxPt=1000)
Type yla(Type x)
Type xla(Type x)
inferior profile
Type yt(Type x)
Thickness.
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
Groups all classes which model the h refinement These classes are used as template arguments of...
Definition: pzrefpoint.cpp:15
Type xl(Type x)
Inferior profile.
static REAL angle
Angle in radians to test.
Definition: pzsubcmesh.cpp:53
void NearestParameter(TPZVec< REAL > &pt, int &uplow, int maxPt, Type &)
Type P()
Creates a geometric element according to the type of the father element.
expr_ expr_ expr_ expr_ expr_ expr_ expr_ expr_ atan
Definition: tfadfunc.h:85
Type xua(Type x)
Contains the TPZBlendNACA class. It is a special map.
Contains the declaration of TPZFlopCounter class and TPZCounter struct.
Contains declaration of TPZGeoElement class which implements a generic geometric element with a unifo...
Groups all classes which model the geometry.
Definition: pzgeopoint.cpp:18
Type xu(Type x)
Superior profile.
TPZFlopCounter cos(const TPZFlopCounter &orig)
Returns the cosine in radians and increments the counter of the Cosine.
Definition: pzreal.h:514
Contains TPZShapeQuad class which implements the shape functions of a quadrilateral element...
Type yl(Type x)