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]);
132 {(1 << 1) | (1 << 2),
134 (1 << 0) | (1 << 1)},
144 {(1 << 1) | (1 << 2) | (1 << 3),
145 (1 << 0) | (1 << 2) | (1 << 3),
146 (1 << 0) | (1 << 1) | (1 << 3),
147 (1 << 0) | (1 << 1) | (1 << 2),
150 {(1 << 2) | (1 << 3),
155 (1 << 0) | (1 << 1)},
264 { {0}, {1}, {2}, {3} },
271 template<
unsigned int dim>
276 bp.rows(1, dim ) = lp;
277 bp( 0 ) = 1.0 - arma::sum(lp);
285 template<
unsigned int dim>
293 template<
unsigned int dim>
296 return n_sides - sid - 1;
300 template<
unsigned int dim>
303 ASSERT_LT_DBG(sid, n_sides).error(
"Side number is out of range!");
312 ASSERT_LT_DBG(sid, n_sides).error(
"Side number is out of range!");
314 return node_coords(sid) - node_coords(1-sid);
320 ASSERT_LT_DBG(sid, n_sides).error(
"Side number is out of range!");
321 vec::fixed<2> barycenter, bar_side, n, t;
324 t = node_coords(line_nodes_[sid][1]) - node_coords(line_nodes_[sid][0]);
326 barycenter.fill(1./3);
328 bar_side = node_coords(line_nodes_[sid][0]) - barycenter;
334 if (dot(n,bar_side) < 0) n *= -1;
342 ASSERT_LT_DBG(sid, n_sides).error(
"Side number is out of range!");
343 vec::fixed<3> barycenter, bar_side, n, t1, t2;
346 t1 = node_coords(side_nodes_[sid][1]) - node_coords(side_nodes_[sid][0]);
347 t2 = node_coords(side_nodes_[sid][2]) - node_coords(side_nodes_[sid][0]);
349 barycenter.fill(0.25);
351 bar_side = node_coords(side_nodes_[sid][0]) - barycenter;
356 if (dot(n,bar_side) < 0) n = -n;
363 template<
unsigned int dim>
368 for(
unsigned int i=0; i < dim; i++) {
371 unsigned int i_bary = interact_<0,dim-1>(i_face)[i];
372 face_barycentric[i] = barycentric[ i_bary ];
374 return face_barycentric;
378 template<
unsigned int dim>
382 unsigned int zeros = 0;
383 unsigned int n_zeros = 0;
384 for(
unsigned int i=0; i < dim+1; i++){
385 if(std::fabs(barycentric[i]) <
tolerance)
387 zeros = zeros | (1 << i);
392 return std::make_pair(n_zeros, zeros);
402 template<
unsigned int dim>
406 for(
unsigned int i=0; i<dim; i++) {
407 bary_unit_vec[i][i] = 1.0;
408 bary_unit_vec[i][dim] = -1.0;
409 bary_unit_vec[dim][i] = -1.0 / dim;
411 bary_unit_vec[dim][dim] = 1.0;
412 return bary_unit_vec;
416 template<
unsigned int dim>
421 for(
unsigned int i_bary=0; i_bary < dim +1; i_bary ++) {
422 if (barycentric[i_bary] < 0.0) {
426 unsigned int i_side = (dim - i_bary);
434 projection_to_face = barycentric - barycentric[i_bary]*bary_unit_vec[i_bary];
437 auto bary_on_face = barycentric_on_face(projection_to_face, i_side);
441 return interpolate<dim-1>(sub_clip, i_side);
450 template<
unsigned int dim>
454 if (
list.size() == 0) {
456 for(
unsigned int sdim=0; sdim < dim+1; sdim++) {
462 for(
auto &sub_el_nodes : nodes_of_subelements[sdim]) {
465 for(
unsigned int i_node : sub_el_nodes)
466 center+=node_coords( i_node );
468 list[sdim].push_back(center);
474 return list[sub_dim];
481 ASSERT_LT_DBG(sid, n_sides).error(
"Side number is out of range!");
490 ASSERT_LT_DBG(sid, n_sides).error(
"Side number is out of range!");
492 return norm(node_coords(line_nodes_[sid][1]) - node_coords(line_nodes_[sid][0]),2);
499 ASSERT_LT_DBG(sid, n_sides).error(
"Side number is out of range!");
501 return 0.5*norm(cross(node_coords(side_nodes_[sid][1]) - node_coords(side_nodes_[sid][0]),
502 node_coords(side_nodes_[sid][2]) - node_coords(side_nodes_[sid][0])),2);
511 while (side_lines_[f1][i] != side_lines_[f2][j])
512 if (side_lines_[f1][i] < side_lines_[f2][j]) i++;
514 return side_lines_[f1][i];
523 template<
unsigned int dim>
525 arma::vec::fixed<dim+1> first_coords,
526 arma::vec::fixed<dim+1> second_coords,
527 double first_theta,
double second_theta,
double theta){
529 arma::vec::fixed<dim+1> bary_interpolated_coords;
530 bary_interpolated_coords = ((theta - first_theta) * second_coords + (second_theta - theta) * first_coords)
531 /(second_theta - first_theta);
532 return bary_interpolated_coords;