Salome HOME
1st step.
[modules/med.git] / src / MEDCouplingCorba / Test / MEDCouplingMeshFieldFactoryComponentClt.cxx
1 // Copyright (C) 2007-2015  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (CEA/DEN)
20
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 "MEDCouplingExtrudedMesh.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"
46 #include <fstream>
47 #include <pthread.h>
48
49 SALOME_TEST::MEDCouplingMeshFieldFactory_ptr SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::_objC;
50
51 MEDCoupling::MEDCouplingUMesh *SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::_mesh_from_distant=0;
52
53 int SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::_argc=0;
54
55 char **SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::_argv=0;
56
57 CORBA::ORB_var SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::_orb;
58
59 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkBaseCorbaFetching()
60 {
61   _orb=CORBA::ORB_init(_argc,_argv);
62   std::ifstream ifs(SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildFileNameForIOR().c_str());
63   std::string ior;
64   ifs >> ior;
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));
68 }
69
70
71
72 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkContentOfFetched1DMesh()
73 {
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));
86   meshRef->decrRef();
87   _mesh_from_distant->decrRef();
88 }
89
90 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFetching2D()
91 {
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());
98 }
99
100 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkContentOfFetched2DMesh()
101 {
102   MEDCoupling::MEDCouplingUMesh *meshRef=SALOME_TEST::MEDCouplingCorbaServBasicsTest::build2DMesh();
103   CPPUNIT_ASSERT(_mesh_from_distant->isEqual(meshRef,1e-12));
104   meshRef->decrRef();
105   _mesh_from_distant->decrRef();
106 }
107
108 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkMultiFetchingToTestMemoryManagement()
109 {
110   for(int i=0;i<1000;i++)
111     {
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));
118       meshRef->decrRef();
119       _mesh_from_distant->decrRef();
120     }
121 }
122
123 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFetching3D()
124 {
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());
131 }
132
133 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkContentOfFetched3DMesh()
134 {
135   MEDCoupling::MEDCouplingUMesh *meshRef=SALOME_TEST::MEDCouplingCorbaServBasicsTest::build3DMesh();
136   CPPUNIT_ASSERT(_mesh_from_distant->isEqual(meshRef,1e-12));
137   meshRef->decrRef();
138   _mesh_from_distant->decrRef();
139 }
140
141 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFetching3DSurf()
142 {
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());
149 }
150
151 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkContentOfFetched3DSurfMesh()
152 {
153   MEDCoupling::MEDCouplingUMesh *meshRef=SALOME_TEST::MEDCouplingCorbaServBasicsTest::build3DSurfMesh();
154   CPPUNIT_ASSERT(_mesh_from_distant->isEqual(meshRef,1e-12));
155   meshRef->decrRef();
156   _mesh_from_distant->decrRef();
157 }
158
159 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFetching0D()
160 {
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));
169   meshRef->decrRef();
170   _mesh_from_distant->decrRef();
171 }
172
173 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFetchingM1D()
174 {
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));
182   meshRef->decrRef();
183   _mesh_from_distant->decrRef();
184 }
185
186 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFetchingExtruded()
187 {
188   SALOME_MED::MEDCouplingExtrudedMeshCorbaInterface_ptr meshPtr=_objC->getExtrudedMesh();
189   MEDCoupling::MEDCouplingExtrudedMesh *meshFromDistant=MEDCoupling::MEDCouplingExtrudedMeshClient::New(meshPtr);
190   meshPtr->UnRegister();
191   CORBA::release(meshPtr);
192   MEDCoupling::MEDCouplingUMesh *meshRef2;
193   MEDCoupling::MEDCouplingExtrudedMesh *meshRef=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildExtrudedMesh(meshRef2);
194   CPPUNIT_ASSERT(meshFromDistant->isEqual(meshRef,1e-12));
195   CPPUNIT_ASSERT(meshFromDistant->getMesh2D()->isEqual(meshRef2,1e-12));
196   meshRef2->decrRef();
197   meshRef->decrRef();
198   meshFromDistant->decrRef();
199 }
200
201 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFetchingCMesh()
202 {
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));
209   meshRef->decrRef();
210   meshFromDistant->decrRef();
211 }
212
213 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFetchingIMesh()
214 {
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));
221   meshRef->decrRef();
222   meshFromDistant->decrRef();
223 }
224
225 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFetchingCurveLinearMesh()
226 {
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));
233   meshRef->decrRef();
234   meshFromDistant->decrRef();
235 }
236
237 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFetching1SGTUMesh()
238 {
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));
245   meshRef->decrRef();
246   meshFromDistant->decrRef();
247 }
248
249 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFetching1DGTUMesh()
250 {
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));
257   meshRef->decrRef();
258   meshFromDistant->decrRef();
259 }
260
261 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaField2DNTFetching()
262 {
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);
270   refField->decrRef();
271   fieldCpp->decrRef();
272 }
273
274 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaField2DNTMultiFetching()
275 {
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));
282   fieldCpp->decrRef();
283   fieldCpp2->decrRef();
284 }
285
286 void *SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaField2DNTMultiFetchingMTStatic(void *stack)
287 {
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);
293   return fieldCpp;
294 }
295
296 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaField2DNTMultiFetchingMT()
297 {
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++)
311     rets[i]->decrRef();
312   fieldPtr->UnRegister();
313   CORBA::release(fieldPtr);
314   CORBA::string_free(ior);
315 }
316
317 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFieldNode2DNTFetching()
318 {
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);
326   refField->decrRef();
327   fieldCpp->decrRef();
328 }
329
330 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaField3DNTFetching()
331 {
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);
339   refField->decrRef();
340   fieldCpp->decrRef();
341 }
342
343 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaField3DSurfWTFetching()
344 {
345   SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr fieldPtr=_objC->getFieldScalarOn3DSurfWT();
346   //
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");
356   delete comps;
357   //
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));
363   int dt,it;
364   fieldCpp->getTime(dt,it);
365   CPPUNIT_ASSERT_EQUAL(1,dt);
366   CPPUNIT_ASSERT_EQUAL(4,it);
367   refField->decrRef();
368   fieldCpp->decrRef();
369 }
370
371 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaField3DSurfCOTIFetching()
372 {
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));
379   int dt,it;
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);
386   refField->decrRef();
387   fieldCpp->decrRef();
388 }
389
390 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaField2DLTFetching()
391 {
392   SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr fieldPtr=_objC->getFieldScalarOn2DLT();
393   MEDCoupling::MEDCouplingFieldDouble *fieldCpp=MEDCoupling::MEDCouplingFieldDoubleClient::New(fieldPtr);
394   fieldPtr->UnRegister();
395   CORBA::release(fieldPtr);
396   double res[4];
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));
405   int dt,it;
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);
412   refField->decrRef();
413   fieldCpp->decrRef();
414 }
415
416 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFieldGaussPt2DWTFetching()
417 {
418   SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr fieldPtr=_objC->getFieldGaussPt2DWT();
419   MEDCoupling::MEDCouplingFieldDouble *fieldCpp=MEDCoupling::MEDCouplingFieldDoubleClient::New(fieldPtr);
420   fieldPtr->UnRegister();
421   CORBA::release(fieldPtr);
422   //
423   MEDCoupling::MEDCouplingFieldDouble *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildFieldGaussPt2DWT();
424   CPPUNIT_ASSERT(fieldCpp->isEqual(refField,1.e-12,1.e-15));
425   refField->decrRef();
426   fieldCpp->decrRef();
427 }
428
429 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFieldGaussPtNE2DWTFetching()
430 {
431   SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr fieldPtr=_objC->getFieldGaussPtNE2DWT();
432   MEDCoupling::MEDCouplingFieldDouble *fieldCpp=MEDCoupling::MEDCouplingFieldDoubleClient::New(fieldPtr);
433   fieldPtr->UnRegister();
434   CORBA::release(fieldPtr);
435   //
436   MEDCoupling::MEDCouplingFieldDouble *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildFieldGaussPtNE2DWT();
437   CPPUNIT_ASSERT(fieldCpp->isEqual(refField,1.e-12,1.e-15));
438   refField->decrRef();
439   fieldCpp->decrRef();
440 }
441
442 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFieldVectorOnExtrudedWT()
443 {
444   SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr fieldPtr=_objC->getFieldVectorOnExtrudedWT();
445   MEDCoupling::MEDCouplingFieldDouble *fieldCpp=MEDCoupling::MEDCouplingFieldDoubleClient::New(fieldPtr);
446   fieldPtr->UnRegister();
447   CORBA::release(fieldPtr);
448   //
449   MEDCoupling::MEDCouplingFieldDouble *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildFieldVectorOnExtrudedWT();
450   CPPUNIT_ASSERT(fieldCpp->isEqual(refField,1.e-12,1.e-15));
451   refField->decrRef();
452   fieldCpp->decrRef();
453 }
454
455 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFieldVectorOnCMeshWT()
456 {
457   SALOME_MED::MEDCouplingFieldDoubleCorbaInterface_ptr fieldPtr=_objC->getFieldVectorOnCMeshWT();
458   MEDCoupling::MEDCouplingFieldDouble *fieldCpp=MEDCoupling::MEDCouplingFieldDoubleClient::New(fieldPtr);
459   fieldPtr->UnRegister();
460   CORBA::release(fieldPtr);
461   //
462   MEDCoupling::MEDCouplingFieldDouble *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildFieldVectorOnCMeshWT();
463   CPPUNIT_ASSERT(fieldCpp->isEqual(refField,1.e-12,1.e-15));
464   refField->decrRef();
465   fieldCpp->decrRef();
466 }
467
468 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFieldTemplateCellOn2D()
469 {
470   SALOME_MED::MEDCouplingFieldTemplateCorbaInterface_ptr fieldPtr=_objC->getFieldTemplateCellOn2D();
471   MEDCoupling::MEDCouplingFieldTemplate *fieldCpp=MEDCoupling::MEDCouplingFieldTemplateClient::New(fieldPtr);
472   fieldPtr->UnRegister();
473   CORBA::release(fieldPtr);
474   //
475   MEDCoupling::MEDCouplingFieldTemplate *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildFieldTemplateCellOn2D();
476   CPPUNIT_ASSERT(fieldCpp->isEqual(refField,1.e-12,1.e-15));
477   refField->decrRef();
478   fieldCpp->decrRef();
479 }
480
481 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFieldTemplateNodeOn2D()
482 {
483   SALOME_MED::MEDCouplingFieldTemplateCorbaInterface_ptr fieldPtr=_objC->getFieldTemplateNodeOn2D();
484   MEDCoupling::MEDCouplingFieldTemplate *fieldCpp=MEDCoupling::MEDCouplingFieldTemplateClient::New(fieldPtr);
485   fieldPtr->UnRegister();
486   CORBA::release(fieldPtr);
487   //
488   MEDCoupling::MEDCouplingFieldTemplate *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildFieldTemplateNodeOn2D();
489   CPPUNIT_ASSERT(fieldCpp->isEqual(refField,1.e-12,1.e-15));
490   refField->decrRef();
491   fieldCpp->decrRef();
492 }
493
494 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFieldTemplateGaussPtOn2D()
495 {
496   SALOME_MED::MEDCouplingFieldTemplateCorbaInterface_ptr fieldPtr=_objC->getFieldTemplateGaussPtOn2D();
497   MEDCoupling::MEDCouplingFieldTemplate *fieldCpp=MEDCoupling::MEDCouplingFieldTemplateClient::New(fieldPtr);
498   fieldPtr->UnRegister();
499   CORBA::release(fieldPtr);
500   //
501   MEDCoupling::MEDCouplingFieldTemplate *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildFieldTemplateGaussPtOn2D();
502   CPPUNIT_ASSERT(fieldCpp->isEqual(refField,1.e-12,1.e-15));
503   refField->decrRef();
504   fieldCpp->decrRef();
505 }
506
507 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFieldTemplateGaussNEOn2D()
508 {
509   SALOME_MED::MEDCouplingFieldTemplateCorbaInterface_ptr fieldPtr=_objC->getFieldTemplateGaussNEOn2D();
510   MEDCoupling::MEDCouplingFieldTemplate *fieldCpp=MEDCoupling::MEDCouplingFieldTemplateClient::New(fieldPtr);
511   fieldPtr->UnRegister();
512   CORBA::release(fieldPtr);
513   //
514   MEDCoupling::MEDCouplingFieldTemplate *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildFieldTemplateGaussNEOn2D();
515   CPPUNIT_ASSERT(fieldCpp->isEqual(refField,1.e-12,1.e-15));
516   refField->decrRef();
517   fieldCpp->decrRef();
518 }
519
520 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaMultiFields1()
521 {
522   SALOME_MED::MEDCouplingMultiFieldsCorbaInterface_ptr fieldPtr=_objC->getMultiFields1();
523   MEDCoupling::MEDCouplingMultiFields *fieldCpp=MEDCoupling::MEDCouplingMultiFieldsClient::New(fieldPtr);
524   fieldPtr->UnRegister();
525   CORBA::release(fieldPtr);
526   //
527   MEDCoupling::MEDCouplingMultiFields *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildMultiFields1();
528   CPPUNIT_ASSERT(fieldCpp->isEqual(refField,1.e-12,1.e-15));
529   refField->decrRef();
530   fieldCpp->decrRef();
531 }
532
533 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaArrayDouble1()
534 {
535   SALOME_MED::DataArrayDoubleCorbaInterface_ptr fieldPtr=_objC->getArrayDouble1();
536   //
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");
546   delete comps;
547   //
548   MEDCoupling::DataArrayDouble *fieldCpp=MEDCoupling::DataArrayDoubleClient::New(fieldPtr);
549   fieldPtr->UnRegister();
550   CORBA::release(fieldPtr);
551   //
552   MEDCoupling::DataArrayDouble *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildArrayDouble1();
553   CPPUNIT_ASSERT(fieldCpp->isEqual(*refField,1.e-12));
554   refField->decrRef();
555   fieldCpp->decrRef();
556 }
557
558 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaArrayDouble2()
559 {
560   SALOME_MED::DataArrayDoubleCorbaInterface_ptr fieldPtr=_objC->getArrayDouble2();
561   MEDCoupling::DataArrayDouble *fieldCpp=MEDCoupling::DataArrayDoubleClient::New(fieldPtr);
562   fieldPtr->UnRegister();
563   CORBA::release(fieldPtr);
564   //
565   MEDCoupling::DataArrayDouble *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildArrayDouble2();
566   CPPUNIT_ASSERT(fieldCpp->isEqual(*refField,1.e-12));
567   refField->decrRef();
568   fieldCpp->decrRef();
569 }
570
571 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaArrayDouble3()
572 {
573   SALOME_MED::DataArrayDoubleCorbaInterface_ptr fieldPtr=_objC->getArrayDouble3();
574   MEDCoupling::DataArrayDouble *fieldCpp=MEDCoupling::DataArrayDoubleClient::New(fieldPtr);
575   fieldPtr->UnRegister();
576   CORBA::release(fieldPtr);
577   //
578   MEDCoupling::DataArrayDouble *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildArrayDouble3();
579   CPPUNIT_ASSERT(fieldCpp->isEqual(*refField,1.e-12));
580   refField->decrRef();
581   fieldCpp->decrRef();
582 }
583
584 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaArrayInt1()
585 {
586   SALOME_MED::DataArrayIntCorbaInterface_ptr fieldPtr=_objC->getArrayInt1();
587   MEDCoupling::DataArrayInt *fieldCpp=MEDCoupling::DataArrayIntClient::New(fieldPtr);
588   fieldPtr->UnRegister();
589   CORBA::release(fieldPtr);
590   //
591   MEDCoupling::DataArrayInt *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildArrayInt1();
592   CPPUNIT_ASSERT(fieldCpp->isEqual(*refField));
593   refField->decrRef();
594   fieldCpp->decrRef();
595 }
596
597 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaArrayInt2()
598 {
599   SALOME_MED::DataArrayIntCorbaInterface_ptr fieldPtr=_objC->getArrayInt2();
600   MEDCoupling::DataArrayInt *fieldCpp=MEDCoupling::DataArrayIntClient::New(fieldPtr);
601   fieldPtr->UnRegister();
602   CORBA::release(fieldPtr);
603   //
604   MEDCoupling::DataArrayInt *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildArrayInt2();
605   CPPUNIT_ASSERT(fieldCpp->isEqual(*refField));
606   refField->decrRef();
607   fieldCpp->decrRef();
608 }
609
610 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaArrayInt3()
611 {
612   SALOME_MED::DataArrayIntCorbaInterface_ptr fieldPtr=_objC->getArrayInt3();
613   MEDCoupling::DataArrayInt *fieldCpp=MEDCoupling::DataArrayIntClient::New(fieldPtr);
614   fieldPtr->UnRegister();
615   CORBA::release(fieldPtr);
616   //
617   MEDCoupling::DataArrayInt *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildArrayInt3();
618   CPPUNIT_ASSERT(fieldCpp->isEqual(*refField));
619   refField->decrRef();
620   fieldCpp->decrRef();
621 }
622
623 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaFetchingCoords1()
624 {
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();
631   //
632   CPPUNIT_ASSERT(meshRef->getCoords()->isEqual(*cooCpp,1e-12));
633   //
634   cooPtr->UnRegister();
635   CORBA::release(cooPtr);
636   cooCpp->decrRef();
637   meshRef->decrRef();
638 }
639
640 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::checkCorbaMultiFields2()
641 {
642   SALOME_MED::MEDCouplingFieldOverTimeCorbaInterface_ptr fotPtr=_objC->getMultiFields2();
643   MEDCoupling::MEDCouplingFieldOverTimeClient *fotc=MEDCoupling::MEDCouplingFieldOverTimeClient::New(fotPtr);
644   fotPtr->UnRegister();
645   CORBA::release(fotPtr);
646   //
647   MEDCoupling::MEDCouplingFieldOverTime *refField=SALOME_TEST::MEDCouplingCorbaServBasicsTest::buildMultiFields2();
648   CPPUNIT_ASSERT(fotc->isEqual(refField,1.e-12,1.e-15));
649   refField->decrRef();
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};
653   for(int i=0;i<6;i++)
654     CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[i],ts[i],1e-12);
655   fotc->decrRef();
656 }
657
658 void SALOME_TEST::MEDCouplingCorbaServBasicsTestClt::shutdownServer()
659 {
660   _objC->shutdownOrb();
661 }