Commit e2756950 authored by kraus's avatar kraus
Browse files

throw exception instead of calling PInsist

parent f2f86efb
......@@ -30,11 +30,14 @@
#include "Region/RegionLayout.h"
#include "Message/Message.h"
#include "FieldLayout/FieldLayoutUser.h"
#include "Utility/IpplException.h"
#include <cstddef>
#include <vector>
#include <iostream>
#include <map>
#include <functional>
#include "BoxParticleCachingPolicy.h"
......@@ -1178,6 +1181,7 @@ protected:
int minParticlesPerNode = PData.getMinimumNumberOfParticlesPerCore();
int particlesLeft = LocalNum;
bool responsibleNodeNotFound = false;
for (unsigned int ip=0; ip<LocalNum; ++ip)
{
for (unsigned int j = 0; j < Dim; j++)
......@@ -1200,14 +1204,27 @@ protected:
typename RegionLayout<T,Dim,Mesh>::touch_range_dv touchingVN = RLayout.touch_range_rdv(pLoc);
//external location
PInsist(touchingVN.first != touchingVN.second, "could not find node responsible for particle;\nmesh does not seem correctly adapted to particle distribution");
if (touchingVN.first != touchingVN.second) {
responsibleNodeNotFound = true;
break;
}
destination = (*(touchingVN.first)).second->getNode();
msgsend[destination] = 1;
p2n.insert(std::pair<unsigned, unsigned>(destination, ip));
sent++;
particlesLeft--;
particlesLeft--;
}
new_reduce(&responsibleNodeNotFound,
&responsibleNodeNotFound,
1,
std::logical_or<bool>());
if (responsibleNodeNotFound) {
throw IpplException("ParticleSpatialLayout::new_swap_particles",
"could not find node responsible for particle");
}
//reduce message count so every node knows how many messages to receive
......@@ -1284,7 +1301,7 @@ protected:
template < class PB >
size_t new_swap_particles(size_t LocalNum, PB& PData,
const ParticleAttrib<char>& canSwap)
const ParticleAttrib<char>& canSwap)
{
Ippl::Comm->barrier();
static int sent = 0;
......@@ -1305,7 +1322,8 @@ protected:
std::multimap<unsigned, unsigned> p2n; //<node ID, particle ID>
int minParticlesPerNode = PData.getMinimumNumberOfParticlesPerCore();
int particlesLeft = LocalNum;
int particlesLeft = LocalNum;
bool responsibleNodeNotFound = false;
for (unsigned int ip=0; ip<LocalNum; ++ip)
{
if (!bool(canSwap[ip]))//skip if it can't be swapped
......@@ -1325,22 +1343,30 @@ protected:
if (found)
continue;
if (particlesLeft <= minParticlesPerNode)
continue; //leave atleast minimum number of particles per core
if (particlesLeft <= minParticlesPerNode)
continue; //leave atleast minimum number of particles per core
typename RegionLayout<T,Dim,Mesh>::touch_range_dv touchingVN = RLayout.touch_range_rdv(pLoc);
//external location
PInsist(touchingVN.first != touchingVN.second, "could not find node responsible for particle;\nmesh does not seem correctly adapted to particle distribution");
if (touchingVN.first != touchingVN.second) {
responsibleNodeNotFound = true;
break;
}
destination = (*(touchingVN.first)).second->getNode();
msgsend[destination] = 1;
p2n.insert(std::pair<unsigned, unsigned>(destination, ip));
sent++;
particlesLeft--;
particlesLeft--;
}
new_reduce(&responsibleNodeNotFound,
&responsibleNodeNotFound,
1,
std::logical_or<bool>());
//reduce message count so every node knows how many messages to receive
MPI_Allreduce(msgsend, msgrecv, N, MPI_INT, MPI_SUM, Ippl::getComm());
......@@ -1419,4 +1445,4 @@ protected:
* $RCSfile: ParticleSpatialLayout.h,v $ $Author: adelmann $
* $Revision: 1.1.1.1 $ $Date: 2003/01/23 07:40:29 $
* IPPL_VERSION_ID: $Id: ParticleSpatialLayout.h,v 1.1.1.1 2003/01/23 07:40:29 adelmann Exp $
***************************************************************************/
***************************************************************************/
\ No newline at end of file
......@@ -2392,12 +2392,20 @@ void PartBunchBase<T, Dim>::resetID() {
template <class T, unsigned Dim>
void PartBunchBase<T, Dim>::update() {
pbase->update();
try {
pbase->update();
} catch (IpplException &ex) {
throw OpalException(ex.where(), ex.what());
}
}
template <class T, unsigned Dim>
void PartBunchBase<T, Dim>::update(const ParticleAttrib<char>& canSwap) {
pbase->update(canSwap);
try {
pbase->update(canSwap);
} catch (IpplException &ex) {
throw OpalException(ex.where(), ex.what());
}
}
template <class T, unsigned Dim>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment