Flow123d  JS_before_hm-1-ge159291
ref_element.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file ref_element.hh
15  * @brief Class RefElement defines numbering of vertices, sides, calculation of normal vectors etc.
16  * @author Jan Stebel
17  * @todo
18  *
19  * TODO: reconsider following whether it is actual...
20  * - design interface in such a way, that we can change numbering
21  * - design numbering and orientations on ref element that is consistent (orientation and numbering od 2d el. match sides of 3d),
22  * and possibly allows permute vertices of elements so that sides sharing an edge match numbering and orientation (we dos'nt need permute faces)
23  *
24  * Proposal(prefers combinatoric order) :
25  * 1D - orientation V0 -> V1
26  *
27  * 2D - edges: E0: V0 -> V1,
28  * E1: V0 -> V2
29  * E2: V1 -> V2
30  * This maximize number of edge orientations achievable by edge permutations
31  * edge numbering edge orientation( in original numbering)
32  * 0 1 2 + + +
33  * 0 2 1 - + +
34  * 1 0 2 + + -
35  * 1 2 0 - - +
36  * 2 0 1 + - -
37  * 2 1 0 - - -
38  *
39  * vertices edges normal (out = +)
40  * 3D - sides: S0: 0 1 2 E0 E1 E3 -
41  * S1: 0 1 3 E0 E2 E4 +
42  * S2: 0 2 3 E1 E2 E5 -
43  * S3: 1 2 3 E3 E4 E5 -
44  *
45  * edges: E0: V0 -> V1 x direction
46  * E1: V0 -> V2 y direction
47  * E2: V0 -> V3 z direction
48  * E3: V1 -> V2
49  * E4: V1 -> V3
50  * E5: V2 -> V3
51  *
52  * - functions from DEAL.ii:
53  * bool is_inside_unit_cell( point )
54  * line_to_cell_vertices(line, vertex) vertex index on line to index on whole element
55  * face_to_cell_vertices(face, vertex, Orientation), Orientation should be some class describing permutation of shared face to element's face/side
56  * face_to_cel_lines
57  * standard_to_real_face_vertex(vertex, Orientation), maps vertex to permuted face
58  * real_to_standard_face_vertex - inverse
59  * ... same for line; we should need also something like standard_to_real_line_vertex; Deal dosn;t support Orientation changes for 2D element faces
60  * Point unit_cell_vertex(vertex) - coordinates
61  * project_to_unit_cell
62  * distance_to_unit_cell
63  * d_linear_shape_function
64  *
65  * - can not change numbering of element sides due to DarcyFlow, which use hardwired side numbering in construction of basis functions
66  * - any change of side numbering requires also change in flow/old_bcd.cc
67  *
68  *
69  */
70 
71 #ifndef REF_ELEMENT_HH_
72 #define REF_ELEMENT_HH_
73 
74 #include <vector> // for vector
75 #include <array>
76 #include <armadillo>
77 #include "system/asserts.hh"
78 
79 
80 /*
81  * Ordering of nodes and sides in reference elements
82  * =================================================
83  *
84  * TODO we want the following (22.10.):
85  *
86  * 1D element (line segment) 2D element (triangle) 3D element (tetrahedron)
87  *
88  * z
89  * .
90  * ,/
91  * /
92  * 3
93  * y ,/|`\
94  * ^ ,/ | `\
95  * | ,/ '. `\
96  * 2 ,/ | `\
97  * |`\ ,/ | `\
98  * | `\ 0-----------'.--------1 --> x
99  * | `\ `\. | ,/
100  * | `\ `\. | ,/
101  * | `\ `\. '. ,/
102  * 0----------1 --> x 0----------1 --> x `\. |/
103  * `2
104  * `\.
105  * `y
106  *
107  * side id node ids side id node ids side id node ids normal
108  * 0 0 0 0,1 0 0,1,2 OUT
109  * 1 1 1 0,2 1 0,1,3 IN
110  * 2 1,2 2 0,2,3 OUT
111  * 3 1,2,3 IN
112  *
113  *
114  * nodes coordinates:
115  * 0 [0] 0 [0,0] 0 [0,0,0]
116  * 1 [1] 1 [1,0] 1 [1,0,0]
117  * 2 [0,1] 2 [0,1,0]
118  * 3 [0,0,1]
119  *
120  * barycentric coordinates of nodes:
121  * 0 [1,0] 0 [1,0,0] 0 [1,0,0,0]
122  * 1 [0,1] 1 [0,1,0] 1 [0,1,0,0]
123  * 2 [0,0,1] 2 [0,0,1,0]
124  * 3 [0,0,0,1]
125  */
126 
127 /** Auxilliary class representing vector of indices (unsigned int).
128  * @tparam Size is the fixed size of the vector.
129  */
130 /*
131 template<unsigned int Size>
132 class IdxVector{
133  unsigned int data_[Size]; ///< Array with indices.
134 
135  public:
136  /// Constructor taking in array of indices.
137  IdxVector(std::array<unsigned int,Size> data_in);
138  /// Constructor enabling creating object with initializer list {...}.
139  IdxVector(std::initializer_list<unsigned int> data_in);
140  /// Getter for index @p idx.
141  unsigned int operator[](unsigned int idx) const;
142 };
143 */
144 
145 template<std::size_t Size>
146 using IdxVector = std::array<unsigned int, Size>;
147 
148 
149 /** Auxilliary structure that is used to pass template arguments into interact function of RefElement:
150  * RefElement<dim>::interact( Interaction<OutDim,InDim>(i) )
151  *
152  * This enables automatic deduction of dimensional template arguments.
153  * @see @p RefElement<dim>::interact
154  */
155 template <unsigned int OutDim, unsigned int InDim>
156 struct Interaction {
157  Interaction(unsigned int i) : i_(i) {}
158  unsigned int i_;
159 };
160 
161 template<unsigned int dim>
163 {
164 public:
165  typedef arma::vec::fixed<dim> LocalPoint;
166  /**
167  * Barycentric coordinates.
168  *
169  * e.g. coordinates (a,b,c) on triangle with vertices X, Y, Z
170  * represents a point: a*X+b*Y+c*Z
171  */
172  typedef arma::vec::fixed<dim+1> BaryPoint;
173  typedef arma::vec::fixed<dim> FaceBaryPoint;
174 
175  /**
176  * Return coordinates of given node.
177  * @see the class documentation @p RefElement
178  * @param nid Node number.
179  * NOTE: Implementation is dependent on current node and side numbering.
180  */
181  static LocalPoint node_coords(unsigned int nid);
182 
183  /**
184  * Compute normal vector to a given side.
185  * @param sid Side number.
186  */
187  static LocalPoint normal_vector(unsigned int sid);
188 
189 
190  /**
191  * If the given barycentric coordinate is in the ref. element, return unchanged.
192  * If the given barycentric coordinate is out of the ref. element,
193  * project it on the surface of the ref. element.
194  */
195  static BaryPoint clip(const BaryPoint &barycentric);
196 
197  /** Returns orientation of the normal of side @p sid. 0 -> OUT, 1 -> IN.
198  * NOTE: Implementation is dependent on current node and side numbering.
199  */
200  static unsigned int normal_orientation(unsigned int sid);
201 
202  static double side_measure(unsigned int sid);
203 
204  /**
205  * Returns index of the node that is oposite to side of given index @p sid.
206  * Note: It is dependent on current node and side numbering.
207  * @param sid Side number.
208  * NOTE: Implementation is dependent on current node and side numbering.
209  */
210  static unsigned int oposite_node(unsigned int sid);
211 
212  /**
213  * Return index of 1D line, shared by two faces @p f1 and @p f2 of the reference tetrahedron.
214  * Implemented only for @p dim == 3.
215  */
216  static unsigned int line_between_faces(unsigned int f1, unsigned int f2);
217 
218 
219  static const unsigned int n_sides = dim + 1; ///< Number of sides.
220  static const unsigned int n_nodes = dim + 1; ///< Number of nodes.
221  static const unsigned int n_nodes_per_side = dim; ///< Number of nodes on one side.
222  static const unsigned int n_lines_per_node = dim; ///< Number of lines with one common node.
223  static const unsigned int n_nodes_per_line = 2; ///< Number of nodes in one line.
224  static const unsigned int n_sides_per_line = 2; ///< Number of sides with one common line. @p dim == 3.
225  static const unsigned int n_sides_per_node = dim; ///< Number of sides with one common line.
226 
227  /// Number of lines on boundary of one side.
228  static const unsigned int n_lines_per_side = (unsigned int)((dim * (dim - 1)) / 2);//( dim == 3 ? 3 : 0);// Kombinační číslo dim nad dvěma
229 
230  /// Number of lines, i.e. @p object of dimension @p dim-2 on the boundary of the reference element.
231  static const unsigned int n_lines = (unsigned int)((dim * (dim + 1)) / 2); //( dim == 3 ? 6 : dim == 2 ? 3 : dim == 1 ? 1 : 0); součet posloupnosti
232 
233 
234 // /**
235 // * Node numbers for each side.
236 // */
237 // static const unsigned int side_nodes[n_sides][n_nodes_per_side];
238 //
239 // /**
240 // * Indices of 1D lines of the 2D sides of an tetrahedron. Nonempty only for @p dim==3.
241 // */
242 // static const unsigned int side_lines[n_sides][n_lines_per_side];
243 //
244 // /**
245 // * Nodes of 1D lines of the tetrahedron.
246 // */
247 // static const unsigned int line_nodes[n_lines][2];
248 //
249 // /**
250 // * Indices of sides for each line. Nonempty only for @p dim==3 and @p dim==2.
251 // */
252 // static const unsigned int line_sides[n_lines][2];
253 
254 
256 
257  /**
258  * Number of permutations of nodes on sides.
259  * dim value
260  * -----------
261  * 1 1
262  * 2 2
263  * 3 6
264  */
265  static const unsigned int n_side_permutations = (dim+1)*(2*dim*dim-5*dim+6)/6;
266 
267  /**
268  * Permutations of nodes on sides.
269  * [n_side_permutations][n_nodes_per_side]
270  */
272 
273  /**
274  * For a given permutation @p p of nodes finds its index within @p side_permutations.
275  * @param p Permutation of nodes.
276  */
277  static unsigned int permutation_index(unsigned int p[n_nodes_per_side]);
278 
279  /** @brief Converts from local to barycentric coordinates.
280  * @param lp point in local coordinates (x,y)
281  * @return point in barycentric coordinates (1-x-y, x, y)
282  */
283  static BaryPoint local_to_bary(const LocalPoint& lp);
284 
285  /** @brief Converts from barycentric to local coordinates.
286  * @param bp point in barycentric coordinates
287  * @return point in local coordinates
288  */
289  static LocalPoint bary_to_local(const BaryPoint& bp);
290 
292 
293  /**
294  * Used in the clip method.
295  */
296  static BarycentricUnitVec make_bary_unit_vec();
297 
298  /**
299  * For given barycentric coordinates on the ref element returns barycentric coordinates
300  * on the ref. element of given face. Assumes that the input point is on the face.
301  * Barycentric order: (complanatory, local_coords )
302  */
303  static FaceBaryPoint barycentric_on_face(const BaryPoint &barycentric, unsigned int i_face);
304 
305 
307  static CentersList centers_of_subelements(unsigned int sub_dim);
308 
309  /**
310  * Return (1) number of zeros and (2) positions of zeros in barycentric coordinates.
311  * @p tolerance serves for testing zero values of @p barycentric coordinates.
312  */
313  static std::pair<unsigned int, unsigned int> zeros_positions(const BaryPoint &barycentric,
314  double tolerance = std::numeric_limits<double>::epsilon()*2);
315 
316  /**
317  * According to positions of zeros in barycentric coordinates, it gives the index of subdim-simplex
318  * in the reference element. Number of zeros must be equal to (3-subdim).
319  * e.g.:
320  * if 1 zeros, return index of side (subdim 2)
321  * if 2 zeros, return index of edge (subdim 1)
322  * if 3 zeros, return index of vertex (subdim 0)
323  */
324  template<unsigned int subdim> static unsigned int topology_idx(unsigned int zeros_positions);
325 
326  /** Function returns number of subdim-simplices inside dim-simplex.
327  * The aim is covering all the n_**** members with a single function.
328  * TODO: think of generalization for n_****_per_**** members, like function @p interact:
329  * template<unsigned int subdimA, unsigned int subdimB> static unsigned int count();
330  */
331  template<unsigned int subdim> static unsigned int count();
332 
333  /**
334  * @param sid - index of a sub-simplex in a simplex
335  * return an array of barycentric coordinates on <dim> simplex from <subdim> simplex
336  * for example: simplex<3> - ABCD and its subsubsimplex<1> AD (line index: 3)
337  * AD has barycoords for A (1,0), for D (0,1), but A in ABCD is (1,0,0,0) and D is (0,0,0,1)
338  * this method creates array ((1,0,0,0),(0,0,0,1))
339  */
340  template<unsigned int subdim> static arma::mat::fixed<dim+1,subdim+1> bary_coords(unsigned int sid);
341 
342  /** Interpolate barycentric coords to a higher dimension of a simplex.
343  * @param coord - barycentric coords of a point on a sub-simplex
344  * @param sub_simplex_idx - id of sub-simplex on a simplex
345  */
346  template<unsigned int subdim> static BaryPoint interpolate(arma::vec::fixed<subdim+1> coord, int sub_simplex_idx);
347 
348 
349  /**
350  * Basic line interpolation.
351  */
352  static BaryPoint line_barycentric_interpolation(BaryPoint first_coords,
353  BaryPoint second_coords,
354  double first_theta, double second_theta, double theta);
355 
356  /**
357  * Usage:
358  * RefElement<3>::interact(Interaction<2,0>(1))
359  * (means: In tetrahedron <3>, give indices of sides <2>, connected by node <0> with index 1)
360  * RefElement<3>::interact(Interaction<2,0>(1))[1]
361  * (as above, but give only the side with index 1)
362  *
363  * Template usage: RefElement<dim>::interact(Interaction<OutDim, InDim>(i))[j]
364  * (means: on dim-dimensional reference element, go on InDim-dimensional subelement with index i,
365  * which connects OutDim-dimnesional subelements and select the one with index j)
366  *
367  * This method serves as an interface to topology information of the reference element.
368  * It returns indices of OutDim-dimensional object
369  * of InDim-dimnesional object of given index
370  * in dim-dimnesional reference element.
371  * @tparam interaction - auxilliary object carying the index and the template arguments OutDim and InDim
372  * @tparam OutDim - output dimension (give me node-0, line-1, side-2), <= dim
373  * @tparam InDim - input dimension (for node-0, line-1, side-2), <= dim
374  * @return vector of indices of OutDim-dimensional subelements represented by @p IdxVector object.
375  *
376  * possible calls:
377  * dim OutDim InDim return
378  * 1,2,3 0 1 InDim+1 - give me indices of nodes of line of given index
379  * 3 0 2 InDim+1 - give me indices of nodes of a side (triangle) of given index
380  * 3 1 2 InDim+1 - give me indices of lines of side (triangle) of given index
381  *
382  * 1,2,3 1 0 dim-InDim - give me indices of lines with common node of given index
383  * 3 2 0 dim-InDim - give me indices of sides (triangles) with common node of given index
384  * 3 2 1 dim-InDim - give me indices of sides (triangles) with common line of given index
385  *
386  */
387  template < template <unsigned int OutDim, unsigned int InDim> class TInteraction, unsigned int OutDim, unsigned int InDim>
388  static const IdxVector< (InDim>OutDim ? InDim+1 : dim-InDim) > interact( TInteraction<OutDim,InDim> interaction );
389 
390 
391 private:
392  /// Internal part of the interact function.
393  template<unsigned int OutDim, unsigned int InDim>
394  static const IdxVector< (InDim>OutDim ? InDim+1 : dim-InDim) > interact_(unsigned int index);
395 
396  static const std::vector<IdxVector<n_nodes_per_line>> line_nodes_; ///< [n_lines] For given line, returns its nodes indices.
397  static const std::vector<IdxVector<n_lines_per_node>> node_lines_; ///< [n_nodes] For given node, returns lines indices.
398  static const std::vector<IdxVector<n_nodes_per_side>> side_nodes_; ///< [n_sides] For given side, returns nodes indices. For @p dim == 3.
399  static const std::vector<IdxVector<n_sides_per_node>> node_sides_; ///< [n_nodes] For given node, returns sides indices. For @p dim == 3.
400  static const std::vector<IdxVector<n_sides_per_line>> line_sides_; ///< [n_lines] For given line, returns sides indices. For @p dim == 3.
401  static const std::vector<IdxVector<n_lines_per_side>> side_lines_; ///< [n_sides] For given side, returns lines indices. For @p dim == 3.
402 
403  //TODO: implement for 1d and 2d
404  /**
405  * Consider an n-face (node, edge, face, bulk) with dimension `subdim` and
406  * index within subdimension `idx`. Barycentric coordinates of all points
407  * on the n-face have unique pattern of zero coordinates.
408  *
409  * topology_zeros_[subdim][idx] is a bitfield with '1' where the pattern have zeros.
410  */
411  static const IdxVector<(n_lines > n_nodes) ? n_lines : n_nodes> topology_zeros_[dim+1];
412 };
413 
414 
419 
420 
421 
422 
423 
424 
425 /************************* template implementation ****************************/
426 
427 template<unsigned int dim>
428 template<unsigned int subdim> inline
429 arma::mat::fixed<dim+1,subdim+1> RefElement<dim>::bary_coords(unsigned int sid){
430  ASSERT_LT_DBG(subdim, dim).error("Dimension mismatch!");
431  arma::mat::fixed<dim+1,subdim+1> bary_c;
432 
433  for(unsigned int i = 0; i < subdim+1; i++){
434  unsigned int nid = interact_<0,subdim>(sid)[i];
435  bary_c.col(i).zeros();
436  bary_c.col(i)(nid) = 1;
437  }
438 
439  return bary_c;
440 }
441 
442 
443 template<unsigned int dim> inline
444 arma::vec::fixed<dim> RefElement<dim>::node_coords(unsigned int nid)
445 {
446  ASSERT_LT_DBG(nid, n_nodes).error("Node number is out of range!");
447 
448  arma::vec::fixed<dim> p;
449  p.zeros();
450 
451  if (nid > 0)
452  p(nid-1) = 1;
453 
454  return p;
455 }
456 
457 
458 template<unsigned int dim>
459 template<unsigned int subdim>
460 auto RefElement<dim>::interpolate(arma::vec::fixed<subdim+1> coord, int sub_simplex_idx) -> BaryPoint
461 {
462  return RefElement<dim>::bary_coords<subdim>(sub_simplex_idx)*coord;
463 }
464 /*
465 template <unsigned int Size>
466 IdxVector<Size>::IdxVector(std::array<unsigned int,Size> data_in)
467 : data_(data_in){}
468 
469 template <unsigned int Size>
470 IdxVector<Size>::IdxVector(std::initializer_list<unsigned int> data_in)
471 {
472  ASSERT_EQ_DBG(data_in.size(), Size).error("Incorrect data size.");
473  std::copy(data_in.begin(), data_in.end(), data_);
474 }
475 
476 template <unsigned int Size>
477 inline unsigned int IdxVector<Size>::operator[](unsigned int idx) const
478 { ASSERT_LT_DBG(idx, Size).error("Index out of bounds.");
479  return data_[idx]; }
480 
481 */
482 
483 template<> template<> inline unsigned int RefElement<3>::count<0>()
484 { return n_nodes; }
485 template<> template<> inline unsigned int RefElement<3>::count<1>()
486 { return n_lines; }
487 template<> template<> inline unsigned int RefElement<3>::count<2>()
488 { return n_sides; }
489 template<> template<> inline unsigned int RefElement<3>::count<3>()
490 { return 1; }
491 template<> template<> inline unsigned int RefElement<2>::count<0>()
492 { return n_nodes; }
493 template<> template<> inline unsigned int RefElement<2>::count<1>()
494 { return n_lines; }
495 template<> template<> inline unsigned int RefElement<2>::count<2>()
496 { return 1; }
497 template<> template<> inline unsigned int RefElement<2>::count<3>()
498 { return 0; }
499 template<> template<> inline unsigned int RefElement<1>::count<0>()
500 { return n_nodes; }
501 template<> template<> inline unsigned int RefElement<1>::count<1>()
502 { return 1; }
503 template<> template<> inline unsigned int RefElement<1>::count<2>()
504 { return 0; }
505 template<> template<> inline unsigned int RefElement<1>::count<3>()
506 { return 0; }
507 template<> template<> inline unsigned int RefElement<0>::count<0>()
508 { return 1; }
509 template<> template<> inline unsigned int RefElement<0>::count<1>()
510 { return 0; }
511 template<> template<> inline unsigned int RefElement<0>::count<2>()
512 { return 0; }
513 template<> template<> inline unsigned int RefElement<0>::count<3>()
514 { return 0; }
515 
516 template<unsigned int dim>
517 template<unsigned int subdim>
518 unsigned int RefElement<dim>::topology_idx(unsigned int zeros_positions)
519 {
520  for(unsigned int i=0; i < RefElement<dim>::count<subdim>(); i++){
521  if(zeros_positions == topology_zeros_[subdim][i]) return i;
522  }
523  ASSERT(0).error("Undefined zero pattern.");
524  return -1;
525 }
526 
527 
528 /// This function is for "side_nodes" - for given side, give me nodes (0->0, 1->1).
529 template<> template<> inline const IdxVector<1> RefElement<1>::interact_<0,0>(unsigned int i)
530 { ASSERT_LT_DBG(i, RefElement<1>::n_nodes).error("Index out of bounds.");
531  return IdxVector<1>({i});}
532 
533 /// For line i {0}, give me indices of its nodes.
534 template<> template<> inline const IdxVector<2> RefElement<1>::interact_<0,1>(unsigned int i)
535 { ASSERT_LT_DBG(i, RefElement<1>::n_lines).error("Index out of bounds.");
536  return line_nodes_[i];}
537 
538 /// For line i {0,1,2}, give me indices of its nodes.
539 template<> template<> inline const IdxVector<2> RefElement<2>::interact_<0,1>(unsigned int i)
540 { ASSERT_LT_DBG(i, RefElement<2>::n_lines).error("Index out of bounds.");
541  return line_nodes_[i];}
542 
543 /// For line i {0,1,2,3,4,5}, give me indices of its nodes.
544 template<> template<> inline const IdxVector<2> RefElement<3>::interact_<0,1>(unsigned int i)
545 { ASSERT_LT_DBG(i, RefElement<3>::n_lines).error("Index out of bounds.");
546  return line_nodes_[i];}
547 
548 /// For node i {0,1}, give me indices of lines.
549 template<> template<> inline const IdxVector<1> RefElement<1>::interact_<1,0>(unsigned int i)
550 { ASSERT_LT_DBG(i, RefElement<1>::n_nodes).error("Index out of bounds.");
551  return node_lines_[i];}
552 
553 /// For node i {0,1,2}, give me indices of lines.
554 template<> template<> inline const IdxVector<2> RefElement<2>::interact_<1,0>(unsigned int i)
555 { ASSERT_LT_DBG(i, RefElement<2>::n_nodes).error("Index out of bounds.");
556  return node_lines_[i];}
557 
558 /// For node i {0,1,2,3}, give me indices of lines.
559 template<> template<> inline const IdxVector<3> RefElement<3>::interact_<1,0>(unsigned int i)
560 { ASSERT_LT_DBG(i, RefElement<3>::n_nodes).error("Index out of bounds.");
561  return node_lines_[i];}
562 
563 /// For side i {0,1,2}, give me indices of its nodes.
564 template<> template<> inline const IdxVector<3> RefElement<3>::interact_<0,2>(unsigned int i)
565 { ASSERT_LT_DBG(i, RefElement<3>::n_sides).error("Index out of bounds.");
566  return side_nodes_[i];}
567 
568 /// For node i {0,1,2,3}, give me indices of sides.
569 template<> template<> inline const IdxVector<3> RefElement<3>::interact_<2,0>(unsigned int i)
570 { ASSERT_LT_DBG(i, RefElement<3>::n_sides).error("Index out of bounds.");
571  return node_sides_[i];}
572 
573 /// For line i {0,1,2,3}, give me indices of sides.
574 template<> template<> inline const IdxVector<2> RefElement<3>::interact_<2,1>(unsigned int i)
575 { ASSERT_LT_DBG(i, RefElement<3>::n_lines).error("Index out of bounds.");
576  return line_sides_[i];}
577 
578 /// For side i {0,1,2}, give me indices of its lines.
579 template<> template<> inline const IdxVector<3> RefElement<3>::interact_<1,2>(unsigned int i)
580 { ASSERT_LT_DBG(i, RefElement<3>::n_sides).error("Index out of bounds.");
581  return side_lines_[i];}
582 
583 template<unsigned int dim> template<unsigned int OutDim, unsigned int InDim>
584 inline const IdxVector< (InDim>OutDim ? InDim+1 : dim-InDim) > RefElement<dim>::interact_(unsigned int i)
585 {
586  ASSERT(false)(dim)(OutDim)(InDim)(i).error("Not implemented.");
587  //ASSERT_LT_DBG(OutDim, dim);
588  //ASSERT_LT_DBG(InDim, dim);
589  return IdxVector<(InDim>OutDim ? InDim+1 : dim-InDim)>();
590 }
591 
592 
593 template<unsigned int dim>
594 template < template <unsigned int OutDim, unsigned int InDim> class TInteraction, unsigned int OutDim, unsigned int InDim>
595 inline const IdxVector< (InDim>OutDim ? InDim+1 : dim-InDim) > RefElement<dim>::interact( TInteraction<OutDim,InDim> interaction )
596 {
597  return interact_<OutDim,InDim>(interaction.i_);
598 }
599 
600 #endif /* REF_ELEMENT_HH_ */
static const std::vector< IdxVector< n_sides_per_line > > line_sides_
[n_lines] For given line, returns sides indices. For dim == 3.
Definition: ref_element.hh:400
static arma::mat::fixed< dim+1, subdim+1 > bary_coords(unsigned int sid)
Definition: ref_element.hh:429
static const std::vector< IdxVector< n_nodes_per_side > > side_nodes_
[n_sides] For given side, returns nodes indices. For dim == 3.
Definition: ref_element.hh:398
static const std::vector< IdxVector< n_lines_per_node > > node_lines_
[n_nodes] For given node, returns lines indices.
Definition: ref_element.hh:397
static BaryPoint interpolate(arma::vec::fixed< subdim+1 > coord, int sub_simplex_idx)
std::vector< BaryPoint > BarycentricUnitVec
Definition: ref_element.hh:291
arma::vec::fixed< dim > LocalPoint
Definition: ref_element.hh:165
Definitions of ASSERTS.
static const std::vector< IdxVector< n_nodes_per_line > > line_nodes_
[n_lines] For given line, returns its nodes indices.
Definition: ref_element.hh:396
unsigned int i_
Definition: ref_element.hh:158
static const std::vector< std::vector< std::vector< unsigned int > > > nodes_of_subelements
Definition: ref_element.hh:255
#define ASSERT(expr)
Allow use shorter versions of macro names if these names is not used with external library...
Definition: asserts.hh:347
static LocalPoint node_coords(unsigned int nid)
Definition: ref_element.hh:444
Interaction(unsigned int i)
Definition: ref_element.hh:157
const std::vector< LocalPoint > & CentersList
Definition: ref_element.hh:306
std::array< unsigned int, Size > IdxVector
Definition: ref_element.hh:146
arma::vec::fixed< dim > FaceBaryPoint
Definition: ref_element.hh:173
static const std::vector< std::vector< unsigned int > > side_permutations
Definition: ref_element.hh:271
arma::vec::fixed< dim+1 > BaryPoint
Definition: ref_element.hh:172
static unsigned int topology_idx(unsigned int zeros_positions)
Definition: ref_element.hh:518
static const std::vector< IdxVector< n_lines_per_side > > side_lines_
[n_sides] For given side, returns lines indices. For dim == 3.
Definition: ref_element.hh:401
static const std::vector< IdxVector< n_sides_per_node > > node_sides_
[n_nodes] For given node, returns sides indices. For dim == 3.
Definition: ref_element.hh:399
#define ASSERT_LT_DBG(a, b)
Definition of comparative assert macro (Less Than) only for debug mode.
Definition: asserts.hh:300