Canoe
Comprehensive Atmosphere N' Ocean Engine
particles.hpp
Go to the documentation of this file.
1 #ifndef SRC_NBODY_PARTICLES_HPP_
2 #define SRC_NBODY_PARTICLES_HPP_
3 
4 // C++ headers
5 #include <memory>
6 #include <string>
7 #include <vector>
8 
9 // Athena++
10 #include <athena/athena.hpp>
11 
12 // canoe
13 #include <virtual_groups.hpp>
14 
15 // exchanger
17 
18 // integrator
20 
21 class MeshBlock;
22 class ParameterInput;
23 class Coordinates;
24 class ParticleData;
25 class Hydro;
26 
27 using ParticleContainer = std::vector<ParticleData>;
28 
29 class ParticleBase : public NamedGroup,
30  public RestartGroup,
31  // ASCIIOutputGroup,
32  // BinaryOutputGroup,
33  public MeshOutputGroup,
34  public MultiStageIntegrator,
35  public NeighborExchanger<ParticleBase> {
36  public:
40 
43 
44  public: // constructor and destructor
45  ParticleBase(MeshBlock *pmb, std::string name);
46  virtual ~ParticleBase();
47 
48  public: // member functions
50  void LinkMesh();
51 
52  public: // inbound functions
53  void SetVelocitiesFromHydro(Hydro const *phydro, Coordinates const *pcoord);
54 
55  public: // RestartGroup functions
56  size_t RestartDataSizeInBytes(Mesh const *pm) const override;
57  void DumpRestartData(char *pdst) const override;
58  size_t LoadRestartData(char *psrt) override;
59 
60  public: // MeshOutputGroup functions
61  bool ShouldMeshOutput(std::string variable_name) const override;
62  void LoadMeshOutputData(OutputType *pod, int *num_vars) const override;
63 
64  public: // MultiStageIntegrator functions
65  void TimeIntegrate(Real time, Real dt) override;
66  void WeightedAverage(Real ave_wghts[]) override;
67 
68  public: // NeighborExchanger functions
69  void PackData(MeshBlock const *pmb) override;
70  bool UnpackData(MeshBlock const *pmb) override;
71 
72  protected:
76 
79 
80  private:
82  MeshBlock const *pmy_block_;
83 };
84 
85 using ParticlePtr = std::shared_ptr<ParticleBase>;
86 using AllParticles = std::vector<ParticlePtr>;
87 
88 // factory methods
90  public:
91  static AllParticles Create(MeshBlock *pmb, ParameterInput *pin);
92 };
93 
94 // helper functions
95 namespace ParticlesHelper {
96 ParticlePtr find_particle(AllParticles const &pts, std::string name);
97 } // namespace ParticlesHelper
98 
99 namespace AllTasks {
100 
101 bool launch_particles(MeshBlock *pmb, int stage);
102 bool integrate_particles(MeshBlock *pmb, int stage);
103 bool mesh_to_particles(MeshBlock *pmb, int stage);
104 bool send_particles(MeshBlock *pmb, int stage);
105 bool recv_particles(MeshBlock *pmb, int stage);
106 bool particles_to_mesh(MeshBlock *pmb, int stage);
107 bool attach_particles(MeshBlock *pmb, int stage);
108 
109 } // namespace AllTasks
110 
111 #endif // SRC_NBODY_PARTICLE_BASE_HPP_
void WeightedAverage(Real ave_wghts[]) override
AthenaArray< ParticleData * > pd_in_cell_
Definition: particles.hpp:75
void TimeIntegrate(Real time, Real dt) override
virtual ~ParticleBase()
Definition: particles.cpp:34
void PackData(MeshBlock const *pmb) override
Pack data to send buffer.
ParticleContainer pc
Definition: particles.hpp:39
bool linked_flag_
linked flag
Definition: particles.hpp:78
void SetVelocitiesFromHydro(Hydro const *phydro, Coordinates const *pcoord)
void LinkMesh()
particle-mesh
void DumpRestartData(char *pdst) const override
bool UnpackData(MeshBlock const *pmb) override
Unpack data from receive buffer.
AthenaArray< Real > charge
Definition: particles.hpp:42
MeshBlock const * pmy_block_
pointer to parent MeshBlock
Definition: particles.hpp:82
AthenaArray< Real > weight
mesh data container
Definition: particles.hpp:42
bool ShouldMeshOutput(std::string variable_name) const override
size_t RestartDataSizeInBytes(Mesh const *pm) const override
size_t LoadRestartData(char *psrt) override
ParticleBase(MeshBlock *pmb, std::string name)
Definition: particles.cpp:22
void LoadMeshOutputData(OutputType *pod, int *num_vars) const override
ParticleContainer pc1
Definition: particles.hpp:39
static AllParticles Create(MeshBlock *pmb, ParameterInput *pin)
Definition: particles.cpp:39
bool particles_to_mesh(MeshBlock *pmb, int stage)
bool mesh_to_particles(MeshBlock *pmb, int stage)
bool integrate_particles(MeshBlock *pmb, int stage)
bool send_particles(MeshBlock *pmb, int stage)
bool recv_particles(MeshBlock *pmb, int stage)
bool launch_particles(MeshBlock *pmb, int stage)
bool attach_particles(MeshBlock *pmb, int stage)
ParticlePtr find_particle(AllParticles const &pts, std::string name)
Definition: particles.cpp:60
std::vector< ParticleData > ParticleContainer
Definition: particles.hpp:27
std::shared_ptr< ParticleBase > ParticlePtr
Definition: particles.hpp:85
std::vector< ParticlePtr > AllParticles
Definition: particles.hpp:86