Salome HOME
Compilation SALOME on Windows
[modules/med.git] / doc / doxygen / medcouplingexamples.doxy
1 /*!
2 \page medcouplingcppexamples MEDCoupling C++ examples
3
4
5 \anchor cpp_mcfielddouble_WriteVTK
6 <br><h2> Writting fields in a VTK file </h2>
7
8 In this example we 
9 - create an 2D mesh and 3 fields on it,
10 - use 
11 \ref ParaMEDMEM::MEDCouplingFieldDouble::WriteVTK "WriteVTK()"
12 to write all the fields and the mesh to a VTK file.
13
14 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_WriteVTK_1
15
16
17
18 \anchor cpp_mcfielddouble_MaxFields
19 <br><h2> Getting maximal and minimal fields </h2>
20
21 In this example we 
22 - create two fields with two tuples per two components,
23 - use 
24 \ref ParaMEDMEM::MEDCouplingFieldDouble::MaxFields "MaxFields()"
25 to get a field holding maximal values of the two fields.
26 - use 
27 \ref ParaMEDMEM::MEDCouplingFieldDouble::MinFields "MinFields()"
28 to get a field holding minimal values of the two fields.
29
30 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_MaxFields_1
31
32
33 \anchor cpp_mcfielddouble_MergeFields
34 <br><h2> Concatenating fields</h2>
35
36 In this example we 
37 - create an 1D mesh and a field on it,
38 - make a deep copy of the mesh and the field,
39 - translate the mesh and the field,
40 - use two variants of
41 \ref ParaMEDMEM::MEDCouplingFieldDouble::MergeFields "MergeFields()"
42 to create one field from the two by concatenating them and their meshes.
43
44 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_MergeFields_1
45 The result field is twice "longer" than \b field1.
46
47
48
49 \anchor cpp_mcfielddouble_substractInPlaceDM
50 <br><h2> Subtracting field on different meshs </h2>
51
52 We make two meshes in 1D space with no cells and 4 nodes. Nodes #0 and #2 are swapped
53 in the two meshes.<br>
54 And we make two fields on these meshes, so that fields values to equal to node
55 coordinates of the underlying meshes.
56 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_substractInPlaceDM_1
57 We are going to subtract \b field2 from \b field1, though they are on
58 different meshes.
59 \ref ParaMEDMEM::MEDCouplingFieldDouble::substractInPlaceDM "substractInPlaceDM()"
60 allows us doing this. We use a mesh comparison level \b levOfCheck = 10 that allows
61 subtracting fields on meshes with different node arrays.<br>
62 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_substractInPlaceDM_2
63 After applying 
64 \ref ParaMEDMEM::MEDCouplingFieldDouble::substractInPlaceDM "substractInPlaceDM()"
65 the both fields lie on \b mesh2. As
66 \ref ParaMEDMEM::MEDCouplingFieldDouble::substractInPlaceDM "substractInPlaceDM()"
67 permutes values of \b field1 before value subtraction, and thus \b field1 becomes
68 equal to \b feild2, hence their subtraction results in a zero field.
69 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_substractInPlaceDM_3
70
71
72
73 \anchor cpp_mcfielddouble_changeUnderlyingMesh
74 <br><h2> Changing the underlying mesh </h2>
75
76 We make two meshes in 1D space with no cells and 4 nodes. Nodes #0 and #2 are swapped
77 in the two meshes.
78 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_changeUnderlyingMesh_1
79 We are going to use
80 \ref ParaMEDMEM::MEDCouplingFieldDouble::changeUnderlyingMesh "changeUnderlyingMesh()"
81 to set \b mesh2 instead of \b mesh1 as a support of a field. <br>
82 We use
83 \ref ParaMEDMEM::MEDCouplingMesh::fillFromAnalytic "fillFromAnalytic()"
84 to make a field on nodes of \b mesh1, so that its values to equal to node coordinates.
85 Then we use 
86 \ref ParaMEDMEM::MEDCouplingFieldDouble::changeUnderlyingMesh "changeUnderlyingMesh()"
87 to change the underlying mesh of the \b field.
88 (We use a mesh comparison level \b levOfCheck = 10 that allows substituting meshes with
89 different node arrays.) As a result, we expect that values of the \b field are also
90 permuted same as nodes of the two meshes, and thus its values become equal to the
91 array \b coords2.
92 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_changeUnderlyingMesh_2
93
94
95 \anchor cpp_mcfielddouble_applyFunc_same_nb_comp
96 <br><h2> Changing a field using a formular </h2>
97
98 We create a 2D vector field with 2 tuples and we want to transform this
99 field using a formular using 
100 \ref ParaMEDMEM::MEDCouplingFieldDouble::applyFunc(const char *func) "applyFunc()".
101 The formular \b func is applied each atomic value of the \b field. We want to change
102 the \b field as follows. (In \b func, we use the variable "v" to refer to an atomic field value). 
103 - Component #0 = component #0 (remains the same); hence "IVec * v" in \b func.
104 - Component #1 = component #1 ^ 2; hence "JVec * v*v".
105
106 In addition we want to add 10.0 to each component computed as described above, hence
107 "10" in \b func.
108 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_applyFunc_same_nb_comp_1
109 Now we ascertain that the result field is as we expect.
110 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_applyFunc_same_nb_comp_2
111
112
113
114 \anchor cpp_mcfielddouble_applyFunc3
115 <br><h2> Changing a field using a formular </h2>
116
117 We create a 2D vector field with 2 values (vectors) and then we transform this
118 field into a 3D vector field by applying a formular to values of the 2D field
119 using 
120 \ref ParaMEDMEM::MEDCouplingFieldDouble::applyFunc3() "applyFunc3()".
121 The formular \b func is applied to components of each vector of the \b field. We want
122 the \b field to have 3 components computed as follows. (In \b func, we refer to the
123 first component of a field value using the variable "a", and to the second component, using
124 the variable "b", as we define it by \b varNamesVec). 
125 - Component #0 = the second vector component; hence "IVec * b" in \b func.
126 - Component #1 = the first vector component; hence "JVec * a".
127 - Component #2 = a vector magnitude; hence "KVec * sqrt( a*a + b*b )".
128
129 In addition we want to add 10.0 to each component computed as described above, hence
130 "10" in \b func.
131 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_applyFunc3_1
132 Now we ascertain that the result field is as we expect. We check the second vector of
133 the \b field.
134 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_applyFunc3_2
135
136
137
138 \anchor cpp_mcfielddouble_applyFunc2
139 <br><h2> Changing a field using a formular </h2>
140
141 We create a 2D vector field with 2 values (vectors) and then we transform this
142 field into a 3D vector field by applying a formular to values of the 2D field
143 using 
144 \ref ParaMEDMEM::MEDCouplingFieldDouble::applyFunc2(int nbOfComp, const char *func) "applyFunc2()".
145 Note that we set component info the \b array ("a" and "b" ) which will be used to refer to
146 corresponding components within a function.
147 The formular \b func is applied to components of each vector of the \b field. We want
148 the \b field to have 3 components computed as follows. (In \b func, we refer to the
149 first component of a field value using the variable "a", and to the second component, using
150 the variable "b"). 
151 - Component #0 = the second vector component; hence "IVec * b" in \b func.
152 - Component #1 = the first vector component; hence "JVec * a".
153 - Component #2 = a vector magnitude; hence "KVec * sqrt( a*a + b*b )".
154
155 In addition we want to add 10.0 to each component computed as described above, hence
156 "10" in \b func.
157 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_applyFunc2_1
158 Now we ascertain that the result field is as we expect. We check the second vector of
159 the \b field.
160 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_applyFunc2_2
161
162
163
164 \anchor cpp_mcfielddouble_applyFunc
165 <br><h2> Changing a field using a formular </h2>
166
167 We create a 2D vector field with 2 values (vectors) and then we transform this
168 field into a 3D vector field by applying a formular to values of the 2D field
169 using 
170 \ref ParaMEDMEM::MEDCouplingFieldDouble::applyFunc(int nbOfComp, const char *func) "applyFunc()".
171 The formular \b func is applied to components of each vector of the \b field. We want
172 the \b field to have 3 components computed as follows. (In \b func, we refer to the
173 first component of a field value using the variable "a", and to the second component, using
174 the variable "b"). 
175 - Component #0 = the second vector component; hence "IVec * b" in \b func.
176 - Component #1 = the first vector component; hence "JVec * a".
177 - Component #2 = a vector magnitude; hence "KVec * sqrt( a*a + b*b )".
178
179 In addition we want to add 10.0 to each component computed as described above, hence
180 "10" in \b func.
181 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_applyFunc_1
182 Now we ascertain that the result field is as we expect. We check the second vector of
183 the \b field.
184 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_applyFunc_2
185
186
187
188 \anchor cpp_mcfielddouble_applyFunc_val
189 <br><h2> Filling a field with a value</h2>
190
191 We want to transform a 2D vector field to a 3D vector field so that all values to be
192 equal to a certain value. First, we create the 2D mesh and the vector field on it.
193 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_applyFunc_val_1
194 Finally we use
195 \ref ParaMEDMEM::MEDCouplingFieldDouble::applyFunc(int nbOfComp, double val) "applyFunc()"
196 to change the number of components and all field values.
197 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_applyFunc_val_2
198 As a result, number of tuples in the field equals to the number of cells in the mesh,
199 and number of components becomes equal to 3 as required.
200
201
202 \anchor cpp_mcfielddouble_fillFromAnalytic3
203 <br><h2> Filling a field using a formular </h2>
204
205 First, we create a 2D Cartesian mesh constituted by 2 cells.
206 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_fillFromAnalytic3_1
207 Now we create a field on cells and use
208 \ref ParaMEDMEM::MEDCouplingFieldDouble::fillFromAnalytic2 "fillFromAnalytic2()"
209 to fill it
210 with values computed using a formular \b func. This formular is applied to coordinates of
211 each point (barycenter) for which the field value is computed. We want the \b field
212 to have 3 components computed as follows. (In \b func, we refer to the
213 first component of a point using the variable "a", and to the second component, using
214 the variable "b").
215 - Component #0 = the second coordinate of the point; hence "IVec * b" in \b func.
216 - Component #1 = the first coordinate of the point; hence "JVec * a".
217 - Component #2 = distance between the point and SC origin (0.,0.); hence 
218 "KVec * sqrt( a*a + b*b )".
219
220 In addition we want to add 10.0 to each component computed as described above, hence
221 "10" in \b func.
222 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_fillFromAnalytic3_2
223 Now we ascertain that the result field is as we expect. We check the second tuple of
224 the \b field. We get barycenter of the cell #1 and checks that values of the second
225 tuple are computed as we want.
226 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_fillFromAnalytic3_3
227
228
229
230 \anchor cpp_mcfielddouble_fillFromAnalytic2
231 <br><h2> Filling a field using a formular </h2>
232
233 First, we create a 2D Cartesian mesh constituted by 2 cells.
234 Note that we set names to coordinates arrays ("a" and "b" ) which will be used to refer to
235 corresponding coordinates within a function.
236 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_fillFromAnalytic2_1
237 Now we create a field on cells and use
238 \ref ParaMEDMEM::MEDCouplingFieldDouble::fillFromAnalytic2 "fillFromAnalytic2()"
239 to fill it
240 with values computed using a formular \b func. This formular is applied to coordinates of
241 each point (barycenter) for which the field value is computed. We want the \b field
242 to have 3 components computed as follows. (In \b func, we refer to the
243 first component of a point using the variable "a", and to the second component, using
244 the variable "b").
245 - Component #0 = the second coordinate of the point; hence "IVec * b" in \b func.
246 - Component #1 = the first coordinate of the point; hence "JVec * a".
247 - Component #2 = distance between the point and SC origin (0.,0.); hence 
248 "KVec * sqrt( a*a + b*b )".
249
250 In addition we want to add 10.0 to each component computed as described above, hence
251 "10" in \b func.
252 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_fillFromAnalytic2_2
253 Now we ascertain that the result field is as we expect. We check the second tuple of
254 the \b field. We get barycenter of the cell #1 and checks that values of the second
255 tuple are computed as we want.
256 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_fillFromAnalytic2_3
257
258
259 \anchor cpp_mcfielddouble_fillFromAnalytic
260 <br><h2> Filling a field using a formular </h2>
261
262 First, we create a 2D Cartesian mesh constituted by 2 cells.
263 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_fillFromAnalytic_1
264 Now we create a field on cells and use
265 \ref ParaMEDMEM::MEDCouplingFieldDouble::fillFromAnalytic(int nbOfComp, const char *func) "fillFromAnalytic()"
266 to fill it
267 with values computed using a formular \b func. This formular is applied to coordinates of
268 each point (barycenter) for which the field value is computed. We want the \b field to have
269  3 components computed as follows. (In \b func, we refer to the
270 first component of a point using the variable "a", and to the second component, using
271 the variable "b").
272 - Component #0 = the second coordinate of the point; hence "IVec * b" in \b func.
273 - Component #1 = the first coordinate of the point; hence "JVec * a".
274 - Component #2 = distance between the point and SC origin (0.,0.); hence 
275 "KVec * sqrt( a*a + b*b )".
276
277 In addition we want to add 10.0 to each component computed as described above, hence
278 "10" in \b func.
279 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_fillFromAnalytic_2
280 Now we ascertain that the result field is as we expect. We check the second tuple of
281 the \b field. We get barycenter of the cell #1 to check that values of the second
282 tuple (#1) are computed as we want.
283 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_fillFromAnalytic_3
284
285
286 \anchor cpp_mcfielddouble_getValueOn_time
287 <br><h2> Getting a field value at some point at certain time</h2>
288
289 First, we create a supporting structured mesh. We create a 2x2 Cartesian mesh
290 constituted by 4 cells. 
291 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_getValueOn_time_1
292 Then we create a scalar field on cells, whose values vary linearly in time.
293 We set all field values at a start time to be equal 10.0 using
294 \ref ParaMEDMEM::MEDCouplingFieldDouble::fillFromAnalytic "fillFromAnalytic()".
295 And we set all field values at an end time to be equal 20.0 by doubling the start
296 time array.
297 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_getValueOn_time_2
298 Now, we want to get a field value at a point [0,0] at a middle time between the start
299 and end times. We expect the returned value to be equal to an average of 10. and 20.
300 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_getValueOn_time_3
301
302
303 \anchor cpp_mcfielddouble_getValueOnMulti
304 <br><h2> Getting field values at some points</h2>
305
306 First, we create a supporting structured mesh. We create a 2x2 Cartesian mesh
307 constituted by 4 cells. Then we create a scalar field on cells using
308 \ref ParaMEDMEM::MEDCouplingFieldDouble::fillFromAnalytic "fillFromAnalytic()".
309 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_getValueOnMulti_1
310 Now, we want to retrieve all field values using 
311 \ref ParaMEDMEM::MEDCouplingFieldDouble::getValueOnMulti "getValueOnMulti()".
312 The field values relate to cells, hence we will use cell barycenters as a parameter of
313 \ref ParaMEDMEM::MEDCouplingFieldDouble::getValueOnMulti "getValueOnMulti()".
314 We expect that the double array returned 
315 \ref ParaMEDMEM::MEDCouplingFieldDouble::getValueOnMulti "getValueOnMulti()"
316 is equal to that stored by \b field.
317 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_getValueOnMulti_2
318
319
320
321 \anchor cpp_mcfielddouble_getValueOn
322 <br><h2> Getting a field value at a point</h2>
323
324 First, we create a supporting structured mesh. We create a 2x2 Cartesian mesh
325 constituted by 4 cells. Then we create a scalar field on cells using
326 \ref ParaMEDMEM::MEDCouplingFieldDouble::fillFromAnalytic "fillFromAnalytic()".
327 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_getValueOn_1
328 Now, we want to retrieve all field values using 
329 \ref ParaMEDMEM::MEDCouplingFieldDouble::getValueOn "getValueOn()".
330 The field values relate to cells, hence we will use cell barycenters to get a field
331 value at each cell.
332 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_getValueOn_2
333 We collected all values returned by 
334 \ref ParaMEDMEM::MEDCouplingFieldDouble::getValueOn "getValueOn()" in an array, so
335 that we can ascertain that the array of returned values is same as that stored by \b
336 field. 
337
338
339
340 \anchor cpp_mcfielddouble_getValueOnPos
341 <br><h2> Getting a value of field lying on a structured mesh</h2>
342
343 First, we create a supporting structured mesh. We create a 2x2 Cartesian mesh
344 constituted by 4 cells. Then we create a scalar field on cells using
345 \ref ParaMEDMEM::MEDCouplingFieldDouble::fillFromAnalytic "fillFromAnalytic()".
346 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_getValueOnPos_1
347 Now, we retrieve a field value relating to the cell #3 (this cell has a structured indexed
348 (1,1)). For that we use
349 \ref ParaMEDMEM::MEDCouplingFieldDouble::getValueOnPos "getValueOnPos()" where we
350 pass the structured indexed of the cell: 1,1,-1 (the last index is meaningless as the
351 mesh is 2D).
352 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_getValueOnPos_2
353 After all we ascertain that the returned value corresponds to the formular used for
354 the field creation. Namely that the value equals to the sum of components of
355 barycenter of cell #3.
356
357
358
359 \anchor cpp_mcfielddouble_renumberNodes
360 <br><h2> Permuting a field on nodes</h2>
361
362 First, we create a supporting 2D mesh constituted by 4 cells. We create a 2x2
363 Cartesian mesh and then convert it to an unstructured one, since the Cartesian mesh
364 is not suitable for
365 \ref ParaMEDMEM::MEDCouplingFieldDouble::renumberNodes "renumberNodes()" as its
366  nature does not imply node renumbering.
367 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_renumberNodes_1
368 Then we create a field on nodes using
369 \ref ParaMEDMEM::MEDCouplingFieldDouble::fillFromAnalytic "fillFromAnalytic()", 
370 such that its values to coincide with coordinates of field location points that are
371  nodes in our case (as our field is \ref ParaMEDMEM::ON_NODES "ON_NODES").
372 At last we ascertain that field values are equal to node coordinates.
373 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_renumberNodes_2
374 Now, we are going to reverse order of nodes using
375 \ref ParaMEDMEM::MEDCouplingFieldDouble::renumberNodes "renumberNodes()".
376 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_renumberNodes_3
377 As a result, the underlying mesh of \b field is changed and its nodes are also
378  renumbered. 
379 And the field values are still equal to node coordinates of the renumbered \b mesh2.
380
381
382
383 \anchor cpp_mcfielddouble_renumberCells
384 <br><h2> Permuting a field on cells</h2>
385
386 First, we create a supporting 2D mesh constituted by 4 cells. We create a 2x2
387 Cartesian mesh and then convert it to an unstructured one, since the Cartesian mesh
388 is not suitable for
389 \ref ParaMEDMEM::MEDCouplingFieldDouble::renumberCells "renumberCells()" as its
390  nature does not imply cell renumbering.
391 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_renumberCells_1
392 Then we create a field on cells using
393 \ref ParaMEDMEM::MEDCouplingFieldDouble::fillFromAnalytic "fillFromAnalytic()", 
394 such that its values to coincide with coordinates of field location points that are
395  cell barycenters in our case (as our field is \ref ParaMEDMEM::ON_CELLS "ON_CELLS").
396 At last we ascertain that field values are equal to cell barycenters.
397 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_renumberCells_2
398 Now, we are going to reverse order of cells using
399 \ref ParaMEDMEM::MEDCouplingFieldDouble::renumberCells "renumberCells()".
400 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_renumberCells_3
401 As a result, the underlying mesh of \b field is changed and its cells are also
402  renumbered. 
403 And the field values are still equal to cell barycenters of the renumbered \b mesh2.
404
405
406
407 \anchor cpp_mcfielddouble_buildNewTimeReprFromThis
408 <br><h2> Getting a field copy with different time discretization </h2>
409
410 First, we create a supporting 2D mesh and a field on it got using
411 \ref ParaMEDMEM::MEDCouplingFieldDouble::fillFromAnalytic "fillFromAnalytic()".
412 \ref MEDCouplingTemporalDisc "Time discretization" of this field is 
413 \ref ParaMEDMEM::ONE_TIME "ONE_TIME".
414 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_buildNewTimeReprFromThis_1
415 Now we use
416 \ref ParaMEDMEM::MEDCouplingFieldDouble::buildNewTimeReprFromThis "buildNewTimeReprFromThis()"
417 to get a copy of \b field1 whose time discretization is 
418 \ref ParaMEDMEM::NO_TIME "NO_TIME".
419 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_buildNewTimeReprFromThis_2
420
421
422 \anchor cpp_mcmesh_fillFromAnalytic3
423 <br><h2> Creating a field using a formular </h2>
424
425 First, we create a 2D Cartesian mesh constituted by 2 cells.
426 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingMesh_fillFromAnalytic3_1
427 Now we use
428 \ref ParaMEDMEM::MEDCouplingMesh::fillFromAnalytic3 "fillFromAnalytic3()"
429 to get a \ref ParaMEDMEM::MEDCouplingFieldDouble "MEDCouplingFieldDouble" on cells filled
430 with values computed using a formular \b func. This formular is applied to coordinates of
431 each point (barycenter) for which the field value is computed. We want to get the
432 field on cells, with 3 components computed as follows. (In \b func, we refer to the
433 first component of a point using the variable "a", and to the second component, using
434 the variable "b").
435 - Component #0 = the second coordinate of the point; hence "IVec * b" in \b func.
436 - Component #1 = the first coordinate of the point; hence "JVec * a".
437 - Component #2 = distance between the point and SC origin (0.,0.); hence 
438 "KVec * sqrt( a*a + b*b )".
439
440 In addition we want to add 10.0 to each component computed as described above, hence
441 "10" in \b func.
442 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingMesh_fillFromAnalytic3_2
443 Now we ascertain that the result field is as we expect. We check the second tuple of
444 the \b field. We get barycenter of the cell #1 and checks that values of the second
445 tuple are computed as we want.
446 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingMesh_fillFromAnalytic3_3
447
448
449
450 \anchor cpp_mcmesh_fillFromAnalytic2
451 <br><h2> Creating a field using a formular </h2>
452
453 First, we create a 2D Cartesian mesh constituted by 2 cells.
454 Note that we set names to coordinates arrays ("a" and "b" ) which will be used to refer to
455 corresponding coordinates within a function.
456 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingMesh_fillFromAnalytic2_1
457 Now we use
458 \ref ParaMEDMEM::MEDCouplingMesh::fillFromAnalytic2 "fillFromAnalytic2()"
459 to get a \ref ParaMEDMEM::MEDCouplingFieldDouble "MEDCouplingFieldDouble" on cells filled
460 with values computed using a formular \b func. This formular is applied to coordinates of
461 each point (barycenter) for which the field value is computed. We want to get the
462 field on cells, with 3 components computed as follows. (In \b func, we refer to the
463 first component of a point using the variable "a", and to the second component, using
464 the variable "b").
465 - Component #0 = the second coordinate of the point; hence "IVec * b" in \b func.
466 - Component #1 = the first coordinate of the point; hence "JVec * a".
467 - Component #2 = distance between the point and SC origin (0.,0.); hence 
468 "KVec * sqrt( a*a + b*b )".
469
470 In addition we want to add 10.0 to each component computed as described above, hence
471 "10" in \b func.
472 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingMesh_fillFromAnalytic2_2
473 Now we ascertain that the result field is as we expect. We check the second tuple of
474 the \b field. We get barycenter of the cell #1 and checks that values of the second
475 tuple are computed as we want.
476 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingMesh_fillFromAnalytic2_3
477
478
479 \anchor cpp_mcmesh_fillFromAnalytic
480 <br><h2> Creating a field using a formular </h2>
481
482 First, we create a 2D Cartesian mesh constituted by 2 cells.
483 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingMesh_fillFromAnalytic_1
484 Now we use
485 \ref ParaMEDMEM::MEDCouplingMesh::fillFromAnalytic "fillFromAnalytic()"
486 to get a \ref ParaMEDMEM::MEDCouplingFieldDouble "MEDCouplingFieldDouble" on cells filled 
487 with values computed using a formular \b func. This formular is applied to coordinates of
488 each point (barycenter) for which the field value is computed. We want to get the
489 field on cells, with 3 components computed as follows. (In \b func, we refer to the
490 first component of a point using the variable "a", and to the second component, using
491 the variable "b").
492 - Component #0 = the second coordinate of the point; hence "IVec * b" in \b func.
493 - Component #1 = the first coordinate of the point; hence "JVec * a".
494 - Component #2 = distance between the point and SC origin (0.,0.); hence 
495 "KVec * sqrt( a*a + b*b )".
496
497 In addition we want to add 10.0 to each component computed as described above, hence
498 "10" in \b func.
499 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingMesh_fillFromAnalytic_2
500 Now we ascertain that the result field is as we expect. We check the second tuple of
501 the \b field. We get barycenter of the cell #1 and checks that values of the second
502 tuple are computed as we want.
503 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingMesh_fillFromAnalytic_3
504
505
506 \anchor cpp_mccmesh_getCoordsAt
507 <br><h2> Getting node coordinates </h2>
508
509 We create an 1D Cartesian mesh and retrieves node coordinates using
510 \ref ParaMEDMEM::MEDCouplingCMesh::getCoordsAt "getCoordsAt()".
511 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingCMesh_getCoordsAt_1
512
513
514
515 \anchor cpp_mcumesh_areCellsIncludedIn
516 <br><h2> Cells correspondence in two meshes </h2>
517
518 First, we create a 2D \b mesh1 with 3 QUAD4 and 2 TRI3 cells.
519 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_areCellsIncludedIn_1
520 Then we create a \b mesh2 which includes cells #4, #2 and #0 of \b mesh1. The two meshes
521 share the same node coordinates array.
522 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_areCellsIncludedIn_2
523 Now we ascertain that
524 - \ref ParaMEDMEM::MEDCouplingUMesh::areCellsIncludedIn "areCellsIncludedIn()"
525 detects that all cells of \b mesh2 are present in \b mesh1,
526 -  the correspondence array \b corr2to1, which gives cell ids of \b mesh2 within
527 \b mesh1, is equal to the array \b cells2 which selected cells from \b mesh1 for creation
528 of \b mesh2.
529
530 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_areCellsIncludedIn_3
531 Now we apply
532 \ref ParaMEDMEM::MEDCouplingUMesh::areCellsIncludedIn "areCellsIncludedIn()"
533 in a reverse direction and ascertain that it returns \c false. 
534 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_areCellsIncludedIn_4
535 The contents of the correspondence
536 array \b corr1to2 [2, 3, 1, 4, 0] means the following.
537 - The cell #0 of \b mesh1 is equal to the cell #2 (== \b corr1to2[ 0 ]) of \b mesh2.
538 - The cell #1 of \b mesh1 is missing from \b mesh2 (as \b corr1to2[ 1 ] >= \b mesh2->getNumberOfCells()).
539 - The cell #2 of \b mesh1 is equal to the cell #1 (== \b corr1to2[ 2 ]) of \b mesh2.
540 - The cell #3 of \b mesh1 is missing from \b mesh2 (as \b corr1to2[ 3 ] >= \b mesh2->getNumberOfCells()).
541 - The cell #4 of \b mesh1 is equal to the cell #0 (== \b corr1to2[ 4 ]) of \b mesh2.
542
543
544 \anchor cpp_mcumesh_checkDeepEquivalWith
545 <br><h2> Deep comparison of meshes </h2>
546
547 First, we create two 2D meshes with two triangles, so that 
548 - their nodes are almost same but permuted,
549 - the first triangle is based exactly on the same nodes (taking the permutation into account),
550 - an order of nodes in the second triangle is changed.
551
552 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_checkDeepEquivalWith_1
553 Then we check that 
554 - \ref ParaMEDMEM::MEDCouplingUMesh::checkDeepEquivalWith "checkDeepEquivalWith()"
555 considers the meshes equal (i.e. it does not throw any exception) if it is called with a cell
556 comparison policy \b cellCompPol == 1
557 -  mapping from \b mesh1 to \b mesh2 for both nodes and cells is as expected.
558
559 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_checkDeepEquivalWith_2
560 Next we ascertain that 
561 \ref ParaMEDMEM::MEDCouplingUMesh::checkDeepEquivalOnSameNodesWith "checkDeepEquivalOnSameNodesWith()"
562 consider \b mesh1 and \b mesh2 different as they do not share the same nodal connectivity
563 array. <br>
564 After that we make the meshes share the node coordinates array and insert new
565 triangles based on the same nodes but in different order. This is to ascertain that
566 \ref ParaMEDMEM::MEDCouplingUMesh::checkDeepEquivalOnSameNodesWith "checkDeepEquivalOnSameNodesWith()"
567 called with the weakest cell comparison policy considers the meshes equal.
568 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_checkDeepEquivalWith_3
569
570
571
572 \anchor cpp_mcumesh_getPartBarycenterAndOwner
573 <br><h2> Getting barycenters of cells </h2>
574
575 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
576 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getPartMeasureField_1
577 Now we use
578 \ref ParaMEDMEM::MEDCouplingUMesh::getPartBarycenterAndOwner "getPartBarycenterAndOwner()" to get
579 barycenters of all but the first cell.
580 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getPartMeasureField_3
581 The returned array contains 4 tuples per 2 components.
582
583
584 \anchor cpp_mcumesh_findAndCorrectBadOriented3DExtrudedCells
585 <br><h2> Fixing orientation of "extruded" volumes </h2>
586
587 First, we create a mesh with 2 incorrectly oriented "extruded" volumes.
588 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_findAndCorrectBadOriented3DExtrudedCells_1
589 Now we check that
590 \ref ParaMEDMEM::MEDCouplingUMesh::findAndCorrectBadOriented3DExtrudedCells "findAndCorrectBadOriented3DExtrudedCells()"
591 finds and fixes the reversed cells.
592 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_findAndCorrectBadOriented3DExtrudedCells_2
593
594
595 \anchor cpp_mcumesh_arePolyhedronsNotCorrectlyOriented
596 <br><h2> Fixing orientation of polyhedra </h2>
597
598 First, we create a mesh with 2 polyhedra, one of which is incorrectly oriented. We create
599 two "extruded" polyhedra and then convert them to correctly defined polyhedra.
600 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_arePolyhedronsNotCorrectlyOriented_1
601 Now we check that
602 \ref ParaMEDMEM::MEDCouplingUMesh::arePolyhedronsNotCorrectlyOriented "arePolyhedronsNotCorrectlyOriented()"
603 finds one reversed cell. After that we fix it using
604 \ref ParaMEDMEM::MEDCouplingUMesh::orientCorrectlyPolyhedrons "orientCorrectlyPolyhedrons()" and
605 re-check the orientation of polyhedra.
606 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_arePolyhedronsNotCorrectlyOriented_2
607
608
609 \anchor cpp_mcumesh_are2DCellsNotCorrectlyOriented
610 <br><h2> Fixing orientation of faces </h2>
611
612 First, we create a 2D mesh in 3D space with 3 QUAD4 and 2 TRI3 cells. Orientation of the cell #1 is
613 reversed comparing with others.
614 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_are2DCellsNotCorrectlyOriented_1
615 Now we check that
616 \ref ParaMEDMEM::MEDCouplingUMesh::are2DCellsNotCorrectlyOriented "are2DCellsNotCorrectlyOriented()"
617 finds one reversed face. After that we fix the incorrectly oriented cell using
618 \ref ParaMEDMEM::MEDCouplingUMesh::orientCorrectly2DCells "orientCorrectly2DCells()" and
619 re-check the orientation of cells.
620 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_are2DCellsNotCorrectlyOriented_2
621
622
623 \anchor cpp_mcumesh_getCellsContainingPoints
624 <br><h2> Finding cells containing a point (multi-point case) </h2>
625
626 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
627 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getCellsContainingPoints_1
628 Then we use 
629 \ref ParaMEDMEM::MEDCouplingUMesh::getCellsContainingPoints "getCellsContainingPoints()" to
630 get cells in contact with tree points. Two of them are in contact with some cells and one is not.
631 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getCellsContainingPoints_2
632 The contents of the result arrays \b cells ([4, 0, 1]) and \b cellsIndex ([0, 0, 1, 3])
633 mean the following.
634 - Point #0 is in contact with none (== \b cellsIndx[1] - \b cellsIndx[0]) cell.
635 - Point #1 is in contact with 1 (== \b cellsIndx[2] - \b cellsIndx[1]) cell whose id is #4
636   (== \b cells[ \b cellsIndx[ 1 ]]).
637 - Point #2 is in contact with 2 (== \b cellsIndx[3] - \b cellsIndx[2]) cells whose ids are #0 
638   (== \b cells[ \b cellsIndx[ 2 ]]) and #1 (== \b cells[ \b cellsIndx[ 2 ] + 1 ]).
639
640
641 \anchor cpp_mcumesh_getCellsContainingPoint
642 <br><h2> Finding cells containing a point </h2>
643
644 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
645 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getCellsContainingPoint_1
646 Then we use 
647 \ref ParaMEDMEM::MEDCouplingUMesh::getCellsContainingPoint "getCellsContainingPoint()" to
648 get cells in contact with a small ball (point with precision) located near the node #4 and
649 shifted from this node by its radius \b eps.
650 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getCellsContainingPoint_2
651 Since the node #4 is shared by all cells, size of the vector \b cellIds must be equal to
652 the number of cells in \b mesh.
653
654 \anchor cpp_mcumesh_buildPartOrthogonalField
655 <br><h2> Getting normals of cells </h2>
656
657 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells. Orientation of the cell #1 is
658 reversed.
659 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildPartOrthogonalField_1
660 Now we use
661 \ref ParaMEDMEM::MEDCouplingUMesh::buildPartOrthogonalField "buildPartOrthogonalField()" to get
662 normal vectors to the cells.
663 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildPartOrthogonalField_2
664
665
666
667 \anchor cpp_mcumesh_getPartMeasureField
668 <br><h2> Getting volumes of cells </h2>
669
670 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells. Orientation of the cell #1 is
671 reversed.
672 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getPartMeasureField_1
673 Now we use
674 \ref ParaMEDMEM::MEDCouplingUMesh::getPartMeasureField "getPartMeasureField()" to get
675 volumes of all but the first cell. If we call
676 \ref ParaMEDMEM::MEDCouplingUMesh::getPartMeasureField "getPartMeasureField()" with \b
677 isAbs == \c true, the area of the cell #1 is returned positive, else, negative that
678 reflects its inverse orientation.
679 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getPartMeasureField_2
680
681
682
683 \anchor cpp_mcumesh_getCellsInBoundingBox
684 <br><h2> Getting cells using the bounding box </h2>
685
686 First, we create a 2D mesh with 1 TRI3 cell. Bounding box of this cell is [0.,0., 1.,1].
687 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getCellsInBoundingBox_1
688 Now we check how 
689 \ref ParaMEDMEM::MEDCouplingUMesh::getCellsInBoundingBox "getCellsInBoundingBox()"
690 searches for cells using the bounding box. We use a bounding box touching the bounding box
691 of the sole cell at one point (1.,1.).
692 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getCellsInBoundingBox_2
693 If \ref ParaMEDMEM::MEDCouplingUMesh::getCellsInBoundingBox "getCellsInBoundingBox()" is
694 called with parameter \b eps == 0.0, the cell is not found because the two bounding boxes
695 (one of the cell and the one passed as parameter) do not overlap. <br>
696 If \ref ParaMEDMEM::MEDCouplingUMesh::getCellsInBoundingBox "getCellsInBoundingBox()" is
697 called with parameter \b eps == 0.1, the cell is found because \b eps is used to increase
698 the bounding box of the cell and thus the two bounding boxes intersect each other. <br>
699
700 \anchor cpp_mcumesh_renumberNodesInConn
701 <br><h2> Renumbering nodes in the connectivity array </h2>
702
703 First, we create a 2D mesh with 1 QUAD4 cell and with undefined coordinates of nodes.
704 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_renumberNodesInConn_1
705 Now we use
706 \ref ParaMEDMEM::MEDCouplingUMesh::renumberNodesInConn "renumberNodesInConn()"
707 to get the following nodal connectivity of a sole cell: 0,1,2,3.
708 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_renumberNodesInConn_2
709 \b old2newIds array defines how node ids are changed:
710 - new id of node #0 is -1,
711 - new id of node #1 is 3,
712 - new id of node #2 is 4,
713 - new id of node #3 is 1,
714 - new id of node #4 is 0.
715
716 \anchor cpp_mcumesh_renumberNodes
717 <br><h2> Renumbering nodes </h2>
718
719 First, we create a 2D mesh with 4 nodes and no cells.
720 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_renumberNodes_1
721 Next, we use 
722 \ref ParaMEDMEM::MEDCouplingUMesh::renumberNodes "renumberNodes()"
723 to permute nodes so that
724 - old node #0 becomes #2,
725 - old node #1 remains #1,
726 - old node #2 becomes #0,
727 - old node #3 is removed.
728
729 Number of nodes becomes 3.
730 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_renumberNodes_2
731
732 Next we compare behavior of 
733 \ref ParaMEDMEM::MEDCouplingUMesh::renumberNodes "renumberNodes()" and that of
734 \ref ParaMEDMEM::MEDCouplingUMesh::renumberNodes2 "renumberNodes2()" which, in contrast to
735 \ref ParaMEDMEM::MEDCouplingUMesh::renumberNodes "renumberNodes()",
736 moves merged nodes to their barycenter.<br> 
737 We set #2 as new id of old node #3 and expect that 
738 \ref ParaMEDMEM::MEDCouplingUMesh::renumberNodes2 "renumberNodes2()" moves old nodes #0
739 and #3 to their barycenter (-0.3,0.0) which becomes position of node #2.<br>
740 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_renumberNodes_3
741
742
743 \anchor cpp_mcumesh_findBoundaryNodes
744 <br><h2> Getting boundary nodes </h2>
745
746 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
747 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_findBoundaryNodes_1
748 Now we use 
749 \ref ParaMEDMEM::MEDCouplingUMesh::findBoundaryNodes "findBoundaryNodes()" to get ids
750 of boundary nodes.
751 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_findBoundaryNodes_2
752 \ref ParaMEDMEM::MEDCouplingUMesh::findBoundaryNodes "findBoundaryNodes()" returns all
753 node ids except the node #4 which is in the middle of \b mesh.
754
755
756 \anchor cpp_mcumesh_buildBoundaryMesh
757 <br><h2> Getting a bounding mesh </h2>
758
759 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
760 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildBoundaryMesh_1
761 Now we use 
762 \ref ParaMEDMEM::MEDCouplingUMesh::buildBoundaryMesh "buildBoundaryMesh()" to get a mesh
763 of lower dimension bounding \b mesh.
764 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildBoundaryMesh_2
765 Depending on the value of a parameter,
766 \ref ParaMEDMEM::MEDCouplingUMesh::buildBoundaryMesh "buildBoundaryMesh()"
767 creates the mesh sharing the node coordinates array with \b mesh or not.
768
769
770 \anchor cpp_mcumesh_buildFacePartOfMySelfNode
771 <br><h2> Retrieving a lower dimension mesh based on given nodes </h2>
772
773 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
774 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildFacePartOfMySelfNode_1
775 In the following code we retrieve nodes of the cell #0 an then we call
776 \ref ParaMEDMEM::MEDCouplingUMesh::buildFacePartOfMySelfNode "buildFacePartOfMySelfNode()" 
777 twice with these nodes and with varying last parameter \b allNodes as input.
778 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildFacePartOfMySelfNode_2
779 <br>If the last parameter is \c true 
780 \ref ParaMEDMEM::MEDCouplingUMesh::buildFacePartOfMySelfNode "buildFacePartOfMySelfNode()" looks
781 for segements whose all nodes are given to it, hence it finds segments bounding the cell #0 only.
782 <br>If the last parameter is \c false
783 \ref ParaMEDMEM::MEDCouplingUMesh::buildFacePartOfMySelfNode "buildFacePartOfMySelfNode()" looks
784 for any segment whose nodes are given to it, hence it adds more segments to \b mesh2.
785
786
787 \anchor cpp_mcumesh_buildPartOfMySelfNode
788 <br><h2> Copying cells selected by nodes </h2>
789
790 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
791 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildPartOfMySelfNode_1
792 In the following code we retrieve nodes of the cell #0 an then we call
793 \ref ParaMEDMEM::MEDCouplingUMesh::buildPartOfMySelfNode "buildPartOfMySelfNode()" 
794 twice with these nodes and with varying last parameter \b allNodes as input.
795 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildPartOfMySelfNode_2
796 <br>If the last parameter is \c true 
797 \ref ParaMEDMEM::MEDCouplingUMesh::buildPartOfMySelfNode "buildPartOfMySelfNode()" looks
798 for cells whose all nodes are given to it, hence it finds the cell #0 only.
799 <br>If the last parameter is \c false
800 \ref ParaMEDMEM::MEDCouplingUMesh::buildPartOfMySelfNode "buildPartOfMySelfNode()" looks
801 for any cell whose nodes are given to it, hence it finds all cells of \b mesh because all
802 cells share the node #4.
803
804
805 \anchor cpp_mcumesh_getCellIdsLyingOnNodes
806 <br><h2> Getting cells by nodes </h2>
807
808 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
809 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getCellIdsLyingOnNodes_1
810 In the following code we retrieve nodes of the cell #0 an then we call
811 \ref ParaMEDMEM::MEDCouplingUMesh::getCellIdsLyingOnNodes "getCellIdsLyingOnNodes()" 
812 twice with these nodes and with varying last parameter \b allNodes as input.
813 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getCellIdsLyingOnNodes_2
814 <br>If the last parameter is \c true 
815 \ref ParaMEDMEM::MEDCouplingUMesh::getCellIdsLyingOnNodes "getCellIdsLyingOnNodes()" looks
816 for cells whose all nodes are given to it, hence it finds the cell #0 only.
817 <br>If the last parameter is \c false
818 \ref ParaMEDMEM::MEDCouplingUMesh::getCellIdsLyingOnNodes "getCellIdsLyingOnNodes()" looks
819 for any cell whose nodes are given to it, hence it finds all cells of \b mesh because all
820 cells share the node #4.
821
822
823
824 \anchor cpp_mcumesh_getCellIdsFullyIncludedInNodeIds
825 <br><h2> Getting cells by nodes </h2>
826
827 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
828 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getCellIdsFullyIncludedInNodeIds_1
829 In the following code we retrieve nodes of two cells an then we use 
830 \ref ParaMEDMEM::MEDCouplingUMesh::getCellIdsFullyIncludedInNodeIds
831 "getCellIdsFullyIncludedInNodeIds()" to find these cells by their nodes.
832 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getCellIdsFullyIncludedInNodeIds_2
833
834
835 \anchor cpp_mcumesh_buildPartOfMySelf
836 <br><h2> Getting a part of mesh </h2>
837
838 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
839 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildPartOfMySelf_1
840 Now we use 
841 \ref ParaMEDMEM::MEDCouplingUMesh::buildPartOfMySelf "buildPartOfMySelf()" to get a mesh
842 containing only two cells of \b mesh. 
843 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildPartOfMySelf_2
844
845
846 \anchor cpp_mcumesh_mergeNodes
847 <br><h2> Merging equal nodes </h2>
848
849 First, we create a 2D mesh with 1 QUAD4 and 2 TRI3 cells. The cells are based on 6 nodes
850 of which 2 nodes fully coincide (#3 and #4) and 3 nodes are equal with precision 0.003.
851 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_mergeNodes_1
852 Now we merge node duplicates using
853 \ref ParaMEDMEM::MEDCouplingUMesh::mergeNodes "mergeNodes()" and check values it returns.
854 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_mergeNodes_2
855 Contents of \b arr shows ids of old nodes after the merging. The nodes considered equal
856 one to the other have the same id in \b arr.
857
858 Next we compare behavior of 
859 \ref ParaMEDMEM::MEDCouplingUMesh::mergeNodes "mergeNodes()" and that of
860 \ref ParaMEDMEM::MEDCouplingUMesh::mergeNodes2 "mergeNodes2()" which, in contrast to
861 \ref ParaMEDMEM::MEDCouplingUMesh::mergeNodes "mergeNodes()",
862 moves merged nodes to their barycenter.<br> We expect that 
863 \ref ParaMEDMEM::MEDCouplingUMesh::mergeNodes2 "mergeNodes2()" moves old nodes #0, #2 
864 and #5 to their barycenter equal to position of node #2.<br>
865 First we check that 
866 \ref ParaMEDMEM::MEDCouplingUMesh::mergeNodes "mergeNodes()" does not move nodes
867 coincident with the node #2 to the position of node #2, and then we check that 
868 \ref ParaMEDMEM::MEDCouplingUMesh::mergeNodes "mergeNodes2()" does move.
869 (We check only the second (Y) component of node coordinates since the first component of
870 these nodes is exactly same.)
871 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_mergeNodes_3
872
873
874
875 \anchor cpp_mcumesh_zipConnectivityTraducer
876 <br><h2> Removing cell duplicates </h2>
877
878 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells, so that
879 - the cell #2 has the same nodal connectivity as the cell #1 does,
880 - the cell #3 has the same nodal connectivity as the cell #0 does,
881 - the cell #4 is based on the same nodes as the cell #0 but nodes order is different.
882
883 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_zipConnectivityTraducer_1
884 Now we use 
885 \ref ParaMEDMEM::MEDCouplingUMesh::zipConnectivityTraducer "zipConnectivityTraducer()" 
886 to remove duplicate cells. Then we check that two cells, having exactly same nodal
887 connectivity with other cells, have been removed.
888 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_zipConnectivityTraducer_2
889 Contents of \b arr shows ids of cells after duplicates removal. If a value (cell id)
890 equals to its index in \b arr, this means that the cell is not a duplicate of any cell
891 with lower id. Else, the value gives a cell id to which this cell is equal. <br>
892 Thus, the cells #0 and #1 have no preceding equal cell since \b arr[i] == i.<br>
893 The cell #2 equals to the cell #1 (== \b arr[2] ).<br>
894 The cell #3 equals to the cell #0 (== \b arr[3] ).<br>
895 The cell #4 has no equal cell. This is because the cell comparison technique specified
896 when we called 
897 \ref ParaMEDMEM::MEDCouplingUMesh::zipConnectivityTraducer "zipConnectivityTraducer()" 
898 was 0 ("exact"), if we had used the technique 2 ("nodal"), \b arr[4] would be 0.
899
900
901
902 \anchor cpp_mcumesh_zipCoordsTraducer
903 <br><h2> Removing unused nodes </h2>
904
905 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
906 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_zipCoordsTraducer_1
907 Now we create \b mesh2 including all nodes but only two cells of \b mesh, and we use \ref
908 ParaMEDMEM::MEDCouplingUMesh::zipCoordsTraducer "zipCoordsTraducer()" to remove unused
909 nodes from \b mesh2. 
910 \ref ParaMEDMEM::MEDCouplingUMesh::zipCoordsTraducer "zipCoordsTraducer()" returns an array
911 with -1 for unused nodes and new ids for used ones.
912 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_zipCoordsTraducer_2
913
914
915
916 \anchor cpp_mcumesh_getNodeIdsInUse
917 <br><h2> Retrieving unused nodes </h2>
918
919 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
920 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getNodeIdsInUse_1
921 Now we create \b mesh2 including all nodes but only two cells of \b mesh, and we use \ref
922 ParaMEDMEM::MEDCouplingUMesh::getNodeIdsInUse "getNodeIdsInUse()" to get nodes of \b mesh2
923 used in its two cells. 
924 \ref ParaMEDMEM::MEDCouplingUMesh::getNodeIdsInUse "getNodeIdsInUse()" returns an array
925 with -1 for unused nodes and new ids for used ones.
926 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getNodeIdsInUse_2
927 Now we use \b newNbOfNodes returned by 
928 \ref ParaMEDMEM::MEDCouplingUMesh::getNodeIdsInUse "getNodeIdsInUse()" to convert \b arr
929 to "New to Old" mode.
930 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getNodeIdsInUse_3
931
932
933 \anchor cpp_mcumesh_convertToPolyTypes
934 <br><h2> Conversion of cells to "poly" types </h2>
935
936 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
937 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_convertToPolyTypes_1
938 Now we convert cells #1 and #3 to type POLYGON and check the result
939 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_convertToPolyTypes_2
940
941
942 \anchor cpp_mcumesh_buildDescendingConnectivity2
943 <br><h2> Retrieving the descending connectivity with orientation </h2>
944
945 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
946 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildDescendingConnectivity2_1
947 Now we get and check the descending connectivity.
948 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildDescendingConnectivity2_2
949 Here we get connectivity of the cell #2 (#3 in FORTRAN mode) of \b mesh2 to see how
950 mutual orientation of cells in \b mesh and \b mesh2 is defined.
951 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildDescendingConnectivity2_3
952 The contents of the result arrays \b desc and \b descIndx mean the following.
953 - The cell #0 of \b mesh (QUAD4) is bound by 4 (== \b descIndx[1] - \b descIndx[0])
954   segments (SEG2) of \b mesh2 whose ids in FORTRAN mode are
955   - #1 (== \b desc[ \b descIndx[ 0 ]]),
956   - #2 (== \b desc[ \b descIndx[ 0 ] + 1 ]), 
957   - #3 (== \b desc[ \b descIndx[ 0 ] + 2 ]) and 
958   - #4 (== \b desc[ \b descIndx[ 0 ] + 3 ]).
959   <br>Ids are positive since order of nodes in the corresponding cells of \b mesh and \b mesh2
960   are same. For example nodes of SEG2 #3 are [4,1] and nodes of QUAD4 #0 are [0,3,\b 4,\b 1].
961 - The cell #1 of \b mesh (TRI3) is bound by 3 (== \b descIndx[2] - \b descIndx[1]) segements of
962   \b mesh2 whose ids in FORTRAN mode are: 
963   - #-3 (== \b desc[ \b descIndx[ 1 ]]),
964   - #5 (== \b desc[ \b descIndx[ 1 ] + 1 ]) and 
965   - #6 (== \b desc[ \b descIndx[ 1 ] + 2 ]).
966   <br>The id -3 means that order of nodes in SEG2 #3 ([4,1]) is different from the order of
967   these nodes in TRI3 #1: [\b 1,\b 4,2].
968 - etc.
969
970 The contents of the result arrays \b revDesc and \b revDescIndx mean the following.
971 - The cell #0 of \b mesh2 (SEG2) bounds 1 (== \b revDescIndx[1] - \b revDescIndx[0]) cell of \b
972   mesh whose id is:
973   - # 0 (== \b revDesc[ \b revDescIndx[ 0 ]]).
974 - The cell #1 of \b mesh2 bounds 2 (== \b revDescIndx[2] - \b revDescIndx[1]) cells of \b
975   mesh whose ids are:
976   - # 0 (== \b revDesc[ \b revDescIndx[ 1 ]]) and
977   - # 1 (== \b revDesc[ \b revDescIndx[ 1 ] + 1 ]).
978 - etc.
979
980
981
982 \anchor cpp_mcumesh_buildDescendingConnectivity
983 <br><h2> Retrieving the descending connectivity </h2>
984
985 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
986 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildDescendingConnectivity_1
987 Now we get and check the descending connectivity.
988 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildDescendingConnectivity_2
989 The contents of the result arrays \b desc and \b descIndx mean the following.
990 - The cell #0 of \b mesh (QUAD4) is bound by 4 (== \b descIndx[1] - \b descIndx[0])
991   segments (SEG2) of \b mesh2 whose ids are 
992   - #0 (== \b desc[ \b descIndx[ 0 ]]), 
993   - #1 (== \b desc[ \b descIndx[ 0 ] + 1 ]), 
994   - #2 (== \b desc[ \b descIndx[ 0 ] + 2 ]) and 
995   - #3 (== \b desc[ \b descIndx[ 0 ] + 3 ]).
996 - The cell #1 of \b mesh (TRI3) is bound by 3 (== \b descIndx[2] - \b descIndx[1]) segements of
997   \b mesh2 whose ids are: 
998   - #2 (== \b desc[ \b descIndx[ 1 ]]), 
999   - #4 (== \b desc[ \b descIndx[ 1 ] + 1 ]) and 
1000   - #5 (== \b desc[ \b descIndx[ 1 ] + 2 ]).
1001 - etc.
1002
1003 The contents of the result arrays \b revDesc and \b revDescIndx mean the following.
1004 - The cell #0 of \b mesh2 (SEG2) bounds 1 (== \b revDescIndx[1] - \b revDescIndx[0]) cell of \b
1005   mesh whose id is:
1006   - # 0 (== \b revDesc[ \b revDescIndx[ 0 ]]).
1007 - The cell #1 of \b mesh2 bounds 2 (== \b revDescIndx[2] - \b revDescIndx[1]) cells of \b
1008   mesh whose ids are:
1009   - # 0 (== \b revDesc[ \b revDescIndx[ 1 ]]) and
1010   - # 1 (== \b revDesc[ \b revDescIndx[ 1 ] + 1 ]).
1011 - etc.
1012
1013
1014 \anchor cpp_mcumesh_getReverseNodalConnectivity
1015 <br><h2> Getting the reverse nodal connectivity </h2>
1016
1017 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
1018 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getReverseNodalConnectivity_1
1019 Now we get and check its reverse nodal connectivity.
1020 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getReverseNodalConnectivity_2
1021 The contents of the result arrays mean the following.
1022 - Node #0 is shared by 1 (== \b revNodalIndx[1] - \b revNodalIndx[0]) cell whose id is #0 
1023   (== \b revNodal[ \b revNodalIndx[ 0 ]]).
1024 - Node #1 is shared by 2 (== \b revNodalIndx[2] - \b revNodalIndx[1]) cells whose ids are #0 
1025   (== \b revNodal[ \b revNodalIndx[ 1 ]]) and #1 (== \b revNodal[ \b revNodalIndx[ 1 ] + 1 ]).
1026 - etc.
1027
1028 \anchor cpp_mcpointset_scale
1029 <br><h2> Scaling the mesh </h2>
1030
1031 First, we create a 2D mesh with 4 nodes and no cells.
1032 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_scale_1
1033 Then we scale it by a factor of 2 with a center (0.,0.).
1034 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_scale_2
1035 Finally we check that all node coordinates have changed by more than 0.9.
1036 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_scale_3
1037
1038
1039
1040
1041 \anchor cpp_mcpointset_translate
1042 <br><h2> Translating the mesh </h2>
1043
1044 First, we create a 2D mesh with 4 nodes and no cells.
1045 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_translate_1
1046 Then we translate it by a vector (1.,1.).
1047 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_translate_2
1048 Finally we check that all node coordinates have changed by more than 0.9.
1049 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_translate_3
1050
1051
1052
1053 \anchor cpp_mcpointset_rotate
1054 <br><h2> Rotating the mesh </h2>
1055
1056 First, we create a 2D mesh with 4 nodes and no cells.
1057 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_rotate_1
1058 Then we rotate it around a point (0.,0.) by 90 degrees clockwise.
1059 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_rotate_2
1060 Next, we make a 3D mesh from the 2D one and rotate it around the Z axis by 90 degrees
1061 counter-clockwise. 
1062 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_rotate_3
1063 Finally we transform the mesh back to 2D space and check that all nodes get back to the
1064 initial location.
1065 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_rotate_4
1066
1067 \anchor cpp_mcpointset_getBoundingBox
1068 <br><h2> Getting a minimum box bounding nodes </h2>
1069
1070 First, we create a 3D mesh with 2 nodes, so that the first one has minimal coordinates and
1071 the second one has maximal coordinates.
1072 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_getBoundingBox_1
1073 Now we get a bounding box enclosing these nodes. This bounding box should contain
1074 coordinates of our two nodes (but in "no interlace" mode), as the nodes coincide with
1075 points returned by the bounding box.
1076 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_getBoundingBox_2
1077
1078
1079 \anchor cpp_mcpointset_getnodeidsnearpoint
1080 <br><h2> Getting nodes close to a point </h2>
1081
1082 The following code creates a 2D \ref ParaMEDMEM::MEDCouplingUMesh
1083 "MEDCouplingUMesh" with 5 nodes and no cells.
1084 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_getNodeIdsNearPoint_1
1085 Now we define an array of coordinates of a point close to nodes #0, #2 and #4.
1086
1087 Thus we expect that 
1088 \ref ParaMEDMEM::MEDCouplingPointSet::getNodeIdsNearPoint "getNodeIdsNearPoint()" that
1089 we are going to use,
1090 if called with \b eps = 0.003, would return ids of nodes #0, #2 and #4.
1091 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_getNodeIdsNearPoint_2
1092
1093
1094 \anchor cpp_mcpointset_getnodeidsnearpoints
1095 <br><h2> Getting nodes close to some points </h2>
1096
1097 The following code creates a 2D \ref ParaMEDMEM::MEDCouplingUMesh
1098 "MEDCouplingUMesh" with 7 nodes and no cells.
1099 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_getNodeIdsNearPoints_1
1100 Now we define an array of coordinates of 3 points near which we want to find nodes of the mesh.
1101 - Point #0 is at distance 0.001 from the node #1.
1102 - Point #1 is rather far from all nodes.
1103 - Point #2 is close to nodes #3, #4 and #5.
1104
1105 Thus we expect that 
1106 \ref ParaMEDMEM::MEDCouplingPointSet::getNodeIdsNearPoints "getNodeIdsNearPoints()" that
1107 we are going to use,
1108 if called with \b eps = 0.003, would return ids of close nodes #1, #3, #4 and #5.
1109 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_getNodeIdsNearPoints_2
1110 \b idsIndex returns [0, 1, 1, 4] which means that:
1111 - Point #0 is close to 1 (== \b idsIndex[1] - \b idsIndex[0]) node whose id is 
1112 \b ids[ \b idsIndex[ 0 ]].
1113 - Point #1 is close to 0 (== \b idsIndex[2] - \b idsIndex[1]) nodes.
1114 - Point #2 is close to 3 (== \b idsIndex[3] - \b idsIndex[2]) nodes whose ids are
1115 \b ids[ \b idsIndex[ 2 ]], \b ids[ \b idsIndex[ 2 ] + 1 ] and \b ids[ \b idsIndex[ 2 ] + 2 ].
1116
1117
1118 \anchor cpp_mcpointset_findcommonnodes
1119 <br><h2> Finding coincident nodes </h2>
1120
1121 First, we create a mesh with 6 nodes, of which two nodes (#3 and #4) are fully coincident
1122 and 3 nodes (#0, #2 and #5) have distance less than 0.004 between them.
1123 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_findCommonNodes_1
1124 Then, we use \ref ParaMEDMEM::MEDCouplingPointSet::findCommonNodes() "findCommonNodes()" to find
1125 coincident nodes, and check that (1) calling 
1126 \ref ParaMEDMEM::MEDCouplingPointSet::findCommonNodes() "findCommonNodes()" with \b prec
1127 == 1e-13 finds the two fully coincident nodes only and (2)
1128 \ref ParaMEDMEM::MEDCouplingPointSet::findCommonNodes() "findCommonNodes"(0.004) finds 5
1129 equal nodes.
1130 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_findCommonNodes_2
1131
1132 \anchor cpp_mcpointset_getcoordinatesofnode
1133 <br><h2> Getting coordinates of a node </h2>
1134
1135 The following code creates a 2D \ref ParaMEDMEM::MEDCouplingUMesh
1136 "MEDCouplingUMesh" with 3 nodes and no cells.
1137 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_getCoordinatesOfNode_1
1138 Here we get coordinates of the second node and check its two coordinates.
1139 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_getCoordinatesOfNode_2
1140
1141 \anchor cpp_mcdataarrayint_getTuple
1142 <br><h2> Getting a tuple of DataArrayInt </h2>
1143
1144 In this simple example we create an array of integers arranged into 3
1145 tuples per 2 components, and finally print the second tuple.
1146 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_getTuple_1
1147 The output is
1148 <pre> [9, 10] </pre>
1149 Note that we can traverse all tuples in the array by simply iterating
1150 over it as the code below does.
1151 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_getTuple_2
1152 Its output follows.
1153 <pre>
1154 (7, 8)
1155 (9, 10)
1156 (11, 12)
1157 </pre>
1158
1159 \anchor cpp_mcdataarrayint_buildpermutationarr
1160 <br><h2> Building a permutation array </h2>
1161
1162 Here we create two arrays containing same values but in different order and then we use
1163 \ref ParaMEDMEM::DataArrayInt::buildPermutationArr "DataArrayInt::buildPermutationArr()" to get
1164 an array showing in what places the values of \b b array are located in \b a array.
1165 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayInt_buildPermutationArr_1
1166 The result array \b c contains [1,0,4,2,3].
1167
1168 <br><h2> Inverting renumbering maps </h2>
1169 \anchor cpp_mcdataarrayint_invertarrayo2n2n2o
1170 <h3> invertArrayO2N2N2O() </h3>
1171
1172 In this example we create a DataArrayInt containing a renumbering map in 
1173 "Old to New" mode, convert it into the renumbering map in "New to Old" mode and check the
1174 result.
1175 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayInt_invertArrayO2N2N2O_1
1176
1177 \anchor cpp_mcdataarrayint_invertarrayn2o2o2n
1178 <br><h3> invertArrayN2O2O2N() </h3>
1179
1180 In this example we create a DataArrayInt containing a renumbering map in 
1181 "New to Old" mode, convert it into the renumbering map in "Old to New" mode and check the
1182 result.
1183 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayInt_invertArrayN2O2O2N_1
1184
1185
1186
1187 \anchor cpp_mcdataarraydouble_getidsinrange
1188 <br><h2> Finding values in range in  DataArrayDouble</h2>
1189
1190 In this example we create an array \b da containing same values as ones returned by
1191 \c range( \c 10 ). Then we get an array of indices of values of \b da being in
1192 range [ 2.5, 6 ].
1193 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayDouble_getIdsInRange_1
1194 As result contents of the array \b da2 are as follows.
1195 <pre>
1196     Tuple #0 : 3
1197     Tuple #1 : 4
1198     Tuple #2 : 5
1199     Tuple #3 : 6
1200 </pre>
1201
1202
1203 \anchor py_mcdataarraydouble_setselectedcomponents
1204 <br><h2> Set part of values of DataArrayDouble </h2>
1205 <h3> setSelectedComponents() </h3>
1206 First, we create a 'source' array.
1207 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setSelectedComponents1
1208 Now we create a larger zero array and assign the array \b da into it.
1209 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setSelectedComponents2
1210 As result contents of the array \b dv are as follows.
1211 <pre>
1212 Info of components : "a2"   "a1"   "v3"   "v4"   
1213     Tuple #0 : 2 1 0 0 
1214     Tuple #1 : 4 3 0 0 
1215     Tuple #2 : 6 5 0 0 
1216     Tuple #3 : 0 0 0 0 
1217 </pre>
1218 The same result can be achieved other way (except that component info
1219 is not copied):
1220 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setSelectedComponents3
1221
1222 \anchor py_mcdataarraydouble_setpartofvalues1
1223 <br><h3> setPartOfValues1() </h3>
1224 We create two arrays: 
1225 - a "large" (4x4) zero array \b da to assign to and
1226 - a smaller (2x2) array \b dv filled with values [7.,8.,9.,10].
1227
1228 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_1
1229 Now we copy \b dv to the middle of \b da.
1230 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_2
1231 As result contents of the array \b da are as follows.
1232 <pre>
1233     Info of components :"v1"   "v2"   "v3"   "v4"
1234     Tuple #0 : 0 0 0 0 
1235     Tuple #1 : 0 7 8 0 
1236     Tuple #2 : 0 9 10 0 
1237     Tuple #3 : 0 0 0 0 
1238 </pre>
1239
1240 Here we re-fill \b da with zeros and copy \b dv into a component of \b da.
1241
1242 Note that the last parameter \b strictCompoCompare should be \c False
1243 in this case, else \ref ParaMEDMEM::DataArrayDouble::setPartOfValues1() 
1244 throws an exception because \b da has 2 components but only one target
1245 component is specified.
1246 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_3
1247 <pre>
1248     Tuple #0 : 0 7 0 0 
1249     Tuple #1 : 0 8 0 0 
1250     Tuple #2 : 0 9 0 0 
1251     Tuple #3 : 0 10 0 0 
1252 </pre>
1253 Below more two variants of location of target values are shown.
1254 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_4
1255 <pre>
1256     Tuple #0 : 0 0 0 0 
1257     Tuple #1 : 7 8 9 10 
1258     Tuple #2 : 0 0 0 0 
1259     Tuple #3 : 0 0 0 0 
1260 </pre>
1261
1262 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_5
1263 <pre>
1264     Tuple #0 : 0 7 0 8 
1265     Tuple #1 : 0 0 0 0 
1266     Tuple #2 : 0 9 0 10 
1267     Tuple #3 : 0 0 0 0 
1268 </pre>
1269 The same result can be achieved other way:
1270 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_6
1271
1272
1273
1274 \anchor py_mcdataarraydouble_setpartofvaluessimple1
1275 <br><h3> setPartOfValuesSimple1() </h3>
1276 We create an array (4x4) \b da to assign to and define a value \b dv to assign.
1277 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_1
1278 Now we assign \b dv to the middle of \b da.
1279 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_2
1280 As result contents of the array \b da are as follows.
1281 <pre>
1282     Tuple #0 : 0 0 0 0 
1283     Tuple #1 : 0 7 7 0 
1284     Tuple #2 : 0 7 7 0 
1285     Tuple #3 : 0 0 0 0 
1286 </pre>
1287
1288 Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
1289 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_3
1290 <pre>
1291     Tuple #0 : 0 7 0 0 
1292     Tuple #1 : 0 7 0 0 
1293     Tuple #2 : 0 7 0 0 
1294     Tuple #3 : 0 7 0 0 
1295 </pre>
1296 Below more two variants of location of target values are shown.
1297 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_4
1298 <pre>
1299     Tuple #0 : 0 0 0 0 
1300     Tuple #1 : 7 7 7 7 
1301     Tuple #2 : 0 0 0 0 
1302     Tuple #3 : 0 0 0 0 
1303 </pre>
1304
1305 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_5
1306 <pre>
1307     Tuple #0 : 0 7 0 7 
1308     Tuple #1 : 0 0 0 0 
1309     Tuple #2 : 0 7 0 7 
1310     Tuple #3 : 0 0 0 0 
1311 </pre>
1312 The same result can be achieved other way:
1313 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_6
1314
1315
1316 \anchor py_mcdataarraydouble_setpartofvaluessimple2
1317 <br><h3> setPartOfValuesSimple2() </h3>
1318 We create an array (4x4) \b da to assign to and define a value \b dv to assign.
1319 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple2_1
1320 Now we assign \b dv to the middle of \b da.
1321 We explicitly specify tuples and component to assign to by a list [1,2].
1322 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple2_2
1323 As result contents of the array \b da are as follows.
1324 <pre>
1325     Tuple #0 : 0 0 0 0 
1326     Tuple #1 : 0 7 7 0 
1327     Tuple #2 : 0 7 7 0 
1328     Tuple #3 : 0 0 0 0 
1329 </pre>
1330
1331 Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
1332 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple2_3
1333 <pre>
1334     Tuple #0 : 0 7 0 0 
1335     Tuple #1 : 0 7 0 0 
1336     Tuple #2 : 0 7 0 0 
1337     Tuple #3 : 0 7 0 0 
1338 </pre>
1339 Below more two variants of location of target values are shown.
1340 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple2_4
1341 <pre>
1342     Tuple #0 : 0 0 0 0 
1343     Tuple #1 : 7 7 7 7 
1344     Tuple #2 : 0 0 0 0 
1345     Tuple #3 : 0 0 0 0 
1346 </pre>
1347
1348 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple2_5
1349 <pre>
1350     Tuple #0 : 0 7 0 7 
1351     Tuple #1 : 0 0 0 0 
1352     Tuple #2 : 0 7 0 7 
1353     Tuple #3 : 0 0 0 0 
1354 </pre>
1355 \note \ref ParaMEDMEM::DataArrayDouble::setPartOfValuesSimple2() can't
1356 be explicitly called in Python.
1357
1358
1359 \anchor py_mcdataarraydouble_setpartofvaluessimple3
1360 <br><h3> setPartOfValuesSimple3() </h3>
1361 We create an array (4x4) \b da to assign to and define a value \b dv to assign.
1362 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple3_1
1363 Now we assign \b dv to the middle of \b da.
1364 We explicitly specify tuples to assign to by a list [1,2]. And we specify
1365 components to assign to using slicing: 1:3.
1366 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple3_2
1367 As result contents of the array \b da are as follows.
1368 <pre>
1369     Tuple #0 : 0 0 0 0 
1370     Tuple #1 : 0 7 7 0 
1371     Tuple #2 : 0 7 7 0 
1372     Tuple #3 : 0 0 0 0 
1373 </pre>
1374
1375 Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
1376 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple3_3
1377 <pre>
1378     Tuple #0 : 0 7 0 0 
1379     Tuple #1 : 0 7 0 0 
1380     Tuple #2 : 0 7 0 0 
1381     Tuple #3 : 0 7 0 0 
1382 </pre>
1383 Below more two variants of location of target values are shown.
1384 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple3_4
1385 <pre>
1386     Tuple #0 : 0 0 0 0 
1387     Tuple #1 : 7 7 7 7 
1388     Tuple #2 : 0 0 0 0 
1389     Tuple #3 : 0 0 0 0 
1390 </pre>
1391
1392 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple3_5
1393 <pre>
1394     Tuple #0 : 0 7 0 7 
1395     Tuple #1 : 0 0 0 0 
1396     Tuple #2 : 0 7 0 7 
1397     Tuple #3 : 0 0 0 0 
1398 </pre>
1399 \note \ref ParaMEDMEM::DataArrayDouble::setPartOfValuesSimple3() can't
1400 be explicitly called in Python.
1401
1402
1403 \anchor py_mcdataarraydouble_setpartofvalues2
1404 <br><h3> setPartOfValues2() </h3>
1405 We create two arrays: 
1406 - a "large" (4x7) zero array \b da to assign to,
1407 - a smaller (3x2) array \b dv filled with values [7.,8.,9.,10.,11.,12.].
1408
1409 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues2_1
1410 Now we assign the two components of \b dv to the components of \b da
1411 with indices [1,3], and the 3 tuples of \b dv to the 3 tuples of \b da with
1412   indices [0,1,2]. This is the first mode of usage.
1413 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues2_2
1414 As result contents of the array \b da are as follows.
1415 <pre>
1416     Tuple #0 : 0  7  0  8  0  0  0  
1417     Tuple #1 : 0  9  0 10  0  0  0 
1418     Tuple #2 : 0 11  0 12  0  0  0 
1419     Tuple #3 : 0  0  0  0  0  0  0
1420 </pre>
1421 Every value of \b dv has been assigned to its own location within \b da.
1422
1423 Now we re-fill \b da with zeros and rearrange \b dv to have 6 components.
1424 And we assign \b dv to the tuples of \b da with indices [0,2,3] .
1425 This is the second mode of usage.
1426 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues2_3
1427 The contents of \b dv have been assigned to each of specified tuples of \b da.
1428 Every value of \b dv is repeated in the 3 specified tuples within \b da.
1429 <pre>
1430     Tuple #0 : 7  0  8  9 10 11 12
1431     Tuple #1 : 0  0  0  0  0  0  0   
1432     Tuple #2 : 7  0  8  9 10 11 12
1433     Tuple #3 : 7  0  8  9 10 11 12
1434 </pre>
1435 \note \ref ParaMEDMEM::DataArrayDouble::setPartOfValues2() can't
1436 be explicitly called in Python.
1437
1438
1439 \anchor py_mcdataarraydouble_setpartofvalues3
1440 <br><h3> setPartOfValues3() </h3>
1441 We create two arrays: 
1442 - a "large" (4x7) zero array \b da to assign to,
1443 - a smaller (3x2) array \b dv filled with values [7.,8.,9.,10.,11.,12.].
1444
1445 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues3_1
1446 Now we assign the two components of \b dv to the components of \b da
1447 with indices [1,3], and the 3 tuples of \b dv to the 3 tuples of \b da with
1448 indices [0,1,2] which are specified using slicing: "0:3". 
1449 This is the first mode of usage.
1450 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues3_2
1451 As result contents of the array \b da are as follows.
1452 <pre>
1453     Tuple #0 : 0  7  0  8  0  0  0  
1454     Tuple #1 : 0  9  0 10  0  0  0 
1455     Tuple #2 : 0 11  0 12  0  0  0 
1456     Tuple #3 : 0  0  0  0  0  0  0
1457 </pre>
1458 Every value of \b dv has been assigned to its own location within \b da.
1459
1460 Now we re-fill \b da with zeros and rearrange \b dv to have 6 components.
1461 And we assign \b dv to the tuples of \b da with indices [0,2] using \a
1462 slice notation "0:4:2". This is the second mode of usage.
1463 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues3_3
1464 The contents of \b dv have been assigned to each of specified tuples of \b da.
1465 Every value of \b dv is repeated in the 3 specified tuples within \b da.
1466 <pre>
1467     Tuple #0 : 7  0  8  9 10 11 12
1468     Tuple #1 : 0  0  0  0  0  0  0   
1469     Tuple #2 : 7  0  8  9 10 11 12
1470     Tuple #3 : 0  0  0  0  0  0  0   
1471 </pre>
1472 \note \ref ParaMEDMEM::DataArrayDouble::setPartOfValues3() can't
1473 be explicitly called in Python.
1474
1475
1476 \anchor py_mcdataarrayint_setselectedcomponents
1477 <br><h2> Set part of values of DataArrayInt </h2>
1478 <h3> setSelectedComponents() </h3>
1479 First, we create a 'source' array.
1480 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setSelectedComponents1
1481 Now we create a larger zero array and assign the array \b da to it.
1482 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setSelectedComponents2
1483 As result contents of the array \b dv are as follows.
1484 <pre>
1485 Info of components : "a2"   "a1"   "v3"   "v4"   
1486     Tuple #0 : 2 1 0 0 
1487     Tuple #1 : 4 3 0 0 
1488     Tuple #2 : 6 5 0 0 
1489     Tuple #3 : 0 0 0 0 
1490 </pre>
1491 The same result can be achieved other way (except that component info
1492 is not copied):
1493 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setSelectedComponents3
1494
1495 \anchor py_mcdataarrayint_setpartofvalues1
1496 <br><h3> setPartOfValues1() </h3>
1497 We create two arrays: 
1498 - a "large" (4x4) zero array \b da to assign to, and
1499 - a smaller (2x2) array \b dv filled with values [7,8,9,10].
1500
1501 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_1
1502 Now we copy \b dv to the middle of \b da.
1503 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_2
1504 As result contents of the array \b da are as follows.
1505 <pre>
1506     Info of components :"v1"   "v2"   "v3"   "v4"
1507     Tuple #0 : 0 0 0 0 
1508     Tuple #1 : 0 7 8 0 
1509     Tuple #2 : 0 9 10 0 
1510     Tuple #3 : 0 0 0 0 
1511 </pre>
1512
1513 Here we re-fill \b da with zeros and copy \b dv into a component of \b da.
1514
1515 Note that the last parameter \b strictCompoCompare should be \c False
1516 in this case, else \ref ParaMEDMEM::DataArrayInt::setPartOfValues1() 
1517 throws an exception because \b da has 2 components but only one target
1518 component is specified.
1519 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_3
1520 <pre>
1521     Tuple #0 : 0 7 0 0 
1522     Tuple #1 : 0 8 0 0 
1523     Tuple #2 : 0 9 0 0 
1524     Tuple #3 : 0 10 0 0 
1525 </pre>
1526 Below more two variants of location of target values are shown.
1527 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_4
1528 <pre>
1529     Tuple #0 : 0 0 0 0 
1530     Tuple #1 : 7 8 9 10 
1531     Tuple #2 : 0 0 0 0 
1532     Tuple #3 : 0 0 0 0 
1533 </pre>
1534
1535 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_5
1536 <pre>
1537     Tuple #0 : 0 7 0 8 
1538     Tuple #1 : 0 0 0 0 
1539     Tuple #2 : 0 9 0 10 
1540     Tuple #3 : 0 0 0 0 
1541 </pre>
1542 The same result can be achieved other way:
1543 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_6
1544
1545
1546
1547 \anchor py_mcdataarrayint_setpartofvaluessimple1
1548 <br><h3> setPartOfValuesSimple1() </h3>
1549 We create an array (4x4) \b da to assign to and define a value \b dv to assign.
1550 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_1
1551 Now we assign \b dv to the middle of \b da.
1552 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_2
1553 As result contents of the array \b da are as follows.
1554 <pre>
1555     Tuple #0 : 0 0 0 0 
1556     Tuple #1 : 0 7 7 0 
1557     Tuple #2 : 0 7 7 0 
1558     Tuple #3 : 0 0 0 0 
1559 </pre>
1560
1561 Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
1562 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_3
1563 <pre>
1564     Tuple #0 : 0 7 0 0 
1565     Tuple #1 : 0 7 0 0 
1566     Tuple #2 : 0 7 0 0 
1567     Tuple #3 : 0 7 0 0 
1568 </pre>
1569 Below more two variants of location of target values are shown.
1570 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_4
1571 <pre>
1572     Tuple #0 : 0 0 0 0 
1573     Tuple #1 : 7 7 7 7 
1574     Tuple #2 : 0 0 0 0 
1575     Tuple #3 : 0 0 0 0 
1576 </pre>
1577
1578 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_5
1579 <pre>
1580     Tuple #0 : 0 7 0 7 
1581     Tuple #1 : 0 0 0 0 
1582     Tuple #2 : 0 7 0 7 
1583     Tuple #3 : 0 0 0 0 
1584 </pre>
1585 The same result can be achieved other way:
1586 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_6
1587
1588
1589 \anchor py_mcdataarrayint_setpartofvaluessimple2
1590 <br><h3> setPartOfValuesSimple2() </h3>
1591 We create an array (4x4) \b da to assign to and define a value \b dv to assign.
1592 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple2_1
1593 Now we assign \b dv to the middle of \b da.
1594 We explicitly specify tuples and component to assign to by a list [1,2].
1595 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple2_2
1596 As result contents of the array \b da are as follows.
1597 <pre>
1598     Tuple #0 : 0 0 0 0 
1599     Tuple #1 : 0 7 7 0 
1600     Tuple #2 : 0 7 7 0 
1601     Tuple #3 : 0 0 0 0 
1602 </pre>
1603
1604 Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
1605 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple2_3
1606 <pre>
1607     Tuple #0 : 0 7 0 0 
1608     Tuple #1 : 0 7 0 0 
1609     Tuple #2 : 0 7 0 0 
1610     Tuple #3 : 0 7 0 0 
1611 </pre>
1612 Below more two variants of location of target values are shown.
1613 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple2_4
1614 <pre>
1615     Tuple #0 : 0 0 0 0 
1616     Tuple #1 : 7 7 7 7 
1617     Tuple #2 : 0 0 0 0 
1618     Tuple #3 : 0 0 0 0 
1619 </pre>
1620
1621 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple2_5
1622 <pre>
1623     Tuple #0 : 0 7 0 7 
1624     Tuple #1 : 0 0 0 0 
1625     Tuple #2 : 0 7 0 7 
1626     Tuple #3 : 0 0 0 0 
1627 </pre>
1628 \note \ref ParaMEDMEM::DataArrayInt::setPartOfValuesSimple2() can't
1629 be explicitly called in Python.
1630
1631
1632 \anchor py_mcdataarrayint_setpartofvaluessimple3
1633 <br><h3> setPartOfValuesSimple3() </h3>
1634 We create an array (4x4) \b da to assign to and define a value \b dv to assign.
1635 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple3_1
1636 Now we assign \b dv to the middle of \b da.
1637 We explicitly specify tuples to assign to by a list [1,2]. And we specify
1638 components to assign to using slicing: 1:3.
1639 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple3_2
1640 As result contents of the array \b da are as follows.
1641 <pre>
1642     Tuple #0 : 0 0 0 0 
1643     Tuple #1 : 0 7 7 0 
1644     Tuple #2 : 0 7 7 0 
1645     Tuple #3 : 0 0 0 0 
1646 </pre>
1647
1648 Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
1649 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple3_3
1650 <pre>
1651     Tuple #0 : 0 7 0 0 
1652     Tuple #1 : 0 7 0 0 
1653     Tuple #2 : 0 7 0 0 
1654     Tuple #3 : 0 7 0 0 
1655 </pre>
1656 Below more two variants of location of target values are shown.
1657 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple3_4
1658 <pre>
1659     Tuple #0 : 0 0 0 0 
1660     Tuple #1 : 7 7 7 7 
1661     Tuple #2 : 0 0 0 0 
1662     Tuple #3 : 0 0 0 0 
1663 </pre>
1664
1665 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple3_5
1666 <pre>
1667     Tuple #0 : 0 7 0 7 
1668     Tuple #1 : 0 0 0 0 
1669     Tuple #2 : 0 7 0 7 
1670     Tuple #3 : 0 0 0 0 
1671 </pre>
1672 \note \ref ParaMEDMEM::DataArrayInt::setPartOfValuesSimple3() can't
1673 be explicitly called in Python.
1674
1675
1676 \anchor py_mcdataarrayint_setpartofvalues2
1677 <br><h3> setPartOfValues2() </h3>
1678 We create two arrays: 
1679 - a "large" (4x7) zero array \b da to assign to,
1680 - a smaller (3x2) array \b dv filled with values [7,8,9,10,11,12].
1681
1682 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues2_1
1683 Now we assign the two components of \b dv to the components of \b da
1684 with indices [1,3], and the 3 tuples of \b dv to the 3 tuples of \b da with
1685   indices [0,1,2]. This is the first mode of usage.
1686 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues2_2
1687 As result contents of the array \b da are as follows.
1688 <pre>
1689     Tuple #0 : 0  7  0  8  0  0  0  
1690     Tuple #1 : 0  9  0 10  0  0  0 
1691     Tuple #2 : 0 11  0 12  0  0  0 
1692     Tuple #3 : 0  0  0  0  0  0  0
1693 </pre>
1694 Every value of \b dv has been assigned to its own location within \b da.
1695
1696 Now we re-fill \b da with zeros and rearrange \b dv to have 6 components.
1697 And we assign \b dv to the tuples of \b da with indices [0,2,3] .
1698 This is the second mode of usage.
1699 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues2_3
1700 The contents of \b dv have been assigned to each of specified tuples of \b da.
1701 Every value of \b dv is repeated in the 3 specified tuples within \b da.
1702 <pre>
1703     Tuple #0 : 7  0  8  9 10 11 12
1704     Tuple #1 : 0  0  0  0  0  0  0   
1705     Tuple #2 : 7  0  8  9 10 11 12
1706     Tuple #3 : 7  0  8  9 10 11 12
1707 </pre>
1708 \note \ref ParaMEDMEM::DataArrayInt::setPartOfValues2() can't
1709 be explicitly called in Python.
1710
1711
1712 \anchor py_mcdataarrayint_setpartofvalues3
1713 <br><h3> setPartOfValues3() </h3>
1714 We create two arrays: 
1715 - a "large" (4x7) zero array \b da to assign to,
1716 - a smaller (3x2) array \b dv filled with values [7,8,9,10,11,12].
1717
1718 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues3_1
1719 Now we assign the two components of \b dv to the components of \b da
1720 with indices [1,3], and the 3 tuples of \b dv to the 3 tuples of \b da with
1721 indices [0,1,2] which are specified using slicing: "0:3". 
1722 This is the first mode of usage.
1723 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues3_2
1724 As result contents of the array \b da are as follows.
1725 <pre>
1726     Tuple #0 : 0  7  0  8  0  0  0  
1727     Tuple #1 : 0  9  0 10  0  0  0 
1728     Tuple #2 : 0 11  0 12  0  0  0 
1729     Tuple #3 : 0  0  0  0  0  0  0
1730 </pre>
1731 Every value of \b dv has been assigned to its own location within \b da.
1732
1733 Now we re-fill \b da with zeros and rearrange \b dv to have 6 components.
1734 And we assign \b dv to the tuples of \b da with indices [0,2] using \a
1735 slice notation "0:4:2". This is the second mode of usage.
1736 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues3_3
1737 The contents of \b dv have been assigned to each of specified tuples of \b da.
1738 Every value of \b dv is repeated in the 3 specified tuples within \b da.
1739 <pre>
1740     Tuple #0 : 7  0  8  9 10 11 12
1741     Tuple #1 : 0  0  0  0  0  0  0   
1742     Tuple #2 : 7  0  8  9 10 11 12
1743     Tuple #3 : 0  0  0  0  0  0  0   
1744 </pre>
1745 \note \ref ParaMEDMEM::DataArrayInt::setPartOfValues3() can't
1746 be explicitly called in Python.
1747
1748
1749 \anchor py_mcdataarraydouble_getdifferentvalues
1750 <br><h2> Excluding coincident tuples from DataArrayDouble</h2>
1751
1752 The code below creates an array of real values and than an array of
1753   unique values, not closer one to another than 0.2, is retrieved from it.
1754 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_getDifferentValues1
1755
1756
1757 \anchor cpp_mcdataarraydouble_findcommontuples
1758 <br><h2> Finding coincident tuples in DataArrayDouble</h2>
1759
1760 Let's create an array of 6 tuples and 2 components that can be
1761   considered as coordinates of 6 points in 2D space.
1762 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayDouble_findCommonTuples1
1763 Now we find points that are not far each from other than 1e-1.
1764 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayDouble_findCommonTuples2
1765 As we can realize from the above code, a hardcoded array \b expected3 is equal
1766   to the raw data of a DataArrayInt \b c and a hardcoded array \b expected4 is equal
1767   to the raw data of the DataArrayInt \b cI.
1768
1769 The array \b c contains indices of 5 coincident points. The array \b
1770   cI shows us boundaries of (cI->getNumberOfTuples()-1) = 2 groups of coincident points: 
1771 - The first group starts at index 0 and includes (3 - 0) = 3 points: 0,3,4.
1772 - The second group starts at index 3 and includes (5 - 3) = 2 points: 1,2.
1773
1774 \anchor cpp_mcdataarraydouble_meldwith
1775 <br><h2> Concatenating DataArrayDouble's by appending components </h2>
1776
1777 In this example we create two data arrays including \b same number of
1778 tuples and then we concatenate them using \ref
1779 ParaMEDMEM::DataArrayDouble::meldWith "meldWith()".
1780 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayDouble_Meld1_1
1781 Now the array \b da1 includes 7 tuples (as before) of 3 components
1782 each. Its components are: "c0da1","c1da1","c0da2".
1783
1784
1785 \anchor cpp_mcdataarrayint_meldwith
1786 <br><h2> Concatenating DataArrayInt's by appending components </h2>
1787
1788 In this example we create two data arrays including \b same number of
1789 tuples and then we concatenate them using \ref
1790 ParaMEDMEM::DataArrayInt::meldWith "meldWith()".
1791 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayInt_Meld1_1
1792 Now the array \b da1 includes 7 tuples (as before) of 3 components
1793 each. Its components are: "c0da1","c1da1","c0da2".
1794
1795
1796 \anchor py_mcdataarraydouble_KeepSelectedComponents
1797
1798 <br><h2>Creation of a sub-part of the DataArrayDouble by selecting components</h2>
1799
1800 \snippet MEDCouplingExamplesTest.py SnippeDataArrayDoubleKeepSelectedComponents1_1
1801 We created an array \b a1 containing 5 tuples of 4 components each (20
1802 values). Now we are going to create an array \b a2 containing some
1803 components of \b a1.
1804 \snippet MEDCouplingExamplesTest.py SnippeDataArrayDoubleKeepSelectedComponents1_2
1805 Now each tuple of \b a2 includes components named "b","c","b","c","a","a". Thus
1806 the result array \b a2 includes 30 elements (5 tuples per 6 components).
1807
1808
1809 \anchor py_mcdataarrayint_keepselectedcomponents
1810
1811 <br><h2>Creation of a sub-part of the DataArrayInt by selecting components</h2>
1812
1813 \snippet MEDCouplingExamplesTest.py SnippeDataArrayIntKeepSelectedComponents1_1
1814 We created an array \b a1 containing 5 tuples of 4 components each (20
1815 values). Now we are going to create an array \b a2 containing some
1816 components of \b a1.
1817 \snippet MEDCouplingExamplesTest.py SnippeDataArrayIntKeepSelectedComponents1_2
1818 Now each tuple of \b a2 includes components named "b","c","b","c","a","a". Thus
1819 the result array \b a2 includes 30 elements (5 tuples per 6 components).
1820
1821 Note that
1822 \ref ParaMEDMEM::DataArrayInt::keepSelectedComponents() "DataArrayInt::keepSelectedComponents()" 
1823 is called, providing the same result, by the following python code:
1824 \snippet MEDCouplingExamplesTest.py SnippeDataArrayIntKeepSelectedComponents1_3
1825
1826 \anchor cpp_mcfielddouble_subpart1
1827
1828
1829 <br><h2>Creation of a sub part of a field</h2>
1830 <br><h3>Creation of a sub part of a field on cells</h3>
1831 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuildSubPart1_1
1832 The field on cells \b f1 lies on a mesh containing 5 cells and 9 nodes.         
1833 So this field \b f1 contains 5 tuples of 2 components each (10 values).
1834 Now let's create a subfield on cells \b f2 from \b f1.
1835 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuildSubPart1_2
1836
1837 \b f1 is a field on cells, \ref ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart "buildSubPart" method performs an extraction on cells too.
1838
1839 So the array \b part1 lists ids on cells.
1840
1841 - cell #0 of \b f2 is the same cell of cell #2 of \b f1
1842 - cell #1 of \b f2 is the same cell of cell #1 of \b f1
1843 - cell #2 of \b f2 is the same cell of cell #4 of \b f1
1844
1845 So \b f2 contains 3 tuples with 2 components.
1846
1847 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).
1848 \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).
1849 \nOnly fields on cells have this particular behaviour.
1850
1851 <br><h3>Creation of a sub part of a field on nodes</h3>
1852 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuildSubPart1_3
1853 The field on nodes \b f1 lies on a mesh containing 5 cells and 9 nodes.
1854 So this field \b f1 contains 9 tuples of 2 components each (18 values).
1855 Now let's create a subfield on nodes \b f2 from \b f1.
1856 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuildSubPart1_4
1857
1858 \b f1 is a field on nodes, but \ref ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart "buildSubPart" method performs an extraction on \b cells.
1859
1860 After the call of \ref ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart "buildSubPart" on node field \b f1, \b f1 will be reduced on a
1861 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.
1862 \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" 
1863 method does not match the size of the input array (here \b part2).
1864
1865 */
1866
1867 /*!
1868 \page medcouplingcppexamplesUmeshStdBuild1 <br><h1> Example of standard build of an unstructured mesh from scratch in C++ </h1>
1869
1870 Firstly retrieve basic data in full interlace mode for coordinates, and nodal connectivity cell per cell.
1871 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_1
1872
1873 Then create ParaMEDMEM::MEDCouplingUMesh instance giving its meshdimension (2 here) and a name.
1874
1875 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_2
1876
1877 Gives an upper bound of the number of cells to be inserted into the unstructured mesh.
1878 \n Then enter nodal connectivity of all cells, cell per cell using ParaMEDMEM::MEDCouplingUMesh::insertNextCell method.
1879 \n When the nodal connectivity cell per cell has been finished, call ParaMEDMEM::MEDCouplingUMesh::finishInsertingCells method in order to restore \b mesh instance.
1880
1881 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_3
1882
1883 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.
1884
1885 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_4
1886
1887 At this level mesh is usable. When this mesh is no more needed simply call decrRef to decrement its reference counter.
1888
1889 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_5
1890
1891 */
1892
1893 /*!
1894 \page medcouplingcppexamplesUmeshAdvBuild1 <br><h1> Example of advanced build of an unstructured mesh from scratch in C++ </h1>
1895
1896 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).
1897 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_1
1898
1899 Then create ParaMEDMEM::MEDCouplingUMesh instance giving its meshdimension (2 here) and a name.
1900
1901 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_2
1902
1903 Then enter nodal connectivity at once.
1904
1905 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_3
1906
1907 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.
1908
1909 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_4
1910
1911 At this level mesh is usable. When this mesh is no more needed simply call decrRef() to decrement its reference counter.
1912
1913 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_5
1914
1915 */
1916
1917 /*!
1918 \page medcouplingcppexamplesCmeshStdBuild1 <br><h1> Example of standard build of an cartesian mesh from scratch in C++ </h1>
1919
1920 We are going to build a 2D cartesian mesh, constituted from 9 nodes along X axis, and 7 nodes along Y axis.
1921
1922 Firstly retrieve for each direction the discretization and build a \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble instance" on the corresponding direction.
1923
1924 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_1
1925
1926 Then create ParaMEDMEM::MEDCouplingCMesh instance giving the 2 instances of \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble" obtained above.
1927
1928 There are 2 techniques to get it.
1929
1930 Either :
1931
1932 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_2
1933
1934 Or :
1935
1936 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_2bis
1937
1938 \c mesh is now available for use :
1939
1940 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_3
1941
1942 When this mesh is no more needed simply call decrRef to decrement its reference counter.
1943
1944 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_4
1945
1946 */
1947
1948 /*!
1949 \page medcouplingcppexamplesFieldDoubleBuild1 <br><h1> Examples in C++ of standard build of a tensor field on cells with no time attached  </h1>
1950
1951 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild1_1
1952
1953 */
1954
1955 /*!
1956 \page medcouplingcppexamplesFieldDoubleBuild2 <br><h1> Examples in C++ of standard build of a scalar field on nodes with no time attached </h1>
1957
1958 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild2_1
1959
1960 */
1961
1962 /*!
1963 \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>
1964
1965 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild3_1
1966
1967 */
1968
1969 /*!
1970 \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>
1971
1972 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild4_1
1973
1974 */
1975
1976 /*!
1977 \page medcouplingcppexamplesFieldDoubleBuild5 <br><h1> Examples in C++ of operation that can be carried out on fields on cells </h1>
1978
1979 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild1_2
1980
1981 The decrementation of ref counter should be carried out in CPlusPlus only ...
1982
1983 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild1_3
1984
1985 */