Back to index

salome-med  6.5.0
MEDMEMTest_Support.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "MEDMEMTest.hxx"
00021 
00022 #include "MEDMEM_Mesh.hxx"
00023 #include "MEDMEM_STRING.hxx"
00024 #include "MEDMEM_Support.hxx"
00025 #include "MEDMEM_MedMeshDriver.hxx"
00026 
00027 #include <cppunit/TestAssert.h>
00028 #include <sstream>
00029 #include <cmath>
00030 
00031 // use this define to enable lines, execution of which leads to Segmentation Fault
00032 //#define ENABLE_FAULTS
00033 
00034 // use this define to enable CPPUNIT asserts and fails, showing bugs
00035 //#define ENABLE_FORCED_FAILURES
00036 
00037 using namespace std;
00038 using namespace MEDMEM;
00039 
00040 // #52: MEDMEM_Support.hxx  }  MEDMEMTest_Support.cxx
00041 
00126 void MEDMEMTest::testSupport()
00127 {
00128   MESH * aMesh = MEDMEMTest_createTestMesh();
00129   MESH * aMeshOneMore = MEDMEMTest_createTestMesh();
00130 
00132   // TEST 1 //
00134 
00135   SUPPORT *aSupportOnFaces1 = new SUPPORT;
00136   aSupportOnFaces1->setMesh( aMesh );
00137   aSupportOnFaces1->setEntity( MED_EN::MED_FACE );
00138   aSupportOnFaces1->setAll( true );
00139   aSupportOnFaces1->update();
00140 
00141   SUPPORT *aSupportOnCells1 = new SUPPORT;
00142   aSupportOnCells1->setMesh( aMesh );
00143   aSupportOnCells1->setAll( true );
00144   aSupportOnCells1->update();
00145 
00146   SUPPORT *aSupportOnFaces2=new SUPPORT;
00147   SUPPORT *aSupportOnCells2=new SUPPORT;
00148 
00149   SUPPORT *aSupportOnFaces3 = new SUPPORT;
00150   aSupportOnFaces3->setMesh( aMeshOneMore );
00151   aSupportOnFaces3->setName( "Support On Faces 3" );
00152   aSupportOnFaces3->setEntity( MED_EN::MED_FACE );
00153   aSupportOnFaces3->setAll( true );
00154   aSupportOnFaces3->update();
00155   // entity
00156   CPPUNIT_ASSERT_EQUAL(MED_EN::MED_FACE, aSupportOnFaces1->getEntity());
00157   CPPUNIT_ASSERT_EQUAL(MED_EN::MED_CELL, aSupportOnCells1->getEntity());
00158 
00159   CPPUNIT_ASSERT_EQUAL(MED_EN::MED_CELL, aSupportOnFaces2->getEntity());
00160   CPPUNIT_ASSERT_EQUAL(MED_EN::MED_CELL, aSupportOnCells2->getEntity());
00161 
00162   aSupportOnFaces2->setEntity(MED_EN::MED_FACE);
00163   CPPUNIT_ASSERT_EQUAL(MED_EN::MED_FACE, aSupportOnFaces2->getEntity());
00164 
00165   // isOnAllElements
00166   CPPUNIT_ASSERT(aSupportOnFaces1->isOnAllElements());
00167   CPPUNIT_ASSERT(aSupportOnCells1->isOnAllElements());
00168 
00169   CPPUNIT_ASSERT(!aSupportOnFaces2->isOnAllElements());
00170   CPPUNIT_ASSERT(!aSupportOnCells2->isOnAllElements());
00171 
00172   // mesh and mesh name
00173   CPPUNIT_ASSERT_THROW(aSupportOnFaces1->setMeshName("Mesh 1"), MEDEXCEPTION);
00174 
00175   aSupportOnFaces2->setMeshName("Mesh 1");
00176   aSupportOnCells2->setMeshName("Mesh 1");
00177   CPPUNIT_ASSERT(aSupportOnFaces2->getMeshName() == "Mesh 1");
00178   CPPUNIT_ASSERT(aSupportOnCells2->getMeshName() == "Mesh 1");
00179 
00180   aSupportOnFaces2->setMesh(aMesh);
00181   CPPUNIT_ASSERT_THROW(aSupportOnFaces2->setMeshName("Mesh 1"), MEDEXCEPTION);
00182 
00183   aSupportOnCells1->setMesh(NULL);
00184   aSupportOnCells1->setMeshName("Mesh 1");
00185 
00186   CPPUNIT_ASSERT(aSupportOnFaces1->getMeshName() == "meshing");
00187   CPPUNIT_ASSERT(aSupportOnFaces2->getMeshName() == "meshing");
00188   CPPUNIT_ASSERT(aSupportOnCells1->getMeshName() == "Mesh 1");
00189   CPPUNIT_ASSERT(aSupportOnCells2->getMeshName() == "Mesh 1");
00190 
00191   CPPUNIT_ASSERT(aSupportOnFaces1->getMesh() == aMesh);
00192   CPPUNIT_ASSERT(aSupportOnFaces2->getMesh() == aMesh);
00193   CPPUNIT_ASSERT(aSupportOnCells1->getMesh() == NULL);
00194   CPPUNIT_ASSERT(aSupportOnCells2->getMesh() == NULL);
00195 
00196   // _number
00197   {
00198     int iElem = 1, nbTypes = aSupportOnFaces1->getNumberOfTypes();
00199     const MED_EN::medGeometryElement* types = aSupportOnFaces1->getTypes();
00200     for ( int iType = 0; iType < nbTypes; ++iType )
00201       {
00202         const int nb = aSupportOnFaces1->getNumberOfElements( types[iType] );
00203         const int* nums = aSupportOnFaces1->getNumber       ( types[iType] );
00204         for ( int i = 0; i < nb; ++i )
00205           CPPUNIT_ASSERT_EQUAL( iElem++, nums[i] );
00206       }
00207     iElem = 1, nbTypes = aSupportOnCells1->getNumberOfTypes();
00208     types = aSupportOnCells1->getTypes();
00209     for ( int iType = 0; iType < nbTypes; ++iType )
00210       {
00211         const int nb = aSupportOnCells1->getNumberOfElements( types[iType] );
00212         const int* nums = aSupportOnCells1->getNumber       ( types[iType] );
00213         for ( int i = 0; i < nb; ++i )
00214           CPPUNIT_ASSERT_EQUAL( iElem++, nums[i] );
00215       }
00216   }
00217 
00218   // operator ==
00219   aSupportOnFaces2->setName("Support On Faces 2");
00220   aSupportOnCells2->setName("Support On Cells 2");
00221 
00222   // because aSupportOnFaces1 is on all elements, but aSupportOnFaces2 not
00223   CPPUNIT_ASSERT(!(aSupportOnFaces1 == aSupportOnFaces2));
00224 
00225   aSupportOnCells1->setAll(false);
00226   CPPUNIT_ASSERT(!aSupportOnCells1->isOnAllElements());
00227   // this is only sets flag _isOnAllElts to false, but not clear elements and types
00228   // information, so aSupportOnCells1 is not equal to aSupportOnCells2 at this moment
00229 
00230   //#ifdef ENABLE_FAULTS
00231   // (BUG) SUPPORT::operator= gives "Segmentation Fault" on supports with NULL meshes!!!
00232   //CPPUNIT_ASSERT(!(aSupportOnCells1 == aSupportOnCells2));
00233   //#endif
00234   //#ifdef ENABLE_FORCED_FAILURES
00235   //CPPUNIT_FAIL("SUPPORT::operator= gives Segmentation Fault on supports with NULL meshes!!!");
00236   //#endif
00237 
00238   aSupportOnFaces2->setAll(true);
00239   CPPUNIT_ASSERT(aSupportOnFaces2->isOnAllElements());
00240   // flag _isOnAllElts now is set to true, but we need also to call update()
00241   // to set elements and types information from mesh to this support
00242   CPPUNIT_ASSERT(!(*aSupportOnFaces1 == *aSupportOnFaces2));
00243   aSupportOnFaces2->update();
00244   CPPUNIT_ASSERT(*aSupportOnFaces1 == *aSupportOnFaces2);
00245 
00246   // deep compare
00247   CPPUNIT_ASSERT(aSupportOnFaces1->deepCompare(*aSupportOnFaces2));
00248 
00249   CPPUNIT_ASSERT(!(*aSupportOnFaces1 == *aSupportOnFaces3)); // different mesh pointers
00250   CPPUNIT_ASSERT(aSupportOnFaces1->deepCompare(*aSupportOnFaces3)); // meshes are really equal
00251 
00252   // description
00253   aSupportOnFaces1->setDescription("Support on all faces with mesh pointer");
00254   aSupportOnFaces2->setDescription("Support on all faces with mesh pointer");
00255 
00256   aSupportOnCells1->setDescription("Support on a part of cells with mesh name");
00257   aSupportOnCells2->setDescription("Support on a part of cells with mesh name");
00258 
00259   CPPUNIT_ASSERT(aSupportOnFaces1->getDescription() == "Support on all faces with mesh pointer");
00260   CPPUNIT_ASSERT(aSupportOnFaces2->getDescription() == "Support on all faces with mesh pointer");
00261   CPPUNIT_ASSERT(aSupportOnCells1->getDescription() == "Support on a part of cells with mesh name");
00262   CPPUNIT_ASSERT(aSupportOnCells2->getDescription() == "Support on a part of cells with mesh name");
00263   aSupportOnFaces2->removeReference();
00264   // operator<<
00265   ostringstream ostr1;
00266   ostr1 << *aSupportOnFaces1;
00267   CPPUNIT_ASSERT(ostr1.str() != "");
00268 
00269   ostringstream ostr2;
00270   ostr2 << *aSupportOnCells2;
00271   CPPUNIT_ASSERT(ostr2.str() != "");
00272 
00273   // set/get elements and types information
00274 
00275   // 1. aSupportOnCells1 is not on all elements, but now it contains information
00276   //    about all cells of aMesh, because it was created on mesh and with parameters.
00277   CPPUNIT_ASSERT_EQUAL(3, aSupportOnCells1->getNumberOfTypes());
00278   CPPUNIT_ASSERT(aSupportOnCells1->getTypes() != NULL);
00279 
00280   aSupportOnCells1->setNumberOfGeometricType(0);
00281   CPPUNIT_ASSERT_EQUAL(0, aSupportOnCells1->getNumberOfTypes());
00282   CPPUNIT_ASSERT(aSupportOnCells1->getTypes() == NULL);
00283 
00284   MED_EN::medGeometryElement aSCTypes[2] = 
00285     {
00286       MED_EN::MED_PYRA5, MED_EN::MED_PENTA15
00287     };
00288   aSupportOnCells1->setNumberOfGeometricType(2);
00289   aSupportOnCells1->setGeometricType(aSCTypes);
00290 
00291   CPPUNIT_ASSERT_EQUAL(2, aSupportOnCells1->getNumberOfTypes());
00292   CPPUNIT_ASSERT(aSupportOnCells1->getTypes() != NULL);
00293   CPPUNIT_ASSERT(aSupportOnCells1->getNumberOfElements() == NULL); // reset by setNumberOfGeometricType
00294 
00295   int nbEltsSC[2] = 
00296     {
00297       2, 1
00298     };
00299   aSupportOnCells1->setNumberOfElements(nbEltsSC);
00300 
00301   const int * nbEltsSCBack = aSupportOnCells1->getNumberOfElements();
00302   CPPUNIT_ASSERT_EQUAL(2, aSupportOnCells1->getNumberOfElements(MED_EN::MED_PYRA5));
00303   CPPUNIT_ASSERT_EQUAL(2, nbEltsSCBack[0]);
00304   CPPUNIT_ASSERT_EQUAL(1, aSupportOnCells1->getNumberOfElements(MED_EN::MED_PENTA15));
00305   CPPUNIT_ASSERT_EQUAL(1, nbEltsSCBack[1]);
00306   CPPUNIT_ASSERT_EQUAL(3, aSupportOnCells1->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS));
00307 
00308   // old types
00309   CPPUNIT_ASSERT_THROW(aSupportOnCells1->getNumberOfElements(MED_EN::MED_TETRA4), MEDEXCEPTION);
00310   CPPUNIT_ASSERT_THROW(aSupportOnCells1->getNumberOfElements(MED_EN::MED_HEXA8), MEDEXCEPTION);
00311 
00312   //_number= new MEDSKYLINEARRAY(_numberOfGeometricType,_totalNumberOfElements,index,value,shallowCopy);
00313   int indexSC[3] = 
00314     {
00315       1,3,4
00316     }; // length = nb.types + 1
00317   int valueSC[3] = 
00318     {
00319       21,22,47
00320     }; // length = total nb. of elements
00321   aSupportOnCells1->setNumber(indexSC, valueSC);
00322 
00323   // check number
00324   MEDSKYLINEARRAY * aNumberSCBack = aSupportOnCells1->getnumber();
00325 
00326   CPPUNIT_ASSERT_EQUAL(2, aNumberSCBack->getNumberOf());
00327   CPPUNIT_ASSERT_EQUAL(3, aNumberSCBack->getLength());
00328   const int * ind = aNumberSCBack->getIndex();
00329   const int * val = aNumberSCBack->getValue();
00330   CPPUNIT_ASSERT_EQUAL(1, ind[0]);
00331   CPPUNIT_ASSERT_EQUAL(3, ind[1]);
00332   CPPUNIT_ASSERT_EQUAL(4, ind[2]);
00333   CPPUNIT_ASSERT_EQUAL(21, val[0]);
00334   CPPUNIT_ASSERT_EQUAL(22, val[1]);
00335   CPPUNIT_ASSERT_EQUAL(47, val[2]);
00336 
00337   // 2. aSupportOnCells2 is not on all elements, and now it contains
00338   //    no information about elements of a mesh
00339   CPPUNIT_ASSERT_EQUAL(0, aSupportOnCells2->getNumberOfTypes());
00340   CPPUNIT_ASSERT(aSupportOnCells2->getTypes() == NULL);
00341 
00342   aSupportOnCells2->setNumberOfGeometricType(2);
00343   aSupportOnCells2->setGeometricType(aSCTypes);
00344 
00345   CPPUNIT_ASSERT_EQUAL(2, aSupportOnCells2->getNumberOfTypes());
00346   CPPUNIT_ASSERT(aSupportOnCells2->getTypes() != NULL);
00347 
00348   aSupportOnCells2->setNumberOfElements(nbEltsSC);
00349 
00350   // we create MEDSKYLINEARRAY as pointer, because aSupportOnCells2 will
00351   // become an owner of it, and we must not delete it.
00352   MEDSKYLINEARRAY * aNumberSC = new MEDSKYLINEARRAY(2, 3, indexSC, valueSC);
00353   aSupportOnCells2->setNumber(aNumberSC);
00354 
00355   // check number
00356   const int * aNumberIndexSC = aSupportOnCells2->getNumberIndex();
00357   CPPUNIT_ASSERT_EQUAL(1, aNumberIndexSC[0]);
00358   CPPUNIT_ASSERT_EQUAL(3, aNumberIndexSC[1]);
00359   CPPUNIT_ASSERT_EQUAL(4, aNumberIndexSC[2]);
00360 
00361   const int * aNbPYRA5 = aSupportOnCells2->getNumber(MED_EN::MED_PYRA5);
00362   const int * aNbPENTA15 = aSupportOnCells2->getNumber(MED_EN::MED_PENTA15);
00363   CPPUNIT_ASSERT_THROW(aSupportOnCells2->getNumber(MED_EN::MED_TETRA4), MEDEXCEPTION);
00364 
00365   const int * aNbC = aSupportOnCells2->getNumber(MED_EN::MED_ALL_ELEMENTS);
00366 
00367   CPPUNIT_ASSERT_EQUAL(21, aNbPYRA5[0]);
00368   CPPUNIT_ASSERT_EQUAL(22, aNbPYRA5[1]);
00369   CPPUNIT_ASSERT_EQUAL(47, aNbPENTA15[0]);
00370 
00371   CPPUNIT_ASSERT_EQUAL(21, aNbC[0]);
00372   CPPUNIT_ASSERT_EQUAL(22, aNbC[1]);
00373   CPPUNIT_ASSERT_EQUAL(47, aNbC[2]);
00374 
00375   // getValIndFromGlobalNumber
00376   CPPUNIT_ASSERT_EQUAL(1, aSupportOnCells2->getValIndFromGlobalNumber(21));
00377   CPPUNIT_ASSERT_EQUAL(2, aSupportOnCells2->getValIndFromGlobalNumber(22));
00378   CPPUNIT_ASSERT_EQUAL(3, aSupportOnCells2->getValIndFromGlobalNumber(47));
00379   // not existing element
00380   CPPUNIT_ASSERT_THROW(aSupportOnCells2->getValIndFromGlobalNumber(10), MEDEXCEPTION);
00381 
00382   // compare aSupportOnCells1 and aSupportOnCells2
00383 
00384   // temporary set mesh (because of bug with operator==)
00385   aSupportOnCells1->setMesh(aMesh);
00386   aSupportOnCells2->setMesh(aMesh);
00387 
00388   CPPUNIT_ASSERT_EQUAL(*aSupportOnCells1, *aSupportOnCells2);
00389 
00390   // restore mesh name
00391   aSupportOnCells1->setMesh(NULL);
00392   aSupportOnCells2->setMesh(NULL);
00393   aSupportOnCells1->setMeshName("Mesh 1");
00394   aSupportOnCells2->setMeshName("Mesh 1");
00395   aSupportOnCells2->removeReference();
00396 
00397   // 3. aSupportOnFacesN is on all elements, and it contains
00398   //    information about all faces of aMesh
00399   CPPUNIT_ASSERT_EQUAL(2, aSupportOnFaces1->getNumberOfTypes());
00400   const MED_EN::medGeometryElement* aSF1Types = aSupportOnFaces1->getTypes();
00401   CPPUNIT_ASSERT_EQUAL(MED_EN::MED_TRIA3, aSF1Types[0]);
00402   CPPUNIT_ASSERT_EQUAL(MED_EN::MED_QUAD4, aSF1Types[1]);
00403   //#ifdef ENABLE_FORCED_FAILURES
00404   // (BUG) Comment to method SUPPORT::getTypes() says:
00405   // "If isOnAllElements is false, returns an array of %medGeometryElement types used by the support."
00406   // But in fact it returns types in any case (comment to SUPPORT::setAll() gives more information).
00407   //CPPUNIT_FAIL("Comment and implementation does not match for SUPPORT::getTypes()");
00408   // This concerns also method SUPPORT::update(), being called from constructor,
00409   // which fills internal SUPPORT structures with information about mesh elements
00410   // in case of isOnAllElements == true.
00411   // Also comments and implementation does not match for SUPPORT::getNumberOfElements().
00412   // It seems that in case "isOnAllElements == true" calls like getNumberOfElements()
00413   // must be redirected to mesh, but what if mesh is not set (mesh name used instead)?.
00414   //#endif
00415   const int * nbEltsSF1 = aSupportOnFaces1->getNumberOfElements();
00416   CPPUNIT_ASSERT_EQUAL(4, aSupportOnFaces1->getNumberOfElements(MED_EN::MED_TRIA3));
00417   CPPUNIT_ASSERT_EQUAL(4, nbEltsSF1[0]);
00418   CPPUNIT_ASSERT_EQUAL(4, aSupportOnFaces1->getNumberOfElements(MED_EN::MED_QUAD4));
00419   CPPUNIT_ASSERT_EQUAL(4, nbEltsSF1[1]);
00420   CPPUNIT_ASSERT_EQUAL(8, aSupportOnFaces1->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS));
00421   CPPUNIT_ASSERT_THROW(aSupportOnFaces1->getNumberOfElements(MED_EN::MED_TRIA6), MEDEXCEPTION);
00422   CPPUNIT_ASSERT_THROW(aSupportOnFaces1->getNumberOfElements(MED_EN::MED_QUAD8), MEDEXCEPTION);
00423 
00424   // check type of nodal support
00425   // (021199: MEDMEM::SUPPORT : geometric type when support is on node)
00426   {
00427     const SUPPORT* s = aMesh->getSupportOnAll( MED_EN::MED_NODE );
00428     CPPUNIT_ASSERT_EQUAL( MED_EN::MED_NONE, s->getTypes()[0] );
00429 
00430     SUPPORT* s2 = new SUPPORT( *s );
00431     CPPUNIT_ASSERT_EQUAL( MED_EN::MED_NONE, s2->getTypes()[0] );
00432     const MED_EN::medGeometryElement point1 = MED_EN::MED_POINT1;
00433     s2->setNumberOfGeometricType( 1 );
00434     CPPUNIT_ASSERT_THROW( s2->setGeometricType( &point1 ), MEDEXCEPTION );
00435     s2->removeReference();
00436   }
00437 
00438   //checking makeMesh()
00439   MESH *meshFromSupport=aSupportOnFaces1->makeMesh();
00440   CPPUNIT_ASSERT_EQUAL(4,meshFromSupport->getNumberOfElements(MED_EN::MED_CELL,MED_EN::MED_TRIA3));
00441   CPPUNIT_ASSERT_EQUAL(4,meshFromSupport->getNumberOfElements(MED_EN::MED_CELL,MED_EN::MED_QUAD4));
00442   int nbnodes=  meshFromSupport->getNumberOfNodes();
00443   const int* conn=meshFromSupport->getConnectivity( MED_EN::MED_NODAL, MED_EN::MED_CELL, MED_EN::MED_TRIA3);
00444   for (int i=0; i<12;i++)
00445     CPPUNIT_ASSERT(conn[i]>0 && conn[i]<=nbnodes);
00446   meshFromSupport->removeReference();
00447   const SUPPORT *nodal_support=aSupportOnFaces1->getMesh()->getSupportOnAll( MED_EN::MED_NODE );
00448   CPPUNIT_ASSERT_THROW(nodal_support->makeMesh(), MEDEXCEPTION);
00449   //checking makeMesh() on polygonal support
00450   {
00451     // "poly3D" mesh contains:
00452     // 19 MED_NODE
00453     // 6 MED_TRIA3
00454     // 8 MED_QUAD4
00455     // 3 MED_POLYGON
00456     // 1 MED_TETRA4
00457     // 2 MED_POLYHEDRA
00458     string med_file = getResourceFile("poly3D.med");
00459     MESH *poly_mesh=new MESH;
00460     MED_MESH_RDONLY_DRIVER meshDrv(med_file,poly_mesh);
00461     meshDrv.setMeshName( "poly3D" );
00462     meshDrv.desactivateFacesComputation(); // to have nb of faces like in the file
00463     meshDrv.open();
00464     meshDrv.read();
00465     meshDrv.close();
00466     if ( poly_mesh->getNumberOfElements(MED_EN::MED_FACE, MED_EN::MED_ALL_ELEMENTS) != 17 )
00467       CPPUNIT_FAIL("Nb of faces in mesh from 'poly3D.med' resource file != 17");
00468 
00469     // support on 3 cells and the mesh made from it
00470     const SUPPORT *poly_supp=poly_mesh->getSupportOnAll( MED_CELL );
00471     MESH *poly_supp_mesh=poly_supp->makeMesh();
00472     CPPUNIT_ASSERT_EQUAL(3,poly_supp_mesh->getNumberOfElements(MED_EN::MED_CELL,
00473                                                                MED_EN::MED_ALL_ELEMENTS));
00474     CPPUNIT_ASSERT_EQUAL(1,poly_supp_mesh->getNumberOfElements(MED_EN::MED_CELL,
00475                                                                MED_EN::MED_TETRA4));
00476     CPPUNIT_ASSERT_EQUAL(2,poly_supp_mesh->getNumberOfElements(MED_EN::MED_CELL,
00477                                                                MED_EN::MED_POLYHEDRA));
00478     int nbnodes=poly_supp_mesh->getNumberOfNodes();
00479     const int* conn=poly_supp_mesh->getConnectivity(MED_EN::MED_NODAL,
00480                                                     MED_EN::MED_CELL, MED_EN::MED_ALL_ELEMENTS);
00481     int con_len = 1 * MED_EN::MED_TETRA4 % 100;
00482     for (int i=0; i<con_len;i++)
00483       CPPUNIT_ASSERT(conn[i]>0 && conn[i]<=nbnodes);
00484 
00485     conn = poly_supp_mesh->getConnectivity(MED_EN::MED_NODAL,
00486                                            MED_EN::MED_CELL,MED_EN::MED_POLYHEDRA);
00487     con_len = poly_supp_mesh->getConnectivityLength(MED_EN::MED_NODAL,
00488                                                     MED_EN::MED_CELL,MED_EN::MED_POLYHEDRA);
00489     for (int i=0; i<con_len;i++)
00490       CPPUNIT_ASSERT((conn[i]>0 && conn[i]<=nbnodes) || conn[i]==-1 );
00491     poly_supp_mesh->removeReference();
00492     // support on 17 faces and the mesh made from it
00493     SUPPORT *polygon_supp= new SUPPORT( *poly_mesh->getSupportOnAll( MED_EN::MED_FACE ));
00494     poly_mesh->removeReference();
00495     MESH *polygon_supp_mesh=polygon_supp->makeMesh();
00496     CPPUNIT_ASSERT_EQUAL(17,polygon_supp_mesh->getNumberOfElements(MED_EN::MED_CELL,
00497                                                                    MED_EN::MED_ALL_ELEMENTS));
00498     CPPUNIT_ASSERT_EQUAL(6,polygon_supp_mesh->getNumberOfElements(MED_EN::MED_CELL,
00499                                                                   MED_EN::MED_TRIA3));
00500     CPPUNIT_ASSERT_EQUAL(8,polygon_supp_mesh->getNumberOfElements(MED_EN::MED_CELL,
00501                                                                   MED_EN::MED_QUAD4));
00502     CPPUNIT_ASSERT_EQUAL(3,polygon_supp_mesh->getNumberOfElements(MED_EN::MED_CELL,
00503                                                                   MED_EN::MED_POLYGON));
00504     nbnodes = polygon_supp_mesh->getNumberOfNodes();
00505     conn=polygon_supp_mesh->getConnectivity(MED_EN::MED_NODAL,
00506                                             MED_EN::MED_CELL, MED_EN::MED_ALL_ELEMENTS);
00507     con_len = 6 * MED_EN::MED_TRIA3 % 100 + 8 * MED_EN::MED_QUAD4 % 100;
00508     for (int i=0; i<con_len;i++)
00509       CPPUNIT_ASSERT(conn[i]>0 && conn[i]<=nbnodes);
00510 
00511     conn = polygon_supp_mesh->getConnectivity(MED_EN::MED_NODAL,
00512                                               MED_EN::MED_CELL,MED_EN::MED_POLYGON);
00513     con_len = polygon_supp_mesh->getConnectivityLength(MED_EN::MED_NODAL,
00514                                                        MED_EN::MED_CELL,MED_EN::MED_POLYGON);
00515     for (int i=0; i<con_len;i++)
00516       CPPUNIT_ASSERT(conn[i]>0 && conn[i]<=nbnodes);
00517     polygon_supp_mesh->removeReference();
00518     // make polygon_supp patrial: make it contain 4 QUAD4 and 2 POLYGON
00519     const int nb_types = 2;
00520     const int nb_elems = 4 + 2;
00521     int index[nb_types+1] = 
00522       {
00523         1, 1+4, 1+4+2 
00524       };
00525     int elems[nb_elems] = 
00526       {
00527         8, 10, 11, 13,  16, 17 
00528       };
00529     MED_EN::medGeometryElement types[nb_types] = 
00530       {
00531         MED_EN::MED_QUAD4, MED_EN::MED_POLYGON 
00532       };
00533     MEDSKYLINEARRAY* array = new MEDSKYLINEARRAY(nb_types, nb_elems, index, elems);
00534     polygon_supp->setNumberOfGeometricType( nb_types );
00535     polygon_supp->setGeometricType( types );
00536     polygon_supp->setpartial( array, /*shallowCopy=*/true);
00537 
00538     // 0020912: [CEA 414] setPartial and polygons/polyhedra
00539     // do the same but using another version of setpartial()
00540     const int nb_of_elems[nb_types] = 
00541       {
00542         4, 2 
00543       };
00544     polygon_supp->setpartial("issue 0020912",nb_types, nb_elems, types, nb_of_elems, elems);
00545 
00546     // make mesh from partial support containing polygons
00547     MESH *partial_supp_mesh=polygon_supp->makeMesh();
00548     polygon_supp->removeReference();
00549     CPPUNIT_ASSERT_EQUAL(6,partial_supp_mesh->getNumberOfElements(MED_EN::MED_CELL,
00550                                                                   MED_EN::MED_ALL_ELEMENTS));
00551     CPPUNIT_ASSERT_EQUAL(4,partial_supp_mesh->getNumberOfElements(MED_EN::MED_CELL,types[0]));
00552     CPPUNIT_ASSERT_EQUAL(2,partial_supp_mesh->getNumberOfElements(MED_EN::MED_CELL,types[1]));
00553 
00554     nbnodes = partial_supp_mesh->getNumberOfNodes();
00555     int spaceDimension = partial_supp_mesh->getSpaceDimension();
00556     int meshDimension = partial_supp_mesh->getMeshDimension();
00557     const double *coords = partial_supp_mesh->getCoordinates(MED_FULL_INTERLACE);
00558     const double coordsExpected[45]=
00559       {
00560         3., 2., 2., 3., 2., 0., 4., 1., 0., 4., 1., 2., 0., 1., 2., 2., 0., 2., 2., 0., 0., 0.,
00561         1., 0., 1., 2., 2., 1., 2., 0., 7., 2., 2., 5., 3., 2., 6., 3., 0., 7., 2., 0., 6., 0., 2.
00562       };
00563     CPPUNIT_ASSERT_EQUAL(3,spaceDimension);
00564     CPPUNIT_ASSERT_EQUAL(2,meshDimension);
00565     CPPUNIT_ASSERT_EQUAL(15,nbnodes);
00566     for(int i=0 ; i<spaceDimension*nbnodes; i++)
00567       CPPUNIT_ASSERT_DOUBLES_EQUAL(coordsExpected[i],coords[i],1e-15);
00568     conn=partial_supp_mesh->getConnectivity(MED_EN::MED_NODAL,
00569                                             MED_EN::MED_CELL, MED_EN::MED_ALL_ELEMENTS);
00570     con_len = 4 * MED_EN::MED_QUAD4 % 100;
00571     int connExpected[16]=
00572       {
00573         1, 2, 3, 4, 5, 6, 7, 8, 9, 5, 8, 10, 11, 12, 13, 14
00574       };
00575     for (int i=0; i<con_len;i++)
00576       CPPUNIT_ASSERT_EQUAL(connExpected[i],conn[i]);
00577 
00578     conn = partial_supp_mesh->getConnectivity(MED_EN::MED_NODAL,
00579                                               MED_EN::MED_CELL,MED_EN::MED_POLYGON);
00580     con_len = partial_supp_mesh->getConnectivityLength(MED_EN::MED_NODAL,
00581                                                        MED_EN::MED_CELL,MED_EN::MED_POLYGON);
00582     int connExpectedP[10]=
00583       {
00584         7, 3, 2, 10, 8, 12, 11, 15, 4, 1
00585       };
00586     for (int i=0; i<con_len;i++)
00587       CPPUNIT_ASSERT_EQUAL(connExpectedP[i],conn[i]);
00588     partial_supp_mesh->removeReference();
00589   }
00590 
00591 
00592   // check number
00593   CPPUNIT_ASSERT_NO_THROW(aSupportOnFaces1->getNumberIndex());
00594   CPPUNIT_ASSERT_NO_THROW(aSupportOnFaces1->getNumber(MED_EN::MED_TRIA3));
00595   CPPUNIT_ASSERT_NO_THROW(aSupportOnFaces1->getNumber(MED_EN::MED_QUAD4));
00596   CPPUNIT_ASSERT_NO_THROW(aSupportOnFaces1->getNumber(MED_EN::MED_ALL_ELEMENTS));
00597   CPPUNIT_ASSERT_NO_THROW(aSupportOnFaces1->getnumber());
00598 
00599   // getValIndFromGlobalNumber
00600   CPPUNIT_ASSERT_EQUAL(8, aMesh->getNumberOfElements(MED_EN::MED_FACE, MED_EN::MED_ALL_ELEMENTS));
00601   for (int i = 1; i <= 8; i++) 
00602     {
00603       CPPUNIT_ASSERT_EQUAL(i, aSupportOnFaces1->getValIndFromGlobalNumber(i));
00604     }
00605 
00606   //#ifdef ENABLE_FORCED_FAILURES
00607   // Why methods setNumber do not throw exception in case "isOnAllElements == true",
00608   // like methods getNumber do?
00609   //skl???  CPPUNIT_ASSERT_THROW(aSupportOnFaces1->setNumber(indexSF1, valueSF1), MEDEXCEPTION);
00610   //#endif
00611 
00612   //#ifdef ENABLE_FORCED_FAILURES
00613   // It seems to be dangerous and useless to have method SUPPORT::setTotalNumberOfElements()
00614   //CPPUNIT_FAIL("It seems to be dangerous and useless to have method SUPPORT::setTotalNumberOfElements()");
00615   //#endif
00616 
00617   // following test is commented since method
00618   // setTotalNumberOfElements() is removed.
00619   // setTotalNumberOfElements
00620   //aSupportOnFaces1->setTotalNumberOfElements(1000);
00621   //CPPUNIT_ASSERT_EQUAL(1000, aSupportOnFaces1->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS));
00622   aSupportOnFaces1->removeReference();
00623   // clearDataOnNumbers
00624   aSupportOnCells1->clearDataOnNumbers();
00625   CPPUNIT_ASSERT_EQUAL(0, aSupportOnCells1->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS));
00626   CPPUNIT_ASSERT_EQUAL(0, aSupportOnCells1->getNumberOfTypes());
00627   CPPUNIT_ASSERT_THROW(aSupportOnCells1->getnumber(), MEDEXCEPTION);
00628   aSupportOnCells1->removeReference();
00629 
00631   // test SUPPORT* buildSupportOnNode()
00633 
00634   for (medEntityMesh entity = 0; entity < MED_ALL_ENTITIES; ++entity )
00635     {
00636       if ( entity != MED_NODE && !aMesh->existConnectivity( MED_NODAL, entity ))
00637         continue;
00638       // buildSupportOnNode() from full entity support
00639       const SUPPORT *allEntitySupport=aMesh->getSupportOnAll( entity );
00640       SUPPORT *testSupport=allEntitySupport->buildSupportOnNode();
00641       CPPUNIT_ASSERT(testSupport->isOnAllElements());
00642       CPPUNIT_ASSERT_EQUAL(1,testSupport->getNumberOfTypes());
00643       CPPUNIT_ASSERT_EQUAL(19,testSupport->getNumberOfElements(MED_ALL_ELEMENTS));
00644 
00645       // buildSupportOnNode() from partial support
00646       SUPPORT *partialSupport=new SUPPORT(*allEntitySupport);
00647       partialSupport->setAll( false );
00648       partialSupport->setNumberOfGeometricType( 1 );
00649       partialSupport->setGeometricType( allEntitySupport->getTypes() );
00650 
00651       // no element numbers set
00652       CPPUNIT_ASSERT_THROW(partialSupport->buildSupportOnNode(), MEDEXCEPTION);
00653 
00654       int index[] = 
00655         {
00656           1,2
00657         };
00658       int numbers[] = 
00659         {
00660           1
00661         };
00662       partialSupport->setNumberOfElements(numbers);
00663       partialSupport->setNumber( index, numbers );
00664 
00665       // mesh not set
00666       partialSupport->setMesh(0);
00667       CPPUNIT_ASSERT_THROW(partialSupport->buildSupportOnNode(), MEDEXCEPTION);
00668       partialSupport->setMesh(aMesh);
00669 
00670       testSupport->removeReference();
00671       testSupport =( partialSupport->buildSupportOnNode() );
00672       partialSupport->removeReference();
00673       CPPUNIT_ASSERT(!testSupport->isOnAllElements());
00674       CPPUNIT_ASSERT_EQUAL(1,testSupport->getNumberOfTypes());
00675       int nbNodes = testSupport->getNumberOfElements(MED_ALL_ELEMENTS);
00676       if ( entity == MED_NODE )
00677         CPPUNIT_ASSERT_EQUAL(1, nbNodes);
00678       else
00679         CPPUNIT_ASSERT_EQUAL(aMesh->getCellsTypes(entity)[0].getNumberOfNodes(), nbNodes);
00680       const int * nodes = testSupport->getNumber( MED_ALL_ELEMENTS );
00681       switch ( entity )
00682         {
00683         case MED_CELL:
00684           CPPUNIT_ASSERT_EQUAL(1,nodes[0]);
00685           CPPUNIT_ASSERT_EQUAL(2,nodes[1]);
00686           CPPUNIT_ASSERT_EQUAL(3,nodes[2]);
00687           CPPUNIT_ASSERT_EQUAL(6,nodes[3]);
00688           break;
00689         case MED_FACE:
00690           CPPUNIT_ASSERT_EQUAL(1,nodes[0]);
00691           CPPUNIT_ASSERT_EQUAL(3,nodes[1]);
00692           CPPUNIT_ASSERT_EQUAL(4,nodes[2]);
00693           break;
00694         case MED_NODE:
00695           CPPUNIT_ASSERT_EQUAL(1,nodes[0]);
00696           break;
00697         default:;
00698         }
00699       testSupport->removeReference();
00700     }
00701 
00703   // TEST 2 //
00705 
00706   list<int> nodes137;
00707   nodes137.push_back(1);
00708   nodes137.push_back(3);
00709   nodes137.push_back(7);
00710 
00711   list<int> nodes248;
00712   nodes248.push_back(2);
00713   nodes248.push_back(4);
00714   nodes248.push_back(8);
00715 
00716   list<int> nodes27;
00717   nodes27.push_back(2);
00718   nodes27.push_back(7);
00719 
00720   SUPPORT *aNodes137 = new SUPPORT;
00721   SUPPORT *aNodes248 = new SUPPORT;
00722   SUPPORT *aNodes27 = new SUPPORT;
00723   aNodes137->setMesh( aMesh );
00724   aNodes248->setMesh( aMesh );
00725   aNodes27->setMesh( aMesh );
00726   aNodes137->setName( "Support On Nodes 1,3,7" );
00727   aNodes248->setName( "Support On Nodes 2,4,8" );
00728   aNodes27->setName( "Support On Nodes 2,7" );
00729 
00730   aNodes137->fillFromNodeList(nodes137);
00731   aNodes248->fillFromNodeList(nodes248);
00732   aNodes27->fillFromNodeList(nodes27);
00733 
00734   CPPUNIT_ASSERT_EQUAL(MED_EN::MED_NODE, aNodes137->getEntity());
00735   CPPUNIT_ASSERT_EQUAL(MED_EN::MED_NODE, aNodes248->getEntity());
00736 
00737   list<int>::const_iterator iter137 = nodes137.begin();
00738   list<int>::const_iterator iter248 = nodes248.begin();
00739   for (int i = 1; i <= 3; i++, iter137++, iter248++) 
00740     {
00741       CPPUNIT_ASSERT_EQUAL(i, aNodes137->getValIndFromGlobalNumber(*iter137));
00742       CPPUNIT_ASSERT_EQUAL(i, aNodes248->getValIndFromGlobalNumber(*iter248));
00743     }
00744 
00746 
00747   list<int> faces123;
00748   faces123.push_back(1);
00749   faces123.push_back(2);
00750   faces123.push_back(3);
00751 
00752   list<int> faces135;
00753   faces135.push_back(1);
00754   faces135.push_back(3);
00755   faces135.push_back(5);
00756 
00757   SUPPORT *aFaces123 = new SUPPORT;
00758   aFaces123->setMesh( aMesh );
00759   aFaces123->setName( "Support On Faces 1,2,3" );
00760   aFaces123->setEntity( MED_EN::MED_FACE );
00761   SUPPORT *aFaces135 = new SUPPORT;
00762   aFaces135->setMesh( aMesh );
00763   aFaces135->setName( "Support On Faces 1,3,5" );
00764   aFaces135->setEntity( MED_EN::MED_FACE );
00765 
00766   aFaces123->fillFromElementList(faces123);
00767   aFaces135->fillFromElementList(faces135);
00768 
00769   CPPUNIT_ASSERT_EQUAL(MED_EN::MED_FACE, aFaces123->getEntity());
00770   CPPUNIT_ASSERT_EQUAL(MED_EN::MED_FACE, aFaces135->getEntity());
00771 
00772   list<int>::const_iterator iter123 = faces123.begin();
00773   list<int>::const_iterator iter135 = faces135.begin();
00774   for (int i = 1; i <= 3; i++, iter123++, iter135++) 
00775     {
00776       CPPUNIT_ASSERT_EQUAL(i, aFaces123->getValIndFromGlobalNumber(*iter123));
00777       CPPUNIT_ASSERT_EQUAL(i, aFaces135->getValIndFromGlobalNumber(*iter135));
00778     }
00779 
00780   // substract
00781   SUPPORT * aFaces2 = aFaces123->substract(*aFaces135); // => 2
00782   CPPUNIT_ASSERT_EQUAL(MED_EN::MED_FACE, aFaces2->getEntity());
00783   CPPUNIT_ASSERT_EQUAL(1, aFaces2->getValIndFromGlobalNumber(2));
00784   CPPUNIT_ASSERT_EQUAL(1, aFaces2->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS));
00785 
00786   CPPUNIT_ASSERT_THROW(aFaces123->substract(*aNodes137), MEDEXCEPTION);
00787 
00788   //#ifdef ENABLE_FORCED_FAILURES
00789   // (BUG) SUPPORT::substract() does not work with supports on nodes,
00790   //       because it uses method MESH::buildSupportOnNodeFromElementList(),
00791   //       which does not work if entity = MED_NODE
00792   //SUPPORT * aNodes137mesh = aMesh->buildSupportOnNodeFromElementList(nodes137, MED_EN::MED_NODE);
00793   //delete aNodes137mesh;
00794   SUPPORT * aNodes137sub = aNodes137->substract(*aNodes248); // => 1,3,7
00795   CPPUNIT_ASSERT_EQUAL(*aNodes137sub, *aNodes137);
00796   aNodes137sub->removeReference();
00797   //#endif
00798 
00799   // belongsTo
00800   CPPUNIT_ASSERT(aFaces2->belongsTo(*aFaces123));
00801   CPPUNIT_ASSERT(!aFaces2->belongsTo(*aFaces135));
00802 
00803   CPPUNIT_ASSERT(!aFaces2->belongsTo(*aSupportOnFaces3));
00804   CPPUNIT_ASSERT(aFaces2->belongsTo(*aSupportOnFaces3, /*deepCompare*/true));
00805 
00806   aFaces2->removeReference();
00807 
00808   // getComplement
00809   SUPPORT * aFaces_135 = aFaces135->getComplement(); // => 2,4,6,7,8
00810   CPPUNIT_ASSERT_EQUAL(MED_EN::MED_FACE, aFaces_135->getEntity());
00811   CPPUNIT_ASSERT_EQUAL(5, aFaces_135->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS));
00812 
00813   //#ifdef ENABLE_FORCED_FAILURES
00814   // (BUG) Memory problem in SUPPORT::sub()
00815   // Invalid read of size 4
00816   //    at 0x34902492: MEDMEM::SUPPORT::sub(int, int, int const*, int) (MEDMEM_Support.cxx:852)
00817   //    by 0x3490296B: MEDMEM::SUPPORT::getComplement() const (MEDMEM_Support.cxx:916)
00818   //    by 0x34398F1E: MEDMEMTest::testSupport() (MEDMEMTest_Support.cxx:514)
00819   //  Address 0x352DB91C is 0 bytes after a block of size 12 alloc'd
00820   //    at 0x3414C8E2: operator new[](unsigned) (vg_replace_malloc.c:138)
00821   //    by 0x3490243A: MEDMEM::SUPPORT::sub(int, int, int const*, int) (MEDMEM_Support.cxx:847)
00822   //    by 0x3490296B: MEDMEM::SUPPORT::getComplement() const (MEDMEM_Support.cxx:916)
00823   //    by 0x34398F1E: MEDMEMTest::testSupport() (MEDMEMTest_Support.cxx:514)
00824   //CPPUNIT_FAIL("Memory problem in SUPPORT::sub(): Invalid read of size 4 from array <temp>");
00825   //#endif
00826 
00827   //#ifdef ENABLE_FORCED_FAILURES
00828   // (BUG) SUPPORT::getComplement() does not work with support on nodes,
00829   //       because it uses method MESH::buildSupportOnNodeFromElementList(),
00830   //       which does not work if entity = MED_NODE
00831   SUPPORT * aNodes_137 = aNodes137->getComplement(); // => 2,4,5,6,8,9,10-19
00832   CPPUNIT_ASSERT_EQUAL(MED_EN::MED_NODE, aNodes_137->getEntity());
00833   CPPUNIT_ASSERT_EQUAL(16, aNodes_137->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS));
00834   //#endif
00835 
00836   // intersecting
00837   aFaces_135->intersecting(aFaces123); // => 2
00838   aFaces123->removeReference();
00839   CPPUNIT_ASSERT_EQUAL(1, aFaces_135->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS));
00840   CPPUNIT_ASSERT_EQUAL(1, aFaces_135->getValIndFromGlobalNumber(2));
00841 
00842   //aNodes_137->intersecting(&aNodes248); // => 2,4,8
00843   //CPPUNIT_ASSERT_EQUAL(3, aNodes_137->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS));
00844   //CPPUNIT_ASSERT_EQUAL(*aNodes_137, aNodes248);
00845   aNodes137->intersecting(aNodes248); // => 
00846   {
00847   }
00848   CPPUNIT_ASSERT_EQUAL(0, aNodes137->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS));
00849   aNodes137->removeReference();
00850   // blending
00851   aFaces_135->blending(aFaces135); // => 1,2,3,5
00852   CPPUNIT_ASSERT_EQUAL(4, aFaces_135->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS));
00853 
00854   aNodes248->blending(aNodes27); // => 2,4,7,8
00855   aNodes27->removeReference();
00856   CPPUNIT_ASSERT_EQUAL(4, aNodes248->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS));
00857 
00858   // operator=
00859   SUPPORT *aCopy1=new SUPPORT;
00860   *aCopy1 = *aNodes248;
00861   CPPUNIT_ASSERT_EQUAL(*aNodes248, *aCopy1);
00862   aCopy1->removeReference();
00863   aNodes248->removeReference();
00864   // copy constructor
00865   SUPPORT *aCopy2=new SUPPORT (*aFaces135);
00866   CPPUNIT_ASSERT_EQUAL(*aFaces135, *aCopy2);
00867   aCopy2->removeReference();
00868 
00869   aFaces_135->removeReference();
00870   //#ifdef ENABLE_FORCED_FAILURES
00871   aNodes_137->removeReference();
00872   //#endif
00873 
00874   // profil names
00875   vector<string> aPrN2 (2); // nb. types
00876   aPrN2[0] = "Profil 1";
00877   aPrN2[1] = "Profil 2";
00878   aFaces135->setProfilNames(aPrN2);
00879 
00880   // because on all elements
00881   CPPUNIT_ASSERT_THROW(aSupportOnFaces3->setProfilNames(aPrN2), MEDEXCEPTION);
00882 
00883   // because length of vector is not equal to nb.types
00884   vector<string> aPrN3 (3);
00885   CPPUNIT_ASSERT_THROW(aFaces135->setProfilNames(aPrN3), MEDEXCEPTION);
00886 
00887   vector<string> aPrN2Back = aFaces135->getProfilNames();
00888   CPPUNIT_ASSERT_EQUAL(aPrN2[0], aPrN2Back[0]);
00889   CPPUNIT_ASSERT_EQUAL(aPrN2[1], aPrN2Back[1]);
00890   aFaces135->removeReference();
00891   //#ifdef ENABLE_FORCED_FAILURES
00892   // (BUG) profil names are not copied by copy constructor and operator=,
00893   // not compared by operator==, not dumped in stream by operator<<
00894   //CPPUNIT_FAIL("Not complete implementation for Profil Names");
00895   //#endif
00896 
00898   // TEST 3 //
00900 
00901   SUPPORT *aPartialCells = new SUPPORT;
00902   aPartialCells->setMesh( aMesh );
00903   aPartialCells->setName( "Support On Cells 2,3,4" );
00904   aPartialCells->setEntity( MED_EN::MED_CELL );
00905 
00906   SUPPORT *aPartialNodes = new SUPPORT;
00907   aPartialNodes->setMesh( aMesh );
00908   aPartialNodes->setName( "Support On Nodes 2,3,4" );
00909   aPartialNodes->setEntity( MED_EN::MED_NODE );
00910 
00911   // setpartial
00912   MED_EN::medGeometryElement gtCells[1] = 
00913     {
00914       MED_EN::MED_TETRA4
00915     };
00916   int nbCells[1] = 
00917     {
00918       3
00919     };
00920   int cells[3] = 
00921     {
00922       2,3,4
00923     };
00924   aPartialCells->setpartial("with description", 1, 3, gtCells, nbCells, cells);
00925   CPPUNIT_ASSERT_EQUAL(1, aPartialCells->getValIndFromGlobalNumber(2));
00926   CPPUNIT_ASSERT_EQUAL(2, aPartialCells->getValIndFromGlobalNumber(3));
00927   CPPUNIT_ASSERT_EQUAL(3, aPartialCells->getValIndFromGlobalNumber(4));
00928 
00929   MED_EN::medGeometryElement gtNodes[1] = 
00930     {
00931       MED_EN::MED_NONE
00932     };
00933   aPartialNodes->setNumberOfGeometricType(1);
00934   aPartialNodes->setGeometricType(gtNodes);
00935   int indexSN[2] = 
00936     {
00937       1,4
00938     };
00939   int valueSN[3] = 
00940     {
00941       2,3,4
00942     };
00943   MEDSKYLINEARRAY * aNumberSN = new MEDSKYLINEARRAY(1, 3, indexSN, valueSN);
00944   aPartialNodes->setpartial(aNumberSN, /*shallowCopy*/false);
00945   delete aNumberSN;
00946   CPPUNIT_ASSERT_EQUAL(1, aPartialNodes->getValIndFromGlobalNumber(2));
00947   CPPUNIT_ASSERT_EQUAL(2, aPartialNodes->getValIndFromGlobalNumber(3));
00948   CPPUNIT_ASSERT_EQUAL(3, aPartialNodes->getValIndFromGlobalNumber(4));
00949 
00950   // changeElementsNbs
00951 
00952   // {1,2,3,4,5,6,7,8,9,10} -> {10,9,8,7,6,5,4,3,2,1}
00953   int renumberingFromOldToNew[10] = 
00954     {
00955       10,9,8,7,6,5,4,3,2,1
00956     };
00957 
00958   CPPUNIT_ASSERT_THROW(aPartialCells->changeElementsNbs
00959                        (MED_EN::MED_NODE, renumberingFromOldToNew), MEDEXCEPTION);
00960 
00961   aPartialCells->changeElementsNbs(MED_EN::MED_CELL, renumberingFromOldToNew);
00962   CPPUNIT_ASSERT_EQUAL(3, aPartialCells->getValIndFromGlobalNumber(9));
00963   CPPUNIT_ASSERT_EQUAL(2, aPartialCells->getValIndFromGlobalNumber(8));
00964   CPPUNIT_ASSERT_EQUAL(1, aPartialCells->getValIndFromGlobalNumber(7));
00965 
00966   // {1,2,3,4,5,6,7} -> {1,3,5,7,2,4,6}, {8,9,10,11} -> {8,10,9,11}
00967   int renumberingFromOldToNewP[11] = 
00968     {
00969       1,3,5,7,2,4,6,8,10,9,11
00970     };
00971   aPartialCells->changeElementsNbs(MED_EN::MED_CELL, renumberingFromOldToNewP);
00972   CPPUNIT_ASSERT_EQUAL(3, aPartialCells->getValIndFromGlobalNumber(10));
00973   CPPUNIT_ASSERT_EQUAL(2, aPartialCells->getValIndFromGlobalNumber(8));
00974   CPPUNIT_ASSERT_EQUAL(1, aPartialCells->getValIndFromGlobalNumber(6));
00975   aPartialCells->removeReference();
00976   // this method does not suit for nodes renumbering!
00977   // {1,2,3} -> {3,2,1}, {4,5,6,7} -> {5,6,7,4}
00978   //int renumberingFromOldToNewN[3] = {3,2,1};
00979   //int renumberingFromOldToNewPolyN[4] = {5,6,7,4};
00980   //aPartialNodes.changeElementsNbs(MED_EN::MED_NODE, renumberingFromOldToNewN,
00981   //                                3, renumberingFromOldToNewPolyN);
00982   aPartialNodes->removeReference();
00983   // getBoundaryElements
00984   //#ifdef ENABLE_FAULTS
00985   // (BUG) Segmentation Fault during SUPPORT::getBoundaryElements()
00986   // ??? May be mesh is not complete ???
00987   SUPPORT *aBoundaryFaces = new SUPPORT;
00988   aBoundaryFaces->setMesh( aMesh );
00989   aBoundaryFaces->setName( "meshing boundary faces" );
00990   aBoundaryFaces->setEntity( MED_EN::MED_FACE );
00991   aBoundaryFaces->getBoundaryElements();
00992   //cout << "aBoundaryFaces:" << endl;
00993   //cout << aBoundaryFaces << endl;
00994   aBoundaryFaces->removeReference();
00995   SUPPORT * aBoundaryNodes = aSupportOnFaces3->getBoundaryElements(MED_EN::MED_NODE);
00996   //cout << "aSupportOnFaces3:" << endl;
00997   //cout << aSupportOnFaces3 << endl;
00998   //cout << "aBoundaryNodes:" << endl;
00999   //cout << aBoundaryNodes << endl;
01000   aBoundaryNodes->removeReference();
01001   aSupportOnFaces3->removeReference();
01002   //#endif
01003   //#ifdef ENABLE_FORCED_FAILURES
01004   //CPPUNIT_FAIL("Segmentation Fault during SUPPORT::getBoundaryElements()");
01005   // Invalid write of size 4
01006   //   at 0x3439DFCE: void std::_Construct<int, int>(int*, int const&) (stl_construct.h:81)
01007   //   by 0x3476E4D1: std::vector<int, std::allocator<int> >::push_back(int const&) (stl_vector.h:560)
01008   //   by 0x34763DDB: MEDMEM::CONNECTIVITY::calculateReverseNodalConnectivity() (MEDMEM_Connectivity.cxx:1155)
01009   //   by 0x347655FF: MEDMEM::CONNECTIVITY::calculateDescendingConnectivity() (MEDMEM_Connectivity.cxx:1333)
01010   //   by 0x3476363E: MEDMEM::CONNECTIVITY::getReverseDescendingConnectivity() (MEDMEM_Connectivity.cxx:1090)
01011   //   by 0x34772AB6: MEDMEM::CONNECTIVITY::getReverseConnectivity(long, long) (MEDMEM_Connectivity.hxx:503)
01012   //   by 0x348F4F4B: MEDMEM::MESH::getReverseConnectivity(long, long) const (MEDMEM_Mesh.hxx:848)
01013   //   by 0x348FF559: MEDMEM::SUPPORT::getBoundaryElements() (MEDMEM_Support.cxx:483)
01014   //   by 0x3439C8E5: MEDMEMTest::testSupport() (MEDMEMTest_Support.cxx:641)
01015   //  Address 0x61666A2F is not stack'd, malloc'd or (recently) free'd
01016   //#endif
01017   aMesh->removeReference();
01018   aMeshOneMore->removeReference();
01019 }