Salome HOME
8f83469ae47bfda741b6a8a3d01a5cdae492f122
[modules/med.git] / src / ParaMEDMEMTest / ParaMEDMEMTest.hxx
1 // Copyright (C) 2007-2013  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 _ParaMEDMEMTEST_HXX_
21 #define _ParaMEDMEMTEST_HXX_
22
23 #include <cppunit/extensions/HelperMacros.h>
24
25 #include <set>
26 #include <string>
27 #include <iostream>
28 #include "mpi.h"
29
30
31 class ParaMEDMEMTest : public CppUnit::TestFixture
32 {
33   CPPUNIT_TEST_SUITE( ParaMEDMEMTest );
34   CPPUNIT_TEST(testMPIProcessorGroup_constructor);
35   CPPUNIT_TEST(testMPIProcessorGroup_boolean);
36   CPPUNIT_TEST(testMPIProcessorGroup_rank);
37   CPPUNIT_TEST(testBlockTopology_constructor);
38   CPPUNIT_TEST(testBlockTopology_serialize);
39   CPPUNIT_TEST(testInterpKernelDEC_1D);
40   CPPUNIT_TEST(testInterpKernelDEC_2DCurve);
41   CPPUNIT_TEST(testInterpKernelDEC_2D);
42   CPPUNIT_TEST(testInterpKernelDEC2_2D);
43   CPPUNIT_TEST(testInterpKernelDEC_2DP0P1);
44   CPPUNIT_TEST(testInterpKernelDEC_3D);
45   CPPUNIT_TEST(testInterpKernelDECNonOverlapp_2D_P0P0);
46   CPPUNIT_TEST(testInterpKernelDECNonOverlapp_2D_P0P1P1P0);
47   CPPUNIT_TEST(testInterpKernelDEC2DM1D_P0P0);
48   CPPUNIT_TEST(testInterpKernelDECPartialProcs);
49   CPPUNIT_TEST(testInterpKernelDEC3DSurfEmptyBBox);
50   CPPUNIT_TEST(testOverlapDEC1);
51
52   CPPUNIT_TEST(testSynchronousEqualInterpKernelWithoutInterpNativeDEC_2D);
53   CPPUNIT_TEST(testSynchronousEqualInterpKernelWithoutInterpDEC_2D);
54   CPPUNIT_TEST(testSynchronousEqualInterpKernelDEC_2D);
55   CPPUNIT_TEST(testSynchronousFasterSourceInterpKernelDEC_2D);
56   CPPUNIT_TEST(testSynchronousSlowerSourceInterpKernelDEC_2D);
57   CPPUNIT_TEST(testSynchronousSlowSourceInterpKernelDEC_2D);
58   CPPUNIT_TEST(testSynchronousFastSourceInterpKernelDEC_2D);
59   CPPUNIT_TEST(testAsynchronousEqualInterpKernelDEC_2D);
60   CPPUNIT_TEST(testAsynchronousFasterSourceInterpKernelDEC_2D);
61   CPPUNIT_TEST(testAsynchronousSlowerSourceInterpKernelDEC_2D);
62   CPPUNIT_TEST(testAsynchronousSlowSourceInterpKernelDEC_2D);
63   CPPUNIT_TEST(testAsynchronousFastSourceInterpKernelDEC_2D);
64 #ifdef MED_ENABLE_FVM
65   //can be added again after FVM correction for 2D
66   //  CPPUNIT_TEST(testNonCoincidentDEC_2D);
67   CPPUNIT_TEST(testNonCoincidentDEC_3D); 
68 #endif
69   CPPUNIT_TEST(testStructuredCoincidentDEC);
70   CPPUNIT_TEST(testStructuredCoincidentDEC);
71   CPPUNIT_TEST(testICocoTrio1);
72   CPPUNIT_TEST(testGauthier1);
73   CPPUNIT_TEST(testGauthier2);
74   CPPUNIT_TEST(testGauthier3);
75   CPPUNIT_TEST(testFabienAPI1);
76   CPPUNIT_TEST(testFabienAPI2);
77   CPPUNIT_TEST(testMEDLoaderRead1);
78   CPPUNIT_TEST(testMEDLoaderPolygonRead);
79   CPPUNIT_TEST(testMEDLoaderPolyhedronRead);
80   CPPUNIT_TEST_SUITE_END();
81   
82
83 public:
84  
85   ParaMEDMEMTest():CppUnit::TestFixture(){}
86   ~ParaMEDMEMTest(){}  
87   void setUp(){}
88   void tearDown(){}
89   void testMPIProcessorGroup_constructor();
90   void testMPIProcessorGroup_boolean();
91   void testMPIProcessorGroup_rank();
92   void testBlockTopology_constructor();
93   void testBlockTopology_serialize();
94   void testInterpKernelDEC_1D();
95   void testInterpKernelDEC_2DCurve();
96   void testInterpKernelDEC_2D();
97   void testInterpKernelDEC2_2D();
98   void testInterpKernelDEC_2DP0P1();
99   void testInterpKernelDEC_3D();
100   void testInterpKernelDECNonOverlapp_2D_P0P0();
101   void testInterpKernelDECNonOverlapp_2D_P0P1P1P0();
102   void testInterpKernelDEC2DM1D_P0P0();
103   void testInterpKernelDECPartialProcs();
104   void testInterpKernelDEC3DSurfEmptyBBox();
105   void testOverlapDEC1();
106 #ifdef MED_ENABLE_FVM
107   void testNonCoincidentDEC_2D();
108   void testNonCoincidentDEC_3D();
109 #endif
110   void testStructuredCoincidentDEC();
111   void testSynchronousEqualInterpKernelWithoutInterpNativeDEC_2D();
112   void testSynchronousEqualInterpKernelWithoutInterpDEC_2D();
113   void testSynchronousEqualInterpKernelDEC_2D();
114   void testSynchronousFasterSourceInterpKernelDEC_2D();
115   void testSynchronousSlowerSourceInterpKernelDEC_2D();
116   void testSynchronousSlowSourceInterpKernelDEC_2D();
117   void testSynchronousFastSourceInterpKernelDEC_2D();
118
119   void testAsynchronousEqualInterpKernelDEC_2D();
120   void testAsynchronousFasterSourceInterpKernelDEC_2D();
121   void testAsynchronousSlowerSourceInterpKernelDEC_2D();
122   void testAsynchronousSlowSourceInterpKernelDEC_2D();
123   void testAsynchronousFastSourceInterpKernelDEC_2D();
124   //
125   void testICocoTrio1();
126   void testGauthier1();
127   void testGauthier2();
128   void testGauthier3();
129   void testFabienAPI1();
130   void testFabienAPI2();
131   //
132   void testMEDLoaderRead1();
133   void testMEDLoaderPolygonRead();
134   void testMEDLoaderPolyhedronRead();
135   void testMEDLoaderWrite1();
136   void testMEDLoaderPolygonWrite();
137
138   std::string getResourceFile( const std::string& );
139   std::string getTmpDirectory();
140   std::string makeTmpFile( const std::string&, const std::string& = "" );
141
142 private:
143 #ifdef MED_ENABLE_FVM
144   void testNonCoincidentDEC(const std::string& filename1, 
145                             const std::string& meshname1, 
146                             const std::string& filename2, 
147                             const std::string& meshname2,
148                             int nbprocsource, double epsilon);
149 #endif
150   void testAsynchronousInterpKernelDEC_2D(double dtA, double tmaxA, 
151                                           double dtB, double tmaxB,
152                                           bool WithPointToPoint, bool Asynchronous, bool WithInterp, const char *srcMeth, const char *targetMeth);
153   void testInterpKernelDEC_2D_(const char *srcMeth, const char *targetMeth);
154   void testInterpKernelDEC2_2D_(const char *srcMeth, const char *targetMeth);
155   void testInterpKernelDEC_3D_(const char *srcMeth, const char *targetMeth);
156 };
157
158 // to automatically remove temporary files from disk
159 class ParaMEDMEMTest_TmpFilesRemover
160 {
161 public:
162   ParaMEDMEMTest_TmpFilesRemover() {}
163   ~ParaMEDMEMTest_TmpFilesRemover();
164   bool Register(const std::string theTmpFile);
165
166 private:
167   std::set<std::string> myTmpFiles;
168 };
169
170 /*!
171  *  Tool to print array to stream.
172  */
173 template<class T>
174 void ParaMEDMEMTest_DumpArray (std::ostream & stream, const T* array, const int length, const std::string text)
175 {
176   stream << text << ": {";
177   if (length > 0) {
178     stream << array[0];
179     for (int i = 1; i < length; i++) {
180       stream << ", " << array[i];
181     }
182   }
183   stream << "}" << std::endl;
184 }
185
186 #endif