From e955d5a8e8c09e366c5f1ea717f24f64d6b07ac6 Mon Sep 17 00:00:00 2001 From: vbd Date: Fri, 2 Feb 2007 08:31:59 +0000 Subject: [PATCH] improvement of base classes --- src/ParaMEDMEM/ExplicitCoincidentDEC.cxx | 6 +- src/ParaMEDMEM/MPIProcessorGroup.cxx | 4 +- src/ParaMEDMEM/ParaFIELD.hxx | 1 - src/ParaMEDMEM/ParaGRID.cxx | 2 +- src/ParaMEDMEM/ParaSUPPORT.hxx | 2 +- src/ParaMEDMEM/StructuredParaSUPPORT.cxx | 14 ++-- src/ParaMEDMEM/StructuredParaSUPPORT.hxx | 4 +- src/ParaMEDMEM/UnstructuredParaSUPPORT.hxx | 5 +- src/ParaMEDMEM/test_ParaField.cxx | 97 +++++++++++----------- 9 files changed, 68 insertions(+), 67 deletions(-) diff --git a/src/ParaMEDMEM/ExplicitCoincidentDEC.cxx b/src/ParaMEDMEM/ExplicitCoincidentDEC.cxx index c1f2bb7cc..aa9309029 100644 --- a/src/ParaMEDMEM/ExplicitCoincidentDEC.cxx +++ b/src/ParaMEDMEM/ExplicitCoincidentDEC.cxx @@ -190,16 +190,16 @@ void ExplicitCoincidentDEC::broadcastTopology(const ExplicitTopology& toposend, else { vector size (group->size()); - + int myrank=toporecv.getProcGroup()->myRank(); for (int iproc=0; iprocsize();iproc++) { int isource = iproc; if (!toporecv.getProcGroup()->contains(isource)) { int nbelem; - _comm_interface->recv(&nbelem, 1, MPI_INTEGER, isource, tag+isource, *(group->getComm()), &status); + _comm_interface->recv(&nbelem, 1, MPI_INTEGER, isource, tag+myrank, *(group->getComm()), &status); int* buffer = new int[nbelem]; - _comm_interface->recv(buffer, nbelem, MPI_INTEGER, isource,tag+isource, *(group->getComm()), &status); + _comm_interface->recv(buffer, nbelem, MPI_INTEGER, isource,tag+myrank, *(group->getComm()), &status); ExplicitTopology* topotemp=new ExplicitTopology(); topotemp->unserialize(buffer, *_comm_interface); diff --git a/src/ParaMEDMEM/MPIProcessorGroup.cxx b/src/ParaMEDMEM/MPIProcessorGroup.cxx index 84a176fa4..34a84019e 100644 --- a/src/ParaMEDMEM/MPIProcessorGroup.cxx +++ b/src/ParaMEDMEM/MPIProcessorGroup.cxx @@ -38,7 +38,9 @@ ProcessorGroup(interface, proc_ids) // copying proc_ids in ranks copy::const_iterator,int*> (proc_ids.begin(), proc_ids.end(), ranks); - + for (int i=0; igetName()) if (!_block_topology->getProcGroup()->containsMyRank()) return; int dimension=_block_topology->getDimension() ; - if (dimension != global_grid->getMeshDimension()) + if (dimension != global_grid->getSpaceDimension()) throw MEDEXCEPTION(LOCALIZED("ParaGrid::ParaGrid incompatible topology")); vector > xyz_array(dimension); diff --git a/src/ParaMEDMEM/ParaSUPPORT.hxx b/src/ParaMEDMEM/ParaSUPPORT.hxx index 7ff301a6f..73a22cb19 100644 --- a/src/ParaMEDMEM/ParaSUPPORT.hxx +++ b/src/ParaMEDMEM/ParaSUPPORT.hxx @@ -18,7 +18,7 @@ namespace ParaMEDMEM virtual const Topology* getTopology() const {}; virtual const MEDMEM::SUPPORT* getSupport() const {return _support;} virtual const ParaMESH* getMesh() const {return _mesh;} - private : + protected : const MEDMEM::SUPPORT* _support; const ParaMESH* _mesh; }; diff --git a/src/ParaMEDMEM/StructuredParaSUPPORT.cxx b/src/ParaMEDMEM/StructuredParaSUPPORT.cxx index 3af5bca0b..b431efeb7 100644 --- a/src/ParaMEDMEM/StructuredParaSUPPORT.cxx +++ b/src/ParaMEDMEM/StructuredParaSUPPORT.cxx @@ -12,22 +12,20 @@ namespace ParaMEDMEM StructuredParaSUPPORT::StructuredParaSUPPORT(const ParaGRID* const grid, const MED_EN::medEntityMesh entity): _block_topology(grid->getBlockTopology()), _grid(grid), -_mesh(0), -_entity(entity), -_support(new SUPPORT(grid->getGrid(), "support on all entities", entity)) +_entity(entity) { - + _support=new SUPPORT(grid->getGrid(), "support on all entities", entity); } /*! Constructor on all elements from a GRID */ StructuredParaSUPPORT::StructuredParaSUPPORT(const ParaMESH* const mesh, const MED_EN::medEntityMesh entity): _block_topology(mesh->getBlockTopology()), _grid(0), -_mesh(mesh), -_entity(entity), -_support(new SUPPORT(mesh->getMesh(), "support on all entities", entity)) +_entity(entity) { - + _mesh=mesh; + _support=new SUPPORT(mesh->getMesh(), "support on all entities", entity); } + StructuredParaSUPPORT::~StructuredParaSUPPORT() { delete _support; diff --git a/src/ParaMEDMEM/StructuredParaSUPPORT.hxx b/src/ParaMEDMEM/StructuredParaSUPPORT.hxx index 8072cc2b6..a9008f816 100644 --- a/src/ParaMEDMEM/StructuredParaSUPPORT.hxx +++ b/src/ParaMEDMEM/StructuredParaSUPPORT.hxx @@ -31,9 +31,9 @@ public: private: const BlockTopology* const _block_topology; const ParaGRID* const _grid; - const ParaMESH* const _mesh; + // const ParaMESH* const _mesh; const MED_EN::medEntityMesh _entity; - const MEDMEM::SUPPORT* _support; + // const MEDMEM::SUPPORT* _support; }; diff --git a/src/ParaMEDMEM/UnstructuredParaSUPPORT.hxx b/src/ParaMEDMEM/UnstructuredParaSUPPORT.hxx index 4f663f255..7d30c5de4 100644 --- a/src/ParaMEDMEM/UnstructuredParaSUPPORT.hxx +++ b/src/ParaMEDMEM/UnstructuredParaSUPPORT.hxx @@ -22,12 +22,11 @@ public: UnstructuredParaSUPPORT(const ParaMESH* const mesh, SUPPORT* support ); virtual ~UnstructuredParaSUPPORT(); const Topology* getTopology() const {return _block_topology;} - const MEDMEM::SUPPORT* getSupport() {return _support;} + private: const BlockTopology* const _block_topology; - const ParaMESH* const _mesh; const MED_EN::medEntityMesh _entity; - const MEDMEM::SUPPORT* _support; + }; diff --git a/src/ParaMEDMEM/test_ParaField.cxx b/src/ParaMEDMEM/test_ParaField.cxx index 42f4b482b..2c4be32b8 100644 --- a/src/ParaMEDMEM/test_ParaField.cxx +++ b/src/ParaMEDMEM/test_ParaField.cxx @@ -23,54 +23,57 @@ using namespace ParaMEDMEM; using namespace MEDMEM; int main(int argc, char** argv) { - string testname="ParaMEDMEM - test #1 -"; - MPI_Init(&argc, &argv); - int size; - int rank; - MPI_Comm_size(MPI_COMM_WORLD,&size); - MPI_Comm_rank(MPI_COMM_WORLD,&rank); - - set self_procs; - set procs; - for (int i=0; i > axes(2); - axes[0].resize(nx); - axes[1].resize(ny); - for (int i=0; i coord_name; - vector coord_unit; - coord_name.push_back("x");coord_name.push_back("y"); - coord_unit.push_back("m");coord_unit.push_back("m"); - - MEDMEM::GRID grid(axes, coord_name,coord_unit); - - grid.setName("grid_10_10"); - grid.setDescription("10 by 10 square grid"); - Topology* topo = new BlockTopology(*self_group, grid); + string testname="ParaMEDMEM - test #1 -"; + MPI_Init(&argc, &argv); + int size; + int rank; + MPI_Comm_size(MPI_COMM_WORLD,&size); + MPI_Comm_rank(MPI_COMM_WORLD,&rank); + + set self_procs; + set procs; + for (int i=0; icontainsMyRank()) + { + double xmin=0.0, xmax=1.0, ymin=0.0, ymax=1.0; + int nx=10, ny=10; + std::vector > axes(2); + axes[0].resize(nx); + axes[1].resize(ny); + for (int i=0; i coord_name; + vector coord_unit; + coord_name.push_back("x");coord_name.push_back("y"); + coord_unit.push_back("m");coord_unit.push_back("m"); + + MEDMEM::GRID grid(axes, coord_name,coord_unit); + + grid.setName("grid_10_10"); + grid.setDescription("10 by 10 square grid"); + Topology* topo = new BlockTopology(*self_group, grid); + + ParaGRID local_grid(&grid, topo); + StructuredParaSUPPORT support(&local_grid,MED_EN::MED_CELL); + // local_grid.write (MED_DRIVER, "/tmp/toto"); + + ComponentTopology comp_topo(5, group); + ParaFIELD field(&support, comp_topo); - ParaGRID local_grid(&grid, topo); - StructuredParaSUPPORT support(&local_grid,MED_EN::MED_CELL); - local_grid.write (MED_DRIVER, "/tmp/toto"); - - ComponentTopology comp_topo(5, group); - ParaFIELD field(&support, comp_topo); - - MPI_Finalize(); - return 0; + delete topo; + } + MPI_Finalize(); + return 0; } -- 2.39.2