Salome HOME
b8293f96e6160d58a18576c294527ae32ec68a3d
[modules/med.git] / doc / doxygen / medcoupling.dox
1 /*!
2 \page medcoupling MEDCoupling
3
4 \section MEDCouplingIntro Introduction
5
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.
7
8 \ref medcoupling "MEDCoupling" C++ library implements a data structure which is the result of the following tradeoff :
9
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 from
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
22
23 The \ref medcoupling "MEDCoupling" data structure is \b fully \b independant from those implemented in MEDMEM.
24
25 \ref medcoupling "MEDCoupling" implements a set of algorithms linked to the data structure.
26
27 \section MEDCouplingMainConc Main Concepts
28
29 Here are listed basic concepts present into \ref medcoupling "MEDCoupling".
30
31 For beginners in \ref medcoupling "MEDCoupling" world, it is advisable to read the following concepts in the same order than the underlying list.
32
33 - \subpage MEDCouplingArrayPage "DataArrays"
34 - \subpage MEDCouplingMeshesPage "Meshes"
35 - \subpage MEDCouplingFieldsPage "Fields"
36 - \subpage MEDCouplingFieldTemplatesPage "Field templates"
37 - \subpage MEDCouplingTimeLabelPage "Time labels"
38
39 */
40
41 /*!
42   \page MEDCouplingMeshesPage Meshes in MEDCoupling
43
44 \section MEDCouplingMeshes Common concept shared by all type of Meshes in MEDCoupling
45
46 A mesh has a the following properties :
47
48 - name
49 - **a dimension (called mesh dimension) and only one** (it implies that \b all cells constituting
50 mesh have the same dimension)
51 - a space dimension (relative to coordinates)
52 - a number of nodes
53 - a number of cells
54
55 In MEDCoupling library there is no presence of faces nor edges.
56
57 As a mesh has one dimension and only once, that is to say every cells in
58 mesh have the same dimension called MeshDimension.
59
60 That is to say the
61 MEDMEM vocabulary of faces and edges \b do \b not \b exist \b anymore here in
62 MEDCoupling.
63
64 For exemple a mesh with a meshDimension equal to 1, have \b cells of type
65 NORM_SEG2. An another exemple, a mesh with a meshDimension equal
66 to 2, have \b cells of type
67 NORM_TRI3 and NORM_POLYGON for example.
68
69 The class that incarnates the concept described above is :
70 \ref ParaMEDMEM::MEDCouplingMesh.
71
72 \section MEDCouplingMeshesAvailInstan Available instaciable mesh types in MEDCoupling
73
74 - \subpage MEDCouplingUMeshPage "Unstructured meshes"
75 - \subpage MEDCouplingCMeshPage "Cartesian meshes"
76 - \subpage MEDCouplingExtrudedPage "3D Extruded meshes"
77
78 /*!
79 \page MEDCouplingFieldsPage Fields in MEDCoupling
80
81 [TOC]
82
83 \section MEDCouplingFields Field concept
84
85 A field in MEDCoupling point of view, is a structure that allows to
86 store a discretization of a physical value on a defined discretized spatial and
87 possibly temporal support.
88
89 The spatial support is a \ref MEDCouplingMeshesPage "mesh".
90 A field is lying on an entity that will be specified by the spatial
91 discretization of the field. For exemple a field on node will lie on
92 all nodes of its mesh.
93
94 A field on cell will lie on all cells of its mesh.
95
96 Fields in MEDCoupling follow the two following rules :
97
98 - A field will lie on \b ALL entities of its spatial support (\ref MEDCouplingMeshesPage "mesh").
99 - A field has \b only \b one spatial support (\ref MEDCouplingMeshesPage "mesh") on its temporal support.
100
101 The main properties of a field are :
102
103 - name
104 - spatial support which is a \ref MEDCouplingMeshesPage "mesh"
105 - a \ref MEDCouplingSpatialDisc "spatial discretization"
106 - a description of intrinsic nature of the values of field (see \ref NatureOfField). This is important for conservative interpolation (see \ref TableNatureOfField).
107 - a temporal discretization that specifies, if it exists, the time interval on which the field is covering, and how.
108 - number of components
109
110 This definition of field in MEDCoupling allows an instance of field to
111 know at any point inside its spatial-temporal support the value.
112
113 The class that incarnates the concept described above is : \ref ParaMEDMEM::MEDCouplingFieldDouble.
114
115 Some of most important implemented methods are :
116
117 - \ref ParaMEDMEM::MEDCouplingFieldDouble::getNumberOfComponents "getNumberOfComponents"
118 - \ref ParaMEDMEM::MEDCouplingFieldDouble::getValueOn "getValueOn"
119 - \ref ParaMEDMEM::MEDCouplingFieldDouble::applyFunc "applyFunc"
120 - \ref ParaMEDMEM::MEDCouplingFieldDouble::addFields "cross instances operations"
121 \section MEDCouplingSpatialDisc Spatial discretization concept
122
123 This is the concept that makes the link, independantly from temporal
124 discretization, between the field and its spatial support(\ref MEDCouplingMeshesPage "mesh"). This
125 concept allows the field to make a check and interpretation of an
126 array of values given a spatial support (\ref MEDCouplingMeshesPage "mesh").
127
128 The abstract class that incarnates the concept is : \ref ParaMEDMEM::MEDCouplingFieldDiscretization.
129
130 The most important pure virtual methods are :
131
132 - \ref ParaMEDMEM::MEDCouplingFieldDiscretization::getNumberOfTuples "getnumberOfTuples"
133 - \ref ParaMEDMEM::MEDCouplingFieldDiscretization::getValueOn "getValueOn"
134 - \ref ParaMEDMEM::MEDCouplingFieldDiscretization::getMeasureField "getMeasureField"
135
136 \section MEDCouplingTemporalDisc Temporal discretization concept
137
138 This information allows, independantly from spatial discretization, to
139 associate a time interval, if it exists, on which the field will be
140 defined. This concept is able to give the value at any time of
141 the definition interval (if any).
142
143 The abstract class \ref ParaMEDMEM::MEDCouplingTimeDiscretization
144 incarnates this described concept.
145
146 This classes and its subclasses are responsible in storing the arrays
147 of the aggregating field.
148
149 The most important methods are :
150
151 - \ref ParaMEDMEM::MEDCouplingTimeDiscretization::setTime "setTime" and \ref ParaMEDMEM::MEDCouplingTimeDiscretization::getTime "getTime"
152 - \ref ParaMEDMEM::MEDCouplingTimeDiscretization::getArray "getArray" and \ref ParaMEDMEM::MEDCouplingTimeDiscretization::setArray "setArray"
153 - \ref ParaMEDMEM::MEDCouplingTimeDiscretization::getArraysForTime "getArraysForTime"
154 - \ref ParaMEDMEM::MEDCouplingTimeDiscretization::getValueForTime "getValueForTime"
155
156 \section MEDCouplingFirstSteps3 Building a field from scratch
157
158 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" ).
159
160 \subsection MEDCouplingFirstSteps3OnCellsNoTS  Create a tensor field with 9 components on cells with no time step
161
162 \subpage medcouplingcppexamplesFieldDoubleBuild1 "Here the C++ implementation."
163
164 \subpage medcouplingpyexamplesFieldDoubleBuild1 "Here the Python implementation."
165
166 \subsection MEDCouplingFirstSteps3OnNodesNoTS Create a scalar field on nodes with no time step
167
168 \subpage medcouplingcppexamplesFieldDoubleBuild2 "Here the C++ implementation."
169
170 \subpage medcouplingpyexamplesFieldDoubleBuild2 "Here the Python implementation."
171
172 \subsection MEDCouplingFirstSteps3OnCellsWTS Create a 2 components-vector field on cells with one time step and no interval
173
174 \subpage medcouplingcppexamplesFieldDoubleBuild3 "Here the C++ implementation."
175
176 \subpage medcouplingpyexamplesFieldDoubleBuild3 "Here the Python implementation."
177
178 \subsection MEDCouplingFirstSteps3OnCellsCTI Create a 3 components-vector field on nodes with a time interval where field remains constant on this time interval
179
180 \subpage medcouplingcppexamplesFieldDoubleBuild4 "Here the C++ implementation."
181
182 \subpage medcouplingpyexamplesFieldDoubleBuild4 "Here the Python implementation."
183
184 \section MEDCouplingSecondStep0 Operations on Fields
185
186 Here we will make the assumption that an instance of \ref ParaMEDMEM::MEDCouplingMesh "MEDCouplingMesh"
187 called \c mesh has been created with spaceDim==2.
188
189 \subpage medcouplingcppexamplesFieldDoubleBuild5 "Here a C++ example of more advanced use of MEDCouplingFieldDouble instances".
190
191 \subpage medcouplingpyexamplesFieldDoubleBuild5 "Here a Python example of more advanced use of MEDCouplingFieldDouble instances".
192
193 */
194
195 /*!
196
197 \page MEDCouplingArrayPage MEDCoupling Arrays
198
199 [TOC]
200
201 \section MEDCouplingArrayIntro Introduction
202
203 One of the most basic concept mainly used all over MEDCoupling is
204 MEDCoupling array.
205
206 This concept is used all over
207 \ref medcoupling "MEDCoupling", \ref paramedmem "ParaMEDMEM", \ref medloader "MEDLoader" modules so it should be correctly
208 handled to play well with \ref MEDCouplingMeshesPage "Meshes" and \ref MEDCouplingFieldsPage "Fields".
209
210 \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".
211
212 There are for the moment two types of arrays :
213  - double precision float (64 bits) array incarnated by \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble class".
214  - signed integer (32 bits) array incarnated by \ref ParaMEDMEM::DataArrayInt "DataArrayInt class".
215
216 \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble" and \ref ParaMEDMEM::DataArrayInt "DataArrayInt" classes inherits from 
217 \ref ParaMEDMEM::DataArray "DataArray" \b non \b instanciable \b class that factorizes some common methods of inherited instanciable classes.
218
219 In the rest of the documentation \b DataArray will be used for both \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble" and \ref ParaMEDMEM::DataArrayInt "DataArrayInt".
220
221 \section MEDCouplingArrayBasics Basics concepts of the DataArrays.
222
223 It will be presented in this section common concept shared by the two classes to \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble" and \ref ParaMEDMEM::DataArrayInt "DataArrayInt".
224
225 \subsection MEDCouplingArrayBasicsName Name
226
227 A \ref ParaMEDMEM::DataArray "DataArray" instance has an attribute **name**.
228
229 **name** is particulary useful for \ref ParaMEDMEM::DataArray "DataArray" representing profiles, families, groups, fields in MEDLoader.
230 But excepted these useful usecases, **name** attribute is often ignored when \ref ParaMEDMEM::DataArray "DataArrays" are aggregated (field array, connectivity, coordinates) is a bigger object.
231 Whatever the useage 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.
232
233 \subsection MEDCouplingArrayBasicsTuplesAndCompo Raw data, tuples and components of DataArrays.
234
235 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".
236
237 The size of this vector of data is called, number of elements. So the number of bytes stored by a \ref ParaMEDMEM::DataArray "DataArray" instance, is equal to
238 the  product of the __number of elements__ * __constant size of DataType__ .
239
240 As \ref ParaMEDMEM::DataArray "DataArray" instances are designed to stored vector fields, tensor fields, coordinate of nodes, the notion of components has been
241 added.
242
243 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.
244 The vector of atomical elements stored into \ref ParaMEDMEM::DataArray "DataArrays" are grouped in contiguous in memory set of atomical elements having each same size.
245
246 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
247 \ref ParaMEDMEM::DataArray "DataArray" storing it.
248
249 Thus :
250
251 \f[
252  N_{elements}=N_{tuples}*N_{components}.
253 \f]
254
255 \f[
256  N_{bytes}=N_{elements}*sizeof(DataType)=N_{tuples}*N_{components}*sizeof(DataType).
257 \f]
258
259 In another 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
260 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.
261
262 Typically in the **raw data** of  \ref ParaMEDMEM::DataArray "DataArrays" **number of tuples** is highly bigger than **number of components** !
263
264 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.
265
266 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.
267 \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$.
268
269
270 \subsection MEDCouplingArrayBasicsCompoName Information on components name.
271
272 As seen in the sub section above, a \ref ParaMEDMEM::DataArray "DataArray" instance has a defined number of components.
273
274 Their is an information attached to each of these components constiting the \ref ParaMEDMEM::DataArray "DataArray".
275
276 This information is concretely a string of caracters that allows, if needed, to give information about the conresponding component.
277
278 The format chosen in **MEDCoupling** for information on is "MY_COMPO_INFO [MYUNIT]". If needed, the unit attached to the component
279 should be put between "[" and "]" after the information of the components after one space caracter.
280
281 \subsection MEDCouplingArrayBasicsTimeLabel DataArrays and TimeLabel.
282
283 \ref ParaMEDMEM::DataArray "DataArrays instances" can consume big amount of data in memory so they inherit from \subpage MEDCouplingTimeLabelPage "TimeLabel".
284 So in C++ it is a good practice to use :
285 - \c getConstPointer method in readonly access.
286 - \c getPointer method only if write is needed.
287
288 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
289 \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
290 on each call.
291
292 \c setIJ method usage should be reduced to little modification sessions.  
293
294 \section MEDCouplingArraySteps0 Building an array from scratch in Python
295
296 \subsection MEDCouplingArraySteps0Double Building an double array from scratch in Python
297
298 Let's consider a list of floats \c dataDouble.
299
300 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayBuild1_0
301
302 The easiest way to build the \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble instance" called \c arrayDouble simply call :
303
304 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayBuild1_1bis
305
306 An another way is to do that :
307
308 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayBuild1_1
309
310 \subsection MEDCouplingArraySteps0Int Building an int array from scratch in Python
311
312 Let's consider a list of ints \c dataInt.
313
314 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayBuild1_2
315
316 The easiest way to build the \ref ParaMEDMEM::DataArrayInt "DataArrayInt instance" called \c arrayInt simply call :
317
318 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayBuild1_3bis
319
320 An another way is to do that :
321
322 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayBuild1_3
323
324
325 \section MEDCouplingArraySteps1 Building an array from scratch in C++
326
327 Here a description of typical usages to use \ref ParaMEDMEM::DataArrayDouble "MEDCoupling arrays".\n
328 In this example we will create arrays with 12 tuples constituted each
329 of 3 components. These arrays will be created using different ways.\n
330
331 The following code is only based using \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble"
332 but the use of \ref ParaMEDMEM::DataArrayInt "DataArrayInt" is strictly equivalent.
333
334 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_0
335
336 \subsection MEDCouplingArraySteps1NCNO Building an array from scratch in C++, no copy no ownership
337
338 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_1
339
340 \subsection MEDCouplingArraySteps1NCWCPPO Building an array from scratch in C++, no copy with C++ ownership
341
342 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_2
343
344 \subsection MEDCouplingArraySteps1NCWCO Building an array from scratch in C++, no copy with C ownership
345
346 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_3
347
348 \subsection MEDCouplingArraySteps1WC Building an array from scratch in C++, with copy
349
350 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_4
351
352 \section MEDCouplingArrayBasicsCopy Copy DataArrays.
353
354 As \ref ParaMEDMEM::DataArray "DataArrays" are the atomic entity of potentially big memory objects into \ref medcoupling "MEDCoupling"
355 , \ref ParaMEDMEM::DataArray "DataArrays" introduces concepts of copy and comparison that will be used by aggregating classes.
356
357 For more complex objects (that aggregate themselves big objects) 
358 like ParaMEDMEM::MEDCouplingFieldDouble the concept of copy (shallow or deep) is less straight forward because which aggregated subobjects are copied or not.
359
360 \subsection MEDCouplingArrayBasicsCopyDeep Deep copy of DataArray
361
362 As for all potentially heavy memory consumer objects in \ref medcoupling "MEDCoupling", \ref ParaMEDMEM::DataArray "DataArrays" implement
363  method \c deepCpy. This method deeply copies an instance. The life cycle of the returned object is *fully* independant from the instance on which the method
364 \c deepCpy has been invoked.
365
366 To perform a deep copy of a DataArray instance simply invoke :
367
368 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_5
369
370 or :
371
372 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_5bis
373
374 \c myCoordsCpy is the deep copy of \c myCoords so they are independant and their *raw data* has been deeply copied.
375
376 So it leads to the following behaviour :
377 \anchor MEDCouplingArrayBasicsCopyDeepTestEqual
378
379 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_6
380
381 As \c myCoordsCpy is a copy object it needs to be deallocated in C++ like \c myCoords.
382
383 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_7
384
385 \subsection MEDCouplingArrayBasicsCopyShallow Shallow copy of DataArray
386
387 As \ref ParaMEDMEM::DataArray "DataArrays" are the atomic entity of potentially big memory objects into \ref medcoupling "MEDCoupling", the shallow copy
388 simply returns the same object with the reference counter incremented.
389
390 To perform a shallow copy of a DataArray instance simply invoke :
391
392 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_8
393
394 \c myCoordsCpy is the shallow copy of \c myCoords so they share the same *raw data*. In reality they are the same object.
395 So it leads to the following behaviour to compare with the deep copy :
396
397 \anchor MEDCouplingArrayBasicsCopyShallowTestEqual
398
399 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_9
400
401 So here the content of \c myCoords and \c myCoordsCpy are linked, contrary to the deep copy case.
402
403 As \c myCoordsCpy is a copy object, in C++, it needs to be deallocated.
404
405 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_10
406
407 \subsection MEDCouplingArrayBasicsCopyDeepAssign Assignation by deep copy of DataArray
408
409 We start by building a instance of ParaMEDMEM::DataArrayDouble allocated or not. Here, instance is not allocated, only built empty.
410
411 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_11
412
413 Then, \c myCoordsCpy is assigned with the content of \c myCoords.
414
415 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_12
416
417 Then \c myCoordsCpy is a deep copy of \c myCoords except that the instance of ParaMEDMEM::DataArrayDouble is those specified.
418 But the behaviour is the same than those seen for \ref MEDCouplingArrayBasicsCopyDeepTestEqual "deep copy".
419
420 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_13
421
422 As always, in C++, \c myCoordsCpy is an object whose life cycle is fully independant from \c myCoords so decrement is needed.
423
424 \snippet MEDCouplingExamplesTest.cxx CppSnippetDataArrayBuild1_14
425
426 \section MEDCouplingArrayBasicsCompare Compare DataArrays.
427
428 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.
429 There are two types of comparison :
430
431 - strict, that compares strictly all the non mutable attributes (state sensitive). Methods to perform this strict comparison are :
432   - ParaMEDMEM::DataArrayInt::isEqual
433   - ParaMEDMEM::DataArrayDouble::isEqual.
434
435 - less strict, that focus only on non string attributes. Methods to perform less strict comparison are :
436   - ParaMEDMEM::DataArrayInt::isEqualWithoutConsideringStr
437   - ParaMEDMEM::DataArrayDouble::isEqualWithoutConsideringStr
438
439 \section MEDCouplingArrayRenumbering Array renumbering
440
441 Here is presented all it is necessary to know concerning renumbering.
442 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.
443 But it is also used on operations of node cell merging. It is also used in parallel mode when splitting of mesh is needed...
444
445 Formally a renumbering is a mathematical application that can be surjective, injective or bijective. This application is defined using an instance of
446 \ref ParaMEDMEM::DataArrayInt "DataArrayInt". There are different ways to define this application.
447
448 \subsection MEDCouplingArrayRenumberingO2N Old to new mode
449
450 The old to new mode is particulary recommanded for surjective and bijective application. This is typically the case of \ref ParaMEDMEM::MEDCouplingUMesh::mergeNodes "MEDCouplingUMesh::mergeNodes" method.
451 Let's consider a call to \ref ParaMEDMEM::MEDCouplingUMesh::mergeNodes "mergeNodes" that reduces the number of nodes from 5 nodes to 3 nodes.\n
452 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
453
454 If \b MySujection equals [2,1,0,1,2], it means that :
455
456 - old id #0 will have new id equal to 2
457 - old id #1 will have new id equal to 1
458 - old id #2 will have new id equal to 0
459 - old id #3 will have new id equal to 1 like old id #1
460 - old id #4 will have new id equal to 2 like old id #0
461
462 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.
463
464 Method in old to new mode that works on bijective applications :
465
466 - \ref ParaMEDMEM::DataArrayDouble::renumber "DataArrayDouble::renumber"
467 - \ref ParaMEDMEM::DataArrayDouble::renumberInPlace "DataArrayDouble::renumberInPlace"
468
469 Method in old to new mode that works on surjective applications :
470
471 - \ref ParaMEDMEM::DataArrayDouble::renumberAndReduce "DataArrayDouble::renumberAndReduce"
472
473 Sometimes the format old to new for sujections can be replaced by another format with 2 arrays. Less compact in memory. The \ref ParaMEDMEM::DataArrayInt::changeSurjectiveFormat "DataArrayInt::changeSurjectiveFormat" method performs that. 
474
475 \subsection MEDCouplingArrayRenumberingN2O New to old mode
476
477 The new to old mode is particulary recommanded for strictly injective and bijective permutations. This is particulary usefull for methods that increase the number of entities like for example
478 \ref ParaMEDMEM::MEDCouplingUMesh::simplexize "MEDCouplingUMesh::simplexize".\n
479 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
480 the mode new to old.
481 Let's consider a call to \ref ParaMEDMEM::MEDCouplingUMesh::simplexize "simplexize" that increases the number of cell from 4 cells to 6 cells.\n
482 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
483 If \b MyInjection equals [2,0,1,1,3,0] it means that :
484
485 - new id #0 comes from old id 2
486 - new id #1 comes from old id 0
487 - new id #2 comes from old id 1
488 - new id #3 comes from old id 1
489 - new id #4 comes from old id 3
490 - new id #5 comes from old id 0
491
492 Method in new to old mode that works on bijective applications :
493
494 - \ref ParaMEDMEM::DataArrayDouble::renumberR "DataArrayDouble::renumberR"
495 - \ref ParaMEDMEM::DataArrayDouble::renumberInPlace "DataArrayDouble::renumberInPlaceR"
496
497 Method in new to old mode that works on surjective applications :
498
499 - \ref ParaMEDMEM::DataArrayDouble::selectByTupleId "DataArrayDouble::selectByTupleId"
500
501 \section MEDCouplingArrayApplyFunc Application of a function on DataArrayDouble instances.
502
503 This section is only dedicated for \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble instances".
504
505 It is possible to apply to \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble instance" a function given by a string.
506
507 There are different API for applyFunc* methods of \ref ParaMEDMEM::DataArrayDouble "DataArrayDouble class".
508
509 \subsection MEDCouplingArrayApplyFuncExpr Expressions supported
510
511 In order to reduce as much as possible dependancies, a little dynamic formula interpretor has been developped into INTERP_KERNEL.
512 This dynamic expression evaluator can deal the following exhaustive list :
513
514 - +,-,*,^ (^ for exponent 3^2==9)
515 - sin,cos,tan,sqrt,abs,exp,max,min,ln (neper logarithm), log (neper logarithm), log10 (decimal logarithm), 
516 - >,<
517 - if
518
519 The expression evaluator is also sensitive to the following var pattern : IVec, JVec, KVec, LVec,... ,ZVec
520
521 - IVec stands for unitary vector [1,0,0,0,...]
522 - JVec stands for unitary vector [0,1,0,0,...]
523 - KVec stands for unitary vector [0,0,1,0,...]
524 - ...
525
526 The dynamic expression evaluator works tuple by tuple through the *raw data* of DataArrayDouble instance.
527
528 The principle of the dynamic expression evaluator is the following :
529
530 - Given the input string a compilation tree is built whose leaves are either constants or variables.
531   At this phase only syntax errors are thrown.  
532 \anchor MEDCouplingArrayApplyFuncExprA1
533 - Then given the computed tree, a link phase is performed to accelerate evaluation. At this phase the incoherence between the number of
534   components and the number of variables are detected.
535
536 - The given the preprocessed tree given an input tuple a preallocated tuple is fed with the result of the evaluation.
537   At this last phase only mathematical errors are thrown (division by 0, log(0), sqrt of a negative number ...)
538
539 \subsection MEDCouplingArrayApplyFunc0 applyFunc method with only one parameter
540
541 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
542 \ref ParaMEDMEM::DataArrayDouble::applyFunc(const char *) const applyFunc method is applied.
543
544 **This method is useful when the evaluation expression do not need to consider the components of each tuple separately**.
545
546 That's why this method of \ref ParaMEDMEM::DataArrayDouble::applyFunc(const char *) const applyFunc method with one parameter accepts at most only one variable.
547
548 If it is not the case an exception is thrown as seen here :
549
550 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayApplyFunc1_1
551
552 Let's take a very simple example on a DataArrayDouble instance \c d having 4 tuples and 2 components.
553
554 In the next example the expression contains only one variable : \c smth.
555 So \c smth represent a tuple of size 2.
556
557 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayApplyFunc1_2
558
559 As the example shows, the output \c d1 has 2 components as \c d.
560
561 Whereas all the components of the input of \c d be not considered separetely, it is also, possible with \ref ParaMEDMEM::DataArrayDouble::applyFunc(const char *) const applyFunc method with one parameter
562 to build an output having same number of components than input but where components in input are treated separetely.
563
564 Let's build an example using DataArrayDouble instance \c d defined just above.
565
566 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayApplyFunc1_3
567
568 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.
569
570 \subsection MEDCouplingArrayApplyFunc1 applyFunc method with only two parameters
571
572 This method alse 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 pervious \ref MEDCouplingArrayApplyFunc0 "applyFunc with one parameter version" here the number of components is set by the user.
573
574 The big difference with \ref MEDCouplingArrayApplyFunc0 "applyFunc method with one parameter" seen above is that here components of tuples are treated separately.
575
576 The method that implements it is \ref ParaMEDMEM::DataArrayDouble::applyFunc(int,const char *) const here.
577
578 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.
579
580 Let's consider the following DataArrayDouble having 4 tuples with 3 components called dd.
581
582 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayApplyFunc1_4
583
584 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 le square root of the second component and the thrid component
585 the invokation should be something like this :
586
587 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayApplyFunc1_5
588
589 \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
590 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 :
591 - \c f will be attached to component #0 of \c dd
592 - \c g will be attached to component #1 of \c dd
593 - \c h will be attached to component #2 of \c dd
594
595 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
596 of \c dd.
597 \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.
598 \n \ref ParaMEDMEM::DataArrayDouble::applyFunc2 "applyFunc2" and \ref ParaMEDMEM::DataArrayDouble::applyFunc3 "applyFunc3" methods have been developped to remedy to that feature that can be surprising.
599 \n These two methods are explained respectively \ref MEDCouplingArrayApplyFunc2 "here for applyFunc2" and \ref MEDCouplingArrayApplyFunc3 "here for applyFunc3".
600
601 Whatever it is possible to find a workaround using \ref ParaMEDMEM::DataArrayDouble::applyFunc(int,const char *) const applyFunc with 2 parameters.
602 \n Here is a solution to compute \c dd2 :
603
604 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayApplyFunc1_6
605
606 \subsection MEDCouplingArrayApplyFunc2 applyFunc2 method
607
608 The method that implements it is \ref ParaMEDMEM::DataArrayDouble::applyFunc2 here.
609
610 This method is very close to \ref MEDCouplingArrayApplyFunc1 "applyFunc method with only two parameters".
611
612 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.
613
614 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.
615
616 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayApplyFunc1_7
617
618 To compute the sum of the first component (component #0) and the third component (component #2) simply do that :
619
620 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayApplyFunc1_8
621
622 \subsection MEDCouplingArrayApplyFunc3 applyFunc3 method
623
624 The method that implements it is \ref ParaMEDMEM::DataArrayDouble::applyFunc3 here.
625
626 This method is very close to \ref MEDCouplingArrayApplyFunc1 "applyFunc method with only two parameters" and \ref MEDCouplingArrayApplyFunc2 "applyFunc2".
627
628 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.
629
630 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 :
631
632 \snippet MEDCouplingExamplesTest.py PySnippetDataArrayApplyFunc1_9
633
634 */
635
636 /*!
637     \defgroup NatureOfField Nature of a field
638
639     \section  IntExtFields Overview: intensive and extensive field
640
641 \c NatureOfField is an enum which helps determining some physical significance of the field and affects the choice of interpolation formula ( see \ref TableNatureOfField).
642 It has five possible values:
643 -      "NoNature", the default value, does not allow the use of interpolation tools
644
645 -      \ref TableNatureOfFieldExampleConservVol "ConservativeVolumic", for intensive field with the maximum principle favored over conservativity. Relevant for temperature, pression fields.
646
647 -      \ref TableNatureOfFieldExampleIntegral "Integral", for extensive field with the maximum principle favored over conservativity. Relevant for power fields.
648
649 -      \ref TableNatureOfFieldExampleIntegralGlobConstraint "IntegralGlobConstraint", for extensive fields with conservativity favored over the maximum principle. Relevant for power fields.
650
651 -      \ref TableNatureOfFieldExampleRevIntegral "RevIntegral", for intensive field with the conservativity favored over maximum principle. Relevant for power density fields.
652
653 By an intensive field we mean a field that represent volumetric or 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$).
654 By extensive (or integral) field we mean a field that represents an extensive physical quantity sych as mass (\f$kg\f$), volume (\f$m^3\f$), a momentum (\f$kg.m.s^{-1}\f$) or power \f$(W\f$).
655 For fields with a P0 representation, conservativity formulas are different depending on whether the field is extensive or intensive (see \ref InterpKerP0P0Int and \ref InterpKerP0P0Ext).
656 In some cases such a non \ref MeshOverlap "overlapping meshes", it is impossible to fulfill both conservation and maximum principle during the interpolation. The nature of the fields determines the formula to be used for non overlapped cells and thus the property that we will be satisfied.
657 We consider that fields with P1 or P2 representations are necessarily intensive.
658
659 \section Usage
660
661 In order to employ the various \ref interptools, it is important to specify the nature of your field. 
662 In case the sources and target meshes do not overlap different treatments will be employed, depending on the nature of the source and target fields.
663 You can specify the nature of the field when you create a \ref medcoupling field with the following constructor:
664 \code
665 MEDCouplingFieldDouble(NatureOfField n, MEDCouplingTimeDiscretization *td, MEDCouplingFieldDiscretization *type);
666 \endcode
667
668 If you read or copy an already existing field, or later after its creation, you may want to change/set its nature.
669 In order to do so, you can use the function
670
671 \code
672 void setNature(NatureOfField nat);
673 \endcode
674
675 Here is an example
676
677 \code
678 ...
679 const char sourceFileName[]="source.med";
680 MEDCouplingFieldDouble *sourceField=MEDLoader::ReadFieldCell(sourceFileName,"Source_Mesh",0,"Density",/*iteration*/0,/*order*/0);
681 const char targetFileName[]="target.med";
682 MEDCouplingUMesh *med_target_mesh=MEDLoader::ReadUMeshFromFile(targetFileName,"Target_Mesh",0);
683 //
684 sourceField->setNature(ConservativeVolumic);
685 ...
686 \endcode
687
688 */
689
690 /*!
691   \page MEDCouplingUMeshPage Unstructured meshes in MEDCoupling
692         
693 [TOC]
694
695 An unstructured mesh in \ref medcoupling MEDCoupling is defined by :
696
697   - a point clouds where the explicit coordinates of each point must be specified (inherited from \subpage MEDCouplingPointSetPage "MEDCouplingPointSet class").
698   - nodal connectivity that specifies for each cell, the points in the previous point clouds that constitutes the cell.
699
700 As unstructured mesh is dynamically defined enough, this class is also used by MEDCoupling to instanciate degenerated meshes as :
701
702 - points cloud only meshes. This type of mesh will have mesh dimension 0.
703 - abstract meshes containing only one cell that covers a potentially
704   infinite space. This abstract mesh is used as support of fields
705   containing only one integrated value. This is typically used to
706   represent fields used by system code. This type of mesh will have
707   mesh dimension equal to -1.
708
709 The norm used for cells connectivity of different types, is the same as specified in MED file except
710 that connectivities are in represented in \b C \b format and \b not \b in \b FORTRAN \b format !
711
712 The class that incarnates the described concept is : ParaMEDMEM::MEDCouplingUMesh.
713 \n This class inherits from ParaMEDMEM::MEDCouplingPointSet abstract class.
714 \n So \ref MEDCouplingUMeshPage "MEDCouplingUMesh" inherits from all \ref MEDCouplingPointSetPage "point set features".
715
716 \section MEDCouplingUMeshStdBuild Standard building of an unstructured mesh  from scratch
717
718 The described method here is called standard, because no special knowledge of underneath nodal connectivity is needed here.
719 This method of building unstructured mesh is easiest but not the most CPU/memory efficient one.
720
721 All of exemples given here make the assumption that the \c ParaMEDMEM namespace is visible ( by calling for example \c using \c namespace \c ParaMEDMEM; ).
722
723 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)
724 and 9 nodes.
725
726 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".
727
728 \subpage medcouplingcppexamplesUmeshStdBuild1 "Here the C++ implementation."
729
730 \subpage medcouplingpyexamplesUmeshStdBuild1 "Here the Python implementation."
731
732 \section MEDCouplingUMeshNodalConnectivity How MEDCouplingUMesh stores its nodal connectivity.
733
734 \ref ParaMEDMEM::MEDCouplingUMesh "MEDCouplingUMesh class" stores its nodal connectivity into 2 arrays.
735
736 - The first one, the biggest is ParaMEDMEM::MEDCouplingUMesh::_nodal_connectivity.
737 - The second one, the less big is ParaMEDMEM::MEDCouplingUMesh::_nodal_connectivity_index.
738
739 \image html MEDCouplingUMeshConn.png "Nodal connectivity storage into MEDCouplingUMesh class"
740 \image latex MEDCouplingUMeshConn.eps "Nodal connectivity storage into MEDCouplingUMesh class"
741
742 \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
743 are given in format [\b begin,\b end) where \b begin is included and \b end excluded.
744
745 \section MEDCouplingUMeshAdvBuild Advanced building of an unstructured mesh  from scratch
746
747 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.
748
749 The same mesh than \ref MEDCouplingUMeshStdBuild "in the standard section above" is going to be implemented using advanced method.
750
751 \subpage medcouplingcppexamplesUmeshAdvBuild1 "Here the C++ implementation."
752
753 \subpage medcouplingpyexamplesUmeshAdvBuild1 "Here the Python implementation."
754
755 */
756
757 /*!
758   \page MEDCouplingPointSetPage Point set meshes in MEDCoupling
759
760 This is a \b non \b instanciable class that implements many algorithm working only on a set of points without any connectivity aspect.
761 The presence of this class is only for factorization reasons.
762
763 The class that incarnates this concept in \ref medcoupling "MEDCoupling" is : \ref ParaMEDMEM::MEDCouplingPointSet.
764 Instanciable class ParaMEDMEM::MEDCouplingUMesh inherits from ParaMEDMEM::MEDCouplingPointSet.
765
766 Some of most important implemented methods by \ref ParaMEDMEM::MEDCouplingPointSet "MEDCouplingPointSet" class are :
767
768 - \ref ParaMEDMEM::MEDCouplingPointSet::getSpaceDimension "getSpaceDimension"
769 - \ref ParaMEDMEM::MEDCouplingPointSet::getNumberOfNodes "getNumberOfNodes"
770 - \ref ParaMEDMEM::MEDCouplingPointSet::rotate "rotate"
771 - \ref ParaMEDMEM::MEDCouplingPointSet::translate "translate"
772 - \ref ParaMEDMEM::MEDCouplingPointSet::scale "scale"
773 - \ref ParaMEDMEM::MEDCouplingPointSet::findCommonNodes "findCommonNodes"
774 - \ref ParaMEDMEM::MEDCouplingPointSet::renumberNodes "renumberNodes"
775 - \ref ParaMEDMEM::MEDCouplingPointSet::getBoundingBox "getBoundingBox"
776 */
777
778 /*!
779   \page MEDCouplingCMeshPage Cartesian meshes in MEDCoupling
780
781 A cartesian mesh is a mesh that represents structured mesh whose nodes are arranged along axes of trihedron.
782
783 To instanciate an object of this type, only n arrays are needed.
784
785 In this type of mesh space dimension \b and mesh dimension are equals and the value is n ( with n in [1,2,3] ).
786
787 The n arrays will have only one component and the values contained in these arrays will be ascendantly sorted.
788
789 The class that incarnates the described concept is : ParaMEDMEM::MEDCouplingCMesh.
790
791 \section MEDCouplingCMeshStdBuild Standard building of a cartesian mesh from scratch
792
793 Let's present an exemple of a 2D cartesian mesh.
794
795 \subpage medcouplingcppexamplesCmeshStdBuild1 "Here the C++ implementation."
796
797 \subpage medcouplingpyexamplesCmeshStdBuild1 "Here the Python implementation."
798
799 */
800
801 /*!
802   \page MEDCouplingExtrudedPage 3D Extruded meshes in MEDCoupling
803
804 An extruded mesh is a mesh also called 2.5 D.
805
806 It a convolution of 2D unstructured mesh with 1D unstructured mesh.
807
808 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
809 unstructured mesh lying on the same coordinates.
810
811 The advantage of this structure is that the interpolation time is highly improved.
812
813 This class is also useful for users that want to map the 3D unstructured mesh cell ids level by level along an axe.
814
815 The class that incarnates this concept in MEDCoupling is : \ref ParaMEDMEM::MEDCouplingExtrudedMesh.
816 */
817
818 /*!
819   \page MEDCouplingFieldTemplatesPage Field templates in MEDCoupling
820
821 This concept appears in ICOCO API.
822 field template is the adequate datastructure to perform costly interpolation matrix computation as \ref RemapperClasses "Remapper class" does.
823 So, a field template can be seen as field without double values. The double values are only used for light matrix vector multiplication.
824
825 Concretely a field template is a pair containing :
826
827 - a \ref MEDCouplingMeshesPage "mesh"
828 - a spatial discretization (on cells, on nodes, on gauss points (including localizations, reference elements), )
829
830 */
831
832 /*!
833   \page MEDCouplingTimeLabelPage Time label in MEDCoupling
834
835 Time label is a **non instanciable** class whose each objects consuming potentially big amount of memory inherit from.
836 The class that incarnates this concept is ParaMEDMEM::TimeLabel.
837
838 Here some of examples of classes that inherit from \ref ParaMEDMEM::TimeLabel "TimeLabel" class :
839
840 - ParaMEDMEM::DataArrayInt, ParaMEDMEM::DataArrayDouble
841 - ParaMEDMEM::MEDCouplingMesh
842 - ParaMEDMEM::MEDCouplingFieldDouble
843 - ...
844
845 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.
846
847 The usage is simple :
848
849 - call ParaMEDMEM::TimeLabel::getTimeOfThis a first time to retrieve a reference. Store the returned unsigned integer.
850 - 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.
851   If the value is different, the instance has changed, if not the instance has **not** changed.
852
853 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.
854
855 */