Salome HOME
fb2b339ec7f2df06aa7a1920fef042178547027a
[tools/medcoupling.git] / src / ParaMEDMEMTest / ParaMEDMEMTest.hxx
1 // Copyright (C) 2007-2024  CEA, EDF
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
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);  // 1 and 2 procs
35   CPPUNIT_TEST(testMPIProcessorGroup_boolean);      // 1 and 2 procs
36   CPPUNIT_TEST(testMPIProcessorGroup_rank);         // >=2 procs
37   CPPUNIT_TEST(testBlockTopology_constructor);      // >=2 procs
38   CPPUNIT_TEST(testBlockTopology_serialize);        // 1 proc
39   CPPUNIT_TEST(testInterpKernelDEC_1D);             // 5 procs
40   CPPUNIT_TEST(testInterpKernelDEC_2DCurve);        // 5 procs
41   CPPUNIT_TEST(testInterpKernelDEC_2D);             // 5 procs
42   CPPUNIT_TEST(testInterpKernelDEC2_2D);            // 5 procs
43   CPPUNIT_TEST(testInterpKernelDEC_2DP0P1);         // Not impl.
44   CPPUNIT_TEST(testInterpKernelDEC_3D);             // 3 procs
45   CPPUNIT_TEST(testInterpKernelDECNonOverlapp_2D_P0P0);     // 5 procs
46   CPPUNIT_TEST(testInterpKernelDECNonOverlapp_2D_P0P1P1P0); // 5 procs
47   CPPUNIT_TEST(testInterpKernelDEC2DM1D_P0P0);      // 3 procs
48   CPPUNIT_TEST(testInterpKernelDECPartialProcs);    // 3 procs
49   CPPUNIT_TEST(testInterpKernelDEC3DSurfEmptyBBox); // 3 procs
50   CPPUNIT_TEST(testOverlapDEC1);                    // 3 procs
51   CPPUNIT_TEST(testOverlapDEC1_bis);                // 3 procs
52   CPPUNIT_TEST(testOverlapDEC1_ter);                // 3 procs
53   CPPUNIT_TEST(testOverlapDEC2);                    // 3 procs
54   CPPUNIT_TEST(testOverlapDEC2_bis);                // 3 procs
55   CPPUNIT_TEST(testOverlapDEC2_ter);                // 3 procs
56 //  CPPUNIT_TEST(testOverlapDEC3);                    // 2 procs
57 //  CPPUNIT_TEST(testOverlapDEC4);                    // 2 procs
58   CPPUNIT_TEST(testByStringMPIProcessorGroup_constructor);        // 1 and 2 procs
59   CPPUNIT_TEST(testByStringMPIProcessorGroup_stringconstructor);  // 3 procs
60   CPPUNIT_TEST(testSynchronousEqualInterpKernelWithoutInterpNativeDEC_2D);// 5 procs
61   CPPUNIT_TEST(testSynchronousEqualInterpKernelWithoutInterpDEC_2D);      // 5 procs
62   CPPUNIT_TEST(testSynchronousEqualInterpKernelDEC_2D);                   // 5 procs
63   CPPUNIT_TEST(testSynchronousFasterSourceInterpKernelDEC_2D);            // 5 procs
64   CPPUNIT_TEST(testSynchronousSlowerSourceInterpKernelDEC_2D);            // 5 procs
65   CPPUNIT_TEST(testSynchronousSlowSourceInterpKernelDEC_2D);              // 5 procs
66   CPPUNIT_TEST(testSynchronousFastSourceInterpKernelDEC_2D);              // 5 procs
67   CPPUNIT_TEST(testAsynchronousEqualInterpKernelDEC_2D);                  // 5 procs
68   CPPUNIT_TEST(testAsynchronousFasterSourceInterpKernelDEC_2D);           // 5 procs
69   CPPUNIT_TEST(testAsynchronousSlowerSourceInterpKernelDEC_2D);           // 5 procs
70   CPPUNIT_TEST(testAsynchronousSlowSourceInterpKernelDEC_2D);             // 5 procs
71   CPPUNIT_TEST(testAsynchronousFastSourceInterpKernelDEC_2D);             // 5 procs
72 #ifdef MED_ENABLE_FVM
73   //can be added again after FVM correction for 2D
74   //  CPPUNIT_TEST(testNonCoincidentDEC_2D);
75   CPPUNIT_TEST(testNonCoincidentDEC_3D);
76 #endif
77   CPPUNIT_TEST(testStructuredCoincidentDEC);     // 5 procs
78   CPPUNIT_TEST(testICoco1);           // 2 procs
79   CPPUNIT_TEST(testGauthier1);        // 4 procs
80   CPPUNIT_TEST(testGauthier2);        // >= 2 procs
81   CPPUNIT_TEST(testGauthier3_1);      // 4 procs
82   CPPUNIT_TEST(testGauthier3_2);      // 4 procs
83   CPPUNIT_TEST(testGauthier3_3);      // 5 procs
84   CPPUNIT_TEST(testGauthier3_4);      // 5 procs
85   CPPUNIT_TEST(testGauthier4);        // 3 procs
86   CPPUNIT_TEST(testFabienAPI1);       // 3 procs
87   CPPUNIT_TEST(testFabienAPI2);       // 3 procs
88
89   CPPUNIT_TEST(testParallelLoad1);   // 2 procs
90   CPPUNIT_TEST(testParallelLoad2);   // 3 procs
91   CPPUNIT_TEST(testParallelLoad3);   // 2 procs
92   CPPUNIT_TEST(testParallelLoad4);   // 2 procs
93   CPPUNIT_TEST(testParallelLoad5);   // 2 procs
94   CPPUNIT_TEST_SUITE_END();
95
96 public:
97  
98   ParaMEDMEMTest():CppUnit::TestFixture(){}
99   ~ParaMEDMEMTest(){}  
100   void setUp(){}
101   void tearDown(){}
102   void testMPIProcessorGroup_constructor();
103   void testMPIProcessorGroup_boolean();
104   void testMPIProcessorGroup_rank();
105   void testBlockTopology_constructor();
106   void testBlockTopology_serialize();
107   void testInterpKernelDEC_1D();
108   void testInterpKernelDEC_2DCurve();
109   void testInterpKernelDEC_2D();
110   void testInterpKernelDEC2_2D();
111   void testInterpKernelDEC_2DP0P1();
112   void testInterpKernelDEC_3D();
113   void testInterpKernelDECNonOverlapp_2D_P0P0();
114   void testInterpKernelDECNonOverlapp_2D_P0P1P1P0();
115   void testInterpKernelDEC2DM1D_P0P0();
116   void testInterpKernelDECPartialProcs();
117   void testInterpKernelDEC3DSurfEmptyBBox();
118   void testOverlapDEC1();
119   void testOverlapDEC1_bis();
120   void testOverlapDEC1_ter();
121   void testOverlapDEC2();
122   void testOverlapDEC2_bis();
123   void testOverlapDEC2_ter();
124   void testOverlapDEC3();
125 //  void testOverlapDEC3_bis();
126   void testOverlapDEC4();
127   void testByStringMPIProcessorGroup_constructor();
128   void testByStringMPIProcessorGroup_stringconstructor();
129 #ifdef MED_ENABLE_FVM
130   void testNonCoincidentDEC_2D();
131   void testNonCoincidentDEC_3D();
132 #endif
133   void testStructuredCoincidentDEC();
134   void testSynchronousEqualInterpKernelWithoutInterpNativeDEC_2D();
135   void testSynchronousEqualInterpKernelWithoutInterpDEC_2D();
136   void testSynchronousEqualInterpKernelDEC_2D();
137   void testSynchronousFasterSourceInterpKernelDEC_2D();
138   void testSynchronousSlowerSourceInterpKernelDEC_2D();
139   void testSynchronousSlowSourceInterpKernelDEC_2D();
140   void testSynchronousFastSourceInterpKernelDEC_2D();
141
142   void testAsynchronousEqualInterpKernelDEC_2D();
143   void testAsynchronousFasterSourceInterpKernelDEC_2D();
144   void testAsynchronousSlowerSourceInterpKernelDEC_2D();
145   void testAsynchronousSlowSourceInterpKernelDEC_2D();
146   void testAsynchronousFastSourceInterpKernelDEC_2D();
147   //
148   void testICoco1();
149   void testGauthier1();
150   void testGauthier2();
151   void testGauthier3_1();
152   void testGauthier3_2();
153   void testGauthier3_3();
154   void testGauthier3_4();
155   void testGauthier4();
156   void testFabienAPI1();
157   void testFabienAPI2();
158
159   void testParallelLoad1();
160   void testParallelLoad2();
161   void testParallelLoad3();
162   void testParallelLoad4();
163   void testParallelLoad5();
164
165   std::string getTmpDirectory();
166   std::string makeTmpFile( const std::string&, const std::string& = "" );
167
168 private:
169 #ifdef MED_ENABLE_FVM
170   void testNonCoincidentDEC(const std::string& filename1, 
171                             const std::string& meshname1, 
172                             const std::string& filename2, 
173                             const std::string& meshname2,
174                             int nbprocsource, double epsilon);
175 #endif
176   void testAsynchronousInterpKernelDEC_2D(double dtA, double tmaxA, 
177                                           double dtB, double tmaxB,
178                                           bool WithPointToPoint, bool Asynchronous, bool WithInterp, const char *srcMeth, const char *targetMeth);
179   void testInterpKernelDEC_2D_(const char *srcMeth, const char *targetMeth);
180   void testInterpKernelDEC2_2D_(const char *srcMeth, const char *targetMeth);
181   void testInterpKernelDEC_3D_(const char *srcMeth, const char *targetMeth);
182   void testGauthier3_GEN(bool, int);
183
184
185 };
186
187 // to automatically remove temporary files from disk
188 class ParaMEDMEMTest_TmpFilesRemover
189 {
190 public:
191   ParaMEDMEMTest_TmpFilesRemover() {}
192   ~ParaMEDMEMTest_TmpFilesRemover();
193   bool Register(const std::string theTmpFile);
194
195 private:
196   std::set<std::string> myTmpFiles;
197 };
198
199 /*!
200  *  Tool to print array to stream.
201  */
202 template<class T>
203 void ParaMEDMEMTest_DumpArray (std::ostream & stream, const T* array, const int length, const std::string text)
204 {
205   stream << text << ": {";
206   if (length > 0) {
207     stream << array[0];
208     for (int i = 1; i < length; i++) {
209       stream << ", " << array[i];
210     }
211   }
212   stream << "}" << std::endl;
213 }
214
215 #endif