Jet  v1.3.3
particle_system_data3.h
Go to the documentation of this file.
1 // Copyright (c) 2018 Doyub Kim
2 //
3 // I am making my contributions/submissions to this project solely in my
4 // personal capacity and am not conveying any rights to any intellectual
5 // property of any third parties.
6 
7 #ifndef INCLUDE_JET_PARTICLE_SYSTEM_DATA3_H_
8 #define INCLUDE_JET_PARTICLE_SYSTEM_DATA3_H_
9 
10 #include <jet/array1.h>
11 #include <jet/serialization.h>
13 
14 #include <memory>
15 #include <vector>
16 
17 #ifndef JET_DOXYGEN
18 
19 namespace flatbuffers {
20 
21 class FlatBufferBuilder;
22 template<typename T> struct Offset;
23 
24 }
25 
26 namespace jet {
27 namespace fbs {
28 
29 struct ParticleSystemData3;
30 
31 }
32 }
33 
34 #endif // JET_DOXYGEN
35 
36 namespace jet {
37 
46  public:
49 
52 
55 
58 
61 
64 
76  void resize(size_t newNumberOfParticles);
77 
79  size_t numberOfParticles() const;
80 
89  size_t addScalarData(double initialVal = 0.0);
90 
99  size_t addVectorData(const Vector3D& initialVal = Vector3D());
100 
102  double radius() const;
103 
105  virtual void setRadius(double newRadius);
106 
108  double mass() const;
109 
111  virtual void setMass(double newMass);
112 
115 
118 
121 
124 
127 
130 
133 
136 
139 
142 
158  const Vector3D& newPosition,
159  const Vector3D& newVelocity = Vector3D(),
160  const Vector3D& newForce = Vector3D());
161 
176  const ConstArrayAccessor1<Vector3D>& newPositions,
177  const ConstArrayAccessor1<Vector3D>& newVelocities
179  const ConstArrayAccessor1<Vector3D>& newForces
181 
191 
194  const PointNeighborSearcher3Ptr& newNeighborSearcher);
195 
205  const std::vector<std::vector<size_t>>& neighborLists() const;
206 
208  void buildNeighborSearcher(double maxSearchRadius);
209 
211  void buildNeighborLists(double maxSearchRadius);
212 
214  void serialize(std::vector<uint8_t>* buffer) const override;
215 
217  void deserialize(const std::vector<uint8_t>& buffer) override;
218 
220  void set(const ParticleSystemData3& other);
221 
224 
225  protected:
227  flatbuffers::FlatBufferBuilder* builder,
228  flatbuffers::Offset<fbs::ParticleSystemData3>* fbsParticleSystemData)
229  const;
230 
232  const fbs::ParticleSystemData3* fbsParticleSystemData);
233 
234  private:
235  double _radius = 1e-3;
236  double _mass = 1e-3;
237  size_t _numberOfParticles = 0;
238  size_t _positionIdx;
239  size_t _velocityIdx;
240  size_t _forceIdx;
241 
242  std::vector<ScalarData> _scalarDataList;
243  std::vector<VectorData> _vectorDataList;
244 
245  PointNeighborSearcher3Ptr _neighborSearcher;
246  std::vector<std::vector<size_t>> _neighborLists;
247 };
248 
250 typedef std::shared_ptr<ParticleSystemData3> ParticleSystemData3Ptr;
251 
252 } // namespace jet
253 
254 #endif // INCLUDE_JET_PARTICLE_SYSTEM_DATA3_H_
jet::ParticleSystemData3::addScalarData
size_t addScalarData(double initialVal=0.0)
Adds a scalar data layer and returns its index.
jet::ParticleSystemData3::scalarDataAt
ArrayAccessor1< double > scalarDataAt(size_t idx)
Returns custom scalar data layer at given index (mutable).
jet::Array< T, 1 >
1-D array class.
Definition: array1.h:31
jet::ParticleSystemData3::addParticles
void addParticles(const ConstArrayAccessor1< Vector3D > &newPositions, const ConstArrayAccessor1< Vector3D > &newVelocities=ConstArrayAccessor1< Vector3D >(), const ConstArrayAccessor1< Vector3D > &newForces=ConstArrayAccessor1< Vector3D >())
Adds particles to the data structure.
jet::ParticleSystemData3::scalarDataAt
ConstArrayAccessor1< double > scalarDataAt(size_t idx) const
Returns custom scalar data layer at given index (immutable).
jet::ParticleSystemData3
3-D particle system data.
Definition: particle_system_data3.h:45
jet::ParticleSystemData3::forces
ConstArrayAccessor1< Vector3D > forces() const
Returns the force array (immutable).
jet::ParticleSystemData3::buildNeighborSearcher
void buildNeighborSearcher(double maxSearchRadius)
Builds neighbor searcher with given search radius.
jet::ParticleSystemData3::deserialize
void deserialize(const std::vector< uint8_t > &buffer) override
Deserializes this particle system data from the buffer.
jet::ConstArrayAccessor< T, 1 >
1-D read-only array accessor class.
Definition: array_accessor1.h:184
jet::ParticleSystemData3::neighborLists
const std::vector< std::vector< size_t > > & neighborLists() const
Returns neighbor lists.
jet::ParticleSystemData3Ptr
std::shared_ptr< ParticleSystemData3 > ParticleSystemData3Ptr
Shared pointer type of ParticleSystemData3.
Definition: particle_system_data3.h:250
jet::ParticleSystemData3::numberOfParticles
size_t numberOfParticles() const
Returns the number of particles.
jet::ParticleSystemData3::ScalarData
Array1< double > ScalarData
Scalar data chunk.
Definition: particle_system_data3.h:48
jet::ParticleSystemData3::setRadius
virtual void setRadius(double newRadius)
Sets the radius of the particles.
jet::ParticleSystemData3::radius
double radius() const
Returns the radius of the particles.
jet::ParticleSystemData3::vectorDataAt
ConstArrayAccessor1< Vector3D > vectorDataAt(size_t idx) const
Returns custom vector data layer at given index (immutable).
jet::ParticleSystemData3::ParticleSystemData3
ParticleSystemData3()
Default constructor.
jet::ParticleSystemData3::set
void set(const ParticleSystemData3 &other)
Copies from other particle system data.
jet::ParticleSystemData3::setNeighborSearcher
void setNeighborSearcher(const PointNeighborSearcher3Ptr &newNeighborSearcher)
Sets neighbor searcher.
point_neighbor_searcher3.h
jet::ParticleSystemData3::deserializeParticleSystemData
void deserializeParticleSystemData(const fbs::ParticleSystemData3 *fbsParticleSystemData)
jet::ParticleSystemData3::positions
ConstArrayAccessor1< Vector3D > positions() const
Returns the position array (immutable).
jet::ParticleSystemData3::~ParticleSystemData3
virtual ~ParticleSystemData3()
Destructor.
jet::ParticleSystemData3::addParticle
void addParticle(const Vector3D &newPosition, const Vector3D &newVelocity=Vector3D(), const Vector3D &newForce=Vector3D())
Adds a particle to the data structure.
jet
Definition: advection_solver2.h:18
jet::ParticleSystemData3::positions
ArrayAccessor1< Vector3D > positions()
Returns the position array (mutable).
jet::ParticleSystemData3::VectorData
Array1< Vector3D > VectorData
Vector data chunk.
Definition: particle_system_data3.h:51
jet::ParticleSystemData3::ParticleSystemData3
ParticleSystemData3(size_t numberOfParticles)
Constructs particle system data with given number of particles.
jet::ParticleSystemData3::addVectorData
size_t addVectorData(const Vector3D &initialVal=Vector3D())
Adds a vector data layer and returns its index.
jet::PointNeighborSearcher3Ptr
std::shared_ptr< PointNeighborSearcher3 > PointNeighborSearcher3Ptr
Shared pointer for the PointNeighborSearcher3 type.
Definition: point_neighbor_searcher3.h:82
jet::Serializable
Abstract base class for any serializable class.
Definition: serialization.h:17
jet::ParticleSystemData3::forces
ArrayAccessor1< Vector3D > forces()
Returns the force array (mutable).
jet::Vector3D
Vector3< double > Vector3D
Double-type 3D vector.
Definition: vector3.h:349
jet::ParticleSystemData3::neighborSearcher
const PointNeighborSearcher3Ptr & neighborSearcher() const
Returns neighbor searcher.
jet::Vector< T, 3 >
3-D vector class.
Definition: vector3.h:25
jet::ParticleSystemData3::serializeParticleSystemData
void serializeParticleSystemData(flatbuffers::FlatBufferBuilder *builder, flatbuffers::Offset< fbs::ParticleSystemData3 > *fbsParticleSystemData) const
jet::ParticleSystemData3::velocities
ConstArrayAccessor1< Vector3D > velocities() const
Returns the velocity array (immutable).
jet::ParticleSystemData3::buildNeighborLists
void buildNeighborLists(double maxSearchRadius)
Builds neighbor lists with given search radius.
serialization.h
jet::ParticleSystemData3::vectorDataAt
ArrayAccessor1< Vector3D > vectorDataAt(size_t idx)
Returns custom vector data layer at given index (mutable).
jet::ParticleSystemData3::operator=
ParticleSystemData3 & operator=(const ParticleSystemData3 &other)
Copies from other particle system data.
jet::ParticleSystemData3::ParticleSystemData3
ParticleSystemData3(const ParticleSystemData3 &other)
Copy constructor.
jet::ParticleSystemData3::serialize
void serialize(std::vector< uint8_t > *buffer) const override
Serializes this particle system data to the buffer.
jet::ParticleSystemData3::resize
void resize(size_t newNumberOfParticles)
Resizes the number of particles of the container.
jet::ParticleSystemData3::velocities
ArrayAccessor1< Vector3D > velocities()
Returns the velocity array (mutable).
jet::ParticleSystemData3::mass
double mass() const
Returns the mass of the particles.
jet::ParticleSystemData3::setMass
virtual void setMass(double newMass)
Sets the mass of the particles.
jet::ArrayAccessor< T, 1 >
1-D array accessor class.
Definition: array_accessor1.h:27
array1.h