36#ifndef AMR_PARTICLE_BASE_HPP
37#define AMR_PARTICLE_BASE_HPP
42template<
class PLayout>
45 lorentzFactor_m(1.0, 1.0, 1.0),
55template<
class PLayout>
58 forbidTransform_m(false),
60 lorentzFactor_m(1.0, 1.0, 1.0),
70template<
class PLayout>
74 return LocalNumPerLevel_m;
78template<
class PLayout>
82 return LocalNumPerLevel_m;
86template<
class PLayout>
90 LocalNumPerLevel_m = LocalNumPerLevel;
94template<
class PLayout>
101 for (
size_t ip = I; ip < M + I; ++ip)
102 --LocalNumPerLevel_m[ Level[ip] ];
109template<
class PLayout>
112 if ( this->DestroyList.empty() )
115 if ( updateLocalNum ) {
116 typedef std::vector< std::pair<size_t,size_t> > dlist_t;
117 dlist_t::const_iterator curr = this->DestroyList.begin();
118 const dlist_t::const_iterator last = this->DestroyList.end();
120 while ( curr != last ) {
121 for (
size_t ip = curr->first;
122 ip < curr->first + curr->second;
125 --LocalNumPerLevel_m[ Level[ip] ];
134template<
class PLayout>
140 LocalNumPerLevel_m[0] += M;
151template<
class PLayout>
156 ++LocalNumPerLevel_m[0];
165template<
class PLayout>
172template<
class PLayout>
178 PLayout *Layout = &this->getLayout();
183 Layout->update(*
this, lev_min, lev_max, isRegrid);
193template<
class PLayout>
199 PLayout *Layout = &this->getLayout();
203 Layout->update(*
this, &canSwap);
214template<
class PLayout>
218 size_t LocalNum = this->getLocalNum();
224 std::iota(slist1.begin(), slist1.end(), 0);
225 std::sort(slist1.begin(), slist1.end(), [
this](
const SortListIndex_t &i,
228 return (this->Level[i] < this->Level[j] ||
229 (this->Level[i] == this->Level[j] && this->Grid[i] < this->Grid[j]));
233 for (
unsigned int i = 0; i < LocalNum; ++i)
234 slist2[slist1[i]] = i;
243template<
class PLayout>
247 for ( ; abeg != aend; ++abeg )
248 (*abeg)->sort(sortlist);
252template<
class PLayout>
254 forbidTransform_m = forbidTransform;
258template<
class PLayout>
260 return forbidTransform_m;
264template<
class PLayout>
268 double scale = scale_m;
280 getGlobalBounds_m(rmin, rmax);
286 if ( this->getTotalNum() == 1 ||
299 PLayout& layout = this->getLayout();
301 const auto& lo = layout.lowerBound;
302 const auto& hi = layout.upperBound;
319 "Scale factor is Nan or Inf");
325 for (
unsigned int i = 0; i < this->getLocalNum(); ++i) {
326 this->
R[i] = this->
R[i] * gamma / vscale;
329 scale_m = 1.0 / scale;
337template<
class PLayout>
342template<
class PLayout>
344 lorentzFactor_m = lorentzFactor;
348template<
class PLayout>
350 const size_t localNum = this->getLocalNum();
360 for (
size_t i = 1; i < localNum; ++ i) {
361 for (
unsigned short d = 0; d < 3u; ++ d) {
362 if (rmin(d) > this->
R[i](d)) rmin(d) = this->
R[i](d);
363 else if (rmax(d) < this->
R[i](d)) rmax(d) = this->
R[i](d);
369template<
class PLayout>
371 this->getLocalBounds_m(rmin, rmax);
374 for (
unsigned int i = 0; i < 3; ++i) {
376 min[2*i + 1] = -rmax[i];
381 for (
unsigned int i = 0; i < 3; ++i) {
383 rmax[i] = -
min[2*i + 1];
PartBunchBase< T, Dim >::ConstIterator end(PartBunchBase< T, Dim > const &bunch)
PartBunchBase< T, Dim >::ConstIterator begin(PartBunchBase< T, Dim > const &bunch)
void allreduce(const T *input, T *output, int count, Op op)
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
T::PETE_Expr_t::PETE_Return_t min(const PETE_Expr< T > &expr, NDIndex< D > &loc)
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
#define INCIPPLSTAT(stat)
std::string::iterator iterator
T isinf(T x)
isinf function with adjusted return type
T isnan(T x)
isnan function with adjusted return type
void setLorentzFactor(const Vector_t &lorentzFactor)
bool isForbidTransform() const
const double & getScalingFactor() const
std::vector< SortListIndex_t > SortList_t
void getGlobalBounds_m(Vector_t &rmin, Vector_t &rmax)
void performDestroy(bool updateLocalNum=false)
IpplTimings::TimerRef sortParticlesTimer_m
const ParticleLevelCounter_t & getLocalNumPerLevel() const
void getLocalBounds_m(Vector_t &rmin, Vector_t &rmax)
void setLocalNumPerLevel(const ParticleLevelCounter_t &LocalNumPerLevel)
IpplTimings::TimerRef domainMappingTimer_m
void createWithID(unsigned id)
IpplTimings::TimerRef updateParticlesTimer_m
void destroy(size_t M, size_t I, bool doNow=false)
void setForbidTransform(bool forbidTransform)
const double & domainMapping(bool inverse=false)
void performDestroy(bool updateLocalNum=false)
void createWithID(unsigned id)
void destroy(size_t, size_t, bool=false)
static TimerRef getTimer(const char *nm)
static void stopTimer(TimerRef t)
static void startTimer(TimerRef t)
Vektor< double, 3 > Vector_t