37 _vel_half{0., 0., 0.},
45 SPHParticle(
const std::array<double, 3> &r,
const std::array<double, 3> &v,
unsigned long id)
46 :
autopas::ParticleBaseFP64(r, v, id),
58 _vel_half{0., 0., 0.},
70 SPHParticle(
const std::array<double, 3> &r,
const std::array<double, 3> &v,
unsigned long id,
double mass,
71 double smth,
double snds)
72 :
autopas::ParticleBaseFP64(r, v, id),
84 _vel_half{0., 0., 0.},
181 void setVSigMax(
double v_sig_max) { _v_sig_max = v_sig_max; }
220 void addEngDot(
double eng_dot) { _energy_dot += eng_dot; }
226 void setEngDot(
double eng_dot) { _energy_dot = eng_dot; }
250 double getDt()
const {
return _dt; }
263 const double C_CFL = 0.3;
264 _dt = C_CFL * 2.0 * _smth / _v_sig_max;
271 const std::array<double, 3> &
getVel_half()
const {
return _vel_half; }
277 void setVel_half(
const std::array<double, 3> &vel_half) { SPHParticle::_vel_half = vel_half; }
289 void setEng_half(
double eng_half) { SPHParticle::_eng_half = eng_half; }
296 std::vector<double> stream;
297 for (
int i = 0; i < 3; i++) {
298 stream.push_back(this->
getR()[i]);
300 for (
int i = 0; i < 3; i++) {
301 stream.push_back(this->
getV()[i]);
304 for (
int i = 0; i < 3; i++) {
307 auto id = this->
getID();
309 memcpy(&id_dbl, &
id,
sizeof(
double));
310 static_assert(
sizeof(id) ==
sizeof(
double),
"sizes should be the same, otherwise the above will not work");
312 stream.push_back(id_dbl);
313 stream.push_back(_density);
314 stream.push_back(_pressure);
315 stream.push_back(_mass);
316 stream.push_back(_smth);
317 stream.push_back(_snds);
319 for (
int i = 0; i < 3; i++) {
322 stream.push_back(_energy_dot);
323 stream.push_back(_energy);
325 for (
int i = 0; i < 3; i++) {
328 stream.push_back(_eng_half);
340 std::array<double, 3> r = {stream[index], stream[index + 1], stream[index + 2]};
342 std::array<double, 3> v = {stream[index], stream[index + 1], stream[index + 2]};
347 double id_dbl = stream[index++];
349 memcpy(&
id, &id_dbl,
sizeof(
double));
350 static_assert(
sizeof(id) ==
sizeof(
double),
"sizes should be the same, otherwise the above will not work");
352 double density = stream[index++];
353 double pressure = stream[index++];
355 double mass = stream[index++];
356 double smth = stream[index++];
357 double snds = stream[index++];
359 std::array<double, 3> ac = {stream[index], stream[index + 1], stream[index + 2]};
361 double energy_dot = stream[index++];
362 double energy = stream[index++];
364 std::array<double, 3> vel_half = {stream[index], stream[index + 1], stream[index + 2]};
366 double eng_half = stream[index++];
430 template <AttributeNames attribute, std::enable_if_t<attribute == AttributeNames::ptr,
bool> = true>
431 constexpr typename std::tuple_element<attribute, SoAArraysType>::type::value_type
get() {
440 template <AttributeNames attribute, std::enable_if_t<attribute != AttributeNames::ptr,
bool> = true>
441 constexpr typename std::tuple_element<attribute, SoAArraysType>::type::value_type
get()
const {
442 if constexpr (attribute == AttributeNames::mass) {
444 }
else if constexpr (attribute == AttributeNames::posX) {
446 }
else if constexpr (attribute == AttributeNames::posY) {
448 }
else if constexpr (attribute == AttributeNames::posZ) {
450 }
else if constexpr (attribute == AttributeNames::smth) {
452 }
else if constexpr (attribute == AttributeNames::density) {
454 }
else if constexpr (attribute == AttributeNames::velX) {
456 }
else if constexpr (attribute == AttributeNames::velY) {
458 }
else if constexpr (attribute == AttributeNames::velZ) {
460 }
else if constexpr (attribute == AttributeNames::soundSpeed) {
462 }
else if constexpr (attribute == AttributeNames::pressure) {
464 }
else if constexpr (attribute == AttributeNames::vsigmax) {
466 }
else if constexpr (attribute == AttributeNames::accX) {
468 }
else if constexpr (attribute == AttributeNames::accY) {
470 }
else if constexpr (attribute == AttributeNames::accZ) {
472 }
else if constexpr (attribute == AttributeNames::engDot) {
474 }
else if constexpr (attribute == AttributeNames::ownershipState) {
486 template <AttributeNames attribute>
487 constexpr void set(
typename std::tuple_element<attribute, SoAArraysType>::type::value_type value) {
488 if constexpr (attribute == AttributeNames::mass) {
490 }
else if constexpr (attribute == AttributeNames::posX) {
492 }
else if constexpr (attribute == AttributeNames::posY) {
494 }
else if constexpr (attribute == AttributeNames::posZ) {
496 }
else if constexpr (attribute == AttributeNames::smth) {
498 }
else if constexpr (attribute == AttributeNames::density) {
500 }
else if constexpr (attribute == AttributeNames::velX) {
502 }
else if constexpr (attribute == AttributeNames::velY) {
504 }
else if constexpr (attribute == AttributeNames::velZ) {
506 }
else if constexpr (attribute == AttributeNames::soundSpeed) {
508 }
else if constexpr (attribute == AttributeNames::pressure) {
510 }
else if constexpr (attribute == AttributeNames::vsigmax) {
512 }
else if constexpr (attribute == AttributeNames::accX) {
514 }
else if constexpr (attribute == AttributeNames::accY) {
516 }
else if constexpr (attribute == AttributeNames::accZ) {
518 }
else if constexpr (attribute == AttributeNames::engDot) {
520 }
else if constexpr (attribute == AttributeNames::ownershipState) {
538 std::array<double, 3> _acc;
544 std::array<double, 3> _vel_half;
Minimal definition of a basic particle.
Definition: ParticleBase.h:33
std::array< floatType, 3 > _r
Particle position as 3D coordinates.
Definition: ParticleBase.h:78
OwnershipState _ownershipState
Defines the state of the ownership of the particle.
Definition: ParticleBase.h:105
idType getID() const
Get the id of the particle.
Definition: ParticleBase.h:165
const std::array< double, 3 > & getV() const
Get the velocity of the particle.
Definition: ParticleBase.h:265
std::array< floatType, 3 > _v
Particle velocity as 3D vector.
Definition: ParticleBase.h:90
const std::array< double, 3 > & getR() const
Get the position of the particle.
Definition: ParticleBase.h:177
static void exception(const Exception e)
Handle an exception derived by std::exception.
Definition: ExceptionHandler.h:63
Basic SPHParticle class.
Definition: SPHParticle.h:18
const std::array< double, 3 > & getVel_half() const
Getter for velocity at half-time step (leapfrog)
Definition: SPHParticle.h:271
double getEngDot() const
Getter for the time derivative of the energy of the particle.
Definition: SPHParticle.h:213
void setSoundSpeed(double snds)
Setter for the speed of sound of the particle.
Definition: SPHParticle.h:162
SPHParticle(const std::array< double, 3 > &r, const std::array< double, 3 > &v, unsigned long id)
Constructor of the SPHParticle class.
Definition: SPHParticle.h:45
void addDensity(double density)
Adds the given density to the current density.
Definition: SPHParticle.h:102
void addEnergy(double energy)
Adds the given energy to the energy of the particle.
Definition: SPHParticle.h:244
AttributeNames
Attribute names for the soa arrays.
Definition: SPHParticle.h:382
constexpr std::tuple_element< attribute, SoAArraysType >::type::value_type get() const
Getter, which allows access to an attribute using the corresponding attribute name (defined in Attrib...
Definition: SPHParticle.h:441
void addAcceleration(const std::array< double, 3 > &acc)
Adds the given acceleration on the local acceleration.
Definition: SPHParticle.cpp:15
void setEngDot(double eng_dot)
Setter for the time derivative of the energy.
Definition: SPHParticle.h:226
autopas::utils::SoAType< SPHParticle *, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, autopas::OwnershipState >::Type SoAArraysType
SoA arrays type, cf.
Definition: SPHParticle.h:423
void setDt(double dt)
Set the maximally allowed time step for this particle.
Definition: SPHParticle.h:256
double getSmoothingLength() const
Getter for the smoothing length of the particle.
Definition: SPHParticle.h:144
void setDensity(double density)
Setter for Density.
Definition: SPHParticle.h:108
void setEng_half(double eng_half)
Setter for energy at half-time step (leapfrog)
Definition: SPHParticle.h:289
void setPressure(double pressure)
Setter for the pressure.
Definition: SPHParticle.h:126
void calcPressure()
Calculates the pressure within the particle from the energy and density of the particle and updates t...
Definition: SPHParticle.cpp:25
void setEnergy(double energy)
Setter for the energy of the particle.
Definition: SPHParticle.h:238
double getDensity() const
Getter for the Density.
Definition: SPHParticle.h:96
double getDt() const
Getter for the maximally allowed time step for this particle.
Definition: SPHParticle.h:250
double getPressure() const
Getter for Pressure.
Definition: SPHParticle.h:114
void setVSigMax(double v_sig_max)
Setter for the maximally allowed signal velocity.
Definition: SPHParticle.h:181
~SPHParticle() override=default
Destructor of the SPHParticle.
std::vector< double > serialize() const
function to serialize an SPHParticle
Definition: SPHParticle.h:295
void addEngDot(double eng_dot)
Adds the given value to the current value of the time derivative of the energy.
Definition: SPHParticle.h:220
double getMass() const
Getter for the mass of the particle.
Definition: SPHParticle.h:132
SPHParticle()
Default constructor of SPHParticle.
Definition: SPHParticle.h:24
void checkAndSetVSigMax(double v_sig)
Checks if the given signal velocity is higher than the current (local) one and updates the local one ...
Definition: SPHParticle.h:175
double getVSigMax() const
Getter for the current maximally allowed signal velocity of the particle.
Definition: SPHParticle.h:168
void setAcceleration(const std::array< double, 3 > &acc)
Setter for the acceleration.
Definition: SPHParticle.h:207
void subAcceleration(const std::array< double, 3 > &acc)
Substracts the given acceleration from the local acceleration.
Definition: SPHParticle.cpp:20
const std::array< double, 3 > & getAcceleration() const
Getter for the acceleration of the particle.
Definition: SPHParticle.h:187
SPHParticle(const std::array< double, 3 > &r, const std::array< double, 3 > &v, unsigned long id, double mass, double smth, double snds)
Constructor of the SPHParticle class.
Definition: SPHParticle.h:70
constexpr std::tuple_element< attribute, SoAArraysType >::type::value_type get()
Non-const getter for the pointer of this object.
Definition: SPHParticle.h:431
double getSoundSpeed() const
Getter for the speed of sound of the particle.
Definition: SPHParticle.h:156
void setVel_half(const std::array< double, 3 > &vel_half)
Setter for velocity at half-time step (leapfrog)
Definition: SPHParticle.h:277
constexpr void set(typename std::tuple_element< attribute, SoAArraysType >::type::value_type value)
Setter, which allows set an attribute using the corresponding attribute name (defined in AttributeNam...
Definition: SPHParticle.h:487
void calcDt()
Calculate the maximally allowed time step for the particle based on the smoothing length and the sign...
Definition: SPHParticle.h:262
void setSmoothingLength(double smth)
Setter for the smoothing length.
Definition: SPHParticle.h:150
void setMass(double mass)
Setter for the mass of the particle.
Definition: SPHParticle.h:138
double getEng_half() const
Getter for energy at half-time step (leapfrog)
Definition: SPHParticle.h:283
static SPHParticle deserialize(const double *stream, size_t &index)
funtion to deserialize an SPHParticle
Definition: SPHParticle.h:339
double getEnergy() const
Getter for the energy of the particle.
Definition: SPHParticle.h:232
This is the main namespace of AutoPas.
Definition: AutoPasDecl.h:32
OwnershipState
Enum that specifies the state of ownership.
Definition: OwnershipState.h:19
Helper struct to get a the SoAType.
Definition: SoAType.h:23