1 // Copyright (C) 2007-2013 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay (CEA/DEN)
21 #include "MEDCouplingMeshFieldFactoryComponent.hxx"
22 #include "MEDCouplingExtrudedMesh.hxx"
23 #include "MEDCouplingFieldDouble.hxx"
24 #include "MEDCouplingFieldTemplate.hxx"
25 #include "MEDCouplingMultiFields.hxx"
26 #include "MEDCouplingFieldOverTime.hxx"
27 #include "MEDCouplingMemArray.hxx"
28 #include "MEDCoupling1GTUMesh.hxx"
29 #include "MEDCouplingUMesh.hxx"
30 #include "MEDCouplingCMesh.hxx"
31 #include "MEDCouplingCurveLinearMesh.hxx"
38 ParaMEDMEM::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::build1DMesh()
40 double coords[4]={ 0.0, 0.3, 0.75, 1.0 };
41 int conn[2*3]={ 0,1, 1,2, 2,3 };
42 ParaMEDMEM::MEDCouplingUMesh *mesh=ParaMEDMEM::MEDCouplingUMesh::New("1DMeshForCorba",1);
43 mesh->setDescription("build1DMesh");
44 mesh->allocateCells(3);
45 mesh->setTime(5.6,7,8);
46 mesh->setTimeUnit("ms");
47 mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
48 mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2);
49 mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+4);
50 mesh->finishInsertingCells();
51 ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New();
53 std::copy(coords,coords+4,myCoords->getPointer());
54 mesh->setCoords(myCoords);
56 mesh->changeSpaceDimension(3);
57 myCoords=mesh->getCoords();
58 myCoords->setInfoOnComponent(0,"X1D [m]");
59 myCoords->setInfoOnComponent(1,"Y1D [dm]");
60 myCoords->setInfoOnComponent(2,"Z1D [pm]");
61 double center[3]={0.,0.,0.};
62 double vector[3]={0,1,0};
63 mesh->rotate(center,vector,-M_PI/2.);
67 ParaMEDMEM::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::build2DMesh()
69 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 };
70 int targetConn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
71 ParaMEDMEM::MEDCouplingUMesh *targetMesh=ParaMEDMEM::MEDCouplingUMesh::New();
72 targetMesh->setMeshDimension(2);
73 targetMesh->setName("MyMesh2D");
74 targetMesh->setDescription("build2DMesh");
75 targetMesh->allocateCells(5);
76 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
77 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
78 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
79 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
80 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
81 targetMesh->finishInsertingCells();
82 ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New();
84 std::copy(targetCoords,targetCoords+18,myCoords->getPointer());
85 targetMesh->setCoords(myCoords);
90 ParaMEDMEM::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::build3DMesh()
92 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. ,
93 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. ,
94 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. };
95 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,
96 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};
97 ParaMEDMEM::MEDCouplingUMesh *targetMesh=ParaMEDMEM::MEDCouplingUMesh::New();
98 targetMesh->setMeshDimension(3);
99 targetMesh->setName("MyMesh3D");
100 targetMesh->setDescription("build3DMesh");
101 targetMesh->allocateCells(12);
103 targetMesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,targetConn+8*i);
104 targetMesh->finishInsertingCells();
105 ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New();
106 myCoords->alloc(27,3);
107 std::copy(targetCoords,targetCoords+81,myCoords->getPointer());
108 targetMesh->setCoords(myCoords);
109 myCoords->setName("check in case");
114 ParaMEDMEM::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::build3DSurfMesh()
116 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};
117 int targetConn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
118 ParaMEDMEM::MEDCouplingUMesh *targetMesh=ParaMEDMEM::MEDCouplingUMesh::New();
119 targetMesh->setMeshDimension(2);
120 targetMesh->setName("MyMesh3DSurf");
121 targetMesh->setDescription("build3DSurfMesh");
122 targetMesh->allocateCells(5);
123 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
124 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
125 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
126 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
127 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
128 targetMesh->finishInsertingCells();
129 ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New();
130 myCoords->alloc(9,3);
131 std::copy(targetCoords,targetCoords+27,myCoords->getPointer());
132 targetMesh->setCoords(myCoords);
133 myCoords->setInfoOnComponent(0,"X [m]");
134 myCoords->setInfoOnComponent(1,"X [dm]");
135 myCoords->setInfoOnComponent(2,"X [m]");
140 ParaMEDMEM::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::build0DMesh()
142 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};
143 const int targetConn[]={0,1,2,3,4,5,7,6};
144 ParaMEDMEM::MEDCouplingUMesh *targetMesh=ParaMEDMEM::MEDCouplingUMesh::New();
145 targetMesh->setMeshDimension(0);
146 targetMesh->allocateCells(8);
147 targetMesh->setName("Wonderfull 0D mesh");
148 targetMesh->setDescription("build0DMesh");
149 targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn);
150 targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+1);
151 targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+2);
152 targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+3);
153 targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+4);
154 targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+5);
155 targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+6);
156 targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+7);
157 targetMesh->finishInsertingCells();
158 ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New();
159 myCoords->alloc(9,3);
160 std::copy(targetCoords,targetCoords+27,myCoords->getPointer());
161 targetMesh->setCoords(myCoords);
162 myCoords->setInfoOnComponent(0,"X [m]");
163 myCoords->setInfoOnComponent(1,"YY [Pm]");
164 myCoords->setInfoOnComponent(2,"ZZZ [m]");
167 targetMesh->checkCoherency();
171 ParaMEDMEM::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::buildM1DMesh()
173 ParaMEDMEM::MEDCouplingUMesh *meshM1D=ParaMEDMEM::MEDCouplingUMesh::New("wonderfull -1 D mesh",-1);
174 meshM1D->setDescription("buildM1DMesh");
175 meshM1D->checkCoherency();
179 ParaMEDMEM::MEDCouplingExtrudedMesh *MEDCouplingCorbaServBasicsTest::buildExtrudedMesh(ParaMEDMEM::MEDCouplingUMesh *&m2D)
182 m2D->changeSpaceDimension(3);
183 ParaMEDMEM::MEDCouplingUMesh *m1D=build1DMesh();
184 ParaMEDMEM::MEDCouplingUMesh *retu=m2D->buildExtrudedMesh(m1D,0);
186 ParaMEDMEM::MEDCouplingExtrudedMesh *ret=ParaMEDMEM::MEDCouplingExtrudedMesh::New(retu,m2D,2);
187 ret->setName("ExtrudedTestForCorbaTest");
188 ret->setDescription("buildExtrudedMesh");
193 ParaMEDMEM::MEDCouplingCMesh *MEDCouplingCorbaServBasicsTest::buildCMesh()
195 ParaMEDMEM::MEDCouplingCMesh *targetMesh=ParaMEDMEM::MEDCouplingCMesh::New();
196 targetMesh->setTime(2.3,4,5);
197 targetMesh->setTimeUnit("us");
198 targetMesh->setName("Example of CMesh");
199 targetMesh->setDescription("buildCMesh");
200 ParaMEDMEM::DataArrayDouble *a1=ParaMEDMEM::DataArrayDouble::New();
202 a1->setInfoOnComponent(0,"SmthX");
203 const double a1Data[5]={3.,4.,5.,6.,7.};
204 std::copy(a1Data,a1Data+5,a1->getPointer());
205 ParaMEDMEM::DataArrayDouble *a2=ParaMEDMEM::DataArrayDouble::New();
207 a2->setInfoOnComponent(0,"SmthZ");
208 const double a2Data[6]={2.78,3.,4.,5.,6.,7.};
209 std::copy(a2Data,a2Data+6,a2->getPointer());
211 targetMesh->setCoordsAt(0,a1);
212 targetMesh->setCoordsAt(1,a2);
217 targetMesh->checkCoherency();
222 ParaMEDMEM::MEDCouplingCurveLinearMesh *MEDCouplingCorbaServBasicsTest::buildCLMesh()
224 ParaMEDMEM::MEDCouplingCurveLinearMesh *targetMesh=ParaMEDMEM::MEDCouplingCurveLinearMesh::New();
225 targetMesh->setTime(2.3,4,5);
226 targetMesh->setTimeUnit("us");
227 targetMesh->setName("Example of Cuve linear mesh");
228 targetMesh->setDescription("buildCLMesh");
229 ParaMEDMEM::DataArrayDouble *a1=ParaMEDMEM::DataArrayDouble::New();
233 targetMesh->setCoords(a1);
235 int structure[2]={4,5};
236 targetMesh->setNodeGridStructure(structure,structure+2);
238 targetMesh->checkCoherency();
243 ParaMEDMEM::MEDCoupling1SGTUMesh *MEDCouplingCorbaServBasicsTest::build1SGTUMesh()
245 ParaMEDMEM::MEDCoupling1SGTUMesh *targetMesh=ParaMEDMEM::MEDCoupling1SGTUMesh::New("Mesh1SGT",INTERP_KERNEL::NORM_QUAD4);
246 targetMesh->setTime(2.3,44,-55);
247 targetMesh->setTimeUnit("us");
248 targetMesh->setDescription("My Description of 1SGTU");
249 ParaMEDMEM::DataArrayDouble *a1=ParaMEDMEM::DataArrayDouble::New(); a1->alloc(10,3); a1->setInfoOnComponent(0,"X1 [m]"); a1->setInfoOnComponent(1,"YY2 [km]"); a1->setInfoOnComponent(2,"ZZZ3 [km]");
250 const double coords[30]={1.,1.,0.,2.,1.,0.,3.,1.,0.,1.,0.,0.,2.,0.,0.,0.,0.,0.,0.,1.,0.,3.,0.,0.,4.,0.,0.,4.,1.,0.};
251 const int conn[16]={6,0,3,5,3,0,1,4,1,2,7,4,8,7,2,9};
252 std::copy(coords,coords+30,a1->getPointer()); targetMesh->setCoords(a1); a1->decrRef();
253 ParaMEDMEM::DataArrayInt *a2(ParaMEDMEM::DataArrayInt::New()); a2->alloc(4*4,1);
254 std::copy(conn,conn+16,a2->getPointer());
255 targetMesh->setNodalConnectivity(a2); a2->decrRef();
257 targetMesh->checkCoherency();
262 ParaMEDMEM::MEDCoupling1DGTUMesh *MEDCouplingCorbaServBasicsTest::build1DGTUMesh()
264 ParaMEDMEM::MEDCoupling1DGTUMesh *targetMesh=ParaMEDMEM::MEDCoupling1DGTUMesh::New("Mesh1DGT",INTERP_KERNEL::NORM_POLYGON);
265 targetMesh->setTime(2.3,55,-66);
266 targetMesh->setTimeUnit("us");
267 targetMesh->setDescription("My Description of 1DGTU");
268 ParaMEDMEM::DataArrayDouble *a1=ParaMEDMEM::DataArrayDouble::New(); a1->alloc(10,3); a1->setInfoOnComponent(0,"X1 [m]"); a1->setInfoOnComponent(1,"YY2 [km]"); a1->setInfoOnComponent(2,"ZZZ3 [km]");
269 const double coords[30]={1.,1.,0.,2.,1.,0.,3.,1.,0.,1.,0.,0.,2.,0.,0.,0.,0.,0.,0.,1.,0.,3.,0.,0.,4.,0.,0.,4.,1.,0.};
270 const int conn[15]={6,0,3,5,3,0,1,4,1,2,7,4,8,7,2};
271 const int conni[5]={0,4,8,12,15};
272 std::copy(coords,coords+30,a1->getPointer()); targetMesh->setCoords(a1); a1->decrRef();
273 ParaMEDMEM::DataArrayInt *a2(ParaMEDMEM::DataArrayInt::New()); a2->alloc(15,1);
274 std::copy(conn,conn+15,a2->getPointer());
275 ParaMEDMEM::DataArrayInt *a3(ParaMEDMEM::DataArrayInt::New()); a3->alloc(5,1);
276 std::copy(conni,conni+5,a3->getPointer());
277 targetMesh->setNodalConnectivity(a2,a3); a2->decrRef(); a3->decrRef();
279 targetMesh->checkCoherency();
284 ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldScalarOn2DNT()
286 ParaMEDMEM::MEDCouplingUMesh *mesh=build2DMesh();
287 ParaMEDMEM::MEDCouplingFieldDouble *fieldOnCells=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME);
288 fieldOnCells->setTimeUnit("ms");
289 fieldOnCells->setName("toto");
290 fieldOnCells->setMesh(mesh);
291 ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
292 array->alloc(mesh->getNumberOfCells(),6);
293 fieldOnCells->setArray(array);
294 double *tmp=array->getPointer();
296 std::fill(tmp,tmp+mesh->getNumberOfCells()*6,7.);
298 fieldOnCells->checkCoherency();
302 ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldNodeScalarOn2DNT()
304 ParaMEDMEM::MEDCouplingUMesh *mesh=build2DMesh();
305 ParaMEDMEM::MEDCouplingFieldDouble *fieldOnNodes=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_NODES,ParaMEDMEM::NO_TIME);
306 fieldOnNodes->setName("toto2");
307 fieldOnNodes->setTimeUnit("s");
308 fieldOnNodes->setDescription("my wonderful field toto2");
309 fieldOnNodes->setMesh(mesh);
310 ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
311 array->alloc(mesh->getNumberOfNodes(),5);
312 fieldOnNodes->setArray(array);
313 double *tmp=array->getPointer();
315 std::fill(tmp,tmp+mesh->getNumberOfNodes()*5,7.1234);
317 fieldOnNodes->checkCoherency();
321 ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldScalarOn3DNT()
323 ParaMEDMEM::MEDCouplingUMesh *mesh=build3DMesh();
324 ParaMEDMEM::MEDCouplingFieldDouble *fieldOnCells=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME);
325 fieldOnCells->setNature(ParaMEDMEM::ConservativeVolumic);
326 fieldOnCells->setName("toto");
327 fieldOnCells->setDescription("my wonderful 3D field toto2");
328 fieldOnCells->setMesh(mesh);
329 ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
330 array->alloc(mesh->getNumberOfCells(),6);
331 fieldOnCells->setArray(array);
332 double *tmp=array->getPointer();
334 std::fill(tmp,tmp+mesh->getNumberOfCells()*6,7.);
336 fieldOnCells->checkCoherency();
340 ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldScalarOn3DSurfWT()
342 ParaMEDMEM::MEDCouplingUMesh *mesh=build3DSurfMesh();
343 ParaMEDMEM::MEDCouplingFieldDouble *fieldOnCells=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
344 fieldOnCells->setName("toto25");
345 fieldOnCells->setDescription("my wonderful 3D surf field toto25");
346 fieldOnCells->setTimeUnit("us");
347 fieldOnCells->setMesh(mesh);
348 ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
349 array->alloc(mesh->getNumberOfCells(),3);
350 array->setInfoOnComponent(0,"aaa"); array->setInfoOnComponent(1,"bbbb"); array->setInfoOnComponent(2,"ccccc");
351 fieldOnCells->setArray(array);
352 double *tmp=array->getPointer();
354 std::fill(tmp,tmp+mesh->getNumberOfCells()*3,7.);
356 fieldOnCells->setTime(6.7,1,4);
357 fieldOnCells->checkCoherency();
361 ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldScalarOn3DSurfCOTI()
363 ParaMEDMEM::MEDCouplingUMesh *mesh=build3DSurfMesh();
364 ParaMEDMEM::MEDCouplingFieldDouble *fieldOnCells=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::CONST_ON_TIME_INTERVAL);
365 fieldOnCells->setName("toto26");
366 fieldOnCells->setDescription("my wonderful 3D surf field toto26");
367 fieldOnCells->setTimeUnit("us");
368 fieldOnCells->setMesh(mesh);
369 ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
370 array->alloc(mesh->getNumberOfCells(),3);
371 fieldOnCells->setArray(array);
372 double *tmp=array->getPointer();
374 std::fill(tmp,tmp+mesh->getNumberOfCells()*3,7.);
376 fieldOnCells->setStartTime(6.7,1,4);
377 fieldOnCells->setEndTime(7.2,2,8);
378 fieldOnCells->checkCoherency();
382 ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldScalarOn2DLT()
384 ParaMEDMEM::MEDCouplingUMesh *mesh=build2DMesh();
385 ParaMEDMEM::MEDCouplingFieldDouble *fieldOnCells=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::LINEAR_TIME);
386 fieldOnCells->setName("toto27");
387 fieldOnCells->setDescription("my wonderful 2D field toto27");
388 fieldOnCells->setTimeUnit("ms");
389 fieldOnCells->setMesh(mesh);
390 ParaMEDMEM::DataArrayDouble *array1=ParaMEDMEM::DataArrayDouble::New();
391 array1->alloc(mesh->getNumberOfCells(),4);
392 fieldOnCells->setArray(array1);
393 double *tmp=array1->getPointer();
395 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};
396 std::copy(arr1,arr1+20,tmp);
397 ParaMEDMEM::DataArrayDouble *array2=ParaMEDMEM::DataArrayDouble::New();
398 array2->alloc(mesh->getNumberOfCells(),4);
399 fieldOnCells->setEndArray(array2);
400 tmp=array2->getPointer();
403 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};
404 std::copy(arr2,arr2+20,tmp);
405 fieldOnCells->setStartTime(6.7,25,26);
406 fieldOnCells->setEndTime(17.2,125,126);
407 fieldOnCells->checkCoherency();
411 ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldGaussPt2DWT()
413 const double _a=0.446948490915965;
414 const double _b=0.091576213509771;
415 const double _p1=0.11169079483905;
416 const double _p2=0.0549758718227661;
417 const double refCoo1[6]={ 0.,0., 1.,0., 0.,1. };
418 const double gsCoo1[12]={ 2*_b-1, 1-4*_b, 2*_b-1, 2.07*_b-1, 1-4*_b,
419 2*_b-1, 1-4*_a, 2*_a-1, 2*_a-1, 1-4*_a, 2*_a-1, 2*_a-1 };
420 const double wg1[6]={ 4*_p2, 4*_p2, 4*_p2, 4*_p1, 4*_p1, 4*_p1 };
421 std::vector<double> _refCoo1(refCoo1,refCoo1+6);
422 std::vector<double> _gsCoo1(gsCoo1,gsCoo1+12);
423 std::vector<double> _wg1(wg1,wg1+6);
424 ParaMEDMEM::MEDCouplingUMesh *m=build2DMesh();
425 ParaMEDMEM::MEDCouplingFieldDouble *f=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_GAUSS_PT,ParaMEDMEM::ONE_TIME);
429 f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI3,_refCoo1,_gsCoo1,_wg1);
430 const double refCoo2[8]={ 0.,0., 1.,0., 1.,1., 0.,1. };
431 std::vector<double> _refCoo2(refCoo2,refCoo2+8);
432 _gsCoo1.resize(4); _wg1.resize(2);
433 f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_QUAD4,_refCoo2,_gsCoo1,_wg1);
434 ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
436 array->setInfoOnComponent(0,"Power [MW]");
437 array->setInfoOnComponent(1,"Density [kg/m^3]");
438 double *ptr=array->getPointer();
439 for(int i=0;i<18*2;i++)
440 ptr[i]=(double)(i+1);
442 f->setName("MyFirstFieldOnGaussPoint");
443 f->setTimeUnit("ms");
444 f->setDescription("mmmmmmmmmmmm");
450 ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldGaussPtNE2DWT()
452 ParaMEDMEM::MEDCouplingUMesh *m=build2DMesh();
453 ParaMEDMEM::MEDCouplingFieldDouble *f=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_GAUSS_NE,ParaMEDMEM::ONE_TIME);
454 f->setTime(6.8,11,8);
456 f->setTimeUnit("ms");
457 f->setName("MyFirstFieldOnNE");
458 f->setDescription("MyDescriptionNE");
459 ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
461 array->setInfoOnComponent(0,"Power [MW]");
462 array->setInfoOnComponent(1,"Density [kg/m^3]");
463 double *ptr=array->getPointer();
464 for(int i=0;i<18*2;i++)
465 ptr[i]=(double)(i+7);
474 ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldVectorOnExtrudedWT()
476 ParaMEDMEM::MEDCouplingUMesh *m2D=0;
477 ParaMEDMEM::MEDCouplingExtrudedMesh *ext=buildExtrudedMesh(m2D);
479 ParaMEDMEM::MEDCouplingFieldDouble *f=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
480 f->setTime(6.8,11,8);
482 f->setName("MyFieldOnExtruM");
483 f->setDescription("desc of MyFiOnExtruM");
484 ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
485 int nbOfCells=ext->getNumberOfCells();
486 array->alloc(nbOfCells,2);
487 array->setInfoOnComponent(0,"Power [MW]");
488 array->setInfoOnComponent(1,"Density [kg/m^3]");
489 double *ptr=array->getPointer();
490 for(int i=0;i<nbOfCells*2;i++)
491 ptr[i]=(double)(i/2+7)+(double)((i%2)*1000);
502 ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldVectorOnCMeshWT()
504 ParaMEDMEM::MEDCouplingCMesh *m=buildCMesh();
505 ParaMEDMEM::MEDCouplingFieldDouble *f=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
506 f->setTime(6.8,11,8);
509 f->setName("MyFieldOnCMesh");
510 f->setDescription("desc of MyFiOnCMesh");
511 ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
512 int nbOfCells=m->getNumberOfCells();
513 array->alloc(nbOfCells,2);
514 array->setInfoOnComponent(0,"Power [GW]");
515 array->setInfoOnComponent(1,"Density [kg/m^3]");
516 double *ptr=array->getPointer();
517 for(int i=0;i<nbOfCells*2;i++)
518 ptr[i]=(double)(i/2+7)+(double)((i%2)*1000);
527 ParaMEDMEM::MEDCouplingFieldTemplate *MEDCouplingCorbaServBasicsTest::buildFieldTemplateCellOn2D()
529 ParaMEDMEM::MEDCouplingFieldDouble *f1=buildFieldScalarOn2DNT();
530 ParaMEDMEM::MEDCouplingFieldTemplate *f2=ParaMEDMEM::MEDCouplingFieldTemplate::New(*f1);
531 f2->setNature(ParaMEDMEM::NoNature);
536 ParaMEDMEM::MEDCouplingFieldTemplate *MEDCouplingCorbaServBasicsTest::buildFieldTemplateNodeOn2D()
538 ParaMEDMEM::MEDCouplingFieldDouble *f1=buildFieldNodeScalarOn2DNT();
539 ParaMEDMEM::MEDCouplingFieldTemplate *f2=ParaMEDMEM::MEDCouplingFieldTemplate::New(*f1);
540 f2->setNature(ParaMEDMEM::ConservativeVolumic);
545 ParaMEDMEM::MEDCouplingFieldTemplate *MEDCouplingCorbaServBasicsTest::buildFieldTemplateGaussPtOn2D()
547 ParaMEDMEM::MEDCouplingFieldDouble *f1=buildFieldGaussPt2DWT();
548 ParaMEDMEM::MEDCouplingFieldTemplate *f2=ParaMEDMEM::MEDCouplingFieldTemplate::New(*f1);
549 f2->setNature(ParaMEDMEM::Integral);
554 ParaMEDMEM::MEDCouplingFieldTemplate *MEDCouplingCorbaServBasicsTest::buildFieldTemplateGaussNEOn2D()
556 ParaMEDMEM::MEDCouplingFieldDouble *f1=buildFieldGaussPtNE2DWT();
557 ParaMEDMEM::MEDCouplingFieldTemplate *f2=ParaMEDMEM::MEDCouplingFieldTemplate::New(*f1);
558 f2->setNature(ParaMEDMEM::IntegralGlobConstraint);
563 ParaMEDMEM::MEDCouplingMultiFields *MEDCouplingCorbaServBasicsTest::buildMultiFields1()
565 ParaMEDMEM::MEDCouplingUMesh *m1=build2DMesh();
567 ParaMEDMEM::MEDCouplingUMesh *m2=build2DMesh();
569 const double vals0[]={-0.7,-1.,-2.,-3.,-4.};
570 const double vals1[]={0.,1.,2.,3.,4.,0.1,0.2,0.3,0.4};
571 const double vals1_1[]={170.,171.,172.,173.,174.,170.1,170.2,170.3,170.4};
572 const double vals2[]={5.,6.,7.,8.,9.};
573 const double vals4[]={15.,16.,17.,18.,19.};
575 ParaMEDMEM::DataArrayDouble *d0=ParaMEDMEM::DataArrayDouble::New(); d0->alloc(5,1); std::copy(vals0,vals0+5,d0->getPointer());
576 ParaMEDMEM::DataArrayDouble *d1=ParaMEDMEM::DataArrayDouble::New(); d1->alloc(9,1); std::copy(vals1,vals1+9,d1->getPointer());
577 ParaMEDMEM::DataArrayDouble *d1_1=ParaMEDMEM::DataArrayDouble::New(); d1_1->alloc(9,1); std::copy(vals1_1,vals1_1+9,d1_1->getPointer());
578 ParaMEDMEM::DataArrayDouble *d2=ParaMEDMEM::DataArrayDouble::New(); d2->alloc(5,1); std::copy(vals2,vals2+5,d2->getPointer());
579 ParaMEDMEM::DataArrayDouble *d4=ParaMEDMEM::DataArrayDouble::New(); d4->alloc(5,1); std::copy(vals4,vals4+5,d4->getPointer());
581 d0->setName("d0"); d1->setName("d1"); d1_1->setName("d1_1"); d2->setName("d2"); d4->setName("d4");
582 d0->setInfoOnComponent(0,"c1");
583 d1->setInfoOnComponent(0,"c6");
584 d1_1->setInfoOnComponent(0,"c9");
585 d2->setInfoOnComponent(0,"c5");
586 d4->setInfoOnComponent(0,"c7");
588 ParaMEDMEM::MEDCouplingFieldDouble *f0=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
591 f0->setTime(0.2,5,6);
593 ParaMEDMEM::MEDCouplingFieldDouble *f1=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_NODES,ParaMEDMEM::LINEAR_TIME);
595 std::vector<ParaMEDMEM::DataArrayDouble *> d1s(2); d1s[0]=d1; d1s[1]=d1_1;
597 f1->setStartTime(0.7,7,8);
598 f1->setEndTime(1.2,9,10);
600 ParaMEDMEM::MEDCouplingFieldDouble *f2=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::CONST_ON_TIME_INTERVAL);
603 f2->setTime(1.2,11,12);
604 f2->setEndTime(1.5,13,14);
606 ParaMEDMEM::MEDCouplingFieldDouble *f3=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
609 f3->setTime(1.7,15,16);
611 ParaMEDMEM::MEDCouplingFieldDouble *f4=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME);
616 std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> fs(5);
617 fs[0]=f0; fs[1]=f1; fs[2]=f2; fs[3]=f3; fs[4]=f4;
618 ParaMEDMEM::MEDCouplingMultiFields *ret=ParaMEDMEM::MEDCouplingMultiFields::New(fs);
636 ParaMEDMEM::DataArrayDouble *MEDCouplingCorbaServBasicsTest::buildArrayDouble1()
638 ParaMEDMEM::DataArrayDouble *ret=ParaMEDMEM::DataArrayDouble::New();
640 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};
641 std::copy(vals,vals+12,ret->getPointer());
642 ret->setName("toto");
643 ret->setInfoOnComponent(0,"sss");
644 ret->setInfoOnComponent(1,"ppp");
645 ret->setInfoOnComponent(2,"ttt");
649 ParaMEDMEM::DataArrayDouble *MEDCouplingCorbaServBasicsTest::buildArrayDouble2()
651 ParaMEDMEM::DataArrayDouble *ret=ParaMEDMEM::DataArrayDouble::New();
652 ret->setName("titi");
656 ParaMEDMEM::DataArrayDouble *MEDCouplingCorbaServBasicsTest::buildArrayDouble3()
658 ParaMEDMEM::DataArrayDouble *ret=ParaMEDMEM::DataArrayDouble::New();
659 ret->setName("titi");
661 ret->setInfoOnComponent(0,"sss");
662 ret->setInfoOnComponent(1,"ppp");
663 ret->setInfoOnComponent(2,"ttt");
667 ParaMEDMEM::DataArrayInt *MEDCouplingCorbaServBasicsTest::buildArrayInt1()
669 ParaMEDMEM::DataArrayInt *ret=ParaMEDMEM::DataArrayInt::New();
671 const int vals[12]={2,3,5,9,47,20,24,278,2,3,2,9};
672 std::copy(vals,vals+12,ret->getPointer());
673 ret->setName("toto");
674 ret->setInfoOnComponent(0,"sss");
675 ret->setInfoOnComponent(1,"ppp");
676 ret->setInfoOnComponent(2,"ttt");
680 ParaMEDMEM::DataArrayInt *MEDCouplingCorbaServBasicsTest::buildArrayInt2()
682 ParaMEDMEM::DataArrayInt *ret=ParaMEDMEM::DataArrayInt::New();
683 ret->setName("titi");
687 ParaMEDMEM::DataArrayInt *MEDCouplingCorbaServBasicsTest::buildArrayInt3()
689 ParaMEDMEM::DataArrayInt *ret=ParaMEDMEM::DataArrayInt::New();
690 ret->setName("titi");
692 ret->setInfoOnComponent(0,"sss");
693 ret->setInfoOnComponent(1,"ppp");
694 ret->setInfoOnComponent(2,"ttt");
698 ParaMEDMEM::MEDCouplingFieldOverTime *MEDCouplingCorbaServBasicsTest::buildMultiFields2()
700 ParaMEDMEM::MEDCouplingUMesh *m1=build2DMesh();
702 ParaMEDMEM::MEDCouplingUMesh *m2=build2DMesh();
704 const double vals0[]={-0.7,-1.,-2.,-3.,-4.};
705 const double vals1[]={0.,1.,2.,3.,4.};
706 const double vals1_1[]={170.,171.,172.,173.,174.};
707 const double vals2[]={5.,6.,7.,8.,9.};
708 const double vals4[]={15.,16.,17.,18.,19.};
710 ParaMEDMEM::DataArrayDouble *d0=ParaMEDMEM::DataArrayDouble::New(); d0->alloc(5,1); std::copy(vals0,vals0+5,d0->getPointer());
711 ParaMEDMEM::DataArrayDouble *d1=ParaMEDMEM::DataArrayDouble::New(); d1->alloc(5,1); std::copy(vals1,vals1+5,d1->getPointer());
712 ParaMEDMEM::DataArrayDouble *d1_1=ParaMEDMEM::DataArrayDouble::New(); d1_1->alloc(5,1); std::copy(vals1_1,vals1_1+5,d1_1->getPointer());
713 ParaMEDMEM::DataArrayDouble *d2=ParaMEDMEM::DataArrayDouble::New(); d2->alloc(5,1); std::copy(vals2,vals2+5,d2->getPointer());
714 ParaMEDMEM::DataArrayDouble *d4=ParaMEDMEM::DataArrayDouble::New(); d4->alloc(5,1); std::copy(vals4,vals4+5,d4->getPointer());
716 d0->setName("d0"); d1->setName("d1"); d1_1->setName("d1_1"); d2->setName("d2"); d4->setName("d4");
717 d0->setInfoOnComponent(0,"c1");
718 d1->setInfoOnComponent(0,"c6");
719 d1_1->setInfoOnComponent(0,"c9");
720 d2->setInfoOnComponent(0,"c5");
721 d4->setInfoOnComponent(0,"c7");
723 ParaMEDMEM::MEDCouplingFieldDouble *f0=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
726 f0->setTime(0.2,5,6);
728 ParaMEDMEM::MEDCouplingFieldDouble *f1=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::LINEAR_TIME);
730 std::vector<ParaMEDMEM::DataArrayDouble *> d1s(2); d1s[0]=d1; d1s[1]=d1_1;
732 f1->setStartTime(0.7,7,8);
733 f1->setEndTime(1.2,9,10);
735 ParaMEDMEM::MEDCouplingFieldDouble *f2=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::CONST_ON_TIME_INTERVAL);
738 f2->setTime(1.2,11,12);
739 f2->setEndTime(1.5,13,14);
741 ParaMEDMEM::MEDCouplingFieldDouble *f3=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
744 f3->setTime(1.7,15,16);
746 ParaMEDMEM::MEDCouplingFieldDouble *f4=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
750 f4->setTime(2.7,25,26);
752 std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> fs(5);
753 fs[0]=f0; fs[1]=f1; fs[2]=f2; fs[3]=f3; fs[4]=f4;
754 ParaMEDMEM::MEDCouplingFieldOverTime *ret=ParaMEDMEM::MEDCouplingFieldOverTime::New(fs);
755 ret->checkCoherency();
773 std::string MEDCouplingCorbaServBasicsTest::buildFileNameForIOR()
777 tmpdir = getenv("TMP");
781 std::string username;
782 if ( getenv("USERNAME") )
783 username = std::string(getenv("USERNAME"))+"_";
784 else if ( getenv("USER") )
785 username = std::string(getenv("USER"))+"_";
787 std::string ret = tmpdir+"/"+username+"entryPointMEDCouplingCorba.ior";