AutoPas  3.0.0
Loading...
Searching...
No Matches
MultisiteMoleculeLJ.h
Go to the documentation of this file.
1
7#pragma once
8
9#include "MoleculeLJ.h"
12
13namespace mdLib {
23 using idType = size_t;
24
25 public:
26 MultisiteMoleculeLJ() = default;
27
38 MultisiteMoleculeLJ(std::array<double, 3> r, std::array<double, 3> v, std::array<double, 4> q,
39 std::array<double, 3> angularVel, unsigned long moleculeId, unsigned long typeId = 0);
40
44 ~MultisiteMoleculeLJ() override = default;
45
49 enum AttributeNames : int {
50 ptr,
51 id,
52 posX,
53 posY,
54 posZ,
55 velocityX,
56 velocityY,
57 velocityZ,
58 forceX,
59 forceY,
60 forceZ,
61 oldForceX,
62 oldForceY,
63 oldForceZ,
64 quaternion0,
65 quaternion1,
66 quaternion2,
67 quaternion3,
68 angularVelX,
69 angularVelY,
70 angularVelZ,
71 torqueX,
72 torqueY,
73 torqueZ,
74 typeId,
75 ownershipState
76 };
77
85 // clang-format off
88 size_t, // id
89 double, // x
90 double, // y
91 double, // z
92 double, // vx
93 double, // vy
94 double, // vz
95 double, // fx
96 double, // fy
97 double, // fz
98 double, // oldFx
99 double, // oldFy
100 double, // oldFz
101 double, // q0
102 double, // q1
103 double, // q2
104 double, // q3
105 double, // angVx
106 double, // angVy
107 double, // angVz
108 double, // tx
109 double, // ty
110 double, // tz
111 size_t, // typeid
112 autopas::OwnershipState //ownerState
113 >::Type;
114 // clang-format on
115
121 template <AttributeNames attribute, std::enable_if_t<attribute == AttributeNames::ptr, bool> = true>
122 constexpr typename std::tuple_element<attribute, SoAArraysType>::type::value_type get() {
123 return this;
124 }
125
133 template <AttributeNames attribute, std::enable_if_t<attribute != AttributeNames::ptr, bool> = true>
134 constexpr typename std::tuple_element<attribute, SoAArraysType>::type::value_type get() const {
135 if constexpr (attribute == AttributeNames::id) {
136 return getID();
137 } else if constexpr (attribute == AttributeNames::posX) {
138 return getR()[0];
139 } else if constexpr (attribute == AttributeNames::posY) {
140 return getR()[1];
141 } else if constexpr (attribute == AttributeNames::posZ) {
142 return getR()[2];
143 } else if constexpr (attribute == AttributeNames::velocityX) {
144 return getV()[0];
145 } else if constexpr (attribute == AttributeNames::velocityY) {
146 return getV()[1];
147 } else if constexpr (attribute == AttributeNames::velocityZ) {
148 return getV()[2];
149 } else if constexpr (attribute == AttributeNames::forceX) {
150 return getF()[0];
151 } else if constexpr (attribute == AttributeNames::forceY) {
152 return getF()[1];
153 } else if constexpr (attribute == AttributeNames::forceZ) {
154 return getF()[2];
155 } else if constexpr (attribute == AttributeNames::oldForceX) {
156 return getOldF()[0];
157 } else if constexpr (attribute == AttributeNames::oldForceY) {
158 return getOldF()[1];
159 } else if constexpr (attribute == AttributeNames::oldForceZ) {
160 return getOldF()[2];
161 } else if constexpr (attribute == AttributeNames::quaternion0) {
162 return getQuaternion()[0];
163 } else if constexpr (attribute == AttributeNames::quaternion1) {
164 return getQuaternion()[1];
165 } else if constexpr (attribute == AttributeNames::quaternion2) {
166 return getQuaternion()[2];
167 } else if constexpr (attribute == AttributeNames::quaternion3) {
168 return getQuaternion()[3];
169 } else if constexpr (attribute == AttributeNames::angularVelX) {
170 return getAngularVel()[0];
171 } else if constexpr (attribute == AttributeNames::angularVelY) {
172 return getAngularVel()[1];
173 } else if constexpr (attribute == AttributeNames::angularVelZ) {
174 return getAngularVel()[2];
175 } else if constexpr (attribute == AttributeNames::torqueX) {
176 return getTorque()[0];
177 } else if constexpr (attribute == AttributeNames::torqueY) {
178 return getTorque()[1];
179 } else if constexpr (attribute == AttributeNames::torqueZ) {
180 return getTorque()[2];
181 } else if constexpr (attribute == AttributeNames::typeId) {
182 return getTypeId();
183 } else if constexpr (attribute == AttributeNames::ownershipState) {
184 return this->_ownershipState;
185 } else {
186 autopas::utils::ExceptionHandler::exception("MultisiteMoleculeLJ::get() unknown attribute {}", attribute);
187 }
188 }
189
197 template <AttributeNames attribute>
198 constexpr void set(typename std::tuple_element<attribute, SoAArraysType>::type::value_type value) {
199 if constexpr (attribute == AttributeNames::id) {
200 setID(value);
201 } else if constexpr (attribute == AttributeNames::posX) {
202 _r[0] = value;
203 } else if constexpr (attribute == AttributeNames::posY) {
204 _r[1] = value;
205 } else if constexpr (attribute == AttributeNames::posZ) {
206 _r[2] = value;
207 } else if constexpr (attribute == AttributeNames::velocityX) {
208 _v[0] = value;
209 } else if constexpr (attribute == AttributeNames::velocityY) {
210 _v[1] = value;
211 } else if constexpr (attribute == AttributeNames::velocityZ) {
212 _v[2] = value;
213 } else if constexpr (attribute == AttributeNames::forceX) {
214 _f[0] = value;
215 } else if constexpr (attribute == AttributeNames::forceY) {
216 _f[1] = value;
217 } else if constexpr (attribute == AttributeNames::forceZ) {
218 _f[2] = value;
219 } else if constexpr (attribute == AttributeNames::oldForceX) {
220 _oldF[0] = value;
221 } else if constexpr (attribute == AttributeNames::oldForceY) {
222 _oldF[1] = value;
223 } else if constexpr (attribute == AttributeNames::oldForceZ) {
224 _oldF[2] = value;
225 } else if constexpr (attribute == AttributeNames::quaternion0) {
226 _q[0] = value;
227 } else if constexpr (attribute == AttributeNames::quaternion1) {
228 _q[1] = value;
229 } else if constexpr (attribute == AttributeNames::quaternion2) {
230 _q[2] = value;
231 } else if constexpr (attribute == AttributeNames::quaternion3) {
232 _q[3] = value;
233 } else if constexpr (attribute == AttributeNames::angularVelX) {
234 _angularVel[0] = value;
235 } else if constexpr (attribute == AttributeNames::angularVelY) {
236 _angularVel[1] = value;
237 } else if constexpr (attribute == AttributeNames::angularVelZ) {
238 _angularVel[2] = value;
239 } else if constexpr (attribute == AttributeNames::torqueX) {
240 _torque[0] = value;
241 } else if constexpr (attribute == AttributeNames::torqueY) {
242 _torque[1] = value;
243 } else if constexpr (attribute == AttributeNames::torqueZ) {
244 _torque[2] = value;
245 } else if constexpr (attribute == AttributeNames::typeId) {
246 _typeId = value;
247 } else if constexpr (attribute == AttributeNames::ownershipState) {
248 this->_ownershipState = value;
249 } else {
250 autopas::utils::ExceptionHandler::exception("MultisiteMoleculeLJ::set() unknown attribute {}", attribute);
251 }
252 }
253
258 [[nodiscard]] const std::array<double, 4> &getQuaternion() const;
259
264 void setQuaternion(const std::array<double, 4> &q);
265
270 [[nodiscard]] const std::array<double, 3> &getAngularVel() const;
271
276 void setAngularVel(const std::array<double, 3> &angularVel);
277
282 void addAngularVel(const std::array<double, 3> &angularVel);
283
288 [[nodiscard]] const std::array<double, 3> &getTorque() const;
289
294 void setTorque(const std::array<double, 3> &torque);
295
300 void addTorque(const std::array<double, 3> &torque);
301
306 void subTorque(const std::array<double, 3> &torque);
307
312 [[nodiscard]] std::string toString() const override;
313
314 protected:
318 std::array<double, 4> _q{};
319
323 std::array<double, 3> _angularVel{};
324
328 std::array<double, 3> _torque{};
329};
330
331} // namespace mdLib
void setID(idType id)
Set the id of the particle.
Definition: ParticleBase.h:171
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
std::array< floatType, 3 > _f
Force the particle experiences as 3D vector.
Definition: ParticleBase.h:95
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 > & 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
Molecule class for the LJFunctor.
Definition: MoleculeLJ.h:20
size_t getTypeId() const
Get TypeId.
Definition: MoleculeLJ.cpp:17
const std::array< double, 3 > & getOldF() const
Get the old force.
Definition: MoleculeLJ.cpp:14
std::array< double, 3 > _oldF
Old Force of the particle experiences as 3D vector.
Definition: MoleculeLJ.h:211
size_t _typeId
Molecule type id.
Definition: MoleculeLJ.h:206
Standard multi-site LJ molecules.
Definition: MultisiteMoleculeLJ.h:22
std::string toString() const override
Creates a string containing all data of the particle.
Definition: MultisiteMoleculeLJ.cpp:33
void subTorque(const std::array< double, 3 > &torque)
Subracts given torque to the particle's torque.
Definition: MultisiteMoleculeLJ.cpp:29
std::array< double, 3 > _angularVel
Angular velocity of the particle.
Definition: MultisiteMoleculeLJ.h:323
const std::array< double, 3 > & getTorque() const
Get the torque.
Definition: MultisiteMoleculeLJ.cpp:24
void addAngularVel(const std::array< double, 3 > &angularVel)
Adds given angular velocity to the particle's angular velocity.
Definition: MultisiteMoleculeLJ.cpp:20
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: MultisiteMoleculeLJ.h:198
void setTorque(const std::array< double, 3 > &torque)
Set the torque.
Definition: MultisiteMoleculeLJ.cpp:25
void setAngularVel(const std::array< double, 3 > &angularVel)
Set the angular velocity.
Definition: MultisiteMoleculeLJ.cpp:19
std::array< double, 3 > _torque
Torque applied to particle.
Definition: MultisiteMoleculeLJ.h:328
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: MultisiteMoleculeLJ.h:134
~MultisiteMoleculeLJ() override=default
Destructor of the MultisiteMoleculeLJ class.
const std::array< double, 4 > & getQuaternion() const
Get the quaternion defining rotation.
Definition: MultisiteMoleculeLJ.cpp:15
void setQuaternion(const std::array< double, 4 > &q)
Set the quaternion defining rotation.
Definition: MultisiteMoleculeLJ.cpp:16
const std::array< double, 3 > & getAngularVel() const
Get the angular velocity.
Definition: MultisiteMoleculeLJ.cpp:18
AttributeNames
Enums used as ids for accessing and creating a dynamically sized SoA.
Definition: MultisiteMoleculeLJ.h:49
void addTorque(const std::array< double, 3 > &torque)
Adds given torque to the particle's torque.
Definition: MultisiteMoleculeLJ.cpp:26
typename autopas::utils::SoAType< MultisiteMoleculeLJ *, size_t, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, double, size_t, autopas::OwnershipState >::Type SoAArraysType
The type for the SoA storage.
Definition: MultisiteMoleculeLJ.h:113
std::array< double, 4 > _q
Rotational direction of particle as quaternion.
Definition: MultisiteMoleculeLJ.h:318
constexpr std::tuple_element< attribute, SoAArraysType >::type::value_type get()
Non-const getter for the pointer of this object.
Definition: MultisiteMoleculeLJ.h:122
OwnershipState
Enum that specifies the state of ownership.
Definition: OwnershipState.h:19
Helper struct to get a the SoAType.
Definition: SoAType.h:23