LifeV
Update of the current finite element

General issues

When the update method of the LifeV::CurrentFE class is called, several arrays of values are updated with respect to the current cell (and the current quadrature). However, in order to avoid redundant computations, intermediate values are also computed. The next figure shows all the possible values that can be updated.

update_complete_scheme.png
Complete tree of the values. The arrow between two values means that the first value require the second value to be already computed.

However, one could want only a part of the values to be updated (we maybe do not want the second derivative for a simple elliptic problem). This is why a set of flag has been set up. With this flags, one selects the values that he needs (represented on the top of the last figure) and all the needed values are updated, without redundancy. For example, if one calles the update method with the flag UPDATE_DPHI, only the values visible on the next figure will be updated.

update_dphi_scheme.png
Values updated when only the derivatives of the basis functions are required.

Of course, it is possible to combine the different flags to update several values in the same time.

Flags explaination

In this section, we explain how flags work. This can be of interest if one wants to add a new flag.

What is a flag?

At first sight, we might think that a flag is a complicated class implemented to do exaclty what we want, with overloaded operators... Actually, it is much simpler: a LifeV::flag_Type is just an unsigned integer.

to define a flag?

The flags use the binary representation of the integers to work. This enables a very fast definition and use of the flags. To understand it, let us make a simple example. Suppose that we can update three quantities A,B and C.

The first step is to define a "primitive" flag for each of these quantities. These flags are defined as powers of 2. Here, we will define

flag_Type UPDATE_A(1);
flag_Type UPDATE_B(2);
flag_Type UPDATE_C(4);

We need here powers of 2 because this makes the binary representation of the "primitive" flags simple: UPDATE_A is 001, UPDATE_B is 010 and UPDATE_C is 100 (if the integers are coded on 3 bits, otherwise there are many zeros before). The fact that we want A to be update is then represented by a 1 in the third position, for B it is the second position and for C the first position.

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, the flag UPDATE_AC will be defined as:

flag_Type UPDATE_AC(5);

How to combine flags?

With the last example, one could think that is it just a matter of addition, but it is not. Suppose that we want to combine the flags UPDATE_A and UPDATE_AC. If we add the corresponding values, we will get 1+5=6 that is represented in binary by 110. This would mean update B and C, what is not what we want!

To combine flags, we use the binary operator | that do exactly the job that we want: 1|5=5.

How to detect flags?

Now that we can build every flag that we want, we want to detect quickly the different flags. This is achievied by using the binary operator & and the "primitive" flags.

Suppose that we want to know if A has to be updated. Then, we perform that operation "& UPDATE_A" on the incoming flag. If the result is zero, then we do not need to update it: for example, UPDATE_B & UPDATE_A = 0 . Otherwise, we have to update it: for example, UPDATE_AC & UPDATE_A = 1.

Possible flags

There are several flags defined for you. Here is a list of the possible flags that are usually used:

Flag name Effect
UPDATE_QUAD_NODES Update everything needed to know the position of the quadrature nodes in the current cell
UPDATE_DPHI Update everything needed to know the values of the derivatives of the basis functions in the quadrature nodes (in the current cell)
UPDATE_D2PHI Update everything needed to know the values of the second derivatives of the basis functions in the quadrature nodes (in the current cell)
UPDATE_WDET

Update everything needed to know the determinant of the transformation multiplied by the weights of the quadrature.

Note: in the old versions there was also the flag UPDATE_PHI. This flag (together with UPDATE_ONLY_PHI) 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. 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.