Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/med.git] / src / MEDCouplingCorba / Test / MEDCouplingMeshFieldFactoryComponent.cxx
1 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #include "MEDCouplingMeshFieldFactoryComponent.hxx"
21 #include "MEDCouplingExtrudedMesh.hxx"
22 #include "MEDCouplingFieldDouble.hxx"
23 #include "MEDCouplingFieldTemplate.hxx"
24 #include "MEDCouplingMultiFields.hxx"
25 #include "MEDCouplingFieldOverTime.hxx"
26 #include "MEDCouplingMemArray.hxx"
27 #include "MEDCouplingUMesh.hxx"
28 #include "MEDCouplingCMesh.hxx"
29
30 #include <cmath>
31 #include <algorithm>
32
33 namespace SALOME_TEST
34 {
35   ParaMEDMEM::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::build1DMesh()
36   {
37     double coords[4]={ 0.0, 0.3, 0.75, 1.0 };
38     int conn[2*3]={ 0,1, 1,2, 2,3 };
39     ParaMEDMEM::MEDCouplingUMesh *mesh=ParaMEDMEM::MEDCouplingUMesh::New("1DMeshForCorba",1);
40     mesh->setDescription("build1DMesh");
41     mesh->allocateCells(3);
42     mesh->setTime(5.6,7,8);
43     mesh->setTimeUnit("ms");
44     mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
45     mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2);
46     mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+4);
47     mesh->finishInsertingCells();
48     ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New();
49     myCoords->alloc(4,1);
50     std::copy(coords,coords+4,myCoords->getPointer());
51     mesh->setCoords(myCoords);
52     myCoords->decrRef();
53     mesh->changeSpaceDimension(3);
54     myCoords=mesh->getCoords();
55     myCoords->setInfoOnComponent(0,"X1D [m]");
56     myCoords->setInfoOnComponent(1,"Y1D [dm]");
57     myCoords->setInfoOnComponent(2,"Z1D [pm]");
58     double center[3]={0.,0.,0.};
59     double vector[3]={0,1,0};
60     mesh->rotate(center,vector,-M_PI/2.);
61     return mesh;
62   }
63
64   ParaMEDMEM::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::build2DMesh()
65   {
66     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 };
67     int targetConn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
68     ParaMEDMEM::MEDCouplingUMesh *targetMesh=ParaMEDMEM::MEDCouplingUMesh::New();
69     targetMesh->setMeshDimension(2);
70     targetMesh->setName("MyMesh2D");
71     targetMesh->setDescription("build2DMesh");
72     targetMesh->allocateCells(5);
73     targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
74     targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
75     targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
76     targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
77     targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
78     targetMesh->finishInsertingCells();
79     ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New();
80     myCoords->alloc(9,2);
81     std::copy(targetCoords,targetCoords+18,myCoords->getPointer());
82     targetMesh->setCoords(myCoords);
83     myCoords->decrRef();
84     return targetMesh;
85   }
86
87   ParaMEDMEM::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::build3DMesh()
88   {
89     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. ,
90                               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. ,
91                               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. };
92     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,
93                         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};
94     ParaMEDMEM::MEDCouplingUMesh *targetMesh=ParaMEDMEM::MEDCouplingUMesh::New();
95     targetMesh->setMeshDimension(3);
96     targetMesh->setName("MyMesh3D");
97     targetMesh->setDescription("build3DMesh");
98     targetMesh->allocateCells(12);
99     for(int i=0;i<8;i++)
100       targetMesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,targetConn+8*i);
101     targetMesh->finishInsertingCells();
102     ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New();
103     myCoords->alloc(27,3);
104     std::copy(targetCoords,targetCoords+81,myCoords->getPointer());
105     targetMesh->setCoords(myCoords);
106     myCoords->setName("check in case");
107     myCoords->decrRef();
108     return targetMesh;
109   }
110
111   ParaMEDMEM::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::build3DSurfMesh()
112   {
113     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};
114     int targetConn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
115     ParaMEDMEM::MEDCouplingUMesh *targetMesh=ParaMEDMEM::MEDCouplingUMesh::New();
116     targetMesh->setMeshDimension(2);
117     targetMesh->setName("MyMesh3DSurf");
118     targetMesh->setDescription("build3DSurfMesh");
119     targetMesh->allocateCells(5);
120     targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
121     targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
122     targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
123     targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
124     targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
125     targetMesh->finishInsertingCells();
126     ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New();
127     myCoords->alloc(9,3);
128     std::copy(targetCoords,targetCoords+27,myCoords->getPointer());
129     targetMesh->setCoords(myCoords);
130     myCoords->setInfoOnComponent(0,"X [m]");
131     myCoords->setInfoOnComponent(1,"X [dm]");
132     myCoords->setInfoOnComponent(2,"X [m]");
133     myCoords->decrRef();
134     return targetMesh;
135   }
136
137   ParaMEDMEM::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::build0DMesh()
138   {
139     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};
140     const int targetConn[]={0,1,2,3,4,5,7,6};
141     ParaMEDMEM::MEDCouplingUMesh *targetMesh=ParaMEDMEM::MEDCouplingUMesh::New();
142     targetMesh->setMeshDimension(0);
143     targetMesh->allocateCells(8);
144     targetMesh->setName("Wonderfull 0D mesh");
145     targetMesh->setDescription("build0DMesh");
146     targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn);
147     targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+1);
148     targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+2);
149     targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+3);
150     targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+4);
151     targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+5);
152     targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+6);
153     targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+7);
154     targetMesh->finishInsertingCells();
155     ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New();
156     myCoords->alloc(9,3);
157     std::copy(targetCoords,targetCoords+27,myCoords->getPointer());
158     targetMesh->setCoords(myCoords);
159     myCoords->setInfoOnComponent(0,"X [m]");
160     myCoords->setInfoOnComponent(1,"YY [Pm]");
161     myCoords->setInfoOnComponent(2,"ZZZ [m]");
162     myCoords->decrRef();
163     //
164     targetMesh->checkCoherency();
165     return targetMesh;
166   }
167
168   ParaMEDMEM::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::buildM1DMesh()
169   {
170     ParaMEDMEM::MEDCouplingUMesh *meshM1D=ParaMEDMEM::MEDCouplingUMesh::New("wonderfull -1 D mesh",-1);
171     meshM1D->setDescription("buildM1DMesh");
172     meshM1D->checkCoherency();
173     return meshM1D;
174   }
175
176   ParaMEDMEM::MEDCouplingExtrudedMesh *MEDCouplingCorbaServBasicsTest::buildExtrudedMesh(ParaMEDMEM::MEDCouplingUMesh *&m2D)
177   {
178     m2D=build2DMesh();
179     m2D->changeSpaceDimension(3);
180     ParaMEDMEM::MEDCouplingUMesh *m1D=build1DMesh();
181     ParaMEDMEM::MEDCouplingUMesh *retu=m2D->buildExtrudedMesh(m1D,0);
182     m1D->decrRef();
183     ParaMEDMEM::MEDCouplingExtrudedMesh *ret=ParaMEDMEM::MEDCouplingExtrudedMesh::New(retu,m2D,2);
184     ret->setName("ExtrudedTestForCorbaTest");
185     ret->setDescription("buildExtrudedMesh");
186     retu->decrRef();
187     return ret;
188   }
189
190   ParaMEDMEM::MEDCouplingCMesh *MEDCouplingCorbaServBasicsTest::buildCMesh()
191   {
192     ParaMEDMEM::MEDCouplingCMesh *targetMesh=ParaMEDMEM::MEDCouplingCMesh::New();
193     targetMesh->setTime(2.3,4,5);
194     targetMesh->setTimeUnit("us");
195     targetMesh->setName("Example of CMesh");
196     targetMesh->setDescription("buildCMesh");
197     ParaMEDMEM::DataArrayDouble *a1=ParaMEDMEM::DataArrayDouble::New();
198     a1->alloc(5,1);
199     a1->setInfoOnComponent(0,"SmthX");
200     const double a1Data[5]={3.,4.,5.,6.,7.};
201     std::copy(a1Data,a1Data+5,a1->getPointer());
202     ParaMEDMEM::DataArrayDouble *a2=ParaMEDMEM::DataArrayDouble::New();
203     a2->alloc(6,1);
204     a2->setInfoOnComponent(0,"SmthZ");
205     const double a2Data[6]={2.78,3.,4.,5.,6.,7.};
206     std::copy(a2Data,a2Data+6,a2->getPointer());
207     //
208     targetMesh->setCoordsAt(0,a1);
209     targetMesh->setCoordsAt(2,a2);
210     //
211     a1->decrRef();
212     a2->decrRef();
213     //
214     targetMesh->checkCoherency();
215     //
216     return targetMesh;
217   }
218
219   ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldScalarOn2DNT()
220   {
221     ParaMEDMEM::MEDCouplingUMesh *mesh=build2DMesh();
222     ParaMEDMEM::MEDCouplingFieldDouble *fieldOnCells=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME);
223     fieldOnCells->setTimeUnit("ms");
224     fieldOnCells->setName("toto");
225     fieldOnCells->setMesh(mesh);
226     ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
227     array->alloc(mesh->getNumberOfCells(),6);
228     fieldOnCells->setArray(array);
229     double *tmp=array->getPointer();
230     array->decrRef();
231     std::fill(tmp,tmp+mesh->getNumberOfCells()*6,7.);
232     mesh->decrRef();
233     fieldOnCells->checkCoherency();
234     return fieldOnCells;
235   }
236
237   ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldNodeScalarOn2DNT()
238   {
239     ParaMEDMEM::MEDCouplingUMesh *mesh=build2DMesh();
240     ParaMEDMEM::MEDCouplingFieldDouble *fieldOnNodes=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_NODES,ParaMEDMEM::NO_TIME);
241     fieldOnNodes->setName("toto2");
242     fieldOnNodes->setTimeUnit("s");
243     fieldOnNodes->setDescription("my wonderful field toto2");
244     fieldOnNodes->setMesh(mesh);
245     ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
246     array->alloc(mesh->getNumberOfNodes(),5);
247     fieldOnNodes->setArray(array);
248     double *tmp=array->getPointer();
249     array->decrRef();
250     std::fill(tmp,tmp+mesh->getNumberOfNodes()*5,7.1234);
251     mesh->decrRef();
252     fieldOnNodes->checkCoherency();
253     return fieldOnNodes;
254   }
255
256   ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldScalarOn3DNT()
257   {
258     ParaMEDMEM::MEDCouplingUMesh *mesh=build3DMesh();
259     ParaMEDMEM::MEDCouplingFieldDouble *fieldOnCells=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME);
260     fieldOnCells->setNature(ParaMEDMEM::ConservativeVolumic);
261     fieldOnCells->setName("toto");
262     fieldOnCells->setDescription("my wonderful 3D field toto2");
263     fieldOnCells->setMesh(mesh);
264     ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
265     array->alloc(mesh->getNumberOfCells(),6);
266     fieldOnCells->setArray(array);
267     double *tmp=array->getPointer();
268     array->decrRef();
269     std::fill(tmp,tmp+mesh->getNumberOfCells()*6,7.);
270     mesh->decrRef();
271     fieldOnCells->checkCoherency();
272     return fieldOnCells;
273   }
274
275   ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldScalarOn3DSurfWT()
276   {
277     ParaMEDMEM::MEDCouplingUMesh *mesh=build3DSurfMesh();
278     ParaMEDMEM::MEDCouplingFieldDouble *fieldOnCells=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
279     fieldOnCells->setName("toto25");
280     fieldOnCells->setDescription("my wonderful 3D surf field toto25");
281     fieldOnCells->setTimeUnit("us");
282     fieldOnCells->setMesh(mesh);
283     ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
284     array->alloc(mesh->getNumberOfCells(),3);
285     array->setInfoOnComponent(0,"aaa"); array->setInfoOnComponent(1,"bbbb"); array->setInfoOnComponent(2,"ccccc");
286     fieldOnCells->setArray(array);
287     double *tmp=array->getPointer();
288     array->decrRef();
289     std::fill(tmp,tmp+mesh->getNumberOfCells()*3,7.);
290     mesh->decrRef();
291     fieldOnCells->setTime(6.7,1,4);
292     fieldOnCells->checkCoherency();
293     return fieldOnCells;
294   }
295
296   ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldScalarOn3DSurfCOTI()
297   {
298     ParaMEDMEM::MEDCouplingUMesh *mesh=build3DSurfMesh();
299     ParaMEDMEM::MEDCouplingFieldDouble *fieldOnCells=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::CONST_ON_TIME_INTERVAL);
300     fieldOnCells->setName("toto26");
301     fieldOnCells->setDescription("my wonderful 3D surf field toto26");
302     fieldOnCells->setTimeUnit("us");
303     fieldOnCells->setMesh(mesh);
304     ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
305     array->alloc(mesh->getNumberOfCells(),3);
306     fieldOnCells->setArray(array);
307     double *tmp=array->getPointer();
308     array->decrRef();
309     std::fill(tmp,tmp+mesh->getNumberOfCells()*3,7.);
310     mesh->decrRef();
311     fieldOnCells->setStartTime(6.7,1,4);
312     fieldOnCells->setEndTime(7.2,2,8);
313     fieldOnCells->checkCoherency();
314     return fieldOnCells;
315   }
316
317   ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldScalarOn2DLT()
318   {
319     ParaMEDMEM::MEDCouplingUMesh *mesh=build2DMesh();
320     ParaMEDMEM::MEDCouplingFieldDouble *fieldOnCells=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::LINEAR_TIME);
321     fieldOnCells->setName("toto27");
322     fieldOnCells->setDescription("my wonderful 2D field toto27");
323     fieldOnCells->setTimeUnit("ms");
324     fieldOnCells->setMesh(mesh);
325     ParaMEDMEM::DataArrayDouble *array1=ParaMEDMEM::DataArrayDouble::New();
326     array1->alloc(mesh->getNumberOfCells(),4);
327     fieldOnCells->setArray(array1);
328     double *tmp=array1->getPointer();
329     array1->decrRef();
330     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};
331     std::copy(arr1,arr1+20,tmp);
332     ParaMEDMEM::DataArrayDouble *array2=ParaMEDMEM::DataArrayDouble::New();
333     array2->alloc(mesh->getNumberOfCells(),4);
334     fieldOnCells->setEndArray(array2);
335     tmp=array2->getPointer();
336     array2->decrRef();
337     mesh->decrRef();
338     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};
339     std::copy(arr2,arr2+20,tmp);
340     fieldOnCells->setStartTime(6.7,25,26);
341     fieldOnCells->setEndTime(17.2,125,126);
342     fieldOnCells->checkCoherency();
343     return fieldOnCells;
344   }
345
346   ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldGaussPt2DWT()
347   {
348     const double _a=0.446948490915965;
349     const double _b=0.091576213509771;
350     const double _p1=0.11169079483905;
351     const double _p2=0.0549758718227661;
352     const double refCoo1[6]={ 0.,0., 1.,0., 0.,1. };
353     const double gsCoo1[12]={ 2*_b-1, 1-4*_b, 2*_b-1, 2.07*_b-1, 1-4*_b,
354                               2*_b-1, 1-4*_a, 2*_a-1, 2*_a-1, 1-4*_a, 2*_a-1, 2*_a-1 };
355     const double wg1[6]={ 4*_p2, 4*_p2, 4*_p2, 4*_p1, 4*_p1, 4*_p1 };
356     std::vector<double> _refCoo1(refCoo1,refCoo1+6);
357     std::vector<double> _gsCoo1(gsCoo1,gsCoo1+12);
358     std::vector<double> _wg1(wg1,wg1+6);
359     ParaMEDMEM::MEDCouplingUMesh *m=build2DMesh();
360     ParaMEDMEM::MEDCouplingFieldDouble *f=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_GAUSS_PT,ParaMEDMEM::ONE_TIME);
361     f->setTime(6.7,1,4);
362     f->setMesh(m);
363     m->decrRef();
364     f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI3,_refCoo1,_gsCoo1,_wg1);
365     const double refCoo2[8]={ 0.,0., 1.,0., 1.,1., 0.,1. };
366     std::vector<double> _refCoo2(refCoo2,refCoo2+8);
367     _gsCoo1.resize(4); _wg1.resize(2);
368     f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_QUAD4,_refCoo2,_gsCoo1,_wg1);
369     ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
370     array->alloc(18,2);
371     array->setInfoOnComponent(0,"Power [MW]");
372     array->setInfoOnComponent(1,"Density [kg/m^3]");
373     double *ptr=array->getPointer();
374     for(int i=0;i<18*2;i++)
375       ptr[i]=(double)(i+1);
376     f->setArray(array);
377     f->setName("MyFirstFieldOnGaussPoint");
378     f->setTimeUnit("ms");
379     f->setDescription("mmmmmmmmmmmm");
380     array->decrRef();
381     f->checkCoherency();
382     return f;
383   }
384
385   ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldGaussPtNE2DWT()
386   {
387     ParaMEDMEM::MEDCouplingUMesh *m=build2DMesh();
388     ParaMEDMEM::MEDCouplingFieldDouble *f=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_GAUSS_NE,ParaMEDMEM::ONE_TIME);
389     f->setTime(6.8,11,8);
390     f->setMesh(m);
391     f->setTimeUnit("ms");
392     f->setName("MyFirstFieldOnNE");
393     f->setDescription("MyDescriptionNE");
394     ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
395     array->alloc(18,2);
396     array->setInfoOnComponent(0,"Power [MW]");
397     array->setInfoOnComponent(1,"Density [kg/m^3]");
398     double *ptr=array->getPointer();
399     for(int i=0;i<18*2;i++)
400       ptr[i]=(double)(i+7);
401     f->setArray(array);
402     array->decrRef();
403     //
404     f->checkCoherency();
405     m->decrRef();
406     return f;
407   }
408
409   ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldVectorOnExtrudedWT()
410   {
411     ParaMEDMEM::MEDCouplingUMesh *m2D=0;
412     ParaMEDMEM::MEDCouplingExtrudedMesh *ext=buildExtrudedMesh(m2D);
413     //
414     ParaMEDMEM::MEDCouplingFieldDouble *f=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
415     f->setTime(6.8,11,8);
416     f->setMesh(ext);
417     f->setName("MyFieldOnExtruM");
418     f->setDescription("desc of MyFiOnExtruM");
419     ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
420     int nbOfCells=ext->getNumberOfCells();
421     array->alloc(nbOfCells,2);
422     array->setInfoOnComponent(0,"Power [MW]");
423     array->setInfoOnComponent(1,"Density [kg/m^3]");
424     double *ptr=array->getPointer();
425     for(int i=0;i<nbOfCells*2;i++)
426       ptr[i]=(double)(i/2+7)+(double)((i%2)*1000);
427     f->setArray(array);
428     array->decrRef();
429     //
430     f->checkCoherency();
431     //
432     m2D->decrRef();
433     ext->decrRef();
434     return f;
435   }
436
437   ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldVectorOnCMeshWT()
438   {
439     ParaMEDMEM::MEDCouplingCMesh *m=buildCMesh();
440     ParaMEDMEM::MEDCouplingFieldDouble *f=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
441     f->setTime(6.8,11,8);
442     f->setMesh(m);
443     m->decrRef();
444     f->setName("MyFieldOnCMesh");
445     f->setDescription("desc of MyFiOnCMesh");
446     ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
447     int nbOfCells=m->getNumberOfCells();
448     array->alloc(nbOfCells,2);
449     array->setInfoOnComponent(0,"Power [GW]");
450     array->setInfoOnComponent(1,"Density [kg/m^3]");
451     double *ptr=array->getPointer();
452     for(int i=0;i<nbOfCells*2;i++)
453       ptr[i]=(double)(i/2+7)+(double)((i%2)*1000);
454     f->setArray(array);
455     array->decrRef();
456     //
457     f->checkCoherency();
458     //
459     return f;
460   }
461
462   ParaMEDMEM::MEDCouplingFieldTemplate *MEDCouplingCorbaServBasicsTest::buildFieldTemplateCellOn2D()
463   {
464     ParaMEDMEM::MEDCouplingFieldDouble *f1=buildFieldScalarOn2DNT();
465     ParaMEDMEM::MEDCouplingFieldTemplate *f2=ParaMEDMEM::MEDCouplingFieldTemplate::New(f1);
466     f2->setNature(ParaMEDMEM::NoNature);
467     f1->decrRef();
468     return f2;
469   }
470
471   ParaMEDMEM::MEDCouplingFieldTemplate *MEDCouplingCorbaServBasicsTest::buildFieldTemplateNodeOn2D()
472   {
473     ParaMEDMEM::MEDCouplingFieldDouble *f1=buildFieldNodeScalarOn2DNT();
474     ParaMEDMEM::MEDCouplingFieldTemplate *f2=ParaMEDMEM::MEDCouplingFieldTemplate::New(f1);
475     f2->setNature(ParaMEDMEM::ConservativeVolumic);
476     f1->decrRef();
477     return f2;
478   }
479
480   ParaMEDMEM::MEDCouplingFieldTemplate *MEDCouplingCorbaServBasicsTest::buildFieldTemplateGaussPtOn2D()
481   {
482     ParaMEDMEM::MEDCouplingFieldDouble *f1=buildFieldGaussPt2DWT();
483     ParaMEDMEM::MEDCouplingFieldTemplate *f2=ParaMEDMEM::MEDCouplingFieldTemplate::New(f1);
484     f2->setNature(ParaMEDMEM::Integral);
485     f1->decrRef();
486     return f2;
487   }
488
489   ParaMEDMEM::MEDCouplingFieldTemplate *MEDCouplingCorbaServBasicsTest::buildFieldTemplateGaussNEOn2D()
490   {
491     ParaMEDMEM::MEDCouplingFieldDouble *f1=buildFieldGaussPtNE2DWT();
492     ParaMEDMEM::MEDCouplingFieldTemplate *f2=ParaMEDMEM::MEDCouplingFieldTemplate::New(f1);
493     f2->setNature(ParaMEDMEM::IntegralGlobConstraint);
494     f1->decrRef();
495     return f2;
496   }
497
498   ParaMEDMEM::MEDCouplingMultiFields *MEDCouplingCorbaServBasicsTest::buildMultiFields1()
499   {
500     ParaMEDMEM::MEDCouplingUMesh *m1=build2DMesh();
501     m1->setName("m1");
502     ParaMEDMEM::MEDCouplingUMesh *m2=build2DMesh();
503     m2->setName("m2");
504     const double vals0[]={-0.7,-1.,-2.,-3.,-4.};
505     const double vals1[]={0.,1.,2.,3.,4.,0.1,0.2,0.3,0.4};
506     const double vals1_1[]={170.,171.,172.,173.,174.,170.1,170.2,170.3,170.4};
507     const double vals2[]={5.,6.,7.,8.,9.};
508     const double vals4[]={15.,16.,17.,18.,19.};
509     //
510     ParaMEDMEM::DataArrayDouble *d0=ParaMEDMEM::DataArrayDouble::New(); d0->alloc(5,1); std::copy(vals0,vals0+5,d0->getPointer());
511     ParaMEDMEM::DataArrayDouble *d1=ParaMEDMEM::DataArrayDouble::New(); d1->alloc(9,1); std::copy(vals1,vals1+9,d1->getPointer());
512     ParaMEDMEM::DataArrayDouble *d1_1=ParaMEDMEM::DataArrayDouble::New(); d1_1->alloc(9,1); std::copy(vals1_1,vals1_1+9,d1_1->getPointer());
513     ParaMEDMEM::DataArrayDouble *d2=ParaMEDMEM::DataArrayDouble::New(); d2->alloc(5,1); std::copy(vals2,vals2+5,d2->getPointer());
514     ParaMEDMEM::DataArrayDouble *d4=ParaMEDMEM::DataArrayDouble::New(); d4->alloc(5,1); std::copy(vals4,vals4+5,d4->getPointer());
515     //
516     d0->setName("d0"); d1->setName("d1"); d1_1->setName("d1_1"); d2->setName("d2"); d4->setName("d4");
517     d0->setInfoOnComponent(0,"c1");
518     d1->setInfoOnComponent(0,"c6");
519     d1_1->setInfoOnComponent(0,"c9");
520     d2->setInfoOnComponent(0,"c5");
521     d4->setInfoOnComponent(0,"c7");
522     //
523     ParaMEDMEM::MEDCouplingFieldDouble *f0=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
524     f0->setMesh(m1);
525     f0->setArray(d0);
526     f0->setTime(0.2,5,6);
527     f0->setName("f0");
528     ParaMEDMEM::MEDCouplingFieldDouble *f1=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_NODES,ParaMEDMEM::LINEAR_TIME);
529     f1->setMesh(m1);
530     std::vector<ParaMEDMEM::DataArrayDouble *> d1s(2); d1s[0]=d1; d1s[1]=d1_1;
531     f1->setArrays(d1s);
532     f1->setStartTime(0.7,7,8);
533     f1->setEndTime(1.2,9,10);
534     f1->setName("f1");
535     ParaMEDMEM::MEDCouplingFieldDouble *f2=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::CONST_ON_TIME_INTERVAL);
536     f2->setMesh(m2);
537     f2->setArray(d2);
538     f2->setTime(1.2,11,12);
539     f2->setEndTime(1.5,13,14);
540     f2->setName("f2");
541     ParaMEDMEM::MEDCouplingFieldDouble *f3=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
542     f3->setMesh(m1);
543     f3->setArray(d2);
544     f3->setTime(1.7,15,16);
545     f3->setName("f3");
546     ParaMEDMEM::MEDCouplingFieldDouble *f4=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME);
547     f4->setMesh(m2);
548     f4->setArray(d4);
549     f4->setName("f4");
550     //
551     std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> fs(5);
552     fs[0]=f0; fs[1]=f1; fs[2]=f2; fs[3]=f3; fs[4]=f4;
553     ParaMEDMEM::MEDCouplingMultiFields *ret=ParaMEDMEM::MEDCouplingMultiFields::New(fs);
554     //
555     m1->decrRef();
556     m2->decrRef();
557     d0->decrRef();
558     d1->decrRef();
559     d1_1->decrRef();
560     d2->decrRef();
561     d4->decrRef();
562     f0->decrRef();
563     f1->decrRef();
564     f2->decrRef();
565     f3->decrRef();
566     f4->decrRef();
567     //
568     return ret;
569   }
570
571   ParaMEDMEM::DataArrayDouble *MEDCouplingCorbaServBasicsTest::buildArrayDouble1()
572   {
573     ParaMEDMEM::DataArrayDouble *ret=ParaMEDMEM::DataArrayDouble::New();
574     ret->alloc(4,3);
575     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};
576     std::copy(vals,vals+12,ret->getPointer());
577     ret->setName("toto");
578     ret->setInfoOnComponent(0,"sss");
579     ret->setInfoOnComponent(1,"ppp");
580     ret->setInfoOnComponent(2,"ttt");
581     return ret;
582   }
583
584   ParaMEDMEM::DataArrayDouble *MEDCouplingCorbaServBasicsTest::buildArrayDouble2()
585   {
586     ParaMEDMEM::DataArrayDouble *ret=ParaMEDMEM::DataArrayDouble::New();
587     ret->setName("titi");
588     return ret;
589   }
590
591   ParaMEDMEM::DataArrayDouble *MEDCouplingCorbaServBasicsTest::buildArrayDouble3()
592   {
593     ParaMEDMEM::DataArrayDouble *ret=ParaMEDMEM::DataArrayDouble::New();
594     ret->setName("titi");
595     ret->alloc(0,3);
596     ret->setInfoOnComponent(0,"sss");
597     ret->setInfoOnComponent(1,"ppp");
598     ret->setInfoOnComponent(2,"ttt");
599     return ret;
600   }
601
602   ParaMEDMEM::DataArrayInt *MEDCouplingCorbaServBasicsTest::buildArrayInt1()
603   {
604     ParaMEDMEM::DataArrayInt *ret=ParaMEDMEM::DataArrayInt::New();
605     ret->alloc(4,3);
606     const int vals[12]={2,3,5,9,47,20,24,278,2,3,2,9};
607     std::copy(vals,vals+12,ret->getPointer());
608     ret->setName("toto");
609     ret->setInfoOnComponent(0,"sss");
610     ret->setInfoOnComponent(1,"ppp");
611     ret->setInfoOnComponent(2,"ttt");
612     return ret;
613   }
614
615   ParaMEDMEM::DataArrayInt *MEDCouplingCorbaServBasicsTest::buildArrayInt2()
616   {
617     ParaMEDMEM::DataArrayInt *ret=ParaMEDMEM::DataArrayInt::New();
618     ret->setName("titi");
619     return ret;
620   }
621
622   ParaMEDMEM::DataArrayInt *MEDCouplingCorbaServBasicsTest::buildArrayInt3()
623   {
624     ParaMEDMEM::DataArrayInt *ret=ParaMEDMEM::DataArrayInt::New();
625     ret->setName("titi");
626     ret->alloc(0,3);
627     ret->setInfoOnComponent(0,"sss");
628     ret->setInfoOnComponent(1,"ppp");
629     ret->setInfoOnComponent(2,"ttt");
630     return ret;
631   }
632
633   ParaMEDMEM::MEDCouplingFieldOverTime *MEDCouplingCorbaServBasicsTest::buildMultiFields2()
634   {
635     ParaMEDMEM::MEDCouplingUMesh *m1=build2DMesh();
636     m1->setName("m1");
637     ParaMEDMEM::MEDCouplingUMesh *m2=build2DMesh();
638     m2->setName("m2");
639     const double vals0[]={-0.7,-1.,-2.,-3.,-4.};
640     const double vals1[]={0.,1.,2.,3.,4.};
641     const double vals1_1[]={170.,171.,172.,173.,174.};
642     const double vals2[]={5.,6.,7.,8.,9.};
643     const double vals4[]={15.,16.,17.,18.,19.};
644     //
645     ParaMEDMEM::DataArrayDouble *d0=ParaMEDMEM::DataArrayDouble::New(); d0->alloc(5,1); std::copy(vals0,vals0+5,d0->getPointer());
646     ParaMEDMEM::DataArrayDouble *d1=ParaMEDMEM::DataArrayDouble::New(); d1->alloc(5,1); std::copy(vals1,vals1+5,d1->getPointer());
647     ParaMEDMEM::DataArrayDouble *d1_1=ParaMEDMEM::DataArrayDouble::New(); d1_1->alloc(5,1); std::copy(vals1_1,vals1_1+5,d1_1->getPointer());
648     ParaMEDMEM::DataArrayDouble *d2=ParaMEDMEM::DataArrayDouble::New(); d2->alloc(5,1); std::copy(vals2,vals2+5,d2->getPointer());
649     ParaMEDMEM::DataArrayDouble *d4=ParaMEDMEM::DataArrayDouble::New(); d4->alloc(5,1); std::copy(vals4,vals4+5,d4->getPointer());
650     //
651     d0->setName("d0"); d1->setName("d1"); d1_1->setName("d1_1"); d2->setName("d2"); d4->setName("d4");
652     d0->setInfoOnComponent(0,"c1");
653     d1->setInfoOnComponent(0,"c6");
654     d1_1->setInfoOnComponent(0,"c9");
655     d2->setInfoOnComponent(0,"c5");
656     d4->setInfoOnComponent(0,"c7");
657     //
658     ParaMEDMEM::MEDCouplingFieldDouble *f0=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
659     f0->setMesh(m1);
660     f0->setArray(d0);
661     f0->setTime(0.2,5,6);
662     f0->setName("f0");
663     ParaMEDMEM::MEDCouplingFieldDouble *f1=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::LINEAR_TIME);
664     f1->setMesh(m1);
665     std::vector<ParaMEDMEM::DataArrayDouble *> d1s(2); d1s[0]=d1; d1s[1]=d1_1;
666     f1->setArrays(d1s);
667     f1->setStartTime(0.7,7,8);
668     f1->setEndTime(1.2,9,10);
669     f1->setName("f1");
670     ParaMEDMEM::MEDCouplingFieldDouble *f2=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::CONST_ON_TIME_INTERVAL);
671     f2->setMesh(m2);
672     f2->setArray(d2);
673     f2->setTime(1.2,11,12);
674     f2->setEndTime(1.5,13,14);
675     f2->setName("f2");
676     ParaMEDMEM::MEDCouplingFieldDouble *f3=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
677     f3->setMesh(m1);
678     f3->setArray(d2);
679     f3->setTime(1.7,15,16);
680     f3->setName("f3");
681     ParaMEDMEM::MEDCouplingFieldDouble *f4=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
682     f4->setMesh(m2);
683     f4->setArray(d4);
684     f4->setName("f4");
685     f4->setTime(2.7,25,26);
686     //
687     std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> fs(5);
688     fs[0]=f0; fs[1]=f1; fs[2]=f2; fs[3]=f3; fs[4]=f4;
689     ParaMEDMEM::MEDCouplingFieldOverTime *ret=ParaMEDMEM::MEDCouplingFieldOverTime::New(fs);
690     ret->checkCoherency();
691     //
692     m1->decrRef();
693     m2->decrRef();
694     d0->decrRef();
695     d1->decrRef();
696     d1_1->decrRef();
697     d2->decrRef();
698     d4->decrRef();
699     f0->decrRef();
700     f1->decrRef();
701     f2->decrRef();
702     f3->decrRef();
703     f4->decrRef();
704     //
705     return ret;
706   }
707
708   std::string MEDCouplingCorbaServBasicsTest::buildFileNameForIOR()
709   {
710     std::string ret;
711     ret+=getenv("TMP");
712     ret+="/entryPointMEDCouplingCorba.ior";
713     return ret;
714   }
715 }