1 // Copyright (C) 2007-2015 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, or (at your option) any later version.
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 "MEDCouplingIMesh.hxx"
32 #include "MEDCouplingCurveLinearMesh.hxx"
39 MEDCoupling::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::build1DMesh()
41 double coords[4]={ 0.0, 0.3, 0.75, 1.0 };
42 int conn[2*3]={ 0,1, 1,2, 2,3 };
43 MEDCoupling::MEDCouplingUMesh *mesh=MEDCoupling::MEDCouplingUMesh::New("1DMeshForCorba",1);
44 mesh->setDescription("build1DMesh");
45 mesh->allocateCells(3);
46 mesh->setTime(5.6,7,8);
47 mesh->setTimeUnit("ms");
48 mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
49 mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2);
50 mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+4);
51 mesh->finishInsertingCells();
52 MEDCoupling::DataArrayDouble *myCoords=MEDCoupling::DataArrayDouble::New();
54 std::copy(coords,coords+4,myCoords->getPointer());
55 mesh->setCoords(myCoords);
57 mesh->changeSpaceDimension(3);
58 myCoords=mesh->getCoords();
59 myCoords->setInfoOnComponent(0,"X1D [m]");
60 myCoords->setInfoOnComponent(1,"Y1D [dm]");
61 myCoords->setInfoOnComponent(2,"Z1D [pm]");
62 double center[3]={0.,0.,0.};
63 double vector[3]={0,1,0};
64 mesh->rotate(center,vector,-M_PI/2.);
68 MEDCoupling::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::build2DMesh()
70 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 };
71 int targetConn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
72 MEDCoupling::MEDCouplingUMesh *targetMesh=MEDCoupling::MEDCouplingUMesh::New();
73 targetMesh->setMeshDimension(2);
74 targetMesh->setName("MyMesh2D");
75 targetMesh->setDescription("build2DMesh");
76 targetMesh->allocateCells(5);
77 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
78 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
79 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
80 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
81 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
82 targetMesh->finishInsertingCells();
83 MEDCoupling::DataArrayDouble *myCoords=MEDCoupling::DataArrayDouble::New();
85 std::copy(targetCoords,targetCoords+18,myCoords->getPointer());
86 targetMesh->setCoords(myCoords);
91 MEDCoupling::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::build3DMesh()
93 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. ,
94 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. ,
95 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. };
96 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,
97 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};
98 MEDCoupling::MEDCouplingUMesh *targetMesh=MEDCoupling::MEDCouplingUMesh::New();
99 targetMesh->setMeshDimension(3);
100 targetMesh->setName("MyMesh3D");
101 targetMesh->setDescription("build3DMesh");
102 targetMesh->allocateCells(12);
104 targetMesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,targetConn+8*i);
105 targetMesh->finishInsertingCells();
106 MEDCoupling::DataArrayDouble *myCoords=MEDCoupling::DataArrayDouble::New();
107 myCoords->alloc(27,3);
108 std::copy(targetCoords,targetCoords+81,myCoords->getPointer());
109 targetMesh->setCoords(myCoords);
110 myCoords->setName("check in case");
115 MEDCoupling::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::build3DSurfMesh()
117 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};
118 int targetConn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
119 MEDCoupling::MEDCouplingUMesh *targetMesh=MEDCoupling::MEDCouplingUMesh::New();
120 targetMesh->setMeshDimension(2);
121 targetMesh->setName("MyMesh3DSurf");
122 targetMesh->setDescription("build3DSurfMesh");
123 targetMesh->allocateCells(5);
124 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
125 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
126 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
127 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
128 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
129 targetMesh->finishInsertingCells();
130 MEDCoupling::DataArrayDouble *myCoords=MEDCoupling::DataArrayDouble::New();
131 myCoords->alloc(9,3);
132 std::copy(targetCoords,targetCoords+27,myCoords->getPointer());
133 targetMesh->setCoords(myCoords);
134 myCoords->setInfoOnComponent(0,"X [m]");
135 myCoords->setInfoOnComponent(1,"X [dm]");
136 myCoords->setInfoOnComponent(2,"X [m]");
141 MEDCoupling::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::build0DMesh()
143 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};
144 const int targetConn[]={0,1,2,3,4,5,7,6};
145 MEDCoupling::MEDCouplingUMesh *targetMesh=MEDCoupling::MEDCouplingUMesh::New();
146 targetMesh->setMeshDimension(0);
147 targetMesh->allocateCells(8);
148 targetMesh->setName("Wonderfull 0D mesh");
149 targetMesh->setDescription("build0DMesh");
150 targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn);
151 targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+1);
152 targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+2);
153 targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+3);
154 targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+4);
155 targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+5);
156 targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+6);
157 targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+7);
158 targetMesh->finishInsertingCells();
159 MEDCoupling::DataArrayDouble *myCoords=MEDCoupling::DataArrayDouble::New();
160 myCoords->alloc(9,3);
161 std::copy(targetCoords,targetCoords+27,myCoords->getPointer());
162 targetMesh->setCoords(myCoords);
163 myCoords->setInfoOnComponent(0,"X [m]");
164 myCoords->setInfoOnComponent(1,"YY [Pm]");
165 myCoords->setInfoOnComponent(2,"ZZZ [m]");
168 targetMesh->checkCoherency();
172 MEDCoupling::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::buildM1DMesh()
174 MEDCoupling::MEDCouplingUMesh *meshM1D=MEDCoupling::MEDCouplingUMesh::New("wonderfull -1 D mesh",-1);
175 meshM1D->setDescription("buildM1DMesh");
176 meshM1D->checkCoherency();
180 MEDCoupling::MEDCouplingExtrudedMesh *MEDCouplingCorbaServBasicsTest::buildExtrudedMesh(MEDCoupling::MEDCouplingUMesh *&m2D)
183 m2D->changeSpaceDimension(3);
184 MEDCoupling::MEDCouplingUMesh *m1D=build1DMesh();
185 MEDCoupling::MEDCouplingUMesh *retu=m2D->buildExtrudedMesh(m1D,0);
187 MEDCoupling::MEDCouplingExtrudedMesh *ret=MEDCoupling::MEDCouplingExtrudedMesh::New(retu,m2D,2);
188 ret->setName("ExtrudedTestForCorbaTest");
189 ret->setDescription("buildExtrudedMesh");
194 MEDCoupling::MEDCouplingCMesh *MEDCouplingCorbaServBasicsTest::buildCMesh()
196 MEDCoupling::MEDCouplingCMesh *targetMesh=MEDCoupling::MEDCouplingCMesh::New();
197 targetMesh->setTime(2.3,4,5);
198 targetMesh->setTimeUnit("us");
199 targetMesh->setName("Example of CMesh");
200 targetMesh->setDescription("buildCMesh");
201 MEDCoupling::DataArrayDouble *a1=MEDCoupling::DataArrayDouble::New();
203 a1->setInfoOnComponent(0,"SmthX");
204 const double a1Data[5]={3.,4.,5.,6.,7.};
205 std::copy(a1Data,a1Data+5,a1->getPointer());
206 MEDCoupling::DataArrayDouble *a2=MEDCoupling::DataArrayDouble::New();
208 a2->setInfoOnComponent(0,"SmthZ");
209 const double a2Data[6]={2.78,3.,4.,5.,6.,7.};
210 std::copy(a2Data,a2Data+6,a2->getPointer());
212 targetMesh->setCoordsAt(0,a1);
213 targetMesh->setCoordsAt(1,a2);
218 targetMesh->checkCoherency();
224 MEDCoupling::MEDCouplingIMesh *MEDCouplingCorbaServBasicsTest::buildIMesh()
226 MEDCoupling::MEDCouplingIMesh *targetMesh(MEDCoupling::MEDCouplingIMesh::New());
227 targetMesh->setTime(2.3,4,5);
228 targetMesh->setTimeUnit("us");
229 targetMesh->setName("Example of IMesh");
230 targetMesh->setDescription("buildIMesh");
232 double orig[3]={4.25,3.75,-6.125};
233 double inter[3]={0.5,0.375,0.75};
234 targetMesh->setSpaceDimension(3);
235 targetMesh->setNodeStruct(ns,ns+3);
236 targetMesh->setOrigin(orig,orig+3);
237 targetMesh->setDXYZ(inter,inter+3);
238 targetMesh->setAxisUnit("mm");
242 MEDCoupling::MEDCouplingCurveLinearMesh *MEDCouplingCorbaServBasicsTest::buildCLMesh()
244 MEDCoupling::MEDCouplingCurveLinearMesh *targetMesh=MEDCoupling::MEDCouplingCurveLinearMesh::New();
245 targetMesh->setTime(2.3,4,5);
246 targetMesh->setTimeUnit("us");
247 targetMesh->setName("Example of Cuve linear mesh");
248 targetMesh->setDescription("buildCLMesh");
249 MEDCoupling::DataArrayDouble *a1=MEDCoupling::DataArrayDouble::New();
253 targetMesh->setCoords(a1);
255 int structure[2]={4,5};
256 targetMesh->setNodeGridStructure(structure,structure+2);
258 targetMesh->checkCoherency();
263 MEDCoupling::MEDCoupling1SGTUMesh *MEDCouplingCorbaServBasicsTest::build1SGTUMesh()
265 MEDCoupling::MEDCoupling1SGTUMesh *targetMesh=MEDCoupling::MEDCoupling1SGTUMesh::New("Mesh1SGT",INTERP_KERNEL::NORM_QUAD4);
266 targetMesh->setTime(2.3,44,-55);
267 targetMesh->setTimeUnit("us");
268 targetMesh->setDescription("My Description of 1SGTU");
269 MEDCoupling::DataArrayDouble *a1=MEDCoupling::DataArrayDouble::New(); a1->alloc(10,3); a1->setInfoOnComponent(0,"X1 [m]"); a1->setInfoOnComponent(1,"YY2 [km]"); a1->setInfoOnComponent(2,"ZZZ3 [km]");
270 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.};
271 const int conn[16]={6,0,3,5,3,0,1,4,1,2,7,4,8,7,2,9};
272 std::copy(coords,coords+30,a1->getPointer()); targetMesh->setCoords(a1); a1->decrRef();
273 MEDCoupling::DataArrayInt *a2(MEDCoupling::DataArrayInt::New()); a2->alloc(4*4,1);
274 std::copy(conn,conn+16,a2->getPointer());
275 targetMesh->setNodalConnectivity(a2); a2->decrRef();
277 targetMesh->checkCoherency();
282 MEDCoupling::MEDCoupling1DGTUMesh *MEDCouplingCorbaServBasicsTest::build1DGTUMesh()
284 MEDCoupling::MEDCoupling1DGTUMesh *targetMesh=MEDCoupling::MEDCoupling1DGTUMesh::New("Mesh1DGT",INTERP_KERNEL::NORM_POLYGON);
285 targetMesh->setTime(2.3,55,-66);
286 targetMesh->setTimeUnit("us");
287 targetMesh->setDescription("My Description of 1DGTU");
288 MEDCoupling::DataArrayDouble *a1=MEDCoupling::DataArrayDouble::New(); a1->alloc(10,3); a1->setInfoOnComponent(0,"X1 [m]"); a1->setInfoOnComponent(1,"YY2 [km]"); a1->setInfoOnComponent(2,"ZZZ3 [km]");
289 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.};
290 const int conn[15]={6,0,3,5,3,0,1,4,1,2,7,4,8,7,2};
291 const int conni[5]={0,4,8,12,15};
292 std::copy(coords,coords+30,a1->getPointer()); targetMesh->setCoords(a1); a1->decrRef();
293 MEDCoupling::DataArrayInt *a2(MEDCoupling::DataArrayInt::New()); a2->alloc(15,1);
294 std::copy(conn,conn+15,a2->getPointer());
295 MEDCoupling::DataArrayInt *a3(MEDCoupling::DataArrayInt::New()); a3->alloc(5,1);
296 std::copy(conni,conni+5,a3->getPointer());
297 targetMesh->setNodalConnectivity(a2,a3); a2->decrRef(); a3->decrRef();
299 targetMesh->checkCoherency();
304 MEDCoupling::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldScalarOn2DNT()
306 MEDCoupling::MEDCouplingUMesh *mesh=build2DMesh();
307 MEDCoupling::MEDCouplingFieldDouble *fieldOnCells=MEDCoupling::MEDCouplingFieldDouble::New(MEDCoupling::ON_CELLS,MEDCoupling::NO_TIME);
308 fieldOnCells->setTimeUnit("ms");
309 fieldOnCells->setName("toto");
310 fieldOnCells->setMesh(mesh);
311 MEDCoupling::DataArrayDouble *array=MEDCoupling::DataArrayDouble::New();
312 array->alloc(mesh->getNumberOfCells(),6);
313 fieldOnCells->setArray(array);
314 double *tmp=array->getPointer();
316 std::fill(tmp,tmp+mesh->getNumberOfCells()*6,7.);
318 fieldOnCells->checkCoherency();
322 MEDCoupling::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldNodeScalarOn2DNT()
324 MEDCoupling::MEDCouplingUMesh *mesh=build2DMesh();
325 MEDCoupling::MEDCouplingFieldDouble *fieldOnNodes=MEDCoupling::MEDCouplingFieldDouble::New(MEDCoupling::ON_NODES,MEDCoupling::NO_TIME);
326 fieldOnNodes->setName("toto2");
327 fieldOnNodes->setTimeUnit("s");
328 fieldOnNodes->setDescription("my wonderful field toto2");
329 fieldOnNodes->setMesh(mesh);
330 MEDCoupling::DataArrayDouble *array=MEDCoupling::DataArrayDouble::New();
331 array->alloc(mesh->getNumberOfNodes(),5);
332 fieldOnNodes->setArray(array);
333 double *tmp=array->getPointer();
335 std::fill(tmp,tmp+mesh->getNumberOfNodes()*5,7.1234);
337 fieldOnNodes->checkCoherency();
341 MEDCoupling::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldScalarOn3DNT()
343 MEDCoupling::MEDCouplingUMesh *mesh=build3DMesh();
344 MEDCoupling::MEDCouplingFieldDouble *fieldOnCells=MEDCoupling::MEDCouplingFieldDouble::New(MEDCoupling::ON_CELLS,MEDCoupling::NO_TIME);
345 fieldOnCells->setNature(MEDCoupling::ConservativeVolumic);
346 fieldOnCells->setName("toto");
347 fieldOnCells->setDescription("my wonderful 3D field toto2");
348 fieldOnCells->setMesh(mesh);
349 MEDCoupling::DataArrayDouble *array=MEDCoupling::DataArrayDouble::New();
350 array->alloc(mesh->getNumberOfCells(),6);
351 fieldOnCells->setArray(array);
352 double *tmp=array->getPointer();
354 std::fill(tmp,tmp+mesh->getNumberOfCells()*6,7.);
356 fieldOnCells->checkCoherency();
360 MEDCoupling::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldScalarOn3DSurfWT()
362 MEDCoupling::MEDCouplingUMesh *mesh=build3DSurfMesh();
363 MEDCoupling::MEDCouplingFieldDouble *fieldOnCells=MEDCoupling::MEDCouplingFieldDouble::New(MEDCoupling::ON_CELLS,MEDCoupling::ONE_TIME);
364 fieldOnCells->setName("toto25");
365 fieldOnCells->setDescription("my wonderful 3D surf field toto25");
366 fieldOnCells->setTimeUnit("us");
367 fieldOnCells->setMesh(mesh);
368 MEDCoupling::DataArrayDouble *array=MEDCoupling::DataArrayDouble::New();
369 array->alloc(mesh->getNumberOfCells(),3);
370 array->setInfoOnComponent(0,"aaa"); array->setInfoOnComponent(1,"bbbb"); array->setInfoOnComponent(2,"ccccc");
371 fieldOnCells->setArray(array);
372 double *tmp=array->getPointer();
374 std::fill(tmp,tmp+mesh->getNumberOfCells()*3,7.);
376 fieldOnCells->setTime(6.7,1,4);
377 fieldOnCells->checkCoherency();
381 MEDCoupling::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldScalarOn3DSurfCOTI()
383 MEDCoupling::MEDCouplingUMesh *mesh=build3DSurfMesh();
384 MEDCoupling::MEDCouplingFieldDouble *fieldOnCells=MEDCoupling::MEDCouplingFieldDouble::New(MEDCoupling::ON_CELLS,MEDCoupling::CONST_ON_TIME_INTERVAL);
385 fieldOnCells->setName("toto26");
386 fieldOnCells->setDescription("my wonderful 3D surf field toto26");
387 fieldOnCells->setTimeUnit("us");
388 fieldOnCells->setMesh(mesh);
389 MEDCoupling::DataArrayDouble *array=MEDCoupling::DataArrayDouble::New();
390 array->alloc(mesh->getNumberOfCells(),3);
391 fieldOnCells->setArray(array);
392 double *tmp=array->getPointer();
394 std::fill(tmp,tmp+mesh->getNumberOfCells()*3,7.);
396 fieldOnCells->setStartTime(6.7,1,4);
397 fieldOnCells->setEndTime(7.2,2,8);
398 fieldOnCells->checkCoherency();
402 MEDCoupling::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldScalarOn2DLT()
404 MEDCoupling::MEDCouplingUMesh *mesh=build2DMesh();
405 MEDCoupling::MEDCouplingFieldDouble *fieldOnCells=MEDCoupling::MEDCouplingFieldDouble::New(MEDCoupling::ON_CELLS,MEDCoupling::LINEAR_TIME);
406 fieldOnCells->setName("toto27");
407 fieldOnCells->setDescription("my wonderful 2D field toto27");
408 fieldOnCells->setTimeUnit("ms");
409 fieldOnCells->setMesh(mesh);
410 MEDCoupling::DataArrayDouble *array1=MEDCoupling::DataArrayDouble::New();
411 array1->alloc(mesh->getNumberOfCells(),4);
412 fieldOnCells->setArray(array1);
413 double *tmp=array1->getPointer();
415 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};
416 std::copy(arr1,arr1+20,tmp);
417 MEDCoupling::DataArrayDouble *array2=MEDCoupling::DataArrayDouble::New();
418 array2->alloc(mesh->getNumberOfCells(),4);
419 fieldOnCells->setEndArray(array2);
420 tmp=array2->getPointer();
423 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};
424 std::copy(arr2,arr2+20,tmp);
425 fieldOnCells->setStartTime(6.7,25,26);
426 fieldOnCells->setEndTime(17.2,125,126);
427 fieldOnCells->checkCoherency();
431 MEDCoupling::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldGaussPt2DWT()
433 const double _a=0.446948490915965;
434 const double _b=0.091576213509771;
435 const double _p1=0.11169079483905;
436 const double _p2=0.0549758718227661;
437 const double refCoo1[6]={ 0.,0., 1.,0., 0.,1. };
438 const double gsCoo1[12]={ 2*_b-1, 1-4*_b, 2*_b-1, 2.07*_b-1, 1-4*_b,
439 2*_b-1, 1-4*_a, 2*_a-1, 2*_a-1, 1-4*_a, 2*_a-1, 2*_a-1 };
440 const double wg1[6]={ 4*_p2, 4*_p2, 4*_p2, 4*_p1, 4*_p1, 4*_p1 };
441 std::vector<double> _refCoo1(refCoo1,refCoo1+6);
442 std::vector<double> _gsCoo1(gsCoo1,gsCoo1+12);
443 std::vector<double> _wg1(wg1,wg1+6);
444 MEDCoupling::MEDCouplingUMesh *m=build2DMesh();
445 MEDCoupling::MEDCouplingFieldDouble *f=MEDCoupling::MEDCouplingFieldDouble::New(MEDCoupling::ON_GAUSS_PT,MEDCoupling::ONE_TIME);
449 f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI3,_refCoo1,_gsCoo1,_wg1);
450 const double refCoo2[8]={ 0.,0., 1.,0., 1.,1., 0.,1. };
451 std::vector<double> _refCoo2(refCoo2,refCoo2+8);
452 _gsCoo1.resize(4); _wg1.resize(2);
453 f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_QUAD4,_refCoo2,_gsCoo1,_wg1);
454 MEDCoupling::DataArrayDouble *array=MEDCoupling::DataArrayDouble::New();
456 array->setInfoOnComponent(0,"Power [MW]");
457 array->setInfoOnComponent(1,"Density [kg/m^3]");
458 double *ptr=array->getPointer();
459 for(int i=0;i<18*2;i++)
460 ptr[i]=(double)(i+1);
462 f->setName("MyFirstFieldOnGaussPoint");
463 f->setTimeUnit("ms");
464 f->setDescription("mmmmmmmmmmmm");
470 MEDCoupling::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldGaussPtNE2DWT()
472 MEDCoupling::MEDCouplingUMesh *m=build2DMesh();
473 MEDCoupling::MEDCouplingFieldDouble *f=MEDCoupling::MEDCouplingFieldDouble::New(MEDCoupling::ON_GAUSS_NE,MEDCoupling::ONE_TIME);
474 f->setTime(6.8,11,8);
476 f->setTimeUnit("ms");
477 f->setName("MyFirstFieldOnNE");
478 f->setDescription("MyDescriptionNE");
479 MEDCoupling::DataArrayDouble *array=MEDCoupling::DataArrayDouble::New();
481 array->setInfoOnComponent(0,"Power [MW]");
482 array->setInfoOnComponent(1,"Density [kg/m^3]");
483 double *ptr=array->getPointer();
484 for(int i=0;i<18*2;i++)
485 ptr[i]=(double)(i+7);
494 MEDCoupling::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldVectorOnExtrudedWT()
496 MEDCoupling::MEDCouplingUMesh *m2D=0;
497 MEDCoupling::MEDCouplingExtrudedMesh *ext=buildExtrudedMesh(m2D);
499 MEDCoupling::MEDCouplingFieldDouble *f=MEDCoupling::MEDCouplingFieldDouble::New(MEDCoupling::ON_CELLS,MEDCoupling::ONE_TIME);
500 f->setTime(6.8,11,8);
502 f->setName("MyFieldOnExtruM");
503 f->setDescription("desc of MyFiOnExtruM");
504 MEDCoupling::DataArrayDouble *array=MEDCoupling::DataArrayDouble::New();
505 int nbOfCells=ext->getNumberOfCells();
506 array->alloc(nbOfCells,2);
507 array->setInfoOnComponent(0,"Power [MW]");
508 array->setInfoOnComponent(1,"Density [kg/m^3]");
509 double *ptr=array->getPointer();
510 for(int i=0;i<nbOfCells*2;i++)
511 ptr[i]=(double)(i/2+7)+(double)((i%2)*1000);
522 MEDCoupling::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldVectorOnCMeshWT()
524 MEDCoupling::MEDCouplingCMesh *m=buildCMesh();
525 MEDCoupling::MEDCouplingFieldDouble *f=MEDCoupling::MEDCouplingFieldDouble::New(MEDCoupling::ON_CELLS,MEDCoupling::ONE_TIME);
526 f->setTime(6.8,11,8);
529 f->setName("MyFieldOnCMesh");
530 f->setDescription("desc of MyFiOnCMesh");
531 MEDCoupling::DataArrayDouble *array=MEDCoupling::DataArrayDouble::New();
532 int nbOfCells=m->getNumberOfCells();
533 array->alloc(nbOfCells,2);
534 array->setInfoOnComponent(0,"Power [GW]");
535 array->setInfoOnComponent(1,"Density [kg/m^3]");
536 double *ptr=array->getPointer();
537 for(int i=0;i<nbOfCells*2;i++)
538 ptr[i]=(double)(i/2+7)+(double)((i%2)*1000);
547 MEDCoupling::MEDCouplingFieldTemplate *MEDCouplingCorbaServBasicsTest::buildFieldTemplateCellOn2D()
549 MEDCoupling::MEDCouplingFieldDouble *f1=buildFieldScalarOn2DNT();
550 MEDCoupling::MEDCouplingFieldTemplate *f2=MEDCoupling::MEDCouplingFieldTemplate::New(*f1);
551 f2->setNature(MEDCoupling::NoNature);
556 MEDCoupling::MEDCouplingFieldTemplate *MEDCouplingCorbaServBasicsTest::buildFieldTemplateNodeOn2D()
558 MEDCoupling::MEDCouplingFieldDouble *f1=buildFieldNodeScalarOn2DNT();
559 MEDCoupling::MEDCouplingFieldTemplate *f2=MEDCoupling::MEDCouplingFieldTemplate::New(*f1);
560 f2->setNature(MEDCoupling::ConservativeVolumic);
565 MEDCoupling::MEDCouplingFieldTemplate *MEDCouplingCorbaServBasicsTest::buildFieldTemplateGaussPtOn2D()
567 MEDCoupling::MEDCouplingFieldDouble *f1=buildFieldGaussPt2DWT();
568 MEDCoupling::MEDCouplingFieldTemplate *f2=MEDCoupling::MEDCouplingFieldTemplate::New(*f1);
569 f2->setNature(MEDCoupling::Integral);
574 MEDCoupling::MEDCouplingFieldTemplate *MEDCouplingCorbaServBasicsTest::buildFieldTemplateGaussNEOn2D()
576 MEDCoupling::MEDCouplingFieldDouble *f1=buildFieldGaussPtNE2DWT();
577 MEDCoupling::MEDCouplingFieldTemplate *f2=MEDCoupling::MEDCouplingFieldTemplate::New(*f1);
578 f2->setNature(MEDCoupling::IntegralGlobConstraint);
583 MEDCoupling::MEDCouplingMultiFields *MEDCouplingCorbaServBasicsTest::buildMultiFields1()
585 MEDCoupling::MEDCouplingUMesh *m1=build2DMesh();
587 MEDCoupling::MEDCouplingUMesh *m2=build2DMesh();
589 const double vals0[]={-0.7,-1.,-2.,-3.,-4.};
590 const double vals1[]={0.,1.,2.,3.,4.,0.1,0.2,0.3,0.4};
591 const double vals1_1[]={170.,171.,172.,173.,174.,170.1,170.2,170.3,170.4};
592 const double vals2[]={5.,6.,7.,8.,9.};
593 const double vals4[]={15.,16.,17.,18.,19.};
595 MEDCoupling::DataArrayDouble *d0=MEDCoupling::DataArrayDouble::New(); d0->alloc(5,1); std::copy(vals0,vals0+5,d0->getPointer());
596 MEDCoupling::DataArrayDouble *d1=MEDCoupling::DataArrayDouble::New(); d1->alloc(9,1); std::copy(vals1,vals1+9,d1->getPointer());
597 MEDCoupling::DataArrayDouble *d1_1=MEDCoupling::DataArrayDouble::New(); d1_1->alloc(9,1); std::copy(vals1_1,vals1_1+9,d1_1->getPointer());
598 MEDCoupling::DataArrayDouble *d2=MEDCoupling::DataArrayDouble::New(); d2->alloc(5,1); std::copy(vals2,vals2+5,d2->getPointer());
599 MEDCoupling::DataArrayDouble *d4=MEDCoupling::DataArrayDouble::New(); d4->alloc(5,1); std::copy(vals4,vals4+5,d4->getPointer());
601 d0->setName("d0"); d1->setName("d1"); d1_1->setName("d1_1"); d2->setName("d2"); d4->setName("d4");
602 d0->setInfoOnComponent(0,"c1");
603 d1->setInfoOnComponent(0,"c6");
604 d1_1->setInfoOnComponent(0,"c9");
605 d2->setInfoOnComponent(0,"c5");
606 d4->setInfoOnComponent(0,"c7");
608 MEDCoupling::MEDCouplingFieldDouble *f0=MEDCoupling::MEDCouplingFieldDouble::New(MEDCoupling::ON_CELLS,MEDCoupling::ONE_TIME);
611 f0->setTime(0.2,5,6);
613 MEDCoupling::MEDCouplingFieldDouble *f1=MEDCoupling::MEDCouplingFieldDouble::New(MEDCoupling::ON_NODES,MEDCoupling::LINEAR_TIME);
615 std::vector<MEDCoupling::DataArrayDouble *> d1s(2); d1s[0]=d1; d1s[1]=d1_1;
617 f1->setStartTime(0.7,7,8);
618 f1->setEndTime(1.2,9,10);
620 MEDCoupling::MEDCouplingFieldDouble *f2=MEDCoupling::MEDCouplingFieldDouble::New(MEDCoupling::ON_CELLS,MEDCoupling::CONST_ON_TIME_INTERVAL);
623 f2->setTime(1.2,11,12);
624 f2->setEndTime(1.5,13,14);
626 MEDCoupling::MEDCouplingFieldDouble *f3=MEDCoupling::MEDCouplingFieldDouble::New(MEDCoupling::ON_CELLS,MEDCoupling::ONE_TIME);
629 f3->setTime(1.7,15,16);
631 MEDCoupling::MEDCouplingFieldDouble *f4=MEDCoupling::MEDCouplingFieldDouble::New(MEDCoupling::ON_CELLS,MEDCoupling::NO_TIME);
636 std::vector<MEDCoupling::MEDCouplingFieldDouble *> fs(5);
637 fs[0]=f0; fs[1]=f1; fs[2]=f2; fs[3]=f3; fs[4]=f4;
638 MEDCoupling::MEDCouplingMultiFields *ret=MEDCoupling::MEDCouplingMultiFields::New(fs);
656 MEDCoupling::DataArrayDouble *MEDCouplingCorbaServBasicsTest::buildArrayDouble1()
658 MEDCoupling::DataArrayDouble *ret=MEDCoupling::DataArrayDouble::New();
660 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};
661 std::copy(vals,vals+12,ret->getPointer());
662 ret->setName("toto");
663 ret->setInfoOnComponent(0,"sss");
664 ret->setInfoOnComponent(1,"ppp");
665 ret->setInfoOnComponent(2,"ttt");
669 MEDCoupling::DataArrayDouble *MEDCouplingCorbaServBasicsTest::buildArrayDouble2()
671 MEDCoupling::DataArrayDouble *ret=MEDCoupling::DataArrayDouble::New();
672 ret->setName("titi");
676 MEDCoupling::DataArrayDouble *MEDCouplingCorbaServBasicsTest::buildArrayDouble3()
678 MEDCoupling::DataArrayDouble *ret=MEDCoupling::DataArrayDouble::New();
679 ret->setName("titi");
681 ret->setInfoOnComponent(0,"sss");
682 ret->setInfoOnComponent(1,"ppp");
683 ret->setInfoOnComponent(2,"ttt");
687 MEDCoupling::DataArrayInt *MEDCouplingCorbaServBasicsTest::buildArrayInt1()
689 MEDCoupling::DataArrayInt *ret=MEDCoupling::DataArrayInt::New();
691 const int vals[12]={2,3,5,9,47,20,24,278,2,3,2,9};
692 std::copy(vals,vals+12,ret->getPointer());
693 ret->setName("toto");
694 ret->setInfoOnComponent(0,"sss");
695 ret->setInfoOnComponent(1,"ppp");
696 ret->setInfoOnComponent(2,"ttt");
700 MEDCoupling::DataArrayInt *MEDCouplingCorbaServBasicsTest::buildArrayInt2()
702 MEDCoupling::DataArrayInt *ret=MEDCoupling::DataArrayInt::New();
703 ret->setName("titi");
707 MEDCoupling::DataArrayInt *MEDCouplingCorbaServBasicsTest::buildArrayInt3()
709 MEDCoupling::DataArrayInt *ret=MEDCoupling::DataArrayInt::New();
710 ret->setName("titi");
712 ret->setInfoOnComponent(0,"sss");
713 ret->setInfoOnComponent(1,"ppp");
714 ret->setInfoOnComponent(2,"ttt");
718 MEDCoupling::MEDCouplingFieldOverTime *MEDCouplingCorbaServBasicsTest::buildMultiFields2()
720 MEDCoupling::MEDCouplingUMesh *m1=build2DMesh();
722 MEDCoupling::MEDCouplingUMesh *m2=build2DMesh();
724 const double vals0[]={-0.7,-1.,-2.,-3.,-4.};
725 const double vals1[]={0.,1.,2.,3.,4.};
726 const double vals1_1[]={170.,171.,172.,173.,174.};
727 const double vals2[]={5.,6.,7.,8.,9.};
728 const double vals4[]={15.,16.,17.,18.,19.};
730 MEDCoupling::DataArrayDouble *d0=MEDCoupling::DataArrayDouble::New(); d0->alloc(5,1); std::copy(vals0,vals0+5,d0->getPointer());
731 MEDCoupling::DataArrayDouble *d1=MEDCoupling::DataArrayDouble::New(); d1->alloc(5,1); std::copy(vals1,vals1+5,d1->getPointer());
732 MEDCoupling::DataArrayDouble *d1_1=MEDCoupling::DataArrayDouble::New(); d1_1->alloc(5,1); std::copy(vals1_1,vals1_1+5,d1_1->getPointer());
733 MEDCoupling::DataArrayDouble *d2=MEDCoupling::DataArrayDouble::New(); d2->alloc(5,1); std::copy(vals2,vals2+5,d2->getPointer());
734 MEDCoupling::DataArrayDouble *d4=MEDCoupling::DataArrayDouble::New(); d4->alloc(5,1); std::copy(vals4,vals4+5,d4->getPointer());
736 d0->setName("d0"); d1->setName("d1"); d1_1->setName("d1_1"); d2->setName("d2"); d4->setName("d4");
737 d0->setInfoOnComponent(0,"c1");
738 d1->setInfoOnComponent(0,"c6");
739 d1_1->setInfoOnComponent(0,"c9");
740 d2->setInfoOnComponent(0,"c5");
741 d4->setInfoOnComponent(0,"c7");
743 MEDCoupling::MEDCouplingFieldDouble *f0=MEDCoupling::MEDCouplingFieldDouble::New(MEDCoupling::ON_CELLS,MEDCoupling::ONE_TIME);
746 f0->setTime(0.2,5,6);
748 MEDCoupling::MEDCouplingFieldDouble *f1=MEDCoupling::MEDCouplingFieldDouble::New(MEDCoupling::ON_CELLS,MEDCoupling::LINEAR_TIME);
750 std::vector<MEDCoupling::DataArrayDouble *> d1s(2); d1s[0]=d1; d1s[1]=d1_1;
752 f1->setStartTime(0.7,7,8);
753 f1->setEndTime(1.2,9,10);
755 MEDCoupling::MEDCouplingFieldDouble *f2=MEDCoupling::MEDCouplingFieldDouble::New(MEDCoupling::ON_CELLS,MEDCoupling::CONST_ON_TIME_INTERVAL);
758 f2->setTime(1.2,11,12);
759 f2->setEndTime(1.5,13,14);
761 MEDCoupling::MEDCouplingFieldDouble *f3=MEDCoupling::MEDCouplingFieldDouble::New(MEDCoupling::ON_CELLS,MEDCoupling::ONE_TIME);
764 f3->setTime(1.7,15,16);
766 MEDCoupling::MEDCouplingFieldDouble *f4=MEDCoupling::MEDCouplingFieldDouble::New(MEDCoupling::ON_CELLS,MEDCoupling::ONE_TIME);
770 f4->setTime(2.7,25,26);
772 std::vector<MEDCoupling::MEDCouplingFieldDouble *> fs(5);
773 fs[0]=f0; fs[1]=f1; fs[2]=f2; fs[3]=f3; fs[4]=f4;
774 MEDCoupling::MEDCouplingFieldOverTime *ret=MEDCoupling::MEDCouplingFieldOverTime::New(fs);
775 ret->checkCoherency();
793 std::string MEDCouplingCorbaServBasicsTest::buildFileNameForIOR()
797 tmpdir = getenv("TMP");
801 std::string username;
802 if ( getenv("USERNAME") )
803 username = std::string(getenv("USERNAME"))+"_";
804 else if ( getenv("USER") )
805 username = std::string(getenv("USER"))+"_";
807 std::string ret = tmpdir+"/"+username+"entryPointMEDCouplingCorba.ior";