Commit d04c9922 authored by Michael Kuron's avatar Michael Kuron 🔬 Committed by Sebastian Eibl

change BodyTypeTuple of Union to variadic template

so Union<std::tuple<Sphere,Box>> becomes Union<Sphere,Box>
parent 098df370
Pipeline #14840 passed with stages
in 359 minutes and 55 seconds
......@@ -74,7 +74,7 @@ class Sphere;
class Spring;
class Squirmer;
class TriangleMesh;
template <typename BodyTypeTuple>
template <typename... BodyTypes>
class Union;
typedef RigidBody BodyType; //!< Type of the rigid bodies.
......
......@@ -38,8 +38,6 @@
#include "core/Abort.h"
#include <tuple>
namespace walberla {
namespace pe {
......
......@@ -31,6 +31,8 @@
#include "pe/communication/Marshalling.h"
#include "pe/rigidbody/Union.h"
#include <tuple>
namespace walberla {
namespace pe {
namespace communication {
......@@ -57,8 +59,8 @@ struct UnionParameters : public GeomPrimitiveParameters {
* \param obj The object to be marshalled.
* \return void
*/
template < typename BodyTypeTuple >
void marshal( mpi::SendBuffer& buffer, const Union<BodyTypeTuple>& obj )
template < typename... BodyTypes >
void marshal( mpi::SendBuffer& buffer, const Union<BodyTypes...>& obj )
{
// Material of union is not relevant for reconstruction thus marshal RigidBody instead of GeomPrimitive.
marshal( buffer, static_cast<const RigidBody&>( obj ) );
......@@ -72,12 +74,12 @@ void marshal( mpi::SendBuffer& buffer, const Union<BodyTypeTuple>& obj )
buffer << static_cast<size_t> (obj.size()); // Encoding the number of contained bodies
// Encoding the contained primitives
const typename Union<BodyTypeTuple>::const_iterator begin( obj.begin() );
const typename Union<BodyTypeTuple>::const_iterator end ( obj.end() );
for( typename Union<BodyTypeTuple>::const_iterator body=begin; body!=end; ++body )
const typename Union<BodyTypes...>::const_iterator begin( obj.begin() );
const typename Union<BodyTypes...>::const_iterator end ( obj.end() );
for( typename Union<BodyTypes...>::const_iterator body=begin; body!=end; ++body )
{
buffer << body->getTypeID();
MarshalDynamically<BodyTypeTuple>::execute( buffer, *body );
MarshalDynamically<std::tuple<BodyTypes...>>::execute( buffer, *body );
}
}
......@@ -109,13 +111,13 @@ void unmarshal( mpi::RecvBuffer& buffer, UnionParameters& objparam )
//*************************************************************************************************
template <typename BodyTypeTuple>
inline std::unique_ptr<Union<BodyTypeTuple>> instantiate( mpi::RecvBuffer& buffer, const math::AABB& domain, const math::AABB& block, Union<BodyTypeTuple>*& newBody )
template <typename... BodyTypes>
inline std::unique_ptr<Union<BodyTypes...>> instantiate( mpi::RecvBuffer& buffer, const math::AABB& domain, const math::AABB& block, Union<BodyTypes...>*& newBody )
{
UnionParameters subobjparam;
unmarshal( buffer, subobjparam );
correctBodyPosition(domain, block.center(), subobjparam.gpos_);
auto un = std::make_unique<Union<BodyTypeTuple>>( subobjparam.sid_,
auto un = std::make_unique<Union<BodyTypes...>>( subobjparam.sid_,
subobjparam.uid_,
subobjparam.gpos_,
subobjparam.rpos_,
......@@ -131,7 +133,7 @@ inline std::unique_ptr<Union<BodyTypeTuple>> instantiate( mpi::RecvBuffer& buffe
{
decltype ( static_cast<BodyID>(nullptr)->getTypeID() ) type;
buffer >> type;
BodyPtr obj( UnmarshalDynamically<BodyTypeTuple>::execute(buffer, type, domain, block) );
BodyPtr obj( UnmarshalDynamically<std::tuple<BodyTypes...>>::execute(buffer, type, domain, block) );
obj->setRemote( true );
un->add(std::move(obj));
}
......
......@@ -37,8 +37,6 @@
#include "core/math/Shims.h"
#include "geometry/GeometricalFunctions.h"
#include <tuple>
namespace walberla {
namespace pe {
namespace fcd {
......@@ -110,17 +108,17 @@ template <typename Container>
inline
bool collide( CapsuleID c, BoxID b, Container& container );
template <typename BodyTypeTuple, typename BodyB, typename Container>
template <typename... BodyTypes, typename BodyB, typename Container>
inline
bool collide( Union<BodyTypeTuple>* bd1, BodyB* bd2, Container& container );
bool collide( Union<BodyTypes...>* bd1, BodyB* bd2, Container& container );
template <typename BodyA, typename BodyTypeTuple, typename Container>
template <typename BodyA, typename... BodyTypes, typename Container>
inline
bool collide( BodyA* bd1, Union<BodyTypeTuple>* bd2, Container& container );
bool collide( BodyA* bd1, Union<BodyTypes...>* bd2, Container& container );
template <typename BodyTypeTupleA, typename BodyTypeTupleB, typename Container>
template <typename... BodyTypesA, typename... BodyTypesB, typename Container>
inline
bool collide( Union<BodyTypeTupleA>* bd1, Union<BodyTypeTupleB>* bd2, Container& container );
bool collide( Union<BodyTypesA...>* bd1, Union<BodyTypesB...>* bd2, Container& container );
} //namespace analytic
......@@ -2120,29 +2118,29 @@ bool collide( CapsuleID c, BoxID b, Container& container )
return collide(b, c, container);
}
template <typename BodyTypeTuple, typename BodyB, typename Container>
template <typename... BodyTypes, typename BodyB, typename Container>
inline
bool collide( Union<BodyTypeTuple>* bd1, BodyB* bd2, Container& container )
bool collide( Union<BodyTypes...>* bd1, BodyB* bd2, Container& container )
{
AnalyticSingleCollideFunctor<BodyB, Container> func(bd2, container);
bool collision = false;
for( auto it=bd1->begin(); it!=bd1->end(); ++it )
{
collision |= SingleCast<BodyTypeTuple, AnalyticSingleCollideFunctor<BodyB, Container>, bool>::execute(it.getBodyID(), func);
collision |= SingleCast<std::tuple<BodyTypes...>, AnalyticSingleCollideFunctor<BodyB, Container>, bool>::execute(it.getBodyID(), func);
}
return collision;
}
template <typename BodyA, typename BodyTypeTuple, typename Container>
template <typename BodyA, typename... BodyTypes, typename Container>
inline
bool collide( BodyA* bd1, Union<BodyTypeTuple>* bd2, Container& container )
bool collide( BodyA* bd1, Union<BodyTypes...>* bd2, Container& container )
{
return collide (bd2, bd1, container);
}
template <typename BodyTypeTupleA, typename BodyTypeTupleB, typename Container>
template <typename... BodyTypesA, typename... BodyTypesB, typename Container>
inline
bool collide( Union<BodyTypeTupleA>* bd1, Union<BodyTypeTupleB>* bd2, Container& container )
bool collide( Union<BodyTypesA...>* bd1, Union<BodyTypesB...>* bd2, Container& container )
{
AnalyticCollideFunctor<Container> func(container);
bool collision = false;
......@@ -2150,7 +2148,7 @@ bool collide( Union<BodyTypeTupleA>* bd1, Union<BodyTypeTupleB>* bd2, Container&
{
for( auto it2=bd2->begin(); it2!=bd2->end(); ++it2 )
{
collision |= DoubleCast<BodyTypeTupleA, BodyTypeTupleB, AnalyticCollideFunctor<Container>, bool>::execute(it1.getBodyID(), it2.getBodyID(), func);
collision |= DoubleCast<std::tuple<BodyTypesA...>, std::tuple<BodyTypesB...>, AnalyticCollideFunctor<Container>, bool>::execute(it1.getBodyID(), it2.getBodyID(), func);
}
}
return collision;
......
......@@ -28,7 +28,6 @@
#include "pe/rigidbody/Plane.h"
#include "pe/rigidbody/Union.h"
#include <pe/Thresholds.h>
#include <tuple>
namespace walberla{
namespace pe{
......@@ -50,25 +49,25 @@ namespace gjkepa{
inline bool generateContacts(Plane *a, Plane *b, Container& contacts_);
//Unions
template<typename BodyTupleA, typename BodyB, typename Container>
inline bool generateContacts(Union<BodyTupleA> *a, BodyB *b, Container& contacts_);
template<typename... BodyTypesA, typename BodyB, typename Container>
inline bool generateContacts(Union<BodyTypesA...> *a, BodyB *b, Container& contacts_);
template<typename BodyA, typename BodyTupleB, typename Container>
inline bool generateContacts(BodyA *a, Union<BodyTupleB> *b, Container& contacts_);
template<typename BodyA, typename... BodyTypesB, typename Container>
inline bool generateContacts(BodyA *a, Union<BodyTypesB...> *b, Container& contacts_);
template<typename BodyTupleA, typename BodyTupleB, typename Container>
inline bool generateContacts(Union<BodyTupleA> *a, Union<BodyTupleB> *b, Container& contacts_);
template<typename... BodyTypesA, typename... BodyTypesB, typename Container>
inline bool generateContacts(Union<BodyTypesA...> *a, Union<BodyTypesB...> *b, Container& contacts_);
//Union and Plane
template<typename BodyTupleA, typename Container>
inline bool generateContacts(Union<BodyTupleA> *a, Plane *b, Container& contacts_);
template<typename... BodyTypesA, typename Container>
inline bool generateContacts(Union<BodyTypesA...> *a, Plane *b, Container& contacts_);
template<typename BodyTupleB, typename Container>
inline bool generateContacts(Plane *a, Union<BodyTupleB> *b, Container& contacts_);
template<typename... BodyTypesB, typename Container>
inline bool generateContacts(Plane *a, Union<BodyTypesB...> *b, Container& contacts_);
}
/* Iterative Collide Functor for contact Generation with iterative collision detection (GJK and EPA algorithms).
* Usage: fcd::GenericFCD<BodyTuple, fcd::GJKEPACollideFunctor> testFCD;
* Usage: fcd::GenericFCD<BodyTypes..., fcd::GJKEPACollideFunctor> testFCD;
* testFCD.generateContacts(...);
*/
template <typename Container>
......@@ -163,50 +162,50 @@ namespace gjkepa{
}
//Unions
template<typename BodyTupleA, typename BodyB, typename Container>
inline bool generateContacts(Union<BodyTupleA> *a, BodyB *b, Container& contacts_){
template<typename... BodyTypesA, typename BodyB, typename Container>
inline bool generateContacts(Union<BodyTypesA...> *a, BodyB *b, Container& contacts_){
GJKEPASingleCollideFunctor<BodyB, Container> func(b, contacts_);
bool collision = false;
for( auto it=a->begin(); it!=a->end(); ++it )
{
collision |= SingleCast<BodyTupleA, GJKEPASingleCollideFunctor<BodyB, Container>, bool>::execute(it.getBodyID(), func);
collision |= SingleCast<std::tuple<BodyTypesA...>, GJKEPASingleCollideFunctor<BodyB, Container>, bool>::execute(it.getBodyID(), func);
}
return collision;
}
template<typename BodyA, typename BodyTupleB, typename Container>
inline bool generateContacts(BodyA *a, Union<BodyTupleB> *b, Container& contacts_){
template<typename BodyA, typename... BodyTypesB, typename Container>
inline bool generateContacts(BodyA *a, Union<BodyTypesB...> *b, Container& contacts_){
return generateContacts(b, a, contacts_);
}
template<typename BodyTupleA, typename BodyTupleB, typename Container>
inline bool generateContacts(Union<BodyTupleA> *a, Union<BodyTupleB> *b, Container& contacts_){
template<typename... BodyTypesA, typename... BodyTypesB, typename Container>
inline bool generateContacts(Union<BodyTypesA...> *a, Union<BodyTypesB...> *b, Container& contacts_){
GJKEPACollideFunctor<Container> func(contacts_);
bool collision = false;
for( auto it1=a->begin(); it1!=a->end(); ++it1 )
{
for( auto it2=b->begin(); it2!=b->end(); ++it2 )
{
collision |= DoubleCast<BodyTupleA, BodyTupleB, GJKEPACollideFunctor<Container>, bool>::execute(it1.getBodyID(), it2.getBodyID(), func);
collision |= DoubleCast<std::tuple<BodyTypesA...>, std::tuple<BodyTypesB...>, GJKEPACollideFunctor<Container>, bool>::execute(it1.getBodyID(), it2.getBodyID(), func);
}
}
return collision;
}
//Union and Plane (these calls are ambigous if not implemented seperatly)
template<typename BodyTupleA, typename Container>
inline bool generateContacts(Union<BodyTupleA> *a, Plane *b, Container& contacts_){
template<typename... BodyTypesA, typename Container>
inline bool generateContacts(Union<BodyTypesA...> *a, Plane *b, Container& contacts_){
GJKEPASingleCollideFunctor<Plane, Container> func(b, contacts_);
bool collision = false;
for( auto it=a->begin(); it!=a->end(); ++it )
{
collision |= SingleCast<BodyTupleA, GJKEPASingleCollideFunctor<Plane, Container>, bool>::execute(it.getBodyID(), func);
collision |= SingleCast<std::tuple<BodyTypesA...>, GJKEPASingleCollideFunctor<Plane, Container>, bool>::execute(it.getBodyID(), func);
}
return collision;
}
template<typename BodyTupleB, typename Container>
inline bool generateContacts(Plane *a, Union<BodyTupleB> *b, Container& contacts_){
template<typename... BodyTypesB, typename Container>
inline bool generateContacts(Plane *a, Union<BodyTypesB...> *b, Container& contacts_){
return generateContacts(b, a, contacts_);
}
......
......@@ -23,7 +23,6 @@
#include "AnalyticCollisionDetection.h"
#include "GenericFCD.h"
#include <tuple>
#include <type_traits>
namespace walberla{
......
......@@ -30,7 +30,6 @@
#include "pe/rigidbody/Union.h"
#include "pe/utility/BodyCast.h"
#include <core/math/Utility.h>
#include <tuple>
#include <pe/raytracing/Ray.h>
......
......@@ -39,7 +39,7 @@
namespace walberla{
namespace pe{
template <typename BodyTypeTuple>
template <typename... BodyTypes>
class Union;
/**
......@@ -50,7 +50,7 @@ class RigidBody : public ccd::HashGridsBodyTrait
, private NonCopyable
{
private:
template <typename BodyTypeTuple>
template <typename... BodyTypes>
friend class Union;
protected:
......
This diff is collapsed.
......@@ -50,7 +50,7 @@ namespace pe {
* \ingroup pe
* \brief Setup of a new Union.
*
* \tparam BodyTypeTuple std::tuple of all geometries the Union should be able to contain
* \tparam BodyTypes all geometries the Union should be able to contain
* \param globalStorage process local global storage
* \param blocks storage of all the blocks on this process
* \param storageID BlockDataID of the BlockStorage block datum
......@@ -67,23 +67,23 @@ namespace pe {
* \snippet PeDocumentationSnippets.cpp Definition of Union Types
* \snippet PeDocumentationSnippets.cpp Create a Union
*/
template <typename BodyTypeTuple>
Union<BodyTypeTuple>* createUnion( BodyStorage& globalStorage, BlockStorage& blocks, BlockDataID storageID,
template <typename... BodyTypes>
Union<BodyTypes...>* createUnion( BodyStorage& globalStorage, BlockStorage& blocks, BlockDataID storageID,
id_t uid, const Vec3& gpos,
bool global = false, bool communicating = true, bool infiniteMass = false )
{
if (Union<BodyTypeTuple>::getStaticTypeID() == std::numeric_limits<id_t>::max())
if (Union<BodyTypes...>::getStaticTypeID() == std::numeric_limits<id_t>::max())
throw std::runtime_error("Union TypeID not initalized!");
Union<BodyTypeTuple>* bd = nullptr;
Union<BodyTypes...>* bd = nullptr;
if (global)
{
const id_t sid = UniqueID<RigidBody>::createGlobal();
WALBERLA_ASSERT_EQUAL(communicating, false);
WALBERLA_ASSERT_EQUAL(infiniteMass, true);
auto un = std::make_unique<Union<BodyTypeTuple>>(sid, uid, gpos, Vec3(0,0,0), Quat(), global, false, true);
bd = static_cast<Union<BodyTypeTuple>*>(&globalStorage.add(std::move(un)));
auto un = std::make_unique<Union<BodyTypes...>>(sid, uid, gpos, Vec3(0,0,0), Quat(), global, false, true);
bd = static_cast<Union<BodyTypes...>*>(&globalStorage.add(std::move(un)));
} else
{
for (auto& block : blocks){
......@@ -92,9 +92,9 @@ Union<BodyTypeTuple>* createUnion( BodyStorage& globalStorage, BlockStorage& b
const id_t sid( UniqueID<RigidBody>::create() );
BodyStorage& bs = (*block.getData<Storage>(storageID))[0];
auto un = std::make_unique<Union<BodyTypeTuple>>(sid, uid, gpos, Vec3(0,0,0), Quat(), global, communicating, infiniteMass);
auto un = std::make_unique<Union<BodyTypes...>>(sid, uid, gpos, Vec3(0,0,0), Quat(), global, communicating, infiniteMass);
un->MPITrait.setOwner(Owner(MPIManager::instance()->rank(), block.getId().getID()));
bd = static_cast<Union<BodyTypeTuple>*>(&bs.add(std::move(un)));
bd = static_cast<Union<BodyTypes...>*>(&bs.add(std::move(un)));
}
}
}
......@@ -116,15 +116,15 @@ Union<BodyTypeTuple>* createUnion( BodyStorage& globalStorage, BlockStorage& b
* \ingroup pe
* \brief Setup of a new Box directly attached to a Union.
*
* \tparam BodyTypeTuple std::tuple of all geometries the Union is able to contain
* \tparam BodyTypes all geometries the Union is able to contain
* \exception std::runtime_error Box TypeID not initalized!
* \exception std::invalid_argument createBox: Union argument is NULL
* \exception std::logic_error createBox: Union is remote
* \exception std::invalid_argument Invalid side length
* \see createBox for more details
*/
template <typename BodyTypeTuple>
BoxID createBox( Union<BodyTypeTuple>* un,
template <typename... BodyTypes>
BoxID createBox( Union<BodyTypes...>* un,
id_t uid, const Vec3& gpos, const Vec3& lengths,
MaterialID material = Material::find("iron"),
bool global = false, bool communicating = true, bool infiniteMass = false )
......@@ -180,7 +180,7 @@ BoxID createBox( Union<BodyTypeTuple>* un,
* \ingroup pe
* \brief Setup of a new Capsule directly attached to a Union.
*
* \tparam BodyTypeTuple std::tuple of all geometries the Union is able to contain
* \tparam BodyTypes all geometries the Union is able to contain
* \exception std::runtime_error Capsule TypeID not initalized!
* \exception std::invalid_argument createCapsule: Union argument is NULL
* \exception std::logic_error createCapsule: Union is remote
......@@ -189,8 +189,8 @@ BoxID createBox( Union<BodyTypeTuple>* un,
*
* \see createCapsule for more details
*/
template <typename BodyTypeTuple>
CapsuleID createCapsule( Union<BodyTypeTuple>* un,
template <typename... BodyTypes>
CapsuleID createCapsule( Union<BodyTypes...>* un,
id_t uid, const Vec3& gpos, const real_t radius, const real_t length,
MaterialID material = Material::find("iron"),
bool global = false, bool communicating = true, bool infiniteMass = false )
......@@ -242,7 +242,7 @@ CapsuleID createCapsule( Union<BodyTypeTuple>* un,
* \ingroup pe
* \brief Setup of a new Sphere directly attached to a Union.
*
* \tparam BodyTypeTuple std::tuple of all geometries the Union is able to contain
* \tparam BodyTypes all geometries the Union is able to contain
* \exception std::runtime_error Sphere TypeID not initalized!
* \exception std::invalid_argument createSphere: Union argument is NULL
* \exception std::logic_error createSphere: Union is remote
......@@ -250,8 +250,8 @@ CapsuleID createCapsule( Union<BodyTypeTuple>* un,
*
* \see createSphere for more details
*/
template <typename BodyTypeTuple>
SphereID createSphere( Union<BodyTypeTuple>* un,
template <typename... BodyTypes>
SphereID createSphere( Union<BodyTypes...>* un,
id_t uid, const Vec3& gpos, real_t radius,
MaterialID material = Material::find("iron"),
bool global = false, bool communicating = true, bool infiniteMass = false )
......
......@@ -58,36 +58,36 @@ void SphereVtkOutput::configure()
{
if (body.getTypeID() == Sphere::getStaticTypeID() || body.getTypeID() == Squirmer::getStaticTypeID())
bodies_.push_back( static_cast<Sphere const *> (&body) );
if (body.getTypeID() == Union<std::tuple<Sphere> >::getStaticTypeID())
if (body.getTypeID() == Union<Sphere>::getStaticTypeID())
{
auto un = static_cast<Union<std::tuple<Sphere> > const * > (&body);
auto un = static_cast<Union<Sphere> const * > (&body);
for( auto it2 = un->begin(); it2 != un->end(); ++it2 )
{
if (it2->getTypeID() == Sphere::getStaticTypeID())
bodies_.push_back( static_cast<ConstSphereID> (it2.getBodyID()) );
}
}
if (body.getTypeID() == Union<std::tuple<Squirmer> >::getStaticTypeID())
if (body.getTypeID() == Union<Squirmer>::getStaticTypeID())
{
auto un = static_cast<Union<std::tuple<Squirmer> > const * > (&body);
auto un = static_cast<Union<Squirmer> const * > (&body);
for( auto it2 = un->begin(); it2 != un->end(); ++it2 )
{
if (it2->getTypeID() == Squirmer::getStaticTypeID())
bodies_.push_back( static_cast<ConstSphereID> (it2.getBodyID()) );
}
}
if (body.getTypeID() == Union<std::tuple<Sphere,Squirmer> >::getStaticTypeID())
if (body.getTypeID() == Union<Sphere,Squirmer>::getStaticTypeID())
{
auto un = static_cast<Union<std::tuple<Sphere,Squirmer> > const * > (&body);
auto un = static_cast<Union<Sphere,Squirmer> const * > (&body);
for( auto it2 = un->begin(); it2 != un->end(); ++it2 )
{
if (it2->getTypeID() == Sphere::getStaticTypeID() || it2->getTypeID() == Squirmer::getStaticTypeID())
bodies_.push_back( static_cast<ConstSphereID> (it2.getBodyID()) );
}
}
if (body.getTypeID() == Union<std::tuple<Squirmer,Sphere> >::getStaticTypeID())
if (body.getTypeID() == Union<Squirmer,Sphere>::getStaticTypeID())
{
auto un = static_cast<Union<std::tuple<Squirmer,Sphere> > const * > (&body);
auto un = static_cast<Union<Squirmer,Sphere> const * > (&body);
for( auto it2 = un->begin(); it2 != un->end(); ++it2 )
{
if (it2->getTypeID() == Sphere::getStaticTypeID() || it2->getTypeID() == Squirmer::getStaticTypeID())
......
......@@ -41,8 +41,7 @@ namespace walberla {
using namespace walberla::pe;
using namespace walberla::pe::communication;
using UnionTypeTuple = std::tuple<mesh::pe::ConvexPolyhedron>;
using UnionT = Union<UnionTypeTuple>;
using UnionT = Union<mesh::pe::ConvexPolyhedron>;
using UnionID = UnionT *;
using UnionPtr = std::unique_ptr<UnionT>;
......
......@@ -235,7 +235,7 @@ void CapsuleTest2()
void UnionTest()
{
using UnionT = Union<std::tuple<Sphere> >;
using UnionT = Union<Sphere>;
UnionT un1(120, 0, Vec3(0,0,0), Vec3(0,0,0), Quat(), false, true, false);
UnionT un2(121, 0, Vec3(real_t(1.5),0,0), Vec3(0,0,0), Quat(), false, true, false);
auto sp1 = createSphere(&un1, 123, Vec3(0,0,0), 1);
......
......@@ -49,7 +49,7 @@
namespace walberla {
using namespace walberla::pe;
typedef std::tuple<Box, Capsule, Plane, Sphere, Union<std::tuple<Sphere>>, Union<std::tuple<Sphere, Union<std::tuple<Sphere>>>>, Ellipsoid> BodyTuple ;
typedef std::tuple<Box, Capsule, Plane, Sphere, Union<Sphere>, Union<Sphere, Union<Sphere>>, Ellipsoid> BodyTuple ;
bool gjkEPAcollideHybrid(GeomPrimitive &geom1, GeomPrimitive &geom2, Vec3& normal, Vec3& contactPoint, real_t& penetrationDepth)
{
......@@ -356,20 +356,20 @@ void UnionTest(){
Box box(179, 179, Vec3(0,0,0), Vec3(0,0,0), Quat(), Vec3(real_t(10),real_t(2), real_t(10)), iron, false, true, false);
using UnionT = Union<std::tuple<Sphere>>;
using UnionT = Union<Sphere>;
auto unsub = std::make_unique<UnionT>(192, 192, Vec3(0,real_t(3.8),0), Vec3(0,0,0), Quat(), false, true, false);
auto sp1 = createSphere(unsub.get(), 180, Vec3(-3,real_t(3.8),0), real_t(3.0));
auto sp2 = createSphere(unsub.get(), 181, Vec3(3,real_t(3.8),0), real_t(3.0));
//Create another union, and add sub union
Union<std::tuple<Sphere, Union<std::tuple<Sphere>>>> un(193, 193, Vec3(0, 0, 0), Vec3(0,0,0), Quat(), false, true, false);
Union<Sphere, Union<Sphere>> un(193, 193, Vec3(0, 0, 0), Vec3(0,0,0), Quat(), false, true, false);
createSphere(&un, 182, Vec3(0,real_t(6),0), real_t(3.0));
un.add(std::move(unsub));
PossibleContacts pcs;
pcs.push_back(std::pair<Union<std::tuple<Sphere,Union<std::tuple<Sphere>>>>*, Box*>(&un, &box));
pcs.push_back(std::pair<Union<Sphere,Union<Sphere>>*, Box*>(&un, &box));
Contacts& container = testFCD.generateContacts(pcs);
WALBERLA_CHECK(container.size() == 2);
......@@ -397,7 +397,7 @@ void UnionTest(){
pcs.clear();
//Vice Versa
pcs.push_back(std::pair<Box*, Union<std::tuple<Sphere, Union<std::tuple<Sphere>>>>* >(&box, &un));
pcs.push_back(std::pair<Box*, Union<Sphere, Union<Sphere>>* >(&box, &un));
container = testFCD.generateContacts(pcs);
WALBERLA_CHECK(container.size() == 2);
......
......@@ -38,8 +38,7 @@ namespace walberla {
using namespace walberla::pe;
using namespace walberla::pe::communication;
using UnionTypeTuple = std::tuple<Sphere>;
using UnionT = Union<UnionTypeTuple>;
using UnionT = Union<Sphere>;
using UnionID = UnionT *;
using UnionPtr = std::unique_ptr<UnionT>;
......@@ -171,8 +170,8 @@ void testUnion()
{
WALBERLA_LOG_INFO_ON_ROOT("*** testUnion ***");
UnionT u1(159, 423, Vec3(real_c(1), real_c(2), real_c(3)), Vec3(0,0,0), Quat(), false, false, false);
SphereID s11 = createSphere< UnionTypeTuple >(&u1, 1234794, Vec3(real_c(1), real_c(2), real_c(3)), 2);
SphereID s21 = createSphere< UnionTypeTuple >(&u1, 4567789, Vec3(real_c(3), real_c(2), real_c(3)), real_c(1.5));
SphereID s11 = createSphere(&u1, 1234794, Vec3(real_c(1), real_c(2), real_c(3)), 2);
SphereID s21 = createSphere(&u1, 4567789, Vec3(real_c(3), real_c(2), real_c(3)), real_c(1.5));
WALBERLA_CHECK_NOT_NULLPTR( s11 );
WALBERLA_CHECK_NOT_NULLPTR( s21 );
......
......@@ -47,8 +47,7 @@ namespace walberla {
using namespace walberla::pe;
//! [Definition of Union Types]
typedef std::tuple<Box, Capsule, Sphere> UnionTypeTuple;
using UnionT = Union<UnionTypeTuple>;
using UnionT = Union<Box, Capsule, Sphere>;
using UnionID = UnionT *;
//! [Definition of Union Types]
......@@ -123,7 +122,7 @@ int main( int argc, char ** argv )
//! [Create a Union]
// Create a union and add a box, capsule and sphere.
UnionID un = createUnion<UnionTypeTuple>( *globalBodyStorage, forest->getBlockStorage(), storageID, 1, Vec3(2,3,4) );
UnionID un = createUnion<Box, Capsule, Sphere>( *globalBodyStorage, forest->getBlockStorage(), storageID, 1, Vec3(2,3,4) );
if (un != nullptr)
{
createBox ( un, 1, Vec3(2,3,4), Vec3(2.5,2.5,2.5) );
......
......@@ -125,7 +125,7 @@ int main( int argc, char** argv )
WALBERLA_CHECK_UNEQUAL(A::getStaticTypeID(), C::getStaticTypeID());
WALBERLA_CHECK_UNEQUAL(B::getStaticTypeID(), C::getStaticTypeID());
typedef std::tuple<Plane, Sphere, Box, Capsule, Union< std::tuple<Sphere, Box> > > BodyTuple2 ;
typedef std::tuple<Plane, Sphere, Box, Capsule, Union<Sphere, Box> > BodyTuple2 ;
SetBodyTypeIDs<BodyTuple2>::execute();
WALBERLA_CHECK_UNEQUAL(Plane::getStaticTypeID(), Sphere::getStaticTypeID());
WALBERLA_CHECK_UNEQUAL(Plane::getStaticTypeID(), Box::getStaticTypeID());
......
......@@ -34,7 +34,7 @@
namespace walberla {
using namespace walberla::pe;
using UnionT = Union<std::tuple<Sphere> >;
using UnionT = Union<Sphere>;
typedef std::tuple<Sphere, UnionT> BodyTuple ;
int main( int argc, char** argv )
......@@ -126,7 +126,7 @@ int main( int argc, char** argv )
destroyBodyBySID( *globalBodyStorage, forest->getBlockStorage(), storageID, sid );
WALBERLA_LOG_PROGRESS_ON_ROOT( " *** UNION *** ");
UnionT* un = createUnion< std::tuple<Sphere> >( *globalBodyStorage, forest->getBlockStorage(), storageID, 0, Vec3(2,2,2) );
UnionT* un = createUnion<Sphere>( *globalBodyStorage, forest->getBlockStorage(), storageID, 0, Vec3(2,2,2) );
auto sp1 = createSphere(un, 10, Vec3(real_t(4.9),2,2), real_t(1));
auto sp2 = createSphere(un, 11, Vec3(3,2,2), real_t(1.5));
un->setPosition( Vec3( real_t(4.9), 2, 2) );
......
......@@ -44,7 +44,7 @@
namespace walberla {
using namespace walberla::pe;
using UnionType = Union<std::tuple<Sphere> > ;
using UnionType = Union<Sphere> ;
typedef std::tuple<Sphere, Plane, UnionType> BodyTuple ;
void SnowManFallingOnPlane()
......@@ -75,7 +75,7 @@ void SnowManFallingOnPlane()
createPlane( *globalBodyStorage, 0, Vec3(0,0,1), Vec3(0,0,0) );
UnionType* un = createUnion< std::tuple<Sphere> >( *globalBodyStorage, forest->getBlockStorage(), storageID, 0, Vec3(5,5,5) );
UnionType* un = createUnion<Sphere>( *globalBodyStorage, forest->getBlockStorage(), storageID, 0, Vec3(5,5,5) );
auto sp1 = createSphere(un, 10, Vec3(5,5,1), real_t(1));
auto sp2 = createSphere(un, 11, Vec3(real_t(6.7),5,real_t(1.2)), real_t(1.1));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment