LifeV
ETCurrentFlag.hpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3 *******************************************************************************
4 
5  Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
6  Copyright (C) 2010 EPFL, Politecnico di Milano, Emory UNiversity
7 
8  This file is part of the LifeV library
9 
10  LifeV is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation; either version 3 of the License, or
13  (at your option) any later version.
14 
15  LifeV is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public
21  License along with this library; if not, see <http://www.gnu.org/licenses/>
22 
23 
24 *******************************************************************************
25 */
26 //@HEADER
27 
28 /*!
29  * @file
30  @brief This file contains the definition of the flags for the ETCurrentFE class.
31 
32  @date 06/2011
33  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
34  */
35 
36 #ifndef ETCURRENTFEFLAG_HPP
37 #define ETCURRENTFEFLAG_HPP
38 
39 #include <lifev/core/LifeV.hpp>
40 
41 namespace LifeV
42 {
43 
44 /*! \page Update_flag Flags to update the ETCurrentFE
45 
46  \section flag_goal Why do we need flags?
47 
48  Flags are needed in order to save computation. Indeed, when the LifeV::ETCurrentFE structure has
49  to be updated for a given element, it is possible that all the informations (e.g. second derivatives
50  of the basis functions) are not needed. The flag carry the information of the values to be computed
51  because they are required.
52 
53  \section flag_definition What is a flag?
54 
55  At first sight, we might think that a flag is a complicated class implemented to do exactly what we want,
56  with overloaded operators... Actually, it is much simpler: a LifeV::flag_Type is just an unsigned integer.
57 
58  \section flag_primitive How to define a flag?
59 
60  The flags use the binary representation of the integers to work. This enables a very fast definition and
61  use of the flags. To understand it, let us make a simple example. Suppose that we can update three
62  quantities A,B and C.
63 
64  The first step is to define a "primitive" flag for each of these quantities. These flags are defined as
65  powers of 2. Here, we will define
66 
67  \code
68  flag_Type UPDATE_A(1);
69  flag_Type UPDATE_B(2);
70  flag_Type UPDATE_C(4);
71  \endcode
72 
73  We need here powers of 2 because this makes the binary representation of the "primitive" flags simple:
74  UPDATE_A is 001, UPDATE_B is 010 and UPDATE_C is 100 (if the integers are coded on 3 bits, otherwise there
75  are many zeros before). The fact that we want A to be update is then represented by a 1 in the third position,
76  for B it is the second position and for C the first position.
77 
78  So now, if we want to build a flag that updates A and C, we want it to be in binary 101, that is 5. So,
79  the flag UPDATE_AC will be defined as:
80 
81  \code
82  flag_Type UPDATE_AC(5);
83  \endcode
84 
85  \section flag_combine How to combine flags?
86 
87  With the last example, one could think that is it just a matter of addition, but it is not. Suppose that we
88  want to combine the flags UPDATE_A and UPDATE_AC. If we add the corresponding values, we will get 1+5=6 that
89  is represented in binary by 110. This would mean update B and C, what is not what we want!
90 
91  To combine flags, we use the binary operator | (bitwise "OR" operation) that do exactly the job that we want: 1|5=5.
92 
93  \section flag_detect How to detect flags?
94 
95  Now that we can build every flag that we want, we want to detect quickly the different flags. This is achievied
96  by using the binary operator & (bitwise "AND" operation) and the "primitive" flags.
97 
98  Suppose that we want to know if A has to be updated. Then, we perform the operation "& UPDATE_A" on the incoming
99  flag. If the result is zero, then we do not need to update it: for example, UPDATE_B & UPDATE_A = 0 . Otherwise,
100  we have to update it: for example, UPDATE_AC & UPDATE_A = 1.
101 
102 
103  \section flag_list Possible flags
104 
105  There are several flags defined for you. Here is a list of the possible flags that are usually used:
106 
107  <table>
108  <tr>
109  <th> Flag name </th> <th> Effect </th>
110  </tr>
111  <tr>
112  <td> ET_UPDATE_QUAD_NODES </td> <td> Update everything needed to know the position of the quadrature nodes in the current cell </td>
113  </tr>
114  <tr>
115  <td> ET_UPDATE_DPHI </td> <td> Update everything needed to know the values of the derivatives of the basis functions in the quadrature nodes (in the current cell) </td>
116  </tr>
117  <tr>
118  <td> ET_UPDATE_D2PHI </td> <td> Update everything needed to know the values of the second derivatives of the basis functions in the quadrature nodes (in the current cell) </td>
119  </tr>
120  <tr>
121  <td> ET_UPDATE_WDET </td> <td> Update everything needed to know the determinant of the transformation multiplied by the weights of the quadrature. </td>
122  </tr>
123 
124  </table>
125 
126  Note: in the old versions there was also the flag UPDATE_PHI. This flag has been removed, since the values of the basis functions in the quadrature nodes are always the same, so they do not need to be updated.
127  Besides this usual flags, there are a couple of "primitive" flags, that update only a particular element in the currentFE structure. Be sure to know what you are doing before using them.
128 
129 */
130 
131 // For more informations about the flags, please visite the documentation \ref Update_flag
132 
133 /*! Typedef for the flag_Type */
134 typedef unsigned int flag_Type;
135 
136 // PRIMITIVE FLAGS
137 // The flags containing "ONLY" are not intended to be directly used.
138 // They are rather meant to be composed into other flags that take
139 // care for the completeness of the procedure.
140 
141 // Do nothing flag
142 const flag_Type ET_UPDATE_NONE (0);
143 
144 // Update cell coordinates
145 const flag_Type ET_UPDATE_ONLY_CELL_NODE (1);
146 
147 // Update quadrature points coordinate in the current element
148 const flag_Type ET_UPDATE_ONLY_QUAD_NODE (2);
149 
150 //Update the jacobian of the transformation
151 const flag_Type ET_UPDATE_ONLY_JACOBIAN (4);
152 
153 // Update the determinant of the jacobian
154 const flag_Type ET_UPDATE_ONLY_DET_JACOBIAN (8);
155 
156 // Update the inverse of the jacobian
157 const flag_Type ET_UPDATE_ONLY_T_INVERSE_JACOBIAN (16);
158 
159 // Update the weighted determinant only
160 const flag_Type ET_UPDATE_ONLY_W_DET_JACOBIAN (32);
161 
162 // Update the derivative of the basis functions
163 const flag_Type ET_UPDATE_ONLY_DPHI (64);
164 
165 // Update the second derivative of the basis functions
166 const flag_Type ET_UPDATE_ONLY_D2PHI (128);
167 
168 // Update the divergence of the basis functions
169 const flag_Type ET_UPDATE_ONLY_DIVERGENCE (256);
170 
171 // Update the laplacian of the basis functions
172 const flag_Type ET_UPDATE_ONLY_LAPLACIAN (512);
173 
174 // Update the diameter of the triangle
175 const flag_Type ET_UPDATE_ONLY_DIAMETER (1024);
176 
177 // Update the measure of the triangle
178 const flag_Type ET_UPDATE_ONLY_MEASURE (2048);
179 
180 // Update the metric tensor of the tetrahedra
181 const flag_Type ET_UPDATE_ONLY_METRIC (4096);
182 
183 // Update everything
184 const flag_Type ET_UPDATE_ALL (8192 - 1);
185 
186 
187 // COMPOSITE FLAGS
188 // These flags are composed of elementary flags. They take care
189 // that all the intermediate quantities required to compute
190 // the final (required) quantity are updated as well.
191 
192 // Flag for the quadrature nodes in the current cell
193 const flag_Type ET_UPDATE_QUAD_NODE (ET_UPDATE_ONLY_CELL_NODE
194  | ET_UPDATE_ONLY_QUAD_NODE);
195 
196 // Flag for the gradient of the basis functions
197 const flag_Type ET_UPDATE_DPHI (ET_UPDATE_ONLY_CELL_NODE
198  | ET_UPDATE_ONLY_JACOBIAN
199  | ET_UPDATE_ONLY_DET_JACOBIAN
200  | ET_UPDATE_ONLY_T_INVERSE_JACOBIAN
201  | ET_UPDATE_ONLY_DPHI);
202 
203 // Flag for the second derivate of the basis functions
204 const flag_Type ET_UPDATE_D2PHI (ET_UPDATE_ONLY_CELL_NODE
205  | ET_UPDATE_ONLY_JACOBIAN
206  | ET_UPDATE_ONLY_DET_JACOBIAN
207  | ET_UPDATE_ONLY_T_INVERSE_JACOBIAN
208  | ET_UPDATE_ONLY_D2PHI);
209 
210 // Flag for the weighted determinant
211 const flag_Type ET_UPDATE_WDET (ET_UPDATE_ONLY_CELL_NODE
212  | ET_UPDATE_ONLY_JACOBIAN
213  | ET_UPDATE_ONLY_DET_JACOBIAN
214  | ET_UPDATE_ONLY_W_DET_JACOBIAN);
215 
216 // Flag for the gradient of the basis functions
217 const flag_Type ET_UPDATE_DIVERGENCE (ET_UPDATE_ONLY_CELL_NODE
218  | ET_UPDATE_ONLY_JACOBIAN
219  | ET_UPDATE_ONLY_DET_JACOBIAN
220  | ET_UPDATE_ONLY_T_INVERSE_JACOBIAN
221  | ET_UPDATE_ONLY_DPHI
222  | ET_UPDATE_ONLY_DIVERGENCE);
223 
224 // Flag for the laplacian of the basis functions
225 const flag_Type ET_UPDATE_LAPLACIAN (ET_UPDATE_ONLY_CELL_NODE
226  | ET_UPDATE_ONLY_JACOBIAN
227  | ET_UPDATE_ONLY_DET_JACOBIAN
228  | ET_UPDATE_ONLY_T_INVERSE_JACOBIAN
229  | ET_UPDATE_ONLY_D2PHI
230  | ET_UPDATE_ONLY_LAPLACIAN);
231 
232 // Flag for the diameter of the cell
233 const flag_Type ET_UPDATE_DIAMETER (ET_UPDATE_ONLY_CELL_NODE
234  | ET_UPDATE_ONLY_DIAMETER);
235 
236 // Flag for the metric of the cell
237 const flag_Type ET_UPDATE_METRIC (ET_UPDATE_ONLY_CELL_NODE
238  | ET_UPDATE_ONLY_METRIC);
239 
240 // Flag for the diameter of the cell
241 const flag_Type ET_UPDATE_MEASURE (ET_UPDATE_WDET
242  | ET_UPDATE_ONLY_MEASURE);
243 
244 
245 
246 } // Namespace LifeV
247 
248 #endif // ETCURRENTFEFLAG_HPP
uint32_type flag_Type
bit-flag with up to 32 different flags
Definition: LifeV.hpp:197
void updateInverseJacobian(const UInt &iQuadPt)