Salome HOME
Merge from BR_V5_DEV 16Feb09
[tools/medcoupling.git] / src / ParaMEDMEM / Test / ParaMEDMEMTest.hxx
1 //  Copyright (C) 2007-2008  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 #ifndef _ParaMEDMEMTEST_HXX_
20 #define _ParaMEDMEMTEST_HXX_
21
22 #include <cppunit/extensions/HelperMacros.h>
23
24 #include <set>
25 #include <string>
26 #include <iostream>
27 #include "mpi.h"
28
29
30 class ParaMEDMEMTest : public CppUnit::TestFixture
31 {
32   CPPUNIT_TEST_SUITE( ParaMEDMEMTest );
33   CPPUNIT_TEST(testMPIProcessorGroup_constructor);
34   CPPUNIT_TEST(testMPIProcessorGroup_boolean);
35   CPPUNIT_TEST(testMPIProcessorGroup_rank);
36   CPPUNIT_TEST(testBlockTopology_constructor);
37   CPPUNIT_TEST(testBlockTopology_serialize);
38   CPPUNIT_TEST(testIntersectionDEC_2D);
39   CPPUNIT_TEST(testIntersectionDEC_2DP0P1);
40
41   CPPUNIT_TEST(testSynchronousEqualIntersectionWithoutInterpNativeDEC_2D);
42   CPPUNIT_TEST(testSynchronousEqualIntersectionWithoutInterpDEC_2D);
43   CPPUNIT_TEST(testSynchronousEqualIntersectionDEC_2D);
44   CPPUNIT_TEST(testSynchronousFasterSourceIntersectionDEC_2D);
45   CPPUNIT_TEST(testSynchronousSlowerSourceIntersectionDEC_2D);
46   CPPUNIT_TEST(testSynchronousSlowSourceIntersectionDEC_2D);
47   CPPUNIT_TEST(testSynchronousFastSourceIntersectionDEC_2D);
48   CPPUNIT_TEST(testAsynchronousEqualIntersectionDEC_2D);
49   CPPUNIT_TEST(testAsynchronousFasterSourceIntersectionDEC_2D);
50   CPPUNIT_TEST(testAsynchronousSlowerSourceIntersectionDEC_2D);
51   CPPUNIT_TEST(testAsynchronousSlowSourceIntersectionDEC_2D);
52   CPPUNIT_TEST(testAsynchronousFastSourceIntersectionDEC_2D);
53 #ifdef MED_ENABLE_FVM
54   //can be added again after FVM correction for 2D
55   //  CPPUNIT_TEST(testNonCoincidentDEC_2D);
56   CPPUNIT_TEST(testNonCoincidentDEC_3D); 
57 #endif
58   CPPUNIT_TEST(testStructuredCoincidentDEC);
59   CPPUNIT_TEST_SUITE_END();
60   
61
62 public:
63  
64   ParaMEDMEMTest():CppUnit::TestFixture(){}
65   ~ParaMEDMEMTest(){}  
66   void setUp(){}
67   void tearDown(){}
68   void testMPIProcessorGroup_constructor();
69   void testMPIProcessorGroup_boolean();
70   void testMPIProcessorGroup_rank();
71   void testBlockTopology_constructor();
72   void testBlockTopology_serialize();
73   void testIntersectionDEC_2D();
74   void testIntersectionDEC_2DP0P1();
75 #ifdef MED_ENABLE_FVM
76   void testNonCoincidentDEC_2D();
77   void testNonCoincidentDEC_3D();
78 #endif
79   void testStructuredCoincidentDEC();
80   void testSynchronousEqualIntersectionWithoutInterpNativeDEC_2D();
81   void testSynchronousEqualIntersectionWithoutInterpDEC_2D();
82   void testSynchronousEqualIntersectionDEC_2D();
83   void testSynchronousFasterSourceIntersectionDEC_2D();
84   void testSynchronousSlowerSourceIntersectionDEC_2D();
85   void testSynchronousSlowSourceIntersectionDEC_2D();
86   void testSynchronousFastSourceIntersectionDEC_2D();
87
88   void testAsynchronousEqualIntersectionDEC_2D();
89   void testAsynchronousFasterSourceIntersectionDEC_2D();
90   void testAsynchronousSlowerSourceIntersectionDEC_2D();
91   void testAsynchronousSlowSourceIntersectionDEC_2D();
92   void testAsynchronousFastSourceIntersectionDEC_2D();
93
94
95 private:
96   void testNonCoincidentDEC(const std::string& filename1, 
97                             const std::string& meshname1, 
98                             const std::string& filename2, 
99                             const std::string& meshname2,
100                             int nbprocsource, double epsilon);
101   void testAsynchronousIntersectionDEC_2D(double dtA, double tmaxA, 
102                                           double dtB, double tmaxB,
103                                           bool WithPointToPoint, bool Asynchronous, bool WithInterp, const char *srcMeth, const char *targetMeth);
104   void testIntersectionDEC_2D_(const char *srcMeth, const char *targetMeth);
105   
106 };
107
108 // to automatically remove temporary files from disk
109 class ParaMEDMEMTest_TmpFilesRemover
110 {
111 public:
112   ParaMEDMEMTest_TmpFilesRemover() {}
113   ~ParaMEDMEMTest_TmpFilesRemover();
114   bool Register(const std::string theTmpFile);
115
116 private:
117   std::set<std::string> myTmpFiles;
118 };
119
120 /*!
121  *  Tool to print array to stream.
122  */
123 template<class T>
124 void ParaMEDMEMTest_DumpArray (std::ostream & stream, const T* array, const int length, const std::string text)
125 {
126   stream << text << ": {";
127   if (length > 0) {
128     stream << array[0];
129     for (int i = 1; i < length; i++) {
130       stream << ", " << array[i];
131     }
132   }
133   stream << "}" << std::endl;
134 };
135
136 #endif