2 \page medcouplingcppexamples MEDCoupling C++ examples
5 \anchor cpp_mcfielddouble_WriteVTK
6 <br><h2> Writting fields in a VTK file </h2>
9 - create an 2D mesh and 3 fields on it,
11 \ref ParaMEDMEM::MEDCouplingFieldDouble::WriteVTK "WriteVTK()"
12 to write all the fields and the mesh to a VTK file.
14 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_WriteVTK_1
18 \anchor cpp_mcfielddouble_MaxFields
19 <br><h2> Getting maximal and minimal fields </h2>
22 - create two fields with two tuples per two components,
24 \ref ParaMEDMEM::MEDCouplingFieldDouble::MaxFields "MaxFields()"
25 to get a field holding maximal values of the two fields.
27 \ref ParaMEDMEM::MEDCouplingFieldDouble::MinFields "MinFields()"
28 to get a field holding minimal values of the two fields.
30 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_MaxFields_1
33 \anchor cpp_mcfielddouble_MergeFields
34 <br><h2> Concatenating fields</h2>
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,
41 \ref ParaMEDMEM::MEDCouplingFieldDouble::MergeFields "MergeFields()"
42 to create one field from the two by concatenating them and their meshes.
44 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_MergeFields_1
45 The result field is twice "longer" than \b field1.
49 \anchor cpp_mcfielddouble_substractInPlaceDM
50 <br><h2> Subtracting field on different meshs </h2>
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
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
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
73 \anchor cpp_mcfielddouble_changeUnderlyingMesh
74 <br><h2> Changing the underlying mesh </h2>
76 We make two meshes in 1D space with no cells and 4 nodes. Nodes #0 and #2 are swapped
78 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_changeUnderlyingMesh_1
80 \ref ParaMEDMEM::MEDCouplingFieldDouble::changeUnderlyingMesh "changeUnderlyingMesh()"
81 to set \b mesh2 instead of \b mesh1 as a support of a field. <br>
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.
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
92 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_changeUnderlyingMesh_2
95 \anchor cpp_mcfielddouble_applyFunc_same_nb_comp
96 <br><h2> Changing a field using a formular </h2>
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".
106 In addition we want to add 10.0 to each component computed as described above, hence
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
114 \anchor cpp_mcfielddouble_applyFunc3
115 <br><h2> Changing a field using a formular </h2>
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
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 )".
129 In addition we want to add 10.0 to each component computed as described above, hence
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
134 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_applyFunc3_2
138 \anchor cpp_mcfielddouble_applyFunc2
139 <br><h2> Changing a field using a formular </h2>
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
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
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 )".
155 In addition we want to add 10.0 to each component computed as described above, hence
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
160 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_applyFunc2_2
164 \anchor cpp_mcfielddouble_applyFunc
165 <br><h2> Changing a field using a formular </h2>
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
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
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 )".
179 In addition we want to add 10.0 to each component computed as described above, hence
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
184 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingFieldDouble_applyFunc_2
188 \anchor cpp_mcfielddouble_applyFunc_val
189 <br><h2> Filling a field with a value</h2>
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
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.
202 \anchor cpp_mcfielddouble_fillFromAnalytic3
203 <br><h2> Filling a field using a formular </h2>
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()"
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
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 )".
220 In addition we want to add 10.0 to each component computed as described above, hence
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
230 \anchor cpp_mcfielddouble_fillFromAnalytic2
231 <br><h2> Filling a field using a formular </h2>
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()"
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
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 )".
250 In addition we want to add 10.0 to each component computed as described above, hence
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
259 \anchor cpp_mcfielddouble_fillFromAnalytic
260 <br><h2> Filling a field using a formular </h2>
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()"
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
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 )".
277 In addition we want to add 10.0 to each component computed as described above, hence
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
286 \anchor cpp_mcfielddouble_getValueOn_time
287 <br><h2> Getting a field value at some point at certain time</h2>
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
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
303 \anchor cpp_mcfielddouble_getValueOnMulti
304 <br><h2> Getting field values at some points</h2>
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
321 \anchor cpp_mcfielddouble_getValueOn
322 <br><h2> Getting a field value at a point</h2>
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
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
340 \anchor cpp_mcfielddouble_getValueOnPos
341 <br><h2> Getting a value of field lying on a structured mesh</h2>
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
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.
359 \anchor cpp_mcfielddouble_renumberNodes
360 <br><h2> Permuting a field on nodes</h2>
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
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
379 And the field values are still equal to node coordinates of the renumbered \b mesh2.
383 \anchor cpp_mcfielddouble_renumberCells
384 <br><h2> Permuting a field on cells</h2>
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
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
403 And the field values are still equal to cell barycenters of the renumbered \b mesh2.
407 \anchor cpp_mcfielddouble_buildNewTimeReprFromThis
408 <br><h2> Getting a field copy with different time discretization </h2>
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
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
422 \anchor cpp_mcmesh_fillFromAnalytic3
423 <br><h2> Creating a field using a formular </h2>
425 First, we create a 2D Cartesian mesh constituted by 2 cells.
426 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingMesh_fillFromAnalytic3_1
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
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 )".
440 In addition we want to add 10.0 to each component computed as described above, hence
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
450 \anchor cpp_mcmesh_fillFromAnalytic2
451 <br><h2> Creating a field using a formular </h2>
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
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
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 )".
470 In addition we want to add 10.0 to each component computed as described above, hence
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
479 \anchor cpp_mcmesh_fillFromAnalytic
480 <br><h2> Creating a field using a formular </h2>
482 First, we create a 2D Cartesian mesh constituted by 2 cells.
483 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingMesh_fillFromAnalytic_1
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
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 )".
497 In addition we want to add 10.0 to each component computed as described above, hence
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
506 \anchor cpp_mccmesh_getCoordsAt
507 <br><h2> Getting node coordinates </h2>
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
515 \anchor cpp_mcumesh_areCellsIncludedIn
516 <br><h2> Cells correspondence in two meshes </h2>
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
530 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_areCellsIncludedIn_3
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.
544 \anchor cpp_mcumesh_checkDeepEquivalWith
545 <br><h2> Deep comparison of meshes </h2>
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.
552 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_checkDeepEquivalWith_1
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.
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
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
572 \anchor cpp_mcumesh_getPartBarycenterAndOwner
573 <br><h2> Getting barycenters of cells </h2>
575 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
576 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getPartMeasureField_1
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.
584 \anchor cpp_mcumesh_findAndCorrectBadOriented3DExtrudedCells
585 <br><h2> Fixing orientation of "extruded" volumes </h2>
587 First, we create a mesh with 2 incorrectly oriented "extruded" volumes.
588 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_findAndCorrectBadOriented3DExtrudedCells_1
590 \ref ParaMEDMEM::MEDCouplingUMesh::findAndCorrectBadOriented3DExtrudedCells "findAndCorrectBadOriented3DExtrudedCells()"
591 finds and fixes the reversed cells.
592 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_findAndCorrectBadOriented3DExtrudedCells_2
595 \anchor cpp_mcumesh_arePolyhedronsNotCorrectlyOriented
596 <br><h2> Fixing orientation of polyhedra </h2>
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
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
609 \anchor cpp_mcumesh_are2DCellsNotCorrectlyOriented
610 <br><h2> Fixing orientation of faces </h2>
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
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
623 \anchor cpp_mcumesh_getCellsContainingPoints
624 <br><h2> Finding cells containing a point (multi-point case) </h2>
626 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
627 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getCellsContainingPoints_1
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])
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 ]).
641 \anchor cpp_mcumesh_getCellsContainingPoint
642 <br><h2> Finding cells containing a point </h2>
644 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
645 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getCellsContainingPoint_1
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.
654 \anchor cpp_mcumesh_buildPartOrthogonalField
655 <br><h2> Getting normals of cells </h2>
657 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells. Orientation of the cell #1 is
659 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildPartOrthogonalField_1
661 \ref ParaMEDMEM::MEDCouplingUMesh::buildPartOrthogonalField "buildPartOrthogonalField()" to get
662 normal vectors to the cells.
663 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildPartOrthogonalField_2
667 \anchor cpp_mcumesh_getPartMeasureField
668 <br><h2> Getting volumes of cells </h2>
670 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells. Orientation of the cell #1 is
672 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getPartMeasureField_1
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
683 \anchor cpp_mcumesh_getCellsInBoundingBox
684 <br><h2> Getting cells using the bounding box </h2>
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
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>
700 \anchor cpp_mcumesh_renumberNodesInConn
701 <br><h2> Renumbering nodes in the connectivity array </h2>
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
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.
716 \anchor cpp_mcumesh_renumberNodes
717 <br><h2> Renumbering nodes </h2>
719 First, we create a 2D mesh with 4 nodes and no cells.
720 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_renumberNodes_1
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.
729 Number of nodes becomes 3.
730 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_renumberNodes_2
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
743 \anchor cpp_mcumesh_findBoundaryNodes
744 <br><h2> Getting boundary nodes </h2>
746 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
747 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_findBoundaryNodes_1
749 \ref ParaMEDMEM::MEDCouplingUMesh::findBoundaryNodes "findBoundaryNodes()" to get ids
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.
756 \anchor cpp_mcumesh_buildBoundaryMesh
757 <br><h2> Getting a bounding mesh </h2>
759 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
760 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildBoundaryMesh_1
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.
770 \anchor cpp_mcumesh_buildFacePartOfMySelfNode
771 <br><h2> Retrieving a lower dimension mesh based on given nodes </h2>
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.
787 \anchor cpp_mcumesh_buildPartOfMySelfNode
788 <br><h2> Copying cells selected by nodes </h2>
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.
805 \anchor cpp_mcumesh_getCellIdsLyingOnNodes
806 <br><h2> Getting cells by nodes </h2>
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.
824 \anchor cpp_mcumesh_getCellIdsFullyIncludedInNodeIds
825 <br><h2> Getting cells by nodes </h2>
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
835 \anchor cpp_mcumesh_buildPartOfMySelf
836 <br><h2> Getting a part of mesh </h2>
838 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
839 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildPartOfMySelf_1
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
846 \anchor cpp_mcumesh_mergeNodes
847 <br><h2> Merging equal nodes </h2>
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.
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>
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
875 \anchor cpp_mcumesh_zipConnectivityTraducer
876 <br><h2> Removing cell duplicates </h2>
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.
883 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_zipConnectivityTraducer_1
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
897 \ref ParaMEDMEM::MEDCouplingUMesh::zipConnectivityTraducer "zipConnectivityTraducer()"
898 was 0 ("exact"), if we had used the technique 2 ("nodal"), \b arr[4] would be 0.
902 \anchor cpp_mcumesh_zipCoordsTraducer
903 <br><h2> Removing unused nodes </h2>
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
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
916 \anchor cpp_mcumesh_getNodeIdsInUse
917 <br><h2> Retrieving unused nodes </h2>
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
933 \anchor cpp_mcumesh_convertToPolyTypes
934 <br><h2> Conversion of cells to "poly" types </h2>
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
942 \anchor cpp_mcumesh_buildDescendingConnectivity2
943 <br><h2> Retrieving the descending connectivity with orientation </h2>
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].
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
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
976 - # 0 (== \b revDesc[ \b revDescIndx[ 1 ]]) and
977 - # 1 (== \b revDesc[ \b revDescIndx[ 1 ] + 1 ]).
982 \anchor cpp_mcumesh_buildDescendingConnectivity
983 <br><h2> Retrieving the descending connectivity </h2>
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 ]).
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
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
1009 - # 0 (== \b revDesc[ \b revDescIndx[ 1 ]]) and
1010 - # 1 (== \b revDesc[ \b revDescIndx[ 1 ] + 1 ]).
1014 \anchor cpp_mcumesh_getReverseNodalConnectivity
1015 <br><h2> Getting the reverse nodal connectivity </h2>
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 ]).
1028 \anchor cpp_mcpointset_scale
1029 <br><h2> Scaling the mesh </h2>
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
1041 \anchor cpp_mcpointset_translate
1042 <br><h2> Translating the mesh </h2>
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
1053 \anchor cpp_mcpointset_rotate
1054 <br><h2> Rotating the mesh </h2>
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
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
1065 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_rotate_4
1067 \anchor cpp_mcpointset_getBoundingBox
1068 <br><h2> Getting a minimum box bounding nodes </h2>
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
1079 \anchor cpp_mcpointset_getnodeidsnearpoint
1080 <br><h2> Getting nodes close to a point </h2>
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.
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
1094 \anchor cpp_mcpointset_getnodeidsnearpoints
1095 <br><h2> Getting nodes close to some points </h2>
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.
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 ].
1118 \anchor cpp_mcpointset_findcommonnodes
1119 <br><h2> Finding coincident nodes </h2>
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
1130 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_findCommonNodes_2
1132 \anchor cpp_mcpointset_getcoordinatesofnode
1133 <br><h2> Getting coordinates of a node </h2>
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
1141 \anchor cpp_mcdataarrayint_getTuple
1142 <br><h2> Getting a tuple of DataArrayInt </h2>
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
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
1159 \anchor cpp_mcdataarrayint_buildpermutationarr
1160 <br><h2> Building a permutation array </h2>
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].
1168 <br><h2> Inverting renumbering maps </h2>
1169 \anchor cpp_mcdataarrayint_invertarrayo2n2n2o
1170 <h3> invertArrayO2N2N2O() </h3>
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
1175 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayInt_invertArrayO2N2N2O_1
1177 \anchor cpp_mcdataarrayint_invertarrayn2o2o2n
1178 <br><h3> invertArrayN2O2O2N() </h3>
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
1183 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayInt_invertArrayN2O2O2N_1
1187 \anchor cpp_mcdataarraydouble_getidsinrange
1188 <br><h2> Finding values in range in DataArrayDouble</h2>
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
1193 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayDouble_getIdsInRange_1
1194 As result contents of the array \b da2 are as follows.
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.
1212 Info of components : "a2" "a1" "v3" "v4"
1218 The same result can be achieved other way (except that component info
1220 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setSelectedComponents3
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].
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.
1233 Info of components :"v1" "v2" "v3" "v4"
1240 Here we re-fill \b da with zeros and copy \b dv into a component of \b da.
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
1253 Below more two variants of location of target values are shown.
1254 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_4
1262 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_5
1269 The same result can be achieved other way:
1270 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_6
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.
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
1296 Below more two variants of location of target values are shown.
1297 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_4
1305 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_5
1312 The same result can be achieved other way:
1313 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_6
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.
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
1339 Below more two variants of location of target values are shown.
1340 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple2_4
1348 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple2_5
1355 \note \ref ParaMEDMEM::DataArrayDouble::setPartOfValuesSimple2() can't
1356 be explicitly called in Python.
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.
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
1383 Below more two variants of location of target values are shown.
1384 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple3_4
1392 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple3_5
1399 \note \ref ParaMEDMEM::DataArrayDouble::setPartOfValuesSimple3() can't
1400 be explicitly called in Python.
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.].
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.
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
1421 Every value of \b dv has been assigned to its own location within \b da.
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.
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
1435 \note \ref ParaMEDMEM::DataArrayDouble::setPartOfValues2() can't
1436 be explicitly called in Python.
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.].
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.
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
1458 Every value of \b dv has been assigned to its own location within \b da.
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.
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
1472 \note \ref ParaMEDMEM::DataArrayDouble::setPartOfValues3() can't
1473 be explicitly called in Python.
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.
1485 Info of components : "a2" "a1" "v3" "v4"
1491 The same result can be achieved other way (except that component info
1493 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setSelectedComponents3
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].
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.
1506 Info of components :"v1" "v2" "v3" "v4"
1513 Here we re-fill \b da with zeros and copy \b dv into a component of \b da.
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
1526 Below more two variants of location of target values are shown.
1527 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_4
1535 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_5
1542 The same result can be achieved other way:
1543 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_6
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.
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
1569 Below more two variants of location of target values are shown.
1570 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_4
1578 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_5
1585 The same result can be achieved other way:
1586 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_6
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.
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
1612 Below more two variants of location of target values are shown.
1613 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple2_4
1621 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple2_5
1628 \note \ref ParaMEDMEM::DataArrayInt::setPartOfValuesSimple2() can't
1629 be explicitly called in Python.
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.
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
1656 Below more two variants of location of target values are shown.
1657 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple3_4
1665 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple3_5
1672 \note \ref ParaMEDMEM::DataArrayInt::setPartOfValuesSimple3() can't
1673 be explicitly called in Python.
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].
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.
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
1694 Every value of \b dv has been assigned to its own location within \b da.
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.
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
1708 \note \ref ParaMEDMEM::DataArrayInt::setPartOfValues2() can't
1709 be explicitly called in Python.
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].
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.
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
1731 Every value of \b dv has been assigned to its own location within \b da.
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.
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
1745 \note \ref ParaMEDMEM::DataArrayInt::setPartOfValues3() can't
1746 be explicitly called in Python.
1749 \anchor py_mcdataarraydouble_getdifferentvalues
1750 <br><h2> Excluding coincident tuples from DataArrayDouble</h2>
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
1757 \anchor cpp_mcdataarraydouble_findcommontuples
1758 <br><h2> Finding coincident tuples in DataArrayDouble</h2>
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.
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.
1774 \anchor cpp_mcdataarraydouble_meldwith
1775 <br><h2> Concatenating DataArrayDouble's by appending components </h2>
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".
1785 \anchor cpp_mcdataarrayint_meldwith
1786 <br><h2> Concatenating DataArrayInt's by appending components </h2>
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".
1796 \anchor py_mcdataarraydouble_KeepSelectedComponents
1798 <br><h2>Creation of a sub-part of the DataArrayDouble by selecting components</h2>
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).
1809 \anchor py_mcdataarrayint_keepselectedcomponents
1811 <br><h2>Creation of a sub-part of the DataArrayInt by selecting components</h2>
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).
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
1826 \anchor cpp_mcfielddouble_subpart1
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
1837 \b f1 is a field on cells, \ref ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart "buildSubPart" method performs an extraction on cells too.
1839 So the array \b part1 lists ids on cells.
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
1845 So \b f2 contains 3 tuples with 2 components.
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.
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
1858 \b f1 is a field on nodes, but \ref ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart "buildSubPart" method performs an extraction on \b cells.
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).
1868 \page medcouplingcppexamplesUmeshStdBuild1 <br><h1> Example of standard build of an unstructured mesh from scratch in C++ </h1>
1870 Firstly retrieve basic data in full interlace mode for coordinates, and nodal connectivity cell per cell.
1871 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_1
1873 Then create ParaMEDMEM::MEDCouplingUMesh instance giving its meshdimension (2 here) and a name.
1875 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_2
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.
1881 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_3
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.
1885 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_4
1887 At this level mesh is usable. When this mesh is no more needed simply call decrRef to decrement its reference counter.
1889 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_5
1894 \page medcouplingcppexamplesUmeshAdvBuild1 <br><h1> Example of advanced build of an unstructured mesh from scratch in C++ </h1>
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
1899 Then create ParaMEDMEM::MEDCouplingUMesh instance giving its meshdimension (2 here) and a name.
1901 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_2
1903 Then enter nodal connectivity at once.
1905 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_3
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.
1909 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_4
1911 At this level mesh is usable. When this mesh is no more needed simply call decrRef() to decrement its reference counter.
1913 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_5
1918 \page medcouplingcppexamplesCmeshStdBuild1 <br><h1> Example of standard build of an cartesian mesh from scratch in C++ </h1>
1920 We are going to build a 2D cartesian mesh, constituted from 9 nodes along X axis, and 7 nodes along Y axis.
1922 Firstly retrieve for each direction the discretization and build a \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble instance" on the corresponding direction.
1924 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_1
1926 Then create ParaMEDMEM::MEDCouplingCMesh instance giving the 2 instances of \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble" obtained above.
1928 There are 2 techniques to get it.
1932 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_2
1936 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_2bis
1938 \c mesh is now available for use :
1940 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_3
1942 When this mesh is no more needed simply call decrRef to decrement its reference counter.
1944 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_4
1949 \page medcouplingcppexamplesFieldDoubleBuild1 <br><h1> Examples in C++ of standard build of a tensor field on cells with no time attached </h1>
1951 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild1_1
1956 \page medcouplingcppexamplesFieldDoubleBuild2 <br><h1> Examples in C++ of standard build of a scalar field on nodes with no time attached </h1>
1958 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild2_1
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>
1965 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild3_1
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>
1972 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild4_1
1977 \page medcouplingcppexamplesFieldDoubleBuild5 <br><h1> Examples in C++ of operation that can be carried out on fields on cells </h1>
1979 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild1_2
1981 The decrementation of ref counter should be carried out in CPlusPlus only ...
1983 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild1_3