#include <ElemUtil.hpp>
Public Member Functions | |
SpectralQuad (const std::vector< CartVect > &vertices) | |
SpectralQuad (int order, double *x, double *y, double *z) | |
SpectralQuad (int order) | |
SpectralQuad () | |
virtual | ~SpectralQuad () |
void | set_gl_points (double *x, double *y, double *z) |
virtual CartVect | evaluate (const CartVect &xi) const |
Evaluate the map on \(x_i\) (calculate \(\vec x = F($\vec \xi)\) ) More... | |
virtual CartVect | ievaluate (const CartVect &x, double tol=1e-6, const CartVect &x0=CartVect(0.0)) const |
Evaluate the inverse map (calculate \(\vec \xi = F^-1($\vec x)\) to given tolerance) More... | |
virtual Matrix3 | jacobian (const CartVect &xi) const |
Evaluate the map's Jacobi matrix. More... | |
double | evaluate_scalar_field (const CartVect &xi, const double *field_vertex_values) const |
Evaluate a scalar field at a point given field values at the vertices. More... | |
double | integrate_scalar_field (const double *field_vertex_values) const |
Integrate a scalar field over the element given field values at the vertices. More... | |
bool | inside_nat_space (const CartVect &xi, double &tol) const |
decide if within the natural param space, with a tolerance More... | |
void | Init (int order) |
void | freedata () |
void | compute_gl_positions () |
void | get_gl_points (double *&x, double *&y, double *&z, int &size) |
![]() | |
Map (const std::vector< CartVect > &v) | |
Construct a Map defined by the given std::vector of vertices. More... | |
Map (const unsigned int n) | |
Construct a Map defined by n vertices. More... | |
virtual | ~Map () |
virtual Matrix3 | ijacobian (const CartVect &xi) const |
Evaluate the inverse of the Jacobi matrix. More... | |
virtual double | det_jacobian (const CartVect &xi) const |
Evaluate the determinate of the Jacobi matrix. More... | |
virtual double | det_ijacobian (const CartVect &xi) const |
Evaluate the determinate of the inverse Jacobi matrix. More... | |
unsigned int | size () |
Size of the vertices vector. More... | |
const std::vector< CartVect > & | get_vertices () |
Retrieve vertices. More... | |
virtual void | set_vertices (const std::vector< CartVect > &v) |
Set vertices. More... | |
virtual bool | inside_box (const CartVect &xi, double &tol) const |
Protected Attributes | |
realType * | _xyz [3] |
![]() | |
std::vector< CartVect > | vertex |
Static Protected Attributes | |
static int | _n |
static realType * | _z [2] |
static lagrange_data | _ld [2] |
static opt_data_2 | _data |
static realType * | _odwork |
static bool | _init = false |
static realType * | _glpoints |
Definition at line 421 of file ElemUtil.hpp.
|
inline |
Definition at line 424 of file ElemUtil.hpp.
424 : Map( vertices )
425 {
426 _xyz[0] = _xyz[1] = _xyz[2] = NULL;
427 };
References _xyz.
moab::Element::SpectralQuad::SpectralQuad | ( | int | order, |
double * | x, | ||
double * | y, | ||
double * | z | ||
) |
Definition at line 18 of file SpectralQuad.cpp.
18 : Map( 0 ) 19 { 20 Init( order ); 21 _xyz[0] = x; 22 _xyz[1] = y; 23 _xyz[2] = z; 24 }
moab::Element::SpectralQuad::SpectralQuad | ( | int | order | ) |
Definition at line 25 of file SpectralQuad.cpp.
25 : Map( 4 )
26 {
27 Init( order );
28 _xyz[0] = _xyz[1] = _xyz[2] = NULL;
29 }
moab::Element::SpectralQuad::SpectralQuad | ( | ) |
Definition at line 16 of file SpectralQuad.cpp.
16 : Map( 0 ) {}
|
virtual |
Definition at line 30 of file SpectralQuad.cpp.
31 {
32 if( _init ) freedata();
33 _init = false;
34 }
References _init, and freedata().
void moab::Element::SpectralQuad::compute_gl_positions | ( | ) |
Definition at line 173 of file SpectralQuad.cpp.
174 {
175 // will need to use shape functions on a simple linear quad to compute gl points
176 // so we know the position of gl points in parametric space, we will just compute those
177 // from the 3d vertex position (corner nodes of the quad), using simple mapping
178 assert( this->vertex.size() == 4 );
179 static double corner_params[4][2] = { { -1., -1. }, { 1., -1. }, { 1., 1. }, { -1., 1. } };
180 // we will use the cached lobatto nodes in parametric space _z[d] (the same in both directions)
181 int indexGL = 0;
182 int n2 = _n * _n;
183 for( int i = 0; i < _n; i++ )
184 {
185 double csi = _z[0][i];
186 for( int j = 0; j < _n; j++ )
187 {
188 double eta = _z[1][j]; // we could really use the same _z[0] array of lobatto nodes
189 CartVect pos( 0.0 );
190 for( int k = 0; k < 4; k++ )
191 {
192 const double N_k = ( 1 + csi * corner_params[k][0] ) * ( 1 + eta * corner_params[k][1] );
193 pos += N_k * vertex[k];
194 }
195 pos *= 0.25; // these are x, y, z of gl points; reorder them
196 _glpoints[indexGL] = pos[0]; // x
197 _glpoints[indexGL + n2] = pos[1]; // y
198 _glpoints[indexGL + 2 * n2] = pos[2]; // z
199 indexGL++;
200 }
201 }
202 // now, we can set the _xyz pointers to internal memory allocated to these!
203 _xyz[0] = &( _glpoints[0] );
204 _xyz[1] = &( _glpoints[n2] );
205 _xyz[2] = &( _glpoints[2 * n2] );
206 }
References _glpoints, _n, _xyz, and _z.
Referenced by test_spectral_quad().
Evaluate the map on \(x_i\) (calculate \(\vec x = F($\vec \xi)\) )
Implements moab::Element::Map.
Definition at line 1298 of file ElemUtil.cpp.
1299 {
1300 // piece that we shouldn't want to cache
1301 int d = 0;
1302 for( d = 0; d < 2; d++ )
1303 {
1304 lagrange_0( &_ld[d], xi[d] );
1305 }
1306 CartVect result;
1307 for( d = 0; d < 3; d++ )
1308 {
1309 result[d] = tensor_i2( _ld[0].J, _ld[0].n, _ld[1].J, _ld[1].n, _xyz[d], _odwork );
1310 }
1311 return result;
1312 }
References _ld, _odwork, _xyz, lagrange_0(), and tensor_i2().
|
virtual |
Evaluate a scalar field at a point given field values at the vertices.
Implements moab::Element::Map.
Definition at line 1343 of file ElemUtil.cpp.
1344 {
1345 // piece that we shouldn't want to cache
1346 int d;
1347 for( d = 0; d < 2; d++ )
1348 {
1349 lagrange_0( &_ld[d], xi[d] );
1350 }
1351
1352 double value = tensor_i2( _ld[0].J, _ld[0].n, _ld[1].J, _ld[1].n, field, _odwork );
1353 return value;
1354 }
References _ld, _odwork, lagrange_0(), and tensor_i2().
void moab::Element::SpectralQuad::freedata | ( | ) |
Definition at line 60 of file SpectralQuad.cpp.
61 {
62 for( int d = 0; d < 2; d++ )
63 {
64 free( _z[d] );
65 lagrange_free( &_ld[d] );
66 }
67 opt_free_2( &_data );
68 free( _odwork );
69 free( _glpoints );
70 }
References _data, _glpoints, _ld, _odwork, _z, lagrange_free(), and opt_free_2().
Referenced by Init(), and ~SpectralQuad().
void moab::Element::SpectralQuad::get_gl_points | ( | double *& | x, |
double *& | y, | ||
double *& | z, | ||
int & | size | ||
) |
Definition at line 207 of file SpectralQuad.cpp.
208 {
209 x = (double*)_xyz[0];
210 y = (double*)_xyz[1];
211 z = (double*)_xyz[2];
212 size = _n * _n;
213 }
References _n, _xyz, and moab::Element::Map::size().
Referenced by test_spectral_quad().
|
virtual |
Evaluate the inverse map (calculate \(\vec \xi = F^-1($\vec x)\) to given tolerance)
Reimplemented from moab::Element::Map.
Definition at line 1314 of file ElemUtil.cpp.
1315 {
1316 // find nearest point
1317 realType x_star[3];
1318 xyz.get( x_star );
1319
1320 realType r[2] = { 0, 0 }; // initial guess for parametric coords
1321 unsigned c = opt_no_constraints_3;
1322 realType dist = opt_findpt_2( &_data, (const realType**)_xyz, x_star, r, &c );
1323 // if it did not converge, get out with throw...
1324 if( dist > 0.9e+30 )
1325 {
1326 std::vector< CartVect > dummy;
1327 throw Map::EvaluationError( xyz, dummy );
1328 }
1329
1330 // c tells us if we landed inside the element or exactly on a face, edge, or node
1331 // also, dist shows the distance to the computed point.
1332 // copy parametric coords back
1333 return CartVect( r[0], r[1], 0. );
1334 }
References _data, _xyz, moab::CartVect::get(), opt_findpt_2(), and opt_no_constraints_3.
void moab::Element::SpectralQuad::Init | ( | int | order | ) |
Definition at line 35 of file SpectralQuad.cpp.
36 {
37 if( _init && _n == order ) return;
38 if( _init && _n != order )
39 {
40 // TODO: free data cached
41 freedata();
42 }
43 // compute stuff that depends only on order
44 _init = true;
45 _n = order;
46 // duplicates! n is the same in all directions !!!
47 for( int d = 0; d < 2; d++ )
48 {
49 _z[d] = tmalloc( double, _n );
50 lobatto_nodes( _z[d], _n );
51 lagrange_setup( &_ld[d], _z[d], _n );
52 }
53 opt_alloc_2( &_data, _ld );
54
55 unsigned int nf = _n * _n, ne = _n, nw = 2 * _n * _n + 3 * _n;
56 _odwork = tmalloc( double, 6 * nf + 9 * ne + nw );
57 _glpoints = tmalloc( double, 3 * nf );
58 }
References _data, _glpoints, _init, _ld, _n, _odwork, _z, freedata(), lagrange_setup(), lobatto_nodes(), opt_alloc_2(), and tmalloc.
Referenced by SpectralQuad().
|
virtual |
decide if within the natural param space, with a tolerance
Implements moab::Element::Map.
Definition at line 1360 of file ElemUtil.cpp.
1361 {
1362 // just look at the box+tol here
1363 return ( xi[0] >= -1. - tol ) && ( xi[0] <= 1. + tol ) && ( xi[1] >= -1. - tol ) && ( xi[1] <= 1. + tol );
1364 }
|
virtual |
Integrate a scalar field over the element given field values at the vertices.
Implements moab::Element::Map.
Definition at line 1355 of file ElemUtil.cpp.
1356 {
1357 return 0.; // not implemented
1358 }
Evaluate the map's Jacobi matrix.
Implements moab::Element::Map.
Definition at line 132 of file SpectralQuad.cpp.
138 {
139 // not implemented
140 Matrix3 J( 0. );
141 return J;
142 }
void moab::Element::SpectralQuad::set_gl_points | ( | double * | x, |
double * | y, | ||
double * | z | ||
) |
Definition at line 72 of file SpectralQuad.cpp.
73 { 74 _xyz[0] = x; 75 _xyz[1] = y; 76 _xyz[2] = z; 77 }
References _xyz.
|
staticprotected |
Definition at line 456 of file ElemUtil.hpp.
Referenced by freedata(), ievaluate(), Init(), and moab::SpectralQuad::reverseEvalFcn().
|
staticprotected |
Definition at line 461 of file ElemUtil.hpp.
Referenced by compute_gl_positions(), freedata(), and Init().
|
staticprotected |
Definition at line 460 of file ElemUtil.hpp.
Referenced by Init(), and ~SpectralQuad().
|
staticprotected |
Definition at line 455 of file ElemUtil.hpp.
Referenced by moab::SpectralQuad::evalFcn(), evaluate(), evaluate_scalar_field(), freedata(), and Init().
|
staticprotected |
Definition at line 453 of file ElemUtil.hpp.
Referenced by compute_gl_positions(), get_gl_points(), and Init().
|
staticprotected |
Definition at line 457 of file ElemUtil.hpp.
Referenced by moab::SpectralQuad::evalFcn(), evaluate(), evaluate_scalar_field(), freedata(), and Init().
|
protected |
Definition at line 466 of file ElemUtil.hpp.
Referenced by compute_gl_positions(), moab::SpectralQuad::evalFcn(), evaluate(), get_gl_points(), ievaluate(), moab::SpectralQuad::reverseEvalFcn(), set_gl_points(), and SpectralQuad().
|
staticprotected |
Definition at line 454 of file ElemUtil.hpp.
Referenced by compute_gl_positions(), freedata(), and Init().