2 \page medcouplingcppexamples MEDCoupling C++ examples
9 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
10 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_
11 \snippet MEDCouplingExamplesTest.py PySnippet_MEDCouplingUMesh_
12 \snippet MEDCouplingExamplesTest.py Snippet_MEDCouplingUMesh_
15 \anchor cpp_mcmesh_fillFromAnalytic3
16 <br><h2> Creating a field using a formular </h2>
18 First, we create a 2D Cartesian mesh constituted by 2 cells.
19 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingMesh_fillFromAnalytic3_1
21 \ref ParaMEDMEM::MEDCouplingMesh::fillFromAnalytic3 "fillFromAnalytic3()"
22 to get a \ref ParaMEDMEM::MEDCouplingFieldDouble "MEDCouplingFieldDouble" on cells filled
23 with values computed using a formular \b func. This formular is applied to coordinates of
24 each point (barycenter) for which the field value is computed. We want to get the
25 field on cells, with 3 components computed as follows. (In \b func, we refer to the
26 first component of a point using the variable "a", and to the second component, using
28 - Component #0 = the second coordinate of the point; hence "IVec * b" in \b func.
29 - Component #1 = the first coordinate of the point; hence "JVec * a".
30 - Component #2 = distance between the point and SC origin (0.,0.); hence
31 "KVec * sqrt( a*a + b*b )".
33 In addition we want to add 10.0 to each component computed as described above, hence
35 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingMesh_fillFromAnalytic3_2
36 Now we ascertain that the result field is as we expect. We check the second tuple of
37 the \b field. We get barycenter of the cell #1 and checks that values of the second
38 tuple are computed as we want.
39 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingMesh_fillFromAnalytic3_3
43 \anchor cpp_mcmesh_fillFromAnalytic2
44 <br><h2> Creating a field using a formular </h2>
46 First, we create a 2D Cartesian mesh constituted by 2 cells.
47 Note that we set names to coordinates arrays ("a" and "b" ) which will be used to refer to
48 corresponding coordinates within a function.
49 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingMesh_fillFromAnalytic2_1
51 \ref ParaMEDMEM::MEDCouplingMesh::fillFromAnalytic2 "fillFromAnalytic2()"
52 to get a \ref ParaMEDMEM::MEDCouplingFieldDouble "MEDCouplingFieldDouble" on cells filled
53 with values computed using a formular \b func. This formular is applied to coordinates of
54 each point (barycenter) for which the field value is computed. We want to get the
55 field on cells, with 3 components computed as follows. (In \b func, we refer to the
56 first component of a point using the variable "a", and to the second component, using
58 - Component #0 = the second coordinate of the point; hence "IVec * b" in \b func.
59 - Component #1 = the first coordinate of the point; hence "JVec * a".
60 - Component #2 = distance between the point and SC origin (0.,0.); hence
61 "KVec * sqrt( a*a + b*b )".
63 In addition we want to add 10.0 to each component computed as described above, hence
65 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingMesh_fillFromAnalytic2_2
66 Now we ascertain that the result field is as we expect. We check the second tuple of
67 the \b field. We get barycenter of the cell #1 and checks that values of the second
68 tuple are computed as we want.
69 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingMesh_fillFromAnalytic2_3
72 \anchor cpp_mcmesh_fillFromAnalytic
73 <br><h2> Creating a field using a formular </h2>
75 First, we create a 2D Cartesian mesh constituted by 2 cells.
76 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingMesh_fillFromAnalytic_1
78 \ref ParaMEDMEM::MEDCouplingMesh::fillFromAnalytic "fillFromAnalytic()"
79 to get a \ref ParaMEDMEM::MEDCouplingFieldDouble "MEDCouplingFieldDouble" on cells filled
80 with values computed using a formular \b func. This formular is applied to coordinates of
81 each point (barycenter) for which the field value is computed. We want to get the
82 field on cells, with 3 components computed as follows. (In \b func, we refer to the
83 first component of a point using the variable "a", and to the second component, using
85 - Component #0 = the second coordinate of the point; hence "IVec * b" in \b func.
86 - Component #1 = the first coordinate of the point; hence "JVec * a".
87 - Component #2 = distance between the point and SC origin (0.,0.); hence
88 "KVec * sqrt( a*a + b*b )".
90 In addition we want to add 10.0 to each component computed as described above, hence
92 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingMesh_fillFromAnalytic_2
93 Now we ascertain that the result field is as we expect. We check the second tuple of
94 the \b field. We get barycenter of the cell #1 and checks that values of the second
95 tuple are computed as we want.
96 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingMesh_fillFromAnalytic_3
99 \anchor cpp_mccmesh_getCoordsAt
100 <br><h2> Getting node coordinates </h2>
102 We create an 1D Cartesian mesh and retrieves node coordinates using
103 \ref ParaMEDMEM::MEDCouplingCMesh::getCoordsAt "getCoordsAt()".
104 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingCMesh_getCoordsAt_1
108 \anchor cpp_mcumesh_areCellsIncludedIn
109 <br><h2> Cells correspondence in two meshes </h2>
111 First, we create a 2D \b mesh1 with 3 QUAD4 and 2 TRI3 cells.
112 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_areCellsIncludedIn_1
113 Then we create a \b mesh2 which includes cells #4, #2 and #0 of \b mesh1. The two meshes
114 share the same node coordinates array.
115 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_areCellsIncludedIn_2
116 Now we ascertain that
117 - \ref ParaMEDMEM::MEDCouplingUMesh::areCellsIncludedIn "areCellsIncludedIn()"
118 detects that all cells of \b mesh2 are present in \b mesh1,
119 - the correspondence array \b corr2to1, which gives cell ids of \b mesh2 within
120 \b mesh1, is equal to the array \b cells2 which selected cells from \b mesh1 for creation
123 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_areCellsIncludedIn_3
125 \ref ParaMEDMEM::MEDCouplingUMesh::areCellsIncludedIn "areCellsIncludedIn()"
126 in a reverse direction and ascertain that it returns \c false.
127 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_areCellsIncludedIn_4
128 The contents of the correspondence
129 array \b corr1to2 [2, 3, 1, 4, 0] means the following.
130 - The cell #0 of \b mesh1 is equal to the cell #2 (== \b corr1to2[ 0 ]) of \b mesh2.
131 - The cell #1 of \b mesh1 is missing from \b mesh2 (as \b corr1to2[ 1 ] >= \b mesh2->getNumberOfCells()).
132 - The cell #2 of \b mesh1 is equal to the cell #1 (== \b corr1to2[ 2 ]) of \b mesh2.
133 - The cell #3 of \b mesh1 is missing from \b mesh2 (as \b corr1to2[ 3 ] >= \b mesh2->getNumberOfCells()).
134 - The cell #4 of \b mesh1 is equal to the cell #0 (== \b corr1to2[ 4 ]) of \b mesh2.
137 \anchor cpp_mcumesh_checkDeepEquivalWith
138 <br><h2> Deep comparison of meshes </h2>
140 First, we create two 2D meshes with two triangles, so that
141 - their nodes are almost same but permuted,
142 - the first triangle is based exactly on the same nodes (taking the permutation into account),
143 - an order of nodes in the second triangle is changed.
145 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_checkDeepEquivalWith_1
147 - \ref ParaMEDMEM::MEDCouplingUMesh::checkDeepEquivalWith "checkDeepEquivalWith()"
148 considers the meshes equal (i.e. it does not throw any exception) if it is called with a cell
149 comparison policy \b cellCompPol == 1
150 - mapping from \b mesh1 to \b mesh2 for both nodes and cells is as expected.
152 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_checkDeepEquivalWith_2
153 Next we ascertain that
154 \ref ParaMEDMEM::MEDCouplingUMesh::checkDeepEquivalOnSameNodesWith "checkDeepEquivalOnSameNodesWith()"
155 consider \b mesh1 and \b mesh2 different as they do not share the same nodal connectivity
157 After that we make the meshes share the node coordinates array and insert new
158 triangles based on the same nodes but in different order. This is to ascertain that
159 \ref ParaMEDMEM::MEDCouplingUMesh::checkDeepEquivalOnSameNodesWith "checkDeepEquivalOnSameNodesWith()"
160 called with the weakest cell comparison policy considers the meshes equal.
161 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_checkDeepEquivalWith_3
165 \anchor cpp_mcumesh_getPartBarycenterAndOwner
166 <br><h2> Getting barycenters of cells </h2>
168 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
169 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getPartMeasureField_1
171 \ref ParaMEDMEM::MEDCouplingUMesh::getPartBarycenterAndOwner "getPartBarycenterAndOwner()" to get
172 barycenters of all but the first cell.
173 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getPartMeasureField_3
174 The returned array contains 4 tuples per 2 components.
177 \anchor cpp_mcumesh_findAndCorrectBadOriented3DExtrudedCells
178 <br><h2> Fixing orientation of "extruded" volumes </h2>
180 First, we create a mesh with 2 incorrectly oriented "extruded" volumes.
181 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_findAndCorrectBadOriented3DExtrudedCells_1
183 \ref ParaMEDMEM::MEDCouplingUMesh::findAndCorrectBadOriented3DExtrudedCells "findAndCorrectBadOriented3DExtrudedCells()"
184 finds and fixes the reversed cells.
185 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_findAndCorrectBadOriented3DExtrudedCells_2
188 \anchor cpp_mcumesh_arePolyhedronsNotCorrectlyOriented
189 <br><h2> Fixing orientation of polyhedra </h2>
191 First, we create a mesh with 2 polyhedra, one of which is incorrectly oriented. We create
192 two "extruded" polyhedra and then convert them to correctly defined polyhedra.
193 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_arePolyhedronsNotCorrectlyOriented_1
195 \ref ParaMEDMEM::MEDCouplingUMesh::arePolyhedronsNotCorrectlyOriented "arePolyhedronsNotCorrectlyOriented()"
196 finds one reversed cell. After that we fix it using
197 \ref ParaMEDMEM::MEDCouplingUMesh::orientCorrectlyPolyhedrons "orientCorrectlyPolyhedrons()" and
198 re-check the orientation of polyhedra.
199 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_arePolyhedronsNotCorrectlyOriented_2
202 \anchor cpp_mcumesh_are2DCellsNotCorrectlyOriented
203 <br><h2> Fixing orientation of faces </h2>
205 First, we create a 2D mesh in 3D space with 3 QUAD4 and 2 TRI3 cells. Orientation of the cell #1 is
206 reversed comparing with others.
207 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_are2DCellsNotCorrectlyOriented_1
209 \ref ParaMEDMEM::MEDCouplingUMesh::are2DCellsNotCorrectlyOriented "are2DCellsNotCorrectlyOriented()"
210 finds one reversed face. After that we fix the incorrectly oriented cell using
211 \ref ParaMEDMEM::MEDCouplingUMesh::orientCorrectly2DCells "orientCorrectly2DCells()" and
212 re-check the orientation of cells.
213 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_are2DCellsNotCorrectlyOriented_2
216 \anchor cpp_mcumesh_getCellsContainingPoints
217 <br><h2> Finding cells containing a point (multi-point case) </h2>
219 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
220 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getCellsContainingPoints_1
222 \ref ParaMEDMEM::MEDCouplingUMesh::getCellsContainingPoints "getCellsContainingPoints()" to
223 get cells in contact with tree points. Two of them are in contact with some cells and one is not.
224 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getCellsContainingPoints_2
225 The contents of the result arrays \b cells ([4, 0, 1]) and \b cellsIndex ([0, 0, 1, 3])
227 - Point #0 is in contact with none (== \b cellsIndx[1] - \b cellsIndx[0]) cell.
228 - Point #1 is in contact with 1 (== \b cellsIndx[2] - \b cellsIndx[1]) cell whose id is #4
229 (== \b cells[ \b cellsIndx[ 1 ]]).
230 - Point #2 is in contact with 2 (== \b cellsIndx[3] - \b cellsIndx[2]) cells whose ids are #0
231 (== \b cells[ \b cellsIndx[ 2 ]]) and #1 (== \b cells[ \b cellsIndx[ 2 ] + 1 ]).
234 \anchor cpp_mcumesh_getCellsContainingPoint
235 <br><h2> Finding cells containing a point </h2>
237 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
238 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getCellsContainingPoint_1
240 \ref ParaMEDMEM::MEDCouplingUMesh::getCellsContainingPoint "getCellsContainingPoint()" to
241 get cells in contact with a small ball (point with precision) located near the node #4 and
242 shifted from this node by its radius \b eps.
243 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getCellsContainingPoint_2
244 Since the node #4 is shared by all cells, size of the vector \b cellIds must be equal to
245 the number of cells in \b mesh.
247 \anchor cpp_mcumesh_buildPartOrthogonalField
248 <br><h2> Getting normals of cells </h2>
250 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells. Orientation of the cell #1 is
252 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildPartOrthogonalField_1
254 \ref ParaMEDMEM::MEDCouplingUMesh::buildPartOrthogonalField "buildPartOrthogonalField()" to get
255 normal vectors to the cells.
256 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildPartOrthogonalField_2
260 \anchor cpp_mcumesh_getPartMeasureField
261 <br><h2> Getting volumes of cells </h2>
263 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells. Orientation of the cell #1 is
265 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getPartMeasureField_1
267 \ref ParaMEDMEM::MEDCouplingUMesh::getPartMeasureField "getPartMeasureField()" to get
268 volumes of all but the first cell. If we call
269 \ref ParaMEDMEM::MEDCouplingUMesh::getPartMeasureField "getPartMeasureField()" with \b
270 isAbs == \c true, the area of the cell #1 is returned positive, else, negative that
271 reflects its inverse orientation.
272 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getPartMeasureField_2
276 \anchor cpp_mcumesh_getCellsInBoundingBox
277 <br><h2> Getting cells using the bounding box </h2>
279 First, we create a 2D mesh with 1 TRI3 cell. Bounding box of this cell is [0.,0., 1.,1].
280 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getCellsInBoundingBox_1
282 \ref ParaMEDMEM::MEDCouplingUMesh::getCellsInBoundingBox "getCellsInBoundingBox()"
283 searches for cells using the bounding box. We use a bounding box touching the bounding box
284 of the sole cell at one point (1.,1.).
285 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getCellsInBoundingBox_2
286 If \ref ParaMEDMEM::MEDCouplingUMesh::getCellsInBoundingBox "getCellsInBoundingBox()" is
287 called with parameter \b eps == 0.0, the cell is not found because the two bounding boxes
288 (one of the cell and the one passed as parameter) do not overlap. <br>
289 If \ref ParaMEDMEM::MEDCouplingUMesh::getCellsInBoundingBox "getCellsInBoundingBox()" is
290 called with parameter \b eps == 0.1, the cell is found because \b eps is used to increase
291 the bounding box of the cell and thus the two bounding boxes intersect each other. <br>
293 \anchor cpp_mcumesh_renumberNodesInConn
294 <br><h2> Renumbering nodes in the connectivity array </h2>
296 First, we create a 2D mesh with 1 QUAD4 cell and with undefined coordinates of nodes.
297 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_renumberNodesInConn_1
299 \ref ParaMEDMEM::MEDCouplingUMesh::renumberNodesInConn "renumberNodesInConn()"
300 to get the following nodal connectivity of a sole cell: 0,1,2,3.
301 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_renumberNodesInConn_2
302 \b old2newIds array defines how node ids are changed:
303 - new id of node #0 is -1,
304 - new id of node #1 is 3,
305 - new id of node #2 is 4,
306 - new id of node #3 is 1,
307 - new id of node #4 is 0.
309 \anchor cpp_mcumesh_renumberNodes
310 <br><h2> Renumbering nodes </h2>
312 First, we create a 2D mesh with 4 nodes and no cells.
313 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_renumberNodes_1
315 \ref ParaMEDMEM::MEDCouplingUMesh::renumberNodes "renumberNodes()"
316 to permute nodes so that
317 - old node #0 becomes #2,
318 - old node #1 remains #1,
319 - old node #2 becomes #0,
320 - old node #3 is removed.
322 Number of nodes becomes 3.
323 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_renumberNodes_2
325 Next we compare behavior of
326 \ref ParaMEDMEM::MEDCouplingUMesh::renumberNodes "renumberNodes()" and that of
327 \ref ParaMEDMEM::MEDCouplingUMesh::renumberNodes2 "renumberNodes2()" which, in contrast to
328 \ref ParaMEDMEM::MEDCouplingUMesh::renumberNodes "renumberNodes()",
329 moves merged nodes to their barycenter.<br>
330 We set #2 as new id of old node #3 and expect that
331 \ref ParaMEDMEM::MEDCouplingUMesh::renumberNodes2 "renumberNodes2()" moves old nodes #0
332 and #3 to their barycenter (-0.3,0.0) which becomes position of node #2.<br>
333 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_renumberNodes_3
336 \anchor cpp_mcumesh_findBoundaryNodes
337 <br><h2> Getting boundary nodes </h2>
339 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
340 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_findBoundaryNodes_1
342 \ref ParaMEDMEM::MEDCouplingUMesh::findBoundaryNodes "findBoundaryNodes()" to get ids
344 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_findBoundaryNodes_2
345 \ref ParaMEDMEM::MEDCouplingUMesh::findBoundaryNodes "findBoundaryNodes()" returns all
346 node ids except the node #4 which is in the middle of \b mesh.
349 \anchor cpp_mcumesh_buildBoundaryMesh
350 <br><h2> Getting a bounding mesh </h2>
352 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
353 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildBoundaryMesh_1
355 \ref ParaMEDMEM::MEDCouplingUMesh::buildBoundaryMesh "buildBoundaryMesh()" to get a mesh
356 of lower dimension bounding \b mesh.
357 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildBoundaryMesh_2
358 Depending on the value of a parameter,
359 \ref ParaMEDMEM::MEDCouplingUMesh::buildBoundaryMesh "buildBoundaryMesh()"
360 creates the mesh sharing the node coordinates array with \b mesh or not.
363 \anchor cpp_mcumesh_buildFacePartOfMySelfNode
364 <br><h2> Retrieving a lower dimension mesh based on given nodes </h2>
366 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
367 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildFacePartOfMySelfNode_1
368 In the following code we retrieve nodes of the cell #0 an then we call
369 \ref ParaMEDMEM::MEDCouplingUMesh::buildFacePartOfMySelfNode "buildFacePartOfMySelfNode()"
370 twice with these nodes and with varying last parameter \b allNodes as input.
371 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildFacePartOfMySelfNode_2
372 <br>If the last parameter is \c true
373 \ref ParaMEDMEM::MEDCouplingUMesh::buildFacePartOfMySelfNode "buildFacePartOfMySelfNode()" looks
374 for segements whose all nodes are given to it, hence it finds segments bounding the cell #0 only.
375 <br>If the last parameter is \c false
376 \ref ParaMEDMEM::MEDCouplingUMesh::buildFacePartOfMySelfNode "buildFacePartOfMySelfNode()" looks
377 for any segment whose nodes are given to it, hence it adds more segments to \b mesh2.
380 \anchor cpp_mcumesh_buildPartOfMySelfNode
381 <br><h2> Copying cells selected by nodes </h2>
383 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
384 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildPartOfMySelfNode_1
385 In the following code we retrieve nodes of the cell #0 an then we call
386 \ref ParaMEDMEM::MEDCouplingUMesh::buildPartOfMySelfNode "buildPartOfMySelfNode()"
387 twice with these nodes and with varying last parameter \b allNodes as input.
388 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildPartOfMySelfNode_2
389 <br>If the last parameter is \c true
390 \ref ParaMEDMEM::MEDCouplingUMesh::buildPartOfMySelfNode "buildPartOfMySelfNode()" looks
391 for cells whose all nodes are given to it, hence it finds the cell #0 only.
392 <br>If the last parameter is \c false
393 \ref ParaMEDMEM::MEDCouplingUMesh::buildPartOfMySelfNode "buildPartOfMySelfNode()" looks
394 for any cell whose nodes are given to it, hence it finds all cells of \b mesh because all
395 cells share the node #4.
398 \anchor cpp_mcumesh_getCellIdsLyingOnNodes
399 <br><h2> Getting cells by nodes </h2>
401 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
402 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getCellIdsLyingOnNodes_1
403 In the following code we retrieve nodes of the cell #0 an then we call
404 \ref ParaMEDMEM::MEDCouplingUMesh::getCellIdsLyingOnNodes "getCellIdsLyingOnNodes()"
405 twice with these nodes and with varying last parameter \b allNodes as input.
406 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getCellIdsLyingOnNodes_2
407 <br>If the last parameter is \c true
408 \ref ParaMEDMEM::MEDCouplingUMesh::getCellIdsLyingOnNodes "getCellIdsLyingOnNodes()" looks
409 for cells whose all nodes are given to it, hence it finds the cell #0 only.
410 <br>If the last parameter is \c false
411 \ref ParaMEDMEM::MEDCouplingUMesh::getCellIdsLyingOnNodes "getCellIdsLyingOnNodes()" looks
412 for any cell whose nodes are given to it, hence it finds all cells of \b mesh because all
413 cells share the node #4.
417 \anchor cpp_mcumesh_getCellIdsFullyIncludedInNodeIds
418 <br><h2> Getting cells by nodes </h2>
420 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
421 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getCellIdsFullyIncludedInNodeIds_1
422 In the following code we retrieve nodes of two cells an then we use
423 \ref ParaMEDMEM::MEDCouplingUMesh::getCellIdsFullyIncludedInNodeIds
424 "getCellIdsFullyIncludedInNodeIds()" to find these cells by their nodes.
425 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getCellIdsFullyIncludedInNodeIds_2
428 \anchor cpp_mcumesh_buildPartOfMySelf
429 <br><h2> Getting a part of mesh </h2>
431 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
432 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildPartOfMySelf_1
434 \ref ParaMEDMEM::MEDCouplingUMesh::buildPartOfMySelf "buildPartOfMySelf()" to get a mesh
435 containing only two cells of \b mesh.
436 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildPartOfMySelf_2
439 \anchor cpp_mcumesh_mergeNodes
440 <br><h2> Merging equal nodes </h2>
442 First, we create a 2D mesh with 1 QUAD4 and 2 TRI3 cells. The cells are based on 6 nodes
443 of which 2 nodes fully coincide (#3 and #4) and 3 nodes are equal with precision 0.003.
444 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_mergeNodes_1
445 Now we merge node duplicates using
446 \ref ParaMEDMEM::MEDCouplingUMesh::mergeNodes "mergeNodes()" and check values it returns.
447 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_mergeNodes_2
448 Contents of \b arr shows ids of old nodes after the merging. The nodes considered equal
449 one to the other have the same id in \b arr.
451 Next we compare behavior of
452 \ref ParaMEDMEM::MEDCouplingUMesh::mergeNodes "mergeNodes()" and that of
453 \ref ParaMEDMEM::MEDCouplingUMesh::mergeNodes2 "mergeNodes2()" which, in contrast to
454 \ref ParaMEDMEM::MEDCouplingUMesh::mergeNodes "mergeNodes()",
455 moves merged nodes to their barycenter.<br> We expect that
456 \ref ParaMEDMEM::MEDCouplingUMesh::mergeNodes2 "mergeNodes2()" moves old nodes #0, #2
457 and #5 to their barycenter equal to position of node #2.<br>
459 \ref ParaMEDMEM::MEDCouplingUMesh::mergeNodes "mergeNodes()" does not move nodes
460 coincident with the node #2 to the position of node #2, and then we check that
461 \ref ParaMEDMEM::MEDCouplingUMesh::mergeNodes "mergeNodes2()" does move.
462 (We check only the second (Y) component of node coordinates since the first component of
463 these nodes is exactly same.)
464 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_mergeNodes_3
468 \anchor cpp_mcumesh_zipConnectivityTraducer
469 <br><h2> Removing cell duplicates </h2>
471 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells, so that
472 - the cell #2 has the same nodal connectivity as the cell #1 does,
473 - the cell #3 has the same nodal connectivity as the cell #0 does,
474 - the cell #4 is based on the same nodes as the cell #0 but nodes order is different.
476 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_zipConnectivityTraducer_1
478 \ref ParaMEDMEM::MEDCouplingUMesh::zipConnectivityTraducer "zipConnectivityTraducer()"
479 to remove duplicate cells. Then we check that two cells, having exactly same nodal
480 connectivity with other cells, have been removed.
481 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_zipConnectivityTraducer_2
482 Contents of \b arr shows ids of cells after duplicates removal. If a value (cell id)
483 equals to its index in \b arr, this means that the cell is not a duplicate of any cell
484 with lower id. Else, the value gives a cell id to which this cell is equal. <br>
485 Thus, the cells #0 and #1 have no preceding equal cell since \b arr[i] == i.<br>
486 The cell #2 equals to the cell #1 (== \b arr[2] ).<br>
487 The cell #3 equals to the cell #0 (== \b arr[3] ).<br>
488 The cell #4 has no equal cell. This is because the cell comparison technique specified
490 \ref ParaMEDMEM::MEDCouplingUMesh::zipConnectivityTraducer "zipConnectivityTraducer()"
491 was 0 ("exact"), if we had used the technique 2 ("nodal"), \b arr[4] would be 0.
495 \anchor cpp_mcumesh_zipCoordsTraducer
496 <br><h2> Removing unused nodes </h2>
498 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
499 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_zipCoordsTraducer_1
500 Now we create \b mesh2 including all nodes but only two cells of \b mesh, and we use \ref
501 ParaMEDMEM::MEDCouplingUMesh::zipCoordsTraducer "zipCoordsTraducer()" to remove unused
503 \ref ParaMEDMEM::MEDCouplingUMesh::zipCoordsTraducer "zipCoordsTraducer()" returns an array
504 with -1 for unused nodes and new ids for used ones.
505 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_zipCoordsTraducer_2
509 \anchor cpp_mcumesh_getNodeIdsInUse
510 <br><h2> Retrieving unused nodes </h2>
512 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
513 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getNodeIdsInUse_1
514 Now we create \b mesh2 including all nodes but only two cells of \b mesh, and we use \ref
515 ParaMEDMEM::MEDCouplingUMesh::getNodeIdsInUse "getNodeIdsInUse()" to get nodes of \b mesh2
516 used in its two cells.
517 \ref ParaMEDMEM::MEDCouplingUMesh::getNodeIdsInUse "getNodeIdsInUse()" returns an array
518 with -1 for unused nodes and new ids for used ones.
519 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getNodeIdsInUse_2
520 Now we use \b newNbOfNodes returned by
521 \ref ParaMEDMEM::MEDCouplingUMesh::getNodeIdsInUse "getNodeIdsInUse()" to convert \b arr
522 to "New to Old" mode.
523 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getNodeIdsInUse_3
526 \anchor cpp_mcumesh_convertToPolyTypes
527 <br><h2> Conversion of cells to "poly" types </h2>
529 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
530 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_convertToPolyTypes_1
531 Now we convert cells #1 and #3 to type POLYGON and check the result
532 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_convertToPolyTypes_2
535 \anchor cpp_mcumesh_buildDescendingConnectivity2
536 <br><h2> Retrieving the descending connectivity with orientation </h2>
538 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
539 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildDescendingConnectivity2_1
540 Now we get and check the descending connectivity.
541 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildDescendingConnectivity2_2
542 Here we get connectivity of the cell #2 (#3 in FORTRAN mode) of \b mesh2 to see how
543 mutual orientation of cells in \b mesh and \b mesh2 is defined.
544 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildDescendingConnectivity2_3
545 The contents of the result arrays \b desc and \b descIndx mean the following.
546 - The cell #0 of \b mesh (QUAD4) is bound by 4 (== \b descIndx[1] - \b descIndx[0])
547 segments (SEG2) of \b mesh2 whose ids in FORTRAN mode are
548 - #1 (== \b desc[ \b descIndx[ 0 ]]),
549 - #2 (== \b desc[ \b descIndx[ 0 ] + 1 ]),
550 - #3 (== \b desc[ \b descIndx[ 0 ] + 2 ]) and
551 - #4 (== \b desc[ \b descIndx[ 0 ] + 3 ]).
552 <br>Ids are positive since order of nodes in the corresponding cells of \b mesh and \b mesh2
553 are same. For example nodes of SEG2 #3 are [4,1] and nodes of QUAD4 #0 are [0,3,\b 4,\b 1].
554 - The cell #1 of \b mesh (TRI3) is bound by 3 (== \b descIndx[2] - \b descIndx[1]) segements of
555 \b mesh2 whose ids in FORTRAN mode are:
556 - #-3 (== \b desc[ \b descIndx[ 1 ]]),
557 - #5 (== \b desc[ \b descIndx[ 1 ] + 1 ]) and
558 - #6 (== \b desc[ \b descIndx[ 1 ] + 2 ]).
559 <br>The id -3 means that order of nodes in SEG2 #3 ([4,1]) is different from the order of
560 these nodes in TRI3 #1: [\b 1,\b 4,2].
563 The contents of the result arrays \b revDesc and \b revDescIndx mean the following.
564 - The cell #0 of \b mesh2 (SEG2) bounds 1 (== \b revDescIndx[1] - \b revDescIndx[0]) cell of \b
566 - # 0 (== \b revDesc[ \b revDescIndx[ 0 ]]).
567 - The cell #1 of \b mesh2 bounds 2 (== \b revDescIndx[2] - \b revDescIndx[1]) cells of \b
569 - # 0 (== \b revDesc[ \b revDescIndx[ 1 ]]) and
570 - # 1 (== \b revDesc[ \b revDescIndx[ 1 ] + 1 ]).
575 \anchor cpp_mcumesh_buildDescendingConnectivity
576 <br><h2> Retrieving the descending connectivity </h2>
578 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
579 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildDescendingConnectivity_1
580 Now we get and check the descending connectivity.
581 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_buildDescendingConnectivity_2
582 The contents of the result arrays \b desc and \b descIndx mean the following.
583 - The cell #0 of \b mesh (QUAD4) is bound by 4 (== \b descIndx[1] - \b descIndx[0])
584 segments (SEG2) of \b mesh2 whose ids are
585 - #0 (== \b desc[ \b descIndx[ 0 ]]),
586 - #1 (== \b desc[ \b descIndx[ 0 ] + 1 ]),
587 - #2 (== \b desc[ \b descIndx[ 0 ] + 2 ]) and
588 - #3 (== \b desc[ \b descIndx[ 0 ] + 3 ]).
589 - The cell #1 of \b mesh (TRI3) is bound by 3 (== \b descIndx[2] - \b descIndx[1]) segements of
590 \b mesh2 whose ids are:
591 - #2 (== \b desc[ \b descIndx[ 1 ]]),
592 - #4 (== \b desc[ \b descIndx[ 1 ] + 1 ]) and
593 - #5 (== \b desc[ \b descIndx[ 1 ] + 2 ]).
596 The contents of the result arrays \b revDesc and \b revDescIndx mean the following.
597 - The cell #0 of \b mesh2 (SEG2) bounds 1 (== \b revDescIndx[1] - \b revDescIndx[0]) cell of \b
599 - # 0 (== \b revDesc[ \b revDescIndx[ 0 ]]).
600 - The cell #1 of \b mesh2 bounds 2 (== \b revDescIndx[2] - \b revDescIndx[1]) cells of \b
602 - # 0 (== \b revDesc[ \b revDescIndx[ 1 ]]) and
603 - # 1 (== \b revDesc[ \b revDescIndx[ 1 ] + 1 ]).
607 \anchor cpp_mcumesh_getReverseNodalConnectivity
608 <br><h2> Getting the reverse nodal connectivity </h2>
610 First, we create a 2D mesh with 3 QUAD4 and 2 TRI3 cells.
611 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getReverseNodalConnectivity_1
612 Now we get and check its reverse nodal connectivity.
613 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingUMesh_getReverseNodalConnectivity_2
614 The contents of the result arrays mean the following.
615 - Node #0 is shared by 1 (== \b revNodalIndx[1] - \b revNodalIndx[0]) cell whose id is #0
616 (== \b revNodal[ \b revNodalIndx[ 0 ]]).
617 - Node #1 is shared by 2 (== \b revNodalIndx[2] - \b revNodalIndx[1]) cells whose ids are #0
618 (== \b revNodal[ \b revNodalIndx[ 1 ]]) and #1 (== \b revNodal[ \b revNodalIndx[ 1 ] + 1 ]).
621 \anchor cpp_mcpointset_scale
622 <br><h2> Scaling the mesh </h2>
624 First, we create a 2D mesh with 4 nodes and no cells.
625 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_scale_1
626 Then we scale it by a factor of 2 with a center (0.,0.).
627 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_scale_2
628 Finally we check that all node coordinates have changed by more than 0.9.
629 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_scale_3
634 \anchor cpp_mcpointset_translate
635 <br><h2> Translating the mesh </h2>
637 First, we create a 2D mesh with 4 nodes and no cells.
638 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_translate_1
639 Then we translate it by a vector (1.,1.).
640 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_translate_2
641 Finally we check that all node coordinates have changed by more than 0.9.
642 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_translate_3
646 \anchor cpp_mcpointset_rotate
647 <br><h2> Rotating the mesh </h2>
649 First, we create a 2D mesh with 4 nodes and no cells.
650 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_rotate_1
651 Then we rotate it around a point (0.,0.) by 90 degrees clockwise.
652 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_rotate_2
653 Next, we make a 3D mesh from the 2D one and rotate it around the Z axis by 90 degrees
655 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_rotate_3
656 Finally we transform the mesh back to 2D space and check that all nodes get back to the
658 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_rotate_4
660 \anchor cpp_mcpointset_getBoundingBox
661 <br><h2> Getting a minimum box bounding nodes </h2>
663 First, we create a 3D mesh with 2 nodes, so that the first one has minimal coordinates and
664 the second one has maximal coordinates.
665 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_getBoundingBox_1
666 Now we get a bounding box enclosing these nodes. This bounding box should contain
667 coordinates of our two nodes (but in "no interlace" mode), as the nodes coincide with
668 points returned by the bounding box.
669 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_getBoundingBox_2
672 \anchor cpp_mcpointset_getnodeidsnearpoint
673 <br><h2> Getting nodes close to a point </h2>
675 The following code creates a 2D \ref ParaMEDMEM::MEDCouplingUMesh
676 "MEDCouplingUMesh" with 5 nodes and no cells.
677 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_getNodeIdsNearPoint_1
678 Now we define an array of coordinates of a point close to nodes #0, #2 and #4.
681 \ref ParaMEDMEM::MEDCouplingPointSet::getNodeIdsNearPoint "getNodeIdsNearPoint()" that
683 if called with \b eps = 0.003, would return ids of nodes #0, #2 and #4.
684 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_getNodeIdsNearPoint_2
687 \anchor cpp_mcpointset_getnodeidsnearpoints
688 <br><h2> Getting nodes close to some points </h2>
690 The following code creates a 2D \ref ParaMEDMEM::MEDCouplingUMesh
691 "MEDCouplingUMesh" with 7 nodes and no cells.
692 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_getNodeIdsNearPoints_1
693 Now we define an array of coordinates of 3 points near which we want to find nodes of the mesh.
694 - Point #0 is at distance 0.001 from the node #1.
695 - Point #1 is rather far from all nodes.
696 - Point #2 is close to nodes #3, #4 and #5.
699 \ref ParaMEDMEM::MEDCouplingPointSet::getNodeIdsNearPoints "getNodeIdsNearPoints()" that
701 if called with \b eps = 0.003, would return ids of close nodes #1, #3, #4 and #5.
702 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_getNodeIdsNearPoints_2
703 \b idsIndex returns [0, 1, 1, 4] which means that:
704 - Point #0 is close to 1 (== \b idsIndex[1] - \b idsIndex[0]) node whose id is
705 \b ids[ \b idsIndex[ 0 ]].
706 - Point #1 is close to 0 (== \b idsIndex[2] - \b idsIndex[1]) nodes.
707 - Point #2 is close to 3 (== \b idsIndex[3] - \b idsIndex[2]) nodes whose ids are
708 \b ids[ \b idsIndex[ 2 ]], \b ids[ \b idsIndex[ 2 ] + 1 ] and \b ids[ \b idsIndex[ 2 ] + 2 ].
711 \anchor cpp_mcpointset_findcommonnodes
712 <br><h2> Finding coincident nodes </h2>
714 First, we create a mesh with 6 nodes, of which two nodes (#3 and #4) are fully coincident
715 and 3 nodes (#0, #2 and #5) have distance less than 0.004 between them.
716 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_findCommonNodes_1
717 Then, we use \ref ParaMEDMEM::MEDCouplingPointSet::findCommonNodes() "findCommonNodes()" to find
718 coincident nodes, and check that (1) calling
719 \ref ParaMEDMEM::MEDCouplingPointSet::findCommonNodes() "findCommonNodes()" with \b prec
720 == 1e-13 finds the two fully coincident nodes only and (2)
721 \ref ParaMEDMEM::MEDCouplingPointSet::findCommonNodes() "findCommonNodes"(0.004) finds 5
723 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_findCommonNodes_2
725 \anchor cpp_mcpointset_getcoordinatesofnode
726 <br><h2> Getting coordinates of a node </h2>
728 The following code creates a 2D \ref ParaMEDMEM::MEDCouplingUMesh
729 "MEDCouplingUMesh" with 3 nodes and no cells.
730 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_getCoordinatesOfNode_1
731 Here we get coordinates of the second node and check its two coordinates.
732 \snippet MEDCouplingExamplesTest.cxx CppSnippet_MEDCouplingPointSet_getCoordinatesOfNode_2
734 \anchor cpp_mcdataarrayint_getTuple
735 <br><h2> Getting a tuple of DataArrayInt </h2>
737 In this simple example we create an array of integers arranged into 3
738 tuples per 2 components, and finally print the second tuple.
739 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_getTuple_1
742 Note that we can traverse all tuples in the array by simply iterating
743 over it as the code below does.
744 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_getTuple_2
752 \anchor cpp_mcdataarrayint_buildpermutationarr
753 <br><h2> Building a permutation array </h2>
755 Here we create two arrays containing same values but in different order and then we use
756 \ref ParaMEDMEM::DataArrayInt::buildPermutationArr "DataArrayInt::buildPermutationArr()" to get
757 an array showing in what places the values of \b b array are located in \b a array.
758 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayInt_buildPermutationArr_1
759 The result array \b c contains [1,0,4,2,3].
761 <br><h2> Inverting renumbering maps </h2>
762 \anchor cpp_mcdataarrayint_invertarrayo2n2n2o
763 <h3> invertArrayO2N2N2O() </h3>
765 In this example we create a DataArrayInt containing a renumbering map in
766 "Old to New" mode, convert it into the renumbering map in "New to Old" mode and check the
768 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayInt_invertArrayO2N2N2O_1
770 \anchor cpp_mcdataarrayint_invertarrayn2o2o2n
771 <br><h3> invertArrayN2O2O2N() </h3>
773 In this example we create a DataArrayInt containing a renumbering map in
774 "New to Old" mode, convert it into the renumbering map in "Old to New" mode and check the
776 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayInt_invertArrayN2O2O2N_1
780 \anchor cpp_mcdataarraydouble_getidsinrange
781 <br><h2> Finding values in range in DataArrayDouble</h2>
783 In this example we create an array \b da containing same values as ones returned by
784 \c range( \c 10 ). Then we get an array of indices of values of \b da being in
786 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayDouble_getIdsInRange_1
787 As result contents of the array \b da2 are as follows.
796 \anchor cpp_mcdataarraydouble_setselectedcomponents
797 <br><h2> Set part of values of DataArrayDouble </h2>
798 <h3> setSelectedComponents() </h3>
799 First, we create a 'source' array.
800 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setSelectedComponents1
801 Now we create a larger zero array and assign the array \b da into it.
802 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setSelectedComponents2
803 As result contents of the array \b dv are as follows.
805 Info of components : "a2" "a1" "v3" "v4"
811 The same result can be achieved other way (except that component info
813 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setSelectedComponents3
815 \anchor cpp_mcdataarraydouble_setpartofvalues1
816 <br><h3> setPartOfValues1() </h3>
817 We create two arrays:
818 - a "large" (4x4) zero array \b da to assign to and
819 - a smaller (2x2) array \b dv filled with values [7.,8.,9.,10].
821 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_1
822 Now we copy \b dv to the middle of \b da.
823 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_2
824 As result contents of the array \b da are as follows.
826 Info of components :"v1" "v2" "v3" "v4"
833 Here we re-fill \b da with zeros and copy \b dv into a component of \b da.
835 Note that the last parameter \b strictCompoCompare should be \c False
836 in this case, else \ref ParaMEDMEM::DataArrayDouble::setPartOfValues1()
837 throws an exception because \b da has 2 components but only one target
838 component is specified.
839 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_3
846 Below more two variants of location of target values are shown.
847 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_4
855 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_5
862 The same result can be achieved other way:
863 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues1_6
867 \anchor cpp_mcdataarraydouble_setpartofvaluessimple1
868 <br><h3> setPartOfValuesSimple1() </h3>
869 We create an array (4x4) \b da to assign to and define a value \b dv to assign.
870 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_1
871 Now we assign \b dv to the middle of \b da.
872 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_2
873 As result contents of the array \b da are as follows.
881 Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
882 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_3
889 Below more two variants of location of target values are shown.
890 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_4
898 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_5
905 The same result can be achieved other way:
906 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple1_6
909 \anchor cpp_mcdataarraydouble_setpartofvaluessimple2
910 <br><h3> setPartOfValuesSimple2() </h3>
911 We create an array (4x4) \b da to assign to and define a value \b dv to assign.
912 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple2_1
913 Now we assign \b dv to the middle of \b da.
914 We explicitly specify tuples and component to assign to by a list [1,2].
915 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple2_2
916 As result contents of the array \b da are as follows.
924 Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
925 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple2_3
932 Below more two variants of location of target values are shown.
933 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple2_4
941 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple2_5
948 \note \ref ParaMEDMEM::DataArrayDouble::setPartOfValuesSimple2() can't
949 be explicitly called in Python.
952 \anchor cpp_mcdataarraydouble_setpartofvaluessimple3
953 <br><h3> setPartOfValuesSimple3() </h3>
954 We create an array (4x4) \b da to assign to and define a value \b dv to assign.
955 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple3_1
956 Now we assign \b dv to the middle of \b da.
957 We explicitly specify tuples to assign to by a list [1,2]. And we specify
958 components to assign to using slicing: 1:3.
959 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple3_2
960 As result contents of the array \b da are as follows.
968 Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
969 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple3_3
976 Below more two variants of location of target values are shown.
977 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple3_4
985 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValuesSimple3_5
992 \note \ref ParaMEDMEM::DataArrayDouble::setPartOfValuesSimple3() can't
993 be explicitly called in Python.
996 \anchor cpp_mcdataarraydouble_setpartofvalues2
997 <br><h3> setPartOfValues2() </h3>
998 We create two arrays:
999 - a "large" (4x7) zero array \b da to assign to,
1000 - a smaller (3x2) array \b dv filled with values [7.,8.,9.,10.,11.,12.].
1002 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues2_1
1003 Now we assign the two components of \b dv to the components of \b da
1004 with indices [1,3], and the 3 tuples of \b dv to the 3 tuples of \b da with
1005 indices [0,1,2]. This is the first mode of usage.
1006 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues2_2
1007 As result contents of the array \b da are as follows.
1009 Tuple #0 : 0 7 0 8 0 0 0
1010 Tuple #1 : 0 9 0 10 0 0 0
1011 Tuple #2 : 0 11 0 12 0 0 0
1012 Tuple #3 : 0 0 0 0 0 0 0
1014 Every value of \b dv has been assigned to its own location within \b da.
1016 Now we re-fill \b da with zeros and rearrange \b dv to have 6 components.
1017 And we assign \b dv to the tuples of \b da with indices [0,2,3] .
1018 This is the second mode of usage.
1019 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues2_3
1020 The contents of \b dv have been assigned to each of specified tuples of \b da.
1021 Every value of \b dv is repeated in the 3 specified tuples within \b da.
1023 Tuple #0 : 7 0 8 9 10 11 12
1024 Tuple #1 : 0 0 0 0 0 0 0
1025 Tuple #2 : 7 0 8 9 10 11 12
1026 Tuple #3 : 7 0 8 9 10 11 12
1028 \note \ref ParaMEDMEM::DataArrayDouble::setPartOfValues2() can't
1029 be explicitly called in Python.
1032 \anchor cpp_mcdataarraydouble_setpartofvalues3
1033 <br><h3> setPartOfValues3() </h3>
1034 We create two arrays:
1035 - a "large" (4x7) zero array \b da to assign to,
1036 - a smaller (3x2) array \b dv filled with values [7.,8.,9.,10.,11.,12.].
1038 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues3_1
1039 Now we assign the two components of \b dv to the components of \b da
1040 with indices [1,3], and the 3 tuples of \b dv to the 3 tuples of \b da with
1041 indices [0,1,2] which are specified using slicing: "0:3".
1042 This is the first mode of usage.
1043 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues3_2
1044 As result contents of the array \b da are as follows.
1046 Tuple #0 : 0 7 0 8 0 0 0
1047 Tuple #1 : 0 9 0 10 0 0 0
1048 Tuple #2 : 0 11 0 12 0 0 0
1049 Tuple #3 : 0 0 0 0 0 0 0
1051 Every value of \b dv has been assigned to its own location within \b da.
1053 Now we re-fill \b da with zeros and rearrange \b dv to have 6 components.
1054 And we assign \b dv to the tuples of \b da with indices [0,2] using \a
1055 slice notation "0:4:2". This is the second mode of usage.
1056 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_setPartOfValues3_3
1057 The contents of \b dv have been assigned to each of specified tuples of \b da.
1058 Every value of \b dv is repeated in the 3 specified tuples within \b da.
1060 Tuple #0 : 7 0 8 9 10 11 12
1061 Tuple #1 : 0 0 0 0 0 0 0
1062 Tuple #2 : 7 0 8 9 10 11 12
1063 Tuple #3 : 0 0 0 0 0 0 0
1065 \note \ref ParaMEDMEM::DataArrayDouble::setPartOfValues3() can't
1066 be explicitly called in Python.
1069 \anchor cpp_mcdataarrayint_setselectedcomponents
1070 <br><h2> Set part of values of DataArrayInt </h2>
1071 <h3> setSelectedComponents() </h3>
1072 First, we create a 'source' array.
1073 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setSelectedComponents1
1074 Now we create a larger zero array and assign the array \b da to it.
1075 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setSelectedComponents2
1076 As result contents of the array \b dv are as follows.
1078 Info of components : "a2" "a1" "v3" "v4"
1084 The same result can be achieved other way (except that component info
1086 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setSelectedComponents3
1088 \anchor cpp_mcdataarrayint_setpartofvalues1
1089 <br><h3> setPartOfValues1() </h3>
1090 We create two arrays:
1091 - a "large" (4x4) zero array \b da to assign to and
1092 - a smaller (2x2) array \b dv filled with values [7,8,9,10].
1094 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_1
1095 Now we copy \b dv to the middle of \b da.
1096 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_2
1097 As result contents of the array \b da are as follows.
1099 Info of components :"v1" "v2" "v3" "v4"
1106 Here we re-fill \b da with zeros and copy \b dv into a component of \b da.
1108 Note that the last parameter \b strictCompoCompare should be \c False
1109 in this case, else \ref ParaMEDMEM::DataArrayInt::setPartOfValues1()
1110 throws an exception because \b da has 2 components but only one target
1111 component is specified.
1112 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_3
1119 Below more two variants of location of target values are shown.
1120 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_4
1128 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_5
1135 The same result can be achieved other way:
1136 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues1_6
1140 \anchor cpp_mcdataarrayint_setpartofvaluessimple1
1141 <br><h3> setPartOfValuesSimple1() </h3>
1142 We create an array (4x4) \b da to assign to and define a value \b dv to assign.
1143 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_1
1144 Now we assign \b dv to the middle of \b da.
1145 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_2
1146 As result contents of the array \b da are as follows.
1154 Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
1155 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_3
1162 Below more two variants of location of target values are shown.
1163 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_4
1171 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_5
1178 The same result can be achieved other way:
1179 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple1_6
1182 \anchor cpp_mcdataarrayint_setpartofvaluessimple2
1183 <br><h3> setPartOfValuesSimple2() </h3>
1184 We create an array (4x4) \b da to assign to and define a value \b dv to assign.
1185 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple2_1
1186 Now we assign \b dv to the middle of \b da.
1187 We explicitly specify tuples and component to assign to by a list [1,2].
1188 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple2_2
1189 As result contents of the array \b da are as follows.
1197 Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
1198 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple2_3
1205 Below more two variants of location of target values are shown.
1206 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple2_4
1214 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple2_5
1221 \note \ref ParaMEDMEM::DataArrayInt::setPartOfValuesSimple2() can't
1222 be explicitly called in Python.
1225 \anchor cpp_mcdataarrayint_setpartofvaluessimple3
1226 <br><h3> setPartOfValuesSimple3() </h3>
1227 We create an array (4x4) \b da to assign to and define a value \b dv to assign.
1228 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple3_1
1229 Now we assign \b dv to the middle of \b da.
1230 We explicitly specify tuples to assign to by a list [1,2]. And we specify
1231 components to assign to using slicing: 1:3.
1232 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple3_2
1233 As result contents of the array \b da are as follows.
1241 Here we re-fill \b da with zeros and assign \b dv to a component of \b da.
1242 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple3_3
1249 Below more two variants of location of target values are shown.
1250 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple3_4
1258 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValuesSimple3_5
1265 \note \ref ParaMEDMEM::DataArrayInt::setPartOfValuesSimple3() can't
1266 be explicitly called in Python.
1269 \anchor cpp_mcdataarrayint_setpartofvalues2
1270 <br><h3> setPartOfValues2() </h3>
1271 We create two arrays:
1272 - a "large" (4x7) zero array \b da to assign to,
1273 - a smaller (3x2) array \b dv filled with values [7,8,9,10,11,12].
1275 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues2_1
1276 Now we assign the two components of \b dv to the components of \b da
1277 with indices [1,3], and the 3 tuples of \b dv to the 3 tuples of \b da with
1278 indices [0,1,2]. This is the first mode of usage.
1279 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues2_2
1280 As result contents of the array \b da are as follows.
1282 Tuple #0 : 0 7 0 8 0 0 0
1283 Tuple #1 : 0 9 0 10 0 0 0
1284 Tuple #2 : 0 11 0 12 0 0 0
1285 Tuple #3 : 0 0 0 0 0 0 0
1287 Every value of \b dv has been assigned to its own location within \b da.
1289 Now we re-fill \b da with zeros and rearrange \b dv to have 6 components.
1290 And we assign \b dv to the tuples of \b da with indices [0,2,3] .
1291 This is the second mode of usage.
1292 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues2_3
1293 The contents of \b dv have been assigned to each of specified tuples of \b da.
1294 Every value of \b dv is repeated in the 3 specified tuples within \b da.
1296 Tuple #0 : 7 0 8 9 10 11 12
1297 Tuple #1 : 0 0 0 0 0 0 0
1298 Tuple #2 : 7 0 8 9 10 11 12
1299 Tuple #3 : 7 0 8 9 10 11 12
1301 \note \ref ParaMEDMEM::DataArrayInt::setPartOfValues2() can't
1302 be explicitly called in Python.
1305 \anchor cpp_mcdataarrayint_setpartofvalues3
1306 <br><h3> setPartOfValues3() </h3>
1307 We create two arrays:
1308 - a "large" (4x7) zero array \b da to assign to,
1309 - a smaller (3x2) array \b dv filled with values [7,8,9,10,11,12].
1311 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues3_1
1312 Now we assign the two components of \b dv to the components of \b da
1313 with indices [1,3], and the 3 tuples of \b dv to the 3 tuples of \b da with
1314 indices [0,1,2] which are specified using slicing: "0:3".
1315 This is the first mode of usage.
1316 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues3_2
1317 As result contents of the array \b da are as follows.
1319 Tuple #0 : 0 7 0 8 0 0 0
1320 Tuple #1 : 0 9 0 10 0 0 0
1321 Tuple #2 : 0 11 0 12 0 0 0
1322 Tuple #3 : 0 0 0 0 0 0 0
1324 Every value of \b dv has been assigned to its own location within \b da.
1326 Now we re-fill \b da with zeros and rearrange \b dv to have 6 components.
1327 And we assign \b dv to the tuples of \b da with indices [0,2] using \a
1328 slice notation "0:4:2". This is the second mode of usage.
1329 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayInt_setPartOfValues3_3
1330 The contents of \b dv have been assigned to each of specified tuples of \b da.
1331 Every value of \b dv is repeated in the 3 specified tuples within \b da.
1333 Tuple #0 : 7 0 8 9 10 11 12
1334 Tuple #1 : 0 0 0 0 0 0 0
1335 Tuple #2 : 7 0 8 9 10 11 12
1336 Tuple #3 : 0 0 0 0 0 0 0
1338 \note \ref ParaMEDMEM::DataArrayInt::setPartOfValues3() can't
1339 be explicitly called in Python.
1342 \anchor cpp_mcdataarraydouble_getdifferentvalues
1343 <br><h2> Excluding coincident tuples from DataArrayDouble</h2>
1345 The code below creates an array of real values and than an array of
1346 unique values, not closer one to another than 0.2, is retrieved from it.
1347 \snippet MEDCouplingExamplesTest.py Snippet_DataArrayDouble_getDifferentValues1
1350 \anchor cpp_mcdataarraydouble_findcommontuples
1351 <br><h2> Finding coincident tuples in DataArrayDouble</h2>
1353 Let's create an array of 6 tuples and 2 components that can be
1354 considered as coordinates of 6 points in 2D space.
1355 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayDouble_findCommonTuples1
1356 Now we find points that are not far each from other than 1e-1.
1357 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayDouble_findCommonTuples2
1358 As we can realize from the above code, a hardcoded array \b expected3 is equal
1359 to the raw data of a DataArrayInt \b c and a hardcoded array \b expected4 is equal
1360 to the raw data of the DataArrayInt \b cI.
1362 The array \b c contains indices of 5 coincident points. The array \b
1363 cI shows us boundaries of (cI->getNumberOfTuples()-1) = 2 groups of coincident points:
1364 - The first group starts at index 0 and includes (3 - 0) = 3 points: 0,3,4.
1365 - The second group starts at index 3 and includes (5 - 3) = 2 points: 1,2.
1367 \anchor cpp_mcdataarraydouble_meldwith
1368 <br><h2> Concatenating DataArrayDouble's by appending components </h2>
1370 In this example we create two data arrays including \b same number of
1371 tuples and then we concatenate them using \ref
1372 ParaMEDMEM::DataArrayDouble::meldWith "meldWith()".
1373 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayDouble_Meld1_1
1374 Now the array \b da1 includes 7 tuples (as before) of 3 components
1375 each. Its components are: "c0da1","c1da1","c0da2".
1378 \anchor cpp_mcdataarrayint_meldwith
1379 <br><h2> Concatenating DataArrayInt's by appending components </h2>
1381 In this example we create two data arrays including \b same number of
1382 tuples and then we concatenate them using \ref
1383 ParaMEDMEM::DataArrayInt::meldWith "meldWith()".
1384 \snippet MEDCouplingExamplesTest.cxx CppSnippet_DataArrayInt_Meld1_1
1385 Now the array \b da1 includes 7 tuples (as before) of 3 components
1386 each. Its components are: "c0da1","c1da1","c0da2".
1389 \anchor cpp_mcdataarraydouble_KeepSelectedComponents
1391 <br><h2>Creation of a sub-part of the DataArrayDouble by selecting components</h2>
1393 \snippet MEDCouplingExamplesTest.py SnippeDataArrayDoubleKeepSelectedComponents1_1
1394 We created an array \b a1 containing 5 tuples of 4 components each (20
1395 values). Now we are going to create an array \b a2 containing some
1396 components of \b a1.
1397 \snippet MEDCouplingExamplesTest.py SnippeDataArrayDoubleKeepSelectedComponents1_2
1398 Now each tuple of \b a2 includes components named "b","c","b","c","a","a". Thus
1399 the result array \b a2 includes 30 elements (5 tuples per 6 components).
1401 \anchor cpp_mcfielddouble_subpart1
1403 \anchor cpp_mcdataarrayint_keepselectedcomponents
1405 <br><h2>Creation of a sub-part of the DataArrayInt by selecting components</h2>
1407 \snippet MEDCouplingExamplesTest.py SnippeDataArrayIntKeepSelectedComponents1_1
1408 We created an array \b a1 containing 5 tuples of 4 components each (20
1409 values). Now we are going to create an array \b a2 containing some
1410 components of \b a1.
1411 \snippet MEDCouplingExamplesTest.py SnippeDataArrayIntKeepSelectedComponents1_2
1412 Now each tuple of \b a2 includes components named "b","c","b","c","a","a". Thus
1413 the result array \b a2 includes 30 elements (5 tuples per 6 components).
1416 \ref ParaMEDMEM::DataArrayInt::keepSelectedComponents() "DataArrayInt::keepSelectedComponents()"
1417 is called, providing the same result, by the following python code:
1418 \snippet MEDCouplingExamplesTest.py SnippeDataArrayIntKeepSelectedComponents1_3
1420 \anchor cpp_mcfielddouble_subpart1
1423 <br><h2>Creation of a sub part of a field</h2>
1424 <br><h3>Creation of a sub part of a field on cells</h3>
1425 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuildSubPart1_1
1426 The field on cells \b f1 lies on a mesh containing 5 cells and 9 nodes.
1427 So this field \b f1 contains 5 tuples of 2 components each (10 values).
1428 Now let's create a subfield on cells \b f2 from \b f1.
1429 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuildSubPart1_2
1431 \b f1 is a field on cells, \ref ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart "buildSubPart" method performs an extraction on cells too.
1433 So the array \b part1 lists ids on cells.
1435 - cell #0 of \b f2 is the same cell of cell #2 of \b f1
1436 - cell #1 of \b f2 is the same cell of cell #1 of \b f1
1437 - cell #2 of \b f2 is the same cell of cell #4 of \b f1
1439 So \b f2 contains 3 tuples with 2 components.
1441 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).
1442 \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).
1443 \nOnly fields on cells have this particular behaviour.
1445 <br><h3>Creation of a sub part of a field on nodes</h3>
1446 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuildSubPart1_3
1447 The field on nodes \b f1 lies on a mesh containing 5 cells and 9 nodes.
1448 So this field \b f1 contains 9 tuples of 2 components each (18 values).
1449 Now let's create a subfield on nodes \b f2 from \b f1.
1450 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuildSubPart1_4
1452 \b f1 is a field on nodes, but \ref ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart "buildSubPart" method performs an extraction on \b cells.
1454 After the call of \ref ParaMEDMEM::MEDCouplingFieldDouble::buildSubPart "buildSubPart" on node field \b f1, \b f1 will be reduced on a
1455 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.
1456 \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"
1457 method does not match the size of the input array (here \b part2).
1462 \page medcouplingcppexamplesUmeshStdBuild1 <br><h1> Example of standard build of an unstructured mesh from scratch in C++ </h1>
1464 Firstly retrieve basic data in full interlace mode for coordinates, and nodal connectivity cell per cell.
1465 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_1
1467 Then create ParaMEDMEM::MEDCouplingUMesh instance giving its meshdimension (2 here) and a name.
1469 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_2
1471 Gives an upper bound of the number of cells to be inserted into the unstructured mesh.
1472 \n Then enter nodal connectivity of all cells, cell per cell using ParaMEDMEM::MEDCouplingUMesh::insertNextCell method.
1473 \n When the nodal connectivity cell per cell has been finished, call ParaMEDMEM::MEDCouplingUMesh::finishInsertingCells method in order to restore \b mesh instance.
1475 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_3
1477 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.
1479 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_4
1481 At this level mesh is usable. When this mesh is no more needed simply call decrRef to decrement its reference counter.
1483 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshStdBuild1_5
1488 \page medcouplingcppexamplesUmeshAdvBuild1 <br><h1> Example of advanced build of an unstructured mesh from scratch in C++ </h1>
1490 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).
1491 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_1
1493 Then create ParaMEDMEM::MEDCouplingUMesh instance giving its meshdimension (2 here) and a name.
1495 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_2
1497 Then enter nodal connectivity at once.
1499 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_3
1501 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.
1503 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_4
1505 At this level mesh is usable. When this mesh is no more needed simply call decrRef() to decrement its reference counter.
1507 \snippet MEDCouplingExamplesTest.cxx CppSnippetUMeshAdvBuild1_5
1512 \page medcouplingcppexamplesCmeshStdBuild1 <br><h1> Example of standard build of an cartesian mesh from scratch in C++ </h1>
1514 We are going to build a 2D cartesian mesh, constituted from 9 nodes along X axis, and 7 nodes along Y axis.
1516 Firstly retrieve for each direction the discretization and build a \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble instance" on the corresponding direction.
1518 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_1
1520 Then create ParaMEDMEM::MEDCouplingCMesh instance giving the 2 instances of \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble" obtained above.
1522 There are 2 techniques to get it.
1526 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_2
1530 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_2bis
1532 \c mesh is now available for use :
1534 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_3
1536 When this mesh is no more needed simply call decrRef to decrement its reference counter.
1538 \snippet MEDCouplingExamplesTest.cxx CppSnippetCMeshStdBuild1_4
1543 \page medcouplingcppexamplesFieldDoubleBuild1 <br><h1> Examples in C++ of standard build of a tensor field on cells with no time attached </h1>
1545 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild1_1
1550 \page medcouplingcppexamplesFieldDoubleBuild2 <br><h1> Examples in C++ of standard build of a scalar field on nodes with no time attached </h1>
1552 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild2_1
1557 \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>
1559 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild3_1
1564 \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>
1566 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild4_1
1571 \page medcouplingcppexamplesFieldDoubleBuild5 <br><h1> Examples in C++ of operation that can be carried out on fields on cells </h1>
1573 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild1_2
1575 The decrementation of ref counter should be carried out in CPlusPlus only ...
1577 \snippet MEDCouplingExamplesTest.cxx CppSnippetFieldDoubleBuild1_3