1 #ifndef AMR_PARTICLE_BASE_HPP
2 #define AMR_PARTICLE_BASE_HPP
7 template<
class PLayout>
10 lorentzFactor_m(1.0, 1.0, 1.0),
20 template<
class PLayout>
23 forbidTransform_m(false),
25 lorentzFactor_m(1.0, 1.0, 1.0),
35 template<
class PLayout>
39 return LocalNumPerLevel_m;
43 template<
class PLayout>
47 return LocalNumPerLevel_m;
51 template<
class PLayout>
55 LocalNumPerLevel_m = LocalNumPerLevel;
59 template<
class PLayout>
66 for (
size_t ip = I; ip < M + I; ++ip)
67 --LocalNumPerLevel_m[ Level[ip] ];
74 template<
class PLayout>
77 if ( this->DestroyList.empty() )
80 if ( updateLocalNum ) {
81 typedef std::vector< std::pair<size_t,size_t> > dlist_t;
82 dlist_t::const_iterator curr = this->DestroyList.begin();
83 const dlist_t::const_iterator last = this->DestroyList.end();
85 while ( curr != last ) {
86 for (
size_t ip = curr->first;
87 ip < curr->first + curr->second;
90 --LocalNumPerLevel_m[ Level[ip] ];
99 template<
class PLayout>
105 LocalNumPerLevel_m[0] += M;
116 template<
class PLayout>
121 ++LocalNumPerLevel_m[0];
130 template<
class PLayout>
137 template<
class PLayout>
143 PLayout *Layout = &this->getLayout();
148 Layout->update(*
this, lev_min, lev_max, isRegrid);
158 template<
class PLayout>
164 PLayout *Layout = &this->getLayout();
168 Layout->update(*
this, &canSwap);
179 template<
class PLayout>
183 size_t LocalNum = this->getLocalNum();
189 std::iota(slist1.begin(), slist1.end(), 0);
190 std::sort(slist1.begin(), slist1.end(), [
this](
const SortListIndex_t &i,
193 return (this->Level[i] < this->Level[j] ||
194 (this->Level[i] == this->Level[j] && this->Grid[i] < this->Grid[j]));
198 for (
unsigned int i = 0; i < LocalNum; ++i)
199 slist2[slist1[i]] = i;
208 template<
class PLayout>
212 for ( ; abeg != aend; ++abeg )
213 (*abeg)->sort(sortlist);
217 template<
class PLayout>
219 forbidTransform_m = forbidTransform;
223 template<
class PLayout>
225 return forbidTransform_m;
229 template<
class PLayout>
233 double scale = scale_m;
245 getGlobalBounds_m(rmin, rmax);
251 if ( this->getTotalNum() == 1 ||
264 PLayout& layout = this->getLayout();
266 const auto& lo = layout.lowerBound;
267 const auto& hi = layout.upperBound;
284 "Scale factor is Nan or Inf");
290 for (
unsigned int i = 0; i < this->getLocalNum(); ++i) {
291 this->
R[i] = this->
R[i] * gamma / vscale;
294 scale_m = 1.0 / scale;
302 template<
class PLayout>
307 template<
class PLayout>
309 lorentzFactor_m = lorentzFactor;
313 template<
class PLayout>
315 const size_t localNum = this->getLocalNum();
325 for (
size_t i = 1; i < localNum; ++ i) {
326 for (
unsigned short d = 0; d < 3u; ++ d) {
327 if (rmin(d) > this->
R[i](d)) rmin(d) = this->
R[i](d);
328 else if (rmax(d) < this->
R[i](d)) rmax(d) = this->
R[i](d);
334 template<
class PLayout>
336 this->getLocalBounds_m(rmin, rmax);
339 for (
unsigned int i = 0; i < 3; ++i) {
341 min[2*i + 1] = -rmax[i];
346 for (
unsigned int i = 0; i < 3; ++i) {
348 rmax[i] = -min[2*i + 1];
PETE_TUTree< FnAbs, typename T::PETE_Expr_t > abs(const PETE_Expr< T > &l)
const double & getScalingFactor() const
void getGlobalBounds_m(Vector_t &rmin, Vector_t &rmax)
T::PETE_Expr_t::PETE_Return_t max(const PETE_Expr< T > &expr, NDIndex< D > &loc)
void destroy(size_t, size_t, bool=false)
const ParticleLevelCounter_t & getLocalNumPerLevel() const
IpplTimings::TimerRef domainMappingTimer_m
bool isForbidTransform() const
void createWithID(unsigned id)
void performDestroy(bool updateLocalNum=false)
void getLocalBounds_m(Vector_t &rmin, Vector_t &rmax)
std::vector< SortListIndex_t > SortList_t
void allreduce(const T *input, T *output, int count, Op op)
static void startTimer(TimerRef t)
void createWithID(unsigned id)
void performDestroy(bool updateLocalNum=false)
void setForbidTransform(bool forbidTransform)
Vektor< double, 3 > Vector_t
void setLorentzFactor(const Vector_t &lorentzFactor)
#define INCIPPLSTAT(stat)
const double & domainMapping(bool inverse=false)
IpplTimings::TimerRef updateParticlesTimer_m
T isnan(T x)
isnan function with adjusted return type
void setLocalNumPerLevel(const ParticleLevelCounter_t &LocalNumPerLevel)
IpplTimings::TimerRef sortParticlesTimer_m
std::string::iterator iterator
static TimerRef getTimer(const char *nm)
static void stopTimer(TimerRef t)
T::PETE_Expr_t::PETE_Return_t min(const PETE_Expr< T > &expr, NDIndex< D > &loc)
void destroy(size_t M, size_t I, bool doNow=false)
T isinf(T x)
isinf function with adjusted return type