Skip to content
Snippets Groups Projects
Commit f1d34a9e authored by Tobias Leemann's avatar Tobias Leemann
Browse files

Added Marshalling Test, Setters for EPA memory limits, Recursive Union Call

parent 889cc14a
Branches
Tags
No related merge requests found
...@@ -90,6 +90,20 @@ public: ...@@ -90,6 +90,20 @@ public:
//@} //@}
//********************************************************************************************** //**********************************************************************************************
//**Getter/Setter functions*****************************************************************************
/*!\name Getter and Setter functions */
//@{
inline void setMaxSupportPoints( size_t maxSupportPoints) {maxSupportPoints_ = maxSupportPoints;}
inline size_t getMaxSupportPoints() {return maxSupportPoints_;}
inline void setMaxTriangles( size_t maxTriangles) {maxTriangles_ = maxTriangles;}
inline size_t getMaxTriangles() {return maxTriangles_;}
//@}
//**********************************************************************************************
private: private:
//**Utility functions*************************************************************************** //**Utility functions***************************************************************************
/*!\name Utility functions */ /*!\name Utility functions */
...@@ -128,8 +142,8 @@ private: ...@@ -128,8 +142,8 @@ private:
private: private:
//EPA constants //EPA constants
static const size_t maxSupportPoints_ = 100; size_t maxSupportPoints_ = 100;
static const size_t maxTriangles_ = 200; size_t maxTriangles_ = 200;
}; };
//************************************************************************************************* //*************************************************************************************************
......
...@@ -109,7 +109,7 @@ private: ...@@ -109,7 +109,7 @@ private:
* \param bd1 The first body. * \param bd1 The first body.
* \param bd2 The second body. * \param bd2 The second body.
* *
* This function is called by generateContacts() on all normal * This function is called by generateContactsPair() on all normal (single)
* body pairs and on each single bodys of the union. * body pairs and on each single bodys of the union.
* It checks if one of the bodies is a plane and calls the corresponding * It checks if one of the bodies is a plane and calls the corresponding
* detection function. If collision is detected a Contact is generated and * detection function. If collision is detected a Contact is generated and
...@@ -152,6 +152,38 @@ private: ...@@ -152,6 +152,38 @@ private:
} }
} }
/* Resolve pairs with unions and call generateContacts single for each pair of non-united
* particles.
*/
void generateContactsPair(BodyID bd1, BodyID bd2){
bool hasSubbodies1 = bd1->hasSubBodies();
if( hasSubbodies1 ){
UnionGenericType* u1 = nullptr;
u1= static_cast<UnionGenericType*>(bd1);
//Loop over possible subbodies of first rigid body
auto it1 = u1->begin();
while(it1 != u1->end()){
generateContactsPair(*it1, bd2);
it1++;
}
}else{
//bd1 is a single body
bool hasSubbodies2 = bd2->hasSubBodies();
if( hasSubbodies2 ){
UnionGenericType* u2 = nullptr;
u2= static_cast<UnionGenericType*>(bd2);
auto it2 = u2->begin();
while(it2 != u2->end()){
generateContactsPair(bd1, *it2);
it2++;
}
}else{
//bd1 and bd2 are single bodies
generateContactsSingle(bd1, bd2);
}
}
}
public: public:
/*!\brief Checks each body pair in the given vector and generates /*!\brief Checks each body pair in the given vector and generates
* a vector of contacts. * a vector of contacts.
...@@ -164,25 +196,7 @@ public: ...@@ -164,25 +196,7 @@ public:
contacts_.clear(); contacts_.clear();
for (auto it = possibleContacts.begin(); it != possibleContacts.end(); ++it) for (auto it = possibleContacts.begin(); it != possibleContacts.end(); ++it)
{ {
bool hasSubbodies1 = it->first->hasSubBodies(); generateContactsPair(it->first, it->second);
UnionGenericType* u1 = nullptr;
if( hasSubbodies1 ){
u1= static_cast<UnionGenericType*>(it->first);
}
//Loop over possible subbodies of first rigid body
for(size_t bodynum1 = 0; bodynum1 < (hasSubbodies1 ? u1->size() : 1); bodynum1++){
BodyID bd1 = (hasSubbodies1 ? u1->getBody(bodynum1) : it->first);
bool hasSubbodies2 = it->second->hasSubBodies();
UnionGenericType* u2 = nullptr;
if( hasSubbodies2 ){
u2= static_cast<UnionGenericType*>(it->second);
}
//Loop over possible subbodies of second rigid body
for(size_t bodynum2 = 0; bodynum2 < (hasSubbodies2 ? u2->size() : 1); bodynum2++){
BodyID bd2 = (hasSubbodies2 ? u2->getBody(bodynum2) : it->second);
generateContactsSingle(bd1, bd2);
}
}
} }
return contacts_; return contacts_;
} }
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "pe/rigidbody/Squirmer.h" #include "pe/rigidbody/Squirmer.h"
#include "pe/rigidbody/UnionFactory.h" #include "pe/rigidbody/UnionFactory.h"
#include "pe/rigidbody/Union.h" #include "pe/rigidbody/Union.h"
#include "pe/rigidbody/Ellipsoid.h"
#include "pe/communication/rigidbody/Squirmer.h" #include "pe/communication/rigidbody/Squirmer.h"
#include "pe/communication/DynamicMarshalling.h" #include "pe/communication/DynamicMarshalling.h"
#include "pe/rigidbody/SetBodyTypeIDs.h" #include "pe/rigidbody/SetBodyTypeIDs.h"
...@@ -41,7 +42,7 @@ typedef boost::tuple<Sphere> UnionTypeTuple; ...@@ -41,7 +42,7 @@ typedef boost::tuple<Sphere> UnionTypeTuple;
typedef Union< UnionTypeTuple > UnionT; typedef Union< UnionTypeTuple > UnionT;
typedef UnionT* UnionID; typedef UnionT* UnionID;
typedef boost::tuple<Box, Capsule, Sphere, Squirmer, UnionT> BodyTuple ; typedef boost::tuple<Box, Capsule, Sphere, Squirmer, UnionT, Ellipsoid> BodyTuple ;
void testBox() void testBox()
{ {
...@@ -128,6 +129,28 @@ void testSquirmer() ...@@ -128,6 +129,28 @@ void testSquirmer()
WALBERLA_CHECK_FLOAT_EQUAL(s1.getSquirmerBeta(), s2->getSquirmerBeta()); WALBERLA_CHECK_FLOAT_EQUAL(s1.getSquirmerBeta(), s2->getSquirmerBeta());
} }
void testEllipsoid()
{
MaterialID iron = Material::find("iron");
Ellipsoid e1(759847, 1234795, Vec3(real_c(1), real_c(2), real_c(3)), Vec3(0,0,0), Quat(), Vec3(3,1,5), iron, false, false, false);
e1.setLinearVel(Vec3(real_c(5.2), real_c(6.3), real_c(7.4)));
e1.setAngularVel(Vec3(real_c(1.2), real_c(2.3), real_c(3.4)));
mpi::SendBuffer sb;
MarshalDynamically<BodyTuple>::execute(sb, e1);
mpi::RecvBuffer rb(sb);
EllipsoidID e2 = static_cast<EllipsoidID> (UnmarshalDynamically<BodyTuple>::execute(rb, Ellipsoid::getStaticTypeID(), math::AABB(Vec3(-100,-100,-100), Vec3(100,100,100)), math::AABB(Vec3(-100,-100,-100), Vec3(100,100,100))));
WALBERLA_CHECK_FLOAT_EQUAL(e1.getPosition(), e2->getPosition());
WALBERLA_CHECK_FLOAT_EQUAL(e1.getLinearVel(), e2->getLinearVel());
WALBERLA_CHECK_FLOAT_EQUAL(e1.getAngularVel(), e2->getAngularVel());
WALBERLA_CHECK_FLOAT_EQUAL(e1.getSemiAxes(), e2->getSemiAxes());
WALBERLA_CHECK_EQUAL(e1.getID(), e2->getID());
WALBERLA_CHECK_EQUAL(e1.getSystemID(), e2->getSystemID());
}
void testUnion() void testUnion()
{ {
UnionT u1(159, 423, Vec3(real_c(1), real_c(2), real_c(3)), Vec3(0,0,0), Quat(), false, false, false); UnionT u1(159, 423, Vec3(real_c(1), real_c(2), real_c(3)), Vec3(0,0,0), Quat(), false, false, false);
...@@ -179,6 +202,7 @@ int main( int argc, char** argv ) ...@@ -179,6 +202,7 @@ int main( int argc, char** argv )
testCapsule(); testCapsule();
testUnion(); testUnion();
testSquirmer(); testSquirmer();
testEllipsoid();
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
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