28 template<std::
size_t n>
31 for(
unsigned int i=0; i<array_vec.size(); i++)
32 for(
unsigned int j=0;j<n; j++)
33 vec[i].push_back(array_vec[i][j]);
165 {(1 << 1) | (1 << 2),
167 (1 << 0) | (1 << 1)},
177 {(1 << 1) | (1 << 2) | (1 << 3),
178 (1 << 0) | (1 << 2) | (1 << 3),
179 (1 << 0) | (1 << 1) | (1 << 3),
180 (1 << 0) | (1 << 1) | (1 << 2),
183 {(1 << 2) | (1 << 3),
188 (1 << 0) | (1 << 1)},
297 { {0}, {1}, {2}, {3} },
304 template<
unsigned int dim>
309 bp.rows(1, dim ) = lp;
310 bp( 0 ) = 1.0 - arma::sum(lp);
318 template<
unsigned int dim>
326 template<
unsigned int dim>
329 return n_sides - sid - 1;
333 template<
unsigned int dim>
336 ASSERT_LT_DBG(sid, n_sides).error(
"Side number is out of range!");
345 ASSERT_LT_DBG(sid, n_sides).error(
"Side number is out of range!");
347 return node_coords(sid) - node_coords(1-sid);
353 ASSERT_LT_DBG(sid, n_sides).error(
"Side number is out of range!");
354 vec::fixed<2> barycenter, bar_side, n, t;
357 t = node_coords(line_nodes_[sid][1]) - node_coords(line_nodes_[sid][0]);
359 barycenter.fill(1./3);
361 bar_side = node_coords(line_nodes_[sid][0]) - barycenter;
367 if (dot(n,bar_side) < 0) n *= -1;
375 ASSERT_LT_DBG(sid, n_sides).error(
"Side number is out of range!");
376 vec::fixed<3> barycenter, bar_side, n, t1, t2;
379 t1 = node_coords(side_nodes_[sid][1]) - node_coords(side_nodes_[sid][0]);
380 t2 = node_coords(side_nodes_[sid][2]) - node_coords(side_nodes_[sid][0]);
382 barycenter.fill(0.25);
384 bar_side = node_coords(side_nodes_[sid][0]) - barycenter;
389 if (dot(n,bar_side) < 0) n = -n;
396 template<
unsigned int dim>
401 for(
unsigned int i=0; i < dim; i++) {
404 unsigned int i_bary = interact_<0,dim-1>(i_face)[i];
405 face_barycentric[i] = barycentric[ i_bary ];
407 return face_barycentric;
411 template<
unsigned int dim>
415 unsigned int zeros = 0;
416 unsigned int n_zeros = 0;
417 for(
unsigned int i=0; i < dim+1; i++){
418 if(std::fabs(barycentric[i]) < tolerance)
420 zeros = zeros | (1 << i);
425 return std::make_pair(n_zeros, zeros);
435 template<
unsigned int dim>
439 for(
unsigned int i=0; i<dim; i++) {
440 bary_unit_vec[i][i] = 1.0;
441 bary_unit_vec[i][dim] = -1.0;
442 bary_unit_vec[dim][i] = -1.0 / dim;
444 bary_unit_vec[dim][dim] = 1.0;
445 return bary_unit_vec;
449 template<
unsigned int dim>
454 for(
unsigned int i_bary=0; i_bary < dim +1; i_bary ++) {
455 if (barycentric[i_bary] < 0.0) {
459 unsigned int i_side = (dim - i_bary);
467 projection_to_face = barycentric - barycentric[i_bary]*bary_unit_vec[i_bary];
470 auto bary_on_face = barycentric_on_face(projection_to_face, i_side);
474 return interpolate<dim-1>(sub_clip, i_side);
483 template<
unsigned int dim>
487 if (list.size() == 0) {
489 for(
unsigned int sdim=0; sdim < dim+1; sdim++) {
495 for(
auto &sub_el_nodes : nodes_of_subelements[sdim]) {
498 for(
unsigned int i_node : sub_el_nodes)
499 center+=node_coords( i_node );
501 list[sdim].push_back(center);
507 return list[sub_dim];
514 ASSERT_LT_DBG(sid, n_sides).error(
"Side number is out of range!");
523 ASSERT_LT_DBG(sid, n_sides).error(
"Side number is out of range!");
525 return norm(node_coords(line_nodes_[sid][1]) - node_coords(line_nodes_[sid][0]),2);
532 ASSERT_LT_DBG(sid, n_sides).error(
"Side number is out of range!");
534 return 0.5*norm(cross(node_coords(side_nodes_[sid][1]) - node_coords(side_nodes_[sid][0]),
535 node_coords(side_nodes_[sid][2]) - node_coords(side_nodes_[sid][0])),2);
544 while (side_lines_[f1][i] != side_lines_[f2][j])
545 if (side_lines_[f1][i] < side_lines_[f2][j]) i++;
547 return side_lines_[f1][i];
551 template<
unsigned int dim>
555 for (index = 0; index < n_side_permutations; index++)
556 if (equal(p, p + n_nodes_per_side, side_permutations[index].data()))
570 template<
unsigned int dim>
572 arma::vec::fixed<dim+1> first_coords,
573 arma::vec::fixed<dim+1> second_coords,
574 double first_theta,
double second_theta,
double theta){
576 arma::vec::fixed<dim+1> bary_interpolated_coords;
577 bary_interpolated_coords = ((theta - first_theta) * second_coords + (second_theta - theta) * first_coords)
578 /(second_theta - first_theta);
579 return bary_interpolated_coords;
Armor::ArmaVec< double, dim > FaceBaryPoint
static LocalPoint normal_vector(unsigned int sid)
#define ASSERT_EQ_DBG(a, b)
Definition of comparative assert macro (EQual) only for debug mode.
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)
Armor::ArmaVec< double, dim+1 > BaryPoint
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)
std::vector< std::vector< unsigned int > > _array_to_vec(const std::vector< IdxVector< n >> array_vec)
#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)
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)
#define ASSERT_LT_DBG(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.