VAPOR3
3.9.4
include
vapor
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
12
namespace
flow
{
13
enum
FLOW_ERROR_CODE
// these enum values are available in the flow namespace.
14
{
15
FIELD_ALL_ZERO
= 4,
16
MISSING_VAL
= 3,
17
NO_ADVECT_HAPPENED
= 2,
18
ADVECT_HAPPENED
= 1,
19
SUCCESS
= 0,
20
OUT_OF_FIELD
= -1,
21
NO_FIELD_YET
= -2,
22
NO_SEED_PARTICLE_YET
= -3,
23
FILE_ERROR
= -4,
24
TIME_ERROR
= -5,
25
GRID_ERROR
= -6,
26
SIZE_MISMATCH
= -7,
27
PARAMS_ERROR
= -8
28
};
29
30
// Particle is not expected to serve as a base class.
31
class
FLOW_API
Particle
final {
32
public
:
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);
49
void
ClearProperty
();
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
60
private:
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
flow::Particle
Definition:
Particle.h:31
flow::Particle::Particle
Particle(const glm::vec3 &loc, double t, float val=0.0f)
flow::Particle::RemoveProperty
void RemoveProperty(size_t i)
flow::Particle::GetPropertyList
auto GetPropertyList() const -> const std::forward_list< float > &
flow::Particle::Particle
Particle(float x, float y, float z, double t, float val=0.0f)
flow::Particle::AttachProperty
void AttachProperty(float v)
flow::Particle::ClearProperty
void ClearProperty()
flow::Particle::Particle
Particle()=default
common.h
FLOW_API
#define FLOW_API
Definition:
common.h:75
flow
Definition:
Advection.h:15
flow::FLOW_ERROR_CODE
FLOW_ERROR_CODE
Definition:
Particle.h:14
flow::SIZE_MISMATCH
@ SIZE_MISMATCH
Definition:
Particle.h:26
flow::TIME_ERROR
@ TIME_ERROR
Definition:
Particle.h:24
flow::FILE_ERROR
@ FILE_ERROR
Definition:
Particle.h:23
flow::OUT_OF_FIELD
@ OUT_OF_FIELD
Definition:
Particle.h:20
flow::PARAMS_ERROR
@ PARAMS_ERROR
Definition:
Particle.h:27
flow::MISSING_VAL
@ MISSING_VAL
Definition:
Particle.h:16
flow::GRID_ERROR
@ GRID_ERROR
Definition:
Particle.h:25
flow::NO_SEED_PARTICLE_YET
@ NO_SEED_PARTICLE_YET
Definition:
Particle.h:22
flow::SUCCESS
@ SUCCESS
Definition:
Particle.h:19
flow::FIELD_ALL_ZERO
@ FIELD_ALL_ZERO
Definition:
Particle.h:15
flow::NO_FIELD_YET
@ NO_FIELD_YET
Definition:
Particle.h:21
flow::NO_ADVECT_HAPPENED
@ NO_ADVECT_HAPPENED
Definition:
Particle.h:17
flow::ADVECT_HAPPENED
@ ADVECT_HAPPENED
Definition:
Particle.h:18
Generated by
1.9.6