Back to index

salome-med  6.5.0
MEDCouplingMeshFieldFactoryComponent.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "MEDCouplingMeshFieldFactoryComponent.hxx"
00021 #include "MEDCouplingExtrudedMesh.hxx"
00022 #include "MEDCouplingFieldDouble.hxx"
00023 #include "MEDCouplingFieldTemplate.hxx"
00024 #include "MEDCouplingMultiFields.hxx"
00025 #include "MEDCouplingFieldOverTime.hxx"
00026 #include "MEDCouplingMemArray.hxx"
00027 #include "MEDCouplingUMesh.hxx"
00028 #include "MEDCouplingCMesh.hxx"
00029 
00030 #include <cmath>
00031 #include <algorithm>
00032 
00033 namespace SALOME_TEST
00034 {
00035   ParaMEDMEM::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::build1DMesh()
00036   {
00037     double coords[4]={ 0.0, 0.3, 0.75, 1.0 };
00038     int conn[2*3]={ 0,1, 1,2, 2,3 };
00039     ParaMEDMEM::MEDCouplingUMesh *mesh=ParaMEDMEM::MEDCouplingUMesh::New("1DMeshForCorba",1);
00040     mesh->setDescription("build1DMesh");
00041     mesh->allocateCells(3);
00042     mesh->setTime(5.6,7,8);
00043     mesh->setTimeUnit("ms");
00044     mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
00045     mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2);
00046     mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+4);
00047     mesh->finishInsertingCells();
00048     ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New();
00049     myCoords->alloc(4,1);
00050     std::copy(coords,coords+4,myCoords->getPointer());
00051     mesh->setCoords(myCoords);
00052     myCoords->decrRef();
00053     mesh->changeSpaceDimension(3);
00054     myCoords=mesh->getCoords();
00055     myCoords->setInfoOnComponent(0,"X1D(m)");
00056     myCoords->setInfoOnComponent(1,"Y1D (dm)");
00057     myCoords->setInfoOnComponent(2,"Z1D (pm)");
00058     double center[3]={0.,0.,0.};
00059     double vector[3]={0,1,0};
00060     mesh->rotate(center,vector,-M_PI/2.);
00061     return mesh;
00062   }
00063 
00064   ParaMEDMEM::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::build2DMesh()
00065   {
00066     double targetCoords[18]={-0.3,-0.3, 0.2,-0.3, 0.7,-0.3, -0.3,0.2, 0.2,0.2, 0.7,0.2, -0.3,0.7, 0.2,0.7, 0.7,0.7 };
00067     int targetConn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
00068     ParaMEDMEM::MEDCouplingUMesh *targetMesh=ParaMEDMEM::MEDCouplingUMesh::New();
00069     targetMesh->setMeshDimension(2);
00070     targetMesh->setName("MyMesh2D");
00071     targetMesh->setDescription("build2DMesh");
00072     targetMesh->allocateCells(5);
00073     targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
00074     targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
00075     targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
00076     targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
00077     targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
00078     targetMesh->finishInsertingCells();
00079     ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New();
00080     myCoords->alloc(9,2);
00081     std::copy(targetCoords,targetCoords+18,myCoords->getPointer());
00082     targetMesh->setCoords(myCoords);
00083     myCoords->decrRef();
00084     return targetMesh;
00085   }
00086 
00087   ParaMEDMEM::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::build3DMesh()
00088   {
00089     double targetCoords[81]={ 0., 0., 0., 50., 0., 0. , 200., 0., 0.  , 0., 50., 0., 50., 50., 0. , 200., 50., 0.,   0., 200., 0., 50., 200., 0. , 200., 200., 0. ,
00090                               0., 0., 50., 50., 0., 50. , 200., 0., 50.  , 0., 50., 50., 50., 50., 50. , 200., 50., 50.,   0., 200., 50., 50., 200., 50. , 200., 200., 50. ,
00091                               0., 0., 200., 50., 0., 200. , 200., 0., 200.  , 0., 50., 200., 50., 50., 200. , 200., 50., 200.,   0., 200., 200., 50., 200., 200. , 200., 200., 200. };
00092     int targetConn[64]={0,1,4,3,9,10,13,12, 1,2,5,4,10,11,14,13, 3,4,7,6,12,13,16,15, 4,5,8,7,13,14,17,16,
00093                         9,10,13,12,18,19,22,21, 10,11,14,13,19,20,23,22, 12,13,16,15,21,22,25,24, 13,14,17,16,22,23,26,25};
00094     ParaMEDMEM::MEDCouplingUMesh *targetMesh=ParaMEDMEM::MEDCouplingUMesh::New();
00095     targetMesh->setMeshDimension(3);
00096     targetMesh->setName("MyMesh3D");
00097     targetMesh->setDescription("build3DMesh");
00098     targetMesh->allocateCells(12);
00099     for(int i=0;i<8;i++)
00100       targetMesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,targetConn+8*i);
00101     targetMesh->finishInsertingCells();
00102     ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New();
00103     myCoords->alloc(27,3);
00104     std::copy(targetCoords,targetCoords+81,myCoords->getPointer());
00105     targetMesh->setCoords(myCoords);
00106     myCoords->setName("check in case");
00107     myCoords->decrRef();
00108     return targetMesh;
00109   }
00110 
00111   ParaMEDMEM::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::build3DSurfMesh()
00112   {
00113     double targetCoords[27]={-0.3,-0.3,0.5, 0.2,-0.3,1., 0.7,-0.3,1.5, -0.3,0.2,0.5, 0.2,0.2,1., 0.7,0.2,1.5, -0.3,0.7,0.5, 0.2,0.7,1., 0.7,0.7,1.5};
00114     int targetConn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
00115     ParaMEDMEM::MEDCouplingUMesh *targetMesh=ParaMEDMEM::MEDCouplingUMesh::New();
00116     targetMesh->setMeshDimension(2);
00117     targetMesh->setName("MyMesh3DSurf");
00118     targetMesh->setDescription("build3DSurfMesh");
00119     targetMesh->allocateCells(5);
00120     targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
00121     targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
00122     targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
00123     targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
00124     targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
00125     targetMesh->finishInsertingCells();
00126     ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New();
00127     myCoords->alloc(9,3);
00128     std::copy(targetCoords,targetCoords+27,myCoords->getPointer());
00129     targetMesh->setCoords(myCoords);
00130     myCoords->setInfoOnComponent(0,"X (m)");
00131     myCoords->setInfoOnComponent(1,"X (dm)");
00132     myCoords->setInfoOnComponent(2,"X (m)");
00133     myCoords->decrRef();
00134     return targetMesh;
00135   }
00136 
00137   ParaMEDMEM::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::build0DMesh()
00138   {
00139     double targetCoords[27]={-0.3,-0.3,0.5, 0.2,-0.3,1., 0.7,-0.3,1.5, -0.3,0.2,0.5, 0.2,0.2,1., 0.7,0.2,1.5, -0.3,0.7,0.5, 0.2,0.7,1., 0.7,0.7,1.5};
00140     const int targetConn[]={0,1,2,3,4,5,7,6};
00141     ParaMEDMEM::MEDCouplingUMesh *targetMesh=ParaMEDMEM::MEDCouplingUMesh::New();
00142     targetMesh->setMeshDimension(0);
00143     targetMesh->allocateCells(8);
00144     targetMesh->setName("Wonderfull 0D mesh");
00145     targetMesh->setDescription("build0DMesh");
00146     targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn);
00147     targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+1);
00148     targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+2);
00149     targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+3);
00150     targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+4);
00151     targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+5);
00152     targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+6);
00153     targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+7);
00154     targetMesh->finishInsertingCells();
00155     ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New();
00156     myCoords->alloc(9,3);
00157     std::copy(targetCoords,targetCoords+27,myCoords->getPointer());
00158     targetMesh->setCoords(myCoords);
00159     myCoords->setInfoOnComponent(0,"X (m)");
00160     myCoords->setInfoOnComponent(1,"YY (Pm)");
00161     myCoords->setInfoOnComponent(2,"ZZZ (m)");
00162     myCoords->decrRef();
00163     //
00164     targetMesh->checkCoherency();
00165     return targetMesh;
00166   }
00167 
00168   ParaMEDMEM::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::buildM1DMesh()
00169   {
00170     ParaMEDMEM::MEDCouplingUMesh *meshM1D=ParaMEDMEM::MEDCouplingUMesh::New("wonderfull -1 D mesh",-1);
00171     meshM1D->setDescription("buildM1DMesh");
00172     meshM1D->checkCoherency();
00173     return meshM1D;
00174   }
00175 
00176   ParaMEDMEM::MEDCouplingExtrudedMesh *MEDCouplingCorbaServBasicsTest::buildExtrudedMesh(ParaMEDMEM::MEDCouplingUMesh *&m2D)
00177   {
00178     m2D=build2DMesh();
00179     m2D->changeSpaceDimension(3);
00180     ParaMEDMEM::MEDCouplingUMesh *m1D=build1DMesh();
00181     ParaMEDMEM::MEDCouplingUMesh *retu=m2D->buildExtrudedMesh(m1D,0);
00182     m1D->decrRef();
00183     ParaMEDMEM::MEDCouplingExtrudedMesh *ret=ParaMEDMEM::MEDCouplingExtrudedMesh::New(retu,m2D,2);
00184     ret->setName("ExtrudedTestForCorbaTest");
00185     ret->setDescription("buildExtrudedMesh");
00186     retu->decrRef();
00187     return ret;
00188   }
00189 
00190   ParaMEDMEM::MEDCouplingCMesh *MEDCouplingCorbaServBasicsTest::buildCMesh()
00191   {
00192     ParaMEDMEM::MEDCouplingCMesh *targetMesh=ParaMEDMEM::MEDCouplingCMesh::New();
00193     targetMesh->setTime(2.3,4,5);
00194     targetMesh->setTimeUnit("us");
00195     targetMesh->setName("Example of CMesh");
00196     targetMesh->setDescription("buildCMesh");
00197     ParaMEDMEM::DataArrayDouble *a1=ParaMEDMEM::DataArrayDouble::New();
00198     a1->alloc(5,1);
00199     a1->setInfoOnComponent(0,"SmthX");
00200     const double a1Data[5]={3.,4.,5.,6.,7.};
00201     std::copy(a1Data,a1Data+5,a1->getPointer());
00202     ParaMEDMEM::DataArrayDouble *a2=ParaMEDMEM::DataArrayDouble::New();
00203     a2->alloc(6,1);
00204     a2->setInfoOnComponent(0,"SmthZ");
00205     const double a2Data[6]={2.78,3.,4.,5.,6.,7.};
00206     std::copy(a2Data,a2Data+6,a2->getPointer());
00207     //
00208     targetMesh->setCoordsAt(0,a1);
00209     targetMesh->setCoordsAt(2,a2);
00210     //
00211     a1->decrRef();
00212     a2->decrRef();
00213     //
00214     targetMesh->checkCoherency();
00215     //
00216     return targetMesh;
00217   }
00218 
00219   ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldScalarOn2DNT()
00220   {
00221     ParaMEDMEM::MEDCouplingUMesh *mesh=build2DMesh();
00222     ParaMEDMEM::MEDCouplingFieldDouble *fieldOnCells=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME);
00223     fieldOnCells->setTimeUnit("ms");
00224     fieldOnCells->setName("toto");
00225     fieldOnCells->setMesh(mesh);
00226     ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
00227     array->alloc(mesh->getNumberOfCells(),6);
00228     fieldOnCells->setArray(array);
00229     double *tmp=array->getPointer();
00230     array->decrRef();
00231     std::fill(tmp,tmp+mesh->getNumberOfCells()*6,7.);
00232     mesh->decrRef();
00233     fieldOnCells->checkCoherency();
00234     return fieldOnCells;
00235   }
00236 
00237   ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldNodeScalarOn2DNT()
00238   {
00239     ParaMEDMEM::MEDCouplingUMesh *mesh=build2DMesh();
00240     ParaMEDMEM::MEDCouplingFieldDouble *fieldOnNodes=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_NODES,ParaMEDMEM::NO_TIME);
00241     fieldOnNodes->setName("toto2");
00242     fieldOnNodes->setTimeUnit("s");
00243     fieldOnNodes->setDescription("my wonderful field toto2");
00244     fieldOnNodes->setMesh(mesh);
00245     ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
00246     array->alloc(mesh->getNumberOfNodes(),5);
00247     fieldOnNodes->setArray(array);
00248     double *tmp=array->getPointer();
00249     array->decrRef();
00250     std::fill(tmp,tmp+mesh->getNumberOfNodes()*5,7.1234);
00251     mesh->decrRef();
00252     fieldOnNodes->checkCoherency();
00253     return fieldOnNodes;
00254   }
00255 
00256   ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldScalarOn3DNT()
00257   {
00258     ParaMEDMEM::MEDCouplingUMesh *mesh=build3DMesh();
00259     ParaMEDMEM::MEDCouplingFieldDouble *fieldOnCells=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME);
00260     fieldOnCells->setNature(ParaMEDMEM::ConservativeVolumic);
00261     fieldOnCells->setName("toto");
00262     fieldOnCells->setDescription("my wonderful 3D field toto2");
00263     fieldOnCells->setMesh(mesh);
00264     ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
00265     array->alloc(mesh->getNumberOfCells(),6);
00266     fieldOnCells->setArray(array);
00267     double *tmp=array->getPointer();
00268     array->decrRef();
00269     std::fill(tmp,tmp+mesh->getNumberOfCells()*6,7.);
00270     mesh->decrRef();
00271     fieldOnCells->checkCoherency();
00272     return fieldOnCells;
00273   }
00274 
00275   ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldScalarOn3DSurfWT()
00276   {
00277     ParaMEDMEM::MEDCouplingUMesh *mesh=build3DSurfMesh();
00278     ParaMEDMEM::MEDCouplingFieldDouble *fieldOnCells=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
00279     fieldOnCells->setName("toto25");
00280     fieldOnCells->setDescription("my wonderful 3D surf field toto25");
00281     fieldOnCells->setTimeUnit("us");
00282     fieldOnCells->setMesh(mesh);
00283     ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
00284     array->alloc(mesh->getNumberOfCells(),3);
00285     fieldOnCells->setArray(array);
00286     double *tmp=array->getPointer();
00287     array->decrRef();
00288     std::fill(tmp,tmp+mesh->getNumberOfCells()*3,7.);
00289     mesh->decrRef();
00290     fieldOnCells->setTime(6.7,1,4);
00291     fieldOnCells->checkCoherency();
00292     return fieldOnCells;
00293   }
00294 
00295   ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldScalarOn3DSurfCOTI()
00296   {
00297     ParaMEDMEM::MEDCouplingUMesh *mesh=build3DSurfMesh();
00298     ParaMEDMEM::MEDCouplingFieldDouble *fieldOnCells=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::CONST_ON_TIME_INTERVAL);
00299     fieldOnCells->setName("toto26");
00300     fieldOnCells->setDescription("my wonderful 3D surf field toto26");
00301     fieldOnCells->setTimeUnit("us");
00302     fieldOnCells->setMesh(mesh);
00303     ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
00304     array->alloc(mesh->getNumberOfCells(),3);
00305     fieldOnCells->setArray(array);
00306     double *tmp=array->getPointer();
00307     array->decrRef();
00308     std::fill(tmp,tmp+mesh->getNumberOfCells()*3,7.);
00309     mesh->decrRef();
00310     fieldOnCells->setStartTime(6.7,1,4);
00311     fieldOnCells->setEndTime(7.2,2,8);
00312     fieldOnCells->checkCoherency();
00313     return fieldOnCells;
00314   }
00315 
00316   ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldScalarOn2DLT()
00317   {
00318     ParaMEDMEM::MEDCouplingUMesh *mesh=build2DMesh();
00319     ParaMEDMEM::MEDCouplingFieldDouble *fieldOnCells=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::LINEAR_TIME);
00320     fieldOnCells->setName("toto27");
00321     fieldOnCells->setDescription("my wonderful 2D field toto27");
00322     fieldOnCells->setTimeUnit("ms");
00323     fieldOnCells->setMesh(mesh);
00324     ParaMEDMEM::DataArrayDouble *array1=ParaMEDMEM::DataArrayDouble::New();
00325     array1->alloc(mesh->getNumberOfCells(),4);
00326     fieldOnCells->setArray(array1);
00327     double *tmp=array1->getPointer();
00328     array1->decrRef();
00329     const double arr1[20]={1.2,1.02,1.002,1.0002, 3.4,3.04,3.004,3.0004, 5.6,5.06,5.006,5.0006, 7.8,7.08,7.008,7.0008, 9.1,9.01,9.001,9.0001};
00330     std::copy(arr1,arr1+20,tmp);
00331     ParaMEDMEM::DataArrayDouble *array2=ParaMEDMEM::DataArrayDouble::New();
00332     array2->alloc(mesh->getNumberOfCells(),4);
00333     fieldOnCells->setEndArray(array2);
00334     tmp=array2->getPointer();
00335     array2->decrRef();
00336     mesh->decrRef();
00337     const double arr2[20]={71.2,71.02,71.002,71.0002, 73.4,73.04,73.004,73.0004, 75.6,75.06,75.006,75.0006, 77.8,77.08,77.008,77.0008, 79.1,79.01,79.001,79.0001};
00338     std::copy(arr2,arr2+20,tmp);
00339     fieldOnCells->setStartTime(6.7,25,26);
00340     fieldOnCells->setEndTime(17.2,125,126);
00341     fieldOnCells->checkCoherency();
00342     return fieldOnCells;
00343   }
00344 
00345   ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldGaussPt2DWT()
00346   {
00347     const double _a=0.446948490915965;
00348     const double _b=0.091576213509771;
00349     const double _p1=0.11169079483905;
00350     const double _p2=0.0549758718227661;
00351     const double refCoo1[6]={ 0.,0., 1.,0., 0.,1. };
00352     const double gsCoo1[12]={ 2*_b-1, 1-4*_b, 2*_b-1, 2.07*_b-1, 1-4*_b,
00353                               2*_b-1, 1-4*_a, 2*_a-1, 2*_a-1, 1-4*_a, 2*_a-1, 2*_a-1 };
00354     const double wg1[6]={ 4*_p2, 4*_p2, 4*_p2, 4*_p1, 4*_p1, 4*_p1 };
00355     std::vector<double> _refCoo1(refCoo1,refCoo1+6);
00356     std::vector<double> _gsCoo1(gsCoo1,gsCoo1+12);
00357     std::vector<double> _wg1(wg1,wg1+6);
00358     ParaMEDMEM::MEDCouplingUMesh *m=build2DMesh();
00359     ParaMEDMEM::MEDCouplingFieldDouble *f=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_GAUSS_PT,ParaMEDMEM::ONE_TIME);
00360     f->setTime(6.7,1,4);
00361     f->setMesh(m);
00362     m->decrRef();
00363     f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI3,_refCoo1,_gsCoo1,_wg1);
00364     const double refCoo2[8]={ 0.,0., 1.,0., 1.,1., 0.,1. };
00365     std::vector<double> _refCoo2(refCoo2,refCoo2+8);
00366     _gsCoo1.resize(4); _wg1.resize(2);
00367     f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_QUAD4,_refCoo2,_gsCoo1,_wg1);
00368     ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
00369     array->alloc(18,2);
00370     array->setInfoOnComponent(0,"Power(MW)");
00371     array->setInfoOnComponent(1,"Density (kg/m^3)");
00372     double *ptr=array->getPointer();
00373     for(int i=0;i<18*2;i++)
00374       ptr[i]=(double)(i+1);
00375     f->setArray(array);
00376     f->setName("MyFirstFieldOnGaussPoint");
00377     f->setTimeUnit("ms");
00378     f->setDescription("mmmmmmmmmmmm");
00379     array->decrRef();
00380     f->checkCoherency();
00381     return f;
00382   }
00383 
00384   ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldGaussPtNE2DWT()
00385   {
00386     ParaMEDMEM::MEDCouplingUMesh *m=build2DMesh();
00387     ParaMEDMEM::MEDCouplingFieldDouble *f=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_GAUSS_NE,ParaMEDMEM::ONE_TIME);
00388     f->setTime(6.8,11,8);
00389     f->setMesh(m);
00390     f->setTimeUnit("ms");
00391     f->setName("MyFirstFieldOnNE");
00392     f->setDescription("MyDescriptionNE");
00393     ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
00394     array->alloc(18,2);
00395     array->setInfoOnComponent(0,"Power(MW)");
00396     array->setInfoOnComponent(1,"Density (kg/m^3)");
00397     double *ptr=array->getPointer();
00398     for(int i=0;i<18*2;i++)
00399       ptr[i]=(double)(i+7);
00400     f->setArray(array);
00401     array->decrRef();
00402     //
00403     f->checkCoherency();
00404     m->decrRef();
00405     return f;
00406   }
00407 
00408   ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldVectorOnExtrudedWT()
00409   {
00410     ParaMEDMEM::MEDCouplingUMesh *m2D=0;
00411     ParaMEDMEM::MEDCouplingExtrudedMesh *ext=buildExtrudedMesh(m2D);
00412     //
00413     ParaMEDMEM::MEDCouplingFieldDouble *f=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
00414     f->setTime(6.8,11,8);
00415     f->setMesh(ext);
00416     f->setName("MyFieldOnExtruM");
00417     f->setDescription("desc of MyFiOnExtruM");
00418     ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
00419     int nbOfCells=ext->getNumberOfCells();
00420     array->alloc(nbOfCells,2);
00421     array->setInfoOnComponent(0,"Power(MW)");
00422     array->setInfoOnComponent(1,"Density (kg/m^3)");
00423     double *ptr=array->getPointer();
00424     for(int i=0;i<nbOfCells*2;i++)
00425       ptr[i]=(double)(i/2+7)+(double)((i%2)*1000);
00426     f->setArray(array);
00427     array->decrRef();
00428     //
00429     f->checkCoherency();
00430     //
00431     m2D->decrRef();
00432     ext->decrRef();
00433     return f;
00434   }
00435 
00436   ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldVectorOnCMeshWT()
00437   {
00438     ParaMEDMEM::MEDCouplingCMesh *m=buildCMesh();
00439     ParaMEDMEM::MEDCouplingFieldDouble *f=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
00440     f->setTime(6.8,11,8);
00441     f->setMesh(m);
00442     m->decrRef();
00443     f->setName("MyFieldOnCMesh");
00444     f->setDescription("desc of MyFiOnCMesh");
00445     ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
00446     int nbOfCells=m->getNumberOfCells();
00447     array->alloc(nbOfCells,2);
00448     array->setInfoOnComponent(0,"Power(GW)");
00449     array->setInfoOnComponent(1,"Density (kg/m^3)");
00450     double *ptr=array->getPointer();
00451     for(int i=0;i<nbOfCells*2;i++)
00452       ptr[i]=(double)(i/2+7)+(double)((i%2)*1000);
00453     f->setArray(array);
00454     array->decrRef();
00455     //
00456     f->checkCoherency();
00457     //
00458     return f;
00459   }
00460 
00461   ParaMEDMEM::MEDCouplingFieldTemplate *MEDCouplingCorbaServBasicsTest::buildFieldTemplateCellOn2D()
00462   {
00463     ParaMEDMEM::MEDCouplingFieldDouble *f1=buildFieldScalarOn2DNT();
00464     ParaMEDMEM::MEDCouplingFieldTemplate *f2=ParaMEDMEM::MEDCouplingFieldTemplate::New(f1);
00465     f2->setNature(ParaMEDMEM::NoNature);
00466     f1->decrRef();
00467     return f2;
00468   }
00469 
00470   ParaMEDMEM::MEDCouplingFieldTemplate *MEDCouplingCorbaServBasicsTest::buildFieldTemplateNodeOn2D()
00471   {
00472     ParaMEDMEM::MEDCouplingFieldDouble *f1=buildFieldNodeScalarOn2DNT();
00473     ParaMEDMEM::MEDCouplingFieldTemplate *f2=ParaMEDMEM::MEDCouplingFieldTemplate::New(f1);
00474     f2->setNature(ParaMEDMEM::ConservativeVolumic);
00475     f1->decrRef();
00476     return f2;
00477   }
00478 
00479   ParaMEDMEM::MEDCouplingFieldTemplate *MEDCouplingCorbaServBasicsTest::buildFieldTemplateGaussPtOn2D()
00480   {
00481     ParaMEDMEM::MEDCouplingFieldDouble *f1=buildFieldGaussPt2DWT();
00482     ParaMEDMEM::MEDCouplingFieldTemplate *f2=ParaMEDMEM::MEDCouplingFieldTemplate::New(f1);
00483     f2->setNature(ParaMEDMEM::Integral);
00484     f1->decrRef();
00485     return f2;
00486   }
00487 
00488   ParaMEDMEM::MEDCouplingFieldTemplate *MEDCouplingCorbaServBasicsTest::buildFieldTemplateGaussNEOn2D()
00489   {
00490     ParaMEDMEM::MEDCouplingFieldDouble *f1=buildFieldGaussPtNE2DWT();
00491     ParaMEDMEM::MEDCouplingFieldTemplate *f2=ParaMEDMEM::MEDCouplingFieldTemplate::New(f1);
00492     f2->setNature(ParaMEDMEM::IntegralGlobConstraint);
00493     f1->decrRef();
00494     return f2;
00495   }
00496 
00497   ParaMEDMEM::MEDCouplingMultiFields *MEDCouplingCorbaServBasicsTest::buildMultiFields1()
00498   {
00499     ParaMEDMEM::MEDCouplingUMesh *m1=build2DMesh();
00500     m1->setName("m1");
00501     ParaMEDMEM::MEDCouplingUMesh *m2=build2DMesh();
00502     m2->setName("m2");
00503     const double vals0[]={-0.7,-1.,-2.,-3.,-4.};
00504     const double vals1[]={0.,1.,2.,3.,4.,0.1,0.2,0.3,0.4};
00505     const double vals1_1[]={170.,171.,172.,173.,174.,170.1,170.2,170.3,170.4};
00506     const double vals2[]={5.,6.,7.,8.,9.};
00507     const double vals4[]={15.,16.,17.,18.,19.};
00508     //
00509     ParaMEDMEM::DataArrayDouble *d0=ParaMEDMEM::DataArrayDouble::New(); d0->alloc(5,1); std::copy(vals0,vals0+5,d0->getPointer());
00510     ParaMEDMEM::DataArrayDouble *d1=ParaMEDMEM::DataArrayDouble::New(); d1->alloc(9,1); std::copy(vals1,vals1+9,d1->getPointer());
00511     ParaMEDMEM::DataArrayDouble *d1_1=ParaMEDMEM::DataArrayDouble::New(); d1_1->alloc(9,1); std::copy(vals1_1,vals1_1+9,d1_1->getPointer());
00512     ParaMEDMEM::DataArrayDouble *d2=ParaMEDMEM::DataArrayDouble::New(); d2->alloc(5,1); std::copy(vals2,vals2+5,d2->getPointer());
00513     ParaMEDMEM::DataArrayDouble *d4=ParaMEDMEM::DataArrayDouble::New(); d4->alloc(5,1); std::copy(vals4,vals4+5,d4->getPointer());
00514     //
00515     d0->setName("d0"); d1->setName("d1"); d1_1->setName("d1_1"); d2->setName("d2"); d4->setName("d4");
00516     d0->setInfoOnComponent(0,"c1");
00517     d1->setInfoOnComponent(0,"c6");
00518     d1_1->setInfoOnComponent(0,"c9");
00519     d2->setInfoOnComponent(0,"c5");
00520     d4->setInfoOnComponent(0,"c7");
00521     //
00522     ParaMEDMEM::MEDCouplingFieldDouble *f0=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
00523     f0->setMesh(m1);
00524     f0->setArray(d0);
00525     f0->setTime(0.2,5,6);
00526     f0->setName("f0");
00527     ParaMEDMEM::MEDCouplingFieldDouble *f1=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_NODES,ParaMEDMEM::LINEAR_TIME);
00528     f1->setMesh(m1);
00529     std::vector<ParaMEDMEM::DataArrayDouble *> d1s(2); d1s[0]=d1; d1s[1]=d1_1;
00530     f1->setArrays(d1s);
00531     f1->setStartTime(0.7,7,8);
00532     f1->setEndTime(1.2,9,10);
00533     f1->setName("f1");
00534     ParaMEDMEM::MEDCouplingFieldDouble *f2=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::CONST_ON_TIME_INTERVAL);
00535     f2->setMesh(m2);
00536     f2->setArray(d2);
00537     f2->setTime(1.2,11,12);
00538     f2->setEndTime(1.5,13,14);
00539     f2->setName("f2");
00540     ParaMEDMEM::MEDCouplingFieldDouble *f3=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
00541     f3->setMesh(m1);
00542     f3->setArray(d2);
00543     f3->setTime(1.7,15,16);
00544     f3->setName("f3");
00545     ParaMEDMEM::MEDCouplingFieldDouble *f4=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME);
00546     f4->setMesh(m2);
00547     f4->setArray(d4);
00548     f4->setName("f4");
00549     //
00550     std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> fs(5);
00551     fs[0]=f0; fs[1]=f1; fs[2]=f2; fs[3]=f3; fs[4]=f4;
00552     ParaMEDMEM::MEDCouplingMultiFields *ret=ParaMEDMEM::MEDCouplingMultiFields::New(fs);
00553     //
00554     m1->decrRef();
00555     m2->decrRef();
00556     d0->decrRef();
00557     d1->decrRef();
00558     d1_1->decrRef();
00559     d2->decrRef();
00560     d4->decrRef();
00561     f0->decrRef();
00562     f1->decrRef();
00563     f2->decrRef();
00564     f3->decrRef();
00565     f4->decrRef();
00566     //
00567     return ret;
00568   }
00569 
00570   ParaMEDMEM::DataArrayDouble *MEDCouplingCorbaServBasicsTest::buildArrayDouble1()
00571   {
00572     ParaMEDMEM::DataArrayDouble *ret=ParaMEDMEM::DataArrayDouble::New();
00573     ret->alloc(4,3);
00574     const double vals[12]={2.4,3.2,5.6,9.6,47.6,20.4,24.6,278.1,2.01,3.3,2.4,9.4};
00575     std::copy(vals,vals+12,ret->getPointer());
00576     ret->setName("toto");
00577     ret->setInfoOnComponent(0,"sss");
00578     ret->setInfoOnComponent(1,"ppp");
00579     ret->setInfoOnComponent(2,"ttt");
00580     return ret;
00581   }
00582 
00583   ParaMEDMEM::DataArrayDouble *MEDCouplingCorbaServBasicsTest::buildArrayDouble2()
00584   {
00585     ParaMEDMEM::DataArrayDouble *ret=ParaMEDMEM::DataArrayDouble::New();
00586     ret->setName("titi");
00587     return ret;
00588   }
00589 
00590   ParaMEDMEM::DataArrayDouble *MEDCouplingCorbaServBasicsTest::buildArrayDouble3()
00591   {
00592     ParaMEDMEM::DataArrayDouble *ret=ParaMEDMEM::DataArrayDouble::New();
00593     ret->setName("titi");
00594     ret->alloc(0,3);
00595     ret->setInfoOnComponent(0,"sss");
00596     ret->setInfoOnComponent(1,"ppp");
00597     ret->setInfoOnComponent(2,"ttt");
00598     return ret;
00599   }
00600 
00601   ParaMEDMEM::DataArrayInt *MEDCouplingCorbaServBasicsTest::buildArrayInt1()
00602   {
00603     ParaMEDMEM::DataArrayInt *ret=ParaMEDMEM::DataArrayInt::New();
00604     ret->alloc(4,3);
00605     const int vals[12]={2,3,5,9,47,20,24,278,2,3,2,9};
00606     std::copy(vals,vals+12,ret->getPointer());
00607     ret->setName("toto");
00608     ret->setInfoOnComponent(0,"sss");
00609     ret->setInfoOnComponent(1,"ppp");
00610     ret->setInfoOnComponent(2,"ttt");
00611     return ret;
00612   }
00613 
00614   ParaMEDMEM::DataArrayInt *MEDCouplingCorbaServBasicsTest::buildArrayInt2()
00615   {
00616     ParaMEDMEM::DataArrayInt *ret=ParaMEDMEM::DataArrayInt::New();
00617     ret->setName("titi");
00618     return ret;
00619   }
00620 
00621   ParaMEDMEM::DataArrayInt *MEDCouplingCorbaServBasicsTest::buildArrayInt3()
00622   {
00623     ParaMEDMEM::DataArrayInt *ret=ParaMEDMEM::DataArrayInt::New();
00624     ret->setName("titi");
00625     ret->alloc(0,3);
00626     ret->setInfoOnComponent(0,"sss");
00627     ret->setInfoOnComponent(1,"ppp");
00628     ret->setInfoOnComponent(2,"ttt");
00629     return ret;
00630   }
00631 
00632   ParaMEDMEM::MEDCouplingFieldOverTime *MEDCouplingCorbaServBasicsTest::buildMultiFields2()
00633   {
00634     ParaMEDMEM::MEDCouplingUMesh *m1=build2DMesh();
00635     m1->setName("m1");
00636     ParaMEDMEM::MEDCouplingUMesh *m2=build2DMesh();
00637     m2->setName("m2");
00638     const double vals0[]={-0.7,-1.,-2.,-3.,-4.};
00639     const double vals1[]={0.,1.,2.,3.,4.};
00640     const double vals1_1[]={170.,171.,172.,173.,174.};
00641     const double vals2[]={5.,6.,7.,8.,9.};
00642     const double vals4[]={15.,16.,17.,18.,19.};
00643     //
00644     ParaMEDMEM::DataArrayDouble *d0=ParaMEDMEM::DataArrayDouble::New(); d0->alloc(5,1); std::copy(vals0,vals0+5,d0->getPointer());
00645     ParaMEDMEM::DataArrayDouble *d1=ParaMEDMEM::DataArrayDouble::New(); d1->alloc(5,1); std::copy(vals1,vals1+5,d1->getPointer());
00646     ParaMEDMEM::DataArrayDouble *d1_1=ParaMEDMEM::DataArrayDouble::New(); d1_1->alloc(5,1); std::copy(vals1_1,vals1_1+5,d1_1->getPointer());
00647     ParaMEDMEM::DataArrayDouble *d2=ParaMEDMEM::DataArrayDouble::New(); d2->alloc(5,1); std::copy(vals2,vals2+5,d2->getPointer());
00648     ParaMEDMEM::DataArrayDouble *d4=ParaMEDMEM::DataArrayDouble::New(); d4->alloc(5,1); std::copy(vals4,vals4+5,d4->getPointer());
00649     //
00650     d0->setName("d0"); d1->setName("d1"); d1_1->setName("d1_1"); d2->setName("d2"); d4->setName("d4");
00651     d0->setInfoOnComponent(0,"c1");
00652     d1->setInfoOnComponent(0,"c6");
00653     d1_1->setInfoOnComponent(0,"c9");
00654     d2->setInfoOnComponent(0,"c5");
00655     d4->setInfoOnComponent(0,"c7");
00656     //
00657     ParaMEDMEM::MEDCouplingFieldDouble *f0=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
00658     f0->setMesh(m1);
00659     f0->setArray(d0);
00660     f0->setTime(0.2,5,6);
00661     f0->setName("f0");
00662     ParaMEDMEM::MEDCouplingFieldDouble *f1=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::LINEAR_TIME);
00663     f1->setMesh(m1);
00664     std::vector<ParaMEDMEM::DataArrayDouble *> d1s(2); d1s[0]=d1; d1s[1]=d1_1;
00665     f1->setArrays(d1s);
00666     f1->setStartTime(0.7,7,8);
00667     f1->setEndTime(1.2,9,10);
00668     f1->setName("f1");
00669     ParaMEDMEM::MEDCouplingFieldDouble *f2=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::CONST_ON_TIME_INTERVAL);
00670     f2->setMesh(m2);
00671     f2->setArray(d2);
00672     f2->setTime(1.2,11,12);
00673     f2->setEndTime(1.5,13,14);
00674     f2->setName("f2");
00675     ParaMEDMEM::MEDCouplingFieldDouble *f3=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
00676     f3->setMesh(m1);
00677     f3->setArray(d2);
00678     f3->setTime(1.7,15,16);
00679     f3->setName("f3");
00680     ParaMEDMEM::MEDCouplingFieldDouble *f4=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
00681     f4->setMesh(m2);
00682     f4->setArray(d4);
00683     f4->setName("f4");
00684     f4->setTime(2.7,25,26);
00685     //
00686     std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> fs(5);
00687     fs[0]=f0; fs[1]=f1; fs[2]=f2; fs[3]=f3; fs[4]=f4;
00688     ParaMEDMEM::MEDCouplingFieldOverTime *ret=ParaMEDMEM::MEDCouplingFieldOverTime::New(fs);
00689     ret->checkCoherency();
00690     //
00691     m1->decrRef();
00692     m2->decrRef();
00693     d0->decrRef();
00694     d1->decrRef();
00695     d1_1->decrRef();
00696     d2->decrRef();
00697     d4->decrRef();
00698     f0->decrRef();
00699     f1->decrRef();
00700     f2->decrRef();
00701     f3->decrRef();
00702     f4->decrRef();
00703     //
00704     return ret;
00705   }
00706 
00707   std::string MEDCouplingCorbaServBasicsTest::buildFileNameForIOR()
00708   {
00709     std::string ret;
00710     ret+=getenv("TMP");
00711     ret+="/entryPointMEDCouplingCorba.ior";
00712     return ret;
00713   }
00714 }