*/
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<map<int,double> > 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<map<int,double> > 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()="<<surfaces.size()<<" source_size="<<source_size<<endl;
- throw MEDEXCEPTION("uncoherent number of rows in interpolation matrix");
- }
-
- //computing the vectors containing the source and target element volumes
- MEDMEM::SUPPORT target_support(&distant_support,"all cells", MED_EN::MED_CELL);
- MEDMEM::FIELD<double>* target_triangle_surf = getSupportVolumes(target_support);
- MEDMEM::SUPPORT source_support (const_cast<MEDMEM::MESH*>(&_source_support),"all cells", MED_EN::MED_CELL);
- MEDMEM::FIELD<double>* source_triangle_surf = getSupportVolumes(source_support);
-
- //storing the source volumes
- _source_volume.resize(source_size);
- for (int i=0; i<source_size;i++)
- _source_volume[i]=source_triangle_surf->getValueIJ(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()="<<surfaces.size()<<" source_size="<<source_size<<endl;
+ throw MEDEXCEPTION("uncoherent number of rows in interpolation matrix");
+ }
+
+ //computing the vectors containing the source and target element volumes
+ MEDMEM::SUPPORT target_support(&distant_support,"all cells", MED_EN::MED_CELL);
+ MEDMEM::FIELD<double>* target_triangle_surf = getSupportVolumes(target_support);
+ MEDMEM::SUPPORT source_support (const_cast<MEDMEM::MESH*>(&_source_support),"all cells", MED_EN::MED_CELL);
+ MEDMEM::FIELD<double>* source_triangle_surf = getSupportVolumes(source_support);
+
+ //storing the source volumes
+ _source_volume.resize(source_size);
+ for (int i=0; i<source_size;i++)
+ _source_volume[i]=source_triangle_surf->getValueIJ(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<int,double>::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<int,double>::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<pair<int,int> >::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<pair<int,int> >::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
{
vector<double> 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; irow<nbrows; irow++)
- for (int icomp=0; icomp< nbcomp; icomp++)
- {
- double coeff_row = field.getValueIJ(irow+1,icomp+1);
- for (int icol=_row_offsets[irow]; icol< _row_offsets[irow+1];icol++)
- {
- int colid= _coeffs[irow][icol-_row_offsets[irow]].first;
- double value = _coeffs[irow][icol-_row_offsets[irow]].second;
- target_value[(colid-1)*nbcomp+icomp]+=value*coeff_row;
- }
- }
-
- // performing VT^(-1).(W.S)
- // where VT^(-1) is the inverse of the diagonal matrix containing
- // the volumes of target cells
-
- for (int i=0; i<_col_offsets.size();i++)
- for (int icomp=0; icomp<nbcomp; icomp++)
- target_value[i*nbcomp+icomp] /= _target_volume[i];
- }
-
- if (_target_group.containsMyRank())
- {
- int nbelems=field.getSupport()->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS);
- int nbcomp = field.getNumberOfComponents();
- double* value = const_cast<double*> (field.getValue());
- for (int i=0; i<nbelems*nbcomp;i++)
- value[i]=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; irow<nbrows; irow++)
+ for (int icomp=0; icomp< nbcomp; icomp++)
+ {
+ double coeff_row = field.getValueIJ(irow+1,icomp+1);
+ for (int icol=_row_offsets[irow]; icol< _row_offsets[irow+1];icol++)
+ {
+ int colid= _coeffs[irow][icol-_row_offsets[irow]].first;
+ double value = _coeffs[irow][icol-_row_offsets[irow]].second;
+ target_value[(colid-1)*nbcomp+icomp]+=value*coeff_row;
+ }
+ }
+
+ // performing VT^(-1).(W.S)
+ // where VT^(-1) is the inverse of the diagonal matrix containing
+ // the volumes of target cells
+
+ for (int i=0; i<_col_offsets.size();i++)
+ for (int icomp=0; icomp<nbcomp; icomp++)
+ target_value[i*nbcomp+icomp] /= _target_volume[i];
}
- //on source side : sending T=VT^(-1).(W.S)
- //on target side :: receiving T and storing it in field
+
+ if (_target_group.containsMyRank())
+ {
+ int nbelems=field.getSupport()->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS);
+ int nbcomp = field.getNumberOfComponents();
+ double* value = const_cast<double*> (field.getValue());
+ for (int i=0; i<nbelems*nbcomp;i++)
+ value[i]=0.0;
+ }
+ //on source side : sending T=VT^(-1).(W.S)
+ //on target side :: receiving T and storing it in field
_mapping.sendRecv(&target_value[0],field);
-
+
}
/*!
\brief performs s=WTt, where t is the target field, s is the source field, WT is the transpose matrix from W
The call to this method must be called both on the working side
and on the idle side. On the working side, the target vector T is received and the
- vector S=VS^(-1).(WT.T) is computed to update the field.
+vector S=VS^(-1).(WT.T) is computed to update the field.
On the idle side, no computation is done, but the field is sent.
\param field source field on processors involved on the source side, target field on processors on the target side
- */
+*/
void InterpolationMatrix::transposeMultiply(MEDMEM::FIELD<double>& field) const
{
vector<double> 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<double> target_value(nbrows,0.0);
-
- //performing WT.T
- //WT is W transpose
- //T is the target vector
- for (int irow=0; irow<nbrows; irow++)
- for (int icol=_row_offsets[irow]; icol< _row_offsets[irow+1];icol++)
- for (int icomp=0; icomp<nbcomp; icomp++)
- {
- int colid= _coeffs[irow][icol-_row_offsets[irow]].first;
- double value = _coeffs[irow][icol-_row_offsets[irow]].second;
-
- double coeff_row = source_value[colid-1];
- target_value[irow*nbcomp+icomp]+=value*coeff_row;
- }
-
- //performing VS^(-1).(WT.T)
- //VS^(-1) is the inverse of the diagonal matrix storing
- //volumes of the source cells
- for (int i=0; i<nbrows; i++)
- for (int icomp=0; icomp<nbcomp; icomp++)
- target_value[i*nbcomp+icomp]/=_source_volume[i];
-
- //storing S= VS^(-1).(WT.T)
- for (int irow=0; irow<nbrows; irow++)
- for (int icomp=0; icomp<nbcomp; icomp++)
- field.setValueIJ(irow+1,icomp+1,target_value[irow*nbcomp+icomp]);
- }
+ //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<double> target_value(nbrows,0.0);
+
+ //performing WT.T
+ //WT is W transpose
+ //T is the target vector
+ for (int irow=0; irow<nbrows; irow++)
+ for (int icol=_row_offsets[irow]; icol< _row_offsets[irow+1];icol++)
+ for (int icomp=0; icomp<nbcomp; icomp++)
+ {
+ int colid= _coeffs[irow][icol-_row_offsets[irow]].first;
+ double value = _coeffs[irow][icol-_row_offsets[irow]].second;
+
+ double coeff_row = source_value[colid-1];
+ target_value[irow*nbcomp+icomp]+=value*coeff_row;
+ }
+
+ //performing VS^(-1).(WT.T)
+ //VS^(-1) is the inverse of the diagonal matrix storing
+ //volumes of the source cells
+ for (int i=0; i<nbrows; i++)
+ for (int icomp=0; icomp<nbcomp; icomp++)
+ target_value[i*nbcomp+icomp]/=_source_volume[i];
+
+ //storing S= VS^(-1).(WT.T)
+ for (int irow=0; irow<nbrows; irow++)
+ for (int icomp=0; icomp<nbcomp; icomp++)
+ field.setValueIJ(irow+1,icomp+1,target_value[irow*nbcomp+icomp]);
+ }
}
-# The lazy side is updated so that it knows the structure of the data that will be sent by
the working side during a \a sendData() call.
- */
+*/
void IntersectionDEC::synchronize()
{
- const ParaMEDMEM::ParaMESH* para_mesh = _local_field->getSupport()->getMesh();
- cout <<"size of Interpolation Matrix"<<sizeof(InterpolationMatrix)<<endl;
- _interpolation_matrix = new InterpolationMatrix (*para_mesh, *_source_group,*_target_group,"P0");
+ const ParaMEDMEM::ParaMESH* para_mesh = _local_field->getSupport()->getMesh();
+ cout <<"size of Interpolation Matrix"<<sizeof(InterpolationMatrix)<<endl;
+ _interpolation_matrix = new InterpolationMatrix (*para_mesh, *_source_group,*_target_group,"P0");
_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 "<<idistant_proc_in_union<<" to proc "<<_union_group->myRank()<<endl;
- _interpolation_matrix->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 "<<idistant_proc_in_union<<" to proc "<<_union_group->myRank()<<endl;
+ _interpolation_matrix->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<<endl;
- if (distant_mesh!=0)
- {
- delete distant_mesh;
- delete[] distant_ids;
- distant_mesh=0;
- distant_ids=0;
- }
- }
- }
+ // 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<<endl;
+ if (distant_mesh!=0)
+ {
+ delete distant_mesh;
+ delete[] distant_ids;
+ distant_mesh=0;
+ distant_ids=0;
+ }
+ }
+ }
_interpolation_matrix->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()
{
{
CommInterface comm_interface=_union_group->getCommInterface();
const MPIProcessorGroup* group = static_cast<const MPIProcessorGroup*>(_union_group);
-
+
int nbcomp=field.getNumberOfComponents();
double* sendbuf=0;
double* recvbuf=0;
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]);
}
//building the buffer of the elements to be sent
vector<int> 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; icomp<nbcomp; icomp++)
- sendbuf[i*nbcomp+icomp]=field.getValueIJ(_recv_ids[i],icomp+1);
- // offsets[iproc]++;
- }
+
+ 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; icomp<nbcomp; icomp++)
+ sendbuf[i*nbcomp+icomp]=field.getValueIJ(_recv_ids[i],icomp+1);
+ // offsets[iproc]++;
+ }
// for (int i=0; i<_recv_ids.size();i++)
-// {
-// // int iproc = _recv_ids[i].first;
-// int iproc=_recv_ids[i];
-// for (int icomp=0; icomp<nbcomp; icomp++)
-// // sendbuf[offsets[iproc]*nbcomp+icomp]=recvfield[i+1*nbcomp+icomp];
-// sendbuf[offsets[iproc]*nbcomp+icomp]=field.getValueIJ(i+1,icomp+1);
-// offsets[iproc]++;
-// }
-
+ // {
+ // // int iproc = _recv_ids[i].first;
+ // int iproc=_recv_ids[i];
+ // for (int icomp=0; icomp<nbcomp; icomp++)
+ // // sendbuf[offsets[iproc]*nbcomp+icomp]=recvfield[i+1*nbcomp+icomp];
+ // sendbuf[offsets[iproc]*nbcomp+icomp]=field.getValueIJ(i+1,icomp+1);
+ // offsets[iproc]++;
+ // }
+
//communication phase
- switch (_allToAllMethod) {
- case Native:
- {
+ switch (_allToAllMethod) {
+ case Native:
+ {
const MPI_Comm* comm = group->getComm();
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; j<field.getNumberOfComponents(); j++)
- // field.setValueIJ(i+1,j+1,0.0);
-
+ // for (int i=0; i< field.getSupport()->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS);i++)
+ // for (int j=0; j<field.getNumberOfComponents(); j++)
+ // field.setValueIJ(i+1,j+1,0.0);
+
//setting the received values in the field
double* recvptr=recvbuf;
for (int i=0; i< _send_proc_offsets[_union_group->size()]; i++)
- {
- for (int icomp=0; icomp<nbcomp; icomp++)
- {
- // recvfield[(_sending_ids[i].second-1)*nbcomp+icomp]+=*recvptr;
- recvfield[i*nbcomp+icomp]=*recvptr;
- recvptr++;
- }
- }
-
-
-// if (sendbuf!=0) delete[] sendbuf;
+ {
+ for (int icomp=0; icomp<nbcomp; icomp++)
+ {
+ // recvfield[(_sending_ids[i].second-1)*nbcomp+icomp]+=*recvptr;
+ recvfield[i*nbcomp+icomp]=*recvptr;
+ recvptr++;
+ }
+ }
+
+
+ // if (sendbuf!=0) delete[] sendbuf;
if (sendbuf!=0 && _allToAllMethod == Native) delete[] sendbuf;
if (recvbuf!=0) delete[] recvbuf;
delete[] sendcounts;
delete[] recvcounts;
delete[] senddispls;
delete[] recvdispls;
-
+
}