From cf13930c804a0e965ac67f63e9bbe2e9c91170c4 Mon Sep 17 00:00:00 2001 From: ageay Date: Tue, 19 Oct 2010 09:32:44 +0000 Subject: [PATCH] *** empty log message *** --- src/ParaMEDMEM/DEC.cxx | 70 ++- src/ParaMEDMEM/DEC.hxx | 5 +- src/ParaMEDMEM/ElementLocator.cxx | 15 +- src/ParaMEDMEM/ExplicitCoincidentDEC.cxx | 4 +- src/ParaMEDMEM/ICoCoField.cxx | 10 +- src/ParaMEDMEM/ICoCoField.hxx | 35 +- src/ParaMEDMEM/ICoCoTrioField.cxx | 277 ++++----- src/ParaMEDMEM/ICoCoTrioField.hxx | 46 +- src/ParaMEDMEM/InterpKernelDEC.cxx | 14 +- src/ParaMEDMEM/InterpKernelDEC.hxx | 3 +- src/ParaMEDMEM/InterpolationMatrix.cxx | 24 + src/ParaMEDMEM/ParaFIELD.cxx | 2 +- src/ParaMEDMEMTest/MPI2Connector.cxx | 143 +++++ src/ParaMEDMEMTest/MPI2Connector.hxx | 48 ++ src/ParaMEDMEMTest/Makefile.am | 23 +- src/ParaMEDMEMTest/ParaMEDMEMTest.hxx | 10 + src/ParaMEDMEMTest/ParaMEDMEMTestMPI2_1.cxx | 125 ++++ src/ParaMEDMEMTest/ParaMEDMEMTestMPI2_2.cxx | 130 +++++ .../ParaMEDMEMTest_FabienAPI.cxx | 93 ++- .../ParaMEDMEMTest_Gauthier1.cxx | 6 +- .../ParaMEDMEMTest_ICocoTrio.cxx | 2 +- .../ParaMEDMEMTest_InterpKernelDEC.cxx | 533 +++++++++++++++++- .../ParaMEDMEMTest_MEDLoader.cxx | 101 ++-- .../ParaMEDMEMTest_NonCoincidentDEC.cxx | 3 + 24 files changed, 1422 insertions(+), 300 deletions(-) create mode 100644 src/ParaMEDMEMTest/MPI2Connector.cxx create mode 100644 src/ParaMEDMEMTest/MPI2Connector.hxx create mode 100644 src/ParaMEDMEMTest/ParaMEDMEMTestMPI2_1.cxx create mode 100644 src/ParaMEDMEMTest/ParaMEDMEMTestMPI2_2.cxx diff --git a/src/ParaMEDMEM/DEC.cxx b/src/ParaMEDMEM/DEC.cxx index 32bcc69ea..4003b65fc 100644 --- a/src/ParaMEDMEM/DEC.cxx +++ b/src/ParaMEDMEM/DEC.cxx @@ -84,42 +84,60 @@ namespace ParaMEDMEM { _union_group = source_group.fuse(target_group); } - - DEC::DEC(const int *src_ids_bg, const int *src_ids_end, - const int *trg_ids_bg, const int *trg_ids_end, - const MPI_Comm& world_comm):_local_field(0), - _owns_field(false), - _owns_groups(true), - _icoco_field(0) + DEC::DEC(const std::set& source_ids, const std::set& target_ids, const MPI_Comm& world_comm):_local_field(0), + _owns_field(false), + _owns_groups(true), + _icoco_field(0) { ParaMEDMEM::CommInterface comm; // Create the list of procs including source and target - int nbOfProcsInComm=std::distance(src_ids_bg,src_ids_end)+std::distance(trg_ids_bg,trg_ids_end); - int *allRanks=new int[nbOfProcsInComm]; - std::copy(src_ids_bg,src_ids_end,allRanks); - std::copy(trg_ids_bg,trg_ids_end,allRanks+std::distance(src_ids_bg,src_ids_end)); + std::set union_ids; // source and target ids in world_comm + union_ids.insert(source_ids.begin(),source_ids.end()); + union_ids.insert(target_ids.begin(),target_ids.end()); + int* union_ranks_world=new int[union_ids.size()]; // ranks of sources and targets in world_comm + std::copy::const_iterator,int*> (union_ids.begin(), union_ids.end(), union_ranks_world); + // Create a communicator on these procs - MPI_Group src_trg_group, world_group; + MPI_Group union_group,world_group; comm.commGroup(world_comm,&world_group); - comm.groupIncl(world_group,nbOfProcsInComm,allRanks,&src_trg_group); - MPI_Comm src_trg_comm; - comm.commCreate(world_comm,src_trg_group,&src_trg_comm); - delete [] allRanks; - // - if(src_trg_comm==MPI_COMM_NULL) - {//Current procid is not part of src_trg_comm + comm.groupIncl(world_group,union_ids.size(),union_ranks_world,&union_group); + MPI_Comm union_comm; + comm.commCreate(world_comm,union_group,&union_comm); + delete[] union_ranks_world; + + if (union_comm==MPI_COMM_NULL) + { // This process is not in union _source_group=0; _target_group=0; _union_group=0; return; } - std::set source_ids(src_ids_bg,src_ids_end); - _source_group=new MPIProcessorGroup(comm,source_ids,src_trg_comm); - std::set target_ids(trg_ids_bg,trg_ids_end); - _target_group=new MPIProcessorGroup(comm,target_ids,src_trg_comm); - std::set src_trg_ids(src_ids_bg,src_ids_end); - src_trg_ids.insert(trg_ids_bg,trg_ids_end); - _union_group=new MPIProcessorGroup(comm,src_trg_ids,src_trg_comm); + + // Translate source_ids and target_ids from world_comm to union_comm + int* source_ranks_world=new int[source_ids.size()]; // ranks of sources in world_comm + std::copy::const_iterator,int*> (source_ids.begin(), source_ids.end(),source_ranks_world); + int* source_ranks_union=new int[source_ids.size()]; // ranks of sources in union_comm + int* target_ranks_world=new int[target_ids.size()]; // ranks of targets in world_comm + std::copy::const_iterator,int*> (target_ids.begin(), target_ids.end(),target_ranks_world); + int* target_ranks_union=new int[target_ids.size()]; // ranks of targets in union_comm + MPI_Group_translate_ranks(world_group,source_ids.size(),source_ranks_world,union_group,source_ranks_union); + MPI_Group_translate_ranks(world_group,target_ids.size(),target_ranks_world,union_group,target_ranks_union); + std::set source_ids_union; + for (int i=0;i<(int)source_ids.size();i++) + source_ids_union.insert(source_ranks_union[i]); + std::set target_ids_union; + for (int i=0;i<(int)target_ids.size();i++) + target_ids_union.insert(target_ranks_union[i]); + delete [] source_ranks_world; + delete [] source_ranks_union; + delete [] target_ranks_world; + delete [] target_ranks_union; + + // Create the MPIProcessorGroups + _source_group= new MPIProcessorGroup(comm,source_ids_union,union_comm); + _target_group = new MPIProcessorGroup(comm,target_ids_union,union_comm); + _union_group = _source_group->fuse(*_target_group); + } DEC::~DEC() diff --git a/src/ParaMEDMEM/DEC.hxx b/src/ParaMEDMEM/DEC.hxx index e60825168..3c5ddf8fb 100644 --- a/src/ParaMEDMEM/DEC.hxx +++ b/src/ParaMEDMEM/DEC.hxx @@ -24,6 +24,8 @@ #include "NormalizedUnstructuredMesh.hxx" #include "DECOptions.hxx" +#include + namespace ICoCo { class Field; @@ -39,8 +41,7 @@ namespace ParaMEDMEM public: DEC():_local_field(0) { } DEC(ProcessorGroup& source_group, ProcessorGroup& target_group); - DEC(const int *src_ids_bg, const int *src_ids_end, - const int *trg_ids_bg, const int *trg_ids_end, + DEC(const std::set& src_ids, const std::set& trg_ids, const MPI_Comm& world_comm=MPI_COMM_WORLD); void setNature(NatureOfField nature); void attachLocalField( MEDCouplingFieldDouble* field); diff --git a/src/ParaMEDMEM/ElementLocator.cxx b/src/ParaMEDMEM/ElementLocator.cxx index e694c4e1d..3252279cd 100644 --- a/src/ParaMEDMEM/ElementLocator.cxx +++ b/src/ParaMEDMEM/ElementLocator.cxx @@ -35,7 +35,7 @@ using namespace std; -#define USE_DIRECTED_BB +//#define USE_DIRECTED_BB namespace ParaMEDMEM { @@ -299,14 +299,11 @@ namespace ParaMEDMEM ptDist2, nbDistElem, MPI_DOUBLE, iprocdistant_in_union, 1112, *comm, &status); - if(!distant_mesh_tmp->isEmptyMesh(tinyInfoDistant)) - { - distant_mesh=distant_mesh_tmp; - //finish unserialization - distant_mesh->unserialization(tinyInfoDistant,v1Distant,v2Distant,unusedTinyDistantSts); - } - else - distant_mesh_tmp->decrRef(); + // + distant_mesh=distant_mesh_tmp; + //finish unserialization + distant_mesh->unserialization(tinyInfoDistant,v1Distant,v2Distant,unusedTinyDistantSts); + // distant_ids_recv=new int[tinyInfoDistant.back()]; comm_interface.sendRecv((void *)distant_ids_send->getConstPointer(),tinyInfoLocal.back(), MPI_INT, iprocdistant_in_union, 1113, diff --git a/src/ParaMEDMEM/ExplicitCoincidentDEC.cxx b/src/ParaMEDMEM/ExplicitCoincidentDEC.cxx index 7794ef150..0d805af4f 100644 --- a/src/ParaMEDMEM/ExplicitCoincidentDEC.cxx +++ b/src/ParaMEDMEM/ExplicitCoincidentDEC.cxx @@ -288,7 +288,7 @@ namespace ParaMEDMEM } int* recvcounts=new int[world_size]; int* recvdispls=new int[world_size]; - int *dummyrecv; + int *dummyrecv=0; for (int i=0; i #include -#include using namespace ICoCo; using std::string; diff --git a/src/ParaMEDMEM/ICoCoField.hxx b/src/ParaMEDMEM/ICoCoField.hxx index c9d2813f6..b38eb0034 100644 --- a/src/ParaMEDMEM/ICoCoField.hxx +++ b/src/ParaMEDMEM/ICoCoField.hxx @@ -1,31 +1,15 @@ -// Copyright (C) 2007-2010 CEA/DEN, EDF R&D -// -// 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 __ICOCOFIELD_HXX__ -#define __ICOCOFIELD_HXX__ +// ICoCo file common to several codes +// ICoCoField.h +// version 1.2 10/05/2010 +#ifndef _ICoCoField_included_ +#define _ICoCoField_included_ #include -namespace ICoCo -{ - class Field - { + +namespace ICoCo { + + class Field { public: Field(); virtual ~Field(); @@ -37,5 +21,4 @@ namespace ICoCo std::string* _name; }; } - #endif diff --git a/src/ParaMEDMEM/ICoCoTrioField.cxx b/src/ParaMEDMEM/ICoCoTrioField.cxx index 1e5a14d22..0b18196c2 100644 --- a/src/ParaMEDMEM/ICoCoTrioField.cxx +++ b/src/ParaMEDMEM/ICoCoTrioField.cxx @@ -16,28 +16,41 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // - -////////////////////////////////////////////////////////////////////////////// -// File: ICoCoTrioField.cpp -// Directory: $TRIO_U_ROOT/Kernel/Framework -// Version: -////////////////////////////////////////////////////////////////////////////// +// ICoCo file common to several codes +// ICoCoTrioField.cpp +// version 1.2 10/05/2010 #include #include #include -#include +#include using namespace ICoCo; using namespace std; +// Default constructor TrioField::TrioField() : _type(0), + _mesh_dim(0), + _space_dim(0), + _nbnodes(0), + _nodes_per_elem(0), + _nb_elems(0), + _itnumber(0), _connectivity(0), _coords(0), + _time1(0.), + _time2(0.), + _nb_field_components(0), _field(0), _has_field_ownership(false) { } +// Copy constructor +TrioField::TrioField(const TrioField& OtherField) { + (*this)=OtherField; +} + +// Destructor TrioField::~TrioField() { clear(); } @@ -57,134 +70,124 @@ void TrioField::clear() { _has_field_ownership=false; } -int TrioField::nb_values() const -{ +// Returns the number of value locations +// The size of field is nb_values()*_nb_field_components +int TrioField::nb_values() const { if (_type==0) return _nb_elems; - else - if (_type==1) - return _nbnodes; - exit(-1); + else if (_type==1) + return _nbnodes; + throw 0; + //exit(-1); return -1; - } + +// Save field to a .field file (loadable by visit!) void TrioField::save(ostream& os) const{ - os <> name; setName(name); - in>>_type; - in>>_mesh_dim; - in>> _space_dim; - in>> _nbnodes; - in>> _nodes_per_elem; - in>> _nb_elems; + in >> _type; + in >> _mesh_dim; + in >> _space_dim; + in >> _nbnodes; + in >> _nodes_per_elem; + in >> _nb_elems; - in>> _itnumber; + in >> _itnumber; if (_connectivity) delete [] _connectivity; _connectivity=new int[_nodes_per_elem*_nb_elems]; - for (int i=0;i<_nb_elems;i++) - { - for (int j=0;j<_nodes_per_elem;j++) - in>>_connectivity[i*_nodes_per_elem+j]; - - } + for (int i=0;i<_nb_elems;i++) { + for (int j=0;j<_nodes_per_elem;j++) + in >> _connectivity[i*_nodes_per_elem+j]; + } if (_coords) delete [] _coords; _coords=new double[_nbnodes*_space_dim]; - for (int i=0;i<_nbnodes;i++) - { - for (int j=0;j<_space_dim;j++) - in>> _coords[i*_space_dim+j] ; - - } + for (int i=0;i<_nbnodes;i++) { + for (int j=0;j<_space_dim;j++) + in >> _coords[i*_space_dim+j]; + } - in>> _time1; - in>>_time2; - in>> _nb_field_components; + in >> _time1; + in >> _time2; + in >> _nb_field_components; int test; - in>> test; - if (test) - { - if (_field) - delete [] _field; - _field=new double[_nb_field_components*nb_values()]; - for (int i=0;i> _field[i*_nb_field_components+j]; - - } + in >> test; + if (test) { + if (_field) + delete [] _field; + _field=new double[_nb_field_components*nb_values()]; + for (int i=0;i> _field[i*_nb_field_components+j]; } + } else - { - _field=0; - } - in>> _has_field_ownership; + _field=0; + + in >> _has_field_ownership; } - void TrioField::print() { - } // After the call to set_standalone(), field ownership is true and field is allocated -// to the size _nb_field_components*_nb_elems. +// to the size _nb_field_components*nb_values(). // The values of the field have been copied if necessary. void TrioField::set_standalone() { if (!_field) { - _field=new double[_nb_field_components*_nb_elems]; + _field=new double[_nb_field_components*nb_values()]; _has_field_ownership=true; } else if (!_has_field_ownership) { - double *tmp_field=new double[_nb_field_components*_nb_elems]; - memcpy(tmp_field,_field,_nb_field_components*_nb_elems*sizeof(double)); + double *tmp_field=new double[_nb_field_components*nb_values()]; + memcpy(tmp_field,_field,_nb_field_components*nb_values()*sizeof(double)); _field=tmp_field; _has_field_ownership=true; } @@ -192,6 +195,7 @@ void TrioField::set_standalone() { // Used to simulate a 0D geometry (Cathare/Trio for example). void TrioField::dummy_geom() { + _type=0; _mesh_dim=2; _space_dim=2; _nbnodes=3; @@ -201,9 +205,9 @@ void TrioField::dummy_geom() { if (_connectivity) delete[] _connectivity; _connectivity=new int[3]; - _connectivity[0]=1; - _connectivity[1]=2; - _connectivity[2]=3; + _connectivity[0]=0; + _connectivity[1]=1; + _connectivity[2]=2; if (_coords) delete[] _coords; _coords=new double[6]; @@ -213,53 +217,60 @@ void TrioField::dummy_geom() { _coords[3]=0; _coords[4]=0; _coords[5]=1; + _time1=0; + _time2=1; + _nb_field_components=1; if (_field && _has_field_ownership) delete[] _field; _has_field_ownership=false; _field=0; } -// Surcharge de l'operateur = pour la classe TrioField -// remplace les valeurs trouvee dans le TrioField donnee en parametre +// Overloading operator = for TrioField +// This becomes an exact copy of NewField. +// If NewField._has_field_ownership is false, they point to the same values. +// Otherwise the values are copied. TrioField& TrioField::operator=(const TrioField& NewField){ - clear(); - _type=NewField._type; - _mesh_dim=NewField._mesh_dim; - _space_dim=NewField._space_dim; - _nbnodes=NewField._nbnodes; - _nodes_per_elem=NewField._nodes_per_elem; - _nb_elems=NewField._nb_elems; - _itnumber=NewField._itnumber; - // std::string _name; // ?? Hérité de la classe mère - _time1=NewField._time1; - _time2=NewField._time2; - _nb_field_components=NewField._nb_field_components; + clear(); - if (!NewField._connectivity) - _connectivity=0; - else { - _connectivity=new int[_nodes_per_elem*_nb_elems]; - memcpy( _connectivity,NewField._connectivity,_nodes_per_elem*_nb_elems*sizeof(int)); - } + _type=NewField._type; + _mesh_dim=NewField._mesh_dim; + _space_dim=NewField._space_dim; + _nbnodes=NewField._nbnodes; + _nodes_per_elem=NewField._nodes_per_elem; + _nb_elems=NewField._nb_elems; + _itnumber=NewField._itnumber; + _time1=NewField._time1; + _time2=NewField._time2; + _nb_field_components=NewField._nb_field_components; - if (!NewField._coords) - _coords=0; - else { - _coords=new double[_nbnodes*_space_dim]; - memcpy( _coords,NewField._coords,_nbnodes*_space_dim*sizeof(double)); - } + if (!NewField._connectivity) + _connectivity=0; + else { + _connectivity=new int[_nodes_per_elem*_nb_elems]; + memcpy( _connectivity,NewField._connectivity,_nodes_per_elem*_nb_elems*sizeof(int)); + } - //Copie des valeurs du champ - _has_field_ownership=NewField._has_field_ownership; - if (_has_field_ownership) { - _field=new double[_nb_elems*_nb_field_components]; - memcpy(_field,NewField._field,_nb_elems*_nb_field_components*sizeof(double)); - } - else - _field=NewField._field; + if (!NewField._coords) + _coords=0; + else { + _coords=new double[_nbnodes*_space_dim]; + memcpy( _coords,NewField._coords,_nbnodes*_space_dim*sizeof(double)); + } - return(*this); + //Copie des valeurs du champ + _has_field_ownership=NewField._has_field_ownership; + if (_has_field_ownership) { + _field=new double[nb_values()*_nb_field_components]; + memcpy(_field,NewField._field,nb_values()*_nb_field_components*sizeof(double)); + } + else + _field=NewField._field; + + return(*this); } + + diff --git a/src/ParaMEDMEM/ICoCoTrioField.hxx b/src/ParaMEDMEM/ICoCoTrioField.hxx index cb238ff5c..738e312ea 100644 --- a/src/ParaMEDMEM/ICoCoTrioField.hxx +++ b/src/ParaMEDMEM/ICoCoTrioField.hxx @@ -16,46 +16,42 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +// ICoCo file common to several codes +// ICoCoTrioField.h +// version 1.2 10/05/2010 -////////////////////////////////////////////////////////////////////////////// -// File: ICoCoTrioField.h -// Directory: $TRIO_U_ROOT/Kernel/Framework -// Version: -////////////////////////////////////////////////////////////////////////////// - -#ifndef _ICOCOTRIOFIELD_HXX_ -#define _ICOCOTRIOFIELD_HXX_ +#ifndef _ICoCoTrioField_included_ +#define _ICoCoTrioField_included_ #include -namespace ICoCo -{ - /*! - \brief structure for coupling Trio codes via the ICoCo interface - - This structure contains all the necessary information - for constructing a ParaMEDMEM::ParaFIELD (with the addition of the MPI - communicator). The ICoCo API specifies two kinds of calls for - the ICoCo::Field : either with the mesh only or with the entire information (mesh and field). - This structure can therefore be left without _time, _nb_field_components, _field - information, which are related to the field values. +namespace ICoCo { - _coords and _connectivity tables are always owned by the TrioField. - - */ - class TrioField:public Field - { + ////////////////////////////////////////////////////////////////////////////// + // + // .DESCRIPTION + // class TrioField, used for coupling Trio codes via the ICoCo interface + // This structure contains all the necessary information + // for constructing a ParaMEDMEM::ParaFIELD (with the addition of the MPI + // communicator). + // This structure can either own or not _field values (_has_field_ownership) + // For _coords, _connectivity and _field, a null pointer means no data allocated. + // _coords and _connectivity tables, when allocated, are always owned by the TrioField. + // + ////////////////////////////////////////////////////////////////////////////// + class TrioField:public Field { public: TrioField(); + TrioField(const TrioField& OtherField); ~TrioField(); void clear(); - void print(); void set_standalone(); void dummy_geom(); TrioField& operator=(const TrioField& NewField); void save(std::ostream& os) const; void restore(std::istream& in); int nb_values() const ; + public: int _type ; // 0 elem 1 nodes int _mesh_dim; diff --git a/src/ParaMEDMEM/InterpKernelDEC.cxx b/src/ParaMEDMEM/InterpKernelDEC.cxx index 1eb5a243e..6c4674f84 100644 --- a/src/ParaMEDMEM/InterpKernelDEC.cxx +++ b/src/ParaMEDMEM/InterpKernelDEC.cxx @@ -123,9 +123,8 @@ namespace ParaMEDMEM } - InterpKernelDEC::InterpKernelDEC(const int *src_ids_bg, const int *src_ids_end, - const int *trg_ids_bg, const int *trg_ids_end, - const MPI_Comm& world_comm):DEC(src_ids_bg,src_ids_end,trg_ids_bg,trg_ids_end,world_comm), + InterpKernelDEC::InterpKernelDEC(const std::set& src_ids, const std::set& trg_ids, + const MPI_Comm& world_comm):DEC(src_ids,trg_ids,world_comm), _interpolation_matrix(0) { } @@ -160,10 +159,8 @@ namespace ParaMEDMEM { //locate the distant meshes ElementLocator locator(*_local_field, *_target_group, *_source_group); - - //transfering option from InterpKernelDEC to ElementLocator - locator.setBoundingBoxAdjustment(getBoundingBoxAdjustment()); - + //transfering option from InterpKernelDEC to ElementLocator + locator.copyOptions(*this); MEDCouplingPointSet* distant_mesh=0; int* distant_ids=0; std::string distantMeth; @@ -194,8 +191,7 @@ namespace ParaMEDMEM { ElementLocator locator(*_local_field, *_source_group, *_target_group); //transfering option from InterpKernelDEC to ElementLocator - locator.setBoundingBoxAdjustment(getBoundingBoxAdjustment()); - + locator.copyOptions(*this); MEDCouplingPointSet* distant_mesh=0; int* distant_ids=0; for (int i=0; i<_source_group->size(); i++) diff --git a/src/ParaMEDMEM/InterpKernelDEC.hxx b/src/ParaMEDMEM/InterpKernelDEC.hxx index 908f21700..7930a044d 100644 --- a/src/ParaMEDMEM/InterpKernelDEC.hxx +++ b/src/ParaMEDMEM/InterpKernelDEC.hxx @@ -33,8 +33,7 @@ namespace ParaMEDMEM public: InterpKernelDEC(); InterpKernelDEC(ProcessorGroup& source_group, ProcessorGroup& target_group); - InterpKernelDEC(const int *src_ids_bg, const int *src_ids_end, - const int *trg_ids_bg, const int *trg_ids_end, + InterpKernelDEC(const std::set& src_ids, const std::set& trg_ids, const MPI_Comm& world_comm=MPI_COMM_WORLD); virtual ~InterpKernelDEC(); void synchronize(); diff --git a/src/ParaMEDMEM/InterpolationMatrix.cxx b/src/ParaMEDMEM/InterpolationMatrix.cxx index 5f3a424ea..c7db0371c 100644 --- a/src/ParaMEDMEM/InterpolationMatrix.cxx +++ b/src/ParaMEDMEM/InterpolationMatrix.cxx @@ -24,6 +24,8 @@ #include "InterpolationMatrix.hxx" #include "TranslationRotationMatrix.hxx" #include "Interpolation.hxx" +#include "Interpolation1D.txx" +#include "Interpolation2DCurve.txx" #include "Interpolation2D.txx" #include "Interpolation3DSurf.txx" #include "Interpolation3D.txx" @@ -160,6 +162,28 @@ namespace ParaMEDMEM { throw INTERP_KERNEL::Exception("local and distant meshes do not have the same space and mesh dimensions"); } + else if( distant_support.getMeshDimension() == 1 + && distant_support.getSpaceDimension() == 1 ) + { + MEDCouplingNormalizedUnstructuredMesh<1,1> target_wrapper(distant_supportC); + MEDCouplingNormalizedUnstructuredMesh<1,1> source_wrapper(source_supportC); + + INTERP_KERNEL::Interpolation1D interpolation(*this); + colSize=interpolation.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod.c_str()); + target_wrapper.releaseTempArrays(); + source_wrapper.releaseTempArrays(); + } + else if( distant_support.getMeshDimension() == 1 + && distant_support.getSpaceDimension() == 2 ) + { + MEDCouplingNormalizedUnstructuredMesh<2,1> target_wrapper(distant_supportC); + MEDCouplingNormalizedUnstructuredMesh<2,1> source_wrapper(source_supportC); + + INTERP_KERNEL::Interpolation2DCurve interpolation(*this); + colSize=interpolation.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod.c_str()); + target_wrapper.releaseTempArrays(); + source_wrapper.releaseTempArrays(); + } else if ( distant_support.getMeshDimension() == 2 && distant_support.getSpaceDimension() == 3 ) { diff --git a/src/ParaMEDMEM/ParaFIELD.cxx b/src/ParaMEDMEM/ParaFIELD.cxx index 6822a19fb..e0f0ba085 100644 --- a/src/ParaMEDMEM/ParaFIELD.cxx +++ b/src/ParaMEDMEM/ParaFIELD.cxx @@ -213,7 +213,7 @@ namespace ParaMEDMEM double ParaFIELD::getVolumeIntegral(int icomp, bool isWAbs) const { CommInterface comm_interface = _topology->getProcGroup()->getCommInterface(); - double integral=_field->measureAccumulate(icomp,isWAbs); + double integral=_field->integral(icomp,isWAbs); double total=0.; const MPI_Comm* comm = (dynamic_cast(_topology->getProcGroup()))->getComm(); comm_interface.allReduce(&integral, &total, 1, MPI_DOUBLE, MPI_SUM, *comm); diff --git a/src/ParaMEDMEMTest/MPI2Connector.cxx b/src/ParaMEDMEMTest/MPI2Connector.cxx new file mode 100644 index 000000000..8daa23516 --- /dev/null +++ b/src/ParaMEDMEMTest/MPI2Connector.cxx @@ -0,0 +1,143 @@ +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// +// 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 "MPI2Connector.hxx" + +#include + +MPI2Connector::MPI2Connector() +{ + MPI_Comm_size( MPI_COMM_WORLD, &_nb_proc ); + MPI_Comm_rank( MPI_COMM_WORLD, &_num_proc ); +} + +MPI2Connector::~MPI2Connector() +{ +} + +MPI_Comm MPI2Connector::remoteMPI2Connect(const std::string& service) +{ + int i; + char port_name[MPI_MAX_PORT_NAME]; + char port_name_clt[MPI_MAX_PORT_NAME]; + std::ostringstream msg; + MPI_Comm icom; + + if( service.size() == 0 ) + { + msg << "[" << _num_proc << "] You have to give a service name !"; + std::cerr << msg.str().c_str() << std::endl; + throw std::exception(); + } + + _srv = false; + + MPI_Barrier(MPI_COMM_WORLD); + + MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_RETURN); + if( _num_proc == 0 ) + { + /* rank 0 try to be a server. If service is already published, try to be a cient */ + MPI_Open_port(MPI_INFO_NULL, port_name); + if ( MPI_Publish_name((char*)service.c_str(), MPI_INFO_NULL, port_name) == MPI_SUCCESS ) + { + _srv = true; + _port_name = port_name; + std::cerr << "[" << _num_proc << "] service " << service << " available at " << port_name << std::endl; + } + else if ( MPI_Lookup_name((char*)service.c_str(), MPI_INFO_NULL, port_name_clt) == MPI_SUCCESS ) + { + std::cerr << "[" << _num_proc << "] I get the connection with " << service << " at " << port_name_clt << std::endl; + MPI_Close_port( port_name ); + } + else + { + msg << "[" << _num_proc << "] Error on connection with " << service << " at " << port_name_clt; + std::cerr << msg.str().c_str() << std::endl; + throw std::exception(); + } + } + else + { + i=0; + /* Waiting rank 0 publish name and try to be a client */ + while ( i != TIMEOUT ) + { + sleep(1); + if ( MPI_Lookup_name((char*)service.c_str(), MPI_INFO_NULL, port_name_clt) == MPI_SUCCESS ) + { + std::cerr << "[" << _num_proc << "] I get the connection with " << service << " at " << port_name_clt << std::endl; + break; + } + i++; + } + if(i==TIMEOUT) + { + msg << "[" << _num_proc << "] Error on connection with " << service << " at " << port_name_clt; + std::cerr << msg.str().c_str() << std::endl; + throw std::exception(); + } + } + MPI_Errhandler_set(MPI_COMM_WORLD, MPI_ERRORS_ARE_FATAL); + + /* If rank 0 is server, all processes call MPI_Comm_accept */ + /* If rank 0 is not server, all processes call MPI_Comm_connect */ + int srv = (int)_srv; + MPI_Bcast(&srv,1,MPI_INT,0,MPI_COMM_WORLD); + _srv = (bool)srv; + if ( _srv ) + MPI_Comm_accept( port_name, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &icom ); + else + MPI_Comm_connect(port_name_clt, MPI_INFO_NULL, 0, MPI_COMM_WORLD, &icom ); + + /* create global communicator: servers have low index in global communicator*/ + MPI_Intercomm_merge(icom,!_srv,&_gcom); + + /* only rank 0 can be server for unpublish name */ + if(_num_proc != 0) _srv = false; + + return _gcom; + +} + +void MPI2Connector::remoteMPI2Disconnect(const std::string& service) +{ + std::ostringstream msg; + + if( service.size() == 0 ) + { + msg << "[" << _num_proc << "] You have to give a service name !"; + std::cerr << msg.str().c_str() << std::endl; + throw std::exception(); + } + + MPI_Comm_disconnect( &_gcom ); + if ( _srv ) + { + + char port_name[MPI_MAX_PORT_NAME]; + strcpy(port_name,_port_name.c_str()); + + MPI_Unpublish_name((char*)service.c_str(), MPI_INFO_NULL, port_name); + std::cerr << "[" << _num_proc << "] " << service << ": close port " << _port_name << std::endl; + MPI_Close_port( port_name ); + } + +} + diff --git a/src/ParaMEDMEMTest/MPI2Connector.hxx b/src/ParaMEDMEMTest/MPI2Connector.hxx new file mode 100644 index 000000000..905de10fb --- /dev/null +++ b/src/ParaMEDMEMTest/MPI2Connector.hxx @@ -0,0 +1,48 @@ +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// +// 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 __MPI2CONNECTOR_HXX__ +#define __MPI2CONNECTOR_HXX__ + +#include +#include +#include + +class MPI2Connector +{ +public: + MPI2Connector(); + ~MPI2Connector(); + // MPI2 connection + MPI_Comm remoteMPI2Connect(const std::string& service); + // MPI2 disconnection + void remoteMPI2Disconnect(const std::string& service); +private: + // Processus id + int _num_proc; + // Processus size + int _nb_proc; + MPI_Comm _gcom; + bool _srv; + std::string _port_name; +private: + static const int TIMEOUT=5; +}; + +#endif diff --git a/src/ParaMEDMEMTest/Makefile.am b/src/ParaMEDMEMTest/Makefile.am index d2a12d21f..f5478b9b9 100644 --- a/src/ParaMEDMEMTest/Makefile.am +++ b/src/ParaMEDMEMTest/Makefile.am @@ -25,9 +25,8 @@ salomeinclude_HEADERS = \ MPIMainTest.hxx \ MPIAccessDECTest.hxx \ MPIAccessTest.hxx \ - ParaMEDMEMTest.hxx - -EXTRA_DIST += MPIMainTest.hxx ParaMEDMEMTest_NonCoincidentDEC.cxx + ParaMEDMEMTest.hxx \ + MPI2Connector.hxx dist_libParaMEDMEMTest_la_SOURCES = \ ParaMEDMEMTest.cxx \ @@ -39,6 +38,7 @@ dist_libParaMEDMEMTest_la_SOURCES = \ ParaMEDMEMTest_ICocoTrio.cxx \ ParaMEDMEMTest_Gauthier1.cxx \ ParaMEDMEMTest_FabienAPI.cxx \ + ParaMEDMEMTest_NonCoincidentDEC.cxx \ MPIAccessDECTest.cxx \ test_AllToAllDEC.cxx \ test_AllToAllvDEC.cxx \ @@ -62,7 +62,6 @@ dist_libParaMEDMEMTest_la_SOURCES = \ test_MPI_Access_Time_0.cxx \ test_MPI_Access_ISend_IRecv_BottleNeck.cxx - libParaMEDMEMTest_la_CPPFLAGS = \ @CPPUNIT_INCLUDES@ \ $(MPI_INCLUDES) \ @@ -91,13 +90,27 @@ dist_TestMPIAccessDEC_SOURCES = TestMPIAccessDEC.cxx dist_TestMPIAccess_SOURCES = TestMPIAccess.cxx dist_test_perf_SOURCES = test_perf.cxx +if MPI2_IS_OK +bin_PROGRAMS += \ + ParaMEDMEMTestMPI2_1 \ + ParaMEDMEMTestMPI2_2 + +dist_ParaMEDMEMTestMPI2_1_SOURCES = \ + MPI2Connector.cxx \ + ParaMEDMEMTestMPI2_1.cxx + +dist_ParaMEDMEMTestMPI2_2_SOURCES = \ + MPI2Connector.cxx \ + ParaMEDMEMTestMPI2_2.cxx + +endif + LDADD = $(MED2_LIBS) $(libMEDMEMTest_la_LDFLAGS) -lm $(MPI_LIBS) \ libParaMEDMEMTest.la \ ../INTERP_KERNEL/libinterpkernel.la if MED_ENABLE_FVM LDADD += $(FVM_LIBS) - dist_libParaMEDMEMTest_la_SOURCES += ParaMEDMEMTest_NonCoincidentDEC.cxx libParaMEDMEMTest_la_CPPFLAGS += -DMED_ENABLE_FVM $(FVM_INCLUDES) libParaMEDMEMTest_la_LDFLAGS += $(FVM_LIBS) endif diff --git a/src/ParaMEDMEMTest/ParaMEDMEMTest.hxx b/src/ParaMEDMEMTest/ParaMEDMEMTest.hxx index da4e4873c..be30599ae 100644 --- a/src/ParaMEDMEMTest/ParaMEDMEMTest.hxx +++ b/src/ParaMEDMEMTest/ParaMEDMEMTest.hxx @@ -36,6 +36,8 @@ class ParaMEDMEMTest : public CppUnit::TestFixture CPPUNIT_TEST(testMPIProcessorGroup_rank); CPPUNIT_TEST(testBlockTopology_constructor); CPPUNIT_TEST(testBlockTopology_serialize); + CPPUNIT_TEST(testInterpKernelDEC_1D); + CPPUNIT_TEST(testInterpKernelDEC_2DCurve); CPPUNIT_TEST(testInterpKernelDEC_2D); CPPUNIT_TEST(testInterpKernelDEC2_2D); CPPUNIT_TEST(testInterpKernelDEC_2DP0P1); @@ -44,6 +46,7 @@ class ParaMEDMEMTest : public CppUnit::TestFixture CPPUNIT_TEST(testInterpKernelDECNonOverlapp_2D_P0P1P1P0); CPPUNIT_TEST(testInterpKernelDEC2DM1D_P0P0); CPPUNIT_TEST(testInterpKernelDECPartialProcs); + CPPUNIT_TEST(testInterpKernelDEC3DSurfEmptyBBox); CPPUNIT_TEST(testSynchronousEqualInterpKernelWithoutInterpNativeDEC_2D); CPPUNIT_TEST(testSynchronousEqualInterpKernelWithoutInterpDEC_2D); @@ -68,6 +71,7 @@ class ParaMEDMEMTest : public CppUnit::TestFixture CPPUNIT_TEST(testGauthier1); CPPUNIT_TEST(testGauthier2); CPPUNIT_TEST(testFabienAPI1); + CPPUNIT_TEST(testFabienAPI2); CPPUNIT_TEST(testMEDLoaderRead1); CPPUNIT_TEST(testMEDLoaderPolygonRead); CPPUNIT_TEST(testMEDLoaderPolyhedronRead); @@ -87,6 +91,8 @@ public: void testMPIProcessorGroup_rank(); void testBlockTopology_constructor(); void testBlockTopology_serialize(); + void testInterpKernelDEC_1D(); + void testInterpKernelDEC_2DCurve(); void testInterpKernelDEC_2D(); void testInterpKernelDEC2_2D(); void testInterpKernelDEC_2DP0P1(); @@ -95,6 +101,7 @@ public: void testInterpKernelDECNonOverlapp_2D_P0P1P1P0(); void testInterpKernelDEC2DM1D_P0P0(); void testInterpKernelDECPartialProcs(); + void testInterpKernelDEC3DSurfEmptyBBox(); #ifdef MED_ENABLE_FVM void testNonCoincidentDEC_2D(); void testNonCoincidentDEC_3D(); @@ -118,6 +125,7 @@ public: void testGauthier1(); void testGauthier2(); void testFabienAPI1(); + void testFabienAPI2(); // void testMEDLoaderRead1(); void testMEDLoaderPolygonRead(); @@ -130,11 +138,13 @@ public: std::string makeTmpFile( const std::string&, const std::string& = "" ); private: +#ifdef MED_ENABLE_FVM void testNonCoincidentDEC(const std::string& filename1, const std::string& meshname1, const std::string& filename2, const std::string& meshname2, int nbprocsource, double epsilon); +#endif void testAsynchronousInterpKernelDEC_2D(double dtA, double tmaxA, double dtB, double tmaxB, bool WithPointToPoint, bool Asynchronous, bool WithInterp, const char *srcMeth, const char *targetMeth); diff --git a/src/ParaMEDMEMTest/ParaMEDMEMTestMPI2_1.cxx b/src/ParaMEDMEMTest/ParaMEDMEMTestMPI2_1.cxx new file mode 100644 index 000000000..599d3fb57 --- /dev/null +++ b/src/ParaMEDMEMTest/ParaMEDMEMTestMPI2_1.cxx @@ -0,0 +1,125 @@ +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// +// 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 + +#include "MPI2Connector.hxx" +#include "ParaMESH.hxx" +#include "ParaFIELD.hxx" +#include "MEDCouplingUMesh.hxx" +#include "MEDCouplingFieldDouble.hxx" +#include "InterpKernelDEC.hxx" +#include "MPIProcessorGroup.hxx" +#include "CommInterface.hxx" + +#include +#include +#include + +class MPI2ParaMEDMEMTest : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE( MPI2ParaMEDMEMTest ); + CPPUNIT_TEST( testBasicMPI2_1 ); + CPPUNIT_TEST_SUITE_END(); +public: + void testBasicMPI2_1(); +}; + +using namespace ParaMEDMEM; + +void MPI2ParaMEDMEMTest::testBasicMPI2_1() +{ + int lsize, lrank, gsize, grank; + MPI_Comm gcom; + std::string service = "SERVICE"; + std::ostringstream meshfilename, meshname; + ParaMEDMEM::ParaMESH *paramesh=0; + ParaMEDMEM::MEDCouplingUMesh *mesh; + ParaMEDMEM::ParaFIELD *parafield=0; + ParaMEDMEM::CommInterface *interface; + ParaMEDMEM::MPIProcessorGroup *source, *target; + + MPI_Comm_size( MPI_COMM_WORLD, &lsize ); + MPI_Comm_rank( MPI_COMM_WORLD, &lrank ); + if(lsize!=2) + { + CPPUNIT_ASSERT(false); + return; + } + + /* Connection to remote programm */ + MPI2Connector *mpio = new MPI2Connector; + gcom = mpio->remoteMPI2Connect(service); + MPI_Comm_size( gcom, &gsize ); + MPI_Comm_rank( gcom, &grank ); + if(gsize!=5) + { + CPPUNIT_ASSERT(false); + return; + } + interface = new ParaMEDMEM::CommInterface; + source = new ParaMEDMEM::MPIProcessorGroup(*interface,0,lsize-1,gcom); + target = new ParaMEDMEM::MPIProcessorGroup(*interface,lsize,gsize-1,gcom); + + const double sourceCoordsAll[2][8]={{0.4,0.5,0.4,1.5,1.6,1.5,1.6,0.5}, + {0.3,-0.5,1.6,-0.5,1.6,-1.5,0.3,-1.5}}; + + int conn4All[8]={0,1,2,3,4,5,6,7}; + + std::ostringstream stream; stream << "sourcemesh2D proc " << grank; + mesh=MEDCouplingUMesh::New(stream.str().c_str(),2); + mesh->allocateCells(2); + mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn4All); + mesh->finishInsertingCells(); + DataArrayDouble *myCoords=DataArrayDouble::New(); + myCoords->alloc(4,2); + const double *sourceCoords=sourceCoordsAll[grank]; + std::copy(sourceCoords,sourceCoords+8,myCoords->getPointer()); + mesh->setCoords(myCoords); + myCoords->decrRef(); + paramesh=new ParaMESH(mesh,*source,"source mesh"); + ParaMEDMEM::ComponentTopology comptopo; + parafield = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); + double *value=parafield->getField()->getArray()->getPointer(); + value[0]=34+13*((double)grank); + + ParaMEDMEM::InterpKernelDEC dec(*source,*target); + parafield->getField()->setNature(ConservativeVolumic); + + + dec.setMethod("P0"); + dec.attachLocalField(parafield); + dec.synchronize(); + dec.setForcedRenormalization(false); + dec.sendData(); + /* Deconnection of remote programm */ + mpio->remoteMPI2Disconnect(service); + /* clean-up */ + delete mpio; + delete parafield; + mesh->decrRef(); + delete paramesh; + delete source; + delete target; + delete interface; +} + +CPPUNIT_TEST_SUITE_REGISTRATION( MPI2ParaMEDMEMTest ); + +#include "MPIMainTest.hxx" diff --git a/src/ParaMEDMEMTest/ParaMEDMEMTestMPI2_2.cxx b/src/ParaMEDMEMTest/ParaMEDMEMTestMPI2_2.cxx new file mode 100644 index 000000000..9ed8819b0 --- /dev/null +++ b/src/ParaMEDMEMTest/ParaMEDMEMTestMPI2_2.cxx @@ -0,0 +1,130 @@ +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D +// +// 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 + +#include "MPI2Connector.hxx" +#include "ParaMESH.hxx" +#include "ParaFIELD.hxx" +#include "MEDCouplingUMesh.hxx" +#include "MEDCouplingFieldDouble.hxx" +#include "InterpKernelDEC.hxx" +#include "MPIProcessorGroup.hxx" +#include "CommInterface.hxx" + +#include +#include +#include + +class MPI2ParaMEDMEMTest : public CppUnit::TestFixture +{ + CPPUNIT_TEST_SUITE( MPI2ParaMEDMEMTest ); + CPPUNIT_TEST( testBasicMPI2_1 ); + CPPUNIT_TEST_SUITE_END(); +public: + void testBasicMPI2_1(); +}; + +using namespace ParaMEDMEM; + +void MPI2ParaMEDMEMTest::testBasicMPI2_1() +{ + int lsize, lrank, gsize, grank; + MPI_Comm gcom; + std::string service = "SERVICE"; + std::ostringstream meshfilename, meshname; + ParaMEDMEM::ParaMESH *paramesh=0; + ParaMEDMEM::MEDCouplingUMesh* mesh; + ParaMEDMEM::ParaFIELD *parafield=0; + ParaMEDMEM::CommInterface* interface; + ParaMEDMEM::MPIProcessorGroup* source, *target; + + MPI_Comm_size( MPI_COMM_WORLD, &lsize ); + MPI_Comm_rank( MPI_COMM_WORLD, &lrank ); + if(lsize!=3) + { + CPPUNIT_ASSERT(false); + return; + } + + /* Connection to remote programm */ + MPI2Connector *mpio = new MPI2Connector; + gcom = mpio->remoteMPI2Connect(service); + + MPI_Comm_size( gcom, &gsize ); + MPI_Comm_rank( gcom, &grank ); + if(gsize!=5) + { + CPPUNIT_ASSERT(false); + return; + } + + interface = new ParaMEDMEM::CommInterface; + source = new ParaMEDMEM::MPIProcessorGroup(*interface,0,gsize-lsize-1,gcom); + target = new ParaMEDMEM::MPIProcessorGroup(*interface,gsize-lsize,gsize-1,gcom); + + const double targetCoordsAll[3][16]={{0.7,1.45,0.7,1.65,0.9,1.65,0.9,1.45, 1.1,1.4,1.1,1.6,1.3,1.6,1.3,1.4}, + {0.7,-0.6,0.7,0.7,0.9,0.7,0.9,-0.6, 1.1,-0.7,1.1,0.6,1.3,0.6,1.3,-0.7}, + {0.7,-1.55,0.7,-1.35,0.9,-1.35,0.9,-1.55, 1.1,-1.65,1.1,-1.45,1.3,-1.45,1.3,-1.65}}; + int conn4All[8]={0,1,2,3,4,5,6,7}; + double targetResults[3][2]={{34.,34.},{38.333333333333336,42.666666666666664},{47.,47.}}; + + std::ostringstream stream; stream << "targetmesh2D proc " << grank-(gsize-lsize); + mesh=MEDCouplingUMesh::New(stream.str().c_str(),2); + mesh->allocateCells(2); + mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn4All); + mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn4All+4); + mesh->finishInsertingCells(); + DataArrayDouble *myCoords=DataArrayDouble::New(); + myCoords->alloc(8,2); + const double *targetCoords=targetCoordsAll[grank-(gsize-lsize)]; + std::copy(targetCoords,targetCoords+16,myCoords->getPointer()); + mesh->setCoords(myCoords); + myCoords->decrRef(); + paramesh=new ParaMESH (mesh,*target,"target mesh"); + ParaMEDMEM::ComponentTopology comptopo; + parafield = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); + + ParaMEDMEM::InterpKernelDEC dec(*source,*target); + parafield->getField()->setNature(ConservativeVolumic); + + dec.setMethod("P0"); + dec.attachLocalField(parafield); + dec.synchronize(); + dec.setForcedRenormalization(false); + dec.recvData(); + const double *res=parafield->getField()->getArray()->getConstPointer(); + const double *expected=targetResults[grank-(gsize-lsize)]; + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[0],res[0],1e-13); + CPPUNIT_ASSERT_DOUBLES_EQUAL(expected[1],res[1],1e-13); + /* Deconnection of remote programm */ + mpio->remoteMPI2Disconnect(service); + /* clean-up */ + delete mpio; + delete parafield; + mesh->decrRef(); + delete paramesh; + delete source; + delete target; + delete interface; +} + +CPPUNIT_TEST_SUITE_REGISTRATION( MPI2ParaMEDMEMTest ); + +#include "MPIMainTest.hxx" diff --git a/src/ParaMEDMEMTest/ParaMEDMEMTest_FabienAPI.cxx b/src/ParaMEDMEMTest/ParaMEDMEMTest_FabienAPI.cxx index 92c33f5b3..a08eb9995 100644 --- a/src/ParaMEDMEMTest/ParaMEDMEMTest_FabienAPI.cxx +++ b/src/ParaMEDMEMTest/ParaMEDMEMTest_FabienAPI.cxx @@ -40,8 +40,10 @@ void ParaMEDMEMTest::testFabienAPI1() // if(size!=3) return ; - int procs_source[1]={0}; - int procs_target[1]={1}; + int procs_source_c[1]={0}; + std::set procs_source(procs_source_c,procs_source_c+1); + int procs_target_c[1]={1}; + std::set procs_target(procs_target_c,procs_target_c+1); // ParaMEDMEM::MEDCouplingUMesh *mesh=0; ParaMEDMEM::ParaMESH *paramesh=0; @@ -53,7 +55,92 @@ void ParaMEDMEMTest::testFabienAPI1() double targetCoords[8]={ 0.,0., 1., 0., 0., 1., 1., 1. }; CommInterface comm; // - ParaMEDMEM::InterpKernelDEC *dec=new ParaMEDMEM::InterpKernelDEC(procs_source,procs_source+1,procs_target,procs_target+1); + ParaMEDMEM::InterpKernelDEC *dec=new ParaMEDMEM::InterpKernelDEC(procs_source,procs_target); + if(dec->isInSourceSide()) + { + mesh=MEDCouplingUMesh::New(); + mesh->setMeshDimension(2); + DataArrayDouble *myCoords=DataArrayDouble::New(); + myCoords->alloc(4,2); + std::copy(targetCoords,targetCoords+8,myCoords->getPointer()); + mesh->setCoords(myCoords); + myCoords->decrRef(); + int targetConn[4]={0,2,3,1}; + mesh->allocateCells(1); + mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,targetConn); + mesh->finishInsertingCells(); + ParaMEDMEM::ComponentTopology comptopo; + paramesh=new ParaMESH(mesh,*dec->getSourceGrp(),"source mesh"); + parafield=new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); + parafield->getField()->setNature(ConservativeVolumic); + double *vals=parafield->getField()->getArray()->getPointer(); + vals[0]=7.; + } + if(dec->isInTargetSide()) + { + mesh=MEDCouplingUMesh::New(); + mesh->setMeshDimension(2); + DataArrayDouble *myCoords=DataArrayDouble::New(); + myCoords->alloc(4,2); + std::copy(targetCoords,targetCoords+8,myCoords->getPointer()); + mesh->setCoords(myCoords); + myCoords->decrRef(); + int targetConn[6]={0,2,1,2,3,1}; + mesh->allocateCells(2); + mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn); + mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,3,targetConn+3); + mesh->finishInsertingCells(); + ParaMEDMEM::ComponentTopology comptopo; + paramesh=new ParaMESH(mesh,*dec->getTargetGrp(),"target mesh"); + parafield=new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); + parafield->getField()->setNature(ConservativeVolumic); + } + dec->attachLocalField(parafield); + dec->synchronize(); + dec->sendRecvData(); + if(dec->isInTargetSide()) + { + const double *valsToTest=parafield->getField()->getArray()->getConstPointer(); + CPPUNIT_ASSERT_DOUBLES_EQUAL(valsToTest[0],7.,1e-14); + CPPUNIT_ASSERT_DOUBLES_EQUAL(valsToTest[1],7.,1e-14); + } + // + delete parafield; + delete paramesh; + if(mesh) + mesh->decrRef(); + delete dec; + MPI_Barrier(MPI_COMM_WORLD); +} + +/*! + * Idem testFabienAPI1 except that procs are shuffled. Test of the good management of group translation in newly created communicator. + */ +void ParaMEDMEMTest::testFabienAPI2() +{ + int size; + int rank; + MPI_Comm_size(MPI_COMM_WORLD,&size); + MPI_Comm_rank(MPI_COMM_WORLD,&rank); + // + if(size!=3) + return ; + int procs_source_c[1]={2};//difference with testFabienAPI1 + std::set procs_source(procs_source_c,procs_source_c+1); + int procs_target_c[1]={1}; + std::set procs_target(procs_target_c,procs_target_c+1); + // + ParaMEDMEM::MEDCouplingUMesh *mesh=0; + ParaMEDMEM::ParaMESH *paramesh=0; + ParaMEDMEM::ParaFIELD *parafield=0; + // + ParaMEDMEM::CommInterface interface; + // + MPI_Barrier(MPI_COMM_WORLD); + double targetCoords[8]={ 0.,0., 1., 0., 0., 1., 1., 1. }; + CommInterface comm; + // + ParaMEDMEM::InterpKernelDEC *dec=new ParaMEDMEM::InterpKernelDEC(procs_source,procs_target); if(dec->isInSourceSide()) { mesh=MEDCouplingUMesh::New(); diff --git a/src/ParaMEDMEMTest/ParaMEDMEMTest_Gauthier1.cxx b/src/ParaMEDMEMTest/ParaMEDMEMTest_Gauthier1.cxx index 11c582843..17cadfe05 100644 --- a/src/ParaMEDMEMTest/ParaMEDMEMTest_Gauthier1.cxx +++ b/src/ParaMEDMEMTest/ParaMEDMEMTest_Gauthier1.cxx @@ -252,7 +252,7 @@ void ParaMEDMEMTest::testGauthier1() MPI_Barrier(MPI_COMM_WORLD); - clock_t clock0= clock (); + //clock_t clock0= clock (); int compti=0; bool init=true; // first time step ?? @@ -261,7 +261,7 @@ void ParaMEDMEMTest::testGauthier1() while (!stop) { compti++; - clock_t clocki= clock (); + //clock_t clocki= clock (); //cout << compti << " CLOCK " << (clocki-clock0)*1.e-6 << endl; for (int non_unif=0;non_unif<2;non_unif++) { @@ -278,7 +278,7 @@ void ParaMEDMEMTest::testGauthier1() if(rank!=3) champ_emetteur._field[0]=40; } - bool ok=false; // Is the time interval successfully solved ? + //bool ok=false; // Is the time interval successfully solved ? // Loop on the time interval tries if(1) { diff --git a/src/ParaMEDMEMTest/ParaMEDMEMTest_ICocoTrio.cxx b/src/ParaMEDMEMTest/ParaMEDMEMTest_ICocoTrio.cxx index 386491362..b3a573c3e 100644 --- a/src/ParaMEDMEMTest/ParaMEDMEMTest_ICocoTrio.cxx +++ b/src/ParaMEDMEMTest/ParaMEDMEMTest_ICocoTrio.cxx @@ -236,7 +236,7 @@ void ParaMEDMEMTest::testICocoTrio1() if (cas=="emetteur") if (non_unif) champ_emetteur._field[0]=40; - bool ok=false; // Is the time interval successfully solved ? + //bool ok=false; // Is the time interval successfully solved ? // Loop on the time interval tries if(1) diff --git a/src/ParaMEDMEMTest/ParaMEDMEMTest_InterpKernelDEC.cxx b/src/ParaMEDMEMTest/ParaMEDMEMTest_InterpKernelDEC.cxx index c41981608..af66e57bb 100644 --- a/src/ParaMEDMEMTest/ParaMEDMEMTest_InterpKernelDEC.cxx +++ b/src/ParaMEDMEMTest/ParaMEDMEMTest_InterpKernelDEC.cxx @@ -47,7 +47,7 @@ using namespace std; using namespace ParaMEDMEM; - + void ParaMEDMEMTest::testInterpKernelDEC_2D() { testInterpKernelDEC_2D_("P0","P0"); @@ -68,6 +68,385 @@ void ParaMEDMEMTest::testInterpKernelDEC_2DP0P1() //testInterpKernelDEC_2D_("P0","P1"); } +void ParaMEDMEMTest::testInterpKernelDEC_1D() +{ + int size; + int rank; + MPI_Comm_size(MPI_COMM_WORLD,&size); + MPI_Comm_rank(MPI_COMM_WORLD,&rank); + // + if(size!=5) + return ; + int nproc_source = 3; + set self_procs; + set procs_source; + set procs_target; + + for (int i=0; icontainsMyRank()) + { + if(rank==0) + { + double coords[4]={0.3,0.7, 0.9,1.0}; + int conn[4]={0,1,2,3}; + mesh=MEDCouplingUMesh::New("Source mesh Proc0",1); + mesh->allocateCells(2); + mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn); + mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2); + mesh->finishInsertingCells(); + DataArrayDouble *myCoords=DataArrayDouble::New(); + myCoords->alloc(4,1); + std::copy(coords,coords+4,myCoords->getPointer()); + mesh->setCoords(myCoords); + myCoords->decrRef(); + } + if(rank==1) + { + double coords[2]={0.7,0.9}; + int conn[2]={0,1}; + mesh=MEDCouplingUMesh::New("Source mesh Proc1",1); + mesh->allocateCells(1); + mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn); + mesh->finishInsertingCells(); + DataArrayDouble *myCoords=DataArrayDouble::New(); + myCoords->alloc(2,1); + std::copy(coords,coords+2,myCoords->getPointer()); + mesh->setCoords(myCoords); + myCoords->decrRef(); + } + if(rank==2) + { + double coords[2]={1.,1.12}; + int conn[2]={0,1}; + mesh=MEDCouplingUMesh::New("Source mesh Proc2",1); + mesh->allocateCells(1); + mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn); + mesh->finishInsertingCells(); + DataArrayDouble *myCoords=DataArrayDouble::New(); + myCoords->alloc(2,1); + std::copy(coords,coords+2,myCoords->getPointer()); + mesh->setCoords(myCoords); + myCoords->decrRef(); + } + paramesh=new ParaMESH(mesh,*source_group,"source mesh"); + ParaMEDMEM::ComponentTopology comptopo; + parafieldP0 = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); + double *valueP0=parafieldP0->getField()->getArray()->getPointer(); + parafieldP0->getField()->setNature(ConservativeVolumic); + if(rank==0) + { + valueP0[0]=7.; valueP0[1]=8.; + } + if(rank==1) + { + valueP0[0]=9.; + } + if(rank==2) + { + valueP0[0]=10.; + } + } + else + { + const char targetMeshName[]="target mesh"; + if(rank==3) + { + double coords[2]={0.5,0.75}; + int conn[2]={0,1}; + mesh=MEDCouplingUMesh::New("Target mesh Proc3",1); + mesh->allocateCells(1); + mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn); + mesh->finishInsertingCells(); + DataArrayDouble *myCoords=DataArrayDouble::New(); + myCoords->alloc(2,1); + std::copy(coords,coords+2,myCoords->getPointer()); + mesh->setCoords(myCoords); + myCoords->decrRef(); + paramesh=new ParaMESH(mesh,*target_group,targetMeshName); + } + if(rank==4) + { + double coords[2]={0.75,1.2}; + int conn[2]={0,1}; + mesh=MEDCouplingUMesh::New("Target mesh Proc4",1); + mesh->allocateCells(1); + mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn); + mesh->finishInsertingCells(); + DataArrayDouble *myCoords=DataArrayDouble::New(); + myCoords->alloc(2,1); + std::copy(coords,coords+2,myCoords->getPointer()); + mesh->setCoords(myCoords); + myCoords->decrRef(); + paramesh=new ParaMESH(mesh,*target_group,targetMeshName); + } + ParaMEDMEM::ComponentTopology comptopo; + parafieldP0 = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); + parafieldP0->getField()->setNature(ConservativeVolumic); + } + // test 1 + ParaMEDMEM::InterpKernelDEC dec(*source_group,*target_group); + if (source_group->containsMyRank()) + { + dec.setMethod("P0"); + dec.attachLocalField(parafieldP0); + dec.synchronize(); + dec.setForcedRenormalization(false); + dec.sendData(); + dec.recvData(); + const double *valueP0=parafieldP0->getField()->getArray()->getPointer(); + if(rank==0) + { + CPPUNIT_ASSERT_DOUBLES_EQUAL(7.4,valueP0[0],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0540540540540544,valueP0[1],1e-7); + } + if(rank==1) + { + CPPUNIT_ASSERT_DOUBLES_EQUAL(8.64054054054054,valueP0[0],1e-7); + } + if(rank==2) + { + CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0540540540540544,valueP0[0],1e-7); + } + } + else + { + dec.setMethod("P0"); + dec.attachLocalField(parafieldP0); + dec.synchronize(); + dec.setForcedRenormalization(false); + dec.recvData(); + const double *res=parafieldP0->getField()->getArray()->getConstPointer(); + if(rank==3) + { + CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfComponents()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(7.4,res[0],1e-12); + } + if(rank==4) + { + CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfComponents()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0540540540540526,res[0],1e-12); + } + dec.sendData(); + } + // + delete parafieldP0; + mesh->decrRef(); + delete paramesh; + delete self_group; + delete target_group; + delete source_group; + // + MPI_Barrier(MPI_COMM_WORLD); +} + +void ParaMEDMEMTest::testInterpKernelDEC_2DCurve() +{ + int size; + int rank; + MPI_Comm_size(MPI_COMM_WORLD,&size); + MPI_Comm_rank(MPI_COMM_WORLD,&rank); + // + if(size!=5) + return ; + int nproc_source = 3; + set self_procs; + set procs_source; + set procs_target; + + for (int i=0; icontainsMyRank()) + { + if(rank==0) + { + double coords[8]={0.3,0.3,0.7,0.7, 0.9,0.9,1.0,1.0}; + int conn[4]={0,1,2,3}; + mesh=MEDCouplingUMesh::New("Source mesh Proc0",1); + mesh->allocateCells(2); + mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn); + mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn+2); + mesh->finishInsertingCells(); + DataArrayDouble *myCoords=DataArrayDouble::New(); + myCoords->alloc(4,2); + std::copy(coords,coords+8,myCoords->getPointer()); + mesh->setCoords(myCoords); + myCoords->decrRef(); + } + if(rank==1) + { + double coords[4]={0.7,0.7,0.9,0.9}; + int conn[2]={0,1}; + mesh=MEDCouplingUMesh::New("Source mesh Proc1",1); + mesh->allocateCells(1); + mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn); + mesh->finishInsertingCells(); + DataArrayDouble *myCoords=DataArrayDouble::New(); + myCoords->alloc(2,2); + std::copy(coords,coords+4,myCoords->getPointer()); + mesh->setCoords(myCoords); + myCoords->decrRef(); + } + if(rank==2) + { + double coords[4]={1.,1.,1.12,1.12}; + int conn[2]={0,1}; + mesh=MEDCouplingUMesh::New("Source mesh Proc2",1); + mesh->allocateCells(1); + mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn); + mesh->finishInsertingCells(); + DataArrayDouble *myCoords=DataArrayDouble::New(); + myCoords->alloc(2,2); + std::copy(coords,coords+4,myCoords->getPointer()); + mesh->setCoords(myCoords); + myCoords->decrRef(); + } + paramesh=new ParaMESH(mesh,*source_group,"source mesh"); + ParaMEDMEM::ComponentTopology comptopo; + parafieldP0 = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); + double *valueP0=parafieldP0->getField()->getArray()->getPointer(); + parafieldP0->getField()->setNature(ConservativeVolumic); + if(rank==0) + { + valueP0[0]=7.; valueP0[1]=8.; + } + if(rank==1) + { + valueP0[0]=9.; + } + if(rank==2) + { + valueP0[0]=10.; + } + } + else + { + const char targetMeshName[]="target mesh"; + if(rank==3) + { + double coords[4]={0.5,0.5,0.75,0.75}; + int conn[2]={0,1}; + mesh=MEDCouplingUMesh::New("Target mesh Proc3",1); + mesh->allocateCells(1); + mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn); + mesh->finishInsertingCells(); + DataArrayDouble *myCoords=DataArrayDouble::New(); + myCoords->alloc(2,2); + std::copy(coords,coords+4,myCoords->getPointer()); + mesh->setCoords(myCoords); + myCoords->decrRef(); + paramesh=new ParaMESH(mesh,*target_group,targetMeshName); + } + if(rank==4) + { + double coords[4]={0.75,0.75,1.2,1.2}; + int conn[2]={0,1}; + mesh=MEDCouplingUMesh::New("Target mesh Proc4",1); + mesh->allocateCells(1); + mesh->insertNextCell(INTERP_KERNEL::NORM_SEG2,2,conn); + mesh->finishInsertingCells(); + DataArrayDouble *myCoords=DataArrayDouble::New(); + myCoords->alloc(2,2); + std::copy(coords,coords+4,myCoords->getPointer()); + mesh->setCoords(myCoords); + myCoords->decrRef(); + paramesh=new ParaMESH(mesh,*target_group,targetMeshName); + } + ParaMEDMEM::ComponentTopology comptopo; + parafieldP0 = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); + parafieldP0->getField()->setNature(ConservativeVolumic); + } + // test 1 + ParaMEDMEM::InterpKernelDEC dec(*source_group,*target_group); + if (source_group->containsMyRank()) + { + dec.setMethod("P0"); + dec.attachLocalField(parafieldP0); + dec.synchronize(); + dec.setForcedRenormalization(false); + dec.sendData(); + dec.recvData(); + const double *valueP0=parafieldP0->getField()->getArray()->getPointer(); + if(rank==0) + { + CPPUNIT_ASSERT_DOUBLES_EQUAL(7.4,valueP0[0],1e-7); + CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0540540540540544,valueP0[1],1e-7); + } + if(rank==1) + { + CPPUNIT_ASSERT_DOUBLES_EQUAL(8.64054054054054,valueP0[0],1e-7); + } + if(rank==2) + { + CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0540540540540544,valueP0[0],1e-7); + } + } + else + { + dec.setMethod("P0"); + dec.attachLocalField(parafieldP0); + dec.synchronize(); + dec.setForcedRenormalization(false); + dec.recvData(); + const double *res=parafieldP0->getField()->getArray()->getConstPointer(); + if(rank==3) + { + CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfComponents()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(7.4,res[0],1e-12); + } + if(rank==4) + { + CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfTuples()); + CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfComponents()); + CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0540540540540526,res[0],1e-12); + } + dec.sendData(); + } + // + delete parafieldP0; + mesh->decrRef(); + delete paramesh; + delete self_group; + delete target_group; + delete source_group; + // + MPI_Barrier(MPI_COMM_WORLD); +} + + /* * Check methods defined in InterpKernelDEC.hxx * @@ -1531,6 +1910,158 @@ void ParaMEDMEMTest::testInterpKernelDECPartialProcs() MPI_Barrier(MPI_COMM_WORLD); } +/*! + * This test reproduces bug of Gauthier on 13/9/2010 concerning 3DSurf meshes. + * It is possible to lead to dead lock in InterpKernelDEC when 3DSurfMeshes global bounding boxes intersects whereas cell bounding box intersecting only on one side. + */ +void ParaMEDMEMTest::testInterpKernelDEC3DSurfEmptyBBox() +{ + int size; + int rank; + MPI_Comm_size(MPI_COMM_WORLD,&size); + MPI_Comm_rank(MPI_COMM_WORLD,&rank); + // + if(size!=3) + return ; + int nproc_source = 1; + set self_procs; + set procs_source; + set procs_target; + + for (int i=0; icontainsMyRank()) + { + double coords[15]={1.,0.,0., 2.,0.,0., 2.,2.,0., 0.,2.,0., 0.5,0.5,1.}; + int conn[4]={0,1,2,3}; + mesh=MEDCouplingUMesh::New("Source mesh Proc0",2); + mesh->allocateCells(2); + mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn); + mesh->insertNextCell(INTERP_KERNEL::NORM_TRI3,2,conn+4); + mesh->finishInsertingCells(); + DataArrayDouble *myCoords=DataArrayDouble::New(); + myCoords->alloc(5,3); + std::copy(coords,coords+15,myCoords->getPointer()); + mesh->setCoords(myCoords); + myCoords->decrRef(); + // + paramesh=new ParaMESH(mesh,*source_group,"source mesh"); + ParaMEDMEM::ComponentTopology comptopo; + parafieldP0 = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); + double *valueP0=parafieldP0->getField()->getArray()->getPointer(); + parafieldP0->getField()->setNature(ConservativeVolumic); + valueP0[0]=7.; valueP0[1]=8.; + } + else + { + const char targetMeshName[]="target mesh"; + if(rank==1) + { + double coords[12]={0.25,0.25,0.5, 0.,0.25,0.5, 0.,0.,0.5, 0.25,0.,0.5}; + int conn[4]={0,1,2,3}; + mesh=MEDCouplingUMesh::New("Target mesh Proc1",2); + mesh->allocateCells(1); + mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn); + mesh->finishInsertingCells(); + DataArrayDouble *myCoords=DataArrayDouble::New(); + myCoords->alloc(4,3); + std::copy(coords,coords+12,myCoords->getPointer()); + mesh->setCoords(myCoords); + myCoords->decrRef(); + paramesh=new ParaMESH(mesh,*target_group,targetMeshName); + } + if(rank==2) + { + double coords[12]={0.,0.25,0.5, 0.,0.,0.5, -1.,0.,0.5, -1.,0.25,0.5}; + int conn[4]={0,1,2,3}; + mesh=MEDCouplingUMesh::New("Target mesh Proc2",2); + mesh->allocateCells(1); + mesh->insertNextCell(INTERP_KERNEL::NORM_QUAD4,4,conn); + mesh->finishInsertingCells(); + DataArrayDouble *myCoords=DataArrayDouble::New(); + myCoords->alloc(4,3); + std::copy(coords,coords+12,myCoords->getPointer()); + mesh->setCoords(myCoords); + myCoords->decrRef(); + paramesh=new ParaMESH(mesh,*target_group,targetMeshName); + } + ParaMEDMEM::ComponentTopology comptopo; + parafieldP0 = new ParaFIELD(ON_CELLS,NO_TIME,paramesh, comptopo); + parafieldP0->getField()->setNature(ConservativeVolumic); + } + // test 1 + ParaMEDMEM::InterpKernelDEC dec(*source_group,*target_group); + if (source_group->containsMyRank()) + { + dec.setMethod("P0"); + dec.attachLocalField(parafieldP0); + dec.synchronize(); + // dec.setForcedRenormalization(false); + // dec.sendData(); + // dec.recvData(); + // const double *valueP0=parafieldP0->getField()->getArray()->getPointer(); + // if(rank==0) + // { + // CPPUNIT_ASSERT_DOUBLES_EQUAL(7.4,valueP0[0],1e-7); + // CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0540540540540544,valueP0[1],1e-7); + // } + // if(rank==1) + // { + // CPPUNIT_ASSERT_DOUBLES_EQUAL(8.64054054054054,valueP0[0],1e-7); + // } + // if(rank==2) + // { + // CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0540540540540544,valueP0[0],1e-7); + // } + } + else + { + dec.setMethod("P0"); + dec.attachLocalField(parafieldP0); + dec.synchronize(); + // dec.setForcedRenormalization(false); + // dec.recvData(); + // const double *res=parafieldP0->getField()->getArray()->getConstPointer(); + // if(rank==3) + // { + // CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfTuples()); + // CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfComponents()); + // CPPUNIT_ASSERT_DOUBLES_EQUAL(7.4,res[0],1e-12); + // } + // if(rank==4) + // { + // CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfTuples()); + // CPPUNIT_ASSERT_EQUAL(1,parafieldP0->getField()->getNumberOfComponents()); + // CPPUNIT_ASSERT_DOUBLES_EQUAL(9.0540540540540526,res[0],1e-12); + // } + // dec.sendData(); + } + // + delete parafieldP0; + mesh->decrRef(); + delete paramesh; + delete self_group; + delete target_group; + delete source_group; + // + MPI_Barrier(MPI_COMM_WORLD); +} + /*! * Tests an asynchronous exchange between two codes * one sends data with dtA as an interval, the max time being tmaxA diff --git a/src/ParaMEDMEMTest/ParaMEDMEMTest_MEDLoader.cxx b/src/ParaMEDMEMTest/ParaMEDMEMTest_MEDLoader.cxx index 325b46f03..b0b216137 100644 --- a/src/ParaMEDMEMTest/ParaMEDMEMTest_MEDLoader.cxx +++ b/src/ParaMEDMEMTest/ParaMEDMEMTest_MEDLoader.cxx @@ -45,17 +45,17 @@ void ParaMEDMEMTest::testMEDLoaderRead1() CPPUNIT_ASSERT_EQUAL(3,(int)mesh->getAllTypes().size()); for(int i=0;i<12;i++) CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,mesh->getTypeOfCell(i)); - for(int i=12;i<14;i++) - CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,mesh->getTypeOfCell(i)); - for(int i=14;i<16;i++) - CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,mesh->getTypeOfCell(i)); + CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,mesh->getTypeOfCell(12)); + CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,mesh->getTypeOfCell(13)); + CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,mesh->getTypeOfCell(14)); + CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,mesh->getTypeOfCell(15)); CPPUNIT_ASSERT_EQUAL(90,mesh->getNodalConnectivity()->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(701,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+90,0)); - CPPUNIT_ASSERT_EQUAL(711,std::accumulate(mesh->getNodalConnectivityIndex()->getPointer(),mesh->getNodalConnectivityIndex()->getPointer()+17,0)); + CPPUNIT_ASSERT_EQUAL(705,std::accumulate(mesh->getNodalConnectivityIndex()->getPointer(),mesh->getNodalConnectivityIndex()->getPointer()+17,0)); CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+57,0),1e-12); mesh->decrRef(); // - vector families=MEDLoader::GetMeshFamilyNames(fileName.c_str(),meshNames[0].c_str()); + vector families=MEDLoader::GetMeshFamiliesNames(fileName.c_str(),meshNames[0].c_str()); CPPUNIT_ASSERT_EQUAL(8,(int)families.size()); CPPUNIT_ASSERT(families[2]=="FAMILLE_ELEMENT_3"); // @@ -103,21 +103,21 @@ void ParaMEDMEMTest::testMEDLoaderRead1() CPPUNIT_ASSERT_EQUAL(2,(int)fieldsName.size()); CPPUNIT_ASSERT(fieldsName[0]=="fieldcelldoublescalar"); CPPUNIT_ASSERT(fieldsName[1]=="fieldcelldoublevector"); - std::vector > its0=MEDLoader::GetCellFieldIterations(fileName.c_str(),fieldsName[0].c_str()); + std::vector > its0=MEDLoader::GetCellFieldIterations(fileName.c_str(),meshNames[0].c_str(),fieldsName[0].c_str()); CPPUNIT_ASSERT_EQUAL(1,(int)its0.size()); CPPUNIT_ASSERT_EQUAL(-1,its0[0].first); CPPUNIT_ASSERT_EQUAL(-1,its0[0].second); - std::vector > its1=MEDLoader::GetCellFieldIterations(fileName.c_str(),fieldsName[1].c_str()); + std::vector > its1=MEDLoader::GetCellFieldIterations(fileName.c_str(),meshNames[0].c_str(),fieldsName[1].c_str()); CPPUNIT_ASSERT_EQUAL(1,(int)its1.size()); CPPUNIT_ASSERT_EQUAL(-1,its1[0].first); CPPUNIT_ASSERT_EQUAL(-1,its1[0].second); // - MEDCouplingFieldDouble *field0=MEDLoader::ReadFieldDoubleCell(fileName.c_str(),meshNames[0].c_str(),0,fieldsName[0].c_str(),its0[0].first,its0[0].second); + MEDCouplingFieldDouble *field0=MEDLoader::ReadFieldCell(fileName.c_str(),meshNames[0].c_str(),0,fieldsName[0].c_str(),its0[0].first,its0[0].second); field0->checkCoherency(); CPPUNIT_ASSERT(field0->getName()==fieldsName[0]); CPPUNIT_ASSERT_EQUAL(1,field0->getNumberOfComponents()); CPPUNIT_ASSERT_EQUAL(16,field0->getNumberOfTuples()); - const double expectedValues[16]={1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,3.,3.,2.,2.}; + const double expectedValues[16]={1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,1.,2.,3.,3.,2.}; double diffValue[16]; std::transform(field0->getArray()->getPointer(),field0->getArray()->getPointer()+16,expectedValues,diffValue,std::minus()); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue,diffValue+16),1e-12); @@ -131,22 +131,22 @@ void ParaMEDMEMTest::testMEDLoaderRead1() CPPUNIT_ASSERT_EQUAL(3,(int)constMesh->getAllTypes().size()); for(int i=0;i<12;i++) CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,constMesh->getTypeOfCell(i)); - for(int i=12;i<14;i++) - CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(i)); - for(int i=14;i<16;i++) - CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(i)); + CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(12)); + CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(13)); + CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(14)); + CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(15)); CPPUNIT_ASSERT_EQUAL(90,constMesh->getNodalConnectivity()->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(701,std::accumulate(constMesh->getNodalConnectivity()->getPointer(),constMesh->getNodalConnectivity()->getPointer()+90,0)); - CPPUNIT_ASSERT_EQUAL(711,std::accumulate(constMesh->getNodalConnectivityIndex()->getPointer(),constMesh->getNodalConnectivityIndex()->getPointer()+17,0)); + CPPUNIT_ASSERT_EQUAL(705,std::accumulate(constMesh->getNodalConnectivityIndex()->getPointer(),constMesh->getNodalConnectivityIndex()->getPointer()+17,0)); CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(constMesh->getCoords()->getPointer(),constMesh->getCoords()->getPointer()+57,0),1e-12); field0->decrRef(); // - MEDCouplingFieldDouble *field1=MEDLoader::ReadFieldDoubleCell(fileName.c_str(),meshNames[0].c_str(),0,fieldsName[1].c_str(),its1[0].first,its1[0].second); + MEDCouplingFieldDouble *field1=MEDLoader::ReadFieldCell(fileName.c_str(),meshNames[0].c_str(),0,fieldsName[1].c_str(),its1[0].first,its1[0].second); field1->checkCoherency(); CPPUNIT_ASSERT(field1->getName()==fieldsName[1]); CPPUNIT_ASSERT_EQUAL(3,field1->getNumberOfComponents()); CPPUNIT_ASSERT_EQUAL(16,field1->getNumberOfTuples()); - const double expectedValues2[48]={1.,0.,1.,1.,0.,1.,1.,0.,1.,2.,1.,0.,2.,1.,0.,2.,1.,0.,3.,0.,1.,3.,0.,1.,3.,0.,1.,4.,1.,0.,4.,1.,0.,4.,1.,0.,6.,1.,1.,6.,0.,0.,5.,0.,0.,5.,1.,1.}; + const double expectedValues2[48]={1.,0.,1.,1.,0.,1.,1.,0.,1.,2.,1.,0.,2.,1.,0.,2.,1.,0.,3.,0.,1.,3.,0.,1.,3.,0.,1.,4.,1.,0.,4.,1.,0.,4.,1.,0.,5.,0.,0.,6.,1.,1.,6.,0.,0.,5.,1.,1.}; double diffValue2[48]; std::transform(field1->getArray()->getPointer(),field1->getArray()->getPointer()+48,expectedValues2,diffValue2,std::minus()); CPPUNIT_ASSERT_DOUBLES_EQUAL(0.,*std::max_element(diffValue2,diffValue2+48),1e-12); @@ -160,13 +160,13 @@ void ParaMEDMEMTest::testMEDLoaderRead1() CPPUNIT_ASSERT_EQUAL(3,(int)constMesh->getAllTypes().size()); for(int i=0;i<12;i++) CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,constMesh->getTypeOfCell(i)); - for(int i=12;i<14;i++) - CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(i)); - for(int i=14;i<16;i++) - CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(i)); + CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(12)); + CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(13)); + CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(14)); + CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(15)); CPPUNIT_ASSERT_EQUAL(90,constMesh->getNodalConnectivity()->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(701,std::accumulate(constMesh->getNodalConnectivity()->getPointer(),constMesh->getNodalConnectivity()->getPointer()+90,0)); - CPPUNIT_ASSERT_EQUAL(711,std::accumulate(constMesh->getNodalConnectivityIndex()->getPointer(),constMesh->getNodalConnectivityIndex()->getPointer()+17,0)); + CPPUNIT_ASSERT_EQUAL(705,std::accumulate(constMesh->getNodalConnectivityIndex()->getPointer(),constMesh->getNodalConnectivityIndex()->getPointer()+17,0)); CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(constMesh->getCoords()->getPointer(),constMesh->getCoords()->getPointer()+57,0),1e-12); field1->decrRef(); //fields on nodes @@ -174,7 +174,7 @@ void ParaMEDMEMTest::testMEDLoaderRead1() CPPUNIT_ASSERT_EQUAL(2,(int)fieldsNameNode.size()); CPPUNIT_ASSERT(fieldsNameNode[0]=="fieldnodedouble"); CPPUNIT_ASSERT(fieldsNameNode[1]=="fieldnodeint"); - std::vector > its0Node=MEDLoader::GetNodeFieldIterations(fileName.c_str(),fieldsNameNode[0].c_str()); + std::vector > its0Node=MEDLoader::GetNodeFieldIterations(fileName.c_str(),meshNames[0].c_str(),fieldsNameNode[0].c_str()); CPPUNIT_ASSERT_EQUAL(3,(int)its0Node.size()); CPPUNIT_ASSERT_EQUAL(1,its0Node[0].first); CPPUNIT_ASSERT_EQUAL(-1,its0Node[0].second); @@ -182,7 +182,7 @@ void ParaMEDMEMTest::testMEDLoaderRead1() CPPUNIT_ASSERT_EQUAL(-1,its0Node[1].second); CPPUNIT_ASSERT_EQUAL(-1,its0Node[2].first);//strange but like that CPPUNIT_ASSERT_EQUAL(-1,its0Node[2].second); - MEDCouplingFieldDouble *field0Nodes=MEDLoader::ReadFieldDoubleNode(fileName.c_str(),meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[0].first,its0Node[0].second); + MEDCouplingFieldDouble *field0Nodes=MEDLoader::ReadFieldNode(fileName.c_str(),meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[0].first,its0Node[0].second); field0Nodes->checkCoherency(); CPPUNIT_ASSERT(field0Nodes->getName()==fieldsNameNode[0]); CPPUNIT_ASSERT_EQUAL(1,field0Nodes->getNumberOfComponents()); @@ -196,7 +196,7 @@ void ParaMEDMEMTest::testMEDLoaderRead1() CPPUNIT_ASSERT(constMesh); field0Nodes->decrRef(); // - field0Nodes=MEDLoader::ReadFieldDoubleNode(fileName.c_str(),meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[1].first,its0Node[1].second); + field0Nodes=MEDLoader::ReadFieldNode(fileName.c_str(),meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[1].first,its0Node[1].second); field0Nodes->checkCoherency(); CPPUNIT_ASSERT(field0Nodes->getName()==fieldsNameNode[0]); CPPUNIT_ASSERT_EQUAL(1,field0Nodes->getNumberOfComponents()); @@ -214,17 +214,17 @@ void ParaMEDMEMTest::testMEDLoaderRead1() CPPUNIT_ASSERT_EQUAL(3,(int)constMesh->getAllTypes().size()); for(int i=0;i<12;i++) CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,constMesh->getTypeOfCell(i)); - for(int i=12;i<14;i++) - CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(i)); - for(int i=14;i<16;i++) - CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(i)); + CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(12)); + CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(13)); + CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(14)); + CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(15)); CPPUNIT_ASSERT_EQUAL(90,constMesh->getNodalConnectivity()->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(701,std::accumulate(constMesh->getNodalConnectivity()->getPointer(),constMesh->getNodalConnectivity()->getPointer()+90,0)); - CPPUNIT_ASSERT_EQUAL(711,std::accumulate(constMesh->getNodalConnectivityIndex()->getPointer(),constMesh->getNodalConnectivityIndex()->getPointer()+17,0)); + CPPUNIT_ASSERT_EQUAL(705,std::accumulate(constMesh->getNodalConnectivityIndex()->getPointer(),constMesh->getNodalConnectivityIndex()->getPointer()+17,0)); CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(constMesh->getCoords()->getPointer(),constMesh->getCoords()->getPointer()+57,0),1e-12); field0Nodes->decrRef(); // - field0Nodes=MEDLoader::ReadFieldDoubleNode(fileName.c_str(),meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[2].first,its0Node[2].second); + field0Nodes=MEDLoader::ReadFieldNode(fileName.c_str(),meshNames[0].c_str(),0,fieldsNameNode[0].c_str(),its0Node[2].first,its0Node[2].second); field0Nodes->checkCoherency(); CPPUNIT_ASSERT(field0Nodes->getName()==fieldsNameNode[0]); CPPUNIT_ASSERT_EQUAL(1,field0Nodes->getNumberOfComponents()); @@ -242,13 +242,13 @@ void ParaMEDMEMTest::testMEDLoaderRead1() CPPUNIT_ASSERT_EQUAL(3,(int)constMesh->getAllTypes().size()); for(int i=0;i<12;i++) CPPUNIT_ASSERT_EQUAL(NORM_TETRA4,constMesh->getTypeOfCell(i)); - for(int i=12;i<14;i++) - CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(i)); - for(int i=14;i<16;i++) - CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(i)); + CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(12)); + CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(13)); + CPPUNIT_ASSERT_EQUAL(NORM_HEXA8,constMesh->getTypeOfCell(14)); + CPPUNIT_ASSERT_EQUAL(NORM_PYRA5,constMesh->getTypeOfCell(15)); CPPUNIT_ASSERT_EQUAL(90,constMesh->getNodalConnectivity()->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(701,std::accumulate(constMesh->getNodalConnectivity()->getPointer(),constMesh->getNodalConnectivity()->getPointer()+90,0)); - CPPUNIT_ASSERT_EQUAL(711,std::accumulate(constMesh->getNodalConnectivityIndex()->getPointer(),constMesh->getNodalConnectivityIndex()->getPointer()+17,0)); + CPPUNIT_ASSERT_EQUAL(705,std::accumulate(constMesh->getNodalConnectivityIndex()->getPointer(),constMesh->getNodalConnectivityIndex()->getPointer()+17,0)); CPPUNIT_ASSERT_DOUBLES_EQUAL(46.,std::accumulate(constMesh->getCoords()->getPointer(),constMesh->getCoords()->getPointer()+57,0),1e-12); field0Nodes->decrRef(); } @@ -286,9 +286,9 @@ void ParaMEDMEMTest::testMEDLoaderPolygonRead() CPPUNIT_ASSERT(fieldsName[0]=="bord_:_distorsion"); CPPUNIT_ASSERT(fieldsName[1]=="bord_:_familles"); CPPUNIT_ASSERT(fieldsName[2]=="bord_:_non-ortho"); - std::vector > its0=MEDLoader::GetCellFieldIterations(fileName.c_str(),fieldsName[0].c_str()); + std::vector > its0=MEDLoader::GetCellFieldIterations(fileName.c_str(),meshNames[0].c_str(),fieldsName[0].c_str()); CPPUNIT_ASSERT_EQUAL(1,(int)its0.size()); - MEDCouplingFieldDouble *field=MEDLoader::ReadFieldDoubleCell(fileName.c_str(),meshNames[0].c_str(),0,fieldsName[0].c_str(),its0[0].first,its0[0].second); + MEDCouplingFieldDouble *field=MEDLoader::ReadFieldCell(fileName.c_str(),meshNames[0].c_str(),0,fieldsName[0].c_str(),its0[0].first,its0[0].second); field->checkCoherency(); CPPUNIT_ASSERT(field->getName()==fieldsName[0]); CPPUNIT_ASSERT_EQUAL(1,field->getNumberOfComponents()); @@ -345,18 +345,29 @@ void ParaMEDMEMTest::testMEDLoaderPolyhedronRead() CPPUNIT_ASSERT_EQUAL(17,mesh->getNumberOfCells()); CPPUNIT_ASSERT_EQUAL(19,mesh->getNumberOfNodes()); CPPUNIT_ASSERT_EQUAL(3,(int)mesh->getAllTypes().size()); - for(int i=0;i<6;i++) - CPPUNIT_ASSERT_EQUAL(NORM_TRI3,mesh->getTypeOfCell(i)); - for(int i=6;i<14;i++) - CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(i)); - for(int i=14;i<17;i++) - CPPUNIT_ASSERT_EQUAL(NORM_POLYGON,mesh->getTypeOfCell(i)); + CPPUNIT_ASSERT_EQUAL(NORM_POLYGON,mesh->getTypeOfCell(0)); + CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(1)); + CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(2)); + CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(3)); + CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(4)); + CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(5)); + CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(6)); + CPPUNIT_ASSERT_EQUAL(NORM_TRI3,mesh->getTypeOfCell(7)); + CPPUNIT_ASSERT_EQUAL(NORM_POLYGON,mesh->getTypeOfCell(8)); + CPPUNIT_ASSERT_EQUAL(NORM_POLYGON,mesh->getTypeOfCell(9)); + CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(10)); + CPPUNIT_ASSERT_EQUAL(NORM_TRI3,mesh->getTypeOfCell(11)); + CPPUNIT_ASSERT_EQUAL(NORM_TRI3,mesh->getTypeOfCell(12)); + CPPUNIT_ASSERT_EQUAL(NORM_TRI3,mesh->getTypeOfCell(13)); + CPPUNIT_ASSERT_EQUAL(NORM_TRI3,mesh->getTypeOfCell(14)); + CPPUNIT_ASSERT_EQUAL(NORM_QUAD4,mesh->getTypeOfCell(15)); + CPPUNIT_ASSERT_EQUAL(NORM_TRI3,mesh->getTypeOfCell(16)); CPPUNIT_ASSERT_DOUBLES_EQUAL(110.,std::accumulate(mesh->getCoords()->getPointer(),mesh->getCoords()->getPointer()+57,0),1e-12); CPPUNIT_ASSERT_EQUAL(83,mesh->getNodalConnectivity()->getNbOfElems()); CPPUNIT_ASSERT_EQUAL(619,std::accumulate(mesh->getNodalConnectivity()->getPointer(),mesh->getNodalConnectivity()->getPointer()+83,0)); mesh->decrRef(); // - vector families=MEDLoader::GetMeshFamilyNames(fileName.c_str(),meshNames[0].c_str()); + vector families=MEDLoader::GetMeshFamiliesNames(fileName.c_str(),meshNames[0].c_str()); CPPUNIT_ASSERT_EQUAL(4,(int)families.size()); CPPUNIT_ASSERT(families[0]=="FAMILLE_FACE_POLYGONS3"); CPPUNIT_ASSERT(families[1]=="FAMILLE_FACE_QUAD41"); diff --git a/src/ParaMEDMEMTest/ParaMEDMEMTest_NonCoincidentDEC.cxx b/src/ParaMEDMEMTest/ParaMEDMEMTest_NonCoincidentDEC.cxx index ee55782a8..8911fba39 100644 --- a/src/ParaMEDMEMTest/ParaMEDMEMTest_NonCoincidentDEC.cxx +++ b/src/ParaMEDMEMTest/ParaMEDMEMTest_NonCoincidentDEC.cxx @@ -17,6 +17,8 @@ // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // +#ifdef MED_ENABLE_FVM + #include "ParaMEDMEMTest.hxx" #include @@ -251,3 +253,4 @@ void ParaMEDMEMTest::testNonCoincidentDEC(const string& filename1, MPI_Barrier(MPI_COMM_WORLD); } +#endif -- 2.39.2