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 assebly 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>

+ Inheritance diagram for walberla::pe::Union< BodyTypes >:

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

virtual real_t getVolume () const
 Returns the volume of the union. More...
 
virtual bool hasSubBodies () const WALBERLA_OVERRIDE
 
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
virtual ~Union ()
 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
 
Set functions
virtual void setRemote (bool remote) WALBERLA_OVERRIDE
 Setting the remote flag of the union and all contained bodies. More...
 
Signal functions
virtual void handleModification () WALBERLA_OVERRIDE
 Signals an internal modification of a contained subordiante rigid body. More...
 
virtual void handleTranslation () WALBERLA_OVERRIDE
 Signals a position change of a contained subordiante rigid body. More...
 
virtual void handleRotation () WALBERLA_OVERRIDE
 Signals an orientation change of a contained subordiante rigid body. More...
 
Rigid body manager functions
RigidBodyadd (std::unique_ptr< RigidBody > &&body)
 Adding a rigid body to the union. More...
 
Output functions
virtual void print (std::ostream &os, const char *tab) const
 Output of the current state of an union. More...
 
- Public Member Functions inherited from walberla::pe::RigidBody
virtual ~RigidBody ()=0
 Destructor for the RigidBody class. More...
 
void wake ()
 Waking the rigid body and ending the sleep mode. More...
 
void calcMotion ()
 Calculating the current motion of a rigid body. More...
 
bool hasManager () const
 Returns whether the rigid body currently has a supervising rigid body manager. More...
 
ManagerID getManager ()
 Returns the supervising rigid body manager of the rigid body. More...
 
ConstManagerID getManager () const
 Returns the supervising rigid body manager of the rigid body. More...
 
bool hasSuperBody () const
 Returns whether the rigid body is contained in a superordinate body. More...
 
BodyID getSuperBody ()
 Returns the superordinate body in which the rigid body is contained. More...
 
ConstBodyID getSuperBody () const
 Returns the superordinate body in which the rigid body is contained. More...
 
BodyID getTopSuperBody ()
 Returns the top level superordinate body in which the rigid body is contained. More...
 
ConstBodyID getTopSuperBody () const
 Returns the top level superordinate body in which the rigid body is contained. More...
 
bool isFinite () const
 Returns whether the rigid body is finite or not. More...
 
bool isAwake () const
 Returns whether the rigid body is awake or not. More...
 
bool isFixed () const
 Returns whether the rigid body's position is fixed or not. More...
 
bool hasInfiniteMass () const
 Checks if a body is "mobile" e.g. More...
 
bool isVisible () const
 Returns whether the rigid body is visible or not. More...
 
bool isMarkedForDeletion () const
 
id_t getSystemID () const
 Returns the unique system-specific ID of the rigid body. More...
 
id_t getID () const
 Returns the user-specific ID of the rigid body. More...
 
const Vec3 getRelPosition () const
 Returns the relative position of the rigid body within the superordinate body. More...
 
const Vec3 getPosition () const
 Returns the global position of the center of mass of the rigid body. More...
 
const Vec3 getBodyLinearVel () const
 Returns the relative linear velocity of the rigid body. More...
 
const Vec3 getLinearVel () const
 Returns the global linear velocity of the rigid body. More...
 
const Vec3 getBodyAngularVel () const
 Returns the relative angular velocity. More...
 
const Vec3getAngularVel () const
 Returns the global angular velocity. More...
 
const Quat getRelQuaternion () const
 Returns the relative orientation of the rigid body to its superbody. More...
 
const Quat getQuaternion () const
 Returns the orientation of the rigid body. More...
 
const Mat3 getRotation () const
 Returns the rotation of the rigid body. More...
 
real_t getMass () const
 Returns the total mass of the rigid body. More...
 
real_t getInvMass () const
 Returns the inverse total mass of the rigid body. More...
 
const Mat3getBodyInertia () const
 Returns the moment of inertia in reference to the body frame of the rigid body. More...
 
const Mat3 getInertia () const
 Returns the moment of inertia in reference to the global world frame. More...
 
const Mat3getInvBodyInertia () const
 Returns the inverse moment of inertia in reference to the body frame of the rigid body. More...
 
const Mat3 getInvInertia () const
 Returns the inverse moment of inertia in reference to the global world frame. More...
 
const AABB & getAABB () const
 Returns the axis-aligned bounding box of the rigid body. More...
 
real_t getAABBSize () const
 Returns the length of the longest side of the AABB of the rigid body. More...
 
real_t getKineticEnergy () const
 Returns the kinetic energy of the rigid body. More...
 
real_t getRotationalEnergy () const
 Returns the rotational energy of the rigid body. More...
 
real_t getEnergy () const
 Returns the energy of the rigid body. More...
 
const Vec3 vectorFromBFtoWF (real_t vx, real_t vy, real_t vz) const
 Transformation from a relative to a global vector. More...
 
const Vec3 vectorFromBFtoWF (const Vec3 &v) const
 Transformation from a relative to a global vector. More...
 
const Vec3 pointFromBFtoWF (real_t px, real_t py, real_t pz) const
 Transformation from a relative to a global coordinate. More...
 
const Vec3 pointFromBFtoWF (const Vec3 &rpos) const
 Transformation from a relative to a global coordinate. More...
 
virtual Vec3 velFromBF (real_t px, real_t py, real_t pz) const
 Calculation of the global velocity of a relative point. More...
 
virtual Vec3 velFromBF (const Vec3 &rpos) const
 Calculation of the global velocity of a relative point. More...
 
const Vec3 vectorFromWFtoBF (real_t vx, real_t vy, real_t vz) const
 Transformation from a global to a relative vector. More...
 
const Vec3 vectorFromWFtoBF (const Vec3 &v) const
 Transformation from a global to a relative vector. More...
 
const Vec3 pointFromWFtoBF (real_t px, real_t py, real_t pz) const
 Transformation from a global to a relative coordinate. More...
 
const Vec3 pointFromWFtoBF (const Vec3 &gpos) const
 Transformation from a global to a relative coordinate. More...
 
virtual Vec3 velFromWF (real_t px, real_t py, real_t pz) const
 Calculation of the global velocity of a point in global coordinates. More...
 
virtual Vec3 velFromWF (const Vec3 &gpos) const
 Calculation of the global velocity of a point in global coordinates. More...
 
const Vec3 accFromWF (real_t px, real_t py, real_t pz) const
 Calculation of the global acceleration of a point in global coordinates. More...
 
const Vec3 accFromWF (const Vec3 &gpos) const
 Calculation of the global acceleration of a point in global coordinates. More...
 
id_t getTypeID () const
 
void translate (real_t dx, real_t dy, real_t dz)
 Translation of the center of mass of the rigid body by the displacement vector. More...
 
void translate (const Vec3 &dp)
 Translation of the center of mass of the rigid body by the displacement vector dp. More...
 
void rotate (real_t x, real_t y, real_t z, real_t angle)
 Rotation of the rigid body around the global rotation axis (x,y,z) by the rotation angle angle. More...
 
void rotate (const Vec3 &axis, real_t angle)
 Rotation of the rigid body around the specified global rotation axis by the rotation. More...
 
void rotate (real_t xangle, real_t yangle, real_t zangle)
 Rotation of the rigid body by the Euler angles xangle, yangle and zangle. More...
 
void rotate (const Vec3 &euler)
 Rotation of the rigid body by the Euler angles euler. More...
 
void rotate (const Quat &dq)
 Rotation of the rigid body by the quaternion dq. More...
 
void rotateAroundOrigin (real_t x, real_t y, real_t z, real_t angle)
 Rotation of the rigid body around the origin of the global world frame. More...
 
void rotateAroundOrigin (const Vec3 &axis, real_t angle)
 Rotation of the rigid body around the origin of the global world frame. More...
 
void rotateAroundOrigin (real_t xangle, real_t yangle, real_t zangle)
 Rotation of the rigid body around the origin of the global world frame. More...
 
void rotateAroundOrigin (const Vec3 &euler)
 Rotation of the rigid body around the origin of the global world frame. More...
 
void rotateAroundOrigin (const Quat &dq)
 Rotation of the rigid body around the origin of the global world frame. More...
 
void rotateAroundPoint (const Vec3 &point, const Vec3 &axis, real_t angle)
 Rotation of the rigid body around a specific global coordinate. More...
 
void rotateAroundPoint (const Vec3 &point, const Vec3 &euler)
 Rotation of the rigid body around a specific global coordinate. More...
 
bool containsRelPoint (real_t px, real_t py, real_t pz) const
 Checks, whether a point in body relative coordinates lies inside the rigid body. More...
 
bool containsRelPoint (const Vec3 &rpos) const
 Checks, whether a point in body relative coordinates lies inside the rigid body. More...
 
bool containsPoint (real_t px, real_t py, real_t pz) const
 Checks, whether a point in global coordinates lies inside the rigid body. More...
 
bool containsPoint (const Vec3 &gpos) const
 Checks, whether a point in global coordinates lies inside the rigid body. More...
 
bool isSurfaceRelPoint (real_t px, real_t py, real_t pz) const
 Checks, whether a point in relative coordinates lies on the surface of the rigid body. More...
 
bool isSurfaceRelPoint (const Vec3 &rpos) const
 Checks, whether a point in body relative coordinates lies on the surface of the rigid body. More...
 
bool isSurfacePoint (real_t px, real_t py, real_t pz) const
 Checks, whether a point in global coordinates lies on the surface of the rigid body. More...
 
bool isSurfacePoint (const Vec3 &gpos) const
 Checks, whether a point in global coordinates lies on the surface of the rigid body. More...
 
virtual Vec3 support (const Vec3 &d) const
 Estimates the point which is farthest in direction d. More...
 
virtual Vec3 supportContactThreshold (const Vec3 &d) const
 Estimates the point which is farthest in direction d. More...
 
bool hasForce () const
 Returns whether the rigid body has non-zero acting forces or torques. More...
 
const Vec3getForce () const
 Returns the current force acting on the body's center of mass. More...
 
const Vec3getTorque () const
 Returns the current torque acting on the body's center of mass. More...
 
void setForce (const Vec3 &f)
 Set the force acting at the body's center of mass. More...
 
void setTorque (const Vec3 &tau)
 Set the torque acting at the body's center of mass. More...
 
void addRelForce (real_t fx, real_t fy, real_t fz)
 Increases the total force acting in the body's center of mass. More...
 
void addRelForce (const Vec3 &f)
 Increases the force acting in the body's center of mass. More...
 
void addForce (real_t fx, real_t fy, real_t fz)
 Increases the force acting in the body's center of mass. More...
 
void addForce (const Vec3 &f)
 Increases the force acting in the body's center of mass. More...
 
void addRelForceAtRelPos (real_t fx, real_t fy, real_t fz, real_t px, real_t py, real_t pz)
 Increases the force acting in the body's center of mass. More...
 
void addRelForceAtRelPos (const Vec3 &f, const Vec3 &rpos)
 Increases the force acting in the body's center of mass. More...
 
void addRelForceAtPos (real_t fx, real_t fy, real_t fz, real_t px, real_t py, real_t pz)
 Increases the force acting in the body's center of mass. More...
 
void addRelForceAtPos (const Vec3 &f, const Vec3 &gpos)
 Increases the force acting in the body's center of mass. More...
 
void addForceAtRelPos (real_t fx, real_t fy, real_t fz, real_t px, real_t py, real_t pz)
 Increases the force acting in the body's center of mass. More...
 
void addForceAtRelPos (const Vec3 &f, const Vec3 &rpos)
 Increases the force acting in the body's center of mass. More...
 
void addForceAtPos (real_t fx, real_t fy, real_t fz, real_t px, real_t py, real_t pz)
 Increases the force acting in the body's center of mass. More...
 
void addForceAtPos (const Vec3 &f, const Vec3 &gpos)
 Increases the force acting in the body's center of mass. More...
 
void addTorque (real_t tx, real_t ty, real_t tz)
 Increasing the torque acting in the body's center of mass. More...
 
void addTorque (const Vec3 &t)
 Increasing the torque acting in the body's center of mass. More...
 
virtual void resetForceAndTorque ()
 Resetting all acting forces and torques from the rigid body. More...
 
void addImpulse (real_t jx, real_t jy, real_t jz)
 Applying an impulse in the body's center of mass. More...
 
void addImpulse (const Vec3 &j)
 Applying an impulse in the body's center of mass. More...
 
void addImpulseAtPos (real_t jx, real_t jy, real_t jz, real_t px, real_t py, real_t pz)
 Applying an impulse at the given global coordinate. More...
 
void addImpulseAtPos (const Vec3 &j, const Vec3 &p)
 Applying an impulse at the given global coordinate. More...
 
bool isRemote () const
 Returns whether the rigid body is remote or not. More...
 
bool isGlobal () const
 Returns whether the rigid body is global or not. More...
 
void setGlobal (const bool global)
 Setting the global flag of the rigid body. More...
 
bool isCommunicating () const
 Returns whether the rigid body is local or not. More...
 
void setCommunicating (const bool communicating)
 Setting the local flag of the rigid body. More...
 
virtual bool checkInvariants ()
 Checks the validity of the state of the rigid body. More...
 
void setSB (BodyID body)
 Sets the super body for the current body. More...
 
void resetSB ()
 Resets the super body for the current body. More...
 
void setFinite (const bool finite)
 
void setVisible (bool visible)
 Setting the rigid body visible/invisible. More...
 
void setPosition (real_t px, real_t py, real_t pz)
 Setting the global position of the rigid body. More...
 
void setPosition (const Vec3 &gpos)
 Setting the global position of the rigid body. More...
 
void setRelPosition (const Vec3 &gpos)
 Setting the global position of the rigid body. More...
 
void setOrientation (real_t r, real_t i, real_t j, real_t k)
 Setting the global orientation of the rigid body. More...
 
void setOrientation (const Quat &q)
 Setting the global orientation of the rigid body. More...
 
void setRelOrientation (const Quat &q)
 Setting the relative position of the rigid body. More...
 
void setMassAndInertiaToInfinity ()
 Setting the mass to infinity. More...
 
void setRelLinearVel (real_t vx, real_t vy, real_t vz)
 Setting the relative linear velocity of the rigid body. More...
 
void setRelLinearVel (const Vec3 &lvel)
 
void setLinearVel (real_t vx, real_t vy, real_t vz)
 Setting the global linear velocity of the rigid body. More...
 
void setLinearVel (const Vec3 &lvel)
 /see setLinearVel( real_t vx, real_t vy, real_t vz ) More...
 
void setRelAngularVel (real_t ax, real_t ay, real_t az)
 Setting the relative angular velocity of the rigid body. More...
 
void setRelAngularVel (const Vec3 &avel)
 /see setRelAngularVel( real_t ax, real_t ay, real_t az ) More...
 
void setAngularVel (real_t ax, real_t ay, real_t az)
 Setting the global angular velocity of the rigid body. More...
 
void setAngularVel (const Vec3 &avel)
 /see setAngularVel( real_t ax, real_t ay, real_t az ) More...
 
void markForDeletion ()
 Marks the rigid body for deletion during the next synchronization. More...
 
- Public Member Functions inherited from walberla::pe::ccd::HashGridsBodyTrait
void * getGrid () const
 Returns the grid the rigid body is currently assigned to. More...
 
size_t getHash () const
 Returns the current hash value of the rigid body. More...
 
size_t getCellId () const
 Returns the current body container index within the cell the body is currently assigned to. More...
 
void setGrid (void *grid)
 Setting the grid the rigid body is associated with. More...
 
void setHash (size_t hash)
 Setting the hash value of the rigid body. More...
 
void setCellId (size_t cell)
 Setting the body container index within the cell the body is currently assigned to. More...
 

Static Private Member Functions

static void setStaticTypeID (id_t typeID)
 

Private Attributes

BodyStorage bodies_
 Rigid bodies contained in the union. More...
 
std::vector< id_tcontainedTypeIDs_
 

Static Private Attributes

static id_t staticTypeID_ = std::numeric_limits<id_t>::max()
 

Friends

template<class T , int N>
struct SetBodyTypeIDs
 needed to be able to set static type ids with setStaticTypeID More...
 

Utility functions

static id_t getStaticTypeID ()
 Returns unique type id of this type. More...
 
virtual void setPositionImpl (real_t px, real_t py, real_t pz) WALBERLA_OVERRIDE
 Setting the global position of the union. More...
 
virtual void setOrientationImpl (real_t r, real_t i, real_t j, real_t k) WALBERLA_OVERRIDE
 Setting the global orientation of the union. More...
 
virtual void translateImpl (real_t dx, real_t dy, real_t dz) WALBERLA_OVERRIDE
 Translation of the center of mass of the union by the displacement vector dp. More...
 
virtual void rotateImpl (const Quat &dq) WALBERLA_OVERRIDE
 Rotation of the union by the quaternion dq. More...
 
virtual void rotateAroundOriginImpl (const Quat &dq) WALBERLA_OVERRIDE
 Rotation of the union around the origin of the global world frame. More...
 
virtual void rotateAroundPointImpl (const Vec3 &point, const Quat &dq) WALBERLA_OVERRIDE
 Rotation of the union around a specific global coordinate. More...
 
virtual bool containsRelPointImpl (real_t px, real_t py, real_t pz) const WALBERLA_OVERRIDE
 Checks, whether a point in body relative coordinates lies inside the union. More...
 
virtual bool isSurfaceRelPointImpl (real_t px, real_t py, real_t pz) const WALBERLA_OVERRIDE
 Checks, whether a point in body relative coordinates lies on the surface of the union. More...
 
virtual void calcBoundingBox () WALBERLA_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...
 

Additional Inherited Members

- Public Attributes inherited from walberla::pe::RigidBody
MPIRigidBodyTrait MPITrait
 
- Public Attributes inherited from walberla::pe::cr::HCSITSBodyTrait
size_t index_
 
- Protected Member Functions inherited from walberla::pe::RigidBody
 RigidBody (id_t const typeID, id_t sid, id_t uid)
 Constructor for the RigidBody class. More...
 
virtual void fix ()
 Setting the global position (the center of mass) of the rigid body fixed. More...
 
void signalModification ()
 Signals an internal modification of a contained subordiante body. More...
 
void signalTranslation ()
 Signals a position change of a contained subordiante body. More...
 
void signalRotation ()
 Signals an orientation change of a contained subordiante body. More...
 
void signalFixation ()
 Signals a fixation change of a contained subordiante body. More...
 
virtual void handleFixation ()
 Handling a fixation change of a contained subordinate body. More...
 
void setMassAndInertia (const real_t mass, const Mat3 &inertia)
 Sets mass and inertia of a rigid body. More...
 
- Protected Member Functions inherited from walberla::pe::ccd::HashGridsBodyTrait
 HashGridsBodyTrait ()
 Constructor for the BodyTrait<HashGrids> specialization. More...
 
- Protected Attributes inherited from walberla::pe::RigidBody
bool awake_
 Sleep mode flag. More...
 
real_t mass_
 The total mass of the rigid body. More...
 
real_t invMass_
 The inverse total mass of the rigid body. More...
 
real_t motion_
 The current motion of the rigid body. More...
 
Vec3 v_
 The linear velocity of this rigid body. More...
 
Vec3 w_
 Angular velocity of this rigid body. More...
 
Vec3 force_
 Total force (external+contact) acting in the body's center of mass. More...
 
Vec3 torque_
 Total torque (external+contact) acting in the body's center of mass. More...
 
Mat3 I_
 The moment of inertia in reference to the body's own body frame. More...
 
Mat3 Iinv_
 The inverse moment of inertia within the body frame. More...
 
ManagerID manager_
 The rigid body manager responsible for the rigid body. More...
 
BodyID sb_
 The superordinate rigid body. More...
 
bool finite_
 Finiteness flag. More...
 
bool visible_
 Visibility flag. More...
 
bool remote_
 Remote flag. More...
 
bool communicating_
 Communicating flag. More...
 
bool global_
 Global flag. More...
 
bool toBeDeleted_
 This flag marks the body for deletion during the next synchronization (only works on local bodies) More...
 
id_t sid_
 The unique system-specific body ID. More...
 
id_t uid_
 The user-specific body ID. More...
 
AABB aabb_
 Axis-aligned bounding box for the rigid body. More...
 
- Protected Attributes inherited from walberla::pe::ccd::HashGridsBodyTrait
void * grid_
 Pointer to the hash grid this rigid body is currently assigned to. More...
 
size_t hash_
 Current hash value of this rigid body. More...
 
size_t cellId_
 The body's index in the body container of the grid cell this rigid body is currently assigned to. More...
 

Member Typedef Documentation

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

Iterator over constant bodies.

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

Iterator over non-const bodies.

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

Size type of the body storage.

Constructor & Destructor Documentation

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
template<typename... BodyTypes>
walberla::pe::Union< BodyTypes >::~Union ( )
virtual

Destructor for the Union class.

Member Function Documentation

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 visiblity, 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.
template<typename... BodyTypes>
iterator walberla::pe::Union< BodyTypes >::begin ( )
inline
template<typename... BodyTypes>
const_iterator walberla::pe::Union< BodyTypes >::begin ( ) const
inline
template<typename... BodyTypes>
template<typename C >
cast_iterator<C> walberla::pe::Union< BodyTypes >::begin ( )
inline
template<typename... BodyTypes>
template<typename C >
const_cast_iterator<C> walberla::pe::Union< BodyTypes >::begin ( ) const
inline
template<typename... BodyTypes>
void walberla::pe::Union< BodyTypes >::calcBoundingBox ( )
inlineprotectedvirtual

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.

Implements walberla::pe::RigidBody.

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

Calculation of the total mass and center of mass.

Returns
void
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
template<typename... BodyTypes>
const_iterator walberla::pe::Union< BodyTypes >::cbegin ( ) const
inline
template<typename... BodyTypes>
template<typename C >
const_cast_iterator<C> walberla::pe::Union< BodyTypes >::cbegin ( ) const
inline
template<typename... BodyTypes>
const_iterator walberla::pe::Union< BodyTypes >::cend ( ) const
inline
template<typename... BodyTypes>
template<typename C >
const_cast_iterator<C> walberla::pe::Union< BodyTypes >::cend ( ) const
inline
template<typename... BodyTypes>
bool walberla::pe::Union< BodyTypes >::containsRelPointImpl ( real_t  px,
real_t  py,
real_t  pz 
) const
protectedvirtual

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.

Reimplemented from walberla::pe::RigidBody.

template<typename... BodyTypes>
iterator walberla::pe::Union< BodyTypes >::end ( )
inline
template<typename... BodyTypes>
const_iterator walberla::pe::Union< BodyTypes >::end ( ) const
inline
template<typename... BodyTypes>
template<typename C >
cast_iterator<C> walberla::pe::Union< BodyTypes >::end ( )
inline
template<typename... BodyTypes>
template<typename C >
const_cast_iterator<C> walberla::pe::Union< BodyTypes >::end ( ) const
inline
template<typename... BodyTypes>
id_t walberla::pe::Union< BodyTypes >::getStaticTypeID ( )
inlinestatic

Returns unique type id of this type.

Returns
geometry specific type id
template<typename... BodyTypes>
real_t walberla::pe::Union< BodyTypes >::getVolume ( ) const
inlinevirtual

Returns the volume of the union.

Returns
The volume of the union.

Reimplemented from walberla::pe::RigidBody.

template<typename... BodyTypes>
void walberla::pe::Union< BodyTypes >::handleModification ( )
virtual

Signals an internal modification of a contained subordiante rigid body.

Returns
void

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

Reimplemented from walberla::pe::RigidBody.

template<typename... BodyTypes>
void walberla::pe::Union< BodyTypes >::handleRotation ( )
virtual

Signals an orientation change of a contained subordiante 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.

Reimplemented from walberla::pe::RigidBody.

template<typename... BodyTypes>
void walberla::pe::Union< BodyTypes >::handleTranslation ( )
virtual

Signals a position change of a contained subordiante 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.

Reimplemented from walberla::pe::RigidBody.

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

Reimplemented from walberla::pe::RigidBody.

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

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.

Reimplemented from walberla::pe::RigidBody.

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

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

Implements walberla::pe::RigidBody.

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

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

Parameters
xangleRotation around the x-axis (radian measure).
yangleRotation around the y-axis (radian measure).
zangleRotation around the z-axis (radian measure).
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 rotations are applied in the order x, y, z. The orientation of the bodies within the union in reference to the body frame of the union is not changed.

Reimplemented from walberla::pe::RigidBody.

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

Rotation of the union around a specific global coordinate.

Parameters
pointThe global center of the rotation.
axisThe global rotation axis.
angleThe rotation angle (radian measure).
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 coordiante 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.

Reimplemented from walberla::pe::RigidBody.

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

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.

Reimplemented from walberla::pe::RigidBody.

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

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.

Reimplemented from walberla::pe::RigidBody.

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

Setting the global position of the union.

Parameters
gposThe global position.
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.

Reimplemented from walberla::pe::RigidBody.

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

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!

Reimplemented from walberla::pe::RigidBody.

template<typename... BodyTypes>
static void walberla::pe::Union< BodyTypes >::setStaticTypeID ( id_t  typeID)
inlinestaticprivate
template<typename... BodyTypes>
size_t walberla::pe::Union< BodyTypes >::size ( ) const
inline
template<typename... BodyTypes>
void walberla::pe::Union< BodyTypes >::translateImpl ( real_t  dx,
real_t  dy,
real_t  dz 
)
protectedvirtual

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

Parameters
dpThe displacement vector.
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.

Reimplemented from walberla::pe::RigidBody.

Friends And Related Function Documentation

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

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

Rigid bodies contained in the union.

template<typename... BodyTypes>
std::vector<id_t> walberla::pe::Union< BodyTypes >::containedTypeIDs_
private
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: