71 #ifndef REF_ELEMENT_HH_ 72 #define REF_ELEMENT_HH_ 138 IdxVector(std::array<unsigned int,Size> data_in);
140 IdxVector(std::initializer_list<unsigned int> data_in);
142 unsigned int operator[](unsigned int idx) const;
146 template<std::
size_t Size>
156 template <
unsigned int OutDim,
unsigned int InDim>
162 template<
unsigned int dim>
184 static LocalPoint node_coords(
unsigned int nid);
190 static LocalPoint normal_vector(
unsigned int sid);
198 static BaryPoint clip(
const BaryPoint &barycentric);
203 static unsigned int normal_orientation(
unsigned int sid);
205 static double side_measure(
unsigned int sid);
213 static unsigned int oposite_node(
unsigned int sid);
219 static unsigned int line_between_faces(
unsigned int f1,
unsigned int f2);
222 static const unsigned int n_sides = dim + 1;
223 static const unsigned int n_nodes = dim + 1;
224 static const unsigned int n_nodes_per_side = dim;
225 static const unsigned int n_lines_per_node = dim;
226 static const unsigned int n_nodes_per_line = 2;
227 static const unsigned int n_sides_per_line = 2;
228 static const unsigned int n_sides_per_node = dim;
231 static const unsigned int n_lines_per_side = (
unsigned int)((dim * (dim - 1)) / 2);
234 static const unsigned int n_lines = (
unsigned int)((dim * (dim + 1)) / 2);
268 static constexpr
unsigned int n_side_permutations = (dim+1)*(2*dim*dim-5*dim+6)/6;
280 static unsigned int permutation_index(
unsigned int p[n_nodes_per_side]);
286 static BaryPoint local_to_bary(
const LocalPoint& lp);
292 static LocalPoint bary_to_local(
const BaryPoint& bp);
299 static BarycentricUnitVec make_bary_unit_vec();
306 static FaceBaryPoint barycentric_on_face(
const BaryPoint &barycentric,
unsigned int i_face);
310 static CentersList centers_of_subelements(
unsigned int sub_dim);
316 static std::pair<unsigned int, unsigned int> zeros_positions(
const BaryPoint &barycentric,
317 double tolerance = std::numeric_limits<double>::epsilon()*2);
327 template<
unsigned int subdim>
static unsigned int topology_idx(
unsigned int zeros_positions);
334 template<
unsigned int subdim>
static unsigned int count();
343 template<
unsigned int subdim>
static arma::mat::fixed<dim+1,subdim+1> bary_coords(
unsigned int sid);
349 template<
unsigned int subdim>
static BaryPoint interpolate(arma::vec::fixed<subdim+1> coord,
int sub_simplex_idx);
355 static BaryPoint line_barycentric_interpolation(BaryPoint first_coords,
356 BaryPoint second_coords,
357 double first_theta,
double second_theta,
double theta);
390 template <
template <
unsigned int OutDim,
unsigned int InDim>
class TInteraction,
unsigned int OutDim,
unsigned int InDim>
391 static const IdxVector< (InDim>OutDim ? InDim+1 : dim-InDim) > interact( TInteraction<OutDim,InDim> interaction );
396 template<
unsigned int OutDim,
unsigned int InDim>
397 static const IdxVector< (InDim>OutDim ? InDim+1 : dim-InDim) > interact_(
unsigned int index);
473 template<
unsigned int dim>
474 template<
unsigned int subdim>
inline 477 arma::mat::fixed<dim+1,subdim+1> bary_c;
479 for(
unsigned int i = 0; i < subdim+1; i++){
480 unsigned int nid = interact_<0,subdim>(sid)[i];
481 bary_c.col(i).zeros();
482 bary_c.col(i)(nid) = 1;
489 template<
unsigned int dim>
inline 492 ASSERT_LT_DBG(nid, n_nodes).error(
"Node number is out of range!");
494 arma::vec::fixed<dim> p;
504 template<
unsigned int dim>
505 template<
unsigned int subdim>
562 template<
unsigned int dim>
563 template<
unsigned int subdim>
566 for(
unsigned int i=0; i < RefElement<dim>::count<subdim>(); i++){
567 if(zeros_positions == topology_zeros_[subdim][i])
return i;
569 ASSERT(0).error(
"Undefined zero pattern.");
580 template<>
template<>
inline const IdxVector<2> RefElement<1>::interact_<0,1>(
unsigned int i)
582 return line_nodes_[i];}
587 return line_nodes_[i];}
592 return line_nodes_[i];}
595 template<>
template<>
inline const IdxVector<1> RefElement<1>::interact_<1,0>(
unsigned int i)
597 return node_lines_[i];}
600 template<>
template<>
inline const IdxVector<2> RefElement<2>::interact_<1,0>(
unsigned int i)
602 return node_lines_[i];}
605 template<>
template<>
inline const IdxVector<3> RefElement<3>::interact_<1,0>(
unsigned int i)
607 return node_lines_[i];}
610 template<>
template<>
inline const IdxVector<3> RefElement<3>::interact_<0,2>(
unsigned int i)
612 return side_nodes_[i];}
615 template<>
template<>
inline const IdxVector<3> RefElement<3>::interact_<2,0>(
unsigned int i)
617 return node_sides_[i];}
620 template<>
template<>
inline const IdxVector<2> RefElement<3>::interact_<2,1>(
unsigned int i)
622 return line_sides_[i];}
625 template<>
template<>
inline const IdxVector<3> RefElement<3>::interact_<1,2>(
unsigned int i)
627 return side_lines_[i];}
629 template<
unsigned int dim>
template<
unsigned int OutDim,
unsigned int InDim>
632 ASSERT(
false)(dim)(OutDim)(InDim)(i).error(
"Not implemented.");
639 template<
unsigned int dim>
640 template <
template <
unsigned int OutDim,
unsigned int InDim>
class TInteraction,
unsigned int OutDim,
unsigned int InDim>
643 return interact_<OutDim,InDim>(interaction.i_);
static const std::vector< IdxVector< n_sides_per_line > > line_sides_
[n_lines] For given line, returns sides indices. For dim == 3.
Armor::ArmaVec< double, dim > FaceBaryPoint
static arma::mat::fixed< dim+1, subdim+1 > bary_coords(unsigned int sid)
static const std::vector< IdxVector< n_nodes_per_side > > side_nodes_
[n_sides] For given side, returns nodes indices. For dim == 3.
static const std::vector< IdxVector< n_lines_per_node > > node_lines_
[n_nodes] For given node, returns lines indices.
static BaryPoint interpolate(arma::vec::fixed< subdim+1 > coord, int sub_simplex_idx)
#define DECLARE_EXCEPTION(ExcName, Format)
Macro for simple definition of exceptions.
std::vector< BaryPoint > BarycentricUnitVec
arma::vec::fixed< dim > LocalPoint
static const std::vector< IdxVector< n_nodes_per_line > > line_nodes_
[n_lines] For given line, returns its nodes indices.
static const std::vector< std::vector< std::vector< unsigned int > > > nodes_of_subelements
Armor::ArmaVec< double, dim+1 > BaryPoint
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library...
static LocalPoint node_coords(unsigned int nid)
Interaction(unsigned int i)
const std::vector< LocalPoint > & CentersList
std::array< unsigned int, Size > IdxVector
typename arma::Col< Type >::template fixed< nr > ArmaVec
static const std::vector< std::vector< unsigned int > > side_permutations
static unsigned int topology_idx(unsigned int zeros_positions)
static const std::vector< IdxVector< n_lines_per_side > > side_lines_
[n_sides] For given side, returns lines indices. For dim == 3.
static const std::vector< IdxVector< n_sides_per_node > > node_sides_
[n_nodes] For given node, returns sides indices. For dim == 3.
#define ASSERT_LT_DBG(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.