AutoPas  3.0.0
Loading...
Searching...
No Matches
NonConstructibleParticle.h
Go to the documentation of this file.
1
7#pragma once
8
10
15 public:
20
24 enum AttributeNames : int { ptr, id, posX, posY, posZ, forceX, forceY, forceZ, ownershipState };
25
30 typename autopas::utils::SoAType<NonConstructibleParticle *, size_t /*id*/, double /*x*/, double /*y*/,
31 double /*z*/, double /*fx*/, double /*fy*/, double /*fz*/,
32 autopas::OwnershipState /*ownershipState*/>::Type;
33
39 template <AttributeNames attribute, std::enable_if_t<attribute == AttributeNames::ptr, bool> = true>
40 constexpr typename std::tuple_element<attribute, SoAArraysType>::type::value_type get() {
41 return this;
42 }
43
50 template <AttributeNames attribute, std::enable_if_t<attribute != AttributeNames::ptr, bool> = true>
51 constexpr typename std::tuple_element<attribute, SoAArraysType>::type::value_type get() const {
52 if constexpr (attribute == AttributeNames::id) {
53 return getID();
54 } else if constexpr (attribute == AttributeNames::posX) {
55 return getR()[0];
56 } else if constexpr (attribute == AttributeNames::posY) {
57 return getR()[1];
58 } else if constexpr (attribute == AttributeNames::posZ) {
59 return getR()[2];
60 } else if constexpr (attribute == AttributeNames::forceX) {
61 return getF()[0];
62 } else if constexpr (attribute == AttributeNames::forceY) {
63 return getF()[1];
64 } else if constexpr (attribute == AttributeNames::forceZ) {
65 return getF()[2];
66 } else if constexpr (attribute == AttributeNames::ownershipState) {
67 return this->_ownershipState;
68 } else {
69 autopas::utils::ExceptionHandler::exception("ParticleBase::get() unknown attribute {}", attribute);
70 }
71 }
72};
A particle class without an actual constructor (only copy, etc.).
Definition: NonConstructibleParticle.h:14
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: NonConstructibleParticle.h:51
typename autopas::utils::SoAType< NonConstructibleParticle *, size_t, double, double, double, double, double, double, autopas::OwnershipState >::Type SoAArraysType
The type for the SoA storage.
Definition: NonConstructibleParticle.h:32
constexpr std::tuple_element< attribute, SoAArraysType >::type::value_type get()
Non-const getter for the pointer of this object.
Definition: NonConstructibleParticle.h:40
AttributeNames
Enums used as ids for accessing and creating a dynamically sized SoA.
Definition: NonConstructibleParticle.h:24
NonConstructibleParticle()=delete
Default constructor is deleted.
Minimal definition of a basic particle.
Definition: ParticleBase.h:33
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 > & getF() const
get the force acting on the particle
Definition: ParticleBase.h:135
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
OwnershipState
Enum that specifies the state of ownership.
Definition: OwnershipState.h:19
Helper struct to get a the SoAType.
Definition: SoAType.h:23