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 | |
RigidBody & | add (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_t > | containedTypeIDs_ |
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) |
using walberla::pe::Union< BodyTypes >::cast_iterator = BodyStorage::cast_iterator<C> |
using walberla::pe::Union< BodyTypes >::const_cast_iterator = BodyStorage::const_cast_iterator<C> |
using walberla::pe::Union< BodyTypes >::const_iterator = BodyStorage::const_iterator |
Iterator over constant bodies.
using walberla::pe::Union< BodyTypes >::iterator = BodyStorage::iterator |
Iterator over non-const bodies.
using walberla::pe::Union< BodyTypes >::size_type = BodyStorage::size_type |
Size type of the body storage.
|
explicit |
Constructor for the Sphere class.
sid | Unique system-specific ID for the sphere. |
uid | User-specific ID for the sphere. |
gpos | Global geometric center of the sphere. |
q | The orientation of the sphere's body frame in the global world frame. |
global | specifies if the sphere should be created in the global storage |
communicating | specifies if the sphere should take part in synchronization (syncNextNeighbour, syncShadowOwner) |
infiniteMass | specifies if the sphere has infinite mass and will be treated as an obstacle |
|
override |
Destructor for the Union class.
|
inline |
Adding a rigid body to the union.
body | The rigid body to be added to the union. |
std::logic_error | Invalid adding into a global union inside an exclusive section. |
std::logic_error | Global 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 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!
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.
The following rules apply for the mobility and visibility of the resulting union:
|
inline |
|
inline |
|
inline |
|
inline |
|
inlineoverrideprotected |
Calculation of the bounding box of the union.
This function updates the axis-aligned bounding box of the union according to the current position and orientation of the contained rigid bodies.
|
inlineprotected |
Calculation of the total mass and center of mass.
|
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)
|
inline |
|
inline |
|
inline |
|
inline |
|
overrideprotected |
Checks, whether a point in body relative coordinates lies inside the union.
px | The x-component of the relative coordinate. |
py | The y-component of the relative coordinate. |
pz | The z-component of the relative coordinate. |
|
inline |
|
inline |
|
inline |
|
inline |
|
inlinestatic |
Returns unique type id of this type.
|
inlineoverride |
Returns the volume of the union.
|
override |
Signals an internal modification of a contained subordinate rigid body.
In case one of the contained rigid bodies is internally modified, this function is called to recalculate the changed properties of the union.
|
override |
Signals an orientation change of a contained subordinate rigid body.
In case one of the contained rigid bodies changes its orientation, this function is called to recalculate the changed properties of the union.
|
override |
Signals a position change of a contained subordinate rigid body.
In case one of the contained rigid bodies changes its position, this function is called to recalculate the changed properties of the union.
|
inlineoverride |
|
inline |
|
overrideprotected |
Checks, whether a point in body relative coordinates lies on the surface of the union.
px | The x-component of the relative coordinate. |
py | The y-component of the relative coordinate. |
pz | The z-component of the relative coordinate. |
The tolerance level of the check is pe::surfaceThreshold.
|
override |
Output of the current state of an union.
os | Reference to the output stream. |
tab | Indentation in front of every line of the union output. |
|
overrideprotected |
Rotation of the union around the origin of the global world frame.
dq | The quaternion for the rotation. |
std::logic_error | Invalid 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.
|
overrideprotected |
Rotation of the union around a specific global coordinate.
point | The global center of the rotation. |
dq | The quaternion for the rotation. |
std::logic_error | Invalid 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.
|
overrideprotected |
Rotation of the union by the quaternion dq.
dq | The quaternion for the rotation. |
std::logic_error | Invalid 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.
|
overrideprotected |
Setting the global orientation of the union.
r | The value for the real part. |
i | The value for the first imaginary part. |
j | The value for the second imaginary part. |
k | The value for the third imaginary part. |
std::logic_error | Invalid 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.
|
overrideprotected |
Setting the global position of the union.
px | The x-component of the global coordinate. |
py | The y-component of the global coordinate. |
pz | The z-component of the global coordinate. |
std::logic_error | Invalid 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.
|
override |
Setting the remote flag of the union and all contained bodies.
remote | true to declare the union remote, false declare it local. |
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!
|
inlinestaticprivate |
|
inline |
|
overrideprotected |
Translation of the center of mass of the union by the displacement vector dp.
dx | The displacement on the x-axis. |
dy | The displacement on the y-axis. |
dz | The displacement on the z-axis. |
std::logic_error | Invalid 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.
needed to be able to set static type ids with setStaticTypeID
|
private |
Rigid bodies contained in the union.
|
private |
|
staticprivate |