FML
Data Structures | Functions
FML::PARTICLE Namespace Reference

This namespace contains things related to particles: different types, containers for holding shared particles across tasks and algorithms for doing stuff with particles. More...

Data Structures

struct  Cell
 Class for binning objects into cells. Useful for speeding up algorithms. More...
 
class  MPIParticles
 A container class for holding particles that are distributed across many CPUs and to easily deal with communication of these particles if they cross the domain boundary (simply call communicate_particles() at any time to do this) More...
 
class  ParticlesInBoxes
 Take a set of objects T with positions in [0,1) and bin them to a grid The objects must have the two methods: auto *get_pos() : Pointer to first element in position int *get_ndim() : Number of dimensions in position. More...
 

Functions

get_vel constexpr double * GetPos (...)
 
constexpr double * GetVel (...)
 
set_id constexpr int GetID (...)
 
constexpr void SetID (...)
 
template<class... Args>
set_mass constexpr double GetMass (Args &... args)
 
constexpr void SetMass (...)
 
template<class... Args>
set_volume constexpr double GetVolume (Args &... args)
 
constexpr void SetVolume (...)
 
template<class T , class... Args>
void AppendToBuffer (T &t, Args... args)
 
template<class T , class... Args>
void AssignFromBuffer (T &t, Args... args)
 
constexpr double * GetdDdloga_1LPT (...)
 
constexpr double * GetD_2LPT (...)
 
constexpr double * GetdDdloga_2LPT (...)
 
constexpr double * GetD_3LPTa (...)
 
constexpr double * GetD_3LPTb (...)
 
constexpr double * GetLagrangianPos (...)
 
set_fofid constexpr size_t GetFoFID (...)
 
constexpr void SetFoFID (...)
 
set_family set_tag set_level constexpr char GetFamily (...)
 
constexpr void SetFamily (...)
 
constexpr char GetTag (...)
 
constexpr void SetTag (...)
 
constexpr int GetLevel (...)
 
constexpr void SetLevel (...)
 
set_RA set_DEC set_z set_weight constexpr double GetRA (...)
 
constexpr double SetRA (...)
 
constexpr double GetDEC (...)
 
constexpr double SetDEC (...)
 
constexpr double GetRedshift (...)
 
constexpr double SetRedshift (...)
 
template<class... Args>
constexpr double GetWeight (Args &... args)
 
constexpr void SetWeight (...)
 
template<class T >
void info ()
 
template<class T >
void swap_eulerian_and_lagrangian_positions (T *part, size_t NumPart)
 

Detailed Description

This namespace contains things related to particles: different types, containers for holding shared particles across tasks and algorithms for doing stuff with particles.

Function Documentation

◆ AppendToBuffer()

template<class T , class... Args>
void FML::PARTICLE::AppendToBuffer ( T &  t,
Args...  args 
)

Definition at line 204 of file ReflectOnParticleMethods.h.

204 {
205 // Fiducial method for communication. Assumes no dynamic allocated memory in class
206 static_assert(sizeof...(args) == 1);
207 using BufferType = NthTypeOf<0, Args...>;
208 static_assert(std::is_same<char *, BufferType>::value);
209 std::memcpy(get_NthArgOf<0>(args...), &t, GetSize(t));
210 };
typename std::tuple_element< N, std::tuple< Ts... > >::type NthTypeOf

◆ AssignFromBuffer()

template<class T , class... Args>
void FML::PARTICLE::AssignFromBuffer ( T &  t,
Args...  args 
)

Definition at line 212 of file ReflectOnParticleMethods.h.

212 {
213 // Fiducial method for communication. Assumes no dynamic allocated memory in class
214 static_assert(sizeof...(args) == 1);
215 using BufferType = NthTypeOf<0, Args...>;
216 static_assert(std::is_same<char *, BufferType>::value);
217 std::memcpy(&t, get_NthArgOf<0>(args...), GetSize(t));
218 };

◆ GetD_2LPT()

constexpr double * FML::PARTICLE::GetD_2LPT (   ...)
constexpr

Definition at line 239 of file ReflectOnParticleMethods.h.

239 {
240 assert_mpi(false, "Trying to get D_2LPT from a particle that has no get_D_2LPT method");
241 return nullptr;
242 };

◆ GetD_3LPTa()

constexpr double * FML::PARTICLE::GetD_3LPTa (   ...)
constexpr

Definition at line 247 of file ReflectOnParticleMethods.h.

247 {
248 assert_mpi(false, "Trying to get D_3LPTa from a particle that has no get_D_3LPTa method");
249 return nullptr;
250 };

◆ GetD_3LPTb()

constexpr double * FML::PARTICLE::GetD_3LPTb (   ...)
constexpr

Definition at line 251 of file ReflectOnParticleMethods.h.

251 {
252 assert_mpi(false, "Trying to get D_3LPTb from a particle that has no get_D_3LPTb method");
253 return nullptr;
254 };

◆ GetdDdloga_1LPT()

constexpr double * FML::PARTICLE::GetdDdloga_1LPT (   ...)
constexpr

Definition at line 235 of file ReflectOnParticleMethods.h.

235 {
236 assert_mpi(false, "Trying to get dDdloga_1LPT from a particle that has no get_dDdloga_1LPT method");
237 return nullptr;
238 };

◆ GetdDdloga_2LPT()

constexpr double * FML::PARTICLE::GetdDdloga_2LPT (   ...)
constexpr

Definition at line 243 of file ReflectOnParticleMethods.h.

243 {
244 assert_mpi(false, "Trying to get dDdloga_2LPT from a particle that has no get_dDdloga_2LPT method");
245 return nullptr;
246 };

◆ GetDEC()

constexpr double FML::PARTICLE::GetDEC (   ...)
constexpr

Definition at line 321 of file ReflectOnParticleMethods.h.

321 {
322 assert_mpi(false, "Trying to get DEC from a particle that has no get_DEC method");
323 return 0.0;
324 }

◆ GetFamily()

set_family set_tag set_level constexpr char FML::PARTICLE::GetFamily (   ...)
constexpr

Definition at line 282 of file ReflectOnParticleMethods.h.

282 {
283 assert_mpi(false, "Trying to get family for particle that has no get_family method");
284 return 0;
285 }

◆ GetFoFID()

set_fofid constexpr size_t FML::PARTICLE::GetFoFID (   ...)
constexpr

Definition at line 265 of file ReflectOnParticleMethods.h.

265 {
266 assert_mpi(false, "Trying to get FoFID for particle that has no get_fofid method");
267 return 0;
268 }

◆ GetID()

set_id constexpr int FML::PARTICLE::GetID (   ...)
constexpr

Definition at line 142 of file ReflectOnParticleMethods.h.

142 {
143 assert_mpi(false, "Trying to get id from a particle that has no get_id method");
144 return -1;
145 };

◆ GetLagrangianPos()

constexpr double * FML::PARTICLE::GetLagrangianPos (   ...)
constexpr

Definition at line 255 of file ReflectOnParticleMethods.h.

255 {
256 assert_mpi(false, "Trying to get the Lagrangian coordinate q from a particle that has no get_q method");
257 return nullptr;
258 };

◆ GetLevel()

constexpr int FML::PARTICLE::GetLevel (   ...)
constexpr

Definition at line 294 of file ReflectOnParticleMethods.h.

294 {
295 assert_mpi(false, "Trying to get level for particle that has no get_level method");
296 return 0;
297 }

◆ GetMass()

template<class... Args>
set_mass constexpr double FML::PARTICLE::GetMass ( Args &...  args)
constexpr

Definition at line 154 of file ReflectOnParticleMethods.h.

154 {
155 // Optional to have this. All particles having equal mass is the fiducial case
156 // NB: not using ... to avoid copies of particle being made when this is called
157 return 1.0;
158 };

◆ GetPos()

get_vel constexpr double * FML::PARTICLE::GetPos (   ...)
constexpr

Definition at line 128 of file ReflectOnParticleMethods.h.

128 {
129 assert_mpi(false, "Trying to get position from a particle that has no get_pos method");
130 return nullptr;
131 };

◆ GetRA()

set_RA set_DEC set_z set_weight constexpr double FML::PARTICLE::GetRA (   ...)
constexpr

Definition at line 313 of file ReflectOnParticleMethods.h.

313 {
314 assert_mpi(false, "Trying to get RA from a particle that has no get_RA method");
315 return 0.0;
316 }

◆ GetRedshift()

constexpr double FML::PARTICLE::GetRedshift (   ...)
constexpr

Definition at line 329 of file ReflectOnParticleMethods.h.

329 {
330 assert_mpi(false, "Trying to get Redshift from a particle that has no get_z method");
331 return 0.0;
332 }

◆ GetTag()

constexpr char FML::PARTICLE::GetTag (   ...)
constexpr

Definition at line 289 of file ReflectOnParticleMethods.h.

289 {
290 assert_mpi(false, "Trying to get tag for particle that has no get_tag method");
291 return 0;
292 }

◆ GetVel()

constexpr double * FML::PARTICLE::GetVel (   ...)
constexpr

Definition at line 132 of file ReflectOnParticleMethods.h.

132 {
133 assert_mpi(false, "Trying to get velocity from a particle that has no get_vel method");
134 return nullptr;
135 };

◆ GetVolume()

template<class... Args>
set_volume constexpr double FML::PARTICLE::GetVolume ( Args &...  args)
constexpr

Definition at line 169 of file ReflectOnParticleMethods.h.

169 {
170 // Optional to have this. All particles having equal volume is the fiducial case
171 // NB: not using ... to avoid copies of particle being made when this is called
172 return 1.0;
173 };

◆ GetWeight()

template<class... Args>
constexpr double FML::PARTICLE::GetWeight ( Args &...  args)
constexpr

Definition at line 338 of file ReflectOnParticleMethods.h.

338 {
339 // Optional to have this. All particles having the same weight is the fiducial case
340 // NB: not using ... to avoid copies of particle being made when this is called
341 return 1.0;
342 }

◆ info()

template<class T >
void FML::PARTICLE::info ( )

Definition at line 348 of file ReflectOnParticleMethods.h.

348 {
349 if (FML::ThisTask == 0) {
350 T tmp{};
351 constexpr int N = FML::PARTICLE::GetNDIM(tmp);
352 std::cout << "\n";
353 std::cout << "#=====================================================\n";
354 std::cout << "#\n";
355 std::cout << "# .___ _____ \n";
356 std::cout << "# | | _____/ ____\\____ \n";
357 std::cout << "# | |/ \\ __\\/ _ \\ \n";
358 std::cout << "# | | | \\ | ( <_> ) \n";
359 std::cout << "# |___|___| /__| \\____/ \n";
360 std::cout << "# \\/ \n";
361 std::cout << "#\n";
362 std::cout << "# Information about (an empty) particle of the given type:\n";
363 std::cout << "# Below we only show info about methods we have implemented support for\n";
364
365 if constexpr (FML::PARTICLE::has_append_to_buffer<T>())
366 std::cout << "# Particle has custom communication append_to_buffer method\n";
367 else
368 std::cout << "# Particle uses fiducial communication append_to_buffer method (assumes no dynamic "
369 "alloc inside class)\n";
370
371 if constexpr (FML::PARTICLE::has_assign_from_buffer<T>())
372 std::cout << "# Particle has custom communication assign_from_buffer method\n";
373 else
374 std::cout << "# Particle uses fiducial communication assign_from_buffer method (assumes no dynamic "
375 "alloc inside class)\n";
376
377 if constexpr (FML::PARTICLE::has_get_particle_byte_size<T>())
378 std::cout << "# Particle has custom size method. Size of an empty particle is "
379 << FML::PARTICLE::GetSize(tmp) << " bytes\n";
380 else
381 std::cout << "# Particle uses fiducial size method. Size of particle is "
382 << FML::PARTICLE::GetSize(tmp) << " bytes\n";
383 std::cout << "# Dimension is " << N << "\n";
384
385 if constexpr (FML::PARTICLE::has_get_pos<T>())
386 std::cout << "# Particle has [Position] (" << sizeof(FML::PARTICLE::GetVel(tmp)[0]) * N
387 << " bytes)\n";
388
389 if constexpr (FML::PARTICLE::has_get_vel<T>())
390 std::cout << "# Particle has [Velocity] (" << sizeof(FML::PARTICLE::GetPos(tmp)[0]) * N
391 << " bytes)\n";
392
393 if constexpr (FML::PARTICLE::has_set_mass<T>())
394 std::cout << "# Particle has [Mass] (" << sizeof(FML::PARTICLE::GetMass(tmp)) << " bytes)\n";
395
396 if constexpr (FML::PARTICLE::has_set_id<T>())
397 std::cout << "# Particle has [ID] (" << sizeof(FML::PARTICLE::GetID(tmp)) << " bytes)\n";
398
399 if constexpr (FML::PARTICLE::has_set_volume<T>())
400 std::cout << "# Particle has [Volume] (" << sizeof(FML::PARTICLE::GetVolume(tmp)) << " bytes)\n";
401
402 // Ramses specific things
403 if constexpr (FML::PARTICLE::has_set_tag<T>())
404 std::cout << "# Particle has [Tag] (" << sizeof(FML::PARTICLE::GetTag(tmp)) << " bytes)\n";
405 if constexpr (FML::PARTICLE::has_set_family<T>())
406 std::cout << "# Particle has [Family] (" << sizeof(FML::PARTICLE::GetFamily(tmp)) << " bytes)\n";
407 if constexpr (FML::PARTICLE::has_set_level<T>())
408 std::cout << "# Particle has [Level] (" << sizeof(FML::PARTICLE::GetLevel(tmp)) << " bytes)\n";
409
410 // Galaxy and paircount specific things
411 if constexpr (FML::PARTICLE::has_set_RA<T>())
412 std::cout << "# Particle has [RA] (" << sizeof(FML::PARTICLE::GetRA(tmp)) << " bytes)\n";
413 if constexpr (FML::PARTICLE::has_set_DEC<T>())
414 std::cout << "# Particle has [DEC] (" << sizeof(FML::PARTICLE::GetDEC(tmp)) << " bytes)\n";
415 if constexpr (FML::PARTICLE::has_set_z<T>())
416 std::cout << "# Particle has [Redshift] (" << sizeof(FML::PARTICLE::GetRedshift(tmp))
417 << " bytes)\n";
418 if constexpr (FML::PARTICLE::has_set_weight<T>())
419 std::cout << "# Particle has [Weight] (" << sizeof(FML::PARTICLE::GetWeight(tmp)) << " bytes)\n";
420
421 // LPT specific things
422 if constexpr (FML::PARTICLE::has_get_D_1LPT<T>())
423 std::cout << "# Particle has [1LPT Displacement field] ("
424 << sizeof(FML::PARTICLE::GetD_1LPT(tmp)[0]) * N << " bytes)\n";
425 if constexpr (FML::PARTICLE::has_get_dDdloga_1LPT<T>())
426 std::cout << "# Particle has [1LPT Displacement field derivative] ("
427 << sizeof(FML::PARTICLE::GetdDdloga_1LPT(tmp)[0]) * N << " bytes)\n";
428 if constexpr (FML::PARTICLE::has_get_D_2LPT<T>())
429 std::cout << "# Particle has [2LPT Displacement field] ("
430 << sizeof(FML::PARTICLE::GetD_1LPT(tmp)[0]) * N << " bytes)\n";
431 if constexpr (FML::PARTICLE::has_get_dDdloga_2LPT<T>())
432 std::cout << "# Particle has [2LPT Displacement field derivative] ("
433 << sizeof(FML::PARTICLE::GetdDdloga_2LPT(tmp)[0]) * N << " bytes)\n";
434 if constexpr (FML::PARTICLE::has_get_D_3LPTa<T>())
435 std::cout << "# Particle has [3LPTa Displacement field] ("
436 << sizeof(FML::PARTICLE::GetD_3LPTa(tmp)[0]) * N << " bytes)\n";
437 if constexpr (FML::PARTICLE::has_get_D_3LPTb<T>())
438 std::cout << "# Particle has [3LPTb Displacement field] ("
439 << sizeof(FML::PARTICLE::GetD_3LPTb(tmp)[0]) * N << " bytes)\n";
440 if constexpr (FML::PARTICLE::has_get_q<T>())
441 std::cout << "# Particle has [Lagrangian position] ("
442 << sizeof(FML::PARTICLE::GetLagrangianPos(tmp)[0]) * N << " bytes)\n";
443 if constexpr (FML::PARTICLE::has_get_D_1LPT<T>() and FML::PARTICLE::has_get_D_2LPT<T>() and
444 FML::PARTICLE::has_get_D_3LPTa<T>() and FML::PARTICLE::has_get_D_3LPTb<T>()) {
445 std::cout << "# Particle compatible with 3LPT COLA\n";
446
447 } else if (FML::PARTICLE::has_get_D_1LPT<T>() and FML::PARTICLE::has_get_D_2LPT<T>()) {
448 std::cout << "# Particle compatible with 2LPT COLA\n";
449 } else if (FML::PARTICLE::has_get_D_1LPT<T>()) {
450 std::cout << "# Particle compatible with 1LPT COLA\n";
451 } else {
452 std::cout << "# Particle is not compatible with COLA\n";
453 }
454 if constexpr (FML::PARTICLE::has_get_q<T>() and FML::PARTICLE::has_get_D_1LPT<T>() and
455 FML::PARTICLE::has_get_dDdloga_1LPT<T>()) {
456 std::cout << "# Particle compatible with 1LPT scaledependent COLA\n";
457 } else if constexpr (FML::PARTICLE::has_get_q<T>() and FML::PARTICLE::has_get_D_1LPT<T>() and
458 FML::PARTICLE::has_get_D_2LPT<T>()) {
459 std::cout << "# Particle compatible with 2+ LPT scaledependent COLA\n";
460 } else {
461 std::cout << "# Particle is not compatible with scaledependent COLA\n";
462 }
463
464 std::cout << "#\n";
465 std::cout << "#=====================================================\n";
466 std::cout << "\n";
467 }
468 }
get_vel constexpr double * GetPos(...)
constexpr double GetDEC(...)
set_volume constexpr double GetVolume(Args &... args)
constexpr double * GetLagrangianPos(...)
constexpr double * GetD_3LPTa(...)
constexpr double * GetdDdloga_2LPT(...)
set_family set_tag set_level constexpr char GetFamily(...)
constexpr double * GetdDdloga_1LPT(...)
set_id constexpr int GetID(...)
constexpr double * GetVel(...)
set_RA set_DEC set_z set_weight constexpr double GetRA(...)
constexpr double * GetD_3LPTb(...)
constexpr double GetRedshift(...)
set_mass constexpr double GetMass(Args &... args)
constexpr double GetWeight(Args &... args)
constexpr int GetLevel(...)
constexpr char GetTag(...)
Definition: CAMBReader.h:10
int ThisTask
The MPI task number.
Definition: Global.cpp:33

◆ SetDEC()

constexpr double FML::PARTICLE::SetDEC (   ...)
constexpr

Definition at line 325 of file ReflectOnParticleMethods.h.

325 {
326 assert_mpi(false, "Trying to set DEC from a particle that has no set_DEC method");
327 return 0.0;
328 }

◆ SetFamily()

constexpr void FML::PARTICLE::SetFamily (   ...)
constexpr

Definition at line 286 of file ReflectOnParticleMethods.h.

286 {
287 assert_mpi(false, "Trying to set family for particle that has no set_family method");
288 }

◆ SetFoFID()

constexpr void FML::PARTICLE::SetFoFID (   ...)
constexpr

Definition at line 269 of file ReflectOnParticleMethods.h.

269 {
270 assert_mpi(false, "Trying to set FoFID for particle that has no set_fofid method");
271 }

◆ SetID()

constexpr void FML::PARTICLE::SetID (   ...)
constexpr

Definition at line 146 of file ReflectOnParticleMethods.h.

146{ assert_mpi(false, "Trying to set id from a particle that has no set_id method"); };

◆ SetLevel()

constexpr void FML::PARTICLE::SetLevel (   ...)
constexpr

Definition at line 298 of file ReflectOnParticleMethods.h.

298 {
299 assert_mpi(false, "Trying to set level for particle that has no set_level method");
300 }

◆ SetMass()

constexpr void FML::PARTICLE::SetMass (   ...)
constexpr

Definition at line 159 of file ReflectOnParticleMethods.h.

159 {
160 assert_mpi(false, "Trying to set mass from a particle that has no set_mass method");
161 };

◆ SetRA()

constexpr double FML::PARTICLE::SetRA (   ...)
constexpr

Definition at line 317 of file ReflectOnParticleMethods.h.

317 {
318 assert_mpi(false, "Trying to set RA from a particle that has no set_RA method");
319 return 0.0;
320 }

◆ SetRedshift()

constexpr double FML::PARTICLE::SetRedshift (   ...)
constexpr

Definition at line 333 of file ReflectOnParticleMethods.h.

333 {
334 assert_mpi(false, "Trying to set Redshift from a particle that has no set_z method");
335 return 0.0;
336 }

◆ SetTag()

constexpr void FML::PARTICLE::SetTag (   ...)
constexpr

Definition at line 293 of file ReflectOnParticleMethods.h.

293{ assert_mpi(false, "Trying to set tag for particle that has no set_tag method"); }

◆ SetVolume()

constexpr void FML::PARTICLE::SetVolume (   ...)
constexpr

Definition at line 174 of file ReflectOnParticleMethods.h.

174 {
175 assert_mpi(false, "Trying to set volume for particle that has no set_volume method");
176 };

◆ SetWeight()

constexpr void FML::PARTICLE::SetWeight (   ...)
constexpr

Definition at line 343 of file ReflectOnParticleMethods.h.

343 {
344 assert_mpi(false, "Trying to set weight from a particle that has no set_weight method");
345 }

◆ swap_eulerian_and_lagrangian_positions()

template<class T >
void FML::PARTICLE::swap_eulerian_and_lagrangian_positions ( T *  part,
size_t  NumPart 
)

Definition at line 472 of file ReflectOnParticleMethods.h.

472 {
473 if constexpr (not FML::PARTICLE::has_get_q<T>())
474 return;
475 constexpr T p{};
476 constexpr int N = p.get_ndim();
477#ifdef USE_OMP
478#pragma omp parallel for
479#endif
480 for (size_t ind = 0; ind < NumPart; ind++) {
481 auto pos_eulerian = FML::PARTICLE::GetPos(part[ind]);
482 auto pos_lagrangian = FML::PARTICLE::GetLagrangianPos(part[ind]);
483 for (int idim = 0; idim < N; idim++) {
484 auto tmp = pos_eulerian[idim];
485 pos_eulerian[idim] = pos_lagrangian[idim];
486 pos_lagrangian[idim] = tmp;
487 }
488 }
489 }