AutoPas  3.0.0
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Attributes | Friends | List of all members
autopas::ParticleBase< floatType, idType > Class Template Reference

Minimal definition of a basic particle. More...

#include <ParticleBase.h>

Inheritance diagram for autopas::ParticleBase< floatType, idType >:
Inheritance graph
[legend]

Public Types

enum  AttributeNames : int {
  ptr , id , posX , posY ,
  posZ , forceX , forceY , forceZ ,
  ownershipState
}
 Enums used as ids for accessing and creating a dynamically sized SoA.
 
using ParticleSoAFloatPrecision = floatType
 Floating Point Type used for this particle.
 
using ParticleIdType = idType
 Id Type used for this particle.
 
using SoAArraysType = typename autopas::utils::SoAType< ParticleBase< floatType, idType > *, idType, floatType, floatType, floatType, floatType, floatType, floatType, OwnershipState >::Type
 The type for the soa storage.
 

Public Member Functions

 ParticleBase (const std::array< double, 3 > &r, const std::array< double, 3 > &v, idType id, OwnershipState ownershipState=OwnershipState::owned)
 Constructor of the Particle class.
 
virtual ~ParticleBase ()=default
 Destructor of ParticleBase class.
 
bool operator== (const ParticleBase &rhs) const
 Equality operator for ParticleBase class.
 
bool operator!= (const ParticleBase &rhs) const
 Not-Equals operator for ParticleBase class.
 
const std::array< double, 3 > & getF () const
 get the force acting on the particle
 
void setF (const std::array< double, 3 > &f)
 Set the force acting on the particle.
 
void addF (const std::array< double, 3 > &f)
 Add a partial force to the force acting on the particle.
 
void subF (const std::array< double, 3 > &f)
 Substract a partial force from the force acting on the particle.
 
idType getID () const
 Get the id of the particle.
 
void setID (idType id)
 Set the id of the particle.
 
const std::array< double, 3 > & getR () const
 Get the position of the particle.
 
void setR (const std::array< double, 3 > &r)
 Set the position of the particle.
 
bool setRDistanceCheck (const std::array< double, 3 > &r, double maxDistSquared)
 Add a distance vector to the position of the particle and check if the distance between the old and new position is less than a given max distance.
 
void addR (const std::array< double, 3 > &r)
 Add a distance vector to the position of the particle.
 
bool addRDistanceCheck (const std::array< double, 3 > &r, double maxDistSquared)
 Add a distance vector to the position of the particle and check if the distance between the old and new position is less than a given max distance.
 
const std::array< double, 3 > & getV () const
 Get the velocity of the particle.
 
void setV (const std::array< double, 3 > &v)
 Set the velocity of the particle.
 
void addV (const std::array< double, 3 > &v)
 Add a vector to the current velocity of the particle.
 
virtual std::string toString () const
 Creates a string containing all data of the particle.
 
bool isOwned () const
 Defines whether the particle is owned by the current AutoPas object (aka (MPI-)process)
 
bool isHalo () const
 Defines whether the particle is a halo particle, i.e., not owned by the current AutoPas object (aka (MPI-)process)
 
bool isDummy () const
 Returns whether the particle is a dummy particle.
 
OwnershipState getOwnershipState () const
 Returns the particle's ownership state.
 
void setOwnershipState (OwnershipState ownershipState)
 Set the OwnershipState to the given value.
 
template<AttributeNames attribute, std::enable_if_t< attribute==AttributeNames::ptr, bool > = true>
constexpr std::tuple_element< attribute, SoAArraysType >::type::value_type get ()
 Non-const getter for the pointer of this object.
 
template<AttributeNames attribute, std::enable_if_t< attribute !=AttributeNames::ptr, bool > = true>
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 AttributeNames).
 
template<AttributeNames attribute>
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 AttributeNames).
 

Protected Attributes

std::array< floatType, 3 > _r
 Particle position as 3D coordinates.
 
std::array< floatType, 3 > _v
 Particle velocity as 3D vector.
 
std::array< floatType, 3 > _f
 Force the particle experiences as 3D vector.
 
idType _id
 Particle id.
 
OwnershipState _ownershipState
 Defines the state of the ownership of the particle.
 

Friends

template<typename T , typename P >
std::ostream & operator<< (std::ostream &os, const autopas::ParticleBase< T, P > &D)
 Stream operator for instances of ParticleBase class.
 
template<class T >
void internal::markParticleAsDeleted (T &)
 Function to access hidden particle.markAsDeleted() to mark it as internal.
 

Detailed Description

template<typename floatType, typename idType>
class autopas::ParticleBase< floatType, idType >

Minimal definition of a basic particle.

If a different Particle class should be used with AutoPas this class must be used as a base to build your own Particle class.

Template Parameters
floatTypeFloating point type to be used for the SoAs.
idTypeInteger type to be used for IDs.

Member Typedef Documentation

◆ SoAArraysType

template<typename floatType , typename idType >
using autopas::ParticleBase< floatType, idType >::SoAArraysType = typename autopas::utils::SoAType<ParticleBase<floatType, idType> *, idType , floatType , floatType , floatType , floatType , floatType , floatType , OwnershipState >::Type

The type for the soa storage.

owned is currently used as a floatType to ease calculations within the functors.

Constructor & Destructor Documentation

◆ ParticleBase()

template<typename floatType , typename idType >
autopas::ParticleBase< floatType, idType >::ParticleBase ( const std::array< double, 3 > &  r,
const std::array< double, 3 > &  v,
idType  id,
OwnershipState  ownershipState = OwnershipState::owned 
)
inline

Constructor of the Particle class.

Parameters
rPosition of the particle.
vVelocity of the particle.
idId of the particle.
ownershipStateOwnershipState of the particle (can be either owned, halo, or dummy)

Member Function Documentation

◆ addF()

template<typename floatType , typename idType >
void autopas::ParticleBase< floatType, idType >::addF ( const std::array< double, 3 > &  f)
inline

Add a partial force to the force acting on the particle.

Parameters
fpartial force to be added

◆ addR()

template<typename floatType , typename idType >
void autopas::ParticleBase< floatType, idType >::addR ( const std::array< double, 3 > &  r)
inline

Add a distance vector to the position of the particle.

Parameters
rvector to be added

◆ addRDistanceCheck()

template<typename floatType , typename idType >
bool autopas::ParticleBase< floatType, idType >::addRDistanceCheck ( const std::array< double, 3 > &  r,
double  maxDistSquared 
)
inline

Add a distance vector to the position of the particle and check if the distance between the old and new position is less than a given max distance.

This max distance usually should be the skin per timestep divided by two.

Note
uses setRDistanceCheck()
Parameters
rvector to be added
maxDistSquaredThe maximum expected movement distance squared.
Returns
true if dot(r - _r) < skinPerTimestepHalvedSquared

◆ addV()

template<typename floatType , typename idType >
void autopas::ParticleBase< floatType, idType >::addV ( const std::array< double, 3 > &  v)
inline

Add a vector to the current velocity of the particle.

Parameters
vvector to be added

◆ get() [1/2]

template<typename floatType , typename idType >
template<AttributeNames attribute, std::enable_if_t< attribute==AttributeNames::ptr, bool > = true>
constexpr std::tuple_element< attribute, SoAArraysType >::type::value_type autopas::ParticleBase< floatType, idType >::get ( )
inlineconstexpr

Non-const getter for the pointer of this object.

Template Parameters
attributeAttribute name.
Returns
this.

◆ get() [2/2]

template<typename floatType , typename idType >
template<AttributeNames attribute, std::enable_if_t< attribute !=AttributeNames::ptr, bool > = true>
constexpr std::tuple_element< attribute, SoAArraysType >::type::value_type autopas::ParticleBase< floatType, idType >::get ( ) const
inlineconstexpr

Getter, which allows access to an attribute using the corresponding attribute name (defined in AttributeNames).

Template Parameters
attributeAttribute name.
Returns
Value of the requested attribute.
Note
The value of owned is return as floating point number (true = 1.0, false = 0.0).

◆ getF()

template<typename floatType , typename idType >
const std::array< double, 3 > & autopas::ParticleBase< floatType, idType >::getF ( ) const
inline

get the force acting on the particle

Returns
force

◆ getID()

template<typename floatType , typename idType >
idType autopas::ParticleBase< floatType, idType >::getID ( ) const
inline

Get the id of the particle.

Returns
id

◆ getOwnershipState()

template<typename floatType , typename idType >
OwnershipState autopas::ParticleBase< floatType, idType >::getOwnershipState ( ) const
inline

Returns the particle's ownership state.

Returns
the current OwnershipState

◆ getR()

template<typename floatType , typename idType >
const std::array< double, 3 > & autopas::ParticleBase< floatType, idType >::getR ( ) const
inline

Get the position of the particle.

Returns
current position

◆ getV()

template<typename floatType , typename idType >
const std::array< double, 3 > & autopas::ParticleBase< floatType, idType >::getV ( ) const
inline

Get the velocity of the particle.

Returns
current velocity

◆ isDummy()

template<typename floatType , typename idType >
bool autopas::ParticleBase< floatType, idType >::isDummy ( ) const
inline

Returns whether the particle is a dummy particle.

Returns
true if the particle is a dummy.

◆ isHalo()

template<typename floatType , typename idType >
bool autopas::ParticleBase< floatType, idType >::isHalo ( ) const
inline

Defines whether the particle is a halo particle, i.e., not owned by the current AutoPas object (aka (MPI-)process)

Returns
true if the particle is not owned by the current AutoPas object, false otherwise.
Note
when a

◆ isOwned()

template<typename floatType , typename idType >
bool autopas::ParticleBase< floatType, idType >::isOwned ( ) const
inline

Defines whether the particle is owned by the current AutoPas object (aka (MPI-)process)

Returns
true if the particle is owned by the current AutoPas object, false otherwise

◆ operator!=()

template<typename floatType , typename idType >
bool autopas::ParticleBase< floatType, idType >::operator!= ( const ParticleBase< floatType, idType > &  rhs) const
inline

Not-Equals operator for ParticleBase class.

Parameters
rhs
Returns

◆ operator==()

template<typename floatType , typename idType >
bool autopas::ParticleBase< floatType, idType >::operator== ( const ParticleBase< floatType, idType > &  rhs) const
inline

Equality operator for ParticleBase class.

Parameters
rhs
Returns

◆ set()

template<typename floatType , typename idType >
template<AttributeNames attribute>
constexpr void autopas::ParticleBase< floatType, idType >::set ( typename std::tuple_element< attribute, SoAArraysType >::type::value_type  value)
inlineconstexpr

Setter, which allows set an attribute using the corresponding attribute name (defined in AttributeNames).

Template Parameters
attributeAttribute name.
Parameters
valueNew value of the requested attribute.
Note
The value of owned is extracted from a floating point number (true = 1.0, false = 0.0).

◆ setF()

template<typename floatType , typename idType >
void autopas::ParticleBase< floatType, idType >::setF ( const std::array< double, 3 > &  f)
inline

Set the force acting on the particle.

Parameters
fforce

◆ setID()

template<typename floatType , typename idType >
void autopas::ParticleBase< floatType, idType >::setID ( idType  id)
inline

Set the id of the particle.

Parameters
idid

◆ setOwnershipState()

template<typename floatType , typename idType >
void autopas::ParticleBase< floatType, idType >::setOwnershipState ( OwnershipState  ownershipState)
inline

Set the OwnershipState to the given value.

Parameters
ownershipState

◆ setR()

template<typename floatType , typename idType >
void autopas::ParticleBase< floatType, idType >::setR ( const std::array< double, 3 > &  r)
inline

Set the position of the particle.

Parameters
rnew position

◆ setRDistanceCheck()

template<typename floatType , typename idType >
bool autopas::ParticleBase< floatType, idType >::setRDistanceCheck ( const std::array< double, 3 > &  r,
double  maxDistSquared 
)
inline

Add a distance vector to the position of the particle and check if the distance between the old and new position is less than a given max distance.

This max distance usually should be the skin per timestep divided by two.

Parameters
rvector to be added
maxDistSquaredThe maximum expected movement distance squared.
Returns
true if dot(r - _r) < skinPerTimestepHalvedSquared

◆ setV()

template<typename floatType , typename idType >
void autopas::ParticleBase< floatType, idType >::setV ( const std::array< double, 3 > &  v)
inline

Set the velocity of the particle.

Parameters
vnew velocity

◆ subF()

template<typename floatType , typename idType >
void autopas::ParticleBase< floatType, idType >::subF ( const std::array< double, 3 > &  f)
inline

Substract a partial force from the force acting on the particle.

Parameters
fpartial force to be substracted

◆ toString()

template<typename floatType , typename idType >
virtual std::string autopas::ParticleBase< floatType, idType >::toString ( ) const
inlinevirtual

Creates a string containing all data of the particle.

Returns
String representation.

Reimplemented in mdLib::MoleculeLJ, and mdLib::MultisiteMoleculeLJ.

Friends And Related Symbol Documentation

◆ internal::markParticleAsDeleted

template<typename floatType , typename idType >
template<class T >
void internal::markParticleAsDeleted ( T &  )
friend

Function to access hidden particle.markAsDeleted() to mark it as internal.

Template Parameters
ParticleIterator

◆ operator<<

template<typename floatType , typename idType >
template<typename T , typename P >
std::ostream & operator<< ( std::ostream &  os,
const autopas::ParticleBase< T, P > &  D 
)
friend

Stream operator for instances of ParticleBase class.

Returns
String representation.

The documentation for this class was generated from the following file: