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]);
150 {(1 << 0) | (1 << 1),
152 (1 << 1) | (1 << 2)},
162 {(1 << 1) | (1 << 2) | (1 << 3),
163 (1 << 0) | (1 << 2) | (1 << 3),
164 (1 << 0) | (1 << 1) | (1 << 3),
165 (1 << 0) | (1 << 1) | (1 << 2),
168 {(1 << 2) | (1 << 3),
173 (1 << 0) | (1 << 1)},
278 { {0}, {1}, {2}, {3} },
285 template<
unsigned int dim>
290 bp.rows(1, dim ) = lp;
291 bp( 0 ) = 1.0 - arma::sum(lp);
299 template<
unsigned int dim>
307 template<
unsigned int dim>
310 return n_sides - sid - 1;
314 template<
unsigned int dim>
317 ASSERT_LT_DBG(sid, n_sides).error(
"Side number is out of range!");
326 ASSERT_LT_DBG(sid, n_sides).error(
"Side number is out of range!");
328 return node_coords(sid) - node_coords(1-sid);
334 ASSERT_LT_DBG(sid, n_sides).error(
"Side number is out of range!");
335 vec::fixed<2> barycenter, bar_side, n, t;
338 t = node_coords(line_nodes_[sid][1]) - node_coords(line_nodes_[sid][0]);
340 barycenter.fill(1./3);
342 bar_side = node_coords(line_nodes_[sid][0]) - barycenter;
348 if (dot(n,bar_side) < 0) n *= -1;
356 ASSERT_LT_DBG(sid, n_sides).error(
"Side number is out of range!");
357 vec::fixed<3> barycenter, bar_side, n, t1, t2;
360 t1 = node_coords(side_nodes_[sid][1]) - node_coords(side_nodes_[sid][0]);
361 t2 = node_coords(side_nodes_[sid][2]) - node_coords(side_nodes_[sid][0]);
363 barycenter.fill(0.25);
365 bar_side = node_coords(side_nodes_[sid][0]) - barycenter;
370 if (dot(n,bar_side) < 0) n = -n;
377 template<
unsigned int dim>
382 for(
unsigned int i=0; i < dim; i++) {
385 unsigned int i_bary = interact_<0,dim-1>(i_face)[i];
386 face_barycentric[i] = barycentric[ i_bary ];
388 return face_barycentric;
392 template<
unsigned int dim>
396 unsigned int zeros = 0;
397 unsigned int n_zeros = 0;
398 for(
char i=0; i < dim+1; i++){
399 if(std::fabs(barycentric[i]) < tolerance)
401 zeros = zeros | (1 << i);
406 return std::make_pair(n_zeros, zeros);
416 template<
unsigned int dim>
420 for(
unsigned int i=0; i<dim; i++) {
421 bary_unit_vec[i][i] = 1.0;
422 bary_unit_vec[i][dim] = -1.0;
423 bary_unit_vec[dim][i] = -1.0 / dim;
425 bary_unit_vec[dim][dim] = 1.0;
426 return bary_unit_vec;
430 template<
unsigned int dim>
435 for(
unsigned int i_bary=0; i_bary < dim +1; i_bary ++) {
436 if (barycentric[i_bary] < 0.0) {
440 unsigned int i_side = (dim - i_bary);
442 arma::vec projection_to_face(dim+1);
448 projection_to_face = barycentric - barycentric[i_bary]*bary_unit_vec[i_bary];
451 auto bary_on_face = barycentric_on_face(projection_to_face, i_side);
464 template<
unsigned int dim>
468 if (list.size() == 0) {
470 for(
unsigned int sdim=0; sdim < dim+1; sdim++) {
476 for(
auto &sub_el_nodes : nodes_of_subelements[sdim]) {
479 for(
unsigned int i_node : sub_el_nodes)
480 center+=node_coords( i_node );
482 list[sdim].push_back(center);
488 return list[sub_dim];
495 ASSERT_LT_DBG(sid, n_sides).error(
"Side number is out of range!");
504 ASSERT_LT_DBG(sid, n_sides).error(
"Side number is out of range!");
506 return norm(node_coords(line_nodes_[sid][1]) - node_coords(line_nodes_[sid][0]),2);
513 ASSERT_LT_DBG(sid, n_sides).error(
"Side number is out of range!");
515 return 0.5*norm(cross(node_coords(side_nodes_[sid][1]) - node_coords(side_nodes_[sid][0]),
516 node_coords(side_nodes_[sid][2]) - node_coords(side_nodes_[sid][0])),2);
525 while (side_lines_[f1][i] != side_lines_[f2][j])
526 if (side_lines_[f1][i] < side_lines_[f2][j]) i++;
528 return side_lines_[f1][i];
532 template<
unsigned int dim>
536 for (index = 0; index < n_side_permutations; index++)
537 if (equal(p, p + n_nodes_per_side, side_permutations[index]))
551 template<
unsigned int dim>
553 arma::vec::fixed<dim+1> first_coords,
554 arma::vec::fixed<dim+1> second_coords,
555 double first_theta,
double second_theta,
double theta){
557 arma::vec::fixed<dim+1> bary_interpolated_coords;
558 bary_interpolated_coords = ((theta - first_theta) * second_coords + (second_theta - theta) * first_coords)
559 /(second_theta - first_theta);
560 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
IntersectionPoint * interpolate(const IntersectionPoint &A1, const IntersectionPoint &A2, double t)
#define ASSERT_LT_DBG(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.