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 "MEDCouplingUMesh.hxx"
29 #include "MEDCouplingCMesh.hxx"
30 #include "MEDCouplingCurveLinearMesh.hxx"
37 ParaMEDMEM::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::build1DMesh()
39 double coords[4]={ 0.0, 0.3, 0.75, 1.0 };
40 int conn[2*3]={ 0,1, 1,2, 2,3 };
41 ParaMEDMEM::MEDCouplingUMesh *mesh=ParaMEDMEM::MEDCouplingUMesh::New("1DMeshForCorba",1);
42 mesh->setDescription("build1DMesh");
43 mesh->allocateCells(3);
44 mesh->setTime(5.6,7,8);
45 mesh->setTimeUnit("ms");
46 mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn);
47 mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2);
48 mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+4);
49 mesh->finishInsertingCells();
50 ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New();
52 std::copy(coords,coords+4,myCoords->getPointer());
53 mesh->setCoords(myCoords);
55 mesh->changeSpaceDimension(3);
56 myCoords=mesh->getCoords();
57 myCoords->setInfoOnComponent(0,"X1D [m]");
58 myCoords->setInfoOnComponent(1,"Y1D [dm]");
59 myCoords->setInfoOnComponent(2,"Z1D [pm]");
60 double center[3]={0.,0.,0.};
61 double vector[3]={0,1,0};
62 mesh->rotate(center,vector,-M_PI/2.);
66 ParaMEDMEM::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::build2DMesh()
68 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 };
69 int targetConn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
70 ParaMEDMEM::MEDCouplingUMesh *targetMesh=ParaMEDMEM::MEDCouplingUMesh::New();
71 targetMesh->setMeshDimension(2);
72 targetMesh->setName("MyMesh2D");
73 targetMesh->setDescription("build2DMesh");
74 targetMesh->allocateCells(5);
75 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
76 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
77 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
78 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
79 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
80 targetMesh->finishInsertingCells();
81 ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New();
83 std::copy(targetCoords,targetCoords+18,myCoords->getPointer());
84 targetMesh->setCoords(myCoords);
89 ParaMEDMEM::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::build3DMesh()
91 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. ,
92 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. ,
93 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. };
94 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,
95 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};
96 ParaMEDMEM::MEDCouplingUMesh *targetMesh=ParaMEDMEM::MEDCouplingUMesh::New();
97 targetMesh->setMeshDimension(3);
98 targetMesh->setName("MyMesh3D");
99 targetMesh->setDescription("build3DMesh");
100 targetMesh->allocateCells(12);
102 targetMesh->insertNextCell(INTERP_KERNEL::NORM_HEXA8,8,targetConn+8*i);
103 targetMesh->finishInsertingCells();
104 ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New();
105 myCoords->alloc(27,3);
106 std::copy(targetCoords,targetCoords+81,myCoords->getPointer());
107 targetMesh->setCoords(myCoords);
108 myCoords->setName("check in case");
113 ParaMEDMEM::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::build3DSurfMesh()
115 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};
116 int targetConn[18]={0,3,4,1, 1,4,2, 4,5,2, 6,7,4,3, 7,8,5,4};
117 ParaMEDMEM::MEDCouplingUMesh *targetMesh=ParaMEDMEM::MEDCouplingUMesh::New();
118 targetMesh->setMeshDimension(2);
119 targetMesh->setName("MyMesh3DSurf");
120 targetMesh->setDescription("build3DSurfMesh");
121 targetMesh->allocateCells(5);
122 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn);
123 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+4);
124 targetMesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+7);
125 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+10);
126 targetMesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn+14);
127 targetMesh->finishInsertingCells();
128 ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New();
129 myCoords->alloc(9,3);
130 std::copy(targetCoords,targetCoords+27,myCoords->getPointer());
131 targetMesh->setCoords(myCoords);
132 myCoords->setInfoOnComponent(0,"X [m]");
133 myCoords->setInfoOnComponent(1,"X [dm]");
134 myCoords->setInfoOnComponent(2,"X [m]");
139 ParaMEDMEM::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::build0DMesh()
141 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};
142 const int targetConn[]={0,1,2,3,4,5,7,6};
143 ParaMEDMEM::MEDCouplingUMesh *targetMesh=ParaMEDMEM::MEDCouplingUMesh::New();
144 targetMesh->setMeshDimension(0);
145 targetMesh->allocateCells(8);
146 targetMesh->setName("Wonderfull 0D mesh");
147 targetMesh->setDescription("build0DMesh");
148 targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn);
149 targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+1);
150 targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+2);
151 targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+3);
152 targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+4);
153 targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+5);
154 targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+6);
155 targetMesh->insertNextCell(INTERP_KERNEL::NORM_POINT1,1,targetConn+7);
156 targetMesh->finishInsertingCells();
157 ParaMEDMEM::DataArrayDouble *myCoords=ParaMEDMEM::DataArrayDouble::New();
158 myCoords->alloc(9,3);
159 std::copy(targetCoords,targetCoords+27,myCoords->getPointer());
160 targetMesh->setCoords(myCoords);
161 myCoords->setInfoOnComponent(0,"X [m]");
162 myCoords->setInfoOnComponent(1,"YY [Pm]");
163 myCoords->setInfoOnComponent(2,"ZZZ [m]");
166 targetMesh->checkCoherency();
170 ParaMEDMEM::MEDCouplingUMesh *MEDCouplingCorbaServBasicsTest::buildM1DMesh()
172 ParaMEDMEM::MEDCouplingUMesh *meshM1D=ParaMEDMEM::MEDCouplingUMesh::New("wonderfull -1 D mesh",-1);
173 meshM1D->setDescription("buildM1DMesh");
174 meshM1D->checkCoherency();
178 ParaMEDMEM::MEDCouplingExtrudedMesh *MEDCouplingCorbaServBasicsTest::buildExtrudedMesh(ParaMEDMEM::MEDCouplingUMesh *&m2D)
181 m2D->changeSpaceDimension(3);
182 ParaMEDMEM::MEDCouplingUMesh *m1D=build1DMesh();
183 ParaMEDMEM::MEDCouplingUMesh *retu=m2D->buildExtrudedMesh(m1D,0);
185 ParaMEDMEM::MEDCouplingExtrudedMesh *ret=ParaMEDMEM::MEDCouplingExtrudedMesh::New(retu,m2D,2);
186 ret->setName("ExtrudedTestForCorbaTest");
187 ret->setDescription("buildExtrudedMesh");
192 ParaMEDMEM::MEDCouplingCMesh *MEDCouplingCorbaServBasicsTest::buildCMesh()
194 ParaMEDMEM::MEDCouplingCMesh *targetMesh=ParaMEDMEM::MEDCouplingCMesh::New();
195 targetMesh->setTime(2.3,4,5);
196 targetMesh->setTimeUnit("us");
197 targetMesh->setName("Example of CMesh");
198 targetMesh->setDescription("buildCMesh");
199 ParaMEDMEM::DataArrayDouble *a1=ParaMEDMEM::DataArrayDouble::New();
201 a1->setInfoOnComponent(0,"SmthX");
202 const double a1Data[5]={3.,4.,5.,6.,7.};
203 std::copy(a1Data,a1Data+5,a1->getPointer());
204 ParaMEDMEM::DataArrayDouble *a2=ParaMEDMEM::DataArrayDouble::New();
206 a2->setInfoOnComponent(0,"SmthZ");
207 const double a2Data[6]={2.78,3.,4.,5.,6.,7.};
208 std::copy(a2Data,a2Data+6,a2->getPointer());
210 targetMesh->setCoordsAt(0,a1);
211 targetMesh->setCoordsAt(2,a2);
216 targetMesh->checkCoherency();
221 ParaMEDMEM::MEDCouplingCurveLinearMesh *MEDCouplingCorbaServBasicsTest::buildCLMesh()
223 ParaMEDMEM::MEDCouplingCurveLinearMesh *targetMesh=ParaMEDMEM::MEDCouplingCurveLinearMesh::New();
224 targetMesh->setTime(2.3,4,5);
225 targetMesh->setTimeUnit("us");
226 targetMesh->setName("Example of Cuve linear mesh");
227 targetMesh->setDescription("buildCLMesh");
228 ParaMEDMEM::DataArrayDouble *a1=ParaMEDMEM::DataArrayDouble::New();
232 targetMesh->setCoords(a1);
234 int structure[2]={4,5};
235 targetMesh->setNodeGridStructure(structure,structure+2);
237 targetMesh->checkCoherency();
242 ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldScalarOn2DNT()
244 ParaMEDMEM::MEDCouplingUMesh *mesh=build2DMesh();
245 ParaMEDMEM::MEDCouplingFieldDouble *fieldOnCells=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME);
246 fieldOnCells->setTimeUnit("ms");
247 fieldOnCells->setName("toto");
248 fieldOnCells->setMesh(mesh);
249 ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
250 array->alloc(mesh->getNumberOfCells(),6);
251 fieldOnCells->setArray(array);
252 double *tmp=array->getPointer();
254 std::fill(tmp,tmp+mesh->getNumberOfCells()*6,7.);
256 fieldOnCells->checkCoherency();
260 ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldNodeScalarOn2DNT()
262 ParaMEDMEM::MEDCouplingUMesh *mesh=build2DMesh();
263 ParaMEDMEM::MEDCouplingFieldDouble *fieldOnNodes=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_NODES,ParaMEDMEM::NO_TIME);
264 fieldOnNodes->setName("toto2");
265 fieldOnNodes->setTimeUnit("s");
266 fieldOnNodes->setDescription("my wonderful field toto2");
267 fieldOnNodes->setMesh(mesh);
268 ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
269 array->alloc(mesh->getNumberOfNodes(),5);
270 fieldOnNodes->setArray(array);
271 double *tmp=array->getPointer();
273 std::fill(tmp,tmp+mesh->getNumberOfNodes()*5,7.1234);
275 fieldOnNodes->checkCoherency();
279 ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldScalarOn3DNT()
281 ParaMEDMEM::MEDCouplingUMesh *mesh=build3DMesh();
282 ParaMEDMEM::MEDCouplingFieldDouble *fieldOnCells=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME);
283 fieldOnCells->setNature(ParaMEDMEM::ConservativeVolumic);
284 fieldOnCells->setName("toto");
285 fieldOnCells->setDescription("my wonderful 3D field toto2");
286 fieldOnCells->setMesh(mesh);
287 ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
288 array->alloc(mesh->getNumberOfCells(),6);
289 fieldOnCells->setArray(array);
290 double *tmp=array->getPointer();
292 std::fill(tmp,tmp+mesh->getNumberOfCells()*6,7.);
294 fieldOnCells->checkCoherency();
298 ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldScalarOn3DSurfWT()
300 ParaMEDMEM::MEDCouplingUMesh *mesh=build3DSurfMesh();
301 ParaMEDMEM::MEDCouplingFieldDouble *fieldOnCells=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
302 fieldOnCells->setName("toto25");
303 fieldOnCells->setDescription("my wonderful 3D surf field toto25");
304 fieldOnCells->setTimeUnit("us");
305 fieldOnCells->setMesh(mesh);
306 ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
307 array->alloc(mesh->getNumberOfCells(),3);
308 array->setInfoOnComponent(0,"aaa"); array->setInfoOnComponent(1,"bbbb"); array->setInfoOnComponent(2,"ccccc");
309 fieldOnCells->setArray(array);
310 double *tmp=array->getPointer();
312 std::fill(tmp,tmp+mesh->getNumberOfCells()*3,7.);
314 fieldOnCells->setTime(6.7,1,4);
315 fieldOnCells->checkCoherency();
319 ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldScalarOn3DSurfCOTI()
321 ParaMEDMEM::MEDCouplingUMesh *mesh=build3DSurfMesh();
322 ParaMEDMEM::MEDCouplingFieldDouble *fieldOnCells=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::CONST_ON_TIME_INTERVAL);
323 fieldOnCells->setName("toto26");
324 fieldOnCells->setDescription("my wonderful 3D surf field toto26");
325 fieldOnCells->setTimeUnit("us");
326 fieldOnCells->setMesh(mesh);
327 ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
328 array->alloc(mesh->getNumberOfCells(),3);
329 fieldOnCells->setArray(array);
330 double *tmp=array->getPointer();
332 std::fill(tmp,tmp+mesh->getNumberOfCells()*3,7.);
334 fieldOnCells->setStartTime(6.7,1,4);
335 fieldOnCells->setEndTime(7.2,2,8);
336 fieldOnCells->checkCoherency();
340 ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldScalarOn2DLT()
342 ParaMEDMEM::MEDCouplingUMesh *mesh=build2DMesh();
343 ParaMEDMEM::MEDCouplingFieldDouble *fieldOnCells=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::LINEAR_TIME);
344 fieldOnCells->setName("toto27");
345 fieldOnCells->setDescription("my wonderful 2D field toto27");
346 fieldOnCells->setTimeUnit("ms");
347 fieldOnCells->setMesh(mesh);
348 ParaMEDMEM::DataArrayDouble *array1=ParaMEDMEM::DataArrayDouble::New();
349 array1->alloc(mesh->getNumberOfCells(),4);
350 fieldOnCells->setArray(array1);
351 double *tmp=array1->getPointer();
353 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};
354 std::copy(arr1,arr1+20,tmp);
355 ParaMEDMEM::DataArrayDouble *array2=ParaMEDMEM::DataArrayDouble::New();
356 array2->alloc(mesh->getNumberOfCells(),4);
357 fieldOnCells->setEndArray(array2);
358 tmp=array2->getPointer();
361 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};
362 std::copy(arr2,arr2+20,tmp);
363 fieldOnCells->setStartTime(6.7,25,26);
364 fieldOnCells->setEndTime(17.2,125,126);
365 fieldOnCells->checkCoherency();
369 ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldGaussPt2DWT()
371 const double _a=0.446948490915965;
372 const double _b=0.091576213509771;
373 const double _p1=0.11169079483905;
374 const double _p2=0.0549758718227661;
375 const double refCoo1[6]={ 0.,0., 1.,0., 0.,1. };
376 const double gsCoo1[12]={ 2*_b-1, 1-4*_b, 2*_b-1, 2.07*_b-1, 1-4*_b,
377 2*_b-1, 1-4*_a, 2*_a-1, 2*_a-1, 1-4*_a, 2*_a-1, 2*_a-1 };
378 const double wg1[6]={ 4*_p2, 4*_p2, 4*_p2, 4*_p1, 4*_p1, 4*_p1 };
379 std::vector<double> _refCoo1(refCoo1,refCoo1+6);
380 std::vector<double> _gsCoo1(gsCoo1,gsCoo1+12);
381 std::vector<double> _wg1(wg1,wg1+6);
382 ParaMEDMEM::MEDCouplingUMesh *m=build2DMesh();
383 ParaMEDMEM::MEDCouplingFieldDouble *f=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_GAUSS_PT,ParaMEDMEM::ONE_TIME);
387 f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_TRI3,_refCoo1,_gsCoo1,_wg1);
388 const double refCoo2[8]={ 0.,0., 1.,0., 1.,1., 0.,1. };
389 std::vector<double> _refCoo2(refCoo2,refCoo2+8);
390 _gsCoo1.resize(4); _wg1.resize(2);
391 f->setGaussLocalizationOnType(INTERP_KERNEL::NORM_QUAD4,_refCoo2,_gsCoo1,_wg1);
392 ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
394 array->setInfoOnComponent(0,"Power [MW]");
395 array->setInfoOnComponent(1,"Density [kg/m^3]");
396 double *ptr=array->getPointer();
397 for(int i=0;i<18*2;i++)
398 ptr[i]=(double)(i+1);
400 f->setName("MyFirstFieldOnGaussPoint");
401 f->setTimeUnit("ms");
402 f->setDescription("mmmmmmmmmmmm");
408 ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldGaussPtNE2DWT()
410 ParaMEDMEM::MEDCouplingUMesh *m=build2DMesh();
411 ParaMEDMEM::MEDCouplingFieldDouble *f=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_GAUSS_NE,ParaMEDMEM::ONE_TIME);
412 f->setTime(6.8,11,8);
414 f->setTimeUnit("ms");
415 f->setName("MyFirstFieldOnNE");
416 f->setDescription("MyDescriptionNE");
417 ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
419 array->setInfoOnComponent(0,"Power [MW]");
420 array->setInfoOnComponent(1,"Density [kg/m^3]");
421 double *ptr=array->getPointer();
422 for(int i=0;i<18*2;i++)
423 ptr[i]=(double)(i+7);
432 ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldVectorOnExtrudedWT()
434 ParaMEDMEM::MEDCouplingUMesh *m2D=0;
435 ParaMEDMEM::MEDCouplingExtrudedMesh *ext=buildExtrudedMesh(m2D);
437 ParaMEDMEM::MEDCouplingFieldDouble *f=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
438 f->setTime(6.8,11,8);
440 f->setName("MyFieldOnExtruM");
441 f->setDescription("desc of MyFiOnExtruM");
442 ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
443 int nbOfCells=ext->getNumberOfCells();
444 array->alloc(nbOfCells,2);
445 array->setInfoOnComponent(0,"Power [MW]");
446 array->setInfoOnComponent(1,"Density [kg/m^3]");
447 double *ptr=array->getPointer();
448 for(int i=0;i<nbOfCells*2;i++)
449 ptr[i]=(double)(i/2+7)+(double)((i%2)*1000);
460 ParaMEDMEM::MEDCouplingFieldDouble *MEDCouplingCorbaServBasicsTest::buildFieldVectorOnCMeshWT()
462 ParaMEDMEM::MEDCouplingCMesh *m=buildCMesh();
463 ParaMEDMEM::MEDCouplingFieldDouble *f=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
464 f->setTime(6.8,11,8);
467 f->setName("MyFieldOnCMesh");
468 f->setDescription("desc of MyFiOnCMesh");
469 ParaMEDMEM::DataArrayDouble *array=ParaMEDMEM::DataArrayDouble::New();
470 int nbOfCells=m->getNumberOfCells();
471 array->alloc(nbOfCells,2);
472 array->setInfoOnComponent(0,"Power [GW]");
473 array->setInfoOnComponent(1,"Density [kg/m^3]");
474 double *ptr=array->getPointer();
475 for(int i=0;i<nbOfCells*2;i++)
476 ptr[i]=(double)(i/2+7)+(double)((i%2)*1000);
485 ParaMEDMEM::MEDCouplingFieldTemplate *MEDCouplingCorbaServBasicsTest::buildFieldTemplateCellOn2D()
487 ParaMEDMEM::MEDCouplingFieldDouble *f1=buildFieldScalarOn2DNT();
488 ParaMEDMEM::MEDCouplingFieldTemplate *f2=ParaMEDMEM::MEDCouplingFieldTemplate::New(*f1);
489 f2->setNature(ParaMEDMEM::NoNature);
494 ParaMEDMEM::MEDCouplingFieldTemplate *MEDCouplingCorbaServBasicsTest::buildFieldTemplateNodeOn2D()
496 ParaMEDMEM::MEDCouplingFieldDouble *f1=buildFieldNodeScalarOn2DNT();
497 ParaMEDMEM::MEDCouplingFieldTemplate *f2=ParaMEDMEM::MEDCouplingFieldTemplate::New(*f1);
498 f2->setNature(ParaMEDMEM::ConservativeVolumic);
503 ParaMEDMEM::MEDCouplingFieldTemplate *MEDCouplingCorbaServBasicsTest::buildFieldTemplateGaussPtOn2D()
505 ParaMEDMEM::MEDCouplingFieldDouble *f1=buildFieldGaussPt2DWT();
506 ParaMEDMEM::MEDCouplingFieldTemplate *f2=ParaMEDMEM::MEDCouplingFieldTemplate::New(*f1);
507 f2->setNature(ParaMEDMEM::Integral);
512 ParaMEDMEM::MEDCouplingFieldTemplate *MEDCouplingCorbaServBasicsTest::buildFieldTemplateGaussNEOn2D()
514 ParaMEDMEM::MEDCouplingFieldDouble *f1=buildFieldGaussPtNE2DWT();
515 ParaMEDMEM::MEDCouplingFieldTemplate *f2=ParaMEDMEM::MEDCouplingFieldTemplate::New(*f1);
516 f2->setNature(ParaMEDMEM::IntegralGlobConstraint);
521 ParaMEDMEM::MEDCouplingMultiFields *MEDCouplingCorbaServBasicsTest::buildMultiFields1()
523 ParaMEDMEM::MEDCouplingUMesh *m1=build2DMesh();
525 ParaMEDMEM::MEDCouplingUMesh *m2=build2DMesh();
527 const double vals0[]={-0.7,-1.,-2.,-3.,-4.};
528 const double vals1[]={0.,1.,2.,3.,4.,0.1,0.2,0.3,0.4};
529 const double vals1_1[]={170.,171.,172.,173.,174.,170.1,170.2,170.3,170.4};
530 const double vals2[]={5.,6.,7.,8.,9.};
531 const double vals4[]={15.,16.,17.,18.,19.};
533 ParaMEDMEM::DataArrayDouble *d0=ParaMEDMEM::DataArrayDouble::New(); d0->alloc(5,1); std::copy(vals0,vals0+5,d0->getPointer());
534 ParaMEDMEM::DataArrayDouble *d1=ParaMEDMEM::DataArrayDouble::New(); d1->alloc(9,1); std::copy(vals1,vals1+9,d1->getPointer());
535 ParaMEDMEM::DataArrayDouble *d1_1=ParaMEDMEM::DataArrayDouble::New(); d1_1->alloc(9,1); std::copy(vals1_1,vals1_1+9,d1_1->getPointer());
536 ParaMEDMEM::DataArrayDouble *d2=ParaMEDMEM::DataArrayDouble::New(); d2->alloc(5,1); std::copy(vals2,vals2+5,d2->getPointer());
537 ParaMEDMEM::DataArrayDouble *d4=ParaMEDMEM::DataArrayDouble::New(); d4->alloc(5,1); std::copy(vals4,vals4+5,d4->getPointer());
539 d0->setName("d0"); d1->setName("d1"); d1_1->setName("d1_1"); d2->setName("d2"); d4->setName("d4");
540 d0->setInfoOnComponent(0,"c1");
541 d1->setInfoOnComponent(0,"c6");
542 d1_1->setInfoOnComponent(0,"c9");
543 d2->setInfoOnComponent(0,"c5");
544 d4->setInfoOnComponent(0,"c7");
546 ParaMEDMEM::MEDCouplingFieldDouble *f0=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
549 f0->setTime(0.2,5,6);
551 ParaMEDMEM::MEDCouplingFieldDouble *f1=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_NODES,ParaMEDMEM::LINEAR_TIME);
553 std::vector<ParaMEDMEM::DataArrayDouble *> d1s(2); d1s[0]=d1; d1s[1]=d1_1;
555 f1->setStartTime(0.7,7,8);
556 f1->setEndTime(1.2,9,10);
558 ParaMEDMEM::MEDCouplingFieldDouble *f2=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::CONST_ON_TIME_INTERVAL);
561 f2->setTime(1.2,11,12);
562 f2->setEndTime(1.5,13,14);
564 ParaMEDMEM::MEDCouplingFieldDouble *f3=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
567 f3->setTime(1.7,15,16);
569 ParaMEDMEM::MEDCouplingFieldDouble *f4=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME);
574 std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> fs(5);
575 fs[0]=f0; fs[1]=f1; fs[2]=f2; fs[3]=f3; fs[4]=f4;
576 ParaMEDMEM::MEDCouplingMultiFields *ret=ParaMEDMEM::MEDCouplingMultiFields::New(fs);
594 ParaMEDMEM::DataArrayDouble *MEDCouplingCorbaServBasicsTest::buildArrayDouble1()
596 ParaMEDMEM::DataArrayDouble *ret=ParaMEDMEM::DataArrayDouble::New();
598 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};
599 std::copy(vals,vals+12,ret->getPointer());
600 ret->setName("toto");
601 ret->setInfoOnComponent(0,"sss");
602 ret->setInfoOnComponent(1,"ppp");
603 ret->setInfoOnComponent(2,"ttt");
607 ParaMEDMEM::DataArrayDouble *MEDCouplingCorbaServBasicsTest::buildArrayDouble2()
609 ParaMEDMEM::DataArrayDouble *ret=ParaMEDMEM::DataArrayDouble::New();
610 ret->setName("titi");
614 ParaMEDMEM::DataArrayDouble *MEDCouplingCorbaServBasicsTest::buildArrayDouble3()
616 ParaMEDMEM::DataArrayDouble *ret=ParaMEDMEM::DataArrayDouble::New();
617 ret->setName("titi");
619 ret->setInfoOnComponent(0,"sss");
620 ret->setInfoOnComponent(1,"ppp");
621 ret->setInfoOnComponent(2,"ttt");
625 ParaMEDMEM::DataArrayInt *MEDCouplingCorbaServBasicsTest::buildArrayInt1()
627 ParaMEDMEM::DataArrayInt *ret=ParaMEDMEM::DataArrayInt::New();
629 const int vals[12]={2,3,5,9,47,20,24,278,2,3,2,9};
630 std::copy(vals,vals+12,ret->getPointer());
631 ret->setName("toto");
632 ret->setInfoOnComponent(0,"sss");
633 ret->setInfoOnComponent(1,"ppp");
634 ret->setInfoOnComponent(2,"ttt");
638 ParaMEDMEM::DataArrayInt *MEDCouplingCorbaServBasicsTest::buildArrayInt2()
640 ParaMEDMEM::DataArrayInt *ret=ParaMEDMEM::DataArrayInt::New();
641 ret->setName("titi");
645 ParaMEDMEM::DataArrayInt *MEDCouplingCorbaServBasicsTest::buildArrayInt3()
647 ParaMEDMEM::DataArrayInt *ret=ParaMEDMEM::DataArrayInt::New();
648 ret->setName("titi");
650 ret->setInfoOnComponent(0,"sss");
651 ret->setInfoOnComponent(1,"ppp");
652 ret->setInfoOnComponent(2,"ttt");
656 ParaMEDMEM::MEDCouplingFieldOverTime *MEDCouplingCorbaServBasicsTest::buildMultiFields2()
658 ParaMEDMEM::MEDCouplingUMesh *m1=build2DMesh();
660 ParaMEDMEM::MEDCouplingUMesh *m2=build2DMesh();
662 const double vals0[]={-0.7,-1.,-2.,-3.,-4.};
663 const double vals1[]={0.,1.,2.,3.,4.};
664 const double vals1_1[]={170.,171.,172.,173.,174.};
665 const double vals2[]={5.,6.,7.,8.,9.};
666 const double vals4[]={15.,16.,17.,18.,19.};
668 ParaMEDMEM::DataArrayDouble *d0=ParaMEDMEM::DataArrayDouble::New(); d0->alloc(5,1); std::copy(vals0,vals0+5,d0->getPointer());
669 ParaMEDMEM::DataArrayDouble *d1=ParaMEDMEM::DataArrayDouble::New(); d1->alloc(5,1); std::copy(vals1,vals1+5,d1->getPointer());
670 ParaMEDMEM::DataArrayDouble *d1_1=ParaMEDMEM::DataArrayDouble::New(); d1_1->alloc(5,1); std::copy(vals1_1,vals1_1+5,d1_1->getPointer());
671 ParaMEDMEM::DataArrayDouble *d2=ParaMEDMEM::DataArrayDouble::New(); d2->alloc(5,1); std::copy(vals2,vals2+5,d2->getPointer());
672 ParaMEDMEM::DataArrayDouble *d4=ParaMEDMEM::DataArrayDouble::New(); d4->alloc(5,1); std::copy(vals4,vals4+5,d4->getPointer());
674 d0->setName("d0"); d1->setName("d1"); d1_1->setName("d1_1"); d2->setName("d2"); d4->setName("d4");
675 d0->setInfoOnComponent(0,"c1");
676 d1->setInfoOnComponent(0,"c6");
677 d1_1->setInfoOnComponent(0,"c9");
678 d2->setInfoOnComponent(0,"c5");
679 d4->setInfoOnComponent(0,"c7");
681 ParaMEDMEM::MEDCouplingFieldDouble *f0=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
684 f0->setTime(0.2,5,6);
686 ParaMEDMEM::MEDCouplingFieldDouble *f1=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::LINEAR_TIME);
688 std::vector<ParaMEDMEM::DataArrayDouble *> d1s(2); d1s[0]=d1; d1s[1]=d1_1;
690 f1->setStartTime(0.7,7,8);
691 f1->setEndTime(1.2,9,10);
693 ParaMEDMEM::MEDCouplingFieldDouble *f2=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::CONST_ON_TIME_INTERVAL);
696 f2->setTime(1.2,11,12);
697 f2->setEndTime(1.5,13,14);
699 ParaMEDMEM::MEDCouplingFieldDouble *f3=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
702 f3->setTime(1.7,15,16);
704 ParaMEDMEM::MEDCouplingFieldDouble *f4=ParaMEDMEM::MEDCouplingFieldDouble::New(ParaMEDMEM::ON_CELLS,ParaMEDMEM::ONE_TIME);
708 f4->setTime(2.7,25,26);
710 std::vector<ParaMEDMEM::MEDCouplingFieldDouble *> fs(5);
711 fs[0]=f0; fs[1]=f1; fs[2]=f2; fs[3]=f3; fs[4]=f4;
712 ParaMEDMEM::MEDCouplingFieldOverTime *ret=ParaMEDMEM::MEDCouplingFieldOverTime::New(fs);
713 ret->checkCoherency();
731 std::string MEDCouplingCorbaServBasicsTest::buildFileNameForIOR()
735 ret+="/entryPointMEDCouplingCorba.ior";