--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef _BASICMAINTEST_HXX_
+#define _BASICMAINTEST_HXX_
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/TestResult.h>
+#include <cppunit/TestResultCollector.h>
+#include <cppunit/TextTestProgressListener.h>
+#include <cppunit/BriefTestProgressListener.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/TestRunner.h>
+#include <stdexcept>
+
+#include <iostream>
+#include <fstream>
+
+// ============================================================================
+/*!
+ * Main program source for Unit Tests with cppunit package does not depend
+ * on actual tests, so we use the same for all partial unit tests.
+ */
+// ============================================================================
+
+int main(int argc, char* argv[])
+{
+ // --- Create the event manager and test controller
+ CPPUNIT_NS::TestResult controller;
+
+ // --- Add a listener that colllects test result
+ CPPUNIT_NS::TestResultCollector result;
+ controller.addListener( &result );
+
+ // --- Add a listener that print dots as test run.
+#ifdef WIN32
+ CPPUNIT_NS::TextTestProgressListener progress;
+#else
+ CPPUNIT_NS::BriefTestProgressListener progress;
+#endif
+ controller.addListener( &progress );
+
+ // --- Get the top level suite from the registry
+
+ CPPUNIT_NS::Test *suite =
+ CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest();
+
+ // --- Adds the test to the list of test to run
+
+ CPPUNIT_NS::TestRunner runner;
+ runner.addTest( suite );
+ runner.run( controller);
+
+ // --- Print test in a compiler compatible format.
+
+ std::ofstream testFile;
+ testFile.open("UnitTestsResult", std::ios::out | std::ios::trunc);
+ //CPPUNIT_NS::CompilerOutputter outputter( &result, std::cerr );
+ CPPUNIT_NS::CompilerOutputter outputter( &result, testFile );
+ outputter.write();
+
+ // --- Run the tests.
+
+ bool wasSucessful = result.wasSuccessful();
+ testFile.close();
+
+ // --- Return error code 1 if the one of test failed.
+
+ return wasSucessful ? 0 : 1;
+}
+
+#endif
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+#ifndef _MPIMAINTEST_HXX_
+#define _MPIMAINTEST_HXX_
+
+#include <cppunit/CompilerOutputter.h>
+#include <cppunit/TestResult.h>
+#include <cppunit/TestResultCollector.h>
+#include <cppunit/TextTestProgressListener.h>
+#include <cppunit/BriefTestProgressListener.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/TestRunner.h>
+#include <stdexcept>
+
+#include <mpi.h>
+
+#include <iostream>
+#include <fstream>
+
+// ============================================================================
+/*!
+ * Main program source for Unit Tests with cppunit package does not depend
+ * on actual tests, so we use the same for all partial unit tests.
+ */
+// ============================================================================
+
+int main(int argc, char* argv[])
+{
+ MPI_Init(&argc,&argv);
+ int rank;
+ MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+
+ // --- Create the event manager and test controller
+ CPPUNIT_NS::TestResult controller;
+
+ // --- Add a listener that colllects test result
+ CPPUNIT_NS::TestResultCollector result;
+ controller.addListener( &result );
+
+ // --- Add a listener that print dots as test run.
+#ifdef WIN32
+ CPPUNIT_NS::TextTestProgressListener progress;
+#else
+ CPPUNIT_NS::BriefTestProgressListener progress;
+#endif
+ controller.addListener( &progress );
+
+ // --- Get the top level suite from the registry
+
+ CPPUNIT_NS::Test *suite =
+ CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest();
+
+ // --- Adds the test to the list of test to run
+
+ CPPUNIT_NS::TestRunner runner;
+ runner.addTest( suite );
+ runner.run( controller);
+
+ // --- Print test in a compiler compatible format.
+
+ std::ostringstream testFileName;
+ testFileName<<"UnitTestResult"<<rank;
+ std::ofstream testFile;
+ testFile.open(testFileName.str().c_str(), std::ios::out | std::ios::trunc);
+ //CPPUNIT_NS::CompilerOutputter outputter( &result, std::cerr );
+ CPPUNIT_NS::CompilerOutputter outputter( &result, testFile );
+ outputter.write();
+
+ // --- Run the tests.
+
+ bool wasSucessful = result.wasSuccessful();
+ testFile.close();
+
+ // --- Return error code 1 if the one of test failed.
+
+ MPI_Finalize();
+
+ return wasSucessful ? 0 : 1;
+}
+
+#endif
--- /dev/null
+# SALOMELocalTrace : log on local machine
+#
+# Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# This library is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+# Lesser General Public License for more details.
+#
+# You should have received a copy of the GNU Lesser General Public
+# License along with this library; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+#
+# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+#
+#
+#
+# File : Makefile.in
+# Author : Vincent BERGEAUD
+# Module : MED
+
+top_srcdir=@top_srcdir@
+top_builddir=../../..
+srcdir=@srcdir@
+VPATH=.:@srcdir@:@top_srcdir@/idl
+
+
+@COMMENCE@
+
+# header files
+EXPORT_HEADERS = ParaMEDMEMTest.hxx
+
+#EXPORT_PYSCRIPTS = testParaMEDMEM.py
+#TEST_PYSCRIPTS = testParaMEDMEM.py
+
+# Libraries targets
+
+LIB = libParaMEDMEMTest.la
+LIB_SRC = TestParaMEDMEM.cxx \
+ ParaMEDMEMTest.cxx \
+ ParaMEDMEMTest_MPIProcessorGroup.cxx \
+ ParaMEDMEMTest_BlockTopology.cxx \
+ ParaMEDMEMTest_IntersectionDEC.cxx
+
+
+LIB_CLIENT_IDL =
+
+# Executables targets
+
+BIN = TestParaMEDMEM
+# Faulting tests
+#BIN += ParaMEDMEMTest_Array_fault
+
+BIN_SRC =
+BIN_CLIENT_IDL =
+
+
+CXXFLAGS += $ @CPPUNIT_INCLUDES@ $(KERNEL_CXXFLAGS) $(LIBXML_CXXFLAGS) $(MPI_INCLUDES) @CXXTMPDPTHFLAGS@ -I$(top_srcdir)/src/ParaMEDMEM
+CPPFLAGS += $ @CPPUNIT_INCLUDES@ $(KERNEL_CXXFLAGS) $(LIBXML_CXXFLAGS) $(MPI_INCLUDES) $(MED2_INCLUDES) $(HDF5_INCLUDES) -I$(top_srcdir)/src/ParaMEDMEM
+
+LIBS = @LIBS@ @CPPUNIT_LIBS@
+
+LDFLAGSFORBIN += $(LDFLAGS) -lm $(MED2_LIBS) $(HDF5_LIBS) $(MPI_LIBS) \
+ -L$(top_builddir)/lib@LIB_LOCATION_SUFFIX@/salome -lmed_V2_1 -lparamed -lmedmem \
+ ${KERNEL_LDFLAGS} -lSALOMELocalTrace -lSALOMEBasics \
+ -lParaMEDMEMTest
+
+UNIT_TEST_PROG = TestParaMEDMEM
+
+@CONCLUDE@
--- /dev/null
+// Copyright (C) 2006 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#include "ParaMEDMEMTest.hxx"
+#include <cppunit/TestAssert.h>
+
+#include "MEDMEM_STRING.hxx"
+
+#include <sstream>
+#include <cmath>
+
+using namespace std;
+
+
+
+/*!
+ * Tool to remove temporary files.
+ * Allows automatique removal of temporary files in case of test failure.
+ */
+ParaMEDMEMTest_TmpFilesRemover::~ParaMEDMEMTest_TmpFilesRemover()
+{
+ set<string>::iterator it = myTmpFiles.begin();
+ for (; it != myTmpFiles.end(); it++) {
+ if (access((*it).data(), F_OK) == 0)
+ remove((*it).data());
+ }
+ myTmpFiles.clear();
+ //cout << "~ParaMEDMEMTest_TmpFilesRemover()" << endl;
+}
+
+bool ParaMEDMEMTest_TmpFilesRemover::Register(const string theTmpFile)
+{
+ return (myTmpFiles.insert(theTmpFile)).second;
+}
--- /dev/null
+// Copyright (C) 2006 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+#ifndef _ParaMEDMEMTEST_HXX_
+#define _ParaMEDMEMTEST_HXX_
+
+#include <cppunit/extensions/HelperMacros.h>
+
+#include <set>
+#include <string>
+#include <iostream>
+#include "mpi.h"
+
+
+static int argc;
+static char** argv;
+
+class ParaMEDMEMTest : public CppUnit::TestFixture
+{
+ CPPUNIT_TEST_SUITE( ParaMEDMEMTest );
+ CPPUNIT_TEST(testMPIProcessorGroup_constructor);
+ CPPUNIT_TEST(testMPIProcessorGroup_boolean);
+ CPPUNIT_TEST(testMPIProcessorGroup_rank);
+ CPPUNIT_TEST(testBlockTopology_constructor);
+ CPPUNIT_TEST(testBlockTopology_serialize);
+ CPPUNIT_TEST(testIntersectionDEC_2D);
+ CPPUNIT_TEST_SUITE_END();
+
+
+public:
+
+ ParaMEDMEMTest():CppUnit::TestFixture(){}
+ ~ParaMEDMEMTest(){}
+ void setUp(){}
+ void tearDown(){}
+ void testMPIProcessorGroup_constructor();
+ void testMPIProcessorGroup_boolean();
+ void testMPIProcessorGroup_rank();
+ void testBlockTopology_constructor();
+ void testBlockTopology_serialize();
+ void testIntersectionDEC_2D();
+ };
+
+// to automatically remove temporary files from disk
+class ParaMEDMEMTest_TmpFilesRemover
+{
+public:
+ ParaMEDMEMTest_TmpFilesRemover() {}
+ ~ParaMEDMEMTest_TmpFilesRemover();
+ bool Register(const std::string theTmpFile);
+
+private:
+ std::set<std::string> myTmpFiles;
+};
+
+/*!
+ * Tool to print array to stream.
+ */
+template<class T>
+void ParaMEDMEMTest_DumpArray (std::ostream & stream, const T* array, const int length, const std::string text)
+{
+ stream << text << ": {";
+ if (length > 0) {
+ stream << array[0];
+ for (int i = 1; i < length; i++) {
+ stream << ", " << array[i];
+ }
+ }
+ stream << "}" << std::endl;
+};
+
+#endif
--- /dev/null
+// Copyright (C) 2006 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+#include "ParaMEDMEMTest.hxx"
+#include <cppunit/TestAssert.h>
+
+#include "MEDMEM_Exception.hxx"
+#include "CommInterface.hxx"
+#include "ProcessorGroup.hxx"
+#include "MPIProcessorGroup.hxx"
+#include "Topology.hxx"
+#include "BlockTopology.hxx"
+
+#include <string>
+
+// use this define to enable lines, execution of which leads to Segmentation Fault
+#define ENABLE_FAULTS
+
+// use this define to enable CPPUNIT asserts and fails, showing bugs
+#define ENABLE_FORCED_FAILURES
+
+
+using namespace std;
+using namespace ParaMEDMEM;
+using namespace MEDMEM;
+
+/*
+ * Check methods defined in BlockTopology.hxx
+ *
+ BlockTopology(){};
+ BlockTopology(const ProcessorGroup& group, const MEDMEM::GRID& grid);
+ BlockTopology(const BlockTopology& geom_topo, const ComponentTopology& comp_topo);
+ (+) BlockTopology(const ProcessorGroup& group, int nb_elem);
+ virtual ~BlockTopology();
+ (+) inline int getNbElements()const;
+ (+) inline int getNbLocalElements() const;
+ const ProcessorGroup* getProcGroup()const {return _proc_group;};
+ (+) inline std::pair<int,int> globalToLocal (const int) const ;
+ (+) inline int localToGlobal (const std::pair<int,int>) const;
+ (+) std::vector<std::pair<int,int> > getLocalArrayMinMax() const ;
+ (+) int getDimension() const {return _dimension;};
+ (+) void serialize(int* & serializer, int& size) const ;
+ (+) void unserialize(const int* serializer, const CommInterface& comm_interface);
+
+ */
+
+void ParaMEDMEMTest::testBlockTopology_constructor()
+{
+ //test constructor
+ int size;
+ MPI_Comm_size(MPI_COMM_WORLD,&size);
+ int rank;
+ MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+ CommInterface interface;
+ MPIProcessorGroup group(interface);
+ BlockTopology blocktopo(group,1);
+ CPPUNIT_ASSERT_EQUAL(1,blocktopo.getNbLocalElements());
+ CPPUNIT_ASSERT_EQUAL(size,blocktopo.getNbElements());
+ CPPUNIT_ASSERT_EQUAL(1,blocktopo.getDimension());
+
+ //checking access methods
+ BlockTopology blocktopo2(group,2);
+ std::pair<int,int> local= blocktopo2.globalToLocal(0);
+ CPPUNIT_ASSERT_EQUAL(local.first,0);
+ CPPUNIT_ASSERT_EQUAL(local.second,0);
+ int global=blocktopo2.localToGlobal(local);
+ CPPUNIT_ASSERT_EQUAL(global,0);
+
+ local = blocktopo2.globalToLocal(1);
+ CPPUNIT_ASSERT_EQUAL(local.first,0);
+ CPPUNIT_ASSERT_EQUAL(local.second,1);
+ global=blocktopo2.localToGlobal(local);
+ CPPUNIT_ASSERT_EQUAL(global,1);
+
+ local = blocktopo2.globalToLocal(2*size-1);
+ CPPUNIT_ASSERT_EQUAL(local.first,size-1);
+ CPPUNIT_ASSERT_EQUAL(local.second,1);
+ global=blocktopo2.localToGlobal(local);
+ CPPUNIT_ASSERT_EQUAL(global,2*size-1);
+
+ std::vector<std::pair<int,int> > bounds = blocktopo2.getLocalArrayMinMax();
+ int vecsize = bounds.size();
+ CPPUNIT_ASSERT_EQUAL(1,vecsize);
+ CPPUNIT_ASSERT_EQUAL(2*rank, (bounds[0]).first);
+ CPPUNIT_ASSERT_EQUAL(2*rank+2, (bounds[0]).second);
+ }
+
+void ParaMEDMEMTest::testBlockTopology_serialize()
+{
+
+ int size;
+ MPI_Comm_size(MPI_COMM_WORLD,&size);
+ int rank;
+ MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+ CommInterface interface;
+ MPIProcessorGroup group(interface);
+ BlockTopology blocktopo(group,3);
+
+//testing the serialization process that is used to transfer a
+//block topology via a MPI_Send/Recv comm
+ BlockTopology blocktopo_recv;
+ int* serializer;
+ int sersize;
+ blocktopo.serialize(serializer,sersize);
+ blocktopo_recv.unserialize(serializer,interface);
+ CPPUNIT_ASSERT_EQUAL(blocktopo.getNbElements(),blocktopo_recv.getNbElements());
+}
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2006 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+#include "ParaMEDMEMTest.hxx"
+#include <cppunit/TestAssert.h>
+
+#include "MEDMEM_Exception.hxx"
+#include "CommInterface.hxx"
+#include "ProcessorGroup.hxx"
+#include "MPIProcessorGroup.hxx"
+#include "Topology.hxx"
+#include "DEC.hxx"
+#include "IntersectionDEC.hxx"
+#include "ParaMESH.hxx"
+#include "ParaFIELD.hxx"
+#include "UnstructuredParaSUPPORT.hxx"
+#include "ICoCoMEDField.hxx"
+
+#include <string>
+
+// use this define to enable lines, execution of which leads to Segmentation Fault
+#define ENABLE_FAULTS
+
+// use this define to enable CPPUNIT asserts and fails, showing bugs
+#define ENABLE_FORCED_FAILURES
+
+
+using namespace std;
+using namespace ParaMEDMEM;
+using namespace MEDMEM;
+
+/*
+ * Check methods defined in IntersectionDEC.hxx
+ *
+ IntersectionDEC();
+ IntersectionDEC(ProcessorGroup& local_group, ProcessorGroup& distant_group);
+ virtual ~IntersectionDEC();
+ void synchronize();
+ void recvData();
+ void sendData();
+ */
+
+void ParaMEDMEMTest::testIntersectionDEC_2D()
+{
+ int size;
+ int rank;
+ MPI_Comm_size(MPI_COMM_WORLD,&size);
+ MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+
+ //test is meant to run on five processors
+ if (size !=5) return 0;
+
+ int nproc_source = 3;
+ set<int> self_procs;
+ set<int> procs_source;
+ set<int> procs_target;
+
+ for (int i=0; i<nproc_source; i++)
+ procs_source.insert(i);
+ for (int i=nproc_source; i<size; i++)
+ procs_target.insert(i);
+ self_procs.insert(rank);
+
+ ParaMEDMEM::CommInterface interface;
+
+ ParaMEDMEM::ProcessorGroup* self_group = new ParaMEDMEM::MPIProcessorGroup(interface,self_procs);
+ ParaMEDMEM::ProcessorGroup* target_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_target);
+ ParaMEDMEM::ProcessorGroup* source_group = new ParaMEDMEM::MPIProcessorGroup(interface,procs_source);
+
+ ParaMEDMEM::ParaMESH* source_mesh=0;
+ ParaMEDMEM::ParaMESH* target_mesh=0;
+
+
+
+ //loading the geometry for the source group
+
+ ParaMEDMEM::IntersectionDEC dec (*source_group,*target_group);
+
+ MEDMEM::MESH* mesh;
+ MEDMEM::SUPPORT* support;
+ MEDMEM::FIELD<double>* field;
+ ParaMEDMEM::ParaMESH* paramesh;
+ ParaMEDMEM::ParaFIELD* parafield;
+
+ string data_dir = getenv("MED_ROOT_DIR");
+ string tmp_dir = getenv("TMP");
+ if (tmp_dir == "")
+ tmp_dir = "/tmp";
+ string filename_xml1 = data_dir + "/share/salome/resources/med/square1_split";
+ string filename_xml2 = data_dir + "/share/salome/resources/med/square2_split";
+ string filename_seq_wr = tmp_dir + "/";
+ string filename_seq_med = tmp_dir + "/myWrField_seq_pointe221.med";
+
+ // To remove tmp files from disk
+ //ParaMEDMEMTest_TmpFilesRemover aRemover;
+ //aRemover.Register(filename_seq_wr);
+ //aRemover.Register(filename_seq_med);
+ MPI_Barrier(MPI_COMM_WORLD);
+ if (source_group->containsMyRank())
+ {
+ string master = filename_xml1;
+
+ ostringstream strstream;
+ strstream <<master<<rank+1<<".med";
+ ostringstream meshname ;
+ meshname<< "Mesh_2_"<< rank+1;
+
+ CPPUNIT_ASSERT_NO_THROW(mesh = new MESH(MED_DRIVER,strstream.str(),meshname.str()));
+ support=new MEDMEM::SUPPORT(mesh,"all elements",MED_EN::MED_CELL);
+
+ paramesh=new ParaMESH (*mesh,*source_group,"source mesh");
+
+ ParaMEDMEM::ParaSUPPORT* parasupport=new UnstructuredParaSUPPORT( support,*source_group);
+ ParaMEDMEM::ComponentTopology comptopo;
+ parafield = new ParaFIELD(parasupport, comptopo);
+
+
+ int nb_local=support->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS);
+ double * value= new double[nb_local];
+ for(int ielem=0; ielem<nb_local;ielem++)
+ value[ielem]=1.0;
+ parafield->getField()->setValue(value);
+
+ ICoCo::Field* icocofield=new ICoCo::MEDField(paramesh,parafield);
+
+ dec.attachLocalField(icocofield);
+ }
+
+ //loading the geometry for the target group
+ if (target_group->containsMyRank())
+ {
+ string master= filename_xml2;
+ ostringstream strstream;
+ strstream << master<<(rank-nproc_source+1)<<".med";
+ ostringstream meshname ;
+ meshname<< "Mesh_3_"<<rank-nproc_source+1;
+
+ CPPUNIT_ASSERT_NO_THROW(mesh = new MESH(MED_DRIVER,strstream.str(),meshname.str()));
+ support=new MEDMEM::SUPPORT(mesh,"all elements",MED_EN::MED_CELL);
+
+ paramesh=new ParaMESH (*mesh,*target_group,"target mesh");
+ ParaMEDMEM::ParaSUPPORT* parasupport=new UnstructuredParaSUPPORT(support,*target_group);
+ ParaMEDMEM::ComponentTopology comptopo;
+ parafield = new ParaFIELD(parasupport, comptopo);
+
+
+ int nb_local=support->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS);
+ double * value= new double[nb_local];
+ for(int ielem=0; ielem<nb_local;ielem++)
+ value[ielem]=0.0;
+ parafield->getField()->setValue(value);
+ ICoCo::Field* icocofield=new ICoCo::MEDField(paramesh,parafield);
+
+ dec.attachLocalField(icocofield);
+ }
+
+
+ //attaching a DEC to the source group
+ double field_before_int;
+ double field_after_int;
+
+ if (source_group->containsMyRank())
+ {
+ field_before_int = parafield->getVolumeIntegral(1);
+ dec.synchronize();
+ cout<<"DEC usage"<<endl;
+ dec.setForcedRenormalizationFlag(false);
+
+ dec.sendData();
+ paramesh->write(MED_DRIVER,"./sourcesquareb");
+ parafield->write(MED_DRIVER,"./sourcesquareb","boundary");
+
+ dec.recvData();
+ cout <<"writing"<<endl;
+ paramesh->write(MED_DRIVER,"./sourcesquare");
+ parafield->write(MED_DRIVER,"./sourcesquare","boundary");
+ field_after_int = parafield->getVolumeIntegral(1);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(field_before_int, field_after_int, 1e-6);
+
+ }
+
+ //attaching a DEC to the target group
+ if (target_group->containsMyRank())
+ {
+ dec.synchronize();
+ dec.setForcedRenormalizationFlag(false);
+
+ dec.recvData();
+ paramesh->write(MED_DRIVER, "./targetsquareb");
+ parafield->write(MED_DRIVER, "./targetsquareb", "boundary");
+ dec.sendData();
+ paramesh->write(MED_DRIVER, "./targetsquare");
+ parafield->write(MED_DRIVER, "./targetsquare", "boundary");
+
+ }
+
+ delete source_group;
+ delete target_group;
+ delete self_group;
+
+ MPI_Barrier(MPI_COMM_WORLD);
+
+}
\ No newline at end of file
--- /dev/null
+// Copyright (C) 2006 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+
+#include "ParaMEDMEMTest.hxx"
+#include <cppunit/TestAssert.h>
+
+#include "MEDMEM_Exception.hxx"
+#include "CommInterface.hxx"
+#include "ProcessorGroup.hxx"
+#include "MPIProcessorGroup.hxx"
+
+#include <string>
+
+// use this define to enable lines, execution of which leads to Segmentation Fault
+#define ENABLE_FAULTS
+
+// use this define to enable CPPUNIT asserts and fails, showing bugs
+#define ENABLE_FORCED_FAILURES
+
+
+using namespace std;
+using namespace ParaMEDMEM;
+using namespace MEDMEM;
+
+/*
+ * Check methods defined in MPPIProcessorGroup.hxx
+ *
+ (+) MPIProcessorGroup(const CommInterface& interface);
+ (+) MPIProcessorGroup(const CommInterface& interface, set<int> proc_ids);
+ (u) MPIProcessorGroup (const ProcessorGroup& proc_group, set<int> proc_ids);
+ (+) MPIProcessorGroup(const CommInterface& interface,int pstart, int pend);
+ (+) virtual ~MPIProcessorGroup();
+ (+) virtual ProcessorGroup* fuse (const ProcessorGroup&) const;
+ (u) void intersect (ProcessorGroup&){};
+ (+) int myRank() const {int rank; MPI_Comm_rank(_comm,&rank); return rank;}
+ (+) bool containsMyRank() const { int rank; MPI_Group_rank(_group, &rank); return (rank!=MPI_UNDEFINED);}
+ (+) int translateRank(const ProcessorGroup* group, int rank) const;
+ (+) const MPI_Comm* getComm() const {return &_comm;}
+ (+) ProcessorGroup* createComplementProcGroup() const;
+ (o) ProcessorGroup* createProcGroup() const;
+
+ */
+
+void ParaMEDMEMTest::testMPIProcessorGroup_constructor()
+{
+ CommInterface comm_interface;
+ MPIProcessorGroup* group= new MPIProcessorGroup(comm_interface);
+ int size;
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ CPPUNIT_ASSERT_EQUAL(size,group->size());
+ int size2;
+ const MPI_Comm* communicator=group->getComm();
+ MPI_Comm_size(*communicator, &size2);
+ CPPUNIT_ASSERT_EQUAL(size,size2);
+ delete group;
+
+ set <int> procs;
+
+ procs.insert(0);
+ procs.insert(1);
+ if (size==1)
+ CPPUNIT_ASSERT_THROW(group=new MPIProcessorGroup(comm_interface,procs),MEDMEM::MEDEXCEPTION);
+ else
+ {
+ CPPUNIT_ASSERT_NO_THROW( group=new MPIProcessorGroup(comm_interface,procs));
+ CPPUNIT_ASSERT_EQUAL (group->size(),2);
+ delete group;
+ }
+
+
+ //throws because plast<pfirst
+ CPPUNIT_ASSERT_THROW(group=new MPIProcessorGroup(comm_interface,1,0),MEDMEM::MEDEXCEPTION);
+ //throws because plast is beyond size-1
+ CPPUNIT_ASSERT_THROW(group=new MPIProcessorGroup(comm_interface,0,size),MEDMEM::MEDEXCEPTION);
+ if (size>1)
+ {
+ group=new MPIProcessorGroup(comm_interface,0,size-2);
+ CPPUNIT_ASSERT_EQUAL(group->size(),size-1);
+ delete group;
+ }
+
+ }
+
+ void ParaMEDMEMTest::testMPIProcessorGroup_boolean()
+ {
+ int size;
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+
+ CommInterface comm_interface;
+ MPIProcessorGroup group(comm_interface,0,0);
+ MPIProcessorGroup group2(comm_interface,size-1,size-1);
+ ProcessorGroup* group_fuse=group.fuse(group2);
+ int group_fuse_size=(size==1)?1:2;
+ CPPUNIT_ASSERT_EQUAL(group_fuse_size,group_fuse->size());
+
+ ProcessorGroup* group_complement=((MPIProcessorGroup*)group_fuse)->createComplementProcGroup();
+ CPPUNIT_ASSERT_EQUAL(group_complement->size(),size-group_fuse_size);
+
+ //intersect not implemented yet
+// if (size>1)
+// {
+// MPIProcessorGroup group3(comm_interface,0,size-2);
+// MPIProcessorGroup group4(comm_interface,1,size-1);
+// group3.intersect(group4);
+// CPPUNIT_ASSERT_EQUAL(group3.size(),size-2);
+// }
+ }
+
+void ParaMEDMEMTest::testMPIProcessorGroup_rank()
+{
+ int size;
+ MPI_Comm_size(MPI_COMM_WORLD, &size);
+ int rank;
+ MPI_Comm_rank(MPI_COMM_WORLD, &rank);
+
+ CommInterface comm_interface;
+ MPIProcessorGroup group(comm_interface,0,0);
+ MPIProcessorGroup group2(comm_interface,size-1,size-1);
+ ProcessorGroup* group_fuse=group2.fuse(group);
+
+ if (group.containsMyRank())
+ CPPUNIT_ASSERT_EQUAL (group.myRank(), rank);
+
+ if (group2.containsMyRank())
+ {
+ int trank=group_fuse->translateRank(&group2,0);
+ CPPUNIT_ASSERT_EQUAL(trank,1);
+ }
+}
--- /dev/null
+// Copyright (C) 2005 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// This library is distributed in the hope that it will be useful
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// --- include all MEDMEM Test
+
+#include "ParaMEDMEMTest.hxx"
+
+// --- Registers the fixture into the 'registry'
+
+CPPUNIT_TEST_SUITE_REGISTRATION( ParaMEDMEMTest );
+
+// --- generic Main program from KERNEL_SRC/src/Basics/Test
+
+#include "MPIMainTest.hxx"