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
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<int,double> >.
+ \f$ M_k \f$ is built using sizeof(Proc group) \c std::vector< \c std::map<int,double> \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.
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()
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();
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<map<int,double> > surfaces;
int colSize=0;
//computation of the intersection volumes between source and target elements
const MEDCouplingUMesh *trgC=dynamic_cast<const MEDCouplingUMesh *>(trg);
const MEDCouplingUMesh *srcC=dynamic_cast<const MEDCouplingUMesh *>(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");
{
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();
}
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();
}
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();
}
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();
}
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();
}
{
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<int,double> >& res,
const DataArrayInt *srcIds, int srcProc,
{
//computing matrix with real ids for target
int sz=res.size();
- std::vector< std::map<int,double> > 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<int,double> > res1(sz);
INTERP_KERNEL::AutoPtr<int> tmp2=new int[nbTrgIds];
+ INTERP_KERNEL::AutoPtr<int> tmp3=new int[nbSrcIds];
if(trgIds)
trgIds2=trgIds->getConstPointer();
else
for(int i=0;i<nbTrgIds;i++)
tmp2[i]=i;
}
+ if(srcIds)
+ srcIds2=srcIds->getConstPointer();
+ else
+ {
+ srcIds2=tmp3;
+ for(int i=0;i<nbSrcIds;i++)
+ tmp3[i]=i;
+ }
for(int i=0;i<sz;i++)
{
std::map<int,double>& m=res1[i];
const std::map<int,double>& ref=res[i];
for(std::map<int,double>::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<int> tmp=new int[sz];
- for(int i=0;i<sz;i++)
- tmp[i]=i;
- _mapping.addContributionST(res1,tmp,trgIds2,nbTrgIds,srcProc,trgProc);
- }
+ _mapping.addContributionST(res1,srcIds2,trgIds2,nbTrgIds,srcProc,trgProc);
}
/*!
void OverlapInterpolationMatrix::prepare(const std::vector< std::vector<int> >& 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());
void computeDeno();
+ void multiply();
+
void transposeMultiply();
virtual ~OverlapInterpolationMatrix();
}
/*!
- * 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<int,double> >& 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);
* 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<int> >& procsInInteraction, int nbOfSrcElems)
+void OverlapMapping::prepare(const std::vector< std::vector<int> >& procsInInteraction, int nbOfTrgElems)
{
CommInterface commInterface=_group.getCommInterface();
const MPIProcessorGroup *group=static_cast<const MPIProcessorGroup*>(&_group);
INTERP_KERNEL::AutoPtr<int> 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<int *>(nbsend2,nbsend2+grpSize,0);
INTERP_KERNEL::AutoPtr<int> nbrecv3=new int[grpSize];
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();
}
* 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<grpSize;i++)
if(nbOfElemsSrcPerProc[i]!=0)
- _the_matrix_st_target_proc_id.push_back(i);
- int nbOfPseudoProcs=_the_matrix_st_target_proc_id.size();//_the_matrix_st_target_proc_id.size() contains number of matrix fetched remotely whose sourceProcId==myProcId
- _the_matrix_st_target_ids.resize(nbOfPseudoProcs);
+ _the_matrix_st_source_proc_id.push_back(i);
+ int nbOfPseudoProcs=_the_matrix_st_source_proc_id.size();//_the_matrix_st_target_proc_id.size() contains number of matrix fetched remotely whose sourceProcId==myProcId
+ _the_matrix_st_source_ids.resize(nbOfPseudoProcs);
_the_matrix_st.resize(nbOfPseudoProcs);
for(int i=0;i<nbOfPseudoProcs;i++)
- _the_matrix_st[i].resize(nbOfSrcElems);
+ _the_matrix_st[i].resize(nbOfTrgElems);
//
int j=0;
for(int i=0;i<grpSize;i++)
if(nbOfElemsSrcPerProc[i]!=0)
{
- std::set<int> targetIdsZip;// this zip is to reduce amount of data to send/rexcv on transposeMultiply target ids transfert
+ std::set<int> sourceIdsZip;// this zip is to reduce amount of data to send/rexcv on transposeMultiply target ids transfert
for(int k=0;k<nbOfElemsSrcPerProc[i];k++)
{
int offs=bigArrRecv[bigArrRecvOffs[i]+k];
int lgthOfMap=bigArrRecv[bigArrRecvOffs[i]+k+1]-offs;
for(int l=0;l<lgthOfMap;l++)
- targetIdsZip.insert(bigArrRecv2[bigArrRecv2Offs[i]+offs+l]);
+ sourceIdsZip.insert(bigArrRecv2[bigArrRecv2Offs[i]+offs+l]);
}
- _the_matrix_st_target_ids[j].insert(_the_matrix_st_target_ids[j].end(),targetIdsZip.begin(),targetIdsZip.end());
- std::map<int,int> old2newTrgIds;
+ _the_matrix_st_source_ids[j].insert(_the_matrix_st_source_ids[j].end(),sourceIdsZip.begin(),sourceIdsZip.end());
+ std::map<int,int> old2newSrcIds;
int newNbTrg=0;
- for(std::set<int>::const_iterator it=targetIdsZip.begin();it!=targetIdsZip.end();it++,newNbTrg++)
- old2newTrgIds[*it]=newNbTrg;
+ for(std::set<int>::const_iterator it=sourceIdsZip.begin();it!=sourceIdsZip.end();it++,newNbTrg++)
+ old2newSrcIds[*it]=newNbTrg;
for(int k=0;k<nbOfElemsSrcPerProc[i];k++)
{
int srcId=bigArrRecv[bigArrRecvOffs[i]+nbOfElemsSrcPerProc[i]+1+k];
int offs=bigArrRecv[bigArrRecvOffs[i]+k];
int lgthOfMap=bigArrRecv[bigArrRecvOffs[i]+k+1]-offs;
for(int l=0;l<lgthOfMap;l++)
- _the_matrix_st[j][srcId][old2newTrgIds[bigArrRecv2[bigArrRecv2Offs[i]+offs+l]]]=bigArrDRecv2[bigArrRecv2Offs[i]+offs+l];
+ _the_matrix_st[j][old2newSrcIds[bigArrRecv2[bigArrRecv2Offs[i]+offs+l]]][srcId]=bigArrDRecv2[bigArrRecv2Offs[i]+offs+l];
}
j++;
}
* and 'this->_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();
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<newNbOfEntry;i++)
- _the_matrix_st[i].resize(nbOfSrcElems);
+ _the_matrix_st[i].resize(nbOfTrgElems);
int j=oldNbOfEntry;
for(int i=0;i<sz;i++)
if(_source_proc_id_st[i]==myProcId)
{
const std::map<int,double>& m2=mat[k];
for(std::map<int,double>::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++;
}
}
const MPIProcessorGroup *group=static_cast<const MPIProcessorGroup*>(&_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<int> nbsend=new int[grpSize];
std::fill<int *>(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<int> nbrecv=new int[grpSize];
commInterface.allToAll(nbsend,1,MPI_INT,nbrecv,1,MPI_INT,*comm);
//
nbsend3[i]=nbsend3[i-1]+nbsend2[i-1];
int sendSz=nbsend3[grpSize-1]+nbsend2[grpSize-1];
INTERP_KERNEL::AutoPtr<int> 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<int> nbrecv2=new int[grpSize];
INTERP_KERNEL::AutoPtr<int> nbrecv3=new int[grpSize];
{
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.
int szToFetch=nbsend2[grpSize-1]+nbrecv[grpSize-1];
INTERP_KERNEL::AutoPtr<double> nbrecv2=new double[szToFetch];
#endif
+#if 0
//
int nbOfCompo=fieldInput->getNumberOfComponents();//to improve same number of components to test
CommInterface commInterface=_group.getCommInterface();
INTERP_KERNEL::AutoPtr<int> nbrecv=new int[grpSize];
INTERP_KERNEL::AutoPtr<int> nbrecv3=new int[grpSize];
std::fill<int *>(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;i<grpSize;i++)
nbrecv3[i]=nbrecv3[i-1]+nbrecv[i-1];
for(std::size_t i=0;i<_the_matrix_st.size();i++)
{
double *res=fieldOutput->getArray()->getPointer();
- int targetProcId=_the_matrix_st_target_proc_id[i];
+ int sourceProcId=_the_matrix_st_source_proc_id[i];
const std::vector<std::map<int,double> >& m=_the_matrix_st[i];
const std::vector<std::map<int,double> >& 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<nbOfIds;j++,res+=nbOfCompo)
{
}
}
}
+#endif
}
public:
OverlapMapping(const ProcessorGroup& group);
void addContributionST(const std::vector< std::map<int,double> >& matrixST, const int *srcIds, const int *trgIds, int trgIdsLgth, int srcProcId, int trgProcId);
- void prepare(const std::vector< std::vector<int> >& procsInInteraction, int nbOfSrcElems);
+ void prepare(const std::vector< std::vector<int> >& 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,
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;
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<int,double> > > _the_matrix_st;
- std::vector< int > _the_matrix_st_target_proc_id;
- std::vector< std::vector<int> > _the_matrix_st_target_ids;
+ std::vector< int > _the_matrix_st_source_proc_id;
+ std::vector< std::vector<int> > _the_matrix_st_source_ids;
std::vector< std::vector< std::map<int,double> > > _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<int> > _target_ids_to_send_st;
+ std::vector< std::vector<int> > _source_ids_to_send_st;
};
}
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.;
//
dec.attachSourceLocalField(parafieldS);
dec.attachTargetLocalField(parafieldT);
dec.synchronize();
- dec.sendRecvData(false);
+ dec.sendRecvData(true);
//
/*if(rank==0)
{