Salome HOME
Join modifications from branch CEAFor_V3_2_0
[tools/medcoupling.git] / doc / MEDMEM / MEDMEM_UsersGuide.tex.in
1 %% LyX 1.1 created this file.  For more info, see http://www.lyx.org/.
2 %% Do not edit unless you really know what you are doing.
3 \documentclass[11pt,a4paper,english]{report}
4 \usepackage[T1]{fontenc}
5 \usepackage[latin1]{inputenc}
6 \usepackage{babel}
7 \usepackage{graphicx}                                                           \setcounter{secnumdepth}{3}
8 \setcounter{tocdepth}{3}
9 \setlength\parskip{\medskipamount}
10 \setlength\parindent{0pt}
11
12 \makeatletter
13
14 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% LyX specific LaTeX commands.
15 \providecommand{\LyX}{L\kern-.1667em\lower.25em\hbox{Y}\kern-.125emX\@}
16
17 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% User specified LaTeX commands.
18 % Packages
19 %%\usepackage[french]{babel}
20 %\usepackage{epsf}
21 %\usepackage[dvips]{graphicx}
22 %\usepackage{fancyhdr}
23 %\usepackage{pslatex}
24
25 %\usepackage[dvips,all,light]{draftcopy}
26
27 \usepackage{verbatim}
28
29 %  ___________________________________________________________________________
30 % |                                                                           |
31 % |                             MISE EN PAGE                                  |
32 % |___________________________________________________________________________|
33 %\draftcopyName{Projet}{200}
34
35 \setlength{\oddsidemargin}{0cm}
36 \setlength{\marginparsep}{0cm}
37 \setlength{\marginparwidth}{0cm}
38
39 \setlength{\textwidth}{16cm}
40
41 \setlength{\topmargin}{0cm}
42 \setlength{\headheight}{0cm}
43 \setlength{\headsep}{0cm}
44
45 \setlength{\textheight}{24cm}
46
47 %  ___________________________________________________________________________
48 % |                                                                           |
49 % |                             COMMANDES UTILISATEUR                         |
50 % |___________________________________________________________________________|
51
52 \newcommand{\method}[1]{method \mbox{\textbf{#1}}}
53
54 \newcommand{\myref}[1]{\ref{#1}, page \pageref{#1}}
55
56 \newcommand{\fileCxx}[1]{
57   \subsection{Full C++ example~: }
58   \label{#1}
59   \verbatiminput{@srcdir@/#1}
60 }
61
62 \newcommand{\filePython}[1]{
63   \subsection{Full Python example~: }
64   \label{#1}
65   \verbatiminput{@srcdir@/#1}
66 }
67
68
69 %  ___________________________________________________________________________
70 % |                                                                           |
71 % |                              LE DOCUMENT                                  |
72 % |___________________________________________________________________________|
73 %
74 \title{User's Guide Of Med Memory}
75 \author{Patrick Goldbronn \and Eric Fayolle \and Nadir Bouhamou \and Jerome Roy \and Nicolas Crouzet}
76
77 %  ___________________________________________________________________________
78 % |                                                                           |
79 % |                              DEBUT DU DOCUMENT                            |
80 % |___________________________________________________________________________|
81 %
82
83 \makeatother
84 \begin{document}
85 \sloppy
86
87 \maketitle
88
89
90 %  ___________________________________________________________________________
91 % |                                                                           |
92 % |                           TABLE DES MATIERES                              |
93 % |___________________________________________________________________________|
94 %
95 %\newpage
96 \cleardoublepage
97 \tableofcontents
98 %  ___________________________________________________________________________
99 % |                                                                           |
100 % |                             DEBUT DU TEXTE                                |
101 % |___________________________________________________________________________|
102
103 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
104 \chapter{Introduction}
105 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
106
107 \section{Convention}
108
109 \begin{itemize}
110
111 \item Difference between local and global number~: when we talk about an 
112 element number, we could see $i^{th}$ quadrangle ($i^{th}$ in quadrangles 
113 array~: local numbering) or $j^{th}$ element ($j^{th}$ in all elements array~: 
114 global numbering). This two numbering are equivalent only if we have one 
115 geometric type ;
116
117 \item All numbering begin at one (take care of array index !) ; 
118 \item When you get a C type array with a \texttt{get...} method, you must
119 not replace some value of it. Access is in read only. Other use may
120 product an impredicable result. To modify a such array use method
121 \texttt{set...} ;
122 \item Difference between local and global number~: when we talk about an
123 element number, we could see \( i^{th} \) quadrangle (\( i^{th} \)
124 in quadrangles array~: local numbering) or \( j^{th} \) element
125 (\( j^{th} \) in all elements array~: global numbering). This two
126 numbering are equivalent only if we have one geometric type.
127 \item They are many methods that have two syntax (one singular and one 
128 plural). Plurals methods returns array and singulars methods returns one 
129 particular value in this array (see \method{getCoordinate} and 
130 \method{getCoordinates}).
131
132 \end{itemize}
133
134 \section{UML diagram}
135
136 \includegraphics[width=16cm]{MEDMEM_UML.eps}
137
138 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
139 \chapter{How to use MED object}
140 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
141
142 \section{General Information}
143
144 A typical use of this object is to mount in memory what is in a MED file (or
145 any type of driver in red or read/write mode) and it will manage its memory on
146 its own. Then from this object one can get some information such as~:
147
148 \begin{itemize}
149 \item the number of meshes stored in this object using the
150 {\method{getNumberOfMeshes}}.
151 \item the number of fields stored in this object using the
152 {\method{getNumberOfFields}}.
153 \item a list of mesh names using the {\method{getMeshNames}}.
154 \item a list of field names using the {\method{getFieldNames}}.
155 \item a list of MESH object using the {\method{getMesh}}
156 \item a list of FIELD object using the {\method{getField}}
157 \item a list of SUPPORT object on all type of entities (node, cell,
158  face in 3d or edge on 2d) using the {\method{getSupport}}.
159 \end{itemize}
160
161 The destuctor of this object will destruct itself all FIELD, SUPPORT and MESH
162 objects; via its get method you will have a pointeur on this object and you
163 should never delete it.
164
165 One can add as well some MESH or FIELD object via the {\method{addMesh}} and
166 the {\method{addField}} respectively.
167
168 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
169 \chapter{How to use MESH object}
170 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
171
172
173 \section{General Information}
174
175 We could get some general information about a MESH object such as~: 
176
177 \begin{itemize}
178 \item name (\method{getName}) 
179 \item a description (\method{getDescription}) 
180 \item the space dimension (\method{getSpaceDimension}) 
181 \item the mesh dimension (\method{getMeshDimension}) 
182 \end{itemize}
183 \fileCxx{MESHgeneral.cxx}
184
185 \filePython{MESHgeneral.py}
186
187 \section{Information about nodes}
188
189 \begin{enumerate}
190 \item I want to get the number of nodes~: Realy simple, use \method{getNumberOfNodes}. 
191 \item I want to get the coordinates components names~: use \method{getCoordinatesNames}
192 which return a string array (one string for each space dimension) 
193 \item I want to get the coordinates components units~: use \method{getCoordinatesUnits}
194 which return a string array (one string for each space dimension) 
195 \item I want to get the coordinates system~: use \method{getCoordinatesSystem}
196 which return a string (\verb+"CARTESIAN"+, \verb+"CYLINDRICAL"+ or \verb+"SPHERICAL"+). 
197 \item I want to get the nodes coordinates~: use \method{getCoordinates}
198 which return a pointer to the coordinates array where values are interlace
199 or no. \textbf{Warning~:}
200
201 \begin{itemize}
202 \item When we get coordinates in \verb+MED_NO_INTERLACE+ mode, we get an
203 array where values are ordered like (\verb+X1,X2,X..., Y1,Y..., Z1,Z...+). 
204 \item When we get coordinates in \verb+MED_FULL_INTERLACE+ mode, we get
205 an array where values are ordered like (\verb+X1,Y1,Z1, X2,Y2,Z2, ...+). 
206 \end{itemize}
207 \item I want to get one particular value of coordinate~: use \method{getCoordinate}
208 which return the value of \( i^{th} \) node and \( j^{th} \) axis.
209 \end{enumerate}
210 \fileCxx{MESHcoordinates.cxx}
211
212 \filePython{MESHcoordinates.py}
213
214 \section{Information about cells}
215
216 \begin{enumerate}
217 \item I want to get the number of geometric type for a mesh entity~: use
218 \method{getNumberOfTypes}
219
220
221 \textbf{C++ Example~:}
222
223 \verb+int NumberOfCellsTypes = myMesh.getNumberOfTypes(MED_CELL);+
224
225 %%%%%%%%%%%%%%%%%
226 \item I want to get all geometric type for a mesh entity~: use 
227 \method{getTypes} to get an array of \verb+medGeometryElement+ 
228 (to use directly in others methods) or \method{getCellsTypes} to get 
229 an array of \verb+CELLMODEL+ (to ask mode information~: see \myref{CellModel}) .
230
231 \textbf{C++ Example~:}
232
233 \verb+const medGeometryElement * Types = myMesh.getTypes(MED_CELL);+
234
235 \verb+const CELLMODEL * CellsTypes = myMesh.getCellsTypes(MED_CELL);+
236
237 (each arrays are size \verb+NumberOfCellsTypes+)
238
239 \item I want to get the number of cells~: use \method{getNumberOfElements}
240 which return this information. You must give the mesh entity (\verb+MED_CELL+,
241 \verb+MED_FACE+, \verb+MED_EDGE+ or \verb+MED_NODE+) and a geometric
242 type of this entity.
243
244
245 \textbf{C++ Example~:}
246
247 \verb+int NumberOfTriangle = myMesh.getNumberOfElements(MED_FACE,MED_TRIA3);+
248
249 \verb+int NumberOfFace = myMesh.getNumberOfElements(MED_FACE,MED_ALL_ELEMENT);+
250
251 \item I want to get the geometric type of one element~: use \method{getElementType}
252 which return a \verb+medGeometryElement+.
253
254
255 \textbf{C++ Example~:}
256
257 \verb+medGeometryElement myType = myMesh.getElementType(MED_FACE,10);+
258
259 Return the \verb+medGeometryElement+ of \( 10^{th} \) face.
260
261 \item I want to get a connectivity~: use \method{getConnectivity} which
262 return an array with connectivity values.
263
264
265 \label{getConnectivity}
266
267 \textbf{C++ Example~:}
268
269 \begin{verbatim}
270 int NumberOfTetrahedron = myMesh.getNumberOfElements(MED_CELL,MED_TETRA4);
271 const int * TetrahedronConnectivity =
272          myMesh.getConnectivity(MED_FULL_ENTERLACE,
273                                 MED_NODAL,
274                                 MED_CELL,
275                                 MED_TETRA4);
276 \end{verbatim}
277 \verb+TetrahedronConnectivity+ contain nodal connectivity
278 of tetrahedron in mesh. It is arranged in full enterlace mode and
279 its size is \verb+NumberOfTetrahedron x 4+.
280
281 If you want to get connectivity of all elements (with \verb+Type=MED_ALL_ELEMENTS+),
282 you must use the index array (return by \method{getConnectivityIndex})
283 to get connectivity for each elements (see example \myref{MESHconnectivities.cxx}).
284
285 \item I want to get an element number from a connectivity~: use \method{getElementNumber}
286 which return the global number of a given connectivity.
287
288
289 \textbf{C++ Example~:}
290 \begin{verbatim}
291 int * myElementConnectivity = {2,10,12,14};
292 int myNumber = myMesh.getElementNumber(MED_NODAL,MED_CELL,
293                                              myElementConnectivity);
294 \end{verbatim}
295
296 %%%%%%%%%%%  WITH POLY METHODS %%%%%%%%%%%%
297
298 \item The listed above methods do not take into account information about
299   \verb+polygonal+ and \verb+polyhedral+ cells contained in a MESH object. To get
300   full information about cell types, use the same methods with
301   \verb+WithPoly+ postfix:
302 \begin{itemize}
303 \item use \method{getNumberOfTypesWithPoly} to get the number of
304   geometric types for a mesh entity;
305 \item use \method{getTypesWithPoly} to get all geometric types for a mesh entity;
306 \item use \method{getNumberOfElementsWithPoly} to get the number of cells;
307 \item use \method{getElementTypeWithPoly} to get the geometric type of
308   one element.
309 \end{itemize}
310 There are separate methods to get number of polygons and polyhedrons:
311 \method{getNumberOfPolygons} and \method{getNumberOfPolyhedron}
312
313 To get connectivity of polygonal elements, use \method{getPolygonsConnectivity} along with
314 \method{getPolygonsConnectivityIndex} (see example \myref{MESHconnectivities.cxx}).
315
316 To get nodal connectivity of polyhedral elements, it is necessary use together
317 3 methods: \method{getPolyhedronConnectivity}, \method{getPolyhedronFacesIndex}
318 and \method{getPolyhedronIndex} (see example \myref{MESHconnectivities.cxx}).
319
320 \end{enumerate}
321 \fileCxx{MESHconnectivities.cxx}
322
323 \filePython{MESHconnectivities.py}
324
325 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
326 \chapter{How to use MESHING object}
327 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
328
329 This class is a derivated class of MESH class to build a MESH object from 
330 scratch (use of set methods).
331
332 All verifications are under user responsability : If arrays values or arrays 
333 dimensions are wrongs, results are impredicable.
334
335 All arrays in arguments in set methods are duplicated in MESHING object.
336
337 \section{Build a MESHING}
338
339 \label{BuildMeshing}
340
341 \subsection{Coordinates}
342
343 First we must defined points coordinates of the mesh. We use 
344 \method{setCoordinates}.
345
346 \textbf{C++ Example~:}
347 \begin{verbatim}
348 MESHING myMeshing ;
349 const int SpaceDimension=2;
350 const int NumberOfNodes=6;
351 int * Coordinates = new int[SpaceDimension*NumberOfNodes] ;
352 string System="CARTESIAN";
353 medModeSwitch MED_FULL_INTERLACE ;
354 myMeshing.setCoordinates(SpaceDimension,NumberOfNodes,Coordinates,System,Mode);
355 \end{verbatim}
356
357 Then you could set the coordinates names and units (with 
358 \method{setCoordinatesNames} and \method{setCoordinatesUnits}).
359
360 \subsection{Connectivities}
361
362 When coordinates are defined, we could defined connectivities.
363
364 First we must defined connectivity of MED\_CELL elements. 
365 After, we could defined constituent connectivity if necesary 
366 (MED\_FACE and/or MED\_EDGE).
367
368 For each connectivities, you could use some methods in the following order :
369 \begin{itemize}
370 \item \method{setNumberOfTypes} to set the number of differents geometrics 
371 types (3 for example). This method allocates all arrays which size is this 
372 number ;
373 \item \method{setTypes} to set the differents geometrics types 
374 ({MED\_TETRA4,MED\_PYRA5,MED\_HEXA8} for example). Types should be given 
375 in increasing order of number of nodes for this type ;
376 \item \method{setNumberOfElements} to set the number of elements for 
377 each geometric type. This method allocates connectivities array ;
378 \item \method{setConnectivity} to set the connectivity in MED\_FULL\_INTERLACE
379 mode for each geometric type (use \method{setPolygonsConnectivity} and
380 \method{setPolyhedraConnectivity} for poly elements);
381 \end{itemize}
382
383 \textbf{C++ Example~:}
384 \begin{verbatim}
385 MESHING myMeshing ;
386 myMeshing.setCoordinates(SpaceDimension,NumberOfNodes,Coordinates,System,Mode);
387
388 myMeshing.setNumberOfTypes(2,MED_CELL);
389 myMeshing.setTypes({MED_TRIA3,MED_QUAD4},MED_CELL);
390 myMeshing.setNumberOfElements({3,2},MED_CELL); // 3 MED_TRIA3 and 2 MED_QUAD4
391 myMeshing.setConnectivity({1,2,3,6,8,9,4,5,6},MED_CELL,MED_TRIA3);
392 myMeshing.setConnectivity({1,3,4,5,4,5,7,8},MED_CELL,MED_QUAD4);
393 \end{verbatim}
394
395
396 \section{Defined a GROUP object}
397
398 To add a group in a MESHING object, use \method{addGroup}.
399
400 This method duplicate the GROUP object in the MESH object.
401
402 To build this GROUP object, use SUPPORT methods \ref{CreateSupport} to set all attributes.
403
404 \subsection{WARNING}
405
406 For instance, translation from GROUP objects to FAMILY objects are not completed !
407
408 You MUST set GROUP objects as if they are FAMILY objects.
409
410 This feature will be fully implemented in next release of med memory. 
411
412 \section{Example}
413
414 \fileCxx{MESHINGexample.cxx}
415
416 %\filePython{MESHINGexample.py}
417
418 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
419 \chapter{How to use SUPPORT object}
420 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
421
422 \section{Create a SUPPORT object}
423
424 \label{CreateSupport}
425
426 To create a SUPPORT object, you must give : 
427
428 \begin{itemize}
429 \item a reference to a MESH object 
430 \item its name 
431 \item on which mesh entity it apply to 
432 \end{itemize}
433 \textbf{C++ example~:}
434
435 \verb+SUPPORT mySupport(myMesh,"support on all faces",MED_FACE) ;+
436 By default, this support is defined on all elements of the given entity.
437
438 If you want a restricted SUPPORT, you must add manualy information
439 about what do you want~: 
440
441 \begin{itemize}
442 \item is not on all elements~: \verb+mySupport.setAll(false);+
443 \item on how many geometric type~:\\
444  \verb+mySupport.setNumberOfGeometricType(myNumberOfGeometricType);+
445 \item on which geometric type~:\\
446  \verb+mySupport.setGeometricType(myGeometricType);+
447 \item Temporary : the Gauss point number for each geometric type~:\\
448  \verb+mySupport.setNumberOfGaussPoint(myNumberOfGaussPoint);+
449 \item the number of elements for each geometric type~:\\
450  \verb+mySupport.setNumberOfEntities(myNumberOfEntities);+
451 \item the total number of elements~:\\
452  \verb+mySupport.setTotalNumberOfEntities(myTotalNumberOfEntities);+
453 \item the array which contains elements for each geometric type~:\\
454  \verb+mySupport.setNumber(myNumber);+
455 \end{itemize}
456 You could also use \method{setpartial} which set all you need.
457
458
459 \section{Use a SUPPORT object}
460
461 You could get all basic information (as you set them in \myref{CreateSupport})~: 
462
463 \begin{itemize}
464 \item \verb+getName()+
465 \item \verb+getDescription()+
466 \item \verb+getMesh()+
467 \item \verb+getEntity()+
468 \item \verb+isOnAllElements()+
469 \item \verb+getNumberOfTypes()+
470 \item \verb+getTypes()+
471 %\item \verb+getNumberOfGaussPoint()+
472 %\item \verb+getNumberOfGaussPoint(myGeometricType)+
473 \item \verb+getGeometricTypeNumber()+
474 \item \verb+getNumberOfElements(myGeometricType)+
475 \item \verb+getNumber(myGeometricType)+
476 \item \verb+getNumberIndex()+
477 \end{itemize}
478 For details about this methods, see the reference manual \cite{RefManual}.
479
480 The use of \method{getNumber} and \method{getNumberIndex} are the
481 same as \method{getConnectivity} and \method{getConnectivityIndex}
482 (see item \myref{getConnectivity}
483
484 There is another particular method to blend another SUPPORT object
485 into it.
486
487 For example in C++ : 
488 \begin{verbatim}
489 SUPPORT mySupport ;
490 SUPPORT myOtherSupport ;
491 ...
492 mySupport.blending(myOtherSupport) ;
493 \end{verbatim}
494
495 \verb+mySupport+ contain now all elements defined originally in it,
496 more those defined in \verb+myOtherSupport+.
497
498
499 \section{Case of FAMILY object}
500
501 A FAMILY is a SUPPORT with some additionnal methods that concern some optional attribut (we could have none) and group (we could also have none) :
502 \begin{itemize}
503 \item \method{getIdentifier} return the family identifier (an integer)
504
505 \item \method{getNumberOfAttributes} return the number of attributes of this family
506 \item \method{getAttributesIdentifiers} and \method{getAttributeIdentifier} return an integer array or an integer that represent attribut identifier.
507 \item \method{getAttributesValues} and \method{getAttributeValue} return an integer array or an integer that represent attribut value.
508 \item \method{getAttributesDescriptions} and \method{getAttributeDescription} return a string array or a string that represent attribut description.
509
510 \item \method{getNumberOfGroups} return the number of groups which it belog to.
511 \item \method{getGroupsNames} and \method{getGroupName} return a string array or a string that represent the group name which it belog to.
512
513 \end{itemize}
514
515 \section{Case of GROUP object}
516
517 A GROUP is a SUPPORT with some additionnal methods to find FAMILY that make up it :
518 \begin{itemize}
519 \item \method{getNumberOfFamilies} return the number of FAMILY that make up the GROUP ;
520 \item \method{getFamilies} and \method{getFamily} return a FAMILY  array or a FAMILY that  make up the GROUP.
521 \end{itemize}
522
523 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
524 \chapter{How to use Field}
525 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
526
527 \section{Introduction}
528
529 A field is characterized by its name (\method{getName}) and an optional description (\method{getDescription}).
530
531 It is also characterized by this calculating moment : 
532 \begin{itemize}
533 \item an iteration number (time step number)
534 \item an order number (use if there are internal iteration in a time step)
535 \item the time that correspond to this iteration number.
536 \end{itemize}
537
538 By default, there are no iteration and order number defined (value 
539 MED\_NOPDT and MED\_NONOR).
540
541 A field contain values which apply on some nodes or elements (cell, face or edge).
542
543 We find these informations from a SUPPORT object (see \method{getSupport}).
544
545 Each field have a number of components (\method getNumberOfComponents) and all these components have a name (\method{getComponentsNames} and \method{getComponentName}), a description (\method{getComponentsDescriptions} and \method{getComponentDescription}) and an unit (\method{getMEDComponentsUnits} and \method{getMEDComponentUnit}). 
546
547 For unit you could use later UNIT (\myref{Unit}) objet to make a more general control on it. But the use of this class must be specified.
548
549 To get values of a FIELD, you could use \method{getValue}, \method{getValueI} 
550 and \method{getValueIJ}~: 
551
552 \begin{itemize}
553 \item First return a reference to all values in the given mode (full or no 
554 interlace).
555 \item Second return a reference to $i^{th}$ element values or component values (in accordance with the given mode).
556 \item Third return the $j^{th}$ component of $i^{th}$ element.
557 \end{itemize}
558
559 \fileCxx{FIELDgeneral.cxx}
560
561 \filePython{FIELDgeneral.py}
562
563 \section{Create a Field}
564
565 It is simple to create a field object. You must know its SUPPORT and the number of components.
566
567 \textbf{Example :} 
568 \verb+FILED<double> myField(mySupport,NumberOfComponents) ;+
569
570 You must now set a name (\method{setName}) and optionaly a description 
571 (\method{setDescription}).
572
573 By default there are no iteration and order number (negative values) and 
574 time is null. You could change this by using \method{setIterationNumber},
575 \method{setOrderNumber} and \method{setTime}.
576
577 You \textbf{SHOULD} also set unit of your components with \method{setMEDComponentUnit}
578
579 To set value, use \method{setValueIJ} to put new value of field.
580
581 \fileCxx{FIELDcreate.cxx}
582
583 \filePython{FIELDcreate.py}
584
585 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
586 \chapter{Other Classes}
587 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
588
589
590 \section{class CELLMODEL}
591 \label{CellModel}
592
593 To do
594
595 \section{class UNIT}
596 \label{Unit}
597
598 To do
599
600 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
601 \chapter{Using drivers}
602 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
603
604 The generic driver mecanism gives users the possibility to write/read
605 the content of an object according to a specified file format. The
606 semantic remains the same whatever the object is (MESH, FIELD, MED).
607 By the way it allows using several file formats for writting an object.
608
609
610 \section{Invoking a driver}
611
612
613 \subsection{Invoking a driver at creation object time}
614
615 This is the simplest way of invoking a driver. The driver parameters
616 are given to the constructor of the object.  Except for the MED object,
617 this way of invoking a driver assume you know exactly the name of
618 the MESH/FIELD you want read from a file <fileName> of type <driverType>.
619
620 ex 1.1 : For a FIELD object, invoking FIELD<double> myField(MED\_DRIVER,fileName,fieldName)
621 create a FIELD object and a driver which loads the mesh <fieldName>
622 from the MED file <fileName> (Not implemented yet !).
623
624 ex 1.2 : To remove the default driver previously created myField->rmDriver();
625
626 ex 2 : For a MESH object, invoking MESH myMesh(MED\_DRIVER,fileName,meshName)
627 create a MESH object and a driver which loads the mesh <meshName>
628 from the MED file <fileName>.
629
630 ex 3 : For a MED object, invoking MED myMed(MED\_DRIVER,fileName)
631 create a MED object to explore the MED file <fileName>.
632
633 rem 1 : ex1 is equivalent to \ref{sec:invoking_a_driver_from_the_std_drv_method}
634 ex1.
635
636 rem 2 : Since the driver has read the object, the associated file
637 is closed. You can reread the object with the default driver by calling
638 the read() method : myObject.read().
639
640 \fileCxx{MEDMEM_InvokingDriverAtObjectCreationTime.cxx}
641
642 \filePython{MEDMEM_InvokingDriverAtObjectCreationTime.py}
643
644 \subsection{Invoking a driver from the standard driver method of an object\label{sec:invoking_a_driver_from_the_std_drv_method}}
645
646 This way of invoking a driver give the possiblility to add several
647 drivers to an exiting object.
648
649 ex1 : First we create a FIELD without any driver FIELD<double>~{*}~myField1~=~new~FIELD<double>;
650 then we add a driver with int myDriver1 = myField1->addDriver(driverType1,
651 fileName1, fieldName1); for reading <fieldName1> from file <fileName1>
652 with myField1->read(myDriver1);
653
654 ex2 : We add a new driver of type <driverType2> int myDriver2 = myField1->addDriver(driverType2,
655 fileName2,fieldName2); in order to write myField1 in file <fileName2>
656 with <fieldName2> name using command myField1->write(myDriver2);
657
658 rem 1 : Files are openned then closed each time you call read() or
659 write() methods.
660
661 rem 2 : If you use more than a driver you need to keep the driver
662 handlers (myDriverI ).
663
664 \fileCxx{MEDMEM_InvokingDriverFromStandardObjectMethod.cxx}
665
666 \filePython{MEDMEM_InvokingDriverFromStandardObjectMethod.py}
667
668 \subsection{Invoking a driver and attaching it to an existing object}
669
670 The methods exposed in the two previous sections always create drivers
671 in read/write access mode. Another way of creating a driver is to
672 create a driver with a specific access mode.
673
674 ex1 : First we create a FIELD without any driver FIELD<double>~{*}~myField1~=~new
675 FIELD<double>(); then we create a read-only driver MED\_FIELD\_RDONLY\_DRIVER<double>~myRdOnlyDriver(fileName1,myField1);
676 and attached it to myField1. Finally you must set the fieldName1 you
677 want to acess in fileName1 with myRdOnlyDriver->setFieldName(fieldName1);
678 in order to read the field with myRdOnlyDriver->open(); myRdOnlyDriver->read();
679
680 Don't forget to close the file with myRdOnlyDriver->close().
681
682 ToDo : By now when you create such specific drivers, the object doesn't
683 know anything about it. 
684
685 \fileCxx{MEDMEM_InvokingDriverByAttachingItToAnObject.cxx}
686
687 \filePython{MEDMEM_InvokingDriverByAttachingItToAnObject.py}
688
689 \section{Using the MED driver}
690
691 The MED object provides the ability of :
692
693 \begin{enumerate}
694 \item \noindent Obtainning a reference on the whole structure contained
695 in a file.
696 \item Obtainning the list of all the Meshes/Fields names contained in a
697 file.
698 \item Obtainning a Mesh/Field reference using a name.
699 \item Writting a whole set of independent objects with a simple command. 
700 \end{enumerate}
701
702 \subsection{Exploring files}
703
704 In this first use case the user wants to explore the meshes \& fields
705 containned within a file <filename> of type given by the <drivertype>
706 parameter.
707
708 ex 1 : Calling MED {*} myMed = new MED(driverType1, fileName1); create
709 a MED object which open fileName1, read all MESHes/FIELDs relations
710 then close the file. 
711
712 This is equivalent to MED~{*}~myMed~=~new~MED(); myDriver~=~myMed->addDriver(driverType1,fileName1);
713 myMed->readFileStruct(myDriver); 
714
715 ex 2 : To get the list of meshNames from a MED object, first ask the
716 object how many meshes it had by calling int numberOfMeshes~=~myMed->getNumberOfMeshes();
717 then get the list with myMeshNames~=~new string{[}getMeshNames{]};
718 myMed->getMeshNames(myMeshNames). 
719
720 Note you can also use the deque<string> getMeshNames() method. 
721
722 ex 3 : To get a list of fieldNames from a MED object, first ask the
723 object how many fields it had by calling int numberOfFields~=~myMed->getNumberOfFields();
724 then get the list with myFieldNames~=~new string{[}getFieldNames{]};
725 myMed->getFieldNames(myFieldNames).
726
727 ex 4 :To get a particular MESH use MESH {*} myMesh1 = myMED->getMesh(myMeshNames{[}0{]}) 
728
729 ex 5 :To get a particular FIELD you first need to know what (time
730 step, iteration number) list is used by calling deque<DT\_IT\_>~myField1DtIt~=~myMed->getFieldIteration(FieldName{[}0{]})
731 ; then you can ask for getting a specific FIELD with FIELD~{*}~myField1~=~myMED->getField(myFieldNames{[}0{]},myField1DtIt{[}0{]}.dt,myField1DtIt{[}0{]}.it).
732
733 ex2 : To write the whole content of a MED object first add a driver
734 myDriver2~=~myMed.addDriver(driverType2,~fileName2); then ask for
735 writing the object myMed->write(myDriver2); (not implemented yet !) 
736
737 You can remove the driver with myMed->rmDriver(myDriver2);
738
739 rem 1 : It is possible to use multiple drivers to read a set of FIELDs
740 / MESHes from various file formats and writing the whole set through
741 a specific write.(not implemented yet !) 
742
743
744 \subsubsection{Adding existing MESHes/FIELDs objects}
745
746 Not yet implemented.
747
748 \section{Using the VTK driver}
749
750 This driver allow to save all MESH and FIELD objects in an ASCII file in 
751 VTK format \cite{vtk}.
752
753 You could use this driver only from a MED object, because VTK file format 
754 impose to write objects in particular order.
755
756 \textbf{C++ Example~:}
757 \begin{verbatim}
758 MED myMed(MED_DRIVER,"file.med");
759 myMed.read();
760 int id = myMed.addDriver(VTK_DRIVER,"file.vtk");
761 myMed.write(id) ;
762 \end{verbatim}
763
764 \section{Using the GIBI driver}
765
766 This driver allow to load a mesh from a GIBI file (ASCII file with the extension '.sauve'), puting the mesh into a MESH object of MED. It's a read only driver and is applicable only to a MESH object.
767
768 \textbf{C++ Example~:}
769 \begin{verbatim}
770 MESH * myMesh= new MESH() ;     
771 GIBI_MESH_RDONLY_DRIVER myGibiMeshDriver("file.sauve", myMesh) ;
772 myGibiMeshDriver.open() ;
773 myGibiMeshDriver.read() ;
774 myGibiMeshDriver.close() ;
775 \end{verbatim}
776
777
778 %  ___________________________________________________________________________
779 % |                                                                           |
780 % |                               REFERENCES                                  |
781 % |___________________________________________________________________________|
782 %
783 \newpage
784 %\thebibliography{biblio}
785 \begin{thebibliography}{1}
786
787 \addcontentsline{toc}{chapter}{\refname}
788
789 \addcontentsline{toc}{chapter}{Bibliography}
790
791 \bibitem{RefManual} Reference Manual~: \verb+http://www-drn2.cea.fr/MED/MEDMEM/DOC/html/index.html+
792
793 \bibitem{vtk} VTK home page~: \verb+http://public.kitware.com/VTK+
794
795 \end{thebibliography}
796
797
798 \end{document}