Flow123d  jenkins-Flow123d-linux-release-multijob-282
ref_element.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2007 Technical University of Liberec. All rights reserved.
4  *
5  * Please make a following refer to Flow123d on your project site if you use the program for any purpose,
6  * especially for academic research:
7  * Flow123d, Research Centre: Advanced Remedial Technologies, Technical University of Liberec, Czech Republic
8  *
9  * This program is free software; you can redistribute it and/or modify it under the terms
10  * of the GNU General Public License version 3 as published by the Free Software Foundation.
11  *
12  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along with this program; if not,
17  * write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 021110-1307, USA.
18  *
19  *
20  * $Id$
21  * $Revision$
22  * $LastChangedBy$
23  * $LastChangedDate$
24  *
25  * @file
26  * @brief Class RefElement defines numbering of vertices, sides, calculation of normal vectors etc.
27  * @author Jan Stebel
28  *
29  *
30  * TODO:
31  *
32  * - design interface in such a way, that we can change numbering
33  * - design numbering and orientations on ref element that is consistent (orientation and numbering od 2d el. match sides of 3d),
34  * and possibly allows permute vertices of elements so that sides sharing an edge match numbering and orientation (we dos'nt need permute faces)
35  *
36  * Proposal(prefers combinatoric order) :
37  * 1D - orientation V0 -> V1
38  *
39  * 2D - edges: E0: V0 -> V1,
40  * E1: V0 -> V2
41  * E2: V1 -> V2
42  * This maximize number of edge orientations achievable by edge permutations
43  * edge numbering edge orientation( in original numbering)
44  * 0 1 2 + + +
45  * 0 2 1 - + +
46  * 1 0 2 + + -
47  * 1 2 0 - - +
48  * 2 0 1 + - -
49  * 2 1 0 - - -
50  *
51  * vertices edges normal (out = +)
52  * 3D - sides: S0: 0 1 2 E0 E1 E3 -
53  * S1: 0 1 3 E0 E2 E4 +
54  * S2: 0 2 3 E1 E2 E5 -
55  * S3: 1 2 3 E3 E4 E5 -
56  *
57  * edges: E0: V0 -> V1 x direction
58  * E1: V0 -> V2 y direction
59  * E2: V0 -> V3 z direction
60  * E3: V1 -> V2
61  * E4: V1 -> V3
62  * E5: V2 -> V3
63  *
64  * - functions from DEAL.ii:
65  * bool is_inside_unit_cell( point )
66  * line_to_cell_vertices(line, vertex) vertex index on line to index on whole element
67  * face_to_cell_vertices(face, vertex, Orientation), Orientation should be some class describing permutation of shared face to element's face/side
68  * face_to_cel_lines
69  * standard_to_real_face_vertex(vertex, Orientation), maps vertex to permuted face
70  * real_to_standard_face_vertex - inverse
71  * ... same for line; we should need also something like standard_to_real_line_vertex; Deal dosn;t support Orientation changes for 2D element faces
72  * Point unit_cell_vertex(vertex) - coordinates
73  * project_to_unit_cell
74  * distance_to_unit_cell
75  * d_linear_shape_function
76  *
77  * - can not change numbering of element sides due to DarcyFlow, which use hardwired side numbering in construction of basis functions
78  * - any change of side numbering requires also change in flow/old_bcd.cc
79  *
80  *
81  */
82 
83 #ifndef REF_ELEMENT_HH_
84 #define REF_ELEMENT_HH_
85 
86 #include <armadillo>
87 
88 /*
89  * Ordering of nodes and sides in reference elements
90  * =================================================
91  *
92  * 1D element (line segment) 2D element (triangle) 3D element (tetrahedron)
93  *
94  * y
95  * .
96  * ,/
97  * /
98  * 2
99  * y ,/|`\
100  * ^ ,/ | `\
101  * | ,/ '. `\
102  * 2 ,/ | `\
103  * |`\ ,/ | `\
104  * | `\ 0-----------'.--------1 --> x
105  * | `\ `\. | ,/
106  * | `\ `\. | ,/
107  * | `\ `\. '. ,/
108  * 0----------1 --> x 0----------1 --> x `\. |/
109  * `3
110  * `\.
111  * ` z
112  *
113  * side id node ids side id node ids side id node ids normal
114  * 0 1 0 1,2 0 1,2,3 OUT
115  * 1 0 1 0,2 1 0,2,3 IN
116  * 2 0,1 2 0,1,3 OUT
117  * 3 0,1,2 IN
118  *
119  *
120  *
121  *
122  *
123  *
124  */
125 template<unsigned int dim>
127 {
128 public:
129 
130  /**
131  * Return barycentric coordinates of given node.
132  * @param nid Node number.
133  */
134  static arma::vec::fixed<dim+1> node_coords(unsigned int nid);
135 
136  /**
137  * Compute normal vector to a given side.
138  * @param sid Side number.
139  */
140  static arma::vec::fixed<dim> normal_vector(unsigned int sid);
141 
142  /**
143  * Return index of 1D line, shared by two faces @p f1 and @p f2 of the reference tetrahedron.
144  * Implemented only for @p dim == 3.
145  */
146  static unsigned int line_between_faces(unsigned int f1, unsigned int f2);
147 
148 
149  /**
150  * Number of sides.
151  */
152  static const unsigned int n_sides = dim + 1;
153 
154  /**
155  * Number of vertices.
156  */
157  static const unsigned int n_nodes = dim + 1;
158 
159  /**
160  * Number of nodes on one side.
161  */
162  static const unsigned int n_nodes_per_side = dim;
163 
164  /// Number of lines on boundary of one side.
165  static const unsigned int n_lines_per_side = ( dim == 3 ? 3 : 0);
166 
167  /// Number of lines, i.e. @p object of dimension @p dim-2 on the boundary of the reference element.
168  static const unsigned int n_lines = ( dim == 3 ? 6 : 0);
169 
170  /**
171  * Node numbers for each side.
172  */
173  static const unsigned int side_nodes[n_sides][n_nodes_per_side];
174 
175  /**
176  * Indices of 1D lines of the 2D sides of an tetrahedron. Nonempty only for @p dim==3.
177  */
178  static const unsigned int side_lines[n_sides][n_lines_per_side];
179 
180  /**
181  * Nodes of 1D lines of the tetrahedron.
182  */
183  static const unsigned int line_nodes[n_lines][2];
184 
185  /**
186  * Number of permutations of nodes on sides.
187  * dim value
188  * -----------
189  * 1 1
190  * 2 2
191  * 3 6
192  */
193  static const unsigned int n_side_permutations = (dim+1)*(2*dim*dim-5*dim+6)/6;
194 
195  /**
196  * Permutations of nodes on sides.
197  */
199 
200  /**
201  * For a given permutation @p p of nodes finds its index within @p side_permutations.
202  * @param p Permutation of nodes.
203  */
204  static unsigned int permutation_index(unsigned int p[n_nodes_per_side]);
205 
206 };
207 
208 
209 
210 
211 
212 
213 
214 #endif /* REF_ELEMENT_HH_ */
static arma::vec::fixed< dim+1 > node_coords(unsigned int nid)
Definition: ref_element.cc:92
const unsigned int line_nodes[][2]
Definition: ref_element.cc:80
static unsigned int permutation_index(unsigned int p[n_nodes_per_side])
Definition: ref_element.cc:146
static unsigned int line_between_faces(unsigned int f1, unsigned int f2)
static const unsigned int n_side_permutations
Definition: ref_element.hh:193
const unsigned int side_lines[][3]
Definition: ref_element.cc:71
const unsigned int side_nodes[][1]
Definition: ref_element.cc:51
static const unsigned int n_lines_per_side
Number of lines on boundary of one side.
Definition: ref_element.hh:165
static const unsigned int n_lines
Number of lines, i.e. object of dimension dim-2 on the boundary of the reference element.
Definition: ref_element.hh:168
const unsigned int side_permutations[][n_nodes_per_side]
Definition: ref_element.cc:37
static const unsigned int n_sides
Definition: ref_element.hh:152
static const unsigned int n_nodes
Definition: ref_element.hh:157
static const unsigned int n_nodes_per_side
Definition: ref_element.hh:162
static arma::vec::fixed< dim > normal_vector(unsigned int sid)
Definition: ref_element.cc:109