Skip to content

Latest commit

 

History

History
101 lines (68 loc) · 2.19 KB

05-EvaluatingFunctions.adoc

File metadata and controls

101 lines (68 loc) · 2.19 KB

Evaluating function

Once you have created an element, you may want to give it a value, that can depends on a lot of parameters ( mainly spaces, but others may apply ).

To do so, Feel++ relies on expressions. We may use various kind of expressions :

Built-in

Let’s begin with the evaluation of the expression \$sin(\pi x)\$ on a unit circle.

First at all, we define the unit circle and its function space :

link:{examplesdir}/05-myexporter.cpp[role=include]

Then the expression we would like to evaluate :

link:{examplesdir}/05-myexporter.cpp[role=include]

Px() refers to the variable x of our space.

With this,we can project it on our function space :

link:{examplesdir}/05-myexporter.cpp[role=include]

The expression will be evaluated on each point of our mesh.

In order to visualize the result, we create an exporter, named exhi, and add to it the projection.

link:{examplesdir}/05-myexporter.cpp[role=include]

Code

link:{examplesdir}/05-myexporter.cpp[role=include]

The list of the Feel++ Keyword is here.

Hard Coded

In this second method, we will use Functor :

link:{examplesdir}/myfunctor.cpp[role=include]

We create a unit square meshed by triangles and we define the associated function space :

link:{examplesdir}/myfunctor.cpp[role=include]

From this space, we can define two elements, here one equals to the variable \$x\$ and the other to the variable \$y\$, obtain from Functor class.

link:{examplesdir}/myfunctor.cpp[role=include]

The data exportation is the final step to visualize our expression \$x\$ and \$y\$ on the defined mesh.

link:{examplesdir}/myfunctor.cpp[role=include]

Code

The complete code reads as follows

link:{examplesdir}/myfunctor.cpp[role=include]

Consult the list of {feelpp} Mathematics keywords for more details.