@COMMENCE@
-SUBDIRS= Test
+SUBDIRS = Test
EXPORT_PYSCRIPTS = \
StructuredCoincidentDEC.hxx\
InterpolationMatrix.hxx\
IntersectionDEC.hxx\
-NonCoincidentDEC.hxx\
UnstructuredParaSUPPORT.hxx\
ExplicitCoincidentDEC.hxx\
ElementLocator.hxx\
StructuredCoincidentDEC.cxx\
ExplicitCoincidentDEC.cxx\
IntersectionDEC.cxx\
-NonCoincidentDEC.cxx\
UnstructuredParaSUPPORT.cxx\
ElementLocator.cxx\
ExplicitTopology.cxx\
LDFLAGS+= -L$(top_builddir)/lib@LIB_LOCATION_SUFFIX@/salome
LDFLAGSFORBIN+= -L$(top_builddir)/lib@LIB_LOCATION_SUFFIX@/salome
-CPPFLAGS+=$(MED2_INCLUDES) $(MPI_INCLUDES) $(FVM_INCLUDES)
+CPPFLAGS+=$(MED2_INCLUDES) $(MPI_INCLUDES)
CPPFLAGS+=-I${srcdir}/../INTERP_KERNEL
CPPFLAGS+=$(BOOST_CPPFLAGS)
#LDFLAGS+=$(MED2_LIBS) $(HDF5_LIBS)
# change motivated by the bug KERNEL4778.
-LDFLAGS+=$(MED2_LIBS) $(HDF5_LIBS) -lmed_V2_1 $(STDLIB) -lmedmem $(MPI_LIBS) $(FVM_LIBS) -lutil -linterpkernel
+LDFLAGS+=$(MED2_LIBS) $(HDF5_LIBS) -lmed_V2_1 $(STDLIB) -lmedmem $(MPI_LIBS) -lutil -linterpkernel
#LDFLAGSFORBIN+=$(MED2_LIBS) $(HDF5_LIBS)
# change motivated by the bug KERNEL4778.
LDFLAGS+= ${KERNEL_LDFLAGS} -lSALOMELocalTrace
LDFLAGSFORBIN+= ${KERNEL_LDFLAGS} -lSALOMELocalTrace -lSALOMEBasics
endif
+LIBSFORBIN=$(BOOSTLIBS) $(MPI_LIBS)
-LIBSFORBIN=$(BOOSTLIBS) $(MPI_LIBS) $(FVM_LIBS)
+
+
+ifneq ( $(FVM_LIBS), "")
+ LIB_SRC += NonCoincidentDEC.cxx
+ EXPORT_HEADERS += NonCoincidentDEC.hxx
+ LDFLAGS += $(FVM_LIBS)
+ LDFLAGSFORBIN += $(FVM_LIBS)
+ CPPFLAGS += $(FVM_INCLUDES)
+ LIBSFORBIN+=$(FVM_LIBS)
+endif
LIBS=
ParaMEDMEMTest.cxx \
ParaMEDMEMTest_MPIProcessorGroup.cxx \
ParaMEDMEMTest_BlockTopology.cxx \
- ParaMEDMEMTest_IntersectionDEC.cxx\
- ParaMEDMEMTest_NonCoincidentDEC.cxx
+ ParaMEDMEMTest_IntersectionDEC.cxx
+
LIB_CLIENT_IDL =
LDFLAGSFORBIN += $(LDFLAGS) -lm $(MED2_LIBS) $(HDF5_LIBS) $(MPI_LIBS) \
-L$(top_builddir)/lib@LIB_LOCATION_SUFFIX@/salome -lmed_V2_1 -lparamed -linterpkernel -lmedmem \
- ${KERNEL_LDFLAGS} ${FVM_LIBS} ${CPPUNIT_LIBS}\
+ $(KERNEL_LDFLAGS) $(CPPUNIT_LIBS)\
-lParaMEDMEMTest
+ifneq ($(FVM_LIBS),"")
+ LIB_SRC += ParaMEDMEMTest_NonCoincidentDEC.cxx
+ LDFLAGSFORBIN += $(FVM_LIBS)
+endif
+
UNIT_TEST_PROG = TestParaMEDMEM
@CONCLUDE@
void testIntersectionDEC_2D();
void testNonCoincidentDEC_2D();
void testNonCoincidentDEC_3D();
-
+ void testAsynchronousEqualIntersectionDEC_2D();
+ void testAsynchronousFasterSourceIntersectionDEC_2D();
+ void testAsynchronousSlowerSourceIntersectionDEC_2D();
+ void testAsynchronousSlowSourceIntersectionDEC_2D();
+ void testAsynchronousFastSourceIntersectionDEC_2D();
+
private:
void testNonCoincidentDEC(const std::string& filename1,
const std::string& filename2,
const std::string& meshname2,
int nbprocsource);
+ void testAsynchronousIntersectionDEC_2D(double dtA, double tmaxA,
+ double dtB, double tmaxB);
+
};
// to automatically remove temporary files from disk
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;
delete self_group;
+ MPI_Barrier(MPI_COMM_WORLD);
+ cout << "end of IntersectionDEC_2D test"<<endl;
+}
+
+
+void ParaMEDMEMTest::testAsynchronousEqualIntersectionDEC_2D()
+{
+ testAsynchronousIntersectionDEC_2D(0.1,1,0.1,1);
+}
+void ParaMEDMEMTest::testAsynchronousFasterSourceIntersectionDEC_2D()
+{
+ testAsynchronousIntersectionDEC_2D(0.09,1,0.1,1);
+}
+void ParaMEDMEMTest::testAsynchronousSlowerSourceIntersectionDEC_2D()
+{
+ testAsynchronousIntersectionDEC_2D(0.11,1,0.1,1);
+}
+void ParaMEDMEMTest::testAsynchronousSlowSourceIntersectionDEC_2D()
+{
+ testAsynchronousIntersectionDEC_2D(0.11,1,0.01,1);
+}
+void ParaMEDMEMTest::testAsynchronousFastSourceIntersectionDEC_2D()
+{
+ testAsynchronousIntersectionDEC_2D(0.01,1,0.11,1);
+}
+
+/*!
+ * Tests an asynchronous exchange between two codes
+ * one sends data with dtA as an interval, the max time being tmaxA
+ * the other one receives with dtB as an interval, the max time being tmaxB
+ */
+void ParaMEDMEMTest::testAsynchronousIntersectionDEC_2D(double dtA, double tmaxA,
+ double dtB, double tmaxB)
+{
+ int size;
+ int rank;
+ MPI_Comm_size(MPI_COMM_WORLD,&size);
+ MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+
+ //the test is meant to run on five processors
+ if (size !=5) return ;
+
+ 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);
+
+ //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;
+
+ 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]=0.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
+
+ if (source_group->containsMyRank())
+ {
+ dec.synchronize();
+ cout<<"DEC usage"<<endl;
+ dec.setOption("ForcedRenormalization",false);
+ dec.setOption("TimeInterpolation","Linear");
+ for (double time=0; time<tmaxA+1e-10; time+=dtA)
+ {
+ dec.sendData(time, dtA);
+ double* value = const_cast<double*> (parafield->getField()->getValue());
+ int nb_local=parafield->getField()->getSupport()->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS);
+ for (int i=0; i<nb_local;i++)
+ value[i]= time+dtA;
+
+ }
+ }
+
+ //attaching a DEC to the target group
+ if (target_group->containsMyRank())
+ {
+ dec.synchronize();
+ dec.setOption("ForcedRenormalization",false);
+ dec.setOption("TimeInterpolation","Linear");
+ vector<double> times;
+ for (double time=0; time<tmaxB+1e-10; time+=dtB)
+ {
+ dec.recvData(time);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(parafield->getVolumeIntegral(1),time*10000,0.001);
+ }
+
+ }
+
+ delete source_group;
+ delete target_group;
+ delete self_group;
+
+
MPI_Barrier(MPI_COMM_WORLD);
cout << "end of IntersectionDEC_2D test"<<endl;
}
--- /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 "NonCoincidentDEC.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::testNonCoincidentDEC_2D()
+{
+
+ int size;
+ MPI_Comm_size(MPI_COMM_WORLD,&size);
+
+ //the test is meant to run on five processors
+ if (size !=5) return ;
+
+ testNonCoincidentDEC( "/share/salome/resources/med/square1_split",
+ "Mesh_2",
+ "/share/salome/resources/med/square2_split",
+ "Mesh_3",
+ 3);
+}
+
+void ParaMEDMEMTest::testNonCoincidentDEC_3D()
+{
+ int size;
+ MPI_Comm_size(MPI_COMM_WORLD,&size);
+
+ //the test is meant to run on five processors
+ if (size !=5) return ;
+
+ testNonCoincidentDEC( "/share/salome/resources/med/blade_12000_split2",
+ "Mesh_1",
+ "/share/salome/resources/med/blade_3000_split2",
+ "Mesh_1",
+ 2);
+}
+
+void ParaMEDMEMTest::testNonCoincidentDEC(const string& filename1,
+ const string& meshname1,
+ const string& filename2,
+ const string& meshname2,
+ int nproc_source)
+{
+ int size;
+ int rank;
+ MPI_Comm_size(MPI_COMM_WORLD,&size);
+ MPI_Comm_rank(MPI_COMM_WORLD,&rank);
+
+ 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::NonCoincidentDEC 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 + filename1;
+ string filename_xml2 = data_dir + filename2;
+ 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);
+ ICoCo::Field* icocofield;
+ if (source_group->containsMyRank())
+ {
+ string master = filename_xml1;
+
+ ostringstream strstream;
+ strstream <<master<<rank+1<<".med";
+ ostringstream meshname ;
+ meshname<< meshname1<<"_"<< 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);
+
+ 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<< meshname2<<"_"<<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);
+ 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);
+ MPI_Bcast(&field_before_int, 1,MPI_DOUBLE, 0,MPI_COMM_WORLD);
+ dec.synchronize();
+ cout<<"DEC usage"<<endl;
+ dec.setOption("ForcedRenormalization",false);
+
+ dec.sendData();
+ // paramesh->write(MED_DRIVER,"./sourcesquarenc");
+ //parafield->write(MED_DRIVER,"./sourcesquarenc","boundary");
+
+
+ }
+
+ //attaching a DEC to the target group
+ if (target_group->containsMyRank())
+ {
+ MPI_Bcast(&field_before_int, 1,MPI_DOUBLE, 0,MPI_COMM_WORLD);
+
+ dec.synchronize();
+ dec.setOption("ForcedRenormalization",false);
+ dec.recvData();
+ //paramesh->write(MED_DRIVER, "./targetsquarenc");
+ //parafield->write(MED_DRIVER, "./targetsquarenc", "boundary");
+ field_after_int = parafield->getVolumeIntegral(1);
+
+ }
+ MPI_Bcast(&field_after_int, 1,MPI_DOUBLE, 4,MPI_COMM_WORLD);
+
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(field_before_int, field_after_int, 1e-6);
+
+ delete source_group;
+ delete target_group;
+ delete self_group;
+ delete icocofield;
+ MPI_Barrier(MPI_COMM_WORLD);
+
+}