2 \page medcoupling MEDCoupling
4 \section MEDCouplingIntro Introduction
6 \ref medcoupling "MEDCoupling" is a library (\b libmedcoupling.so or \b medcoupling.dll) fully written in C++ and wrapped to be called in Python too.
8 \ref medcoupling "MEDCoupling" C++ library implements a data structure which is the result of the following tradeoff :
10 - Compliant with coupling :
11 - Fields definition defined enough to perform well defined interpolation
12 - exchangeable through process as well in parallel case in SPMD paradigm ( \ref paramedmem "ParaMEDMEM" ), as in distributed paradigm using CORBA.
13 - minimize as much as possible the number of prerequisites needed to use it ; So \ref medcoupling "MEDCoupling" only depends on
14 \ref interpkernel "INTERP_KERNEL library"
15 - light enough to be agile in order to :
16 - maximize the amount of algorithms being applied on it
17 - to ease implementation of clients of \ref medcoupling "MEDCoupling".
18 - large enough to be used for MED file I/O.
19 - compliant with VTK visualization DataStructure
20 - integrate HPC constraints (compact structures, limitation of copies and launching of CPU consuming algorithms only when absolutely needed ).
21 - compliant with ICOCO API
23 \ref medcoupling "MEDCoupling" implements a set of algorithms linked to the data structure.
25 \section MEDCouplingMainConc Main Concepts
27 Here are listed basic concepts present into \ref medcoupling "MEDCoupling".
29 For beginners in \ref medcoupling "MEDCoupling" world, it is advisable to read the following concepts in the same order than the underlying list.
31 - \subpage MEDCouplingArrayPage "DataArrays"
32 - \subpage MEDCouplingMeshesPage "Meshes"
33 - \subpage MEDCouplingFieldsPage "Fields"
34 - \subpage MEDCouplingFieldTemplatesPage "Field templates"
35 - \subpage MEDCouplingTimeLabelPage "Time labels"
40 \page MEDCouplingMeshesPage Meshes in MEDCoupling
42 \section MEDCouplingMeshes Common concept shared by all type of Meshes in MEDCoupling
44 A mesh has the following properties :
47 - **a dimension (called mesh dimension) and only one** (it implies that \b all cells constituting
48 mesh have the same dimension)
49 - a space dimension (relative to coordinates)
53 In MEDCoupling library there is no presence of faces nor edges.
55 As a mesh has one dimension and only once, that is to say every cells in
56 mesh have the same dimension called MeshDimension.
58 For example a mesh with a meshDimension equal to 1, have \b cells of type
59 NORM_SEG2. Another example, a mesh with a meshDimension equal
60 to 2, have \b cells of type
61 NORM_TRI3 and NORM_POLYGON for example.
63 The class that incarnates the concept described above is :
64 \ref ParaMEDMEM::MEDCouplingMesh.
66 \section MEDCouplingMeshesAvailInstan Available instantiable mesh types in MEDCoupling
68 - \subpage MEDCouplingUMeshPage "Unstructured meshes"
69 - \subpage MEDCouplingCMeshPage "Cartesian meshes"
70 - \subpage MEDCouplingExtrudedPage "3D Extruded meshes"
73 \page MEDCouplingFieldsPage Fields in MEDCoupling
77 \section MEDCouplingFields Field concept
79 A field in MEDCoupling point of view, is a structure that allows to
80 store a discretization of a physical value on a defined discretized spatial and
81 possibly temporal support.
83 The spatial support is a \ref MEDCouplingMeshesPage "mesh".
84 A field is lying on an entity that will be specified by the spatial
85 discretization of the field. For example a field on node will lie on
86 all nodes of its mesh.
88 A field on cell will lie on all cells of its mesh.
90 Fields in MEDCoupling follow the two following rules :
92 - A field will lie on \b ALL entities of its spatial support (\ref MEDCouplingMeshesPage "mesh").
93 - A field has \b only \b one spatial support (\ref MEDCouplingMeshesPage "mesh") on its temporal support.
95 The main properties of a field are :
98 - spatial support which is a \ref MEDCouplingMeshesPage "mesh"
99 - a \ref MEDCouplingSpatialDisc "spatial discretization"
100 - a description of intrinsic nature of the values of field (see \ref NatureOfField). This is important for conservative interpolation (see \ref TableNatureOfField).
101 - a temporal discretization that specifies, if it exists, the time interval on which the field is covering, and how.
102 - number of components
104 This definition of field in MEDCoupling allows an instance of field to
105 know at any point inside its spatial-temporal support the value.
107 The class that incarnates the concept described above is : \ref ParaMEDMEM::MEDCouplingFieldDouble.
109 Some of most important implemented methods are :
111 - \ref ParaMEDMEM::MEDCouplingFieldDouble::getNumberOfComponents "getNumberOfComponents"
112 - \ref ParaMEDMEM::MEDCouplingFieldDouble::getValueOn "getValueOn"
113 - \ref ParaMEDMEM::MEDCouplingFieldDouble::applyFunc "applyFunc"
114 - \ref ParaMEDMEM::MEDCouplingFieldDouble::addFields "cross instances operations"
115 \section MEDCouplingSpatialDisc Spatial discretization concept
117 This is the concept that makes the link, independently from temporal
118 discretization, between the field and its spatial support(\ref MEDCouplingMeshesPage "mesh"). This
119 concept allows the field to make a check and interpretation of an
120 array of values given a spatial support (\ref MEDCouplingMeshesPage "mesh").
122 The abstract class that incarnates the concept is : \ref ParaMEDMEM::MEDCouplingFieldDiscretization.
124 The most important pure virtual methods are :
126 - \ref ParaMEDMEM::MEDCouplingFieldDiscretization::getNumberOfTuples "getnumberOfTuples"
127 - \ref ParaMEDMEM::MEDCouplingFieldDiscretization::getValueOn "getValueOn"
128 - \ref ParaMEDMEM::MEDCouplingFieldDiscretization::getMeasureField "getMeasureField"
130 \section MEDCouplingTemporalDisc Temporal discretization concept
132 This information allows, independently from spatial discretization, to
133 associate a time interval, if it exists, on which the field will be
134 defined. This concept is able to give the value at any time of
135 the definition interval (if any).
137 The abstract class \ref ParaMEDMEM::MEDCouplingTimeDiscretization
138 incarnates this described concept.
140 This classes and its subclasses are responsible in storing the arrays
141 of the aggregating field.
143 The most important methods are :
145 - \ref ParaMEDMEM::MEDCouplingTimeDiscretization::setTime "setTime" and \ref ParaMEDMEM::MEDCouplingTimeDiscretization::getTime "getTime"
146 - \ref ParaMEDMEM::MEDCouplingTimeDiscretization::getArray "getArray" and \ref ParaMEDMEM::MEDCouplingTimeDiscretization::setArray "setArray"
147 - \ref ParaMEDMEM::MEDCouplingTimeDiscretization::getArraysForTime "getArraysForTime"
148 - \ref ParaMEDMEM::MEDCouplingTimeDiscretization::getValueForTime "getValueForTime"
150 \section MEDCouplingFirstSteps3 Building a field from scratch
152 Here we will make the assumption that an instance of \c MEDCouplingMesh called \c mesh has been created ( to know more about mesh creation \ref MEDCouplingUMeshStdBuild "click here" ).
154 \subsection MEDCouplingFirstSteps3OnCellsNoTS Create a tensor field with 9 components on cells with no time step
156 \subpage medcouplingcppexamplesFieldDoubleBuild1 "Here the C++ implementation."
158 \subpage medcouplingpyexamplesFieldDoubleBuild1 "Here the Python implementation."
160 \subsection MEDCouplingFirstSteps3OnNodesNoTS Create a scalar field on nodes with no time step
162 \subpage medcouplingcppexamplesFieldDoubleBuild2 "Here the C++ implementation."
164 \subpage medcouplingpyexamplesFieldDoubleBuild2 "Here the Python implementation."
166 \subsection MEDCouplingFirstSteps3OnCellsWTS Create a 2 components-vector field on cells with one time step and no interval
168 \subpage medcouplingcppexamplesFieldDoubleBuild3 "Here the C++ implementation."
170 \subpage medcouplingpyexamplesFieldDoubleBuild3 "Here the Python implementation."
172 \subsection MEDCouplingFirstSteps3OnCellsCTI Create a 3 components-vector field on nodes with a time interval where field remains constant on this time interval
174 \subpage medcouplingcppexamplesFieldDoubleBuild4 "Here the C++ implementation."
176 \subpage medcouplingpyexamplesFieldDoubleBuild4 "Here the Python implementation."
178 \section MEDCouplingSecondStep0 Operations on Fields
180 Here we will make the assumption that an instance of \ref ParaMEDMEM::MEDCouplingMesh "MEDCouplingMesh"
181 called \c mesh has been created with spaceDim==2.
183 \subpage medcouplingcppexamplesFieldDoubleBuild5 "Here a C++ example of more advanced use of MEDCouplingFieldDouble instances".
185 \subpage medcouplingpyexamplesFieldDoubleBuild5 "Here a Python example of more advanced use of MEDCouplingFieldDouble instances".
191 \page MEDCouplingArrayPage MEDCoupling Arrays
195 \section MEDCouplingArrayIntro Introduction
197 One of the most basic concept mainly used all over MEDCoupling is
200 This concept is used all over
201 \ref medcoupling "MEDCoupling", \ref paramedmem "ParaMEDMEM", \ref medloader "MEDLoader" modules so it should be correctly
202 handled to play well with \ref MEDCouplingMeshesPage "Meshes" and \ref MEDCouplingFieldsPage "Fields".
204 \ref ParaMEDMEM::DataArray "DataArrays" are the atomic element of potentially heavy in memory objects in \ref medcoupling "MEDCoupling", \ref paramedmem "ParaMEDMEM" and \ref medloader "MEDLoader".
206 There are for the moment two types of arrays :
207 - double precision float (64 bits) array incarnated by \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble class".
208 - signed integer (32 bits) array incarnated by \ref ParaMEDMEM::DataArrayInt "DataArrayInt class".
210 \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble" and \ref ParaMEDMEM::DataArrayInt "DataArrayInt" classes inherits from
211 \ref ParaMEDMEM::DataArray "DataArray" \b non \b instanciable \b class that factorizes some common methods of inherited instanciable classes.
213 In the rest of the documentation \b DataArray will be used for both \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble" and \ref ParaMEDMEM::DataArrayInt "DataArrayInt".
215 \section MEDCouplingArrayBasics Basics concepts of the DataArrays.
217 It will be presented in this section common concept shared by the two classes to \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble" and \ref ParaMEDMEM::DataArrayInt "DataArrayInt".
219 \subsection MEDCouplingArrayBasicsName Name
221 A \ref ParaMEDMEM::DataArray "DataArray" instance has an attribute **name**.
223 **name** is particularly useful for \ref ParaMEDMEM::DataArray "DataArray" representing profiles, families, groups, fields in MEDLoader.
224 But excepted these useful usecases, **name** attribute is often ignored when \ref ParaMEDMEM::DataArray "DataArrays" are aggregated (field array, connectivity, coordinates) in a bigger object.
225 Whatever the usage of the **name** attribute of \ref ParaMEDMEM::DataArray "DataArrays", all methods in ParaMEDMEM::DataArrayDouble and ParaMEDMEM::DataArrayInt class deal with **name** as they do for components names.
227 \subsection MEDCouplingArrayBasicsTuplesAndCompo Raw data, tuples and components of DataArrays.
229 The main goal of \ref ParaMEDMEM::DataArray "DataArray" is to store contiguous vector of atomical elements with same basic datatype (signed integers, double precision...). This vector of atomical elements is called **raw data** of \ref ParaMEDMEM::DataArray "DataArray".
231 The size of this vector of data is called <em>"number of elements"</em>. So the number of bytes stored by a \ref ParaMEDMEM::DataArray "DataArray" instance, is equal to
232 the product of the __number of elements__ * __constant size of DataType__ .
234 As \ref ParaMEDMEM::DataArray "DataArray" instances are designed to store vector fields, tensor fields, coordinate of nodes, the notion of _components_ has been added.
236 So, \ref ParaMEDMEM::DataArray "DataArrays" have an additional attribute that is number of components that represent the size of a contiguous set of atomical elements.
237 The vector of atomical elements stored into \ref ParaMEDMEM::DataArray "DataArrays" are grouped in contiguous memory set of atomical elements having each same size.
239 The contiguous set of atomical elements is called **tuple**. And each **tuple** stored in raw data, have each a length exactly equal to the number of components of
240 \ref ParaMEDMEM::DataArray "DataArray" storing it.
245 N_{elements}=N_{tuples}*N_{components}.
249 N_{bytes}=N_{elements}*sizeof(DataType)=N_{tuples}*N_{components}*sizeof(DataType).
252 In other words, **raw data** of \ref ParaMEDMEM::DataArray "DataArrays" can be seen as a dense matrix, whose number of components would be the row size and number of tuples
253 would be the column size. In this point of view of \ref ParaMEDMEM::DataArray "DataArrays" a **tuple** is represented by the corresponding row in the dense matrix.
255 Typically in the **raw data** of \ref ParaMEDMEM::DataArray "DataArrays" **number of tuples** is highly bigger than **number of components** !
257 To finish, raw data is stored tuples by tuples, in another words, in **full interlace mode**, which is the natural storage strategy in C/C++ world.
259 For example, let's consider a DataArray having 3 components (called *x* for the first component, *y* for the second, and *z* for the third) and composed by 5 tuples.
260 \n The *raw data* of the DataAarray instance will be organized in momory like that : \f$ x_0,y_0,z_0,x_1,y_1,z_1,x_2,y_2,z_2,x_3,y_3,z_3,x_4,y_4,z_4 \f$.
263 \subsection MEDCouplingArrayBasicsCompoName Information on components name.
265 As seen in the sub section above, a \ref ParaMEDMEM::DataArray "DataArray" instance has a defined number of components.
267 There is an information attached to each of these components constituting the \ref ParaMEDMEM::DataArray "DataArray".
269 This information is concretely a string of characters that allows, if needed, to give information about the corresponding component.
271 The format chosen in **MEDCoupling** for information on is "MY_COMPO_INFO [MYUNIT]". If needed, the unit attached to the component
272 should be put between "[" and "]" after the information of the components after one space character.
274 \subsection MEDCouplingArrayBasicsTimeLabel DataArrays and TimeLabel.
276 \ref ParaMEDMEM::DataArray "DataArrays instances" can consume big amount of data in memory so they inherit from \subpage MEDCouplingTimeLabelPage "TimeLabel".
277 So in C++ it is a good practice to use :
278 - \c getConstPointer method in readonly access.
279 - \c getPointer method only if write is needed.
281 If the user in C++ or Python wants to modify intensively its **big** \ref ParaMEDMEM::DataArray "DataArray" instance **not** using raw data pointer it is better to invoke
282 \c setIJSilent just after invokation of \c declareAsNew instead of calling \c setIJ method that will increment time label of \ref ParaMEDMEM::DataArray "DataArray" instance
285 \c setIJ method usage should be reduced to little modification sessions.
287 \section MEDCouplingArraySteps0 Building an array from scratch in Python
289 \subsection MEDCouplingArraySteps0Double Building an double array from scratch in Python
291 Let's consider a list of floats \c dataDouble.
293 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayBuild1_0
295 The easiest way to build the \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble instance" called \c arrayDouble simply call :
297 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayBuild1_1bis
299 An another way is to do that :
301 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayBuild1_1
303 \subsection MEDCouplingArraySteps0Int Building an int array from scratch in Python
305 Let's consider a list of ints \c dataInt.
307 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayBuild1_2
309 The easiest way to build the \ref ParaMEDMEM::DataArrayInt "DataArrayInt instance" called \c arrayInt simply call :
311 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayBuild1_3bis
313 An another way is to do that :
315 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayBuild1_3
318 \section MEDCouplingArraySteps1 Building an array from scratch in C++
320 Here is a description of typical usages of \ref ParaMEDMEM::DataArrayDouble "MEDCoupling arrays".
322 In this example we will create arrays with 12 tuples constituted each
323 of 3 components. These arrays will be created using different ways.\n
325 The following code is only based using \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble"
326 but the use of \ref ParaMEDMEM::DataArrayInt "DataArrayInt" is strictly equivalent.
328 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_0
330 \subsection MEDCouplingArraySteps1NCNO Building an array from scratch in C++, no copy no ownership
332 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_1
334 \subsection MEDCouplingArraySteps1NCWCPPO Building an array from scratch in C++, no copy with C++ ownership
336 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_2
338 \subsection MEDCouplingArraySteps1NCWCO Building an array from scratch in C++, no copy with C ownership
340 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_3
342 \subsection MEDCouplingArraySteps1WC Building an array from scratch in C++, with copy
344 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_4
346 \section MEDCouplingArrayBasicsCopy Copy DataArrays.
348 As \ref ParaMEDMEM::DataArray "DataArrays" are the atomic entity of potentially big memory objects into \ref medcoupling "MEDCoupling"
349 , \ref ParaMEDMEM::DataArray "DataArrays" introduces concepts of copy and comparison that will be used by aggregating classes.
351 For more complex objects (that aggregate themselves big objects)
352 like ParaMEDMEM::MEDCouplingFieldDouble the concept of copy (shallow or deep) is less straight forward because which aggregated subobjects are copied or not.
354 \subsection MEDCouplingArrayBasicsCopyDeep Deep copy of DataArray
356 As for all potentially heavy memory consumer objects in \ref medcoupling "MEDCoupling", \ref ParaMEDMEM::DataArray "DataArrays" implement
357 method \c deepCpy. This method deeply copies an instance. The life cycle of the returned object is *fully* independent from the instance on which the method
358 \c deepCpy has been invoked.
360 To perform a deep copy of a DataArray instance simply invoke :
362 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_5
366 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_5bis
368 \c myCoordsCpy is the deep copy of \c myCoords so they are independent and their *raw data* has been deeply copied.
370 So it leads to the following behaviour :
371 \anchor MEDCouplingArrayBasicsCopyDeepTestEqual
373 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_6
375 As \c myCoordsCpy is a copy object it needs to be deallocated in C++ like \c myCoords.
377 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_7
379 \subsection MEDCouplingArrayBasicsCopyShallow Shallow copy of DataArray
381 As \ref ParaMEDMEM::DataArray "DataArrays" are the atomic entity of potentially big memory objects into \ref medcoupling "MEDCoupling", the shallow copy
382 simply returns the same object with the reference counter incremented.
384 To perform a shallow copy of a DataArray instance simply invoke :
386 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_8
388 \c myCoordsCpy is the shallow copy of \c myCoords so they share the same *raw data*. In reality they are the same object.
389 So it leads to the following behaviour to compare with the deep copy :
391 \anchor MEDCouplingArrayBasicsCopyShallowTestEqual
393 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_9
395 So here the content of \c myCoords and \c myCoordsCpy are linked, contrary to the deep copy case.
397 As \c myCoordsCpy is a copy object, in C++, it needs to be deallocated.
399 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_10
401 \subsection MEDCouplingArrayBasicsCopyDeepAssign Assignation by deep copy of DataArray
403 We start by building a instance of ParaMEDMEM::DataArrayDouble allocated or not. Here, instance is not allocated, only built empty.
405 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_11
407 Then, \c myCoordsCpy is assigned with the content of \c myCoords.
409 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_12
411 Then \c myCoordsCpy is a deep copy of \c myCoords except that the instance of ParaMEDMEM::DataArrayDouble is those specified.
412 But the behaviour is the same than those seen for \ref MEDCouplingArrayBasicsCopyDeepTestEqual "deep copy".
414 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_13
416 As always, in C++, \c myCoordsCpy is an object whose life cycle is fully independent from \c myCoords so decrement is needed.
418 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_14
420 \section MEDCouplingArrayBasicsCompare Compare DataArrays.
422 Comparison is \ref medcoupling "MEDCoupling" is a concept highly sensitive because big amount of tests uses this to state about the sucess or the fail of these tests.
423 There are two types of comparison :
425 - strict, that compares strictly all the non mutable attributes (state sensitive). Methods to perform this strict comparison are :
426 - ParaMEDMEM::DataArrayInt::isEqual
427 - ParaMEDMEM::DataArrayDouble::isEqual.
429 - less strict, that focus only on non string attributes. Methods to perform less strict comparison are :
430 - ParaMEDMEM::DataArrayInt::isEqualWithoutConsideringStr
431 - ParaMEDMEM::DataArrayDouble::isEqualWithoutConsideringStr
433 \section MEDCouplingArrayFill Filling DataArray with values
435 Both DataArrayDouble and DataArrayInt provide comfort methods that
436 fill the array with some values. These methods are:
437 - ParaMEDMEM::DataArrayInt::fillWithZero and
438 ParaMEDMEM::DataArrayDouble::fillWithZero which assigns zero to all
440 - ParaMEDMEM::DataArrayInt::fillWithValue and
441 ParaMEDMEM::DataArrayDouble::fillWithValue which assigns a certain value to all
443 - ParaMEDMEM::DataArrayInt::iota() and
444 ParaMEDMEM::DataArrayDouble::iota() which assigns incrementing values to all
447 \section MEDCouplingArrayRenumbering Array renumbering
449 Here is presented all it is necessary to know concerning renumbering.
450 Renumbering is intensely required in %MEDLoader in %ParaMEDMEM. One of the user of renumbering is MED file for I/O where cells are sorted by type.
451 But it is also used on operations of node cell merging. It is also used in parallel mode when splitting of mesh is needed...
453 Formally a renumbering is a mathematical application that can be surjective, injective or bijective. This application is defined using an instance of
454 \ref ParaMEDMEM::DataArrayInt "DataArrayInt". There are different ways to define this application.
456 \subsection MEDCouplingArrayRenumberingO2N Old to new mode
458 The old to new mode is particularly recommended for surjective and bijective application. This is typically the case of \ref ParaMEDMEM::MEDCouplingUMesh::mergeNodes "MEDCouplingUMesh::mergeNodes" method.
459 Let's consider a call to \ref ParaMEDMEM::MEDCouplingUMesh::mergeNodes "mergeNodes" that reduces the number of nodes from 5 nodes to 3 nodes.\n
460 In old to new mode the array \b MySurjection that specifies this surjection will have 5 tuples and 1 component. The content of the 5*1 values will be in {0,1,2}.\n
462 If \b MySujection equals [2,1,0,1,2], it means that :
464 - old id #0 will have new id equal to 2
465 - old id #1 will have new id equal to 1
466 - old id #2 will have new id equal to 0
467 - old id #3 will have new id equal to 1 like old id #1
468 - old id #4 will have new id equal to 2 like old id #0
470 This is the most common mode of renumbering in MEDCoupling because there is more methods implying renumbering that reduce the number of entities than method that increase number of entities.
472 Method in old to new mode that works on bijective applications :
474 - \ref ParaMEDMEM::DataArrayDouble::renumber "DataArrayDouble::renumber"
475 - \ref ParaMEDMEM::DataArrayDouble::renumberInPlace "DataArrayDouble::renumberInPlace"
477 Method in old to new mode that works on surjective applications :
479 - \ref ParaMEDMEM::DataArrayDouble::renumberAndReduce "DataArrayDouble::renumberAndReduce"
481 Sometimes the format old to new for surjections can be replaced by another format with 2 arrays. Less compact in memory. The \ref ParaMEDMEM::DataArrayInt::changeSurjectiveFormat "DataArrayInt::changeSurjectiveFormat" method performs that.
483 \subsection MEDCouplingArrayRenumberingN2O New to old mode
485 The new to old mode is particularly recommended for strictly injective and bijective permutations. This is particularly useful for methods that increase the number of entities like for example
486 \ref ParaMEDMEM::MEDCouplingUMesh::simplexize "MEDCouplingUMesh::simplexize".\n
487 All non static methods in \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble" or \ref ParaMEDMEM::DataArrayInt "DataArrayInt" having as last letter \b R (meaning Reversed) in capital works with
489 Let's consider a call to \ref ParaMEDMEM::MEDCouplingUMesh::simplexize "simplexize" that increases the number of cell from 4 cells to 6 cells.\n
490 In new to old mode the array \b MyInjection that specifies this injection will have 6 tuples and 1 component. The content of the 5*1 values will be in {0,1,2,3}.\n
491 If \b MyInjection equals [2,0,1,1,3,0] it means that :
493 - new id #0 comes from old id 2
494 - new id #1 comes from old id 0
495 - new id #2 comes from old id 1
496 - new id #3 comes from old id 1
497 - new id #4 comes from old id 3
498 - new id #5 comes from old id 0
500 Method in new to old mode that works on bijective applications :
502 - \ref ParaMEDMEM::DataArrayDouble::renumberR "DataArrayDouble::renumberR"
503 - \ref ParaMEDMEM::DataArrayDouble::renumberInPlace "DataArrayDouble::renumberInPlaceR"
505 Method in new to old mode that works on surjective applications :
507 - \ref ParaMEDMEM::DataArrayDouble::selectByTupleId "DataArrayDouble::selectByTupleId"
508 - \ref ParaMEDMEM::DataArrayDouble::selectByTupleIdSafe "DataArrayDouble::selectByTupleIdSafe"
509 - \ref ParaMEDMEM::DataArrayDouble::selectByTupleId2 "DataArrayDouble::selectByTupleId2"
510 - \ref ParaMEDMEM::DataArrayDouble::selectByTupleRanges "DataArrayDouble::selectByTupleRanges"
512 \section MEDCouplingArrayApplyFunc Application of a function on DataArrayDouble instances.
514 This section is only dedicated for \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble instances".
516 It is possible to apply to \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble instance" a function given by a string.
518 There are different API for applyFunc* methods of \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble class".
520 \subsection MEDCouplingArrayApplyFuncExpr Expressions supported
522 In order to reduce as much as possible dependencies, a little dynamic formula interpretor has been developed into INTERP_KERNEL.
523 This dynamic expression evaluator can deal the following exhaustive list :
525 - +,-,*,^ (^ for exponent 3^2==9)
526 - sin,cos,tan,sqrt,abs,exp,max,min,ln (neper logarithm), log (neper logarithm), log10 (decimal logarithm),
530 The expression evaluator is also sensitive to the following var pattern : IVec, JVec, KVec, LVec,... ,ZVec
532 - IVec stands for unitary vector [1,0,0,0,...]
533 - JVec stands for unitary vector [0,1,0,0,...]
534 - KVec stands for unitary vector [0,0,1,0,...]
537 The dynamic expression evaluator works tuple by tuple through the *raw data* of DataArrayDouble instance.
539 The principle of the dynamic expression evaluator is the following :
541 - Given the input string a compilation tree is built whose leaves are either constants or variables.
542 At this phase only syntax errors are thrown.
543 \anchor MEDCouplingArrayApplyFuncExprA1
544 - Then given the computed tree, a link phase is performed to accelerate evaluation. At this phase the incoherence between the number of
545 components and the number of variables are detected.
547 - The given the preprocessed tree given an input tuple a preallocated tuple is fed with the result of the evaluation.
548 At this last phase only mathematical errors are thrown (division by 0, log(0), sqrt of a negative number ...)
550 \subsection MEDCouplingArrayApplyFunc0 applyFunc method with only one parameter
552 This method produces a newly allocated DataArrayDouble instance having exactly the same number of components **and** number of tuples than the instance on which the
553 \ref ParaMEDMEM::DataArrayDouble::applyFunc(const char *) const applyFunc method is applied.
555 **This method is useful when the evaluation expression do not need to consider the components of each tuple separately**.
557 That's why this method of \ref ParaMEDMEM::DataArrayDouble::applyFunc(const char *) const applyFunc method with one parameter accepts at most only one variable.
559 If it is not the case an exception is thrown as seen here :
561 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayApplyFunc1_1
563 Let's take a very simple example on a DataArrayDouble instance \c d having 4 tuples and 2 components.
565 In the next example the expression contains only one variable : \c smth.
566 So \c smth represent a tuple of size 2.
568 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayApplyFunc1_2
570 As the example shows, the output \c d1 has 2 components as \c d.
572 Whereas all the components of the input of \c d be not considered separately, it is also, possible with \ref ParaMEDMEM::DataArrayDouble::applyFunc(const char *) const applyFunc method with one parameter
573 to build an output having same number of components than input but where components in input are treated separately.
575 Let's build an example using DataArrayDouble instance \c d defined just above.
577 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayApplyFunc1_3
579 In this example using IVec and JVec it is possible to differentiate output in component #0 and output in component #1 for DataArrayDouble instance \c d2.
581 \subsection MEDCouplingArrayApplyFunc1 applyFunc method with only two parameters
583 This method also returns a newly allocated DataArrayDouble instance having the same number of tuples than the DataArrayDouble instance on which \ref ParaMEDMEM::DataArrayDouble::applyFunc(int,const char *) const applyFunc method is called, but the contrary to previous \ref MEDCouplingArrayApplyFunc0 "applyFunc with one parameter version" here the number of components is set by the user.
585 The big difference with \ref MEDCouplingArrayApplyFunc0 "applyFunc method with one parameter" seen above is that here components of tuples are treated separately.
587 The method that implements it is \ref ParaMEDMEM::DataArrayDouble::applyFunc(int,const char *) const here.
589 Here the number of variables appearing in the expression should be equal at most to the number of component of the DataArrayDouble instance on which \ref ParaMEDMEM::DataArrayDouble::applyFunc(int,const char *) const applyFunc method is called.
591 Let's consider the following DataArrayDouble having 4 tuples with 3 components called dd.
593 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayApplyFunc1_4
595 If you intend to create a new DataArrayDouble instance called \c dd1 having only one component that is the result of the sum of first component and the square root of the second component and the third component
596 the invocation should be something like this :
598 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayApplyFunc1_5
600 \warning In the expression \c "f+sqrt(g)+h", there are 3 variables \c {"g","h","f"}. As seen \ref MEDCouplingArrayApplyFuncExprA1 "in link phase in expression evaluator" it is needed to match a variable to
601 the component id. The strategy of expression evaluator is the following. Sort ascendingly variables using their names and affect component id following this sorted list. It leads to :
602 - \c f will be attached to component #0 of \c dd
603 - \c g will be attached to component #1 of \c dd
604 - \c h will be attached to component #2 of \c dd
606 Considering the previous warning, let's try to perform an application of function to compute in a DataArrayDouble instance called \c dd2 starting by adding component #0 and component #2
608 \nThe expression \c "a+c" will add component #0 to component #1 as seen in warning section !!!! It can appear silly, but this strategy has been chosen in order to support different set of variables.
609 \n \ref ParaMEDMEM::DataArrayDouble::applyFunc2 "applyFunc2" and \ref ParaMEDMEM::DataArrayDouble::applyFunc3 "applyFunc3" methods have been developed to remedy to that feature that can be surprising.
610 \n These two methods are explained respectively \ref MEDCouplingArrayApplyFunc2 "here for applyFunc2" and \ref MEDCouplingArrayApplyFunc3 "here for applyFunc3".
612 Whatever it is possible to find a workaround using \ref ParaMEDMEM::DataArrayDouble::applyFunc(int,const char *) const applyFunc with 2 parameters.
613 \n Here is a solution to compute \c dd2 :
615 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayApplyFunc1_6
617 \subsection MEDCouplingArrayApplyFunc2 applyFunc2 method
619 The method that implements it is \ref ParaMEDMEM::DataArrayDouble::applyFunc2 here.
621 This method is very close to \ref MEDCouplingArrayApplyFunc1 "applyFunc method with only two parameters".
623 The only different is the mapping between variables found in expression and tuple id. Rather than using rank in string sorting as \ref MEDCouplingArrayApplyFunc1 "applyFunc method with only two parameters uses" here the component information are considered.
625 Let's consider DataArrayDouble instance \c ddd constituted with 4 tuples containing each 3 components. The components are named respectively \c {"Y","AA","GG"} with following different units attached on them.
627 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayApplyFunc1_7
629 To compute the sum of the first component (component #0) and the third component (component #2) simply do that :
631 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayApplyFunc1_8
633 \subsection MEDCouplingArrayApplyFunc3 applyFunc3 method
635 The method that implements it is \ref ParaMEDMEM::DataArrayDouble::applyFunc3 here.
637 This method is very close to \ref MEDCouplingArrayApplyFunc1 "applyFunc method with only two parameters" and \ref MEDCouplingArrayApplyFunc2 "applyFunc2".
639 The only different is the mapping between variables found in expression and tuple id. Rather than using rank in string sorting as in \ref MEDCouplingArrayApplyFunc1 "applyFunc method with only two parameters uses" or the component information as in \ref MEDCouplingArrayApplyFunc2 "applyFunc2", here an explicit vector is given in input.
641 Let's consider DataArrayDouble instance \c ddd constituted with 4 tuples containing each 3 components. To add first component (component #0) and the third component (component #2) simply do that :
643 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayApplyFunc1_9
648 \defgroup NatureOfField Nature of a field
650 \section IntExtFields Overview: intensive and extensive field
652 \c NatureOfField is an enum which helps determining some physical significance of the field and affects the choice of the interpolation formula (see \ref TableNatureOfField).
653 It has five possible values:
654 - "NoNature", the default value, does not allow the use of any interpolation tools
656 - \ref TableNatureOfFieldExampleConservVol "ConservativeVolumic", for intensive field with the maximum principle favored over conservativity. Relevant for temperature, pressure fields.
658 - \ref TableNatureOfFieldExampleRevIntegral "RevIntegral", for intensive field with the conservativity favored over maximum principle. Relevant for power density fields.
660 - \ref TableNatureOfFieldExampleIntegral "Integral", for extensive field with the maximum principle favored over conservativity. Relevant for power fields.
662 - \ref TableNatureOfFieldExampleIntegralGlobConstraint "IntegralGlobConstraint", for extensive fields with conservativity favored over the maximum principle. Relevant for power fields.
664 The first two correspond to intensive fields, the last two correspond to extensive fields.
666 By an intensive field we mean a field that represent an intensive physical variable such as density (\f$kg.m^{-3}\f$), power density (\f$W.m^{-3}\f$), temperature (\f$K\f$) or pressure (\f$Pa\f$). Typically the physical value doesn't scale with the size of the underlying geometry.
667 By extensive (or integral) field we mean a field that represents an extensive physical quantity such as mass (\f$kg\f$), volume (\f$m^3\f$), a momentum (\f$kg.m.s^{-1}\f$) or power \f$(W\f$).
668 Typically the field value scales linearly with respect to the underlying geometry size.
669 For fields with a P0 representation (cell based), conservativity formulas are different depending on whether the field is extensive or intensive (see \ref InterpKerP0P0Int and \ref InterpKerP0P0Ext).
670 Those two notions are themselves split into two sub-categories.
671 Indeed in some cases (e.g. non \ref MeshOverlap "overlapping meshes"), it is impossible to fulfill both the conservation principle and the maximum principle during the interpolation. The nature of the fields determine the formula to be used for non overlapping cells and thus the property that we will be satisfied.
672 Finally we consider that fields with P1 or P2 representations are necessarily intensive.
676 In order to employ the various \ref interptools, you have to specify the nature of your field.
677 When the source and target meshes do not overlap, different treatments will be employed depending on the nature of the source and target fields.
678 You can specify the nature of the field when you create a \ref medcoupling field with the following constructor:
680 MEDCouplingFieldDouble(NatureOfField n, MEDCouplingTimeDiscretization *td, MEDCouplingFieldDiscretization *type);
683 If you read or copy an already existing field, or later after its creation, you may want to change/set its nature.
684 In order to do so, you can use the function
687 void setNature(NatureOfField nat);
694 const char sourceFileName[]="source.med";
695 MEDCouplingFieldDouble *sourceField=MEDLoader::ReadFieldCell(sourceFileName,"Source_Mesh",0,"Density",/*iteration*/0,/*order*/0);
696 const char targetFileName[]="target.med";
697 MEDCouplingUMesh *med_target_mesh=MEDLoader::ReadUMeshFromFile(targetFileName,"Target_Mesh",0);
699 sourceField->setNature(ConservativeVolumic);
706 \page MEDCouplingUMeshPage Unstructured meshes in MEDCoupling
710 An unstructured mesh in \ref medcoupling MEDCoupling is defined by :
712 - a point clouds where the explicit coordinates of each point must be specified (inherited from \subpage MEDCouplingPointSetPage "MEDCouplingPointSet class").
713 - nodal connectivity that specifies for each cell, the points in the previous point clouds that constitutes the cell.
715 As unstructured mesh is dynamically defined enough, this class is also used by MEDCoupling to instantiate degenerated meshes as :
717 - points cloud only meshes. This type of mesh will have mesh dimension 0.
718 - abstract meshes containing only one cell that covers a potentially
719 infinite space. This abstract mesh is used as support of fields
720 containing only one integrated value. This is typically used to
721 represent fields used by system code. This type of mesh will have
722 mesh dimension equal to -1.
724 The norm used for cells connectivity of different types, is the same as specified in MED file except
725 that connectivities are in represented in \b C \b format and \b not \b in \b FORTRAN \b format !
727 The class that incarnates the described concept is : ParaMEDMEM::MEDCouplingUMesh.
728 \n This class inherits from ParaMEDMEM::MEDCouplingPointSet abstract class.
729 \n So \ref MEDCouplingUMeshPage "MEDCouplingUMesh" inherits from all \ref MEDCouplingPointSetPage "point set features".
731 \section MEDCouplingUMeshStdBuild Standard building of an unstructured mesh from scratch
733 The described method here is called standard, because no special knowledge of underneath nodal connectivity is needed here.
734 This method of building unstructured mesh is easiest but not the most CPU/memory efficient one.
736 All of examples given here make the assumption that the \c ParaMEDMEM namespace is visible ( by calling for example \c using \c namespace \c ParaMEDMEM; ).
738 Here we will create a mesh with spacedim==3 and meshdim==2. \b mesh contains 5 cells (with geometric type INTERP_KERNEL::NORM_TRI3, INTERP_KERNEL::NORM_QUAD4)
741 You can notice that it is possible to mix cell types as long as the dimension of cell is exactly equal to meshDim to respect \ref MEDCouplingMeshes "this rule".
743 \subpage medcouplingcppexamplesUmeshStdBuild1 "Here is the C++ implementation."
745 \subpage medcouplingpyexamplesUmeshStdBuild1 "Here is the Python implementation."
747 \section MEDCouplingUMeshNodalConnectivity How MEDCouplingUMesh stores its nodal connectivity
749 \ref ParaMEDMEM::MEDCouplingUMesh "MEDCouplingUMesh class" stores its nodal connectivity into 2 arrays.
751 - The first one, the biggest is ParaMEDMEM::MEDCouplingUMesh::_nodal_connectivity.
752 - The second one, the less big is ParaMEDMEM::MEDCouplingUMesh::_nodal_connectivity_index.
754 \image html MEDCouplingUMeshConn.png "Nodal connectivity storage into MEDCouplingUMesh class"
755 \image latex MEDCouplingUMeshConn.eps "Nodal connectivity storage into MEDCouplingUMesh class"
757 \note The last value of the nodal connectivity index points to an invalid memory place. It is not an error, simply as for standard C++, all ranges
758 are given in format [\b begin,\b end) where \b begin is included and \b end excluded.
760 \section MEDCouplingUMeshAdvBuild Advanced building of an unstructured mesh from scratch
762 Here we are going to build the mesh in a more advanced manner. This method expects that the user knows the storage format underlying ParaMEDMEM::MEDCouplingUMesh.
764 The same mesh than \ref MEDCouplingUMeshStdBuild "in the standard section above" is going to be implemented using advanced method.
766 \subpage medcouplingcppexamplesUmeshAdvBuild1 "Here the C++ implementation."
768 \subpage medcouplingpyexamplesUmeshAdvBuild1 "Here the Python implementation."
773 \page MEDCouplingPointSetPage Point set meshes in MEDCoupling
775 This is a \b non \b instantiable class that implements many algorithm working only on a set of points without any connectivity aspect.
776 The presence of this class is only for factorization reasons.
778 The class that incarnates this concept in \ref medcoupling "MEDCoupling" is : \ref ParaMEDMEM::MEDCouplingPointSet.
779 Instantiable class ParaMEDMEM::MEDCouplingUMesh inherits from ParaMEDMEM::MEDCouplingPointSet.
781 Some of most important implemented methods by \ref ParaMEDMEM::MEDCouplingPointSet "MEDCouplingPointSet" class are :
783 - \ref ParaMEDMEM::MEDCouplingPointSet::getSpaceDimension "getSpaceDimension"
784 - \ref ParaMEDMEM::MEDCouplingPointSet::getNumberOfNodes "getNumberOfNodes"
785 - \ref ParaMEDMEM::MEDCouplingPointSet::rotate "rotate"
786 - \ref ParaMEDMEM::MEDCouplingPointSet::translate "translate"
787 - \ref ParaMEDMEM::MEDCouplingPointSet::scale "scale"
788 - \ref ParaMEDMEM::MEDCouplingPointSet::findCommonNodes "findCommonNodes"
789 - \ref ParaMEDMEM::MEDCouplingPointSet::renumberNodes "renumberNodes"
790 - \ref ParaMEDMEM::MEDCouplingPointSet::getBoundingBox "getBoundingBox"
794 \page MEDCouplingCMeshPage Cartesian meshes in MEDCoupling
796 A cartesian mesh is a mesh that represents structured mesh whose nodes are arranged along axes of trihedron.
798 To instantiate an object of this type, only n arrays are needed.
800 In this type of mesh space dimension \b and mesh dimension are equals and the value is n ( with n in [1,2,3] ).
802 The n arrays will have only one component and the values contained in these arrays will be ascendently sorted.
804 The class that incarnates the described concept is : ParaMEDMEM::MEDCouplingCMesh.
806 \section MEDCouplingCMeshStdBuild Standard building of a cartesian mesh from scratch
808 Let's present an example of a 2D cartesian mesh.
810 \subpage medcouplingcppexamplesCmeshStdBuild1 "Here the C++ implementation."
812 \subpage medcouplingpyexamplesCmeshStdBuild1 "Here the Python implementation."
817 \page MEDCouplingExtrudedPage 3D Extruded meshes in MEDCoupling
819 An extruded mesh is a mesh also called 2.5 D.
821 It a convolution of 2D unstructured mesh with 1D unstructured mesh.
823 The problem is that this type of mesh is not managed by any file format that's why to build an instance of this mesh you need 3D unstructured mesh and a 2D
824 unstructured mesh lying on the same coordinates.
826 The advantage of this structure is that the interpolation time is highly improved.
828 This class is also useful for users that want to map the 3D unstructured mesh cell ids level by level along an axe.
830 The class that incarnates this concept in MEDCoupling is : \ref ParaMEDMEM::MEDCouplingExtrudedMesh.
834 \page MEDCouplingFieldTemplatesPage Field templates in MEDCoupling
836 This concept appears in ICOCO API.
837 field template is the adequate data structure to perform costly interpolation matrix computation as \ref RemapperClasses "Remapper class" does.
838 So, a field template can be seen as field without double values. The double values are only used for light matrix vector multiplication.
840 Concretely a field template is a pair containing :
842 - a \ref MEDCouplingMeshesPage "mesh"
843 - a spatial discretization (on cells, on nodes, on gauss points (including localizations, reference elements), )
848 \page MEDCouplingTimeLabelPage Time label in MEDCoupling
850 Time label is a **non instanciable** class whose each objects consuming potentially big amount of memory inherit from.
851 The class that incarnates this concept is ParaMEDMEM::TimeLabel.
853 Here some of examples of classes that inherit from \ref ParaMEDMEM::TimeLabel "TimeLabel" class :
855 - ParaMEDMEM::DataArrayInt, ParaMEDMEM::DataArrayDouble
856 - ParaMEDMEM::MEDCouplingMesh
857 - ParaMEDMEM::MEDCouplingFieldDouble
860 This class is in charge to store a 32 bits unsigned integer called time label, that allows the user to know easily, if an heavy object in memory has been modified or not.
862 The usage is simple :
864 - call ParaMEDMEM::TimeLabel::getTimeOfThis a first time to retrieve a reference. Store the returned unsigned integer.
865 - when you need to know if the instance inheriting from ParaMEDMEM::TimeLabel has changed or not simply invoke ParaMEDMEM::TimeLabel::getTimeOfThis again and compare with the stored value.
866 If the value is different, the instance has changed, if not the instance has **not** changed.
868 The virtual call to ParaMEDMEM::TimeLabel::updateTime change the behaviour of ParaMEDMEM::TimeLabel::getTimeOfThis it is a bug, so please notify the bug into the salome forum.
872 LocalWords: discretization