28 template<std::
size_t n>
31 for(
unsigned int i=0; i<m; i++)
32 for(
unsigned int j=0;j<n; j++)
33 vec[i].push_back(array[i][j]);
156 {(1 << 1) | (1 << 2),
158 (1 << 0) | (1 << 1)},
168 {(1 << 1) | (1 << 2) | (1 << 3),
169 (1 << 0) | (1 << 2) | (1 << 3),
170 (1 << 0) | (1 << 1) | (1 << 3),
171 (1 << 0) | (1 << 1) | (1 << 2),
174 {(1 << 2) | (1 << 3),
179 (1 << 0) | (1 << 1)},
288 { {0}, {1}, {2}, {3} },
295 template<
unsigned int dim>
300 bp.rows(1, dim ) = lp;
301 bp( 0 ) = 1.0 - arma::sum(lp);
309 template<
unsigned int dim>
317 template<
unsigned int dim>
320 return n_sides - sid - 1;
324 template<
unsigned int dim>
327 ASSERT_LT_DBG(sid, n_sides).error(
"Side number is out of range!");
336 ASSERT_LT_DBG(sid, n_sides).error(
"Side number is out of range!");
338 return node_coords(sid) - node_coords(1-sid);
344 ASSERT_LT_DBG(sid, n_sides).error(
"Side number is out of range!");
345 vec::fixed<2> barycenter, bar_side, n, t;
348 t = node_coords(line_nodes_[sid][1]) - node_coords(line_nodes_[sid][0]);
350 barycenter.fill(1./3);
352 bar_side = node_coords(line_nodes_[sid][0]) - barycenter;
358 if (dot(n,bar_side) < 0) n *= -1;
366 ASSERT_LT_DBG(sid, n_sides).error(
"Side number is out of range!");
367 vec::fixed<3> barycenter, bar_side, n, t1, t2;
370 t1 = node_coords(side_nodes_[sid][1]) - node_coords(side_nodes_[sid][0]);
371 t2 = node_coords(side_nodes_[sid][2]) - node_coords(side_nodes_[sid][0]);
373 barycenter.fill(0.25);
375 bar_side = node_coords(side_nodes_[sid][0]) - barycenter;
380 if (dot(n,bar_side) < 0) n = -n;
387 template<
unsigned int dim>
392 for(
unsigned int i=0; i < dim; i++) {
395 unsigned int i_bary = interact_<0,dim-1>(i_face)[i];
396 face_barycentric[i] = barycentric[ i_bary ];
398 return face_barycentric;
402 template<
unsigned int dim>
406 unsigned int zeros = 0;
407 unsigned int n_zeros = 0;
408 for(
char i=0; i < dim+1; i++){
409 if(std::fabs(barycentric[i]) < tolerance)
411 zeros = zeros | (1 << i);
416 return std::make_pair(n_zeros, zeros);
426 template<
unsigned int dim>
430 for(
unsigned int i=0; i<dim; i++) {
431 bary_unit_vec[i][i] = 1.0;
432 bary_unit_vec[i][dim] = -1.0;
433 bary_unit_vec[dim][i] = -1.0 / dim;
435 bary_unit_vec[dim][dim] = 1.0;
436 return bary_unit_vec;
440 template<
unsigned int dim>
445 for(
unsigned int i_bary=0; i_bary < dim +1; i_bary ++) {
446 if (barycentric[i_bary] < 0.0) {
450 unsigned int i_side = (dim - i_bary);
452 arma::vec projection_to_face(dim+1);
458 projection_to_face = barycentric - barycentric[i_bary]*bary_unit_vec[i_bary];
461 auto bary_on_face = barycentric_on_face(projection_to_face, i_side);
465 return interpolate<dim-1>(sub_clip, i_side);
474 template<
unsigned int dim>
478 if (list.size() == 0) {
480 for(
unsigned int sdim=0; sdim < dim+1; sdim++) {
486 for(
auto &sub_el_nodes : nodes_of_subelements[sdim]) {
489 for(
unsigned int i_node : sub_el_nodes)
490 center+=node_coords( i_node );
492 list[sdim].push_back(center);
498 return list[sub_dim];
505 ASSERT_LT_DBG(sid, n_sides).error(
"Side number is out of range!");
514 ASSERT_LT_DBG(sid, n_sides).error(
"Side number is out of range!");
516 return norm(node_coords(line_nodes_[sid][1]) - node_coords(line_nodes_[sid][0]),2);
523 ASSERT_LT_DBG(sid, n_sides).error(
"Side number is out of range!");
525 return 0.5*norm(cross(node_coords(side_nodes_[sid][1]) - node_coords(side_nodes_[sid][0]),
526 node_coords(side_nodes_[sid][2]) - node_coords(side_nodes_[sid][0])),2);
535 while (side_lines_[f1][i] != side_lines_[f2][j])
536 if (side_lines_[f1][i] < side_lines_[f2][j]) i++;
538 return side_lines_[f1][i];
542 template<
unsigned int dim>
546 for (index = 0; index < n_side_permutations; index++)
547 if (equal(p, p + n_nodes_per_side, side_permutations[index]))
561 template<
unsigned int dim>
563 arma::vec::fixed<dim+1> first_coords,
564 arma::vec::fixed<dim+1> second_coords,
565 double first_theta,
double second_theta,
double theta){
567 arma::vec::fixed<dim+1> bary_interpolated_coords;
568 bary_interpolated_coords = ((theta - first_theta) * second_coords + (second_theta - theta) * first_coords)
569 /(second_theta - first_theta);
570 return bary_interpolated_coords;
static LocalPoint normal_vector(unsigned int sid)
#define ASSERT_EQ_DBG(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
std::vector< std::vector< unsigned int > > _array_to_vec(const IdxVector< n > array[], unsigned int m)
static BaryPoint line_barycentric_interpolation(BaryPoint first_coords, BaryPoint second_coords, double first_theta, double second_theta, double theta)
static unsigned int permutation_index(unsigned int p[n_nodes_per_side])
arma::vec::fixed< dim > LocalPoint
static unsigned int line_between_faces(unsigned int f1, unsigned int f2)
static std::pair< unsigned int, unsigned int > zeros_positions(const BaryPoint &barycentric, double tolerance=std::numeric_limits< double >::epsilon()*2)
static unsigned int normal_orientation(unsigned int sid)
static unsigned int oposite_node(unsigned int sid)
static CentersList centers_of_subelements(unsigned int sub_dim)
static LocalPoint bary_to_local(const BaryPoint &bp)
Converts from barycentric to local coordinates.
Global macros to enhance readability and debugging, general constants.
static FaceBaryPoint barycentric_on_face(const BaryPoint &barycentric, unsigned int i_face)
#define ASSERT_LE_DBG(a, b)
Definition of comparative assert macro (Less or Equal) only for debug mode.
std::array< unsigned int, Size > IdxVector
static double side_measure(unsigned int sid)
arma::vec::fixed< dim > FaceBaryPoint
static BaryPoint local_to_bary(const LocalPoint &lp)
Converts from local to barycentric coordinates.
Class RefElement defines numbering of vertices, sides, calculation of normal vectors etc...
static BarycentricUnitVec make_bary_unit_vec()
static BaryPoint clip(const BaryPoint &barycentric)
arma::vec::fixed< dim+1 > BaryPoint
#define ASSERT_LT_DBG(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.