Commit 5e29f153 authored by Christoph Schwarzmeier's avatar Christoph Schwarzmeier
Browse files

Merge branch 'mr_mesapd_shape_integration_fix' into 'master'

Fix of integration of angular velocity of non-spherical particles

See merge request walberla/walberla!527
parents 27e2bc06 b67091ed
......@@ -28,6 +28,7 @@
#include <mesa_pd/data/DataTypes.h>
#include <mesa_pd/data/IAccessor.h>
#include <mesa_pd/common/ParticleFunctions.h>
namespace walberla {
namespace mesa_pd {
......@@ -89,8 +90,13 @@ inline void ExplicitEuler::operator()(const size_t idx,
{
ac.setPosition (idx, ac.getInvMass(idx) * ac.getForce(idx) * dt_ * dt_ + ac.getLinearVelocity(idx) * dt_ + ac.getPosition(idx));
ac.setLinearVelocity(idx, ac.getInvMass(idx) * ac.getForce(idx) * dt_ + ac.getLinearVelocity(idx));
const Vec3 wdot = math::transformMatrixRART(ac.getRotation(idx).getMatrix(),
ac.getInvInertiaBF(idx)) * ac.getTorque(idx);
// computation done in body frame: d(omega)/ dt = J^-1 ((J*omega) x omega + T), update in world frame
// see Wachs, 2019, doi:10.1007/s00707-019-02389-9, Eq. 27
const auto omegaBF = transformVectorFromWFtoBF(idx, ac, ac.getAngularVelocity(idx));
const auto torqueBF = transformVectorFromWFtoBF(idx, ac, ac.getTorque(idx));
const Vec3 wdotBF = ac.getInvInertiaBF(idx) * ( ( ac.getInertiaBF(idx) * omegaBF ) % omegaBF + torqueBF );
const Vec3 wdot = transformVectorFromBFtoWF(idx, ac, wdotBF);
// Calculating the rotation angle
const Vec3 phi( ac.getAngularVelocity(idx) * dt_ + wdot * dt_ * dt_);
......
......@@ -83,7 +83,8 @@ inline void InitParticlesForHCSITS::operator()(size_t j, Accessor& ac, real_t dt
initializeVelocityCorrections( ac, j, ac.getDvRef(j), ac.getDwRef(j), dt ); // use applied external forces to calculate starting velocity
if(!isSet(particle_flags, FIXED)){ // Update velocities with global acceleration and angular velocity with euler eqn
ac.getLinearVelocityRef(j) = ac.getLinearVelocity(j) + getGlobalAcceleration() * dt;
ac.getAngularVelocityRef(j) = ac.getAngularVelocity(j) + dt * ( ac.getInvInertiaBF(j) * ( ( ac.getInertiaBF(j) * ac.getAngularVelocity(j) ) % ac.getAngularVelocity(j) ) );
const auto omegaBF = transformVectorFromWFtoBF(j, ac, ac.getAngularVelocity(j));
ac.getAngularVelocityRef(j) = ac.getAngularVelocity(j) + dt * transformVectorFromBFtoWF(j, ac, ( ac.getInvInertiaBF(j) * ( ( ac.getInertiaBF(j) * omegaBF ) % omegaBF ) ) );
}
}
}
......@@ -106,7 +107,7 @@ template <typename Accessor>
inline void InitParticlesForHCSITS::initializeVelocityCorrections(Accessor& ac, size_t body, Vec3& dv, Vec3& dw, real_t dt ) const
{
dv = ( ac.getInvMass(body) * dt ) * ac.getForce(body);
dw = dt * ( ac.getInvInertiaBF(body) * ac.getTorque(body) );
dw = dt * ( getInvInertia(body, ac) * ac.getTorque(body) );
ac.getForceRef(body) = Vec3();
ac.getTorqueRef(body) = Vec3();
......
......@@ -28,6 +28,7 @@
#include <mesa_pd/data/DataTypes.h>
#include <mesa_pd/data/IAccessor.h>
#include <mesa_pd/common/ParticleFunctions.h>
namespace walberla {
namespace mesa_pd {
......@@ -59,6 +60,8 @@ namespace kernel {
*
* const walberla::mesa_pd::Mat3& getInvInertiaBF(const size_t p_idx) const;
*
* const walberla::mesa_pd::Mat3& getInertiaBF(const size_t p_idx) const;
*
* const walberla::mesa_pd::Vec3& getTorque(const size_t p_idx) const;
* void setTorque(const size_t p_idx, const walberla::mesa_pd::Vec3& v);
*
......@@ -91,8 +94,12 @@ inline void SemiImplicitEuler::operator()(const size_t idx,
ac.getLinearVelocity(idx));
ac.setPosition ( idx, ac.getLinearVelocity(idx) * dt_ +
ac.getPosition(idx));
const Vec3 wdot = math::transformMatrixRART(ac.getRotation(idx).getMatrix(),
ac.getInvInertiaBF(idx)) * ac.getTorque(idx);
// computation done in body frame: d(omega)/ dt = J^-1 ((J*omega) x omega + T), update in world frame
// see Wachs, 2019, doi:10.1007/s00707-019-02389-9, Eq. 27
const auto omegaBF = transformVectorFromWFtoBF(idx, ac, ac.getAngularVelocity(idx));
const auto torqueBF = transformVectorFromWFtoBF(idx, ac, ac.getTorque(idx));
const Vec3 wdotBF = ac.getInvInertiaBF(idx) * ( ( ac.getInertiaBF(idx) * omegaBF ) % omegaBF + torqueBF );
const Vec3 wdot = transformVectorFromBFtoWF(idx, ac, wdotBF);
ac.setAngularVelocity(idx, wdot * dt_ +
ac.getAngularVelocity(idx));
......
......@@ -28,6 +28,7 @@
#include <mesa_pd/data/DataTypes.h>
#include <mesa_pd/data/IAccessor.h>
#include <mesa_pd/common/ParticleFunctions.h>
namespace walberla {
namespace mesa_pd {
......@@ -67,6 +68,8 @@ namespace kernel {
*
* const walberla::mesa_pd::Mat3& getInvInertiaBF(const size_t p_idx) const;
*
* const walberla::mesa_pd::Mat3& getInertiaBF(const size_t p_idx) const;
*
* const walberla::mesa_pd::Vec3& getTorque(const size_t p_idx) const;
* void setTorque(const size_t p_idx, const walberla::mesa_pd::Vec3& v);
*
......@@ -111,8 +114,14 @@ inline void VelocityVerletPreForceUpdate::operator()(const size_t p_idx, Accesso
ac.setPosition(p_idx, ac.getPosition(p_idx) +
ac.getLinearVelocity(p_idx) * dt_ +
real_t(0.5) * ac.getInvMass(p_idx) * ac.getOldForce(p_idx) * dt_ * dt_);
const Vec3 wdot = math::transformMatrixRART(ac.getRotation(p_idx).getMatrix(),
ac.getInvInertiaBF(p_idx)) * ac.getOldTorque(p_idx);
// computation done in body frame: d(omega)/ dt = J^-1 ((J*omega) x omega + T), update in world frame
// see Wachs, 2019, doi:10.1007/s00707-019-02389-9, Eq. 27
// note: this implementation (pre and post) is experimental as it is in principle unclear in which order
// angular velocities and rotations (affect again the transformations WF - BF) have to be carried out
const auto omegaBF = transformVectorFromWFtoBF(p_idx, ac, ac.getAngularVelocity(p_idx));
const auto torqueBF = transformVectorFromWFtoBF(p_idx, ac, ac.getOldTorque(p_idx));
const Vec3 wdotBF = ac.getInvInertiaBF(p_idx) * ( ( ac.getInertiaBF(p_idx) * omegaBF ) % omegaBF + torqueBF );
const Vec3 wdot = transformVectorFromBFtoWF(p_idx, ac, wdotBF);
// Calculating the rotation angle
const Vec3 phi( ac.getAngularVelocity(p_idx) * dt_ + real_t(0.5) * wdot * dt_ * dt_);
......@@ -133,12 +142,13 @@ inline void VelocityVerletPostForceUpdate::operator()(const size_t p_idx, Access
{
ac.setLinearVelocity(p_idx, ac.getLinearVelocity(p_idx) +
real_t(0.5) * ac.getInvMass(p_idx) * (ac.getOldForce(p_idx) + ac.getForce(p_idx)) * dt_);
const auto torque = ac.getOldTorque(p_idx) + ac.getTorque(p_idx);
const Vec3 wdot = math::transformMatrixRART(ac.getRotation(p_idx).getMatrix(),
ac.getInvInertiaBF(p_idx)) * torque;
const auto omegaBF = transformVectorFromWFtoBF(p_idx, ac, ac.getAngularVelocity(p_idx));
const auto torqueBF = transformVectorFromWFtoBF(p_idx, ac, 0.5_r * (ac.getOldTorque(p_idx) + ac.getTorque(p_idx)));
const Vec3 wdotBF = ac.getInvInertiaBF(p_idx) * ( ( ac.getInertiaBF(p_idx) * omegaBF ) % omegaBF + torqueBF );
const Vec3 wdot = transformVectorFromBFtoWF(p_idx, ac, wdotBF);
ac.setAngularVelocity(p_idx, ac.getAngularVelocity(p_idx) +
real_t(0.5) * wdot * dt_ );
wdot * dt_ );
}
ac.setOldForce(p_idx, ac.getForce(p_idx));
......
......@@ -21,7 +21,7 @@
#include <mesa_pd/collision_detection/AnalyticContactDetection.h>
#include <mesa_pd/data/LinkedCells.h>
#include <mesa_pd/data/ParticleAccessor.h>
#include <mesa_pd/data/ParticleAccessorWithShape.h>
#include <mesa_pd/data/ParticleStorage.h>
#include <mesa_pd/data/ShapeStorage.h>
#include <mesa_pd/domain/BlockForestDomain.h>
......@@ -45,23 +45,6 @@
namespace walberla {
namespace mesa_pd {
class ParticleAccessorWithShape : public data::ParticleAccessor
{
public:
ParticleAccessorWithShape(std::shared_ptr<data::ParticleStorage>& ps, std::shared_ptr<data::ShapeStorage>& ss)
: ParticleAccessor(ps)
, ss_(ss)
{}
const auto& getInvMass(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)]->getInvMass();}
const auto& getInvInertiaBF(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)]->getInvInertiaBF();}
data::BaseShape* getShape(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)].get();}
private:
std::shared_ptr<data::ShapeStorage> ss_;
};
/*
* Tests linked cells
* Fully periodic, simple cubic sphere array is created
......@@ -119,7 +102,7 @@ int main( const int particlesPerAxisPerProcess = 2 )
//init data structures
auto ps = std::make_shared<data::ParticleStorage>(100);
auto ss = std::make_shared<data::ShapeStorage>();
ParticleAccessorWithShape accessor(ps, ss);
data::ParticleAccessorWithShape accessor(ps, ss);
const real_t linkedCellSize = real_c(linkedCellMultipleOfGenerationSpacing) * generationSpacing;
data::LinkedCells lc(localDomain.getExtended(linkedCellSize), linkedCellSize );
......
......@@ -20,7 +20,7 @@
#include <mesa_pd/collision_detection/AnalyticContactDetection.h>
#include <mesa_pd/data/ParticleAccessor.h>
#include <mesa_pd/data/ParticleAccessorWithShape.h>
#include <mesa_pd/data/ParticleStorage.h>
#include <mesa_pd/data/ShapeStorage.h>
......@@ -42,23 +42,6 @@
namespace walberla {
namespace mesa_pd {
class ParticleAccessorWithShape : public data::ParticleAccessor
{
public:
ParticleAccessorWithShape(std::shared_ptr<data::ParticleStorage>& ps, std::shared_ptr<data::ShapeStorage>& ss)
: ParticleAccessor(ps)
, ss_(ss)
{}
const auto& getInvMass(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)]->getInvMass();}
const auto& getInvInertiaBF(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)]->getInvInertiaBF();}
data::BaseShape* getShape(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)].get();}
private:
std::shared_ptr<data::ShapeStorage> ss_;
};
int main( int argc, char ** argv )
{
using namespace walberla::timing;
......@@ -75,7 +58,7 @@ int main( int argc, char ** argv )
//init data structures
auto ps = std::make_shared<data::ParticleStorage>(100);
auto ss = std::make_shared<data::ShapeStorage>();
ParticleAccessorWithShape accessor(ps, ss);
mesa_pd::data::ParticleAccessorWithShape accessor(ps, ss);
auto p = ps->create();
p->getPositionRef() = Vec3(real_t(0), real_t(0), real_t(0));
......
......@@ -20,7 +20,7 @@
#include <mesa_pd/collision_detection/GeneralContactDetection.h>
#include <mesa_pd/data/ParticleAccessor.h>
#include <mesa_pd/data/ParticleAccessorWithShape.h>
#include <mesa_pd/data/ParticleStorage.h>
#include <mesa_pd/data/ShapeStorage.h>
......@@ -40,23 +40,6 @@
namespace walberla {
namespace mesa_pd {
class ParticleAccessorWithShape : public data::ParticleAccessor
{
public:
ParticleAccessorWithShape(std::shared_ptr<data::ParticleStorage>& ps, std::shared_ptr<data::ShapeStorage>& ss)
: ParticleAccessor(ps)
, ss_(ss)
{}
const auto& getInvMass(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)]->getInvMass();}
const auto& getInvInertiaBF(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)]->getInvInertiaBF();}
data::BaseShape* getShape(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)].get();}
private:
std::shared_ptr<data::ShapeStorage> ss_;
};
int main( int argc, char ** argv )
{
using namespace walberla::timing;
......@@ -73,7 +56,7 @@ int main( int argc, char ** argv )
//init data structures
auto ps = std::make_shared<data::ParticleStorage>(100);
auto ss = std::make_shared<data::ShapeStorage>();
ParticleAccessorWithShape accessor(ps, ss);
mesa_pd::data::ParticleAccessorWithShape accessor(ps, ss);
auto p = ps->create();
p->getPositionRef() = Vec3(real_t(0), real_t(0), real_t(0));
......
......@@ -19,7 +19,7 @@
//======================================================================================================================
#include <mesa_pd/collision_detection/AnalyticContactDetection.h>
#include <mesa_pd/data/ParticleAccessor.h>
#include <mesa_pd/data/ParticleAccessorWithShape.h>
#include <mesa_pd/data/ParticleStorage.h>
#include <mesa_pd/data/ShapeStorage.h>
#include <mesa_pd/kernel/DoubleCast.h>
......@@ -34,23 +34,6 @@
namespace walberla {
namespace mesa_pd {
class ParticleAccessorWithShape : public data::ParticleAccessor
{
public:
ParticleAccessorWithShape(std::shared_ptr<data::ParticleStorage>& ps, std::shared_ptr<data::ShapeStorage>& ss)
: ParticleAccessor(ps)
, ss_(ss)
{}
const auto& getInvMass(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)]->getInvMass();}
const auto& getInvInertiaBF(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)]->getInvInertiaBF();}
data::BaseShape* getShape(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)].get();}
private:
std::shared_ptr<data::ShapeStorage> ss_;
};
void checkRotation( const Vec3& from, const Vec3& to )
{
WALBERLA_LOG_DEVEL_VAR(from);
......@@ -75,7 +58,7 @@ void checkSphereSphereCollision( )
//init data structures
auto ps = std::make_shared<data::ParticleStorage>(100);
auto ss = std::make_shared<data::ShapeStorage>();
ParticleAccessorWithShape ac(ps, ss);
data::ParticleAccessorWithShape ac(ps, ss);
//initialize particles
const real_t radius = real_t(0.5);
......@@ -125,7 +108,7 @@ void checkSphereHalfSpaceCollision( )
//init data structures
auto ps = std::make_shared<data::ParticleStorage>(100);
auto ss = std::make_shared<data::ShapeStorage>();
ParticleAccessorWithShape ac(ps, ss);
data::ParticleAccessorWithShape ac(ps, ss);
//initialize particles
const real_t radius = real_t(1.0);
......
......@@ -19,40 +19,25 @@
//======================================================================================================================
#include <mesa_pd/collision_detection/GeneralContactDetection.h>
#include <mesa_pd/data/ParticleAccessor.h>
#include <mesa_pd/data/ParticleAccessorWithShape.h>
#include <mesa_pd/data/ParticleStorage.h>
#include <mesa_pd/data/ShapeStorage.h>
#include <mesa_pd/kernel/DoubleCast.h>
#include <core/Abort.h>
#include <core/Environment.h>
#include <core/logging/Logging.h>
#include <core/waLBerlaBuildInfo.h>
#include <memory>
namespace walberla {
namespace mesa_pd {
class ParticleAccessorWithShape : public data::ParticleAccessor
{
public:
ParticleAccessorWithShape(std::shared_ptr<data::ParticleStorage>& ps, std::shared_ptr<data::ShapeStorage>& ss)
: ParticleAccessor(ps)
, ss_(ss)
{}
data::BaseShape* getShape(const size_t p_idx) const {return ss_->shapes[ps_->getShapeIDRef(p_idx)].get();}
private:
std::shared_ptr<data::ShapeStorage> ss_;
};
void generalContactDetection()
{
//init data structures
auto ps = std::make_shared<data::ParticleStorage>(100);
auto ss = std::make_shared<data::ShapeStorage>();
ParticleAccessorWithShape accessor(ps, ss);
data::ParticleAccessorWithShape accessor(ps, ss);
auto e0 = ps->create();
e0->setPosition(Vec3(real_t(0),real_t(0),real_t(0)));
......
......@@ -20,7 +20,7 @@
#include "mesa_pd/collision_detection/AnalyticContactDetection.h"
#include "mesa_pd/data/ParticleAccessor.h"
#include "mesa_pd/data/ParticleAccessorWithShape.h"
#include "mesa_pd/data/ParticleStorage.h"
#include "mesa_pd/data/ShapeStorage.h"
......@@ -40,24 +40,6 @@ using namespace walberla;
using namespace walberla::mesa_pd;
class ParticleAccessorWithShape : public data::ParticleAccessor
{
public:
ParticleAccessorWithShape(std::shared_ptr<data::ParticleStorage>& ps, std::shared_ptr<data::ShapeStorage>& ss)
: ParticleAccessor(ps)
, ss_(ss)
{}
const auto& getInvMass(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)]->getInvMass();}
const auto& getInvInertiaBF(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)]->getInvInertiaBF();}
data::BaseShape* getShape(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)].get();}
private:
std::shared_ptr<data::ShapeStorage> ss_;
};
/*
* Tests the integrator accuracy for a DEM simulation by comparing the given coefficient of restitution to the simulated one.
* For that, the velocity after a single sphere-wall collision is divided by the initial velocity before the simulation.
......@@ -99,7 +81,7 @@ int main( int argc, char** argv )
//init data structures
auto ps = walberla::make_shared<data::ParticleStorage>(2);
auto ss = walberla::make_shared<data::ShapeStorage>();
using ParticleAccessor_T = ParticleAccessorWithShape;
using ParticleAccessor_T = mesa_pd::data::ParticleAccessorWithShape;
auto accessor = walberla::make_shared<ParticleAccessor_T >(ps, ss);
auto sphereShape = ss->create<data::Sphere>( radius );
......
......@@ -20,7 +20,7 @@
#include "mesa_pd/collision_detection/AnalyticContactDetection.h"
#include "mesa_pd/data/ParticleAccessor.h"
#include "mesa_pd/data/ParticleAccessorWithShape.h"
#include "mesa_pd/data/ParticleStorage.h"
#include "mesa_pd/data/ShapeStorage.h"
......@@ -40,25 +40,6 @@ namespace dem_integrator_accuracy {
using namespace walberla;
using namespace walberla::mesa_pd;
class ParticleAccessorWithShape : public data::ParticleAccessor
{
public:
ParticleAccessorWithShape(std::shared_ptr<data::ParticleStorage>& ps, std::shared_ptr<data::ShapeStorage>& ss)
: ParticleAccessor(ps)
, ss_(ss)
{}
const auto& getInvMass(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)]->getInvMass();}
const auto& getInvInertiaBF(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)]->getInvInertiaBF();}
data::BaseShape* getShape(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)].get();}
private:
std::shared_ptr<data::ShapeStorage> ss_;
};
/*
* Tests the integrator accuracy for a DEM simulation by comparing the given coefficient of restitution to the simulated one.
* For that, the velocity after a single sphere-wall collision is divided by the initial velocity before the simulation.
......@@ -100,7 +81,7 @@ int main( int argc, char** argv )
//init data structures
auto ps = walberla::make_shared<data::ParticleStorage>(2);
auto ss = walberla::make_shared<data::ShapeStorage>();
using ParticleAccessor_T = ParticleAccessorWithShape;
using ParticleAccessor_T = mesa_pd::data::ParticleAccessorWithShape;
auto accessor = walberla::make_shared<ParticleAccessor_T >(ps, ss);
auto sphereShape = ss->create<data::Sphere>( radius );
......
......@@ -20,7 +20,7 @@
#include "mesa_pd/collision_detection/AnalyticContactDetection.h"
#include "mesa_pd/data/ParticleAccessor.h"
#include "mesa_pd/data/ParticleAccessorWithShape.h"
#include "mesa_pd/data/ParticleStorage.h"
#include "mesa_pd/data/ShapeStorage.h"
......@@ -39,25 +39,6 @@ namespace dem_integrator_accuracy {
using namespace walberla;
using namespace walberla::mesa_pd;
class ParticleAccessorWithShape : public data::ParticleAccessor
{
public:
ParticleAccessorWithShape(std::shared_ptr<data::ParticleStorage>& ps, std::shared_ptr<data::ShapeStorage>& ss)
: ParticleAccessor(ps)
, ss_(ss)
{}
const auto& getInvMass(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)]->getInvMass();}
const auto& getInvInertiaBF(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)]->getInvInertiaBF();}
data::BaseShape* getShape(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)].get();}
private:
std::shared_ptr<data::ShapeStorage> ss_;
};
/*
* Tests the integrator accuracy for a DEM simulation by comparing the given coefficient of restitution to the simulated one.
* For that, the velocity after a single sphere-wall collision is divided by the initial velocity before the simulation.
......@@ -99,7 +80,7 @@ int main( int argc, char** argv )
//init data structures
auto ps = walberla::make_shared<data::ParticleStorage>(2);
auto ss = walberla::make_shared<data::ShapeStorage>();
using ParticleAccessor_T = ParticleAccessorWithShape;
using ParticleAccessor_T = mesa_pd::data::ParticleAccessorWithShape;
auto accessor = walberla::make_shared<ParticleAccessor_T >(ps, ss);
auto sphereShape = ss->create<data::Sphere>( radius );
......
......@@ -29,7 +29,7 @@
#include <mesa_pd/domain/InfiniteDomain.h>
#include <mesa_pd/kernel/ParticleSelector.h>
#include <mesa_pd/data/ParticleAccessor.h>
#include <mesa_pd/data/ParticleAccessorWithShape.h>
#include <core/Environment.h>
#include <core/logging/Logging.h>
......@@ -38,24 +38,6 @@
namespace walberla {
namespace mesa_pd {
class ParticleAccessorWithShape : public data::ParticleAccessor
{
public:
ParticleAccessorWithShape(std::shared_ptr<data::ParticleStorage>& ps, std::shared_ptr<data::ShapeStorage>& ss)
: ParticleAccessor(ps)
, ss_(ss)
{}
const auto& getInvMass(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)]->getInvMass();}
const auto& getInvInertiaBF(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)]->getInvInertiaBF();}
data::BaseShape* getShape(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)].get();}
private:
std::shared_ptr<data::ShapeStorage> ss_;
};
int main( int argc, char ** argv )
{
Environment env(argc, argv);
......@@ -67,7 +49,7 @@ int main( int argc, char ** argv )
//init data structures
auto ps = std::make_shared<data::ParticleStorage>(100);
auto ss = std::make_shared<data::ShapeStorage>();
ParticleAccessorWithShape accessor(ps, ss);
data::ParticleAccessorWithShape accessor(ps, ss);
auto smallSphere = ss->create<data::Sphere>( real_t(1.2) );
......
......@@ -39,7 +39,9 @@ public:
void setInvMass(const size_t /*p_idx*/, const walberla::real_t& v) { invMass_ = v;}
const walberla::mesa_pd::Mat3& getInvInertiaBF(const size_t /*p_idx*/) const {return invInertiaBF_;}
void setInvInertiaBF(const size_t /*p_idx*/, const walberla::mesa_pd::Mat3& v) { invInertiaBF_ = v;}
walberla::mesa_pd::Mat3 getInertiaBF(const size_t /*p_idx*/) const {return invInertiaBF_.getInverse();}
private:
walberla::real_t invMass_;
walberla::mesa_pd::Mat3 invInertiaBF_;
};
......
......@@ -20,7 +20,7 @@
#include <mesa_pd/collision_detection/AnalyticContactDetection.h>
#include <mesa_pd/data/LinkedCells.h>
#include <mesa_pd/data/ParticleAccessor.h>
#include <mesa_pd/data/ParticleAccessorWithShape.h>
#include <mesa_pd/data/ParticleStorage.h>
#include <mesa_pd/data/ShapeStorage.h>
#include <mesa_pd/domain/BlockForestDomain.h>
......@@ -36,8 +36,6 @@
#include <blockforest/Initialization.h>
#include <core/Environment.h>
#include <core/grid_generator/SCIterator.h>
#include <core/logging/Logging.h>
#include <core/mpi/Reduce.h>
#include <iostream>
#include <memory>
......@@ -45,23 +43,6 @@
namespace walberla {
namespace mesa_pd {
class ParticleAccessorWithShape : public data::ParticleAccessor
{
public:
ParticleAccessorWithShape(std::shared_ptr<data::ParticleStorage>& ps, std::shared_ptr<data::ShapeStorage>& ss)
: ParticleAccessor(ps)
, ss_(ss)
{}
const auto& getInvMass(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)]->getInvMass();}
const auto& getInvInertiaBF(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)]->getInvInertiaBF();}
data::BaseShape* getShape(const size_t p_idx) const {return ss_->shapes[ps_->getShapeID(p_idx)].get();}
private:
std::shared_ptr<data::ShapeStorage> ss_;
};
int main( int argc, char ** argv )
{
Environment env(argc, argv);
......@@ -78,7 +59,7 @@ int main( int argc, char ** argv )
//init data structures
auto ps = std::make_shared<data::ParticleStorage>(100);
auto ss = std::make_shared<data::ShapeStorage>();
ParticleAccessorWithShape accessor(ps, ss);
data::ParticleAccessorWithShape accessor(ps, ss);
data::LinkedCells lc(math::AABB(-1,-1,-1,4,4,4), real_t(1.3));
//initialize particles
......
......@@ -43,7 +43,7 @@
#include "mesa_pd/mpi/notifications/VelocityUpdateNotification.h"
#include "mesa_pd/mpi/notifications/VelocityCorrectionNotification.h"
#include <mesa_pd/data/ParticleAccessor.h>