Back to index

salome-med  6.5.0
test_MEDMEM_Meshing.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
00004 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
00005 //
00006 // This library is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU Lesser General Public
00008 // License as published by the Free Software Foundation; either
00009 // version 2.1 of the License.
00010 //
00011 // This library is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014 // Lesser General Public License for more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public
00017 // License along with this library; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00019 //
00020 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00021 //
00022 
00023 //#define protected public
00024 //#define private public
00025 //
00026 #include "MEDMEM_Meshing.hxx"
00027 #include "MEDMEM_Group.hxx"
00028 #include "MEDMEM_Field.hxx"
00029 #ifdef WNT
00030 #include <io.h>
00031 #define access _access
00032 #define W_OK 02
00033 #endif
00034 
00035 using namespace std;
00036 using namespace MEDMEM;
00037 using namespace MED_EN;
00038 using namespace DRIVERFACTORY;
00039 
00040 int main (int argc, char ** argv)
00041 {
00042   if (argc >2)
00043   {
00044     cerr << "Usage : " << argv[0] 
00045          << " filenameRoot" << endl;
00046     cerr << "        where filenameRoot is a root filename, the program will produce" << endl;
00047     cerr << "        3 files filenameRoot21.med filenameRoot22.med and filenameRoot.vtk" << endl << endl;
00048     exit(-1);
00049   }
00050 
00051   string filenameRoot;
00052   if (argc==1)
00053   {
00054     // filename to save the generated MESH
00055     if ( getenv("TMP") && access(getenv("TMP"),W_OK)==0 )
00056       filenameRoot=getenv("TMP");
00057     else if (getenv("TMPDIR") && access(getenv("TMPDIR"),W_OK)==0 )
00058       filenameRoot=getenv("TMPDIR");
00059     else
00060       filenameRoot="/tmp";
00061     filenameRoot += "/test_MEDMEM_Meshing" ;
00062   }
00063   else
00064     filenameRoot=argv[1];
00065 
00066   string filenameMed21 = filenameRoot+"_V21.med";
00067   string filenameMed22 = filenameRoot+"_V22.med";
00068   string filenameVtk = filenameRoot+".vtk";
00069 
00070   MESHING *myMeshing=new MESHING;
00071   myMeshing->setName("meshing") ;
00072 
00073   // define coordinates
00074 
00075   int SpaceDimension = 3 ;
00076   int NumberOfNodes = 19 ;
00077   double Coordinates[57] =
00078     {
00079       0.0, 0.0, 0.0, 
00080       0.0, 0.0, 1.0, 
00081       2.0, 0.0, 1.0, 
00082       0.0, 2.0, 1.0, 
00083       -2.0, 0.0, 1.0, 
00084       0.0, -2.0, 1.0, 
00085       1.0, 1.0, 2.0, 
00086       -1.0, 1.0, 2.0, 
00087       -1.0, -1.0, 2.0, 
00088       1.0, -1.0, 2.0, 
00089       1.0, 1.0, 3.0, 
00090       -1.0, 1.0, 3.0, 
00091       -1.0, -1.0, 3.0, 
00092       1.0, -1.0, 3.0, 
00093       1.0, 1.0, 4.0, 
00094       -1.0, 1.0, 4.0, 
00095       -1.0, -1.0, 4.0, 
00096       1.0, -1.0, 4.0,
00097       0.0, 0.0, 5.0
00098     };
00099 
00100   myMeshing->setCoordinates(SpaceDimension,NumberOfNodes,Coordinates,"CARTESIAN",MED_FULL_INTERLACE);
00101 
00102   string Names[3] =
00103     {
00104       "X","Y","Z"
00105     } ;
00106   myMeshing->setCoordinatesNames(Names);
00107 
00108   string Units[3] =
00109     {
00110       "cm","cm","cm"
00111     } ;
00112   myMeshing->setCoordinatesUnits(Units) ;
00113 
00114   // define conectivities
00115 
00116   // cell part
00117 
00118   const int NumberOfTypes = 3 ;
00119   medGeometryElement Types[NumberOfTypes] = 
00120     {
00121       MED_TETRA4,MED_PYRA5,MED_HEXA8
00122     } ;
00123   const int NumberOfElements[NumberOfTypes] = 
00124     {
00125       12,2,2
00126     } ;
00127 
00128   myMeshing->setNumberOfTypes(NumberOfTypes,MED_CELL);
00129   myMeshing->setTypes(Types,MED_CELL);
00130   myMeshing->setNumberOfElements(NumberOfElements,MED_CELL);
00131 
00132   const int sizeTetra = 12*4 ;
00133   int ConnectivityTetra[sizeTetra]=
00134     {
00135       1,2,3,6,
00136       1,2,4,3,
00137       1,2,5,4,
00138       1,2,6,5,
00139       2,7,4,3,
00140       2,8,5,4,
00141       2,9,6,5,
00142       2,10,3,6,
00143       2,7,3,10,
00144       2,8,4,7,
00145       2,9,5,8,
00146       2,10,6,9
00147     };
00148 
00149   myMeshing->setConnectivity(MED_CELL,MED_TETRA4,ConnectivityTetra);
00150 
00151   int ConnectivityPyra[2*5]=
00152     {
00153       7,8,9,10,2,
00154       15,18,17,16,19
00155     };
00156 
00157   myMeshing->setConnectivity(MED_CELL,MED_PYRA5,ConnectivityPyra);
00158 
00159   int ConnectivityHexa[2*8]=
00160     {
00161       11,12,13,14,7,8,9,10,
00162       15,16,17,18,11,12,13,14
00163     };
00164 
00165   myMeshing->setConnectivity(MED_CELL,MED_HEXA8,ConnectivityHexa);
00166 
00167   // face part
00168 
00169   const int NumberOfFacesTypes = 2 ;
00170   medGeometryElement FacesTypes[NumberOfFacesTypes] =
00171     {
00172       MED_TRIA3,MED_QUAD4
00173     } ;
00174   const int NumberOfFacesElements[NumberOfFacesTypes] =
00175     {
00176       4,4
00177     } ;
00178 
00179   myMeshing->setNumberOfTypes(NumberOfFacesTypes,MED_FACE);
00180   myMeshing->setTypes(FacesTypes,MED_FACE);
00181   myMeshing->setNumberOfElements(NumberOfFacesElements,MED_FACE);
00182 
00183   const int sizeTria = 3*4 ;
00184   int ConnectivityTria[sizeTria]=
00185     {
00186       1,4,3,
00187       1,5,4,
00188       1,6,5,
00189       1,3,6
00190     };
00191   myMeshing->setConnectivity(MED_FACE,MED_TRIA3,ConnectivityTria);
00192 
00193   int ConnectivityQua[4*4]=
00194     {
00195       7,8,9,10,
00196       11,12,13,14,
00197       11,7,8,12,
00198       12,8,9,13
00199     };
00200 
00201   myMeshing->setConnectivity(MED_FACE,MED_QUAD4,ConnectivityQua);
00202 
00203   // edge part
00204 
00205   // not yet implemented : if set, results are unpredictable.
00206 
00207   // Some groups :
00208 
00209   // Node :
00210 
00211   GROUP *partialGroupOnNodes=new GROUP;
00212   {
00213     partialGroupOnNodes->setName("SomeNodes");
00214     partialGroupOnNodes->setMesh(myMeshing);
00215     partialGroupOnNodes->setEntity(MED_NODE);
00216     partialGroupOnNodes->setNumberOfGeometricType(1);
00217     medGeometryElement myTypes[1] = 
00218       {
00219         MED_NONE
00220       };
00221     partialGroupOnNodes->setGeometricType(myTypes);
00222     const int myNumberOfElements[1] = 
00223       {
00224         4
00225       } ;
00226     partialGroupOnNodes->setNumberOfElements(myNumberOfElements);
00227     const int index[1+1] = 
00228       {
00229         1,5
00230       } ;
00231     const int value[4]= 
00232       {
00233         1,4,5,7
00234       } ;
00235     partialGroupOnNodes->setNumber(index,value);
00236   }
00237   GROUP *partialGroupOnNodes2=new GROUP;
00238   {
00239     partialGroupOnNodes2->setName("OtherNodes");
00240     partialGroupOnNodes2->setMesh(myMeshing);
00241     partialGroupOnNodes2->setEntity(MED_NODE);
00242     partialGroupOnNodes2->setNumberOfGeometricType(1);
00243     medGeometryElement myTypes[1] = 
00244       {
00245         MED_NONE
00246       };
00247     partialGroupOnNodes2->setGeometricType(myTypes);
00248     const int myNumberOfElements[1] = 
00249       {
00250         3
00251       } ;
00252     partialGroupOnNodes2->setNumberOfElements(myNumberOfElements);
00253     const int index[1+1] = 
00254       {
00255         1,4
00256       } ;
00257     const int value[3]= 
00258       {
00259         2,3,6
00260       } ;
00261     partialGroupOnNodes2->setNumber(index,value);
00262   }
00263   myMeshing->addGroup(*partialGroupOnNodes2);
00264 
00265 
00266   // Cell :
00267 
00268   GROUP *partialGroupOnCells=new GROUP;
00269   {
00270     partialGroupOnCells->setName("SomeCells");
00271     partialGroupOnCells->setMesh(myMeshing);
00272     partialGroupOnCells->setEntity(MED_CELL);
00273     partialGroupOnCells->setNumberOfGeometricType(3);
00274     medGeometryElement myTypes[3] = 
00275       {
00276         MED_TETRA4,MED_PYRA5,MED_HEXA8
00277       };
00278     partialGroupOnCells->setGeometricType(myTypes);
00279     const int myNumberOfElements[3] = 
00280       {
00281         4,1,2
00282       } ;
00283     partialGroupOnCells->setNumberOfElements(myNumberOfElements);
00284     const int index[3+1] = 
00285       {
00286         1,5,6,8
00287       } ;
00288     const int value[4+1+2]=
00289       {
00290         2,7,8,12,
00291         13,
00292         15,16
00293       };
00294     partialGroupOnCells->setNumber(index,value);
00295   }
00296   myMeshing->addGroup(*partialGroupOnCells);
00297 
00298 
00299   GROUP *partialGroupOnCells2=new GROUP;
00300   {
00301     partialGroupOnCells2->setName("OtherCells");
00302     partialGroupOnCells2->setMesh(myMeshing);
00303     partialGroupOnCells2->setEntity(MED_CELL);
00304     partialGroupOnCells2->setNumberOfGeometricType(2);
00305     medGeometryElement myTypes[] = 
00306       {
00307         MED_TETRA4,MED_PYRA5
00308       };
00309     partialGroupOnCells2->setGeometricType(myTypes);
00310     const int myNumberOfElements[] = 
00311       {
00312         4,1
00313       } ;
00314     partialGroupOnCells2->setNumberOfElements(myNumberOfElements);
00315     const int index[2+1] = 
00316       {
00317         1,5,6
00318       } ;
00319     const int value[4+1]=
00320       {
00321         3,4,5,9,
00322         14
00323       };
00324     partialGroupOnCells2->setNumber(index,value);
00325   }
00326   myMeshing->addGroup(*partialGroupOnCells2);
00327 
00328   // Face :
00329 
00330   GROUP *partialGroupOnFaces=new GROUP;
00331   {
00332     partialGroupOnFaces->setName("SomeFaces");
00333     partialGroupOnFaces->setMesh(myMeshing);
00334     partialGroupOnFaces->setEntity(MED_FACE);
00335     partialGroupOnFaces->setNumberOfGeometricType(2);
00336     medGeometryElement myTypes[2] = 
00337       {
00338         MED_TRIA3,MED_QUAD4
00339       };
00340     partialGroupOnFaces->setGeometricType(myTypes);
00341     const int myNumberOfElements[2] = 
00342       {
00343         2,3
00344       } ;
00345     partialGroupOnFaces->setNumberOfElements(myNumberOfElements);
00346     const int index[2+1] = 
00347       {
00348         1,3,6
00349       } ;
00350     const int value[2+3]=
00351       {
00352         2,4,
00353         5,6,8
00354       } ;
00355     partialGroupOnFaces->setNumber(index,value);
00356   }
00357   myMeshing->addGroup(*partialGroupOnFaces);
00358 
00359 
00360   GROUP *partialGroupOnFaces2=new GROUP;
00361   {
00362     partialGroupOnFaces2->setName("OtherFaces");
00363     partialGroupOnFaces2->setMesh(myMeshing);
00364     partialGroupOnFaces2->setEntity(MED_FACE);
00365     medGeometryElement myTypes[1] = 
00366       {
00367         MED_TRIA3
00368       };
00369     int myNumberOfElements[1] = 
00370       {
00371         2
00372       } ;
00373     int value[2]=
00374       {
00375         1,3
00376       } ;
00377     //    partialGroupOnFaces2->setNumber(index,value);
00378     partialGroupOnFaces2->setpartial("description",1,2,myTypes,myNumberOfElements,value);
00379   }
00380   myMeshing->addGroup(*partialGroupOnFaces2);
00381 
00382   // all right, we save it in Med 2.1 2.2 and vtk !
00383 
00384   int idMed22 = myMeshing->addDriver(MED_DRIVER,filenameMed22,myMeshing->getName());
00385   myMeshing->write(idMed22) ;
00386 
00387   int idVtk = myMeshing->addDriver(VTK_DRIVER,filenameVtk,myMeshing->getName());
00388   myMeshing->write(idVtk) ;
00389 
00390   // we build now 8 fields : 4 fields double (integer) :
00391   //                         2 fields on nodes (cells) :
00392   //                         1 scalar (vector)
00393 
00394   const SUPPORT * supportOnNodes = myMeshing->getSupportOnAll(MED_NODE);
00395   int numberOfNodes = supportOnNodes->getNumberOfElements(MED_ALL_ELEMENTS);
00396 
00397   const SUPPORT * supportOnCells = myMeshing->getSupportOnAll(MED_CELL);
00398   myMeshing->removeReference();
00399   int numberOfCells = supportOnCells->getNumberOfElements(MED_ALL_ELEMENTS);
00400 
00401   FIELD<double> * fieldDoubleScalarOnNodes = new FIELD<double>(supportOnNodes,1);
00402   fieldDoubleScalarOnNodes->setName("fieldScalarDoubleNode");
00403   fieldDoubleScalarOnNodes->setIterationNumber(-1);
00404   fieldDoubleScalarOnNodes->setOrderNumber(-1);
00405   fieldDoubleScalarOnNodes->setTime(0.0);
00406 
00407   fieldDoubleScalarOnNodes->setComponentName(1,"Vx");
00408   fieldDoubleScalarOnNodes->setComponentDescription(1,"comp1");
00409   fieldDoubleScalarOnNodes->setMEDComponentUnit(1,"unit1");
00410   FIELD<double>* fieldDoubleScalarOnPartialNodes = new FIELD<double>(partialGroupOnNodes,1);
00411   fieldDoubleScalarOnPartialNodes->setName("fieldScalarDoublePartialNodes");
00412   fieldDoubleScalarOnPartialNodes->setIterationNumber(-1);
00413   fieldDoubleScalarOnPartialNodes->setOrderNumber(-1);
00414   fieldDoubleScalarOnPartialNodes->setTime(0.0);
00415   fieldDoubleScalarOnPartialNodes->setComponentName(1,"Vx");
00416   fieldDoubleScalarOnPartialNodes->setComponentDescription(1,"comp1");
00417   fieldDoubleScalarOnPartialNodes->setMEDComponentUnit(1,"unit1");
00418 
00419 
00420   FIELD<double> * fieldDoubleVectorOnNodes = new FIELD<double>(supportOnNodes,SpaceDimension);
00421   fieldDoubleVectorOnNodes->setName("fieldVectorDoubleNode");
00422   fieldDoubleVectorOnNodes->setIterationNumber(-1);
00423   fieldDoubleVectorOnNodes->setOrderNumber(-1);
00424   fieldDoubleVectorOnNodes->setTime(0.0);
00425 
00426   fieldDoubleVectorOnNodes->setComponentName(1,"Vx");
00427   fieldDoubleVectorOnNodes->setComponentDescription(1,"comp1");
00428   fieldDoubleVectorOnNodes->setMEDComponentUnit(1,"unit1");
00429   fieldDoubleVectorOnNodes->setComponentName(2,"Vy");
00430   fieldDoubleVectorOnNodes->setComponentDescription(2,"comp2");
00431   fieldDoubleVectorOnNodes->setMEDComponentUnit(2,"unit2");
00432   fieldDoubleVectorOnNodes->setComponentName(3,"Vz");
00433   fieldDoubleVectorOnNodes->setComponentDescription(3,"comp3");
00434   fieldDoubleVectorOnNodes->setMEDComponentUnit(3,"unit3");
00435 
00436   FIELD<double> * fieldDoubleScalarOnCells = new FIELD<double>(supportOnCells,1);
00437   fieldDoubleScalarOnCells->setName("fieldScalarDoubleCell");
00438   fieldDoubleScalarOnCells->setIterationNumber(-1);
00439   fieldDoubleScalarOnCells->setOrderNumber(-1);
00440   fieldDoubleScalarOnCells->setTime(0.0);
00441 
00442   fieldDoubleScalarOnCells->setComponentName(1,"Vx");
00443   fieldDoubleScalarOnCells->setComponentDescription(1,"comp1");
00444   fieldDoubleScalarOnCells->setMEDComponentUnit(1,"unit1");
00445 
00446 
00447   FIELD<double> * fieldDoubleScalarOnPartialCells = new FIELD<double>(partialGroupOnCells,1);
00448   fieldDoubleScalarOnPartialCells->setName("fieldScalarDoublePartialCell");
00449   fieldDoubleScalarOnPartialCells->setIterationNumber(-1);
00450   fieldDoubleScalarOnPartialCells->setOrderNumber(-1);
00451   fieldDoubleScalarOnPartialCells->setTime(0.0);
00452 
00453   fieldDoubleScalarOnPartialCells->setComponentName(1,"Vx");
00454   fieldDoubleScalarOnPartialCells->setComponentDescription(1,"comp1");
00455   fieldDoubleScalarOnPartialCells->setMEDComponentUnit(1,"unit1");
00456 
00457   FIELD<double> * fieldDoubleScalarOnPartialFaces = new FIELD<double>(partialGroupOnFaces,1);
00458   fieldDoubleScalarOnPartialFaces->setName("fieldScalarDoublePartialFace");
00459   fieldDoubleScalarOnPartialFaces->setIterationNumber(-1);
00460   fieldDoubleScalarOnPartialFaces->setOrderNumber(-1);
00461   fieldDoubleScalarOnPartialFaces->setTime(0.0);
00462   fieldDoubleScalarOnPartialFaces->setComponentName(1,"Vx");
00463   fieldDoubleScalarOnPartialFaces->setComponentDescription(1,"comp1");
00464   fieldDoubleScalarOnPartialFaces->setMEDComponentUnit(1,"unit1");
00465 
00466   FIELD<double> * fieldDoubleVectorOnPartialFaces = new FIELD<double>(partialGroupOnFaces2,2);
00467   fieldDoubleVectorOnPartialFaces->setName("fieldVectorDoublePartialFace");
00468   fieldDoubleVectorOnPartialFaces->setIterationNumber(-1);
00469   fieldDoubleVectorOnPartialFaces->setOrderNumber(-1);
00470   fieldDoubleVectorOnPartialFaces->setTime(0.0);
00471   fieldDoubleVectorOnPartialFaces->setComponentName(1,"Vx");
00472   fieldDoubleVectorOnPartialFaces->setComponentName(2,"Vy");
00473 
00474   fieldDoubleVectorOnPartialFaces->setComponentDescription(1,"comp1");
00475   fieldDoubleVectorOnPartialFaces->setComponentDescription(2,"comp2");
00476 
00477   fieldDoubleVectorOnPartialFaces->setMEDComponentUnit(1,"unit1");
00478   fieldDoubleVectorOnPartialFaces->setMEDComponentUnit(2,"unit2");
00479 
00480 
00481   FIELD<double> * fieldDoubleVectorOnCells = new FIELD<double>(supportOnCells,SpaceDimension);
00482   fieldDoubleVectorOnCells->setName("fieldVectorrDoubleCell");
00483   fieldDoubleVectorOnCells->setIterationNumber(-1);
00484   fieldDoubleVectorOnCells->setOrderNumber(-1);
00485   fieldDoubleVectorOnCells->setTime(0.0);
00486 
00487   fieldDoubleVectorOnCells->setComponentName(1,"Vx");
00488   fieldDoubleVectorOnCells->setComponentDescription(1,"comp1");
00489   fieldDoubleVectorOnCells->setMEDComponentUnit(1,"unit1");
00490   fieldDoubleVectorOnCells->setComponentName(2,"Vy");
00491   fieldDoubleVectorOnCells->setComponentDescription(2,"comp2");
00492   fieldDoubleVectorOnCells->setMEDComponentUnit(2,"unit2");
00493   fieldDoubleVectorOnCells->setComponentName(3,"Vz");
00494   fieldDoubleVectorOnCells->setComponentDescription(3,"comp3");
00495   fieldDoubleVectorOnCells->setMEDComponentUnit(3,"unit3");
00496 
00497   FIELD<int> * fieldIntScalarOnNodes = new FIELD<int>(supportOnNodes,1);
00498   fieldIntScalarOnNodes->setName("fieldScalarIntNode");
00499   fieldIntScalarOnNodes->setIterationNumber(-1);
00500   fieldIntScalarOnNodes->setOrderNumber(-1);
00501   fieldIntScalarOnNodes->setTime(0.0);
00502 
00503   fieldIntScalarOnNodes->setComponentName(1,"Vx");
00504   fieldIntScalarOnNodes->setComponentDescription(1,"comp1");
00505   fieldIntScalarOnNodes->setMEDComponentUnit(1,"unit1");
00506 
00507   FIELD<int> * fieldIntVectorOnNodes = new FIELD<int>(supportOnNodes,SpaceDimension);
00508   fieldIntVectorOnNodes->setName("fieldVectorIntNode");
00509   fieldIntVectorOnNodes->setIterationNumber(-1);
00510   fieldIntVectorOnNodes->setOrderNumber(-1);
00511   fieldIntVectorOnNodes->setTime(0.0);
00512 
00513   fieldIntVectorOnNodes->setComponentName(1,"Vx");
00514   fieldIntVectorOnNodes->setComponentDescription(1,"comp1");
00515   fieldIntVectorOnNodes->setMEDComponentUnit(1,"unit1");
00516   fieldIntVectorOnNodes->setComponentName(2,"Vy");
00517   fieldIntVectorOnNodes->setComponentDescription(2,"comp2");
00518   fieldIntVectorOnNodes->setMEDComponentUnit(2,"unit2");
00519   fieldIntVectorOnNodes->setComponentName(3,"Vz");
00520   fieldIntVectorOnNodes->setComponentDescription(3,"comp3");
00521   fieldIntVectorOnNodes->setMEDComponentUnit(3,"unit3");
00522 
00523   FIELD<int> * fieldIntScalarOnCells = new FIELD<int>(supportOnCells,1);
00524   fieldIntScalarOnCells->setName("fieldScalarIntCell");
00525   fieldIntScalarOnCells->setIterationNumber(-1);
00526   fieldIntScalarOnCells->setOrderNumber(-1);
00527   fieldIntScalarOnCells->setTime(0.0);
00528 
00529   fieldIntScalarOnCells->setComponentName(1,"Vx");
00530   fieldIntScalarOnCells->setComponentDescription(1,"comp1");
00531   fieldIntScalarOnCells->setMEDComponentUnit(1,"unit1");
00532 
00533   FIELD<int> * fieldIntVectorOnCells = new FIELD<int>(supportOnCells,SpaceDimension);
00534   fieldIntVectorOnCells->setName("fieldVectorrIntCell");
00535   fieldIntVectorOnCells->setIterationNumber(-1);
00536   fieldIntVectorOnCells->setOrderNumber(-1);
00537   fieldIntVectorOnCells->setTime(0.0);
00538 
00539   fieldIntVectorOnCells->setComponentName(1,"Vx");
00540   fieldIntVectorOnCells->setComponentDescription(1,"comp1");
00541   fieldIntVectorOnCells->setMEDComponentUnit(1,"unit1");
00542   fieldIntVectorOnCells->setComponentName(2,"Vy");
00543   fieldIntVectorOnCells->setComponentDescription(2,"comp2");
00544   fieldIntVectorOnCells->setMEDComponentUnit(2,"unit2");
00545   fieldIntVectorOnCells->setComponentName(3,"Vz");
00546   fieldIntVectorOnCells->setComponentDescription(3,"comp3");
00547   fieldIntVectorOnCells->setMEDComponentUnit(3,"unit3");
00548 
00549   for (int i = 0; i<numberOfNodes; i++)
00550   {
00551     double valueDbl1, valueDbl2, valueDbl3;
00552     int valueInt1, valueInt2, valueInt3;
00553     valueInt1 = i+1;
00554     valueInt2 = i+2;
00555     valueInt3 = i+3;
00556     valueDbl1 = valueInt1*0.1;
00557     valueDbl2 = valueInt2*0.1;
00558     valueDbl3 = valueInt3*0.1;
00559     fieldDoubleScalarOnNodes->setValueIJ(i+1,1,valueDbl1);
00560 
00561     fieldIntScalarOnNodes->setValueIJ(i+1,1,valueInt1);
00562 
00563     fieldDoubleVectorOnNodes->setValueIJ(i+1,1,valueDbl1);
00564     fieldDoubleVectorOnNodes->setValueIJ(i+1,2,valueDbl2);
00565     fieldDoubleVectorOnNodes->setValueIJ(i+1,3,valueDbl3);
00566 
00567     fieldIntVectorOnNodes->setValueIJ(i+1,1,valueInt1);
00568     fieldIntVectorOnNodes->setValueIJ(i+1,2,valueInt2);
00569     fieldIntVectorOnNodes->setValueIJ(i+1,3,valueInt3);
00570   }
00571 
00572   for (int i = 0; i<numberOfCells; i++)
00573   {
00574     double valueDbl1, valueDbl2, valueDbl3;
00575     int valueInt1, valueInt2, valueInt3;
00576     valueInt1 = i+1;
00577     valueInt2 = i+2;
00578     valueInt3 = i+3;
00579     valueDbl1 = valueInt1*0.1;
00580     valueDbl2 = valueInt2*0.1;
00581     valueDbl3 = valueInt3*0.1;
00582     fieldDoubleScalarOnCells->setValueIJ(i+1,1,valueDbl1);
00583 
00584     fieldIntScalarOnCells->setValueIJ(i+1,1,valueInt1);
00585 
00586     fieldDoubleVectorOnCells->setValueIJ(i+1,1,valueDbl1);
00587     fieldDoubleVectorOnCells->setValueIJ(i+1,2,valueDbl2);
00588     fieldDoubleVectorOnCells->setValueIJ(i+1,3,valueDbl3);
00589 
00590     fieldIntVectorOnCells->setValueIJ(i+1,1,valueInt1);
00591     fieldIntVectorOnCells->setValueIJ(i+1,2,valueInt2);
00592     fieldIntVectorOnCells->setValueIJ(i+1,3,valueInt3);
00593   }
00594 
00595   for (int i=0; i<partialGroupOnNodes->getNumberOfElements(MED_ALL_ELEMENTS); i++)
00596   {
00597     const int* number=partialGroupOnNodes->getNumber(MED_ALL_ELEMENTS);
00598     fieldDoubleScalarOnPartialNodes->setValueIJ(number[i],1,i+1);
00599   }
00600 
00601   for (int i=0; i<partialGroupOnCells->getNumberOfElements(MED_ALL_ELEMENTS); i++)
00602   {
00603     const int* number=partialGroupOnCells->getNumber(MED_ALL_ELEMENTS);
00604     fieldDoubleScalarOnPartialCells->setValueIJ(number[i],1,i+1);
00605   }
00606 
00607   for (int i=0; i<partialGroupOnFaces->getNumberOfElements(MED_ALL_ELEMENTS); i++)
00608   {
00609     const int* number=partialGroupOnFaces->getNumber(MED_ALL_ELEMENTS);
00610     fieldDoubleScalarOnPartialFaces->setValueIJ(number[i],1,i+1);
00611   }
00612 
00613   for (int i=0; i<partialGroupOnFaces2->getNumberOfElements(MED_ALL_ELEMENTS); i++)
00614   {
00615     const int* number=partialGroupOnFaces2->getNumber(MED_ALL_ELEMENTS);
00616     fieldDoubleVectorOnPartialFaces->setValueIJ(number[i],1,i+1);
00617     fieldDoubleVectorOnPartialFaces->setValueIJ(number[i],2,-i-1);
00618   }
00619 
00620   idMed22 = fieldDoubleScalarOnNodes->addDriver(MED_DRIVER,filenameMed22,fieldDoubleScalarOnNodes->getName());
00621   fieldDoubleScalarOnNodes->write(idMed22) ;
00622 
00623   idMed22 = fieldIntScalarOnNodes->addDriver(MED_DRIVER,filenameMed22,fieldIntScalarOnNodes->getName());
00624   fieldIntScalarOnNodes->write(idMed22) ;
00625 
00626   idMed22 = fieldDoubleVectorOnNodes->addDriver(MED_DRIVER,filenameMed22,fieldDoubleVectorOnNodes->getName());
00627   fieldDoubleVectorOnNodes->write(idMed22) ;
00628 
00629   idMed22 = fieldIntVectorOnNodes->addDriver(MED_DRIVER,filenameMed22,fieldIntVectorOnNodes->getName());
00630   fieldIntVectorOnNodes->write(idMed22) ;
00631 
00632   idMed22 = fieldDoubleScalarOnCells->addDriver(MED_DRIVER,filenameMed22,fieldDoubleScalarOnCells->getName());
00633   fieldDoubleScalarOnCells->write(idMed22) ;
00634 
00635   idMed22 = fieldIntScalarOnCells->addDriver(MED_DRIVER,filenameMed22,fieldIntScalarOnCells->getName());
00636   fieldIntScalarOnCells->write(idMed22) ;
00637 
00638   idMed22 = fieldDoubleVectorOnCells->addDriver(MED_DRIVER,filenameMed22,fieldDoubleVectorOnCells->getName());
00639   fieldDoubleVectorOnCells->write(idMed22) ;
00640 
00641   idMed22 = fieldIntVectorOnCells->addDriver(MED_DRIVER,filenameMed22,fieldIntVectorOnCells->getName());
00642   fieldIntVectorOnCells->write(idMed22) ;
00643 
00644   idMed22 = fieldDoubleScalarOnPartialNodes->addDriver(MED_DRIVER,filenameMed22,fieldDoubleScalarOnPartialNodes->getName());
00645   fieldDoubleScalarOnPartialNodes->write(idMed22) ;
00646 
00647   idMed22 = fieldDoubleScalarOnPartialCells->addDriver(MED_DRIVER,filenameMed22,fieldDoubleScalarOnPartialCells->getName());
00648   fieldDoubleScalarOnPartialCells->write(idMed22) ;
00649 
00650   idMed22 = fieldDoubleScalarOnPartialFaces->addDriver(MED_DRIVER,filenameMed22,fieldDoubleScalarOnPartialFaces->getName());
00651   fieldDoubleScalarOnPartialFaces->write(idMed22) ;
00652 
00653   idMed22 = fieldDoubleVectorOnPartialFaces->addDriver(MED_DRIVER,filenameMed22,fieldDoubleVectorOnPartialFaces->getName());
00654   fieldDoubleVectorOnPartialFaces->write(idMed22) ;
00655 
00656 
00657   idVtk = fieldDoubleScalarOnNodes->addDriver(VTK_DRIVER,filenameVtk,fieldDoubleScalarOnNodes->getName());
00658   fieldDoubleScalarOnNodes->writeAppend(idVtk) ;
00659 
00660   idVtk = fieldIntScalarOnNodes->addDriver(VTK_DRIVER,filenameVtk,fieldIntScalarOnNodes->getName());
00661   fieldIntScalarOnNodes->writeAppend(idVtk) ;
00662 
00663   idVtk = fieldDoubleVectorOnNodes->addDriver(VTK_DRIVER,filenameVtk,fieldDoubleVectorOnNodes->getName());
00664   fieldDoubleVectorOnNodes->writeAppend(idVtk) ;
00665 
00666   idVtk = fieldIntVectorOnNodes->addDriver(VTK_DRIVER,filenameVtk,fieldIntVectorOnNodes->getName());
00667   fieldIntVectorOnNodes->writeAppend(idVtk) ;
00668 
00669   idVtk = fieldDoubleScalarOnCells->addDriver(VTK_DRIVER,filenameVtk,fieldDoubleScalarOnCells->getName());
00670   fieldDoubleScalarOnCells->writeAppend(idVtk) ;
00671 
00672   idVtk = fieldIntScalarOnCells->addDriver(VTK_DRIVER,filenameVtk,fieldIntScalarOnCells->getName());
00673   fieldIntScalarOnCells->writeAppend(idVtk) ;
00674 
00675   idVtk = fieldDoubleVectorOnCells->addDriver(VTK_DRIVER,filenameVtk,fieldDoubleVectorOnCells->getName());
00676   fieldDoubleVectorOnCells->writeAppend(idVtk) ;
00677 
00678   idVtk = fieldIntVectorOnCells->addDriver(VTK_DRIVER,filenameVtk,fieldIntVectorOnCells->getName());
00679   fieldIntVectorOnCells->writeAppend(idVtk) ;
00680 
00681   if (argc==1) 
00682   {
00683     cout << "Remove generated files" << endl;
00684     remove(filenameMed21.c_str());
00685     remove(filenameMed22.c_str());
00686     remove(filenameVtk.c_str());
00687   }
00688 
00689   fieldDoubleScalarOnNodes->removeReference();
00690   fieldIntScalarOnNodes->removeReference();
00691   fieldDoubleVectorOnNodes->removeReference();
00692   fieldIntVectorOnNodes->removeReference();
00693   fieldDoubleScalarOnCells->removeReference();
00694   fieldIntScalarOnCells->removeReference();
00695   fieldDoubleVectorOnCells->removeReference();
00696   fieldIntVectorOnCells->removeReference();
00697   fieldDoubleScalarOnPartialCells->removeReference();
00698   fieldDoubleScalarOnPartialNodes->removeReference();
00699   fieldDoubleScalarOnPartialFaces->removeReference();
00700   fieldDoubleVectorOnPartialFaces->removeReference();
00701 
00702   partialGroupOnNodes->removeReference();
00703   partialGroupOnNodes2->removeReference();
00704   partialGroupOnCells->removeReference();
00705   partialGroupOnCells2->removeReference();
00706   partialGroupOnFaces->removeReference();
00707   partialGroupOnFaces2->removeReference();
00708 }