From: ageay Date: Fri, 1 Apr 2011 16:55:44 +0000 (+0000) Subject: *** empty log message *** X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=43d1c1dbadb35264aa2b319b4d15ecc2609825d6;p=tools%2Fmedcoupling.git *** empty log message *** --- diff --git a/src/ParaMEDMEM/OverlapDEC.cxx b/src/ParaMEDMEM/OverlapDEC.cxx index f01889489..7a62893ca 100644 --- a/src/ParaMEDMEM/OverlapDEC.cxx +++ b/src/ParaMEDMEM/OverlapDEC.cxx @@ -93,6 +93,15 @@ of proc #m. In this case proc#k computes part of mesh A in boundingbox B of proc#m. It implies that the corresponding cellIds or nodeIds of corresponding part are sent to proc #m too. + Let's consider the couple (k,m) in TODO list. This couple is treated by either k or m as seen \ref ParaMEDMEMOverlapDECAlgoStep2 "here". + + As it will be dealt in Step 6, at the end for final matrix-vector computation the result matrix of the couple (k,m) anywhere it is computed (proc#k or proc#m) + it will be stored in \b proc#m. + + If proc#k is in charge of this couple (k,m) target ids (cells or nodes) of mesh in proc#m are renumbered, because proc#m has stripped + its target mesh to avoid big amount of data. In this case has it is finally proc#m in charge of the matrix, proc#m keeps preciously the + target ids sent to proc#k. No problem will appear for source ids because no restriction done. + This step is performed in ParaMEDMEM::OverlapElementLocator::exchangeMeshes method. \subsection ParaMEDMEMOverlapDECAlgoStep4 Step 4 : The interpolation matrix computation @@ -110,7 +119,7 @@ After having performed the TODO list at the end of \ref ParaMEDMEMOverlapDECAlgoStep4 "Step4" it is needed to assemble the final matrix. The final aim is to have a distributed matrix \f$ M_k \f$ on each proc#k. In order to reduce data exchange during matrix product process. - \f$ M_k \f$ is built using sizeof(Proc group) \c std::vector< std::map >. + \f$ M_k \f$ is built using sizeof(Proc group) \c std::vector< \c std::map \c >. For a proc#k, it is necessary to fetch info of all matrix built in \ref ParaMEDMEMOverlapDECAlgoStep4 "Step4" where the first element in pair is equal to k. @@ -165,12 +174,13 @@ namespace ParaMEDMEM void OverlapDEC::sendData() { - throw INTERP_KERNEL::Exception("Not implemented yet !!!!"); + _interpolation_matrix->multiply(); } void OverlapDEC::recvData() { - _interpolation_matrix->transposeMultiply();; + throw INTERP_KERNEL::Exception("Not implemented yet !!!!"); + //_interpolation_matrix->transposeMultiply(); } void OverlapDEC::synchronize() @@ -191,7 +201,7 @@ namespace ParaMEDMEM const DataArrayInt *srcIds=locator.getSourceIds((*it).first); const MEDCouplingPointSet *trg=locator.getTargetMesh((*it).second); const DataArrayInt *trgIds=locator.getTargetIds((*it).second); - _interpolation_matrix->addContribution(src,srcIds,srcMeth,(*it).first,trg,trgIds,trgMeth,(*it).first); + _interpolation_matrix->addContribution(src,srcIds,srcMeth,(*it).first,trg,trgIds,trgMeth,(*it).second); } _interpolation_matrix->prepare(locator.getProcsInInteraction()); _interpolation_matrix->computeDeno(); diff --git a/src/ParaMEDMEM/OverlapInterpolationMatrix.cxx b/src/ParaMEDMEM/OverlapInterpolationMatrix.cxx index 38da7fe04..f08c2e664 100644 --- a/src/ParaMEDMEM/OverlapInterpolationMatrix.cxx +++ b/src/ParaMEDMEM/OverlapInterpolationMatrix.cxx @@ -68,56 +68,56 @@ namespace ParaMEDMEM void OverlapInterpolationMatrix::addContribution(const MEDCouplingPointSet *src, const DataArrayInt *srcIds, const std::string& srcMeth, int srcProcId, const MEDCouplingPointSet *trg, const DataArrayInt *trgIds, const std::string& trgMeth, int trgProcId) { - std::string interpMethod(trgMeth); - interpMethod+=srcMeth; + std::string interpMethod(srcMeth); + interpMethod+=trgMeth; //creating the interpolator structure vector > surfaces; int colSize=0; //computation of the intersection volumes between source and target elements const MEDCouplingUMesh *trgC=dynamic_cast(trg); const MEDCouplingUMesh *srcC=dynamic_cast(src); - if ( trg->getMeshDimension() == -1 ) + if ( src->getMeshDimension() == -1 ) { - if(srcC->getMeshDimension()==2 && srcC->getSpaceDimension()==2) + if(trgC->getMeshDimension()==2 && trgC->getSpaceDimension()==2) { - MEDCouplingNormalizedUnstructuredMesh<2,2> source_mesh_wrapper(srcC); + MEDCouplingNormalizedUnstructuredMesh<2,2> target_mesh_wrapper(trgC); INTERP_KERNEL::Interpolation2D interpolation(*this); - colSize=interpolation.fromIntegralUniform(source_mesh_wrapper,surfaces,srcMeth.c_str()); + colSize=interpolation.fromIntegralUniform(target_mesh_wrapper,surfaces,trgMeth.c_str()); } - else if(srcC->getMeshDimension()==3 && srcC->getSpaceDimension()==3) + else if(trgC->getMeshDimension()==3 && trgC->getSpaceDimension()==3) { - MEDCouplingNormalizedUnstructuredMesh<3,3> source_mesh_wrapper(srcC); + MEDCouplingNormalizedUnstructuredMesh<3,3> target_mesh_wrapper(trgC); INTERP_KERNEL::Interpolation3D interpolation(*this); - colSize=interpolation.fromIntegralUniform(source_mesh_wrapper,surfaces,srcMeth.c_str()); + colSize=interpolation.fromIntegralUniform(target_mesh_wrapper,surfaces,trgMeth.c_str()); } - else if(srcC->getMeshDimension()==2 && srcC->getSpaceDimension()==3) + else if(trgC->getMeshDimension()==2 && trgC->getSpaceDimension()==3) { - MEDCouplingNormalizedUnstructuredMesh<3,2> source_mesh_wrapper(srcC); + MEDCouplingNormalizedUnstructuredMesh<3,2> target_mesh_wrapper(trgC); INTERP_KERNEL::Interpolation3DSurf interpolation(*this); - colSize=interpolation.fromIntegralUniform(source_mesh_wrapper,surfaces,srcMeth.c_str()); + colSize=interpolation.fromIntegralUniform(target_mesh_wrapper,surfaces,trgMeth.c_str()); } else throw INTERP_KERNEL::Exception("No para interpolation available for the given mesh and space dimension of source mesh to -1D targetMesh"); } - else if ( srcC->getMeshDimension() == -1 ) + else if ( trg->getMeshDimension() == -1 ) { - if(trgC->getMeshDimension()==2 && trgC->getSpaceDimension()==2) + if(srcC->getMeshDimension()==2 && srcC->getSpaceDimension()==2) { - MEDCouplingNormalizedUnstructuredMesh<2,2> distant_mesh_wrapper(trgC); + MEDCouplingNormalizedUnstructuredMesh<2,2> local_mesh_wrapper(srcC); INTERP_KERNEL::Interpolation2D interpolation(*this); - colSize=interpolation.toIntegralUniform(distant_mesh_wrapper,surfaces,srcMeth.c_str()); + colSize=interpolation.toIntegralUniform(local_mesh_wrapper,surfaces,srcMeth.c_str()); } - else if(trgC->getMeshDimension()==3 && trgC->getSpaceDimension()==3) + else if(srcC->getMeshDimension()==3 && srcC->getSpaceDimension()==3) { - MEDCouplingNormalizedUnstructuredMesh<3,3> distant_mesh_wrapper(trgC); + MEDCouplingNormalizedUnstructuredMesh<3,3> local_mesh_wrapper(srcC); INTERP_KERNEL::Interpolation3D interpolation(*this); - colSize=interpolation.toIntegralUniform(distant_mesh_wrapper,surfaces,srcMeth.c_str()); + colSize=interpolation.toIntegralUniform(local_mesh_wrapper,surfaces,srcMeth.c_str()); } - else if(trgC->getMeshDimension()==2 && trgC->getSpaceDimension()==3) + else if(srcC->getMeshDimension()==2 && srcC->getSpaceDimension()==3) { - MEDCouplingNormalizedUnstructuredMesh<3,2> distant_mesh_wrapper(trgC); + MEDCouplingNormalizedUnstructuredMesh<3,2> local_mesh_wrapper(srcC); INTERP_KERNEL::Interpolation3DSurf interpolation(*this); - colSize=interpolation.toIntegralUniform(distant_mesh_wrapper,surfaces,srcMeth.c_str()); + colSize=interpolation.toIntegralUniform(local_mesh_wrapper,surfaces,srcMeth.c_str()); } else throw INTERP_KERNEL::Exception("No para interpolation available for the given mesh and space dimension of distant mesh to -1D sourceMesh"); @@ -126,14 +126,14 @@ namespace ParaMEDMEM { throw INTERP_KERNEL::Exception("local and distant meshes do not have the same space and mesh dimensions"); } - else if( trg->getMeshDimension() == 1 - && trg->getSpaceDimension() == 1 ) + else if( src->getMeshDimension() == 1 + && src->getSpaceDimension() == 1 ) { MEDCouplingNormalizedUnstructuredMesh<1,1> target_wrapper(trgC); MEDCouplingNormalizedUnstructuredMesh<1,1> source_wrapper(srcC); INTERP_KERNEL::Interpolation1D interpolation(*this); - colSize=interpolation.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod.c_str()); + colSize=interpolation.interpolateMeshes(source_wrapper,target_wrapper,surfaces,interpMethod.c_str()); target_wrapper.releaseTempArrays(); source_wrapper.releaseTempArrays(); } @@ -144,7 +144,7 @@ namespace ParaMEDMEM MEDCouplingNormalizedUnstructuredMesh<2,1> source_wrapper(srcC); INTERP_KERNEL::Interpolation2DCurve interpolation(*this); - colSize=interpolation.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod.c_str()); + colSize=interpolation.interpolateMeshes(source_wrapper,target_wrapper,surfaces,interpMethod.c_str()); target_wrapper.releaseTempArrays(); source_wrapper.releaseTempArrays(); } @@ -155,7 +155,7 @@ namespace ParaMEDMEM MEDCouplingNormalizedUnstructuredMesh<3,2> source_wrapper(srcC); INTERP_KERNEL::Interpolation3DSurf interpolator (*this); - colSize=interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod.c_str()); + colSize=interpolator.interpolateMeshes(source_wrapper,target_wrapper,surfaces,interpMethod.c_str()); target_wrapper.releaseTempArrays(); source_wrapper.releaseTempArrays(); } @@ -166,7 +166,7 @@ namespace ParaMEDMEM MEDCouplingNormalizedUnstructuredMesh<2,2> source_wrapper(srcC); INTERP_KERNEL::Interpolation2D interpolator (*this); - colSize=interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod.c_str()); + colSize=interpolator.interpolateMeshes(source_wrapper,target_wrapper,surfaces,interpMethod.c_str()); target_wrapper.releaseTempArrays(); source_wrapper.releaseTempArrays(); } @@ -177,7 +177,7 @@ namespace ParaMEDMEM MEDCouplingNormalizedUnstructuredMesh<3,3> source_wrapper(srcC); INTERP_KERNEL::Interpolation3D interpolator (*this); - colSize=interpolator.interpolateMeshes(target_wrapper,source_wrapper,surfaces,interpMethod.c_str()); + colSize=interpolator.interpolateMeshes(source_wrapper,target_wrapper,surfaces,interpMethod.c_str()); target_wrapper.releaseTempArrays(); source_wrapper.releaseTempArrays(); } @@ -185,19 +185,19 @@ namespace ParaMEDMEM { throw INTERP_KERNEL::Exception("no interpolator exists for these mesh and space dimensions "); } - bool needTargetSurf=isSurfaceComputationNeeded(trgMeth); - MEDCouplingFieldDouble *target_triangle_surf=0; - if(needTargetSurf) - target_triangle_surf=trg->getMeasureField(getMeasureAbsStatus()); + bool needSourceSurf=isSurfaceComputationNeeded(srcMeth); + MEDCouplingFieldDouble *source_triangle_surf=0; + if(needSourceSurf) + source_triangle_surf=src->getMeasureField(getMeasureAbsStatus()); // fillDistributedMatrix(surfaces,srcIds,srcProcId,trgIds,trgProcId); // - if(needTargetSurf) - target_triangle_surf->decrRef(); + if(needSourceSurf) + source_triangle_surf->decrRef(); } /*! - * \b WARNING : res rows refers to source and column (first param of map) to target. + * \b res rows refers to target and column (first param of map) to source. */ void OverlapInterpolationMatrix::fillDistributedMatrix(const std::vector< std::map >& res, const DataArrayInt *srcIds, int srcProc, @@ -205,10 +205,13 @@ namespace ParaMEDMEM { //computing matrix with real ids for target int sz=res.size(); - std::vector< std::map > res1(sz); const int *trgIds2=0; + const int *srcIds2=0; int nbTrgIds=_target_field->getField()->getNumberOfTuplesExpected(); + int nbSrcIds=_source_field->getField()->getNumberOfTuplesExpected(); + std::vector< std::map > res1(sz); INTERP_KERNEL::AutoPtr tmp2=new int[nbTrgIds]; + INTERP_KERNEL::AutoPtr tmp3=new int[nbSrcIds]; if(trgIds) trgIds2=trgIds->getConstPointer(); else @@ -217,25 +220,25 @@ namespace ParaMEDMEM for(int i=0;igetConstPointer(); + else + { + srcIds2=tmp3; + for(int i=0;i& m=res1[i]; const std::map& ref=res[i]; for(std::map::const_iterator it=ref.begin();it!=ref.end();it++) { - m[(*it).first]=(*it).second; //if(trgIds2) m[trgIds2[(*it).first]]=(*it).second; + m[srcIds2[(*it).first]]=(*it).second; } } //dealing source ids - if(srcIds) - _mapping.addContributionST(res1,srcIds->getConstPointer(),trgIds2,nbTrgIds,srcProc,trgProc); - else - { - INTERP_KERNEL::AutoPtr tmp=new int[sz]; - for(int i=0;i >& procsInInteraction) { if(_source_support) - _mapping.prepare(procsInInteraction,_source_field->getField()->getNumberOfTuplesExpected()); + _mapping.prepare(procsInInteraction,_target_field->getField()->getNumberOfTuplesExpected()); else _mapping.prepare(procsInInteraction,0); } void OverlapInterpolationMatrix::computeDeno() { - if(_source_field->getField()->getNature()==IntegralGlobConstraint) + if(_target_field->getField()->getNature()==IntegralGlobConstraint) _mapping.computeDenoGlobConstraint(); } + void OverlapInterpolationMatrix::multiply() + { + _mapping.multiply(_source_field->getField(),_target_field->getField()); + } + void OverlapInterpolationMatrix::transposeMultiply() { _mapping.transposeMultiply(_target_field->getField(),_source_field->getField()); diff --git a/src/ParaMEDMEM/OverlapInterpolationMatrix.hxx b/src/ParaMEDMEM/OverlapInterpolationMatrix.hxx index bd11b01ee..1f84e7ced 100644 --- a/src/ParaMEDMEM/OverlapInterpolationMatrix.hxx +++ b/src/ParaMEDMEM/OverlapInterpolationMatrix.hxx @@ -48,6 +48,8 @@ namespace ParaMEDMEM void computeDeno(); + void multiply(); + void transposeMultiply(); virtual ~OverlapInterpolationMatrix(); diff --git a/src/ParaMEDMEM/OverlapMapping.cxx b/src/ParaMEDMEM/OverlapMapping.cxx index 2f7fc4db5..830d026b8 100644 --- a/src/ParaMEDMEM/OverlapMapping.cxx +++ b/src/ParaMEDMEM/OverlapMapping.cxx @@ -35,15 +35,15 @@ OverlapMapping::OverlapMapping(const ProcessorGroup& group):_group(group) } /*! - * This method stores from a matrix in format Source(rows)/Target(cols) for a source procId 'srcProcId' and for a target procId 'trgProcId'. + * This method stores from a matrix in format Target(rows)/Source(cols) for a source procId 'srcProcId' and for a target procId 'trgProcId'. * All ids (source and target) are in format of local ids. */ void OverlapMapping::addContributionST(const std::vector< std::map >& matrixST, const int *srcIds, const int *trgIds, int trgIdsLgth, int srcProcId, int trgProcId) { int nbOfRows=matrixST.size(); _matrixes_st.push_back(matrixST); - _source_ids_st.resize(_source_ids_st.size()+1); - _source_ids_st.back().insert(_source_ids_st.back().end(),srcIds,srcIds+nbOfRows); + //_source_ids_st.resize(_source_ids_st.size()+1); + //_source_ids_st.back().insert(_source_ids_st.back().end(),srcIds,srcIds+nbOfRows); _source_proc_id_st.push_back(srcProcId); // _target_ids_st.resize(_target_ids_st.size()+1); @@ -59,7 +59,7 @@ void OverlapMapping::addContributionST(const std::vector< std::map > * After the call of this method 'this' contains the matrixST for all source elements of the current proc and * matrixTS for all target elements of current proc. */ -void OverlapMapping::prepare(const std::vector< std::vector >& procsInInteraction, int nbOfSrcElems) +void OverlapMapping::prepare(const std::vector< std::vector >& procsInInteraction, int nbOfTrgElems) { CommInterface commInterface=_group.getCommInterface(); const MPIProcessorGroup *group=static_cast(&_group); @@ -90,7 +90,7 @@ void OverlapMapping::prepare(const std::vector< std::vector >& procsInInter INTERP_KERNEL::AutoPtr bigArrRecv=new int[nbrecv2[grpSize-1]+nbrecv1[grpSize-1]]; commInterface.allToAllV(bigArr,nbsend2,nbsend3,MPI_INT, bigArrRecv,nbrecv1,nbrecv2,MPI_INT, - *comm);// sending ids off sparse matrix (n+1 elems) + src ids (n elems) + *comm);// sending ids of sparse matrix (n+1 elems) + src ids (n elems) //second phase echange target ids std::fill(nbsend2,nbsend2+grpSize,0); INTERP_KERNEL::AutoPtr nbrecv3=new int[grpSize]; @@ -110,10 +110,10 @@ void OverlapMapping::prepare(const std::vector< std::vector >& procsInInter bigArrDRecv2,nbrecv3,nbrecv4,MPI_DOUBLE, *comm); //finishing - unserializationST(nbOfSrcElems,nbrecv,bigArrRecv,nbrecv1,nbrecv2, + unserializationST(nbOfTrgElems,nbrecv,bigArrRecv,nbrecv1,nbrecv2, bigArrRecv2,bigArrDRecv2,nbrecv3,nbrecv4); //finish to fill _the_matrix_st and _the_matrix_st_target_proc_id with already in place matrix in _matrixes_st - finishToFillFinalMatrixST(nbOfSrcElems); + finishToFillFinalMatrixST(nbOfTrgElems); //exchanging target ids for future sending prepareIdsToSendST(); } @@ -262,52 +262,51 @@ int OverlapMapping::serializeMatrixStep1ST(const int *nbOfElemsSrc, const int *r * This is the last step after all2Alls for matrix exchange. * _the_matrix_st is the final matrix : * - The first entry is srcId in current proc. - * - The second is the pseudo id of target proc (correspondance with true id is in attribute _the_matrix_st_target_proc_id and _the_matrix_st_target_ids) - * - the third is the trgId in the pseudo target proc + * - The second is the pseudo id of source proc (correspondance with true id is in attribute _the_matrix_st_source_proc_id and _the_matrix_st_source_ids) + * - the third is the srcId in the pseudo source proc */ -void OverlapMapping::unserializationST(int nbOfSrcElems, +void OverlapMapping::unserializationST(int nbOfTrgElems, const int *nbOfElemsSrcPerProc,//first all2all const int *bigArrRecv, const int *bigArrRecvCounts, const int *bigArrRecvOffs,//2nd all2all const int *bigArrRecv2, const double *bigArrDRecv2, const int *bigArrRecv2Count, const int *bigArrRecv2Offs)//3rd and 4th all2alls { _the_matrix_st.clear(); - _the_matrix_st.resize(nbOfSrcElems); - _the_matrix_st_target_proc_id.clear(); + _the_matrix_st_source_proc_id.clear(); // int grpSize=_group.size(); for(int i=0;i targetIdsZip;// this zip is to reduce amount of data to send/rexcv on transposeMultiply target ids transfert + std::set sourceIdsZip;// this zip is to reduce amount of data to send/rexcv on transposeMultiply target ids transfert for(int k=0;k old2newTrgIds; + _the_matrix_st_source_ids[j].insert(_the_matrix_st_source_ids[j].end(),sourceIdsZip.begin(),sourceIdsZip.end()); + std::map old2newSrcIds; int newNbTrg=0; - for(std::set::const_iterator it=targetIdsZip.begin();it!=targetIdsZip.end();it++,newNbTrg++) - old2newTrgIds[*it]=newNbTrg; + for(std::set::const_iterator it=sourceIdsZip.begin();it!=sourceIdsZip.end();it++,newNbTrg++) + old2newSrcIds[*it]=newNbTrg; for(int k=0;k_the_matrix_st_target_ids'. * This method finish the job of filling 'this->_the_matrix_st' and 'this->_the_matrix_st_target_proc_id' by putting candidates in 'this->_matrixes_st' into them. */ -void OverlapMapping::finishToFillFinalMatrixST(int nbOfSrcElems) +void OverlapMapping::finishToFillFinalMatrixST(int nbOfTrgElems) { int myProcId=_group.myRank(); int sz=_matrixes_st.size(); @@ -327,16 +326,16 @@ void OverlapMapping::finishToFillFinalMatrixST(int nbOfSrcElems) if(_source_proc_id_st[i]==myProcId) { nbOfEntryToAdd++; - _the_matrix_st_target_proc_id.push_back(_target_proc_id_st[i]); + _the_matrix_st_source_proc_id.push_back(_target_proc_id_st[i]); } if(nbOfEntryToAdd==0) return ; int oldNbOfEntry=_the_matrix_st.size(); int newNbOfEntry=oldNbOfEntry+nbOfEntryToAdd; _the_matrix_st.resize(newNbOfEntry); - _the_matrix_st_target_ids.resize(newNbOfEntry); + _the_matrix_st_source_ids.resize(newNbOfEntry); for(int i=oldNbOfEntry;i& m2=mat[k]; for(std::map::const_iterator it=m2.begin();it!=m2.end();it++) - _the_matrix_st[j][srcIds[k]][(*it).first]=(*it).second; + _the_matrix_st[j][(*it).first][srcIds[k]]=(*it).second; } - _the_matrix_st_target_ids[j].insert(_the_matrix_st_target_ids[j].end(),_target_ids_st[i].begin(),_target_ids_st[i].end()); + _the_matrix_st_source_ids[j].insert(_the_matrix_st_source_ids[j].end(),_source_ids_st[i].begin(),_source_ids_st[i].end()); j++; } } @@ -364,12 +363,12 @@ void OverlapMapping::prepareIdsToSendST() const MPIProcessorGroup *group=static_cast(&_group); const MPI_Comm *comm=group->getComm(); int grpSize=_group.size(); - _target_ids_to_send_st.clear(); - _target_ids_to_send_st.resize(grpSize); + _source_ids_to_send_st.clear(); + _source_ids_to_send_st.resize(grpSize); INTERP_KERNEL::AutoPtr nbsend=new int[grpSize]; std::fill(nbsend,nbsend+grpSize,0); - for(std::size_t i=0;i<_the_matrix_st_target_proc_id.size();i++) - nbsend[_the_matrix_st_target_proc_id[i]]=_the_matrix_st_target_ids[i].size(); + for(std::size_t i=0;i<_the_matrix_st_source_proc_id.size();i++) + nbsend[_the_matrix_st_source_proc_id[i]]=_the_matrix_st_source_ids[i].size(); INTERP_KERNEL::AutoPtr nbrecv=new int[grpSize]; commInterface.allToAll(nbsend,1,MPI_INT,nbrecv,1,MPI_INT,*comm); // @@ -381,10 +380,10 @@ void OverlapMapping::prepareIdsToSendST() nbsend3[i]=nbsend3[i-1]+nbsend2[i-1]; int sendSz=nbsend3[grpSize-1]+nbsend2[grpSize-1]; INTERP_KERNEL::AutoPtr bigDataSend=new int[sendSz]; - for(std::size_t i=0;i<_the_matrix_st_target_proc_id.size();i++) + for(std::size_t i=0;i<_the_matrix_st_source_proc_id.size();i++) { - int offset=nbsend3[_the_matrix_st_target_proc_id[i]]; - std::copy(_the_matrix_st_target_ids[i].begin(),_the_matrix_st_target_ids[i].end(),((int *)nbsend3)+offset); + int offset=nbsend3[_the_matrix_st_source_proc_id[i]]; + std::copy(_the_matrix_st_source_ids[i].begin(),_the_matrix_st_source_ids[i].end(),((int *)nbsend3)+offset); } INTERP_KERNEL::AutoPtr nbrecv2=new int[grpSize]; INTERP_KERNEL::AutoPtr nbrecv3=new int[grpSize]; @@ -402,11 +401,20 @@ void OverlapMapping::prepareIdsToSendST() { if(nbrecv2[i]>0) { - _target_ids_to_send_st[i].insert(_target_ids_to_send_st[i].end(),((int *)bigDataRecv)+nbrecv3[i],((int *)bigDataRecv)+nbrecv3[i]+nbrecv2[i]); + _source_ids_to_send_st[i].insert(_source_ids_to_send_st[i].end(),((int *)bigDataRecv)+nbrecv3[i],((int *)bigDataRecv)+nbrecv3[i]+nbrecv2[i]); } } } +/*! + * This method performs a transpose multiply of 'fieldInput' and put the result into 'fieldOutput'. + * 'fieldInput' is expected to be the sourcefield and 'fieldOutput' the targetfield. + */ +void OverlapMapping::multiply(const MEDCouplingFieldDouble *fieldInput, MEDCouplingFieldDouble *fieldOutput) +{ + +} + /*! * This method performs a transpose multiply of 'fieldInput' and put the result into 'fieldOutput'. * 'fieldInput' is expected to be the targetfield and 'fieldOutput' the sourcefield. @@ -446,6 +454,7 @@ void OverlapMapping::transposeMultiply(const MEDCouplingFieldDouble *fieldInput, int szToFetch=nbsend2[grpSize-1]+nbrecv[grpSize-1]; INTERP_KERNEL::AutoPtr nbrecv2=new double[szToFetch]; #endif +#if 0 // int nbOfCompo=fieldInput->getNumberOfComponents();//to improve same number of components to test CommInterface commInterface=_group.getCommInterface(); @@ -466,8 +475,8 @@ void OverlapMapping::transposeMultiply(const MEDCouplingFieldDouble *fieldInput, INTERP_KERNEL::AutoPtr nbrecv=new int[grpSize]; INTERP_KERNEL::AutoPtr nbrecv3=new int[grpSize]; std::fill(nbrecv,nbrecv+grpSize,0); - for(std::size_t i=0;i<_the_matrix_st_target_proc_id.size();i++) - nbrecv[_the_matrix_st_target_proc_id[i]]=_the_matrix_st_target_ids[i].size()*nbOfCompo; + for(std::size_t i=0;i<_the_matrix_st_source_proc_id.size();i++) + nbrecv[_the_matrix_st_source_proc_id[i]]=_the_matrix_st_target_ids[i].size()*nbOfCompo; nbrecv3[0]=0; for(int i=1;igetArray()->getPointer(); - int targetProcId=_the_matrix_st_target_proc_id[i]; + int sourceProcId=_the_matrix_st_source_proc_id[i]; const std::vector >& m=_the_matrix_st[i]; const std::vector >& deno=_the_deno_st[i]; - const double *vecOnTargetProcId=((const double *)nbrecv2)+nbrecv3[targetProcId]; + const double *vecOnTargetProcId=((const double *)nbrecv2)+nbrecv3[sourceProcId]; std::size_t nbOfIds=m.size(); for(std::size_t j=0;j >& matrixST, const int *srcIds, const int *trgIds, int trgIdsLgth, int srcProcId, int trgProcId); - void prepare(const std::vector< std::vector >& procsInInteraction, int nbOfSrcElems); + void prepare(const std::vector< std::vector >& procsInInteraction, int nbOfTrgElems); void computeDenoGlobConstraint(); // + void multiply(const MEDCouplingFieldDouble *fieldInput, MEDCouplingFieldDouble *fieldOutput); void transposeMultiply(const MEDCouplingFieldDouble *fieldInput, MEDCouplingFieldDouble *fieldOutput); private: void serializeMatrixStep0ST(const int *nbOfElemsSrc, int *&bigArr, int *count, int *offsets, @@ -43,9 +44,9 @@ namespace ParaMEDMEM int serializeMatrixStep1ST(const int *nbOfElemsSrc, const int *recvStep0, const int *countStep0, const int *offsStep0, int *&bigArrI, double *&bigArrD, int *count, int *offsets, int *countForRecv, int *offsForRecv) const; - void unserializationST(int nbOfSrcElems, const int *nbOfElemsSrcPerProc, const int *bigArrRecv, const int *bigArrRecvCounts, const int *bigArrRecvOffs, + void unserializationST(int nbOfTrgElems, const int *nbOfElemsSrcPerProc, const int *bigArrRecv, const int *bigArrRecvCounts, const int *bigArrRecvOffs, const int *bigArrRecv2, const double *bigArrDRecv2, const int *bigArrRecv2Count, const int *bigArrRecv2Offs); - void finishToFillFinalMatrixST(int nbOfSrcElems); + void finishToFillFinalMatrixST(int nbOfTrgElems); void prepareIdsToSendST(); private: const ProcessorGroup &_group; @@ -57,11 +58,11 @@ namespace ParaMEDMEM std::vector< int > _target_proc_id_st; //! the matrix for matrix-vector product. The first dimension the set of target procs that interacts with local source mesh. The second dimension correspond to nb of local source ids. std::vector< std::vector< std::map > > _the_matrix_st; - std::vector< int > _the_matrix_st_target_proc_id; - std::vector< std::vector > _the_matrix_st_target_ids; + std::vector< int > _the_matrix_st_source_proc_id; + std::vector< std::vector > _the_matrix_st_source_ids; std::vector< std::vector< std::map > > _the_deno_st; //! this attribute is of size _group.size(); for each procId in _group _target_ids_to_send_st[procId] contains tupleId to send abroad - std::vector< std::vector > _target_ids_to_send_st; + std::vector< std::vector > _source_ids_to_send_st; }; } diff --git a/src/ParaMEDMEMTest/ParaMEDMEMTest_OverlapDEC.cxx b/src/ParaMEDMEMTest/ParaMEDMEMTest_OverlapDEC.cxx index ba9360979..e4391a4da 100644 --- a/src/ParaMEDMEMTest/ParaMEDMEMTest_OverlapDEC.cxx +++ b/src/ParaMEDMEMTest/ParaMEDMEMTest_OverlapDEC.cxx @@ -81,7 +81,7 @@ void ParaMEDMEMTest::testOverlapDEC1() ParaMEDMEM::ComponentTopology comptopo; parameshS=new ParaMEDMEM::ParaMESH(meshS,*dec.getGrp(),"source mesh"); parafieldS=new ParaMEDMEM::ParaFIELD(ParaMEDMEM::ON_CELLS,ParaMEDMEM::NO_TIME,parameshS,comptopo); - parafieldS->getField()->setNature(ParaMEDMEM::IntegralGlobConstraint);//ConservativeVolumic + parafieldS->getField()->setNature(ParaMEDMEM::ConservativeVolumic);//ConservativeVolumic IntegralGlobConstraint double *valsS=parafieldS->getField()->getArray()->getPointer(); valsS[0]=7.; valsS[1]=8.; // @@ -186,7 +186,7 @@ void ParaMEDMEMTest::testOverlapDEC1() dec.attachSourceLocalField(parafieldS); dec.attachTargetLocalField(parafieldT); dec.synchronize(); - dec.sendRecvData(false); + dec.sendRecvData(true); // /*if(rank==0) {