32 #ifndef CORE_BASIS_HEXTRILINEARLGN_H
33 #define CORE_BASIS_HEXTRILINEARLGN_H 1
52 static double unit_vertices[8][3];
54 static int unit_edges[12][2];
56 static int unit_faces[6][4];
58 static double unit_face_normals[6][3];
60 static double unit_center[3];
97 static inline double length(
int edge)
99 const double *v0 = unit_vertices[unit_edges[edge][0]];
100 const double *v1 = unit_vertices[unit_edges[edge][1]];
101 const double dx = v1[0] - v0[0];
102 const double dy = v1[1] - v0[1];
103 const double dz = v1[2] - v0[2];
104 return sqrt(dx*dx+dy*dy+dz*dz);
106 static double area(
int ) {
return 1.; }
122 template<
class VECTOR>
124 const unsigned div_per_unit,
125 VECTOR &coords)
const
127 typedef typename VECTOR::value_type VECTOR2;
128 coords.resize(div_per_unit + 1);
133 const double &p1x = v0[0];
134 const double &p1y = v0[1];
135 const double &p1z = v0[2];
136 const double dx = v1[0] - p1x;
137 const double dy = v1[1] - p1y;
138 const double dz = v1[2] - p1z;
140 for(
unsigned i = 0; i <= div_per_unit; i++) {
141 typename VECTOR::value_type &tmp = coords[i];
143 const double d = (double)i / (
double)div_per_unit;
144 tmp[0] =
static_cast<typename VECTOR2::value_type
>(p1x + d * dx);
145 tmp[1] =
static_cast<typename VECTOR2::value_type
>(p1y + d * dy);
146 tmp[2] =
static_cast<typename VECTOR2::value_type
>(p1z + d * dz);
157 template<
class VECTOR>
159 const unsigned div_per_unit,
160 VECTOR &coords)
const
162 typedef typename VECTOR::value_type VECTOR2;
163 typedef typename VECTOR2::value_type VECTOR3;
168 const double d = 1. / (double)div_per_unit;
169 coords.resize(div_per_unit);
170 typename VECTOR::iterator citer = coords.begin();
171 for(
unsigned j = 0; j < div_per_unit; j++)
173 const double dj = (double)j / (
double)div_per_unit;
174 VECTOR2& jvec = *citer++;
175 jvec.resize((div_per_unit + 1) * 2, VECTOR3(3, 0.0));
176 typename VECTOR2::iterator e = jvec.begin();
177 for(
unsigned i=0; i <= div_per_unit; i++) {
178 const double di = (double) i / (
double)div_per_unit;
180 typedef typename VECTOR3::value_type VECTOR4;
181 c0[0] =
static_cast<VECTOR4
>(v0[0] + dj * (v3[0] - v0[0]) + di * (v1[0] - v0[0]));
182 c0[1] =
static_cast<VECTOR4
>(v0[1] + dj * (v3[1] - v0[1]) + di * (v1[1] - v0[1]));
183 c0[2] =
static_cast<VECTOR4
>(v0[2] + dj * (v3[2] - v0[2]) + di * (v1[2] - v0[2]));
185 c1[0] =
static_cast<VECTOR4
>(v0[0] + (dj + d) * (v3[0] - v0[0]) + di * (v1[0] - v0[0]));
186 c1[1] =
static_cast<VECTOR4
>(v0[1] + (dj + d) * (v3[1] - v0[1]) + di * (v1[1] - v0[1]));
187 c1[2] =
static_cast<VECTOR4
>(v0[2] + (dj + d) * (v3[2] - v0[2]) + di * (v1[2] - v0[2]));
196 template <
class ElemBasis>
199 typedef typename ElemBasis::value_type
T;
205 template <
class ElemData,
class VECTOR>
207 const T& value,
const ElemData &cd)
const
217 template <
class VECTOR>
233 template <
class ElemData,
class VECTOR>
235 VECTOR & guess)
const
237 double dist = DBL_MAX;
244 for (
int x = 1; x < end; x++)
246 coord[0] = x / (double) end;
247 for (
int y = 1; y < end; y++)
249 coord[1] = y / (double) end;
250 for (
int z = 1; z < end; z++)
252 coord[2] = z / (double) end;
257 pElem->derivate(coord, cd, derivs);
302 static T GaussianPoints[8][3];
303 static T GaussianWeights[8];
316 {0.211324865405, 0.211324865405, 0.211324865405},
317 {0.788675134595, 0.211324865405, 0.211324865405},
318 {0.788675134595, 0.788675134595, 0.211324865405},
319 {0.211324865405, 0.788675134595, 0.211324865405},
320 {0.211324865405, 0.211324865405, 0.788675134595},
321 {0.788675134595, 0.211324865405, 0.788675134595},
322 {0.788675134595, 0.788675134595, 0.788675134595},
323 {0.211324865405, 0.788675134595, 0.788675134595}};
326 T HexGaussian2<T>::GaussianWeights[8] =
327 {.125, .125, .125, .125, .125, .125, .125, .125};
335 static T GaussianPoints[27][3];
336 static T GaussianWeights[27];
345 {0.11270166537950, 0.11270166537950, 0.11270166537950}, {0.5, 0.11270166537950, 0.11270166537950}, {0.88729833462050, 0.11270166537950, 0.11270166537950},
346 {0.11270166537950, 0.5, 0.11270166537950}, {0.5, 0.5, 0.11270166537950}, {0.88729833462050, 0.5, 0.11270166537950},
347 {0.11270166537950, 0.88729833462050, 0.11270166537950}, {0.5, 0.88729833462050, 0.11270166537950}, {0.88729833462050, 0.88729833462050, 0.11270166537950},
349 {0.11270166537950, 0.11270166537950, 0.5}, {0.5, 0.11270166537950, 0.5}, {0.88729833462050, 0.11270166537950, 0.5},
350 {0.11270166537950, 0.5, 0.5}, {0.5, 0.5, 0.5}, {0.88729833462050, 0.5, 0.5},
351 {0.11270166537950, 0.88729833462050, 0.5}, {0.5, 0.88729833462050, 0.5}, {0.88729833462050, 0.88729833462050, 0.5},
353 {0.11270166537950, 0.11270166537950, 0.88729833462050}, {0.5, 0.11270166537950, 0.88729833462050}, {0.88729833462050, 0.11270166537950, 0.88729833462050},
354 {0.11270166537950, 0.5, 0.88729833462050}, {0.5, 0.5, 0.88729833462050}, {0.88729833462050, 0.5, 0.88729833462050},
355 {0.11270166537950, 0.88729833462050, 0.88729833462050}, {0.5, 0.88729833462050, 0.88729833462050}, {0.88729833462050, 0.88729833462050, 0.88729833462050}
359 T HexGaussian3<T>::GaussianWeights[27] =
361 0.03429355278944, 0.05486968447298, 0.03429355278944,
362 0.05486968447298, 0.08779149517257, 0.05486968447298,
363 0.03429355278944, 0.05486968447298, 0.03429355278944,
365 0.03429355278944, 0.05486968447298, 0.03429355278944,
366 0.05486968447298, 0.08779149517257, 0.05486968447298,
367 0.03429355278944, 0.05486968447298, 0.03429355278944,
369 0.03429355278944, 0.05486968447298, 0.03429355278944,
370 0.05486968447298, 0.08779149517257, 0.05486968447298,
371 0.03429355278944, 0.05486968447298, 0.03429355278944
378 class HexTrilinearLgn :
379 public BasisSimple<T>,
381 public HexGaussian2<double>,
382 public HexSamplingSchemes,
383 public HexTrilinearLgnUnitElement,
384 public HexElementWeights
395 template<
class VECTOR>
397 { get_linear_weights(coords,w); }
399 template<
class VECTOR>
401 { get_linear_derivate_weights(coords,w); }
404 template <
class ElemData,
class VECTOR>
408 get_linear_weights(coords, w);
422 template <
class ElemData,
class VECTOR1,
class VECTOR2>
423 void derivate(
const VECTOR1 &coords,
const ElemData &cd,
424 VECTOR2 &derivs)
const
427 get_linear_derivate_weights(coords, w);
430 derivs[0] =
static_cast<typename VECTOR2::value_type
>(
440 derivs[1] =
static_cast<typename VECTOR2::value_type
>(
450 derivs[2] =
static_cast<typename VECTOR2::value_type
>(
462 template <
class ElemData,
class VECTOR>
464 const ElemData &cd)
const
467 return CL.
get_coords(
this, coords, value, cd);
471 template <
class ElemData>
474 return get_arc3d_length<CrvGaussian1<double> >(
this, edge, cd);
478 template <
class ElemData>
479 double get_area(
const unsigned face,
const ElemData &cd)
const
481 return get_area3<QuadGaussian3<double> >(
this, face, cd);
485 template <
class ElemData>
491 static const std::string type_name(
int n = -1);
501 ASSERT((n >= -1) && n <= 1);
509 static const std::string nm(
"HexTrilinearLgn");
529 std::string(__FILE__),
static int GaussianNum
Definition: HexTrilinearLgn.h:275
static int dofs()
return degrees of freedom
Definition: HexTrilinearLgn.h:82
void approx_edge(const unsigned edge, const unsigned div_per_unit, VECTOR &coords) const
Definition: HexTrilinearLgn.h:123
static T GaussianPoints[1][3]
Definition: HexTrilinearLgn.h:276
static int unit_edges[12][2]
References to vertices of unit edge.
Definition: HexTrilinearLgn.h:54
double check_zero(const VECTOR &derivs, double epsilon=1e-7)
Definition: Locate.h:709
void approx_face(const unsigned face, const unsigned div_per_unit, VECTOR &coords) const
Definition: HexTrilinearLgn.h:158
T value_type
Definition: HexTrilinearLgn.h:387
static int GaussianNum
Definition: HexTrilinearLgn.h:301
Definition: Persistent.h:89
virtual ~HexLocate()
Definition: HexTrilinearLgn.h:202
void initial_guess(const ElemBasis *pElem, const T &val, const ElemData &cd, VECTOR &guess) const
find a reasonable initial guess
Definition: HexTrilinearLgn.h:234
virtual int get_approx_face_elements() const
return number of vertices per face
Definition: HexTrilinearLgn.h:151
Definition: TypeDescription.h:45
#define SCISHARE
Definition: share.h:39
std::vector< const TypeDescription * > td_vec
Definition: TypeDescription.h:56
static int unit_faces[6][4]
References to vertices of unit face.
Definition: HexTrilinearLgn.h:56
Class for creating geometrical approximations of Hex meshes.
Definition: HexTrilinearLgn.h:112
bool get_coords(VECTOR &coords, const T &value, const ElemData &cd) const
get parametric coordinate for value within the element
Definition: HexTrilinearLgn.h:463
void derivate(const VECTOR1 &coords, const ElemData &cd, VECTOR2 &derivs) const
get first derivative at parametric coordinate
Definition: HexTrilinearLgn.h:423
#define ASSERT(condition)
Definition: Assert.h:110
void get_weights(const VECTOR &coords, double *w) const
get weight factors at parametric coordinate
Definition: HexTrilinearLgn.h:396
virtual int begin_class(const std::string &name, int current_version)
Definition: Persistent.cc:143
static int vertices_of_face()
return number of vertices per face
Definition: HexTrilinearLgn.h:90
const string find_type_name(float *)
Definition: TypeName.cc:63
const int HEX_TRILINEAR_LGN_VERSION
Definition: HexTrilinearLgn.h:517
static int faces_of_cell()
return number of faces per cell
Definition: HexTrilinearLgn.h:94
Class with weights and coordinates for 3rd order Gaussian integration.
Definition: HexTrilinearLgn.h:331
double get_arc_length(const unsigned edge, const ElemData &cd) const
get arc length for edge
Definition: HexTrilinearLgn.h:472
const char * name[]
Definition: BoostGraphExampleTests.cc:87
static double domain_size()
return size of the domain
Definition: HexTrilinearLgn.h:70
static int GaussianNum
Definition: HexTrilinearLgn.h:334
Definition: BasisFwd.h:37
Definition: StackVector.h:50
HexApprox()
Definition: HexTrilinearLgn.h:115
virtual ~HexApprox()
Definition: HexTrilinearLgn.h:116
static double unit_vertices[8][3]
Parametric coordinates of vertices of unit edge.
Definition: HexTrilinearLgn.h:52
ElemBasis::value_type T
Definition: HexTrilinearLgn.h:199
Class with weights and coordinates for 1st order Gaussian integration.
Definition: HexTrilinearLgn.h:272
static const std::string make_template_id(const std::string &templateName, const std::string &templateParam)
Definition: TypeName.h:62
HexLocate()
Definition: HexTrilinearLgn.h:201
bool compare_distance(const T &interp, const T &val, double &cur_d, double dist)
Definition: Locate.h:667
static int polynomial_order()
Definition: HexTrilinearLgn.h:392
virtual void end_class()
Definition: Persistent.cc:178
double get_volume(const ElemData &cd) const
get volume
Definition: HexTrilinearLgn.h:486
virtual ~HexTrilinearLgn()
Definition: HexTrilinearLgn.h:390
static double length(int edge)
Definition: HexTrilinearLgn.h:97
void resize(size_t size, const value_type &val=value_type())
Definition: StackVector.h:61
static int domain_dimension()
return dimension of domain
Definition: HexTrilinearLgn.h:66
double get_area(const unsigned face, const ElemData &cd) const
get area
Definition: HexTrilinearLgn.h:479
Class with weights and coordinates for 2nd order Gaussian integration.
Definition: HexTrilinearLgn.h:298
static double volume()
Definition: HexTrilinearLgn.h:107
static const std::string type_name(int n=-1)
Definition: HexTrilinearLgn.h:499
Definition: HexTrilinearLgn.h:197
int n
Definition: eab.py:9
static int number_of_edges()
return number of edges
Definition: HexTrilinearLgn.h:86
static int number_of_mesh_vertices()
return number of vertices
Definition: HexTrilinearLgn.h:78
void get_derivate_weights(const VECTOR &coords, double *w) const
Definition: HexTrilinearLgn.h:400
bool get_iterative(const ElemBasis *pEB, VECTOR &x, const T &value, const ElemData &cd) const
find value in interpolation for given value
Definition: Locate.h:559
bool get_coords(const ElemBasis *pEB, VECTOR &coords, const T &value, const ElemData &cd) const
find value in interpolation for given value
Definition: HexTrilinearLgn.h:206
static double area(int)
Definition: HexTrilinearLgn.h:106
double get_volume3(const ElemBasis *pEB, const ElemData &cd)
Definition: Locate.h:179
virtual void io(Piostream &str)
Definition: HexTrilinearLgn.h:538
HexTrilinearLgn()
Definition: HexTrilinearLgn.h:389
static int number_of_vertices()
return number of vertices
Definition: HexTrilinearLgn.h:74
bool check_coords(const VECTOR &x) const
Definition: HexTrilinearLgn.h:218
Class for describing unit geometry of HexTrilinearLgn.
Definition: HexTrilinearLgn.h:49
Definition: TypeDescription.h:49
static T GaussianWeights[1]
Definition: HexTrilinearLgn.h:277
const TypeDescription * get_type_description(Core::Basis::ConstantBasis< T > *)
Definition: Constant.h:209
T interpolate(const VECTOR &coords, const ElemData &cd) const
get value at parametric coordinate
Definition: HexTrilinearLgn.h:405