32 #ifndef CORE_BASIS_TRILINEARLGN_H
33 #define CORE_BASIS_TRILINEARLGN_H 1
94 static inline double length(
int edge)
98 const double dx = v1[0] - v0[0];
99 const double dy = v1[1] - v0[1];
100 return sqrt(dx*dx+dy*dy);
103 static double area(
int ) {
return 0.5; }
117 template<
class VECTOR>
119 const unsigned div_per_unit,
120 VECTOR &coords)
const
122 typedef typename VECTOR::value_type VECTOR2;
124 coords.resize(div_per_unit+1);
129 const double &p1x = v0[0];
130 const double &p1y = v0[1];
131 const double dx = v1[0] - p1x;
132 const double dy = v1[1] - p1y;
134 for(
unsigned i = 0; i <= div_per_unit; i++) {
135 const double d = (double)i / (
double)div_per_unit;
136 typename VECTOR::value_type &tmp = coords[i];
138 tmp[0] =
static_cast<typename VECTOR2::value_type
>(p1x + d * dx);
139 tmp[1] =
static_cast<typename VECTOR2::value_type
>(p1y + d * dy);
146 template<
class VECTOR>
148 const unsigned div_per_unit,
149 VECTOR &coords)
const
151 typedef typename VECTOR::value_type VECTOR2;
152 typedef typename VECTOR2::value_type VECTOR3;
154 coords.resize(div_per_unit);
155 const double d = 1. / div_per_unit;
157 for(
unsigned j = 0; j < div_per_unit; j++)
159 const double dj = (double)j / (
double)div_per_unit;
161 coords[j].resize((div_per_unit - j) * 2 + 1);
162 typename VECTOR2::value_type& tmp = coords[j][e++];
166 for(
unsigned i = 0; i<div_per_unit - j; i++)
168 const double di = (double)i / (
double)div_per_unit;
169 typename VECTOR2::value_type& tmp1 = coords[j][e++];
171 tmp1[0] =
static_cast<typename VECTOR3::value_type
>(di);
172 tmp1[1] =
static_cast<typename VECTOR3::value_type
>(dj + d);
173 typename VECTOR2::value_type& tmp2 = coords[j][e++];
175 tmp2[0] =
static_cast<typename VECTOR3::value_type
>(di + d);
176 tmp2[1] =
static_cast<typename VECTOR3::value_type
>(dj);
184 template <
class ElemBasis>
187 typedef typename ElemBasis::value_type
T;
193 template <
class ElemData,
class VECTOR>
195 const T& value,
const ElemData &cd)
const
203 template<
class VECTOR>
216 template <
class ElemData,
class VECTOR>
218 VECTOR & guess)
const
220 double dist = DBL_MAX;
227 for (
int x = 1; x < end; x++)
229 coord[0] = x / (double) end;
230 for (
int y = 1; y < end; y++)
232 coord[1] = y / (double) end;
239 pElem->derivate(coord, cd, derivs);
285 {1./6.,1./6.}, {2./3.,1./6.}, {1./6.,2./3.}};
288 T TriGaussian2<T>::GaussianWeights[3] = {1./3., 1./3., 1./3.};
305 {0.1012865073, 0.1012865073}, {0.7974269853, 0.1012865073}, {0.1012865073, 0.7974269853},
306 {0.4701420641, 0.0597158717}, {0.4701420641, 0.4701420641}, {0.0597158717, 0.4701420641},
307 {0.3333333333, 0.3333333333}};
310 T TriGaussian3<T>::GaussianWeights[7] =
311 {0.1259391805, 0.1259391805, 0.1259391805, 0.1323941527, 0.1323941527, 0.1323941527, 0.225};
315 template class TriGaussian1<double>;
316 template class TriGaussian2<double>;
317 template class TriGaussian3<double>;
340 template<
class VECTOR>
342 { get_linear_weights(coords,w); }
344 template<
class VECTOR>
346 { get_linear_derivate_weights(coords,w); }
349 template <
class ElemData,
class VECTOR>
353 get_linear_weights(coords, w);
355 return (T)(w[0] * cd.node0() +
361 template <
class ElemData,
class VECTOR1,
class VECTOR2>
363 VECTOR2 &derivs)
const
367 derivs[0] =
static_cast<typename VECTOR2::value_type
>(-1. * cd.node0() + cd.node1());
368 derivs[1] =
static_cast<typename VECTOR2::value_type
>(-1. * cd.node0() + cd.node2());
372 template <
class ElemData,
class VECTOR>
374 const ElemData &cd)
const
377 return CL.
get_coords(
this, coords, value, cd);
381 template <
class ElemData>
384 return get_arc2d_length<CrvGaussian1<double> >(
this, edge, cd);
388 template <
class ElemData>
389 double get_area(
const unsigned face,
const ElemData &cd)
const
391 return get_area2<TriGaussian2<double> >(
this, face, cd);
395 template <
class ElemData>
401 template<
class VECTOR>
403 const unsigned int div_per_unit,
404 VECTOR &coords)
const
406 typedef typename VECTOR::value_type VECTOR2;
408 coords.resize(div_per_unit + 1);
413 const double &p1x = v0[0];
414 const double &p1y = v0[1];
415 const double dx = v1[0] - p1x;
416 const double dy = v1[1] - p1y;
418 for(
unsigned int i = 0; i <= div_per_unit; i++) {
419 const double d = (double)i / (
double)div_per_unit;
420 typename VECTOR::value_type &tmp = coords[i];
422 tmp[0] =
static_cast<typename VECTOR2::value_type
>(p1x + d * dx);
423 tmp[1] =
static_cast<typename VECTOR2::value_type
>(p1y + d * dy);
427 template<
class VECTOR>
429 const unsigned int div_per_unit,
430 VECTOR &coords)
const
432 typedef typename VECTOR::value_type VECTOR2;
433 typedef typename VECTOR2::value_type VECTOR3;
439 coords.resize(div_per_unit);
440 const double d = 1. / div_per_unit;
441 for(
unsigned int j = 0; j<div_per_unit; j++)
443 const double dj = (double)j / (
double)div_per_unit;
445 coords[j].resize((div_per_unit - j) * 2 + 1);
446 typename VECTOR2::value_type &tmp = coords[j][e++];
448 tmp[0] =
static_cast<typename VECTOR3::value_type
>(v0[0] + dj * (v2[0] - v0[0]));
449 tmp[1] =
static_cast<typename VECTOR3::value_type
>(v0[1] + dj * (v2[1] - v0[1]));
451 for(
unsigned int i = 0; i<div_per_unit - j; i++)
453 const double di = (double)i / (
double)div_per_unit;
454 typename VECTOR2::value_type &tmp1 = coords[j][e++];
456 tmp1[0] =
static_cast<typename VECTOR3::value_type
>(v0[0] + (dj + d) * (v2[0] - v0[0]) + di * (v1[0] - v0[0]));
457 tmp1[1] =
static_cast<typename VECTOR3::value_type
>(v0[1] + (dj + d) * (v2[1] - v0[1]) + di * (v1[1] - v0[1]));
459 typename VECTOR2::value_type &tmp2 = coords[j][e++];
461 tmp2[0] =
static_cast<typename VECTOR3::value_type
>(v0[0] + dj * (v2[0] - v0[0]) + (di + d) * (v1[0] - v0[0]));
462 tmp2[1] =
static_cast<typename VECTOR3::value_type
>(v0[1] + dj * (v2[1] - v0[1]) + (di + d) * (v1[1] - v0[1]));
468 static const std::string type_name(
int n = -1);
481 ASSERT((n >= -1) && n <= 1);
489 static const std::string nm(
"TriLinearLgn");
507 std::string(__FILE__),
void get_derivate_weights(const VECTOR &coords, double *w) const
Definition: TriLinearLgn.h:345
TriLinearLgn()
Definition: TriLinearLgn.h:335
static SCISHARE int unit_faces[1][3]
References to vertices of unit face.
Definition: TriLinearLgn.h:53
Class with weights and coordinates for 2nd order Gaussian integration.
Definition: TriLinearLgn.h:272
static int number_of_mesh_vertices()
return number of vertices in mesh
Definition: TriLinearLgn.h:75
static SCISHARE int unit_edges[3][2]
References to vertices of unit edge.
Definition: TriLinearLgn.h:51
static T GaussianPoints[3][2]
Definition: TriLinearLgn.h:276
double check_zero(const VECTOR &derivs, double epsilon=1e-7)
Definition: Locate.h:709
bool get_coords(const ElemBasis *pEB, VECTOR &coords, const T &value, const ElemData &cd) const
find value in interpolation for given value
Definition: TriLinearLgn.h:194
virtual ~TriLinearLgnUnitElement()
Definition: TriLinearLgn.h:60
static int domain_dimension()
return dimension of domain
Definition: TriLinearLgn.h:63
T value_type
Definition: TriLinearLgn.h:333
Definition: Persistent.h:89
Class for creating geometrical approximations of Tri meshes.
Definition: TriLinearLgn.h:109
static int GaussianNum
Definition: TriLinearLgn.h:295
static int dofs()
return degrees of freedom
Definition: TriLinearLgn.h:79
bool get_coords(VECTOR &coords, const T &value, const ElemData &cd) const
get the parametric coordinate for value within the element
Definition: TriLinearLgn.h:373
static const std::string type_name(int n=-1)
Definition: TriLinearLgn.h:479
const int TRILINEARLGN_VERSION
Definition: TriLinearLgn.h:514
Definition: TypeDescription.h:45
#define SCISHARE
Definition: share.h:39
std::vector< const TypeDescription * > td_vec
Definition: TypeDescription.h:56
bool check_coords(const VECTOR &x) const
Definition: TriLinearLgn.h:204
void initial_guess(const ElemBasis *pElem, const T &val, const ElemData &cd, VECTOR &guess) const
find a reasonable initial guess
Definition: TriLinearLgn.h:217
Class with weights and coordinates for 2nd order Gaussian integration.
Definition: TriLinearLgn.h:253
void approx_edge(const unsigned edge, const unsigned div_per_unit, VECTOR &coords) const
Definition: TriLinearLgn.h:118
#define ASSERT(condition)
Definition: Assert.h:110
Class for describing interfaces to basis elements.
Definition: Basis.h:48
static int faces_of_cell()
return number of faces per cell
Definition: TriLinearLgn.h:91
static int vertices_of_face()
return number of vertices per face
Definition: TriLinearLgn.h:87
virtual int begin_class(const std::string &name, int current_version)
Definition: Persistent.cc:143
static int number_of_edges()
return number of edges
Definition: TriLinearLgn.h:83
ElemBasis::value_type T
Definition: Locate.h:587
T interpolate(const VECTOR &coords, const ElemData &cd) const
get value at parametric coordinate
Definition: TriLinearLgn.h:350
const string find_type_name(float *)
Definition: TypeName.cc:63
static double domain_size()
return size of the domain
Definition: TriLinearLgn.h:67
static T GaussianPoints[1][2]
Definition: TriLinearLgn.h:257
static double volume()
return volume
Definition: TriLinearLgn.h:104
static T GaussianWeights[7]
Definition: TriLinearLgn.h:297
static SCISHARE double unit_center[2]
The center of the unit element.
Definition: TriLinearLgn.h:57
const char * name[]
Definition: BoostGraphExampleTests.cc:87
double get_area(const unsigned face, const ElemData &cd) const
get area
Definition: TriLinearLgn.h:389
static int number_of_vertices()
return number of vertices
Definition: TriLinearLgn.h:71
Definition: StackVector.h:50
TriApprox()
Definition: TriLinearLgn.h:111
TriLocate()
Definition: TriLinearLgn.h:189
static int GaussianNum
Definition: TriLinearLgn.h:275
static SCISHARE double unit_vertices[3][2]
Parametric coordinates of vertices of unit edge.
Definition: TriLinearLgn.h:49
void approx_face(const unsigned int, const unsigned int div_per_unit, VECTOR &coords) const
Definition: TriLinearLgn.h:428
static T GaussianWeights[1]
Definition: TriLinearLgn.h:258
static const std::string make_template_id(const std::string &templateName, const std::string &templateParam)
Definition: TypeName.h:62
void get_weights(const VECTOR &coords, double *w) const
Definition: TriLinearLgn.h:341
static T GaussianWeights[3]
Definition: TriLinearLgn.h:277
double get_arc_length(const unsigned edge, const ElemData &cd) const
get arc length for edge
Definition: TriLinearLgn.h:382
Class for describing unit geometry of TriLinearLgn.
Definition: TriLinearLgn.h:46
void approx_edge(const unsigned int edge, const unsigned int div_per_unit, VECTOR &coords) const
Definition: TriLinearLgn.h:402
Definition: TriElementWeights.h:36
Definition: TriLinearLgn.h:324
virtual void io(Piostream &str)
Definition: TriLinearLgn.h:517
virtual ~TriApprox()
Definition: TriLinearLgn.h:112
bool compare_distance(const T &interp, const T &val, double &cur_d, double dist)
Definition: Locate.h:667
static SCISHARE double unit_face_normals[1][3]
References to normal of unit face.
Definition: TriLinearLgn.h:55
static int GaussianNum
Definition: TriLinearLgn.h:256
virtual void end_class()
Definition: Persistent.cc:178
void derivate(const VECTOR1 &, const ElemData &cd, VECTOR2 &derivs) const
get first derivative at parametric coordinate
Definition: TriLinearLgn.h:362
double get_volume(const ElemData &) const
get volume
Definition: TriLinearLgn.h:396
void resize(size_t size, const value_type &val=value_type())
Definition: StackVector.h:61
static double area(int)
return area
Definition: TriLinearLgn.h:103
void approx_face(const unsigned, const unsigned div_per_unit, VECTOR &coords) const
Definition: TriLinearLgn.h:147
Definition: TriSamplingSchemes.h:43
int n
Definition: eab.py:9
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:597
Class with weights and coordinates for 3rd order Gaussian integration.
Definition: TriLinearLgn.h:292
virtual ~TriLinearLgn()
Definition: TriLinearLgn.h:336
static int polynomial_order()
Definition: TriLinearLgn.h:338
virtual ~TriLocate()
Definition: TriLinearLgn.h:190
static double length(int edge)
Definition: TriLinearLgn.h:94
Definition: TriLinearLgn.h:185
TriLinearLgnUnitElement()
Definition: TriLinearLgn.h:59
ElemBasis::value_type T
Definition: TriLinearLgn.h:187
static T GaussianPoints[7][2]
Definition: TriLinearLgn.h:296
Definition: TypeDescription.h:49
const TypeDescription * get_type_description(Core::Basis::ConstantBasis< T > *)
Definition: Constant.h:209