VAPOR3 3.9.4
Particle.h
Go to the documentation of this file.
1/*
2 * Defines a particle used in flow integration.
3 */
4
5#ifndef PARTICLE_H
6#define PARTICLE_H
7
8#include "vapor/common.h"
9#include <glm/glm.hpp>
10#include <forward_list>
11
12namespace flow {
13enum FLOW_ERROR_CODE // these enum values are available in the flow namespace.
14{
27 PARAMS_ERROR = -8
28};
29
30// Particle is not expected to serve as a base class.
31class FLOW_API Particle final {
32public:
33 glm::vec3 location = {0.0f, 0.0f, 0.0f};
34 float value = 0.0f;
35 double time = 0.0;
36
37 // Constructors.
38 // This class complies with rule of zero.
39 Particle() = default;
40 Particle(const glm::vec3 &loc, double t, float val = 0.0f);
41 Particle(float x, float y, float z, double t, float val = 0.0f);
42
43 //
44 // The "property" field allows the user to keep one or more arbitrary values that
45 // are associated with this particle. It's up to the user to keep a record on
46 // what these values at each index stand for.
47 //
48 void AttachProperty(float v);
50 // Remove the property at a certain index.
51 // If the index is out of bound, then nothing is performed
52 void RemoveProperty(size_t i);
53
54 auto GetPropertyList() const -> const std::forward_list<float> &;
55
56 // A particle could be set to be at a special state.
57 void SetSpecial(bool isSpecial);
58 bool IsSpecial() const;
59
60private:
61 std::forward_list<float> _properties;
62 // Note on the choice of using a forward_list:
63 // Forward_list takes 8 bytes, whereas a vector or list take 24 bytes!
64 // Fun fact: the end() iterator of a forward_list is the nullptr.
65};
66
67}; // namespace flow
68
69#endif
Particle(const glm::vec3 &loc, double t, float val=0.0f)
void RemoveProperty(size_t i)
auto GetPropertyList() const -> const std::forward_list< float > &
Particle(float x, float y, float z, double t, float val=0.0f)
void AttachProperty(float v)
void ClearProperty()
Particle()=default
#define FLOW_API
Definition: common.h:75
Definition: Advection.h:15
FLOW_ERROR_CODE
Definition: Particle.h:14
@ SIZE_MISMATCH
Definition: Particle.h:26
@ TIME_ERROR
Definition: Particle.h:24
@ FILE_ERROR
Definition: Particle.h:23
@ OUT_OF_FIELD
Definition: Particle.h:20
@ PARAMS_ERROR
Definition: Particle.h:27
@ MISSING_VAL
Definition: Particle.h:16
@ GRID_ERROR
Definition: Particle.h:25
@ NO_SEED_PARTICLE_YET
Definition: Particle.h:22
@ SUCCESS
Definition: Particle.h:19
@ FIELD_ALL_ZERO
Definition: Particle.h:15
@ NO_FIELD_YET
Definition: Particle.h:21
@ NO_ADVECT_HAPPENED
Definition: Particle.h:17
@ ADVECT_HAPPENED
Definition: Particle.h:18