From d98cb4080c7251c9258b0bdccdcf765e27b46904 Mon Sep 17 00:00:00 2001 From: eap Date: Fri, 24 Oct 2008 05:55:19 +0000 Subject: [PATCH] 20011: [CEA 279] MEDMEM_Utilities.hxx roll back changes of BEGIN_OF and END_OF macros --- src/ParaMEDMEM/DEC.cxx | 42 +-- src/ParaMEDMEM/InterpolationMatrix.cxx | 342 ++++++++++++------------- src/ParaMEDMEM/IntersectionDEC.cxx | 132 +++++----- src/ParaMEDMEM/MxN_Mapping.cxx | 94 +++---- src/ParaMEDMEM/ParaGRID.cxx | 3 +- src/ParaMEDMEM/ParaMESH.cxx | 6 +- 6 files changed, 311 insertions(+), 308 deletions(-) diff --git a/src/ParaMEDMEM/DEC.cxx b/src/ParaMEDMEM/DEC.cxx index 315a971d2..bade938b6 100644 --- a/src/ParaMEDMEM/DEC.cxx +++ b/src/ParaMEDMEM/DEC.cxx @@ -147,26 +147,26 @@ Reversely, if the processor is on the sending end, the field will be read, possi */ void DEC::renormalizeTargetField() { - if (_source_group->containsMyRank()) - for (int icomp=0; icomp<_local_field->getField()->getNumberOfComponents(); icomp++) - { - double total_norm = _local_field->getVolumeIntegral(icomp+1); - double source_norm = total_norm; - _comm_interface->broadcast(&source_norm, 1, MPI_DOUBLE, 0,* dynamic_cast(_union_group)->getComm()); - - } - if (_target_group->containsMyRank()) - { - for (int icomp=0; icomp<_local_field->getField()->getNumberOfComponents(); icomp++) - { - double total_norm = _local_field->getVolumeIntegral(icomp+1); - double source_norm=total_norm; - _comm_interface->broadcast(&source_norm, 1, MPI_DOUBLE, 0,* dynamic_cast(_union_group)->getComm()); - - if (abs(total_norm)>1e-100) - _local_field->getField()->applyLin(source_norm/total_norm,0.0,icomp+1); - } - } - } + if (_source_group->containsMyRank()) + for (int icomp=0; icomp<_local_field->getField()->getNumberOfComponents(); icomp++) + { + double total_norm = _local_field->getVolumeIntegral(icomp+1); + double source_norm = total_norm; + _comm_interface->broadcast(&source_norm, 1, MPI_DOUBLE, 0,* dynamic_cast(_union_group)->getComm()); + + } + if (_target_group->containsMyRank()) + { + for (int icomp=0; icomp<_local_field->getField()->getNumberOfComponents(); icomp++) + { + double total_norm = _local_field->getVolumeIntegral(icomp+1); + double source_norm=total_norm; + _comm_interface->broadcast(&source_norm, 1, MPI_DOUBLE, 0,* dynamic_cast(_union_group)->getComm()); + + if (abs(total_norm)>1e-100) + _local_field->getField()->applyLin(source_norm/total_norm,0.0,icomp+1); + } + } + } /*! @} */ } diff --git a/src/ParaMEDMEM/InterpolationMatrix.cxx b/src/ParaMEDMEM/InterpolationMatrix.cxx index 693ac59f6..9aac842de 100644 --- a/src/ParaMEDMEM/InterpolationMatrix.cxx +++ b/src/ParaMEDMEM/InterpolationMatrix.cxx @@ -70,106 +70,106 @@ The number of elements per row is stored in the row_offsets array. */ void InterpolationMatrix::addContribution(MEDMEM::MESH& distant_support, int iproc_distant, int* distant_elems) { - if (distant_support.getMeshDimension() != _source_support.getMeshDimension() || - distant_support.getMeshDimension() != _source_support.getMeshDimension() ) - throw MEDMEM::MEDEXCEPTION("local and distant meshes do not have the same space and mesh dimensions"); - - //creating the interpolator structure - vector > surfaces; - //computation of the intersection volumes between source and target elements - int source_size= _source_support.getNumberOfElements(MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS); - + if (distant_support.getMeshDimension() != _source_support.getMeshDimension() || + distant_support.getMeshDimension() != _source_support.getMeshDimension() ) + throw MEDMEM::MEDEXCEPTION("local and distant meshes do not have the same space and mesh dimensions"); - - if (distant_support.getMeshDimension()==2 && distant_support.getSpaceDimension()==3) - { - MEDNormalizedUnstructuredMesh<3,2>target_wrapper(&distant_support); - MEDNormalizedUnstructuredMesh<3,2> source_wrapper(&_source_support); - INTERP_KERNEL::Interpolation3DSurf interpolator; - interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces); - } - else if (distant_support.getMeshDimension()==2 && distant_support.getSpaceDimension()==2) - { - MEDNormalizedUnstructuredMesh<2,2>target_wrapper(&distant_support); - MEDNormalizedUnstructuredMesh<2,2> source_wrapper(&_source_support); + //creating the interpolator structure + vector > surfaces; + //computation of the intersection volumes between source and target elements + int source_size= _source_support.getNumberOfElements(MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS); - INTERP_KERNEL::Interpolation2D interpolator; - interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces); - } - else if (distant_support.getMeshDimension()==3 && distant_support.getSpaceDimension()==3) - { - MEDNormalizedUnstructuredMesh<3,3>target_wrapper(&distant_support); - MEDNormalizedUnstructuredMesh<3,3> source_wrapper(&_source_support); - INTERP_KERNEL::Interpolation3D interpolator; - interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces); - } - else - { - throw MEDMEM::MEDEXCEPTION("no interpolator exists for these mesh and space dimensions "); - } - - if (surfaces.size() != source_size) - { - cout<<"surfaces.size()="<* target_triangle_surf = getSupportVolumes(target_support); - MEDMEM::SUPPORT source_support (const_cast(&_source_support),"all cells", MED_EN::MED_CELL); - MEDMEM::FIELD* source_triangle_surf = getSupportVolumes(source_support); - - //storing the source volumes - _source_volume.resize(source_size); - for (int i=0; igetValueIJ(i+1,1); - - //loop over the elements to build the interpolation - //matrix structures + + if (distant_support.getMeshDimension()==2 && distant_support.getSpaceDimension()==3) + { + MEDNormalizedUnstructuredMesh<3,2>target_wrapper(&distant_support); + MEDNormalizedUnstructuredMesh<3,2> source_wrapper(&_source_support); + INTERP_KERNEL::Interpolation3DSurf interpolator; + interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces); + } + else if (distant_support.getMeshDimension()==2 && distant_support.getSpaceDimension()==2) + { + MEDNormalizedUnstructuredMesh<2,2>target_wrapper(&distant_support); + MEDNormalizedUnstructuredMesh<2,2> source_wrapper(&_source_support); + + INTERP_KERNEL::Interpolation2D interpolator; + interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces); + } + else if (distant_support.getMeshDimension()==3 && distant_support.getSpaceDimension()==3) + { + MEDNormalizedUnstructuredMesh<3,3>target_wrapper(&distant_support); + MEDNormalizedUnstructuredMesh<3,3> source_wrapper(&_source_support); + + INTERP_KERNEL::Interpolation3D interpolator; + interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces); + } + else + { + throw MEDMEM::MEDEXCEPTION("no interpolator exists for these mesh and space dimensions "); + } + + if (surfaces.size() != source_size) + { + cout<<"surfaces.size()="<* target_triangle_surf = getSupportVolumes(target_support); + MEDMEM::SUPPORT source_support (const_cast(&_source_support),"all cells", MED_EN::MED_CELL); + MEDMEM::FIELD* source_triangle_surf = getSupportVolumes(source_support); + + //storing the source volumes + _source_volume.resize(source_size); + for (int i=0; igetValueIJ(i+1,1); + + //loop over the elements to build the interpolation + //matrix structures for (int ielem=0; ielem < surfaces.size(); ielem++) + { + _row_offsets[ielem+1]+=surfaces[ielem].size(); + // _source_indices.push_back(make_pair(iproc_distant, ielem)); + for (map::const_iterator iter=surfaces[ielem].begin(); + iter!=surfaces[ielem].end(); + iter++) { - _row_offsets[ielem+1]+=surfaces[ielem].size(); - // _source_indices.push_back(make_pair(iproc_distant, ielem)); - for (map::const_iterator iter=surfaces[ielem].begin(); - iter!=surfaces[ielem].end(); - iter++) - { - //surface of the target triangle - double surf = target_triangle_surf->getValueIJ(iter->first,1); - - //locating the (iproc, itriangle) pair in the list of columns - vector >::iterator iter2 = find (_col_offsets.begin(), _col_offsets.end(),make_pair(iproc_distant,iter->first)); - int col_id; - - - if (iter2==_col_offsets.end()) - { - //(iproc, itriangle) is not registered in the list - //of distant elements - - _col_offsets.push_back(make_pair(iproc_distant,iter->first)); - col_id =_col_offsets.size(); - _mapping.addElementFromSource(iproc_distant,distant_elems[iter->first-1]); - _target_volume.push_back(surf); - } - else - { - col_id=iter2-_col_offsets.begin()+1; - } - - //the non zero coefficient is stored - //ielem is the row, - //col_id is the number of the column - //iter->second is the value of the coefficient - - _coeffs[ielem].push_back(make_pair(col_id,iter->second)); - - } + //surface of the target triangle + double surf = target_triangle_surf->getValueIJ(iter->first,1); + + //locating the (iproc, itriangle) pair in the list of columns + vector >::iterator iter2 = find (_col_offsets.begin(), _col_offsets.end(),make_pair(iproc_distant,iter->first)); + int col_id; + + + if (iter2==_col_offsets.end()) + { + //(iproc, itriangle) is not registered in the list + //of distant elements + + _col_offsets.push_back(make_pair(iproc_distant,iter->first)); + col_id =_col_offsets.size(); + _mapping.addElementFromSource(iproc_distant,distant_elems[iter->first-1]); + _target_volume.push_back(surf); + } + else + { + col_id=iter2-_col_offsets.begin()+1; + } + + //the non zero coefficient is stored + //ielem is the row, + //col_id is the number of the column + //iter->second is the value of the coefficient + + _coeffs[ielem].push_back(make_pair(col_id,iter->second)); + } - delete source_triangle_surf; - delete target_triangle_surf; + } + delete source_triangle_surf; + delete target_triangle_surf; } /*! The call to this method updates the arrays on the target side @@ -203,99 +203,99 @@ void InterpolationMatrix::multiply(MEDMEM::FIELD& field) const { vector target_value(_col_offsets.size()* field.getNumberOfComponents(),0.0); - //computing the matrix multiply on source side - if (_source_group.containsMyRank()) - { - int nbcomp = field.getNumberOfComponents(); - int nbrows= _source_support.getNumberOfElements(MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS); - - // performing W.S - // W is the intersection matrix - // S is the source vector - - for (int irow=0; irowgetNumberOfElements(MED_EN::MED_ALL_ELEMENTS); - int nbcomp = field.getNumberOfComponents(); - double* value = const_cast (field.getValue()); - for (int i=0; igetNumberOfElements(MED_EN::MED_ALL_ELEMENTS); + int nbcomp = field.getNumberOfComponents(); + double* value = const_cast (field.getValue()); + for (int i=0; i& field) const { vector source_value(_col_offsets.size()* field.getNumberOfComponents(),0.0); _mapping.reverseSendRecv(&source_value[0],field); - //treatment of the transpose matrix multiply on the source side - if (_source_group.containsMyRank()) - { - int nbcomp = field.getNumberOfComponents(); - int nbrows = _source_support.getNumberOfElements(MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS); - - vector target_value(nbrows,0.0); - - //performing WT.T - //WT is W transpose - //T is the target vector - for (int irow=0; irow target_value(nbrows,0.0); + + //performing WT.T + //WT is W transpose + //T is the target vector + for (int irow=0; irowgetSupport()->getMesh(); - cout <<"size of Interpolation Matrix"<getSupport()->getMesh(); + cout <<"size of Interpolation Matrix"<setAllToAllMethod(_allToAllMethod); _interpolation_matrix->getAccessDEC()->Asynchronous( _asynchronous ) ; _interpolation_matrix->getAccessDEC()->SetTimeInterpolator( _timeinterpolationmethod ) ; - + //setting up the communication DEC on both sides if (_source_group->containsMyRank()) + { + //locate the distant meshes + ElementLocator locator(*para_mesh, *_target_group); + + //transfering option from IntersectionDEC to ElementLocator + double bb_adj; + getOption("BoundingBoxAdjustment",bb_adj); + locator.setOption("BoundingBoxAdjustment",bb_adj); + + MESH* distant_mesh=0; + int* distant_ids=0; + for (int i=0; i<_target_group->size(); i++) { - //locate the distant meshes - ElementLocator locator(*para_mesh, *_target_group); - - //transfering option from IntersectionDEC to ElementLocator - double bb_adj; - getOption("BoundingBoxAdjustment",bb_adj); - locator.setOption("BoundingBoxAdjustment",bb_adj); - - MESH* distant_mesh=0; - int* distant_ids=0; - for (int i=0; i<_target_group->size(); i++) - { - // int idistant_proc = (i+_source_group->myRank())%_target_group->size(); - int idistant_proc=i; - - //gathers pieces of the target meshes that can intersect the local mesh - locator.exchangeMesh(idistant_proc,distant_mesh,distant_ids); - - if (distant_mesh !=0) - { - //adds the contribution of the distant mesh on the local one - int idistant_proc_in_union=_union_group->translateRank(_target_group,idistant_proc); - cout <<"add contribution from proc "<myRank()<addContribution(*distant_mesh,idistant_proc_in_union,distant_ids); - - delete distant_mesh; - delete[] distant_ids; - distant_mesh=0; - distant_ids=0; - } - } - - } - + // int idistant_proc = (i+_source_group->myRank())%_target_group->size(); + int idistant_proc=i; + + //gathers pieces of the target meshes that can intersect the local mesh + locator.exchangeMesh(idistant_proc,distant_mesh,distant_ids); + + if (distant_mesh !=0) + { + //adds the contribution of the distant mesh on the local one + int idistant_proc_in_union=_union_group->translateRank(_target_group,idistant_proc); + cout <<"add contribution from proc "<myRank()<addContribution(*distant_mesh,idistant_proc_in_union,distant_ids); + + delete distant_mesh; + delete[] distant_ids; + distant_mesh=0; + distant_ids=0; + } + } + + } + if (_target_group->containsMyRank()) + { + ElementLocator locator(*para_mesh, *_source_group); + //transfering option from IntersectionDEC to ElementLocator + double bb_adj; + MEDMEM::OptionManager::getOption("BoundingBoxAdjustment",bb_adj); + locator.setOption("BoundingBoxAdjustment",bb_adj); + + MESH* distant_mesh=0; + int* distant_ids=0; + for (int i=0; i<_source_group->size(); i++) { - ElementLocator locator(*para_mesh, *_source_group); - //transfering option from IntersectionDEC to ElementLocator - double bb_adj; - MEDMEM::OptionManager::getOption("BoundingBoxAdjustment",bb_adj); - locator.setOption("BoundingBoxAdjustment",bb_adj); - - MESH* distant_mesh=0; - int* distant_ids=0; - for (int i=0; i<_source_group->size(); i++) - { - // int idistant_proc = (i+_target_group->myRank())%_source_group->size(); - int idistant_proc=i; - //gathers pieces of the target meshes that can intersect the local mesh - locator.exchangeMesh(idistant_proc,distant_mesh,distant_ids); - cout << " Data sent from "<<_union_group->myRank()<<" to source proc "<< idistant_proc<myRank())%_source_group->size(); + int idistant_proc=i; + //gathers pieces of the target meshes that can intersect the local mesh + locator.exchangeMesh(idistant_proc,distant_mesh,distant_ids); + cout << " Data sent from "<<_union_group->myRank()<<" to source proc "<< idistant_proc<prepare(); - + } /*! -Receives the data whether the processor is on the working side or on the lazy side. It must match a \a sendData() call on the other side. - */ + Receives the data whether the processor is on the working side or on the lazy side. It must match a \a sendData() call on the other side. +*/ void IntersectionDEC::recvData() { diff --git a/src/ParaMEDMEM/MxN_Mapping.cxx b/src/ParaMEDMEM/MxN_Mapping.cxx index e2197dcd1..9f83ceceb 100644 --- a/src/ParaMEDMEM/MxN_Mapping.cxx +++ b/src/ParaMEDMEM/MxN_Mapping.cxx @@ -267,7 +267,7 @@ void MxN_Mapping::reverseSendRecv(double* recvfield, MEDMEM::FIELD& fiel { CommInterface comm_interface=_union_group->getCommInterface(); const MPIProcessorGroup* group = static_cast(_union_group); - + int nbcomp=field.getNumberOfComponents(); double* sendbuf=0; double* recvbuf=0; @@ -275,12 +275,12 @@ void MxN_Mapping::reverseSendRecv(double* recvfield, MEDMEM::FIELD& fiel sendbuf = new double[_recv_ids.size()*nbcomp]; if (_sending_ids.size()>0) recvbuf = new double[_sending_ids.size()*nbcomp]; - + int* sendcounts = new int[_union_group->size()]; int* senddispls=new int[_union_group->size()]; int* recvcounts=new int[_union_group->size()]; int* recvdispls=new int[_union_group->size()]; - + for (int i=0; i< _union_group->size(); i++) { sendcounts[i]=nbcomp*(_recv_proc_offsets[i+1]-_recv_proc_offsets[i]); @@ -290,67 +290,67 @@ void MxN_Mapping::reverseSendRecv(double* recvfield, MEDMEM::FIELD& fiel } //building the buffer of the elements to be sent vector offsets = _recv_proc_offsets; - - for (int iproc=0; iproc<_union_group->size();iproc++) - for (int i=_recv_proc_offsets[iproc]; i<_recv_proc_offsets[iproc+1]; i++) - { - for (int icomp=0; icompsize();iproc++) + for (int i=_recv_proc_offsets[iproc]; i<_recv_proc_offsets[iproc+1]; i++) + { + for (int icomp=0; icompgetComm(); comm_interface.allToAllV(sendbuf, sendcounts, senddispls, MPI_DOUBLE, recvbuf, recvcounts, recvdispls, MPI_DOUBLE, *comm); - } - break; - case PointToPoint: - _accessDEC->AllToAllv(sendbuf, sendcounts, senddispls, MPI_DOUBLE, - recvbuf, recvcounts, recvdispls, MPI_DOUBLE); - break; + } + break; + case PointToPoint: + _accessDEC->AllToAllv(sendbuf, sendcounts, senddispls, MPI_DOUBLE, + recvbuf, recvcounts, recvdispls, MPI_DOUBLE); + break; } - - + + //setting zero values in the field - // for (int i=0; i< field.getSupport()->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS);i++) - // for (int j=0; jgetNumberOfElements(MED_EN::MED_ALL_ELEMENTS);i++) + // for (int j=0; jsize()]; i++) - { - for (int icomp=0; icompgetProcGroup()->containsMyRank()) return; diff --git a/src/ParaMEDMEM/ParaMESH.cxx b/src/ParaMEDMEM/ParaMESH.cxx index 9288dc3d7..15f99ac30 100644 --- a/src/ParaMEDMEM/ParaMESH.cxx +++ b/src/ParaMEDMEM/ParaMESH.cxx @@ -20,7 +20,8 @@ ParaMESH::ParaMESH(MEDMEM::driverTypes driver_type, const string& filename, const ProcessorGroup& group) throw (MEDMEM::MEDEXCEPTION) :_has_mesh_ownership(true) { - BEGIN_OF("MEDSPLITTER::MESHCollectionDriver::read()") + const char* LOC = "MEDSPLITTER::MESHCollectionDriver::read()"; + BEGIN_OF(LOC); string meshstring; @@ -234,7 +235,8 @@ ParaMESH::~ParaMESH() void ParaMESH::write(MEDMEM::driverTypes driverType, const string& master_filename) throw (MEDMEM::MEDEXCEPTION){ - BEGIN_OF("ParaMEDMEM::ParaMESH::write()"); + const char* LOC = "ParaMEDMEM::ParaMESH::write()"; + BEGIN_OF(LOC); if (!_block_topology->getProcGroup()->containsMyRank()) return; -- 2.39.2