Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/med.git] / src / MEDMEMBinTest / test_MEDMEM_Meshing.cxx
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //#define protected public
24 //#define private public
25 //
26 #include "MEDMEM_Meshing.hxx"
27 #include "MEDMEM_Group.hxx"
28 #include "MEDMEM_Field.hxx"
29 #ifdef WNT
30 #include <io.h>
31 #define access _access
32 #define W_OK 02
33 #endif
34
35 using namespace std;
36 using namespace MEDMEM;
37 using namespace MED_EN;
38 using namespace DRIVERFACTORY;
39
40 int main (int argc, char ** argv)
41 {
42   if (argc >2)
43   {
44     cerr << "Usage : " << argv[0] 
45          << " filenameRoot" << endl;
46     cerr << "        where filenameRoot is a root filename, the program will produce" << endl;
47     cerr << "        3 files filenameRoot21.med filenameRoot22.med and filenameRoot.vtk" << endl << endl;
48     exit(-1);
49   }
50
51   string filenameRoot;
52   if (argc==1)
53   {
54     // filename to save the generated MESH
55     if ( getenv("TMP") && access(getenv("TMP"),W_OK)==0 )
56       filenameRoot=getenv("TMP");
57     else if (getenv("TMPDIR") && access(getenv("TMPDIR"),W_OK)==0 )
58       filenameRoot=getenv("TMPDIR");
59     else
60       filenameRoot="/tmp";
61     filenameRoot += "/test_MEDMEM_Meshing" ;
62   }
63   else
64     filenameRoot=argv[1];
65
66   string filenameMed21 = filenameRoot+"_V21.med";
67   string filenameMed22 = filenameRoot+"_V22.med";
68   string filenameVtk = filenameRoot+".vtk";
69
70   MESHING *myMeshing=new MESHING;
71   myMeshing->setName("meshing") ;
72
73   // define coordinates
74
75   int SpaceDimension = 3 ;
76   int NumberOfNodes = 19 ;
77   double Coordinates[57] =
78     {
79       0.0, 0.0, 0.0, 
80       0.0, 0.0, 1.0, 
81       2.0, 0.0, 1.0, 
82       0.0, 2.0, 1.0, 
83       -2.0, 0.0, 1.0, 
84       0.0, -2.0, 1.0, 
85       1.0, 1.0, 2.0, 
86       -1.0, 1.0, 2.0, 
87       -1.0, -1.0, 2.0, 
88       1.0, -1.0, 2.0, 
89       1.0, 1.0, 3.0, 
90       -1.0, 1.0, 3.0, 
91       -1.0, -1.0, 3.0, 
92       1.0, -1.0, 3.0, 
93       1.0, 1.0, 4.0, 
94       -1.0, 1.0, 4.0, 
95       -1.0, -1.0, 4.0, 
96       1.0, -1.0, 4.0,
97       0.0, 0.0, 5.0
98     };
99
100   myMeshing->setCoordinates(SpaceDimension,NumberOfNodes,Coordinates,"CARTESIAN",MED_FULL_INTERLACE);
101
102   string Names[3] =
103     {
104       "X","Y","Z"
105     } ;
106   myMeshing->setCoordinatesNames(Names);
107
108   string Units[3] =
109     {
110       "cm","cm","cm"
111     } ;
112   myMeshing->setCoordinatesUnits(Units) ;
113
114   // define conectivities
115
116   // cell part
117
118   const int NumberOfTypes = 3 ;
119   medGeometryElement Types[NumberOfTypes] = 
120     {
121       MED_TETRA4,MED_PYRA5,MED_HEXA8
122     } ;
123   const int NumberOfElements[NumberOfTypes] = 
124     {
125       12,2,2
126     } ;
127
128   myMeshing->setNumberOfTypes(NumberOfTypes,MED_CELL);
129   myMeshing->setTypes(Types,MED_CELL);
130   myMeshing->setNumberOfElements(NumberOfElements,MED_CELL);
131
132   const int sizeTetra = 12*4 ;
133   int ConnectivityTetra[sizeTetra]=
134     {
135       1,2,3,6,
136       1,2,4,3,
137       1,2,5,4,
138       1,2,6,5,
139       2,7,4,3,
140       2,8,5,4,
141       2,9,6,5,
142       2,10,3,6,
143       2,7,3,10,
144       2,8,4,7,
145       2,9,5,8,
146       2,10,6,9
147     };
148
149   myMeshing->setConnectivity(MED_CELL,MED_TETRA4,ConnectivityTetra);
150
151   int ConnectivityPyra[2*5]=
152     {
153       7,8,9,10,2,
154       15,18,17,16,19
155     };
156
157   myMeshing->setConnectivity(MED_CELL,MED_PYRA5,ConnectivityPyra);
158
159   int ConnectivityHexa[2*8]=
160     {
161       11,12,13,14,7,8,9,10,
162       15,16,17,18,11,12,13,14
163     };
164
165   myMeshing->setConnectivity(MED_CELL,MED_HEXA8,ConnectivityHexa);
166
167   // face part
168
169   const int NumberOfFacesTypes = 2 ;
170   medGeometryElement FacesTypes[NumberOfFacesTypes] =
171     {
172       MED_TRIA3,MED_QUAD4
173     } ;
174   const int NumberOfFacesElements[NumberOfFacesTypes] =
175     {
176       4,4
177     } ;
178
179   myMeshing->setNumberOfTypes(NumberOfFacesTypes,MED_FACE);
180   myMeshing->setTypes(FacesTypes,MED_FACE);
181   myMeshing->setNumberOfElements(NumberOfFacesElements,MED_FACE);
182
183   const int sizeTria = 3*4 ;
184   int ConnectivityTria[sizeTria]=
185     {
186       1,4,3,
187       1,5,4,
188       1,6,5,
189       1,3,6
190     };
191   myMeshing->setConnectivity(MED_FACE,MED_TRIA3,ConnectivityTria);
192
193   int ConnectivityQua[4*4]=
194     {
195       7,8,9,10,
196       11,12,13,14,
197       11,7,8,12,
198       12,8,9,13
199     };
200
201   myMeshing->setConnectivity(MED_FACE,MED_QUAD4,ConnectivityQua);
202
203   // edge part
204
205   // not yet implemented : if set, results are unpredictable.
206
207   // Some groups :
208
209   // Node :
210
211   GROUP *partialGroupOnNodes=new GROUP;
212   {
213     partialGroupOnNodes->setName("SomeNodes");
214     partialGroupOnNodes->setMesh(myMeshing);
215     partialGroupOnNodes->setEntity(MED_NODE);
216     partialGroupOnNodes->setNumberOfGeometricType(1);
217     medGeometryElement myTypes[1] = 
218       {
219         MED_NONE
220       };
221     partialGroupOnNodes->setGeometricType(myTypes);
222     const int myNumberOfElements[1] = 
223       {
224         4
225       } ;
226     partialGroupOnNodes->setNumberOfElements(myNumberOfElements);
227     const int index[1+1] = 
228       {
229         1,5
230       } ;
231     const int value[4]= 
232       {
233         1,4,5,7
234       } ;
235     partialGroupOnNodes->setNumber(index,value);
236   }
237   GROUP *partialGroupOnNodes2=new GROUP;
238   {
239     partialGroupOnNodes2->setName("OtherNodes");
240     partialGroupOnNodes2->setMesh(myMeshing);
241     partialGroupOnNodes2->setEntity(MED_NODE);
242     partialGroupOnNodes2->setNumberOfGeometricType(1);
243     medGeometryElement myTypes[1] = 
244       {
245         MED_NONE
246       };
247     partialGroupOnNodes2->setGeometricType(myTypes);
248     const int myNumberOfElements[1] = 
249       {
250         3
251       } ;
252     partialGroupOnNodes2->setNumberOfElements(myNumberOfElements);
253     const int index[1+1] = 
254       {
255         1,4
256       } ;
257     const int value[3]= 
258       {
259         2,3,6
260       } ;
261     partialGroupOnNodes2->setNumber(index,value);
262   }
263   myMeshing->addGroup(*partialGroupOnNodes2);
264
265
266   // Cell :
267
268   GROUP *partialGroupOnCells=new GROUP;
269   {
270     partialGroupOnCells->setName("SomeCells");
271     partialGroupOnCells->setMesh(myMeshing);
272     partialGroupOnCells->setEntity(MED_CELL);
273     partialGroupOnCells->setNumberOfGeometricType(3);
274     medGeometryElement myTypes[3] = 
275       {
276         MED_TETRA4,MED_PYRA5,MED_HEXA8
277       };
278     partialGroupOnCells->setGeometricType(myTypes);
279     const int myNumberOfElements[3] = 
280       {
281         4,1,2
282       } ;
283     partialGroupOnCells->setNumberOfElements(myNumberOfElements);
284     const int index[3+1] = 
285       {
286         1,5,6,8
287       } ;
288     const int value[4+1+2]=
289       {
290         2,7,8,12,
291         13,
292         15,16
293       };
294     partialGroupOnCells->setNumber(index,value);
295   }
296   myMeshing->addGroup(*partialGroupOnCells);
297
298
299   GROUP *partialGroupOnCells2=new GROUP;
300   {
301     partialGroupOnCells2->setName("OtherCells");
302     partialGroupOnCells2->setMesh(myMeshing);
303     partialGroupOnCells2->setEntity(MED_CELL);
304     partialGroupOnCells2->setNumberOfGeometricType(2);
305     medGeometryElement myTypes[] = 
306       {
307         MED_TETRA4,MED_PYRA5
308       };
309     partialGroupOnCells2->setGeometricType(myTypes);
310     const int myNumberOfElements[] = 
311       {
312         4,1
313       } ;
314     partialGroupOnCells2->setNumberOfElements(myNumberOfElements);
315     const int index[2+1] = 
316       {
317         1,5,6
318       } ;
319     const int value[4+1]=
320       {
321         3,4,5,9,
322         14
323       };
324     partialGroupOnCells2->setNumber(index,value);
325   }
326   myMeshing->addGroup(*partialGroupOnCells2);
327
328   // Face :
329
330   GROUP *partialGroupOnFaces=new GROUP;
331   {
332     partialGroupOnFaces->setName("SomeFaces");
333     partialGroupOnFaces->setMesh(myMeshing);
334     partialGroupOnFaces->setEntity(MED_FACE);
335     partialGroupOnFaces->setNumberOfGeometricType(2);
336     medGeometryElement myTypes[2] = 
337       {
338         MED_TRIA3,MED_QUAD4
339       };
340     partialGroupOnFaces->setGeometricType(myTypes);
341     const int myNumberOfElements[2] = 
342       {
343         2,3
344       } ;
345     partialGroupOnFaces->setNumberOfElements(myNumberOfElements);
346     const int index[2+1] = 
347       {
348         1,3,6
349       } ;
350     const int value[2+3]=
351       {
352         2,4,
353         5,6,8
354       } ;
355     partialGroupOnFaces->setNumber(index,value);
356   }
357   myMeshing->addGroup(*partialGroupOnFaces);
358
359
360   GROUP *partialGroupOnFaces2=new GROUP;
361   {
362     partialGroupOnFaces2->setName("OtherFaces");
363     partialGroupOnFaces2->setMesh(myMeshing);
364     partialGroupOnFaces2->setEntity(MED_FACE);
365     medGeometryElement myTypes[1] = 
366       {
367         MED_TRIA3
368       };
369     int myNumberOfElements[1] = 
370       {
371         2
372       } ;
373     int value[2]=
374       {
375         1,3
376       } ;
377     //    partialGroupOnFaces2->setNumber(index,value);
378     partialGroupOnFaces2->setpartial("description",1,2,myTypes,myNumberOfElements,value);
379   }
380   myMeshing->addGroup(*partialGroupOnFaces2);
381
382   // all right, we save it in Med 2.1 2.2 and vtk !
383
384   int idMed22 = myMeshing->addDriver(MED_DRIVER,filenameMed22,myMeshing->getName());
385   myMeshing->write(idMed22) ;
386
387   int idVtk = myMeshing->addDriver(VTK_DRIVER,filenameVtk,myMeshing->getName());
388   myMeshing->write(idVtk) ;
389
390   // we build now 8 fields : 4 fields double (integer) :
391   //                         2 fields on nodes (cells) :
392   //                         1 scalar (vector)
393
394   const SUPPORT * supportOnNodes = myMeshing->getSupportOnAll(MED_NODE);
395   int numberOfNodes = supportOnNodes->getNumberOfElements(MED_ALL_ELEMENTS);
396
397   const SUPPORT * supportOnCells = myMeshing->getSupportOnAll(MED_CELL);
398   myMeshing->removeReference();
399   int numberOfCells = supportOnCells->getNumberOfElements(MED_ALL_ELEMENTS);
400
401   FIELD<double> * fieldDoubleScalarOnNodes = new FIELD<double>(supportOnNodes,1);
402   fieldDoubleScalarOnNodes->setName("fieldScalarDoubleNode");
403   fieldDoubleScalarOnNodes->setIterationNumber(-1);
404   fieldDoubleScalarOnNodes->setOrderNumber(-1);
405   fieldDoubleScalarOnNodes->setTime(0.0);
406
407   fieldDoubleScalarOnNodes->setComponentName(1,"Vx");
408   fieldDoubleScalarOnNodes->setComponentDescription(1,"comp1");
409   fieldDoubleScalarOnNodes->setMEDComponentUnit(1,"unit1");
410   FIELD<double>* fieldDoubleScalarOnPartialNodes = new FIELD<double>(partialGroupOnNodes,1);
411   fieldDoubleScalarOnPartialNodes->setName("fieldScalarDoublePartialNodes");
412   fieldDoubleScalarOnPartialNodes->setIterationNumber(-1);
413   fieldDoubleScalarOnPartialNodes->setOrderNumber(-1);
414   fieldDoubleScalarOnPartialNodes->setTime(0.0);
415   fieldDoubleScalarOnPartialNodes->setComponentName(1,"Vx");
416   fieldDoubleScalarOnPartialNodes->setComponentDescription(1,"comp1");
417   fieldDoubleScalarOnPartialNodes->setMEDComponentUnit(1,"unit1");
418
419
420   FIELD<double> * fieldDoubleVectorOnNodes = new FIELD<double>(supportOnNodes,SpaceDimension);
421   fieldDoubleVectorOnNodes->setName("fieldVectorDoubleNode");
422   fieldDoubleVectorOnNodes->setIterationNumber(-1);
423   fieldDoubleVectorOnNodes->setOrderNumber(-1);
424   fieldDoubleVectorOnNodes->setTime(0.0);
425
426   fieldDoubleVectorOnNodes->setComponentName(1,"Vx");
427   fieldDoubleVectorOnNodes->setComponentDescription(1,"comp1");
428   fieldDoubleVectorOnNodes->setMEDComponentUnit(1,"unit1");
429   fieldDoubleVectorOnNodes->setComponentName(2,"Vy");
430   fieldDoubleVectorOnNodes->setComponentDescription(2,"comp2");
431   fieldDoubleVectorOnNodes->setMEDComponentUnit(2,"unit2");
432   fieldDoubleVectorOnNodes->setComponentName(3,"Vz");
433   fieldDoubleVectorOnNodes->setComponentDescription(3,"comp3");
434   fieldDoubleVectorOnNodes->setMEDComponentUnit(3,"unit3");
435
436   FIELD<double> * fieldDoubleScalarOnCells = new FIELD<double>(supportOnCells,1);
437   fieldDoubleScalarOnCells->setName("fieldScalarDoubleCell");
438   fieldDoubleScalarOnCells->setIterationNumber(-1);
439   fieldDoubleScalarOnCells->setOrderNumber(-1);
440   fieldDoubleScalarOnCells->setTime(0.0);
441
442   fieldDoubleScalarOnCells->setComponentName(1,"Vx");
443   fieldDoubleScalarOnCells->setComponentDescription(1,"comp1");
444   fieldDoubleScalarOnCells->setMEDComponentUnit(1,"unit1");
445
446
447   FIELD<double> * fieldDoubleScalarOnPartialCells = new FIELD<double>(partialGroupOnCells,1);
448   fieldDoubleScalarOnPartialCells->setName("fieldScalarDoublePartialCell");
449   fieldDoubleScalarOnPartialCells->setIterationNumber(-1);
450   fieldDoubleScalarOnPartialCells->setOrderNumber(-1);
451   fieldDoubleScalarOnPartialCells->setTime(0.0);
452
453   fieldDoubleScalarOnPartialCells->setComponentName(1,"Vx");
454   fieldDoubleScalarOnPartialCells->setComponentDescription(1,"comp1");
455   fieldDoubleScalarOnPartialCells->setMEDComponentUnit(1,"unit1");
456
457   FIELD<double> * fieldDoubleScalarOnPartialFaces = new FIELD<double>(partialGroupOnFaces,1);
458   fieldDoubleScalarOnPartialFaces->setName("fieldScalarDoublePartialFace");
459   fieldDoubleScalarOnPartialFaces->setIterationNumber(-1);
460   fieldDoubleScalarOnPartialFaces->setOrderNumber(-1);
461   fieldDoubleScalarOnPartialFaces->setTime(0.0);
462   fieldDoubleScalarOnPartialFaces->setComponentName(1,"Vx");
463   fieldDoubleScalarOnPartialFaces->setComponentDescription(1,"comp1");
464   fieldDoubleScalarOnPartialFaces->setMEDComponentUnit(1,"unit1");
465
466   FIELD<double> * fieldDoubleVectorOnPartialFaces = new FIELD<double>(partialGroupOnFaces2,2);
467   fieldDoubleVectorOnPartialFaces->setName("fieldVectorDoublePartialFace");
468   fieldDoubleVectorOnPartialFaces->setIterationNumber(-1);
469   fieldDoubleVectorOnPartialFaces->setOrderNumber(-1);
470   fieldDoubleVectorOnPartialFaces->setTime(0.0);
471   fieldDoubleVectorOnPartialFaces->setComponentName(1,"Vx");
472   fieldDoubleVectorOnPartialFaces->setComponentName(2,"Vy");
473
474   fieldDoubleVectorOnPartialFaces->setComponentDescription(1,"comp1");
475   fieldDoubleVectorOnPartialFaces->setComponentDescription(2,"comp2");
476
477   fieldDoubleVectorOnPartialFaces->setMEDComponentUnit(1,"unit1");
478   fieldDoubleVectorOnPartialFaces->setMEDComponentUnit(2,"unit2");
479
480
481   FIELD<double> * fieldDoubleVectorOnCells = new FIELD<double>(supportOnCells,SpaceDimension);
482   fieldDoubleVectorOnCells->setName("fieldVectorrDoubleCell");
483   fieldDoubleVectorOnCells->setIterationNumber(-1);
484   fieldDoubleVectorOnCells->setOrderNumber(-1);
485   fieldDoubleVectorOnCells->setTime(0.0);
486
487   fieldDoubleVectorOnCells->setComponentName(1,"Vx");
488   fieldDoubleVectorOnCells->setComponentDescription(1,"comp1");
489   fieldDoubleVectorOnCells->setMEDComponentUnit(1,"unit1");
490   fieldDoubleVectorOnCells->setComponentName(2,"Vy");
491   fieldDoubleVectorOnCells->setComponentDescription(2,"comp2");
492   fieldDoubleVectorOnCells->setMEDComponentUnit(2,"unit2");
493   fieldDoubleVectorOnCells->setComponentName(3,"Vz");
494   fieldDoubleVectorOnCells->setComponentDescription(3,"comp3");
495   fieldDoubleVectorOnCells->setMEDComponentUnit(3,"unit3");
496
497   FIELD<int> * fieldIntScalarOnNodes = new FIELD<int>(supportOnNodes,1);
498   fieldIntScalarOnNodes->setName("fieldScalarIntNode");
499   fieldIntScalarOnNodes->setIterationNumber(-1);
500   fieldIntScalarOnNodes->setOrderNumber(-1);
501   fieldIntScalarOnNodes->setTime(0.0);
502
503   fieldIntScalarOnNodes->setComponentName(1,"Vx");
504   fieldIntScalarOnNodes->setComponentDescription(1,"comp1");
505   fieldIntScalarOnNodes->setMEDComponentUnit(1,"unit1");
506
507   FIELD<int> * fieldIntVectorOnNodes = new FIELD<int>(supportOnNodes,SpaceDimension);
508   fieldIntVectorOnNodes->setName("fieldVectorIntNode");
509   fieldIntVectorOnNodes->setIterationNumber(-1);
510   fieldIntVectorOnNodes->setOrderNumber(-1);
511   fieldIntVectorOnNodes->setTime(0.0);
512
513   fieldIntVectorOnNodes->setComponentName(1,"Vx");
514   fieldIntVectorOnNodes->setComponentDescription(1,"comp1");
515   fieldIntVectorOnNodes->setMEDComponentUnit(1,"unit1");
516   fieldIntVectorOnNodes->setComponentName(2,"Vy");
517   fieldIntVectorOnNodes->setComponentDescription(2,"comp2");
518   fieldIntVectorOnNodes->setMEDComponentUnit(2,"unit2");
519   fieldIntVectorOnNodes->setComponentName(3,"Vz");
520   fieldIntVectorOnNodes->setComponentDescription(3,"comp3");
521   fieldIntVectorOnNodes->setMEDComponentUnit(3,"unit3");
522
523   FIELD<int> * fieldIntScalarOnCells = new FIELD<int>(supportOnCells,1);
524   fieldIntScalarOnCells->setName("fieldScalarIntCell");
525   fieldIntScalarOnCells->setIterationNumber(-1);
526   fieldIntScalarOnCells->setOrderNumber(-1);
527   fieldIntScalarOnCells->setTime(0.0);
528
529   fieldIntScalarOnCells->setComponentName(1,"Vx");
530   fieldIntScalarOnCells->setComponentDescription(1,"comp1");
531   fieldIntScalarOnCells->setMEDComponentUnit(1,"unit1");
532
533   FIELD<int> * fieldIntVectorOnCells = new FIELD<int>(supportOnCells,SpaceDimension);
534   fieldIntVectorOnCells->setName("fieldVectorrIntCell");
535   fieldIntVectorOnCells->setIterationNumber(-1);
536   fieldIntVectorOnCells->setOrderNumber(-1);
537   fieldIntVectorOnCells->setTime(0.0);
538
539   fieldIntVectorOnCells->setComponentName(1,"Vx");
540   fieldIntVectorOnCells->setComponentDescription(1,"comp1");
541   fieldIntVectorOnCells->setMEDComponentUnit(1,"unit1");
542   fieldIntVectorOnCells->setComponentName(2,"Vy");
543   fieldIntVectorOnCells->setComponentDescription(2,"comp2");
544   fieldIntVectorOnCells->setMEDComponentUnit(2,"unit2");
545   fieldIntVectorOnCells->setComponentName(3,"Vz");
546   fieldIntVectorOnCells->setComponentDescription(3,"comp3");
547   fieldIntVectorOnCells->setMEDComponentUnit(3,"unit3");
548
549   for (int i = 0; i<numberOfNodes; i++)
550   {
551     double valueDbl1, valueDbl2, valueDbl3;
552     int valueInt1, valueInt2, valueInt3;
553     valueInt1 = i+1;
554     valueInt2 = i+2;
555     valueInt3 = i+3;
556     valueDbl1 = valueInt1*0.1;
557     valueDbl2 = valueInt2*0.1;
558     valueDbl3 = valueInt3*0.1;
559     fieldDoubleScalarOnNodes->setValueIJ(i+1,1,valueDbl1);
560
561     fieldIntScalarOnNodes->setValueIJ(i+1,1,valueInt1);
562
563     fieldDoubleVectorOnNodes->setValueIJ(i+1,1,valueDbl1);
564     fieldDoubleVectorOnNodes->setValueIJ(i+1,2,valueDbl2);
565     fieldDoubleVectorOnNodes->setValueIJ(i+1,3,valueDbl3);
566
567     fieldIntVectorOnNodes->setValueIJ(i+1,1,valueInt1);
568     fieldIntVectorOnNodes->setValueIJ(i+1,2,valueInt2);
569     fieldIntVectorOnNodes->setValueIJ(i+1,3,valueInt3);
570   }
571
572   for (int i = 0; i<numberOfCells; i++)
573   {
574     double valueDbl1, valueDbl2, valueDbl3;
575     int valueInt1, valueInt2, valueInt3;
576     valueInt1 = i+1;
577     valueInt2 = i+2;
578     valueInt3 = i+3;
579     valueDbl1 = valueInt1*0.1;
580     valueDbl2 = valueInt2*0.1;
581     valueDbl3 = valueInt3*0.1;
582     fieldDoubleScalarOnCells->setValueIJ(i+1,1,valueDbl1);
583
584     fieldIntScalarOnCells->setValueIJ(i+1,1,valueInt1);
585
586     fieldDoubleVectorOnCells->setValueIJ(i+1,1,valueDbl1);
587     fieldDoubleVectorOnCells->setValueIJ(i+1,2,valueDbl2);
588     fieldDoubleVectorOnCells->setValueIJ(i+1,3,valueDbl3);
589
590     fieldIntVectorOnCells->setValueIJ(i+1,1,valueInt1);
591     fieldIntVectorOnCells->setValueIJ(i+1,2,valueInt2);
592     fieldIntVectorOnCells->setValueIJ(i+1,3,valueInt3);
593   }
594
595   for (int i=0; i<partialGroupOnNodes->getNumberOfElements(MED_ALL_ELEMENTS); i++)
596   {
597     const int* number=partialGroupOnNodes->getNumber(MED_ALL_ELEMENTS);
598     fieldDoubleScalarOnPartialNodes->setValueIJ(number[i],1,i+1);
599   }
600
601   for (int i=0; i<partialGroupOnCells->getNumberOfElements(MED_ALL_ELEMENTS); i++)
602   {
603     const int* number=partialGroupOnCells->getNumber(MED_ALL_ELEMENTS);
604     fieldDoubleScalarOnPartialCells->setValueIJ(number[i],1,i+1);
605   }
606
607   for (int i=0; i<partialGroupOnFaces->getNumberOfElements(MED_ALL_ELEMENTS); i++)
608   {
609     const int* number=partialGroupOnFaces->getNumber(MED_ALL_ELEMENTS);
610     fieldDoubleScalarOnPartialFaces->setValueIJ(number[i],1,i+1);
611   }
612
613   for (int i=0; i<partialGroupOnFaces2->getNumberOfElements(MED_ALL_ELEMENTS); i++)
614   {
615     const int* number=partialGroupOnFaces2->getNumber(MED_ALL_ELEMENTS);
616     fieldDoubleVectorOnPartialFaces->setValueIJ(number[i],1,i+1);
617     fieldDoubleVectorOnPartialFaces->setValueIJ(number[i],2,-i-1);
618   }
619
620   idMed22 = fieldDoubleScalarOnNodes->addDriver(MED_DRIVER,filenameMed22,fieldDoubleScalarOnNodes->getName());
621   fieldDoubleScalarOnNodes->write(idMed22) ;
622
623   idMed22 = fieldIntScalarOnNodes->addDriver(MED_DRIVER,filenameMed22,fieldIntScalarOnNodes->getName());
624   fieldIntScalarOnNodes->write(idMed22) ;
625
626   idMed22 = fieldDoubleVectorOnNodes->addDriver(MED_DRIVER,filenameMed22,fieldDoubleVectorOnNodes->getName());
627   fieldDoubleVectorOnNodes->write(idMed22) ;
628
629   idMed22 = fieldIntVectorOnNodes->addDriver(MED_DRIVER,filenameMed22,fieldIntVectorOnNodes->getName());
630   fieldIntVectorOnNodes->write(idMed22) ;
631
632   idMed22 = fieldDoubleScalarOnCells->addDriver(MED_DRIVER,filenameMed22,fieldDoubleScalarOnCells->getName());
633   fieldDoubleScalarOnCells->write(idMed22) ;
634
635   idMed22 = fieldIntScalarOnCells->addDriver(MED_DRIVER,filenameMed22,fieldIntScalarOnCells->getName());
636   fieldIntScalarOnCells->write(idMed22) ;
637
638   idMed22 = fieldDoubleVectorOnCells->addDriver(MED_DRIVER,filenameMed22,fieldDoubleVectorOnCells->getName());
639   fieldDoubleVectorOnCells->write(idMed22) ;
640
641   idMed22 = fieldIntVectorOnCells->addDriver(MED_DRIVER,filenameMed22,fieldIntVectorOnCells->getName());
642   fieldIntVectorOnCells->write(idMed22) ;
643
644   idMed22 = fieldDoubleScalarOnPartialNodes->addDriver(MED_DRIVER,filenameMed22,fieldDoubleScalarOnPartialNodes->getName());
645   fieldDoubleScalarOnPartialNodes->write(idMed22) ;
646
647   idMed22 = fieldDoubleScalarOnPartialCells->addDriver(MED_DRIVER,filenameMed22,fieldDoubleScalarOnPartialCells->getName());
648   fieldDoubleScalarOnPartialCells->write(idMed22) ;
649
650   idMed22 = fieldDoubleScalarOnPartialFaces->addDriver(MED_DRIVER,filenameMed22,fieldDoubleScalarOnPartialFaces->getName());
651   fieldDoubleScalarOnPartialFaces->write(idMed22) ;
652
653   idMed22 = fieldDoubleVectorOnPartialFaces->addDriver(MED_DRIVER,filenameMed22,fieldDoubleVectorOnPartialFaces->getName());
654   fieldDoubleVectorOnPartialFaces->write(idMed22) ;
655
656
657   idVtk = fieldDoubleScalarOnNodes->addDriver(VTK_DRIVER,filenameVtk,fieldDoubleScalarOnNodes->getName());
658   fieldDoubleScalarOnNodes->writeAppend(idVtk) ;
659
660   idVtk = fieldIntScalarOnNodes->addDriver(VTK_DRIVER,filenameVtk,fieldIntScalarOnNodes->getName());
661   fieldIntScalarOnNodes->writeAppend(idVtk) ;
662
663   idVtk = fieldDoubleVectorOnNodes->addDriver(VTK_DRIVER,filenameVtk,fieldDoubleVectorOnNodes->getName());
664   fieldDoubleVectorOnNodes->writeAppend(idVtk) ;
665
666   idVtk = fieldIntVectorOnNodes->addDriver(VTK_DRIVER,filenameVtk,fieldIntVectorOnNodes->getName());
667   fieldIntVectorOnNodes->writeAppend(idVtk) ;
668
669   idVtk = fieldDoubleScalarOnCells->addDriver(VTK_DRIVER,filenameVtk,fieldDoubleScalarOnCells->getName());
670   fieldDoubleScalarOnCells->writeAppend(idVtk) ;
671
672   idVtk = fieldIntScalarOnCells->addDriver(VTK_DRIVER,filenameVtk,fieldIntScalarOnCells->getName());
673   fieldIntScalarOnCells->writeAppend(idVtk) ;
674
675   idVtk = fieldDoubleVectorOnCells->addDriver(VTK_DRIVER,filenameVtk,fieldDoubleVectorOnCells->getName());
676   fieldDoubleVectorOnCells->writeAppend(idVtk) ;
677
678   idVtk = fieldIntVectorOnCells->addDriver(VTK_DRIVER,filenameVtk,fieldIntVectorOnCells->getName());
679   fieldIntVectorOnCells->writeAppend(idVtk) ;
680
681   if (argc==1) 
682   {
683     cout << "Remove generated files" << endl;
684     remove(filenameMed21.c_str());
685     remove(filenameMed22.c_str());
686     remove(filenameVtk.c_str());
687   }
688
689   fieldDoubleScalarOnNodes->removeReference();
690   fieldIntScalarOnNodes->removeReference();
691   fieldDoubleVectorOnNodes->removeReference();
692   fieldIntVectorOnNodes->removeReference();
693   fieldDoubleScalarOnCells->removeReference();
694   fieldIntScalarOnCells->removeReference();
695   fieldDoubleVectorOnCells->removeReference();
696   fieldIntVectorOnCells->removeReference();
697   fieldDoubleScalarOnPartialCells->removeReference();
698   fieldDoubleScalarOnPartialNodes->removeReference();
699   fieldDoubleScalarOnPartialFaces->removeReference();
700   fieldDoubleVectorOnPartialFaces->removeReference();
701
702   partialGroupOnNodes->removeReference();
703   partialGroupOnNodes2->removeReference();
704   partialGroupOnCells->removeReference();
705   partialGroupOnCells2->removeReference();
706   partialGroupOnFaces->removeReference();
707   partialGroupOnFaces2->removeReference();
708 }