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 "MEDCouplingMeshFieldFactoryComponentClt.hxx"
22 #include "MEDCouplingMeshFieldFactoryComponent.hxx"
23 #include "MEDCouplingUMesh.hxx"
24 #include "MEDCouplingUMeshClient.hxx"
25 #include "MEDCoupling1GTUMesh.hxx"
26 #include "MEDCoupling1SGTUMeshClient.hxx"
27 #include "MEDCoupling1DGTUMeshClient.hxx"
28 #include "MEDCouplingMappedExtrudedMesh.hxx"
29 #include "MEDCouplingExtrudedMeshClient.hxx"
30 #include "MEDCouplingCMesh.hxx"
31 #include "MEDCouplingCMeshClient.hxx"
32 #include "MEDCouplingIMesh.hxx"
33 #include "MEDCouplingIMeshClient.hxx"
34 #include "MEDCouplingCurveLinearMesh.hxx"
35 #include "MEDCouplingCurveLinearMeshClient.hxx"
36 #include "MEDCouplingFieldDouble.hxx"
37 #include "MEDCouplingFieldDoubleClient.hxx"
38 #include "MEDCouplingFieldTemplate.hxx"
39 #include "MEDCouplingFieldTemplateClient.hxx"
40 #include "MEDCouplingMultiFields.hxx"
41 #include "MEDCouplingMultiFieldsClient.hxx"
42 #include "MEDCouplingFieldOverTime.hxx"
43 #include "MEDCouplingFieldOverTimeClient.hxx"
44 #include "DataArrayDoubleClient.hxx"
45 #include "DataArrayIntClient.hxx"
49 SALOME_TEST::MEDCouplingMeshFieldFactory_ptr SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::_objC;
51 MEDCoupling::MEDCouplingUMesh *SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::_mesh_from_distant=0;
53 int SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::_argc=0;
55 char **SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::_argv=0;
57 CORBA::ORB_var SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::_orb;
59 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkBaseCorbaFetching()
61 _orb=CORBA::ORB_init(_argc,_argv);
62 std::ifstream ifs(SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildFileNameForIOR().c_str());
65 CORBA::Object_var obj=_orb->string_to_object(ior.c_str());
66 _objC=SALOME_TEST::MEDCouplingMeshFieldFactory::_narrow(obj);
67 CPPUNIT_ASSERT(!CORBA::is_nil(_objC));
72 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkContentOfFetched1DMesh()
74 SALOME_MED::MEDCouplingUMeshCorbaInterface_ptr meshPtr=_objC->get1DMesh();
75 _mesh_from_distant=MEDCoupling::MEDCouplingUMeshClient::New(meshPtr);
76 char *meshName=meshPtr->getName();
77 std::string meshNameCpp(meshName);
78 CPPUNIT_ASSERT(meshNameCpp=="1DMeshForCorba");
79 CORBA::string_free(meshName);
80 meshPtr->UnRegister();
81 CORBA::release(meshPtr);
82 CPPUNIT_ASSERT_EQUAL(3,_mesh_from_distant->getSpaceDimension());
83 CPPUNIT_ASSERT_EQUAL(1,_mesh_from_distant->getMeshDimension());
84 MEDCoupling::MEDCouplingUMesh *meshRef=SALOME_TEST::MEDCouplingCorbaServBasicsTest::build1DMesh();
85 CPPUNIT_ASSERT(_mesh_from_distant->isEqual(meshRef,1e-12));
87 _mesh_from_distant->decrRef();
90 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFetching2D()
92 SALOME_MED::MEDCouplingUMeshCorbaInterface_ptr meshPtr=_objC->get2DMesh();
93 _mesh_from_distant=MEDCoupling::MEDCouplingUMeshClient::New(meshPtr);
94 meshPtr->UnRegister();
95 CORBA::release(meshPtr);
96 CPPUNIT_ASSERT_EQUAL(2,_mesh_from_distant->getSpaceDimension());
97 CPPUNIT_ASSERT_EQUAL(2,_mesh_from_distant->getMeshDimension());
100 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkContentOfFetched2DMesh()
102 MEDCoupling::MEDCouplingUMesh *meshRef=SALOME_TEST::MEDCouplingCorbaServBasicsTest::build2DMesh();
103 CPPUNIT_ASSERT(_mesh_from_distant->isEqual(meshRef,1e-12));
105 _mesh_from_distant->decrRef();
108 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkMultiFetchingToTestMemoryManagement()
110 for(int i=0;i<1000;i++)
112 SALOME_MED::MEDCouplingUMeshCorbaInterface_ptr meshPtr=_objC->get2DMesh();
113 _mesh_from_distant=MEDCoupling::MEDCouplingUMeshClient::New(meshPtr);
114 meshPtr->UnRegister();
115 CORBA::release(meshPtr);
116 MEDCoupling::MEDCouplingUMesh *meshRef=SALOME_TEST::MEDCouplingCorbaServBasicsTest::build2DMesh();
117 CPPUNIT_ASSERT(_mesh_from_distant->isEqual(meshRef,1e-12));
119 _mesh_from_distant->decrRef();
123 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFetching3D()
125 SALOME_MED::MEDCouplingUMeshCorbaInterface_ptr meshPtr=_objC->get3DMesh();
126 _mesh_from_distant=MEDCoupling::MEDCouplingUMeshClient::New(meshPtr);
127 meshPtr->UnRegister();
128 CORBA::release(meshPtr);
129 CPPUNIT_ASSERT_EQUAL(3,_mesh_from_distant->getSpaceDimension());
130 CPPUNIT_ASSERT_EQUAL(3,_mesh_from_distant->getMeshDimension());
133 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkContentOfFetched3DMesh()
135 MEDCoupling::MEDCouplingUMesh *meshRef=SALOME_TEST::MEDCouplingCorbaServBasicsTest::build3DMesh();
136 CPPUNIT_ASSERT(_mesh_from_distant->isEqual(meshRef,1e-12));
138 _mesh_from_distant->decrRef();
141 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFetching3DSurf()
143 SALOME_MED::MEDCouplingUMeshCorbaInterface_ptr meshPtr=_objC->get3DSurfMesh();
144 _mesh_from_distant=MEDCoupling::MEDCouplingUMeshClient::New(meshPtr);
145 meshPtr->UnRegister();
146 CORBA::release(meshPtr);
147 CPPUNIT_ASSERT_EQUAL(3,_mesh_from_distant->getSpaceDimension());
148 CPPUNIT_ASSERT_EQUAL(2,_mesh_from_distant->getMeshDimension());
151 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkContentOfFetched3DSurfMesh()
153 MEDCoupling::MEDCouplingUMesh *meshRef=SALOME_TEST::MEDCouplingCorbaServBasicsTest::build3DSurfMesh();
154 CPPUNIT_ASSERT(_mesh_from_distant->isEqual(meshRef,1e-12));
156 _mesh_from_distant->decrRef();
159 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFetching0D()
161 SALOME_MED::MEDCouplingUMeshCorbaInterface_ptr meshPtr=_objC->get0DMesh();
162 _mesh_from_distant=MEDCoupling::MEDCouplingUMeshClient::New(meshPtr);
163 meshPtr->UnRegister();
164 CORBA::release(meshPtr);
165 MEDCoupling::MEDCouplingUMesh *meshRef=SALOME_TEST::MEDCouplingCorbaServBasicsTest::build0DMesh();
166 CPPUNIT_ASSERT_EQUAL(3,_mesh_from_distant->getSpaceDimension());
167 CPPUNIT_ASSERT_EQUAL(0,_mesh_from_distant->getMeshDimension());
168 CPPUNIT_ASSERT(_mesh_from_distant->isEqual(meshRef,1e-12));
170 _mesh_from_distant->decrRef();
173 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFetchingM1D()
175 SALOME_MED::MEDCouplingUMeshCorbaInterface_ptr meshPtr=_objC->getM1DMesh();
176 _mesh_from_distant=MEDCoupling::MEDCouplingUMeshClient::New(meshPtr);
177 meshPtr->UnRegister();
178 CORBA::release(meshPtr);
179 MEDCoupling::MEDCouplingUMesh *meshRef=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildM1DMesh();
180 CPPUNIT_ASSERT_EQUAL(-1,_mesh_from_distant->getMeshDimension());
181 CPPUNIT_ASSERT(_mesh_from_distant->isEqual(meshRef,1e-12));
183 _mesh_from_distant->decrRef();
186 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFetchingExtruded()
188 SALOME_MED::MEDCouplingExtrudedMeshCorbaInterface_ptr meshPtr=_objC->getExtrudedMesh();
189 MEDCoupling::MEDCouplingMappedExtrudedMesh *meshFromDistant=MEDCoupling::MEDCouplingExtrudedMeshClient::New(meshPtr);
190 meshPtr->UnRegister();
191 CORBA::release(meshPtr);
192 MEDCoupling::MEDCouplingUMesh *meshRef2;
193 MEDCoupling::MEDCouplingMappedExtrudedMesh *meshRef=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildExtrudedMesh(meshRef2);
194 CPPUNIT_ASSERT(meshFromDistant->isEqual(meshRef,1e-12));
195 CPPUNIT_ASSERT(meshFromDistant->getMesh2D()->isEqual(meshRef2,1e-12));
198 meshFromDistant->decrRef();
201 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFetchingCMesh()
203 SALOME_MED::MEDCouplingCMeshCorbaInterface_ptr meshPtr=_objC->getCMesh();
204 MEDCoupling::MEDCouplingCMesh *meshFromDistant=MEDCoupling::MEDCouplingCMeshClient::New(meshPtr);
205 meshPtr->UnRegister();
206 CORBA::release(meshPtr);
207 MEDCoupling::MEDCouplingCMesh *meshRef=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildCMesh();
208 CPPUNIT_ASSERT(meshFromDistant->isEqual(meshRef,1e-12));
210 meshFromDistant->decrRef();
213 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFetchingIMesh()
215 SALOME_MED::MEDCouplingIMeshCorbaInterface_ptr meshPtr=_objC->getIMesh();
216 MEDCoupling::MEDCouplingIMesh *meshFromDistant=MEDCoupling::MEDCouplingIMeshClient::New(meshPtr);
217 meshPtr->UnRegister();
218 CORBA::release(meshPtr);
219 MEDCoupling::MEDCouplingIMesh *meshRef=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildIMesh();
220 CPPUNIT_ASSERT(meshFromDistant->isEqual(meshRef,1e-12));
222 meshFromDistant->decrRef();
225 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFetchingCurveLinearMesh()
227 SALOME_MED::MEDCouplingCurveLinearMeshCorbaInterface_ptr meshPtr=_objC->getCLMesh();
228 MEDCoupling::MEDCouplingCurveLinearMesh *meshFromDistant=MEDCoupling::MEDCouplingCurveLinearMeshClient::New(meshPtr);
229 meshPtr->UnRegister();
230 CORBA::release(meshPtr);
231 MEDCoupling::MEDCouplingCurveLinearMesh *meshRef=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildCLMesh();
232 CPPUNIT_ASSERT(meshFromDistant->isEqual(meshRef,1e-12));
234 meshFromDistant->decrRef();
237 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFetching1SGTUMesh()
239 SALOME_MED::MEDCoupling1SGTUMeshCorbaInterface_ptr meshPtr=_objC->get1SGTUMesh();
240 MEDCoupling::MEDCoupling1SGTUMesh *meshFromDistant=MEDCoupling::MEDCoupling1SGTUMeshClient::New(meshPtr);
241 meshPtr->UnRegister();
242 CORBA::release(meshPtr);
243 MEDCoupling::MEDCoupling1SGTUMesh *meshRef=SALOME_TEST::MEDCouplingCorbaServBasicsTest::build1SGTUMesh();
244 CPPUNIT_ASSERT(meshFromDistant->isEqual(meshRef,1e-12));
246 meshFromDistant->decrRef();
249 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFetching1DGTUMesh()
251 SALOME_MED::MEDCoupling1DGTUMeshCorbaInterface_ptr meshPtr=_objC->get1DGTUMesh();
252 MEDCoupling::MEDCoupling1DGTUMesh *meshFromDistant=MEDCoupling::MEDCoupling1DGTUMeshClient::New(meshPtr);
253 meshPtr->UnRegister();
254 CORBA::release(meshPtr);
255 MEDCoupling::MEDCoupling1DGTUMesh *meshRef=SALOME_TEST::MEDCouplingCorbaServBasicsTest::build1DGTUMesh();
256 CPPUNIT_ASSERT(meshFromDistant->isEqual(meshRef,1e-12));
258 meshFromDistant->decrRef();
261 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaField2DNTFetching()
263 SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr fieldPtr=_objC->getFieldScalarOn2DNT();
264 MEDCoupling::MEDCouplingFieldDouble *fieldCpp=MEDCoupling::MEDCouplingFieldDoubleClient::New(fieldPtr);
265 fieldPtr->UnRegister();
266 CORBA::release(fieldPtr);
267 MEDCoupling::MEDCouplingFieldDouble *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildFieldScalarOn2DNT();
268 CPPUNIT_ASSERT(fieldCpp->isEqual(refField,1.e-12,1.e-15));
269 CPPUNIT_ASSERT_THROW(fieldCpp->setTime(1.23,4,5),INTERP_KERNEL::Exception);
274 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaField2DNTMultiFetching()
276 SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr fieldPtr=_objC->getFieldScalarOn2DNT();
277 MEDCoupling::MEDCouplingFieldDouble *fieldCpp=MEDCoupling::MEDCouplingFieldDoubleClient::New(fieldPtr);
278 MEDCoupling::MEDCouplingFieldDouble *fieldCpp2=MEDCoupling::MEDCouplingFieldDoubleClient::New(fieldPtr);
279 fieldPtr->UnRegister();
280 CORBA::release(fieldPtr);
281 CPPUNIT_ASSERT(fieldCpp->isEqual(fieldCpp2,1.e-12,1.e-15));
283 fieldCpp2->decrRef();
286 void *SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaField2DNTMultiFetchingMTStatic(void *stack)
288 char *stackS=(char *)stack;
289 CORBA::Object_var obj=_orb->string_to_object(stackS);
290 SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr fieldPtr=SALOME_MED::MEDCouplingFieldDoubleCorbaInterface::_narrow(obj);
291 MEDCoupling::MEDCouplingFieldDouble *fieldCpp=MEDCoupling::MEDCouplingFieldDoubleClient::New(fieldPtr);
292 CORBA::release(fieldPtr);
296 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaField2DNTMultiFetchingMT()
298 const int nbOfThreads=8;
299 SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr fieldPtr=_objC->getFieldScalarOn2DNT();
300 //doing nbOfThreads-1 Register.
301 char *ior=_orb->object_to_string(fieldPtr);
302 pthread_t threads[nbOfThreads];
303 MEDCoupling::MEDCouplingFieldDouble *rets[nbOfThreads];
304 for(int i=0;i<nbOfThreads;i++)
305 pthread_create(&threads[i],0,checkCorbaField2DNTMultiFetchingMTStatic,ior);
306 for(int i=0;i<nbOfThreads;i++)
307 pthread_join(threads[i],(void **)&rets[i]);
308 for(int i=0;i<nbOfThreads-1;i++)
309 CPPUNIT_ASSERT(rets[i]->isEqual(rets[i+1],1.e-12,1.e-15));
310 for(int i=0;i<nbOfThreads;i++)
312 fieldPtr->UnRegister();
313 CORBA::release(fieldPtr);
314 CORBA::string_free(ior);
317 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFieldNode2DNTFetching()
319 SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr fieldPtr=_objC->getFieldNodeScalarOn2DNT();
320 MEDCoupling::MEDCouplingFieldDouble *fieldCpp=MEDCoupling::MEDCouplingFieldDoubleClient::New(fieldPtr);
321 fieldPtr->UnRegister();
322 CORBA::release(fieldPtr);
323 MEDCoupling::MEDCouplingFieldDouble *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildFieldNodeScalarOn2DNT();
324 CPPUNIT_ASSERT(fieldCpp->isEqual(refField,1.e-12,1.e-15));
325 CPPUNIT_ASSERT_THROW(fieldCpp->setTime(1.23,4,5),INTERP_KERNEL::Exception);
330 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaField3DNTFetching()
332 SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr fieldPtr=_objC->getFieldScalarOn3DNT();
333 MEDCoupling::MEDCouplingFieldDouble *fieldCpp=MEDCoupling::MEDCouplingFieldDoubleClient::New(fieldPtr);
334 fieldPtr->UnRegister();
335 CORBA::release(fieldPtr);
336 MEDCoupling::MEDCouplingFieldDouble *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildFieldScalarOn3DNT();
337 CPPUNIT_ASSERT(fieldCpp->isEqual(refField,1.e-12,1.e-15));
338 CPPUNIT_ASSERT_THROW(fieldCpp->setTime(1.23,4,5),INTERP_KERNEL::Exception);
343 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaField3DSurfWTFetching()
345 SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr fieldPtr=_objC->getFieldScalarOn3DSurfWT();
347 char *fieldName=fieldPtr->getName();
348 std::string fieldNameCpp(fieldName);
349 CPPUNIT_ASSERT(fieldNameCpp=="toto25");
350 CORBA::string_free(fieldName);
351 SALOME_TYPES::ListOfString *comps=fieldPtr->getInfoOnComponents();
352 CPPUNIT_ASSERT_EQUAL(3,(int)comps->length());
353 CPPUNIT_ASSERT(std::string((*comps)[0])=="aaa");
354 CPPUNIT_ASSERT(std::string((*comps)[1])=="bbbb");
355 CPPUNIT_ASSERT(std::string((*comps)[2])=="ccccc");
358 MEDCoupling::MEDCouplingFieldDouble *fieldCpp=MEDCoupling::MEDCouplingFieldDoubleClient::New(fieldPtr);
359 fieldPtr->UnRegister();
360 CORBA::release(fieldPtr);
361 MEDCoupling::MEDCouplingFieldDouble *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildFieldScalarOn3DSurfWT();
362 CPPUNIT_ASSERT(fieldCpp->isEqual(refField,1.e-12,1.e-15));
364 fieldCpp->getTime(dt,it);
365 CPPUNIT_ASSERT_EQUAL(1,dt);
366 CPPUNIT_ASSERT_EQUAL(4,it);
371 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaField3DSurfCOTIFetching()
373 SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr fieldPtr=_objC->getFieldScalarOn3DSurfCOTI();
374 MEDCoupling::MEDCouplingFieldDouble *fieldCpp=MEDCoupling::MEDCouplingFieldDoubleClient::New(fieldPtr);
375 fieldPtr->UnRegister();
376 CORBA::release(fieldPtr);
377 MEDCoupling::MEDCouplingFieldDouble *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildFieldScalarOn3DSurfCOTI();
378 CPPUNIT_ASSERT(fieldCpp->isEqual(refField,1.e-12,1.e-15));
380 fieldCpp->getStartTime(dt,it);
381 CPPUNIT_ASSERT_EQUAL(1,dt);
382 CPPUNIT_ASSERT_EQUAL(4,it);
383 fieldCpp->getEndTime(dt,it);
384 CPPUNIT_ASSERT_EQUAL(2,dt);
385 CPPUNIT_ASSERT_EQUAL(8,it);
390 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaField2DLTFetching()
392 SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr fieldPtr=_objC->getFieldScalarOn2DLT();
393 MEDCoupling::MEDCouplingFieldDouble *fieldCpp=MEDCoupling::MEDCouplingFieldDoubleClient::New(fieldPtr);
394 fieldPtr->UnRegister();
395 CORBA::release(fieldPtr);
397 const double pos[2]={0.3,-0.2};
398 fieldCpp->getValueOn(pos,10.,res);
399 CPPUNIT_ASSERT_DOUBLES_EQUAL(25.4,res[0],1e-12);
400 CPPUNIT_ASSERT_DOUBLES_EQUAL(25.04,res[1],1e-12);
401 CPPUNIT_ASSERT_DOUBLES_EQUAL(25.004,res[2],1e-12);
402 CPPUNIT_ASSERT_DOUBLES_EQUAL(25.0004,res[3],1e-12);
403 MEDCoupling::MEDCouplingFieldDouble *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildFieldScalarOn2DLT();
404 CPPUNIT_ASSERT(fieldCpp->isEqual(refField,1.e-12,1.e-15));
406 CPPUNIT_ASSERT_DOUBLES_EQUAL(6.7,fieldCpp->getStartTime(dt,it),1e-14);
407 CPPUNIT_ASSERT_EQUAL(25,dt);
408 CPPUNIT_ASSERT_EQUAL(26,it);
409 CPPUNIT_ASSERT_DOUBLES_EQUAL(17.2,fieldCpp->getEndTime(dt,it),1e-14);
410 CPPUNIT_ASSERT_EQUAL(125,dt);
411 CPPUNIT_ASSERT_EQUAL(126,it);
416 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFieldGaussPt2DWTFetching()
418 SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr fieldPtr=_objC->getFieldGaussPt2DWT();
419 MEDCoupling::MEDCouplingFieldDouble *fieldCpp=MEDCoupling::MEDCouplingFieldDoubleClient::New(fieldPtr);
420 fieldPtr->UnRegister();
421 CORBA::release(fieldPtr);
423 MEDCoupling::MEDCouplingFieldDouble *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildFieldGaussPt2DWT();
424 CPPUNIT_ASSERT(fieldCpp->isEqual(refField,1.e-12,1.e-15));
429 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFieldGaussPtNE2DWTFetching()
431 SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr fieldPtr=_objC->getFieldGaussPtNE2DWT();
432 MEDCoupling::MEDCouplingFieldDouble *fieldCpp=MEDCoupling::MEDCouplingFieldDoubleClient::New(fieldPtr);
433 fieldPtr->UnRegister();
434 CORBA::release(fieldPtr);
436 MEDCoupling::MEDCouplingFieldDouble *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildFieldGaussPtNE2DWT();
437 CPPUNIT_ASSERT(fieldCpp->isEqual(refField,1.e-12,1.e-15));
442 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFieldVectorOnExtrudedWT()
444 SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr fieldPtr=_objC->getFieldVectorOnExtrudedWT();
445 MEDCoupling::MEDCouplingFieldDouble *fieldCpp=MEDCoupling::MEDCouplingFieldDoubleClient::New(fieldPtr);
446 fieldPtr->UnRegister();
447 CORBA::release(fieldPtr);
449 MEDCoupling::MEDCouplingFieldDouble *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildFieldVectorOnExtrudedWT();
450 CPPUNIT_ASSERT(fieldCpp->isEqual(refField,1.e-12,1.e-15));
455 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFieldVectorOnCMeshWT()
457 SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr fieldPtr=_objC->getFieldVectorOnCMeshWT();
458 MEDCoupling::MEDCouplingFieldDouble *fieldCpp=MEDCoupling::MEDCouplingFieldDoubleClient::New(fieldPtr);
459 fieldPtr->UnRegister();
460 CORBA::release(fieldPtr);
462 MEDCoupling::MEDCouplingFieldDouble *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildFieldVectorOnCMeshWT();
463 CPPUNIT_ASSERT(fieldCpp->isEqual(refField,1.e-12,1.e-15));
468 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFieldTemplateCellOn2D()
470 SALOME_MED::MEDCouplingFieldTemplateCorbaInterface_ptr fieldPtr=_objC->getFieldTemplateCellOn2D();
471 MEDCoupling::MEDCouplingFieldTemplate *fieldCpp=MEDCoupling::MEDCouplingFieldTemplateClient::New(fieldPtr);
472 fieldPtr->UnRegister();
473 CORBA::release(fieldPtr);
475 MEDCoupling::MEDCouplingFieldTemplate *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildFieldTemplateCellOn2D();
476 CPPUNIT_ASSERT(fieldCpp->isEqual(refField,1.e-12,1.e-15));
481 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFieldTemplateNodeOn2D()
483 SALOME_MED::MEDCouplingFieldTemplateCorbaInterface_ptr fieldPtr=_objC->getFieldTemplateNodeOn2D();
484 MEDCoupling::MEDCouplingFieldTemplate *fieldCpp=MEDCoupling::MEDCouplingFieldTemplateClient::New(fieldPtr);
485 fieldPtr->UnRegister();
486 CORBA::release(fieldPtr);
488 MEDCoupling::MEDCouplingFieldTemplate *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildFieldTemplateNodeOn2D();
489 CPPUNIT_ASSERT(fieldCpp->isEqual(refField,1.e-12,1.e-15));
494 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFieldTemplateGaussPtOn2D()
496 SALOME_MED::MEDCouplingFieldTemplateCorbaInterface_ptr fieldPtr=_objC->getFieldTemplateGaussPtOn2D();
497 MEDCoupling::MEDCouplingFieldTemplate *fieldCpp=MEDCoupling::MEDCouplingFieldTemplateClient::New(fieldPtr);
498 fieldPtr->UnRegister();
499 CORBA::release(fieldPtr);
501 MEDCoupling::MEDCouplingFieldTemplate *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildFieldTemplateGaussPtOn2D();
502 CPPUNIT_ASSERT(fieldCpp->isEqual(refField,1.e-12,1.e-15));
507 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFieldTemplateGaussNEOn2D()
509 SALOME_MED::MEDCouplingFieldTemplateCorbaInterface_ptr fieldPtr=_objC->getFieldTemplateGaussNEOn2D();
510 MEDCoupling::MEDCouplingFieldTemplate *fieldCpp=MEDCoupling::MEDCouplingFieldTemplateClient::New(fieldPtr);
511 fieldPtr->UnRegister();
512 CORBA::release(fieldPtr);
514 MEDCoupling::MEDCouplingFieldTemplate *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildFieldTemplateGaussNEOn2D();
515 CPPUNIT_ASSERT(fieldCpp->isEqual(refField,1.e-12,1.e-15));
520 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaMultiFields1()
522 SALOME_MED::MEDCouplingMultiFieldsCorbaInterface_ptr fieldPtr=_objC->getMultiFields1();
523 MEDCoupling::MEDCouplingMultiFields *fieldCpp=MEDCoupling::MEDCouplingMultiFieldsClient::New(fieldPtr);
524 fieldPtr->UnRegister();
525 CORBA::release(fieldPtr);
527 MEDCoupling::MEDCouplingMultiFields *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildMultiFields1();
528 CPPUNIT_ASSERT(fieldCpp->isEqual(refField,1.e-12,1.e-15));
533 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaArrayDouble1()
535 SALOME_MED::DataArrayDoubleCorbaInterface_ptr fieldPtr=_objC->getArrayDouble1();
537 char *fieldName=fieldPtr->getName();
538 std::string fieldNameCpp(fieldName);
539 CPPUNIT_ASSERT(fieldNameCpp=="toto");
540 CORBA::string_free(fieldName);
541 SALOME_TYPES::ListOfString *comps=fieldPtr->getInfoOnComponents();
542 CPPUNIT_ASSERT_EQUAL(3,(int)comps->length());
543 CPPUNIT_ASSERT(std::string((*comps)[0])=="sss");
544 CPPUNIT_ASSERT(std::string((*comps)[1])=="ppp");
545 CPPUNIT_ASSERT(std::string((*comps)[2])=="ttt");
548 MEDCoupling::DataArrayDouble *fieldCpp=MEDCoupling::DataArrayDoubleClient::New(fieldPtr);
549 fieldPtr->UnRegister();
550 CORBA::release(fieldPtr);
552 MEDCoupling::DataArrayDouble *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildArrayDouble1();
553 CPPUNIT_ASSERT(fieldCpp->isEqual(*refField,1.e-12));
558 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaArrayDouble2()
560 SALOME_MED::DataArrayDoubleCorbaInterface_ptr fieldPtr=_objC->getArrayDouble2();
561 MEDCoupling::DataArrayDouble *fieldCpp=MEDCoupling::DataArrayDoubleClient::New(fieldPtr);
562 fieldPtr->UnRegister();
563 CORBA::release(fieldPtr);
565 MEDCoupling::DataArrayDouble *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildArrayDouble2();
566 CPPUNIT_ASSERT(fieldCpp->isEqual(*refField,1.e-12));
571 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaArrayDouble3()
573 SALOME_MED::DataArrayDoubleCorbaInterface_ptr fieldPtr=_objC->getArrayDouble3();
574 MEDCoupling::DataArrayDouble *fieldCpp=MEDCoupling::DataArrayDoubleClient::New(fieldPtr);
575 fieldPtr->UnRegister();
576 CORBA::release(fieldPtr);
578 MEDCoupling::DataArrayDouble *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildArrayDouble3();
579 CPPUNIT_ASSERT(fieldCpp->isEqual(*refField,1.e-12));
584 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaArrayInt1()
586 SALOME_MED::DataArrayIntCorbaInterface_ptr fieldPtr=_objC->getArrayInt1();
587 MEDCoupling::DataArrayInt *fieldCpp=MEDCoupling::DataArrayIntClient::New(fieldPtr);
588 fieldPtr->UnRegister();
589 CORBA::release(fieldPtr);
591 MEDCoupling::DataArrayInt *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildArrayInt1();
592 CPPUNIT_ASSERT(fieldCpp->isEqual(*refField));
597 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaArrayInt2()
599 SALOME_MED::DataArrayIntCorbaInterface_ptr fieldPtr=_objC->getArrayInt2();
600 MEDCoupling::DataArrayInt *fieldCpp=MEDCoupling::DataArrayIntClient::New(fieldPtr);
601 fieldPtr->UnRegister();
602 CORBA::release(fieldPtr);
604 MEDCoupling::DataArrayInt *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildArrayInt2();
605 CPPUNIT_ASSERT(fieldCpp->isEqual(*refField));
610 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaArrayInt3()
612 SALOME_MED::DataArrayIntCorbaInterface_ptr fieldPtr=_objC->getArrayInt3();
613 MEDCoupling::DataArrayInt *fieldCpp=MEDCoupling::DataArrayIntClient::New(fieldPtr);
614 fieldPtr->UnRegister();
615 CORBA::release(fieldPtr);
617 MEDCoupling::DataArrayInt *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildArrayInt3();
618 CPPUNIT_ASSERT(fieldCpp->isEqual(*refField));
623 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFetchingCoords1()
625 SALOME_MED::MEDCouplingUMeshCorbaInterface_ptr meshPtr=_objC->get3DSurfMesh();
626 SALOME_MED::DataArrayDoubleCorbaInterface_ptr cooPtr=meshPtr->getCoords();
627 meshPtr->UnRegister();
628 CORBA::release(meshPtr);
629 MEDCoupling::DataArrayDouble *cooCpp=MEDCoupling::DataArrayDoubleClient::New(cooPtr);
630 MEDCoupling::MEDCouplingUMesh *meshRef=SALOME_TEST::MEDCouplingCorbaServBasicsTest::build3DSurfMesh();
632 CPPUNIT_ASSERT(meshRef->getCoords()->isEqual(*cooCpp,1e-12));
634 cooPtr->UnRegister();
635 CORBA::release(cooPtr);
640 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaMultiFields2()
642 SALOME_MED::MEDCouplingFieldOverTimeCorbaInterface_ptr fotPtr=_objC->getMultiFields2();
643 MEDCoupling::MEDCouplingFieldOverTimeClient *fotc=MEDCoupling::MEDCouplingFieldOverTimeClient::New(fotPtr);
644 fotPtr->UnRegister();
645 CORBA::release(fotPtr);
647 MEDCoupling::MEDCouplingFieldOverTime *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildMultiFields2();
648 CPPUNIT_ASSERT(fotc->isEqual(refField,1.e-12,1.e-15));
650 std::vector<double> ts=fotc->getTimeSteps();
651 CPPUNIT_ASSERT_EQUAL(6,(int)ts.size());
652 const double expected[6]={0.2,0.7,1.2,1.35,1.7,2.7};
654 CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[i],ts[i],1e-12);
658 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::shutdownServer()
660 _objC->shutdownOrb();