-// Copyright (C) 2007-2008 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2024 CEA, EDF
//
-// 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 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, or (at your option) any later version.
//
-// 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.
+// 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
+// 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
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
//
+
#include "CommInterface.hxx"
#include "ProcessorGroup.hxx"
#include "MPIProcessorGroup.hxx"
using namespace std;
-namespace ParaMEDMEM
+namespace MEDCoupling
{
MxN_Mapping::MxN_Mapping(const ProcessorGroup& source_group, const ProcessorGroup& target_group,const DECOptions& dec_options)
- : _union_group(source_group.fuse(target_group)),
- DECOptions(dec_options)
+ : DECOptions(dec_options),
+ _union_group(source_group.fuse(target_group)),
+ _nb_comps(0), _sending_ids(), _recv_ids()
{
_access_DEC = new MPIAccessDEC(source_group,target_group,getAsynchronous());
_access_DEC->setTimeInterpolator(getTimeInterpolationMethod());
\param distant_proc proc rank of the distant processor (in terms of the union group)
\param distant_element id of the element on the distant processor
*/
- void MxN_Mapping::addElementFromSource(int distant_proc, int distant_element)
+ void MxN_Mapping::addElementFromSource(int distant_proc, mcIdType distant_element)
{
_sending_ids.push_back(make_pair(distant_proc,distant_element));
for (int i=distant_proc; i<_union_group->size(); i++)
_send_proc_offsets[i+1]++;
}
+ void MxN_Mapping::initialize()
+ {
+ _sending_ids.clear();
+ std::fill(_send_proc_offsets.begin(),_send_proc_offsets.end(),0);
+ }
+
void MxN_Mapping::prepareSendRecv()
{
CommInterface comm_interface=_union_group->getCommInterface();
delete[] nbrecv;
_recv_ids.resize(_recv_proc_offsets[_union_group->size()]);
- int* isendbuf=0;
- int* irecvbuf=0;
+ mcIdType* isendbuf=0;
+ mcIdType* irecvbuf=0;
if (_sending_ids.size()>0)
- isendbuf = new int[_sending_ids.size()];
+ isendbuf = new mcIdType[_sending_ids.size()];
if (_recv_ids.size()>0)
- irecvbuf = new int[_recv_ids.size()];
+ irecvbuf = new mcIdType[_recv_ids.size()];
int* sendcounts = new int[_union_group->size()];
int* senddispls=new int[_union_group->size()];
int* recvcounts=new int[_union_group->size()];
recvdispls[i]=_recv_proc_offsets[i];
}
vector<int> offsets = _send_proc_offsets;
- for (int i=0; i<_sending_ids.size();i++)
+ for (std::size_t i=0; i<_sending_ids.size();i++)
{
int iproc = _sending_ids[i].first;
isendbuf[offsets[iproc]]=_sending_ids[i].second;
offsets[iproc]++;
}
- comm_interface.allToAllV(isendbuf, sendcounts, senddispls, MPI_INT,
- irecvbuf, recvcounts, recvdispls, MPI_INT,
+ comm_interface.allToAllV(isendbuf, sendcounts, senddispls, MPI_ID_TYPE,
+ irecvbuf, recvcounts, recvdispls, MPI_ID_TYPE,
*comm);
for (int i=0; i< _recv_proc_offsets[_union_group->size()]; i++)
delete[] recvdispls;
}
+ MCAuto<DataArrayIdType> MxN_Mapping::retrieveNonFetchedIdsTarget(mcIdType nbTuples) const
+ {
+ MCAuto<DataArrayIdType> ret(DataArrayIdType::New()); ret->alloc(0,1);
+ std::vector<bool> hitMachine(nbTuples,false);
+ for (int i=0; i< _recv_proc_offsets[_union_group->size()]; i++)
+ {
+ mcIdType recvId(_recv_ids[i]);
+ hitMachine[recvId] = true;
+ }
+ for( mcIdType ituple = 0 ; ituple < nbTuples ; ++ituple )
+ {
+ if( ! hitMachine[ituple] )
+ ret->pushBackSilent( ituple );
+ }
+ return ret;
+ }
+
/*! Exchanging field data between two groups of processes
*
* \param field MEDCoupling field containing the values to be sent
CommInterface comm_interface=_union_group->getCommInterface();
const MPIProcessorGroup* group = static_cast<const MPIProcessorGroup*>(_union_group);
- int nbcomp=field.getArray()->getNumberOfComponents();
+ int nbcomp=(int)field.getArray()->getNumberOfComponents();
double* sendbuf=0;
double* recvbuf=0;
if (_sending_ids.size() >0)
sendbuf = new double[_sending_ids.size()*nbcomp];
if (_recv_ids.size()>0)
recvbuf = new double[_recv_ids.size()*nbcomp];
-
int* sendcounts = new int[_union_group->size()];
int* senddispls=new int[_union_group->size()];
int* recvcounts=new int[_union_group->size()];
//building the buffer of the elements to be sent
vector<int> offsets = _send_proc_offsets;
- for (int i=0; i<_sending_ids.size();i++)
+ for (int i=0; i<(int)_sending_ids.size();i++)
{
int iproc = _sending_ids[i].first;
for (int icomp=0; icomp<nbcomp; icomp++)
break;
case PointToPoint:
_access_DEC->allToAllv(sendbuf, sendcounts, senddispls, MPI_DOUBLE,
- recvbuf, recvcounts, recvdispls, MPI_DOUBLE);
+ recvbuf, recvcounts, recvdispls, MPI_DOUBLE);
break;
}
//setting the received values in the field
DataArrayDouble *fieldArr=field.getArray();
- double* recvptr=recvbuf;
+ double* recvptr=recvbuf;
for (int i=0; i< _recv_proc_offsets[_union_group->size()]; i++)
{
+ mcIdType recvId(_recv_ids[i]);
for (int icomp=0; icomp<nbcomp; icomp++)
{
- double temp = fieldArr->getIJ(_recv_ids[i],icomp);
- fieldArr->setIJ(_recv_ids[i],icomp,temp+*recvptr);
+ double temp = fieldArr->getIJ(recvId,icomp);
+ fieldArr->setIJ(recvId,icomp,temp+*recvptr);
recvptr++;
}
- }
+ }
if (sendbuf!=0 && getAllToAllMethod()== Native)
delete[] sendbuf;
if (recvbuf !=0)
CommInterface comm_interface=_union_group->getCommInterface();
const MPIProcessorGroup* group = static_cast<const MPIProcessorGroup*>(_union_group);
- int nbcomp=field.getArray()->getNumberOfComponents();
+ int nbcomp=(int)field.getArray()->getNumberOfComponents();
double* sendbuf=0;
double* recvbuf=0;
if (_recv_ids.size() >0)
delete[] recvdispls;
}
-
ostream & operator<< (ostream & f ,const AllToAllMethod & alltoallmethod )
{
switch (alltoallmethod)