Salome HOME
SOURCE -> PROJECT
[tools/medcoupling.git] / doc / doxygen / medcouplingexamplescpponly.dox
1 /*!
2 \page medcouplingexamplescpponly MEDCoupling C++ examples
3
4 \anchor cpp_mcfielddouble_fillFromAnalytic_c_func
5 <br><h2> Filling a field using a C function</h2>
6
7 We want to create a 3D vector field lying on a 2D mesh using a C function as a value
8 generator. For that, first, we define the function that computes 3 values basing on 2
9 coordinates of a 2D point.
10 \snippet MEDCouplingExamplesTest.cxx Snippet_MEDCouplingFieldDouble_fillFromAnalytic_c_func_0
11 Then we create the 2D mesh and the field on it, and finally we use
12 \ref ParaMEDMEM::MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, FunctionToEvaluate func) "fillFromAnalytic()"
13 to fill the field with values each composed of 3 components.
14 \snippet MEDCouplingExamplesTest.cxx Snippet_MEDCouplingFieldDouble_fillFromAnalytic_c_func_1
15 As a result, number of tuples in the field equals to the number of cells in the mesh,
16 and number of components equals to 3 as required.
17
18
19 \anchor cpp_mcfielddouble_applyFunc_c_func
20 <br><h2> Changing a field by applying a C function</h2>
21
22 We want to transform a 2D vector field to a 3D vector field by
23 applying a C function to each vector value. For that, first, we define the function
24 that computes 3 values basing on 2 components of a 2D vector.
25 \snippet MEDCouplingExamplesTest.cxx Snippet_MEDCouplingFieldDouble_fillFromAnalytic_c_func_0
26 Then we create the 2D mesh and the vector field on it.
27 \snippet MEDCouplingExamplesTest.cxx Snippet_MEDCouplingFieldDouble_applyFunc_c_func_1
28 Finally we use
29 \ref ParaMEDMEM::MEDCouplingFieldDouble::applyFunc(int nbOfComp, FunctionToEvaluate func) "applyFunc()"
30 to change the field values.
31 \snippet MEDCouplingExamplesTest.cxx Snippet_MEDCouplingFieldDouble_applyFunc_c_func_2
32 As a result, number of tuples in the field equals to the number of cells in the mesh,
33 and number of components becomes equal to 3 as required.
34
35
36 */