Commit 88d38ccf authored by kraus's avatar kraus
Browse files

In the code for particle matter interaction boundp was called when more

than zero particles are outside the material. When a single particle was
outside the material OPAL aborted with the message 'h<0, can not build a
mesh'. The bounding box around a single particle has no volume and hence
the volume of the mesh would be zero as well. This is fixed if more than
one particle is outside the material. For consistency with the method
computeSpaceChargeFields I chose minBinEmitted_m as number of particles
that have to be outside. Its default value is 10.
parent 9bb22a86
......@@ -822,9 +822,10 @@ void ParallelTTracker::computeParticleMatterInteraction(IndexMap::value_t elemen
//if max particles per node is 2, and only one degrader has particles set
//AllParticlesIn for this degrader to true
int maxPerNode = itsBunch_m->getLocalNum();
reduce(maxPerNode, maxPerNode, OpMaxAssign());
bool allParticlesInMat = (maxPerNode == 0 &&
unsigned int localNum = itsBunch_m->getLocalNum();
unsigned int totalNum = 0;
reduce(localNum, totalNum, OpAddAssign());
bool allParticlesInMat = (totalNum == 0 &&
degradersWithParticlesCount == 1);
if (allParticlesInMat) {
......@@ -833,7 +834,8 @@ void ParallelTTracker::computeParticleMatterInteraction(IndexMap::value_t elemen
}
auto boundingSphere = itsBunch_m->getLocalBoundingSphere();
unsigned redifusedParticles = 0;
unsigned int rediffusedParticles = 0;
unsigned int numEnteredParticles = 0;
for (auto it: activeParticleMatterInteractionHandlers_m) {
ElementBase* element = it->getElement();
CoordinateSystemTrafo refToLocalCSTrafo = (element->getMisalignment() *
......@@ -858,7 +860,8 @@ void ParallelTTracker::computeParticleMatterInteraction(IndexMap::value_t elemen
itsBunch_m->P[i] = localToRefCSTrafo.rotateTo(itsBunch_m->P[i]);
}
redifusedParticles += it->getRediffused();
rediffusedParticles += it->getRediffused();
numEnteredParticles += it->getNumEntered();
//if all particles where in material update time to time in degrader
if (it->getFlagAllParticlesIn()) {
double timeDifference = it->getTime() - itsBunch_m->getdT() - itsBunch_m->getT();
......@@ -878,8 +881,9 @@ void ParallelTTracker::computeParticleMatterInteraction(IndexMap::value_t elemen
//perform boundp only if there are particles in the bunch, or there are particles
//comming out of the degrader
if (maxPerNode > 0 || redifusedParticles > 0) {
if (itsBunch_m->hasFieldSolver()) {
if (numEnteredParticles > 0 || rediffusedParticles > 0) {
totalNum -= (numEnteredParticles + rediffusedParticles);
if (totalNum > minBinEmitted_m && itsBunch_m->hasFieldSolver()) {
itsBunch_m->boundp();
} else {
itsBunch_m->updateNumTotal();
......
......@@ -89,7 +89,7 @@ public:
std::string getName() { return FN_m;}
size_t getParticlesInMat() { return locPartsInMat_m;}
unsigned getRediffused() { return rediffusedStat_m;}
unsigned int getNumEntered() {return bunchToMatStat_m;}
inline void doPhysics(PartBunchBase<double, 3> *bunch);
......
......@@ -25,6 +25,7 @@ public:
virtual std::string getName() = 0;
virtual size_t getParticlesInMat() = 0;
virtual unsigned getRediffused() = 0;
virtual unsigned int getNumEntered() = 0;
void setFlagAllParticlesIn(bool p);
bool getFlagAllParticlesIn() const;
void updateElement(ElementBase *newref);
......
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