walberla::pe::Union< BodyTypes > Class Template Reference

Detailed Description

template<typename... BodyTypes>
class walberla::pe::Union< BodyTypes >

Base class for the union geometry, a rigid assembly of bodies.

The Union class represents the base class for the sphere geometry. For a full description of the union geometry, see the Union class description.

#include <Types.h>

Public Types

using size_type = BodyStorage::size_type
 Size type of the body storage. More...
 
using iterator = BodyStorage::iterator
 Iterator over non-const bodies. More...
 
using const_iterator = BodyStorage::const_iterator
 Iterator over constant bodies. More...
 
template<typename C >
using cast_iterator = BodyStorage::cast_iterator< C >
 
template<typename C >
using const_cast_iterator = BodyStorage::const_cast_iterator< C >
 

Public Member Functions

Constructors
 Union (id_t sid, id_t uid, const Vec3 &gpos, const Quat &q, const bool global, const bool communicating, const bool infiniteMass)
 Constructor for the Sphere class. More...
 
Destructor
 ~Union () override
 Destructor for the Union class. More...
 
BodyStorage functions
bool isEmpty () const
 
size_t size () const
 
iterator begin ()
 
const_iterator begin () const
 
const_iterator cbegin () const
 
iterator end ()
 
const_iterator end () const
 
const_iterator cend () const
 
template<typename C >
cast_iterator< C > begin ()
 
template<typename C >
const_cast_iterator< C > begin () const
 
template<typename C >
const_cast_iterator< C > cbegin () const
 
template<typename C >
cast_iterator< C > end ()
 
template<typename C >
const_cast_iterator< C > end () const
 
template<typename C >
const_cast_iterator< C > cend () const
 
real_t getVolume () const override
 Returns the volume of the union. More...
 
Set functions
void setRemote (bool remote) override
 Setting the remote flag of the union and all contained bodies. More...
 
bool hasSubBodies () const override
 
Signal functions
void handleModification () override
 Signals an internal modification of a contained subordinate rigid body. More...
 
void handleTranslation () override
 Signals a position change of a contained subordinate rigid body. More...
 
void handleRotation () override
 Signals an orientation change of a contained subordinate rigid body. More...
 
Rigid body manager functions
RigidBodyadd (std::unique_ptr< RigidBody > &&body)
 Adding a rigid body to the union. More...
 
Output functions
void print (std::ostream &os, const char *tab) const override
 Output of the current state of an union. More...
 

Utility functions

BodyStorage bodies_
 Rigid bodies contained in the union. More...
 
std::vector< id_tcontainedTypeIDs_
 
static id_t staticTypeID_ = std::numeric_limits<id_t>::max()
 
template<class T , int N>
struct SetBodyTypeIDs
 needed to be able to set static type ids with setStaticTypeID More...
 
static id_t getStaticTypeID ()
 Returns unique type id of this type. More...
 
void setPositionImpl (real_t px, real_t py, real_t pz) override
 Setting the global position of the union. More...
 
void setOrientationImpl (real_t r, real_t i, real_t j, real_t k) override
 Setting the global orientation of the union. More...
 
void translateImpl (real_t dx, real_t dy, real_t dz) override
 Translation of the center of mass of the union by the displacement vector dp. More...
 
void rotateImpl (const Quat &dq) override
 Rotation of the union by the quaternion dq. More...
 
void rotateAroundOriginImpl (const Quat &dq) override
 Rotation of the union around the origin of the global world frame. More...
 
void rotateAroundPointImpl (const Vec3 &point, const Quat &dq) override
 Rotation of the union around a specific global coordinate. More...
 
bool containsRelPointImpl (real_t px, real_t py, real_t pz) const override
 Checks, whether a point in body relative coordinates lies inside the union. More...
 
bool isSurfaceRelPointImpl (real_t px, real_t py, real_t pz) const override
 Checks, whether a point in body relative coordinates lies on the surface of the union. More...
 
void calcBoundingBox () override
 Calculation of the bounding box of the union. More...
 
void calcCenterOfMass ()
 Calculation of the total mass and center of mass. More...
 
void calcInertia ()
 Calculation of the moment of inertia in reference to the body frame of the union. More...
 
static void setStaticTypeID (id_t typeID)
 

Member Typedef Documentation

◆ cast_iterator

template<typename... BodyTypes>
template<typename C >
using walberla::pe::Union< BodyTypes >::cast_iterator = BodyStorage::cast_iterator<C>

◆ const_cast_iterator

template<typename... BodyTypes>
template<typename C >
using walberla::pe::Union< BodyTypes >::const_cast_iterator = BodyStorage::const_cast_iterator<C>

◆ const_iterator

template<typename... BodyTypes>
using walberla::pe::Union< BodyTypes >::const_iterator = BodyStorage::const_iterator

Iterator over constant bodies.

◆ iterator

template<typename... BodyTypes>
using walberla::pe::Union< BodyTypes >::iterator = BodyStorage::iterator

Iterator over non-const bodies.

◆ size_type

template<typename... BodyTypes>
using walberla::pe::Union< BodyTypes >::size_type = BodyStorage::size_type

Size type of the body storage.

Constructor & Destructor Documentation

◆ Union()

template<typename... BodyTypes>
walberla::pe::Union< BodyTypes >::Union ( id_t  sid,
id_t  uid,
const Vec3 gpos,
const Quat q,
const bool  global,
const bool  communicating,
const bool  infiniteMass 
)
explicit

Constructor for the Sphere class.

Parameters
sidUnique system-specific ID for the sphere.
uidUser-specific ID for the sphere.
gposGlobal geometric center of the sphere.
qThe orientation of the sphere's body frame in the global world frame.
globalspecifies if the sphere should be created in the global storage
communicatingspecifies if the sphere should take part in synchronization (syncNextNeighbour, syncShadowOwner)
infiniteMassspecifies if the sphere has infinite mass and will be treated as an obstacle

◆ ~Union()

template<typename... BodyTypes>
walberla::pe::Union< BodyTypes >::~Union
override

Destructor for the Union class.

Member Function Documentation

◆ add()

template<typename... BodyTypes>
RigidBody & walberla::pe::Union< BodyTypes >::add ( std::unique_ptr< RigidBody > &&  body)
inline

Adding a rigid body to the union.

Parameters
bodyThe rigid body to be added to the union.
Returns
void
Exceptions
std::logic_errorInvalid adding into a global union inside an exclusive section.
std::logic_errorGlobal flags of body and union do not match.

This function adds another rigid body to the union (as for instance a sphere, a box, a capsule, or another union). It updates all union properties that change due to the new rigid body: the center of mass, the relative position of all contained rigid bodies, the attached sections of all contained links, the moment of inertia, and the axis-aligned bounding box.
The union takes full responsibility for the newly added body, including the necessary memory management. After adding the body to the union, the body is considered part of the union. All functions called on the union (as for instance all kinds of set functions, translation or rotation functions) additionally define the values for the rigid body according to its relative position and orientation. Do not call any Set-Functions on the single rigid body.

Adding infinite rigid bodies

Adding an infinite rigid body (as for instance a plane) to the union makes the union an infinite rigid body. This additionally resets the linear and angular velocity of the union and fixes its global position. Note that removing the last infinite body from an union will not restore previous settings such as the velocities and will not unfix the union!

Global bodies/unions

Adding a global rigid body (i.e. a body defined inside the pe_GLOBAL_SECTION) to the union requires the union to be also global. Adding a non-global rigid body to a union requires the union to be also non-global. The attempt to add a global rigid body to a non-global union or a non-global body to a global union results in a std::logic_error exception.

Additional rules

The following rules apply for the mobility and visibility of the resulting union:

  • If either the union or the added rigid body is fixed, the new compound will also be fixed. For instance, adding a fixed rigid body to an union will fix the union, and adding a rigid body to a fixed union will fix the body.
  • Neither the (in-)visibility of the added rigid body nor (in-)visibility of the union will change due to the add operation. For instance adding a visible rigid body to an invisible union will not change the visibility of the body. Neither is the visibility of the union changed. In order to change the visibility, the setVisible() function can be either called individually for the rigid body (to exclusively make the body (in-)visible) or the entire union (to make the entire union (in-)visible.

◆ begin() [1/4]

template<typename... BodyTypes>
iterator walberla::pe::Union< BodyTypes >::begin ( )
inline

◆ begin() [2/4]

template<typename... BodyTypes>
template<typename C >
cast_iterator<C> walberla::pe::Union< BodyTypes >::begin ( )
inline

◆ begin() [3/4]

template<typename... BodyTypes>
const_iterator walberla::pe::Union< BodyTypes >::begin ( ) const
inline

◆ begin() [4/4]

template<typename... BodyTypes>
template<typename C >
const_cast_iterator<C> walberla::pe::Union< BodyTypes >::begin ( ) const
inline

◆ calcBoundingBox()

template<typename... BodyTypes>
void walberla::pe::Union< BodyTypes >::calcBoundingBox
inlineoverrideprotected

Calculation of the bounding box of the union.

Returns
void

This function updates the axis-aligned bounding box of the union according to the current position and orientation of the contained rigid bodies.

◆ calcCenterOfMass()

template<typename... BodyTypes>
void walberla::pe::Union< BodyTypes >::calcCenterOfMass
inlineprotected

Calculation of the total mass and center of mass.

Returns
void

◆ calcInertia()

template<typename... BodyTypes>
void walberla::pe::Union< BodyTypes >::calcInertia
inlineprotected

Calculation of the moment of inertia in reference to the body frame of the union.

Use this function only if the center of gravity is set correctly (e.g. after calling calcCenterOfMass)

Returns
void

◆ cbegin() [1/2]

template<typename... BodyTypes>
const_iterator walberla::pe::Union< BodyTypes >::cbegin ( ) const
inline

◆ cbegin() [2/2]

template<typename... BodyTypes>
template<typename C >
const_cast_iterator<C> walberla::pe::Union< BodyTypes >::cbegin ( ) const
inline

◆ cend() [1/2]

template<typename... BodyTypes>
const_iterator walberla::pe::Union< BodyTypes >::cend ( ) const
inline

◆ cend() [2/2]

template<typename... BodyTypes>
template<typename C >
const_cast_iterator<C> walberla::pe::Union< BodyTypes >::cend ( ) const
inline

◆ containsRelPointImpl()

template<typename... BodyTypes>
bool walberla::pe::Union< BodyTypes >::containsRelPointImpl ( real_t  px,
real_t  py,
real_t  pz 
) const
overrideprotected

Checks, whether a point in body relative coordinates lies inside the union.

Parameters
pxThe x-component of the relative coordinate.
pyThe y-component of the relative coordinate.
pzThe z-component of the relative coordinate.
Returns
true if the point lies inside the sphere, false if not.

◆ end() [1/4]

template<typename... BodyTypes>
iterator walberla::pe::Union< BodyTypes >::end ( )
inline

◆ end() [2/4]

template<typename... BodyTypes>
template<typename C >
cast_iterator<C> walberla::pe::Union< BodyTypes >::end ( )
inline

◆ end() [3/4]

template<typename... BodyTypes>
const_iterator walberla::pe::Union< BodyTypes >::end ( ) const
inline

◆ end() [4/4]

template<typename... BodyTypes>
template<typename C >
const_cast_iterator<C> walberla::pe::Union< BodyTypes >::end ( ) const
inline

◆ getStaticTypeID()

template<typename... BodyTypes>
id_t walberla::pe::Union< BodyTypes >::getStaticTypeID
inlinestatic

Returns unique type id of this type.

Returns
geometry specific type id

◆ getVolume()

template<typename... BodyTypes>
real_t walberla::pe::Union< BodyTypes >::getVolume
inlineoverride

Returns the volume of the union.

Returns
The volume of the union.

◆ handleModification()

template<typename... BodyTypes>
void walberla::pe::Union< BodyTypes >::handleModification
override

Signals an internal modification of a contained subordinate rigid body.

Returns
void

In case one of the contained rigid bodies is internally modified, this function is called to recalculate the changed properties of the union.

◆ handleRotation()

template<typename... BodyTypes>
void walberla::pe::Union< BodyTypes >::handleRotation
override

Signals an orientation change of a contained subordinate rigid body.

Returns
void

In case one of the contained rigid bodies changes its orientation, this function is called to recalculate the changed properties of the union.

◆ handleTranslation()

template<typename... BodyTypes>
void walberla::pe::Union< BodyTypes >::handleTranslation
override

Signals a position change of a contained subordinate rigid body.

Returns
void

In case one of the contained rigid bodies changes its position, this function is called to recalculate the changed properties of the union.

◆ hasSubBodies()

template<typename... BodyTypes>
bool walberla::pe::Union< BodyTypes >::hasSubBodies ( ) const
inlineoverride

◆ isEmpty()

template<typename... BodyTypes>
bool walberla::pe::Union< BodyTypes >::isEmpty ( ) const
inline

◆ isSurfaceRelPointImpl()

template<typename... BodyTypes>
bool walberla::pe::Union< BodyTypes >::isSurfaceRelPointImpl ( real_t  px,
real_t  py,
real_t  pz 
) const
overrideprotected

Checks, whether a point in body relative coordinates lies on the surface of the union.

Parameters
pxThe x-component of the relative coordinate.
pyThe y-component of the relative coordinate.
pzThe z-component of the relative coordinate.
Returns
true if the point lies on the surface of the sphere, false if not.

The tolerance level of the check is pe::surfaceThreshold.

◆ print()

template<typename... BodyTypes>
void walberla::pe::Union< BodyTypes >::print ( std::ostream &  os,
const char *  tab 
) const
override

Output of the current state of an union.

Parameters
osReference to the output stream.
tabIndentation in front of every line of the union output.
Returns
void

◆ rotateAroundOriginImpl()

template<typename... BodyTypes>
void walberla::pe::Union< BodyTypes >::rotateAroundOriginImpl ( const Quat dq)
overrideprotected

Rotation of the union around the origin of the global world frame.

Parameters
dqThe quaternion for the rotation.
Returns
void
Exceptions
std::logic_errorInvalid rotation of a global union inside an exclusive section.

This function rotates the entire union around the origin of the global world frame and changes both the global position and the orientation/rotation of the union. Additionally, all contained rigid bodies change their position and orientation accordingly. The orientation of the bodies within the union in reference to the body frame of the union is not changed.

◆ rotateAroundPointImpl()

template<typename... BodyTypes>
void walberla::pe::Union< BodyTypes >::rotateAroundPointImpl ( const Vec3 point,
const Quat dq 
)
overrideprotected

Rotation of the union around a specific global coordinate.

Parameters
pointThe global center of the rotation.
dqThe quaternion for the rotation.
Returns
void
Exceptions
std::logic_errorInvalid rotation of a global union inside an exclusive section.

This function rotates the entire union around the given global coordinate point and changes both the global position and the orientation/rotation of the union. Additionally, all contained rigid bodies change their position and orientation accordingly. The orientation of the bodies within the union in reference to the body frame of the union is not changed.

◆ rotateImpl()

template<typename... BodyTypes>
void walberla::pe::Union< BodyTypes >::rotateImpl ( const Quat dq)
overrideprotected

Rotation of the union by the quaternion dq.

Parameters
dqThe quaternion for the rotation.
Returns
void
Exceptions
std::logic_errorInvalid rotation of a global union inside an exclusive section.

Changing the orientation/rotation of the entire union. This function causes all contained rigid bodies to rotate around the center of mass of the union (if the union is finite) or around the anchor point of the union (if the union is infinite). The orientation of the bodies within the union in reference to the body frame of the union is not changed.

◆ setOrientationImpl()

template<typename... BodyTypes>
void walberla::pe::Union< BodyTypes >::setOrientationImpl ( real_t  r,
real_t  i,
real_t  j,
real_t  k 
)
overrideprotected

Setting the global orientation of the union.

Parameters
rThe value for the real part.
iThe value for the first imaginary part.
jThe value for the second imaginary part.
kThe value for the third imaginary part.
Returns
void
Exceptions
std::logic_errorInvalid rotation of a global union inside an exclusive section.

Setting the orientation/rotation of the entire union. This function causes all contained primitives to rotate around the center of mass of the union (if the union is finite) or around the anchor point of the union (if the union is infinite). The orientation of the rigid bodies within the union in reference to the body frame of the union is not changed.

◆ setPositionImpl()

template<typename... BodyTypes>
void walberla::pe::Union< BodyTypes >::setPositionImpl ( real_t  px,
real_t  py,
real_t  pz 
)
overrideprotected

Setting the global position of the union.

Parameters
pxThe x-component of the global coordinate.
pyThe y-component of the global coordinate.
pzThe z-component of the global coordinate.
Returns
void
Exceptions
std::logic_errorInvalid translation of a global union inside an exclusive section.

Setting the global position of the union's center of mass. If the union contains an infinite rigid body, the function shifts the union to reposition its anchor point according to the given global coordinate.

◆ setRemote()

template<typename... BodyTypes>
void walberla::pe::Union< BodyTypes >::setRemote ( bool  remote)
override

Setting the remote flag of the union and all contained bodies.

Parameters
remotetrue to declare the union remote, false declare it local.
Returns
void

This function sets the remote flag of the union and all contained rigid bodies. Note that this function should not be used explicitly, but is automatically called during the MPI communication to set the remote status of a union within the simulation world. Using this function explicitly may lead to simulation errors during a parallel simulation!

◆ setStaticTypeID()

template<typename... BodyTypes>
static void walberla::pe::Union< BodyTypes >::setStaticTypeID ( id_t  typeID)
inlinestaticprivate

◆ size()

template<typename... BodyTypes>
size_t walberla::pe::Union< BodyTypes >::size ( ) const
inline

◆ translateImpl()

template<typename... BodyTypes>
void walberla::pe::Union< BodyTypes >::translateImpl ( real_t  dx,
real_t  dy,
real_t  dz 
)
overrideprotected

Translation of the center of mass of the union by the displacement vector dp.

Parameters
dxThe displacement on the x-axis.
dyThe displacement on the y-axis.
dzThe displacement on the z-axis.
Returns
void
Exceptions
std::logic_errorInvalid translation of a global union inside an exclusive section.

Changing the global position of the entire union's center of mass. All contained rigid bodies are moved by the same displacement.

Friends And Related Function Documentation

◆ SetBodyTypeIDs

template<typename... BodyTypes>
template<class T , int N>
friend struct SetBodyTypeIDs
friend

needed to be able to set static type ids with setStaticTypeID

Member Data Documentation

◆ bodies_

template<typename... BodyTypes>
BodyStorage walberla::pe::Union< BodyTypes >::bodies_
private

Rigid bodies contained in the union.

◆ containedTypeIDs_

template<typename... BodyTypes>
std::vector<id_t> walberla::pe::Union< BodyTypes >::containedTypeIDs_
private

◆ staticTypeID_

template<typename... BodyTypes>
id_t walberla::pe::Union< BodyTypes >::staticTypeID_ = std::numeric_limits<id_t>::max()
staticprivate

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