Salome HOME
Merge from V6_main_20120808 08Aug12
[tools/medcoupling.git] / src / MEDPartitioner / Test / MEDPARTITIONERTest.hxx
1 // Copyright (C) 2007-2012  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.
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
20 #ifndef __MEDPARTITIONERTEST_HXX__
21 #define __MEDPARTITIONERTEST_HXX__
22
23 #ifdef WIN32
24 # if defined MEDPARTITIONERTEST_EXPORTS || defined MEDPARTITIONERTest_EXPORTS
25 #  define MEDPARTITIONERTEST_EXPORT __declspec( dllexport )
26 # else
27 #  define MEDPARTITIONERTEST_EXPORT __declspec( dllimport )
28 # endif
29 #else
30 # define MEDPARTITIONERTEST_EXPORT
31 #endif
32
33
34 #include <cppunit/extensions/HelperMacros.h>
35
36 #include <set>
37 #include <string>
38 #include <iostream>
39
40 #include "MEDCouplingUMesh.hxx"
41 #include "MEDCouplingExtrudedMesh.hxx"
42 #include "MEDCouplingFieldDouble.hxx"
43
44 class MEDPARTITIONERTEST_EXPORT MEDPARTITIONERTest : public CppUnit::TestFixture
45 {
46   CPPUNIT_TEST_SUITE( MEDPARTITIONERTest );
47   CPPUNIT_TEST( testMeshCollectionSingle );
48   CPPUNIT_TEST( testMeshCollectionXml );
49 #if defined(MED_ENABLE_METIS)
50   CPPUNIT_TEST( testMeshCollectionSinglePartitionMetis );
51   CPPUNIT_TEST( testMeshCollectionComplexPartitionMetis );
52   CPPUNIT_TEST( testMetisSmallSize );
53 #endif
54 #if defined(MED_ENABLE_SCOTCH)
55   CPPUNIT_TEST( testMeshCollectionSinglePartitionScotch );
56   CPPUNIT_TEST( testMeshCollectionComplexPartitionScotch );
57   CPPUNIT_TEST( testScotchSmallSize );
58 #endif
59   
60 #if defined(HAVE_MPI2)
61 #if defined(MED_ENABLE_PARMETIS)
62   //test with mpi on system
63   CPPUNIT_TEST( testMpirunSmallSize );
64   CPPUNIT_TEST( testMpirunMedianSize );
65   CPPUNIT_TEST( testMpirunHugeSize );
66 #endif
67 #endif
68
69   //CPPUNIT_TEST( deleteTestMeshes );
70   CPPUNIT_TEST_SUITE_END();
71
72 public:
73
74   //global use
75   int _ni;  //nb of hexa9
76   int _nj;
77   int _nk;
78   int _ntot;
79   std::string _file_name; //initial test mesh file med CUBE3D
80   std::string _file_name_with_faces; //initial test mesh file med CUBE3D plus a set of faces
81   std::string _file_name2; //initial test mesh file med CARRE3D
82   std::string _file_name_huge_xml;
83   int _nb_target_huge;
84   std::string _mesh_name; //initial test mesh file med
85   int _verbose;
86   
87   //for utils
88   void setSize(int ni, int nj, int nk);
89   void setSmallSize();
90   void setMedianSize();
91   void setbigSize();
92   std::string getPartitionerExe() const;
93   ParaMEDMEM::MEDCouplingUMesh * buildCUBE3DMesh();
94   ParaMEDMEM::MEDCouplingUMesh * buildFACE3DMesh();
95   ParaMEDMEM::MEDCouplingUMesh * buildCARRE3DMesh();
96   ParaMEDMEM::MEDCouplingFieldDouble * buildVecFieldOnCells(std::string myfileName);
97   ParaMEDMEM::MEDCouplingFieldDouble * buildVecFieldOnNodes();
98   void createTestMeshWithoutField();
99   void createTestMeshWithVecFieldOnCells();
100   void createTestMeshWithVecFieldOnNodes();
101   void verifyTestMeshWithVecFieldOnNodes();
102   void verifyMetisOrScotchMedpartitionerOnSmallSizeForMesh(std::string MetisOrScotch);
103   void verifyMetisOrScotchMedpartitionerOnSmallSizeForFieldOnCells(std::string MetisOrScotch);
104   void verifyMetisOrScotchMedpartitionerOnSmallSizeForFieldOnGaussNe(std::string MetisOrScotch);
105   void verifyMedpartitionerOnSmallSizeForMesh();
106   void verifyMedpartitionerOnSmallSizeForFieldOnCells();
107   void verifyMedpartitionerOnSmallSizeForFieldOnGaussNe();
108   void createTestMeshes();
109   void createHugeTestMesh(int ni, int nj, int nk, int nbx, int nby, int nbz, int nbTarget);
110   void launchMetisOrScotchMedpartitionerOnTestMeshes(std::string MetisOrScotch);
111   void launchMedpartitionerOnTestMeshes();
112   void launchMedpartitionerOnHugeTestMeshes();
113   void deleteTestMeshes();
114   
115   //for CPPUNIT_TEST
116   void setUp();
117   void tearDown();
118   void testMeshCollectionSingle();
119   void testMeshCollectionXml();
120 #if defined(MED_ENABLE_METIS)
121   void testMeshCollectionSinglePartitionMetis();
122   void testMeshCollectionComplexPartitionMetis();
123   void testMetisSmallSize();
124 #endif
125 #if defined(MED_ENABLE_SCOTCH)
126   void testMeshCollectionSinglePartitionScotch();
127   void testMeshCollectionComplexPartitionScotch();
128   void testScotchSmallSize();
129 #endif
130   
131 #if defined(HAVE_MPI2)
132   void testMpirunSmallSize();
133   void testMpirunMedianSize();
134   void testMpirunHugeSize();
135 #endif
136 };
137
138 #endif