1 #include "computational_cell_2d.hpp" 2 #include "../../misc/utils.hpp" 7 density(0), pressure(0), velocity(
Vector2D()), tracers(),
30 size_t N = this->
tracers.size();
31 for (
size_t j = 0; j < N; ++j)
42 size_t N = this->
tracers.size();
43 for (
size_t j = 0; j < N; ++j)
53 size_t N = this->
tracers.size();
54 for (
size_t j = 0; j < N; ++j)
66 for (
size_t j = 0; j < N; ++j)
90 for (
size_t j = 0; j < N; ++j)
102 for (
size_t j = 0; j < N; ++j)
118 size_t N = other.
tracers.size();
120 for (
size_t j = 0; j < N; ++j)
124 for (
size_t i = 0; i < N; ++i)
134 size_t N = first.
tracers.size();
136 for (
size_t j = 0; j < N; ++j)
141 for (
size_t i = 0; i < N; ++i)
153 tracer_names = other.tracer_names;
154 sticker_names = other.sticker_names;
159 : tracer_names(vector<string>()), sticker_names(vector<string>()) {}
166 (
const std::vector<std::string>& tracers,
167 const std::vector<std::string>& stickers):
173 return 4 + tracers.size() + stickers.size();
178 vector<double> res (getChunkSize());
180 res.at(1) = pressure;
181 res.at(2) = velocity.x;
182 res.at(3) = velocity.y;
184 size_t N = tracers.size();
185 for (
size_t j = 0; j < N ; ++j)
186 res[j+counter] = tracers[j];
187 size_t N2 = stickers.size();
188 for (
size_t j = 0; j < N2; ++j)
189 res[j + counter + N] = stickers[j] ? 1 : 0;
194 (
const vector<double>& data)
196 assert(data.size()==getChunkSize());
197 density = data.at(0);
198 pressure = data.at(1);
199 velocity.x = data.at(2);
200 velocity.y = data.at(3);
202 size_t N = tracers.size();
203 for (
size_t j = 0; j < N; ++j)
204 tracers[j] = data.at(counter + j);
205 size_t N2 = stickers.size();
206 for (
size_t i = 0; i < N2; ++i)
207 stickers[i] = data.at(counter + N + i)>0.5;
212 return xderivative.getChunkSize() * 2;
217 vector<double> res(getChunkSize());
218 vector<double> temp(xderivative.serialize());
219 std::copy(temp.begin(), temp.end(), res.begin());
220 temp = yderivative.serialize();
221 std::copy(temp.begin(), temp.end(), res.begin() + xderivative.getChunkSize());
227 size_t size = xderivative.getChunkSize();
228 xderivative.unserialize(vector<double>(data.begin(), data.begin() + size));
229 yderivative.unserialize(vector<double>(data.begin() + size, data.end()));
ComputationalCell & operator*=(double s)
Self multiplication operator.
std::vector< std::string > sticker_names
The names of the stickers.
void unserialize(const vector< double > &data)
Convert an array of numbers to an object.
vector< double > serialize(void) const
Convert an object to an array of numbers.
size_t getChunkSize(void) const
Returns the size of array needed to store all data.
size_t getChunkSize(void) const
Returns the size of array needed to store all data.
~TracerStickerNames(void)
Class destructor.
tvector tracers
Tracers (can transfer from one cell to another)
Vector3D operator*(double d, Vector3D const &v)
Scalar product.
ComputationalCell xderivative
Slope in the x direction.
vector< double > serialize(void) const
Convert an object to an array of numbers.
ComputationalCell & operator=(ComputationalCell const &other)
Self decrement operator.
Vector3D operator/(Vector3D const &v, double d)
Scalar division.
ComputationalCell & operator+=(ComputationalCell const &other)
Self increment operator.
std::vector< std::string > tracer_names
The names of the tracers.
svector stickers
Stickers (stick to the same cell)
Class for keeping the names of the tracers and stickers.
ComputationalCell(void)
Default constructor.
Vector3D operator+(Vector3D const &v1, Vector3D const &v2)
Term by term addition.
void unserialize(const vector< double > &data)
Convert an array of numbers to an object.
Slope(void)
Default constructor.
ComputationalCell & operator-=(ComputationalCell const &other)
Self reduction operator.
Vector2D velocity
Velocity.
TracerStickerNames(void)
Default constructor.
Vector3D operator-(Vector3D const &v1, Vector3D const &v2)
Term by term subtraction.
ComputationalCell yderivative
Slope in the y direction.