Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/med.git] / doc / doxygen / medcouplingexamples.doxy
1 /*!
2 \page medcouplingcppexamples <br><h1> MEDCoupling C++ examples </h1>
3
4 \anchor cpp_mcfielddouble_subpart1
5 <br><h2>Creation of a sub part of a field</h2>
6 <br><h3>Creation of a sub part of a field on cells</h3>
7 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuildSubPart1_1
8 The field on cells \b f1 lies on a mesh containg 5 cells and 9 nodes.           
9 So this field \b f1 contains 5 tuples of 2 components each (10 values).
10 Now let's create a subfield on cells \b f2 from \b f1.
11 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuildSubPart1_2
12
13 \b f1 is a field on cells, \ref ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart "buildSubPart" method performs an extraction on cells too.
14
15 So the array \b part1 lists ids on cells.
16
17 - cell #0 of \b f2 is the same cell of cell #2 of \b f1
18 - cell #1 of \b f2 is the same cell of cell #1 of \b f1
19 - cell #2 of \b f2 is the same cell of cell #4 of \b f1
20
21 So \b f2 contains 3 tuples with 2 components.
22
23 The underlying mesh of \b f2 contains a newly created mesh with 3 cells (not as \b mesh1 in \b f1) and 9 nodes (as \b mesh1 in \b f1).
24 \n For fields on cells the number of tuples of the returned field is always equal to the number of ids given in input (here \b part1).
25 \nOnly fields on cells have this particular behaviour.
26
27 <br><h3>Creation of a sub part of a field on nodes</h3>
28 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuildSubPart1_3
29 The field on nodes \b f1 lies on a mesh containg 5 cells and 9 nodes.
30 So this field \b f1 contains 9 tuples of 2 components each (18 values).
31 Now let's create a subfield on nodes \b f2 from \b f1.
32 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuildSubPart1_4
33
34 \b f1 is a field on nodes, but \ref ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart "buildSubPart" method performs an extraction on \b cells.
35
36 After the call of \ref ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart "buildSubPart" on node field \b f1, \b f1 will be reduced on a
37 submesh of \b mesh1 containing cells whoses ids are in \b part2. So here the number of cells of \b f2 is 2 and the number of nodes is 4.
38 \nSo contrary to fields on cells, it is normal for fields on nodes that number of tuples of the returned field of \ref ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart "buildSubPart" 
39 method does not match the size of the input array (here \b part2).
40
41 */
42
43 /*!
44 \page medcouplingcppexamplesUmeshStdBuild1 <br><h1> Example of standard build of an unstructured mesh from scratch in C++ </h1>
45
46 Firstly retrieve basic data in full interlace mode for coordinates, and nodal connectivity cell per cell.
47 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_1
48
49 Then create ParaMEDMEM::MEDCouplingUMesh instance giving its meshdimension (2 here) and a name.
50
51 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_2
52
53 Gives an upper bound of the number of cells to be inserted into the unstructured mesh.
54 \n Then enter nodal connectivity of all cells, cell per cell using ParaMEDMEM::MEDCouplingUMesh::insertNextCell method.
55 \n When the nodal connectivity cell per cell has been finished, call ParaMEDMEM::MEDCouplingUMesh::finishInsertingCells method in order to restore \b mesh instance.
56
57 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_3
58
59 At this level the connectivity part of the mesh \b mesh as been defined. Now let's set the coordinates using array \b coords defined above.
60
61 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_4
62
63 At this level mesh is usable. When this mesh is no more needed simply call decrRef to decrement its reference counter.
64
65 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_5
66
67 */
68
69 /*!
70 \page medcouplingcppexamplesUmeshAdvBuild1 <br><h1> Example of advanced build of an unstructured mesh from scratch in C++ </h1>
71
72 Firstly retrieve basic data in full interlace mode for coordinates, and nodal connectivity cell per cell, cell type \b included (3 for INTERP_KERNEL::NORM_TRI3 and 4 for INTERP_KERNEL::QUAD4).
73 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_1
74
75 Then create ParaMEDMEM::MEDCouplingUMesh instance giving its meshdimension (2 here) and a name.
76
77 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_2
78
79 Then enter nodal connectivity at once.
80
81 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_3
82
83 At this level the connectivity part of the mesh \b mesh as been defined. Now let's set the coordinates using array \b coords defined above.
84
85 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_4
86
87 At this level mesh is usable. When this mesh is no more needed simply call decrRef to decrement its reference counter.
88
89 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_5
90
91 */
92
93 /*!
94 \page medcouplingcppexamplesCmeshStdBuild1 <br><h1> Example of standard build of an cartesian mesh from scratch in C++ </h1>
95
96 We are going to build a 2D cartesian mesh, constituted from 9 nodes along X axis, and 7 nodes along Y axis.
97
98 Firstly retrieve for each direction the discretization and build a \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble instance" on the corresponding direction.
99
100 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_1
101
102 Then create ParaMEDMEM::MEDCouplingCMesh instance giving the 2 instances of \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble" obtained above.
103
104 There are 2 technics to get it.
105
106 Either :
107
108 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_2
109
110 Or :
111
112 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_2bis
113
114 \c mesh is now available for use :
115
116 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_3
117
118 When this mesh is no more needed simply call decrRef to decrement its reference counter.
119
120 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_4
121
122 */
123
124 /*!
125 \page medcouplingcppexamplesFieldDoubleBuild1 <br><h1> Examples in C++ of standard build of a tensor field on cells with no time attached  </h1>
126
127 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild1_1
128
129 */
130
131 /*!
132 \page medcouplingcppexamplesFieldDoubleBuild2 <br><h1> Examples in C++ of standard build of a scalar field on nodes with no time attached </h1>
133
134 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild2_1
135
136 */
137
138 /*!
139 \page medcouplingcppexamplesFieldDoubleBuild3 <br><h1> Examples in C++ of standard build of a vector field on cells with with one time attached and no time interval </h1>
140
141 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild3_1
142
143 */
144
145 /*!
146 \page medcouplingcppexamplesFieldDoubleBuild4 <br><h1> Examples in C++ of standard build of a vector field on nodes defined on a time interval with a constant value during this interval </h1>
147
148 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild4_1
149
150 */
151
152 /*!
153 \page medcouplingcppexamplesFieldDoubleBuild5 <br><h1> Examples in C++ of operation that can be carried out on fields on cells </h1>
154
155 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild1_2
156
157 The decrementation of ref counter should be carried out in CPlusPlus only ...
158
159 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild1_3
160
161 */