Chombo + EB + MF  3.2
Particle.H
Go to the documentation of this file.
1 #ifdef CH_LANG_CC
2 /*
3  * _______ __
4  * / ___/ / ___ __ _ / / ___
5  * / /__/ _ \/ _ \/ V \/ _ \/ _ \
6  * \___/_//_/\___/_/_/_/_.__/\___/
7  * Please refer to Copyright.txt, in Chombo's root directory.
8  */
9 #endif
10 
11 #ifndef _PARTICLE_H_
12 #define _PARTICLE_H_
13 
14 #include <string>
15 #include <typeinfo>
16 #include <cstdio>
17 #include <cmath>
18 
19 #include "BinItem.H"
20 #include "NamespaceHeader.H"
21 
22 /// A basic particle class.
23 /// Includes mass, position, velocity, and acceleration
24 
25 class Particle : public BinItem
26 {
27 public:
28 
29  /// default constructor
30  Particle();
31 
32  /// same as define()
33  Particle(const Real a_mass,
34  const RealVect& a_position,
35  const RealVect& a_velocity = RealVect::Zero);
36 
37  /// default
38  virtual ~Particle();
39 
40  /// for non-default constructor
41  void define(const Real a_mass,
42  const RealVect& a_position,
43  const RealVect& a_velocity = RealVect::Zero);
44 
45  /// set particle mass
46  void setMass(const Real a_mass);
47 
48  // retrieve reference mass field
49  Real& mass();
50 
51  // retrieve const. reference mass field
52  const Real& mass() const;
53 
54  /// set velocity field
55  void setVelocity(const RealVect& a_velocity);
56  void setVelocity(const Real& a_velocity, const int a_dir);
57 
58  // retrieve reference velocity field
59  RealVect& velocity();
60 
61  // retrieve const. reference velocity field
62  const RealVect& velocity() const;
63 
64  // retrieve vel. comp. in a given direction
65  Real velocity(const int a_dir) const;
66 
67  /// set acceleration field
68  void setAcceleration(const RealVect& a_velocity);
69 
70  // retrieve reference acceleration field
72 
73  // retrieve const. reference acceleration field
74  const RealVect& acceleration() const;
75 
76  // retrieve acc. comp. in a given direction
77  Real acceleration(const int a_dir) const;
78 
79  virtual bool operator==(const Particle& a_p) const;
80  virtual bool operator==(const Particle* a_p) const;
81  virtual bool operator!=(const Particle& a_p) const;
82 
83  /// {\bf linearization functions}
84 
85  /** Returns the size, in number of bytes, of a flat linear
86  representation of the data in this object.
87  */
88  virtual int size() const;
89 
90  // return size, in number of bytes, of a comp of the internal data
91  //virtual size_t sizeOfComp(const int a_comp) const;
92 
93  ///
94  /** Write a linear binary representation of the internal data. Assumes that
95  sufficient memory for the buffer has already been allocated by
96  the caller.
97  */
98  virtual void linearOut(void* buf) const;
99 
100  ///
101  /** Read a linear binary representation of the internal data.
102  Assumes that the buffer has the correct data.
103  */
104  virtual void linearIn(void* buf);
105 
106  friend std::ostream & operator<<(std::ostream& ostr,const Particle& p);
107 
108 protected:
109 
113 };
114 
115 std::ostream & operator<<(std::ostream& ostr, const Particle& p);
116 
117 #include "NamespaceFooter.H"
118 
119 #endif // include guard
120 
RealVect & acceleration()
Real m_mass
Definition: Particle.H:110
void setMass(const Real a_mass)
set particle mass
void define(const Real a_mass, const RealVect &a_position, const RealVect &a_velocity=RealVect::Zero)
for non-default constructor
Particle()
default constructor
RealVect & velocity()
void setVelocity(const RealVect &a_velocity)
set velocity field
static const RealVect Zero
Definition: RealVect.H:421
virtual void linearOut(void *buf) const
virtual bool operator==(const Particle &a_p) const
double Real
Definition: REAL.H:33
RealVect m_velocity
Definition: Particle.H:111
Definition: Particle.H:25
Real & mass()
A Real vector in SpaceDim-dimensional space.
Definition: RealVect.H:41
friend std::ostream & operator<<(std::ostream &ostr, const Particle &p)
virtual bool operator!=(const Particle &a_p) const
Virtual base class for particle data.
Definition: BinItem.H:28
virtual int size() const
{ linearization functions}
void setAcceleration(const RealVect &a_velocity)
set acceleration field
virtual void linearIn(void *buf)
virtual ~Particle()
default
RealVect m_acceleration
Definition: Particle.H:112