Chombo + EB + MF  3.2
BinItem.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 _BINITEM_H_
12 #define _BINITEM_H_
13 
14 #include <iostream>
15 
16 #include "RealVect.H"
17 #include "NamespaceHeader.H"
18 
19 /// Virtual base class for particle data.
20 /**
21  BinItem is a base class to provide the necessary interface
22  with BinFab for particle-in-bin/cell problems. Since the only attribute
23  of a particle needed by the BinFab is position, it is the only attribute
24  present in this class. All other attributes (charge, velocity, etc)
25  must appear in a derived class.
26 */
27 
28 class BinItem
29 {
30 public:
31  /// Null constructor, copy constructor and operator= can be compiler defined.
32  BinItem();
33 
34  /// Constructs a \p BinItem at \a a_position
35  BinItem(const RealVect& a_position);
36 
37  /// Destructor
38  virtual ~BinItem();
39 
40  /// Same as the constructor
41  virtual void define(const RealVect& a_position);
42 
43  /// Change the position
44  void setPosition(const RealVect& a_position);
45 
46  /// Change one component of the position
47  void setPosition(const Real a_position, const int a_dimension);
48 
49  /// Return a reference to the position
50  RealVect& position();
51 
52  /// Return a constant reference to the position
53  const RealVect& position() const;
54 
55  /// Gets one component of the position
56  Real position(const int a_dir) const;
57 
58  /// Equality operator. Checks whether two BinItems have equal data.
59  virtual bool operator==(const BinItem& a_p) const;
60 
61  /// Same as the above, but defined for a pointer
62  virtual bool operator==(const BinItem* a_p) const;
63 
64  /// Inequality operator.
65  virtual bool operator!=(const BinItem& a_p) const;
66 
67  // Linearization functions
68 
69  /// Number of bytes used by \b linearIn()/linearOut()
70  /** Returns the size, in number of bytes, of a flat linear
71  representation of the data in this object.
72  */
73  virtual int size() const;
74 
75  /// Write a serialized (packed) representation into \a a_buf
76  /** Write a linear representation of the internal data. Assumes that
77  sufficient memory for the buffer has already been allocated by
78  the caller.
79  */
80  virtual void linearOut(void* a_buf) const;
81 
82  /// Extract a serialized (packed) representation from \a a_buf
83  /** Given a linear representation of the class data previously made
84  using \b linearOut() in \a a_buf, set the data for this class.
85  */
86  virtual void linearIn(void* a_buf);
87 
88  ///
90  {
91  return 0;
92  }
93 
94  // Text output functions
95 
96  /// Write a human-readable version to stdout (for debugging)
97  virtual void print() const;
98  friend std::ostream& operator<<( std::ostream& ostr, const BinItem& a_item );
99 
100 protected:
101  /// this is the position in space of this item
103 };
104 
105 std::ostream& operator<<( std::ostream& ostr, const BinItem& a_item );
106 
107 #include "NamespaceFooter.H"
108 #endif
virtual int size() const
Number of bytes used by linearIn()/linearOut()
virtual void define(const RealVect &a_position)
Same as the constructor.
virtual void print() const
Write a human-readable version to stdout (for debugging)
BinItem()
Null constructor, copy constructor and operator= can be compiler defined.
friend std::ostream & operator<<(std::ostream &ostr, const BinItem &a_item)
virtual void linearIn(void *a_buf)
Extract a serialized (packed) representation from a_buf.
virtual bool operator!=(const BinItem &a_p) const
Inequality operator.
double Real
Definition: REAL.H:33
RealVect m_position
this is the position in space of this item
Definition: BinItem.H:102
void setPosition(const RealVect &a_position)
Change the position.
A Real vector in SpaceDim-dimensional space.
Definition: RealVect.H:41
virtual ~BinItem()
Destructor.
Virtual base class for particle data.
Definition: BinItem.H:28
virtual bool operator==(const BinItem &a_p) const
Equality operator. Checks whether two BinItems have equal data.
virtual void linearOut(void *a_buf) const
Write a serialized (packed) representation into a_buf.
int preAllocatable()
Definition: BinItem.H:89
RealVect & position()
Return a reference to the position.