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
......@@ -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>
......@@ -36,23 +36,6 @@ 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_;
};
int main( int argc, char ** argv )
{
Environment env(argc, argv);
......@@ -72,7 +55,7 @@ int main( int argc, char ** argv )
auto smallSphere = ss->create<data::Sphere>( real_t(2) );
ss->shapes[smallSphere]->updateMassAndInertia(real_t(2500));
ParticleAccessorWithShape ac(ps, ss);
mesa_pd::data::ParticleAccessorWithShape ac(ps, ss);
data::Particle&& p1 = *ps->create();
p1.getPositionRef() = Vec3(0,0,0);
......
......@@ -18,7 +18,7 @@
//
//======================================================================================================================
#include <mesa_pd/data/ParticleAccessor.h>
#include <mesa_pd/data/ParticleAccessorWithShape.h>
#include <mesa_pd/data/ParticleStorage.h>
#include <mesa_pd/data/shape/Sphere.h>
......@@ -48,6 +48,7 @@ public:
const auto& getInvMass(const size_t /*p_idx*/) const {return sp.getInvMass();}
const auto& getInvInertiaBF(const size_t /*p_idx*/) const {return sp.getInvInertiaBF();}
const auto& getInertiaBF(const size_t /*p_idx*/) const {return sp.getInertiaBF();}
data::BaseShape* getShape(const size_t /*p_idx*/) {return &sp;}
private:
......
......@@ -38,10 +38,13 @@ public:
constexpr auto getInvMass(const size_t /*p_idx*/) const {return 1_r / kernel::cnt::mass_T;}
constexpr auto& getInvInertiaBF(const size_t /*p_idx*/) const {return invI;}
constexpr auto& getInertiaBF(const size_t /*p_idx*/) const {return I;}
private:
// - sphere : I = (2/5)*mass*radius^2
static constexpr auto Ia = 0.4_r * kernel::cnt::mass_T * kernel::cnt::inner_radius * kernel::cnt::inner_radius;
static constexpr auto invI = Mat3(1_r/Ia, 0_r, 0_r, 0_r, 1_r/Ia, 0_r, 0_r, 0_r, 1_r/Ia);
static constexpr auto I = Mat3(Ia, 0_r, 0_r, 0_r, Ia, 0_r, 0_r, 0_r, Ia);
};
} //namespace mesa_pd
......
......@@ -59,6 +59,8 @@ public:
const walberla::mesa_pd::Mat3& getInvInertiaBF(const size_t /*p_idx*/) const {return invInertiaBF_;}
const walberla::mesa_pd::Mat3& getInertiaBF(const size_t /*p_idx*/) const {return inertiaBF_;}
const walberla::mesa_pd::Vec3& getTorque(const size_t /*p_idx*/) const {return torque_;}
void setTorque(const size_t /*p_idx*/, const walberla::mesa_pd::Vec3& v) { torque_ = v;}
......@@ -81,6 +83,7 @@ private:
walberla::mesa_pd::Rot3 rotation_;
walberla::mesa_pd::Vec3 angularVelocity_;
walberla::mesa_pd::Mat3 invInertiaBF_;
walberla::mesa_pd::Mat3 inertiaBF_;
walberla::mesa_pd::Vec3 torque_;
};
......
......@@ -56,6 +56,8 @@ public:
void setAngularVelocity(const size_t /*p_idx*/, const walberla::mesa_pd::Vec3& v) { angularVelocity_ = v;}
const walberla::mesa_pd::Mat3& getInvInertiaBF(const size_t /*p_idx*/) const {return invInertiaBF_;}
const walberla::mesa_pd::Mat3& getInertiaBF(const size_t /*p_idx*/) const {return inertiaBF_;}
const walberla::mesa_pd::Vec3& getTorque(const size_t /*p_idx*/) const {return torque_;}
void setTorque(const size_t /*p_idx*/, const walberla::mesa_pd::Vec3& v) { torque_ = v;}
......@@ -80,6 +82,7 @@ private:
walberla::mesa_pd::Rot3 rotation_;
walberla::mesa_pd::Vec3 angularVelocity_;
walberla::mesa_pd::Mat3 invInertiaBF_;
walberla::mesa_pd::Mat3 inertiaBF_;
walberla::mesa_pd::Vec3 torque_;
walberla::mesa_pd::data::particle_flags::FlagT flags_;
};
......
......@@ -59,6 +59,8 @@ public:
const walberla::mesa_pd::Mat3& getInvInertiaBF(const size_t /*p_idx*/) const {return invInertiaBF_;}
const walberla::mesa_pd::Mat3& getInertiaBF(const size_t /*p_idx*/) const {return inertiaBF_;}
const walberla::mesa_pd::Vec3& getTorque(const size_t /*p_idx*/) const {return torque_;}
void setTorque(const size_t /*p_idx*/, const walberla::mesa_pd::Vec3& v) { torque_ = v;}
......@@ -81,6 +83,7 @@ private:
walberla::mesa_pd::Rot3 rotation_;
walberla::mesa_pd::Vec3 angularVelocity_;
walberla::mesa_pd::Mat3 invInertiaBF_;
walberla::mesa_pd::Mat3 inertiaBF_;
walberla::mesa_pd::Vec3 torque_;
};
......
......@@ -60,6 +60,8 @@ public:
const walberla::mesa_pd::Mat3& getInvInertiaBF(const size_t /*p_idx*/) const {return invInertiaBF_;}
const walberla::mesa_pd::Mat3& getInertiaBF(const size_t /*p_idx*/) const {return inertiaBF_;}
const walberla::mesa_pd::Vec3& getTorque(const size_t /*p_idx*/) const {return torque_;}
void setTorque(const size_t /*p_idx*/, const walberla::mesa_pd::Vec3& v) { torque_ = v;}
......@@ -87,6 +89,7 @@ private:
walberla::mesa_pd::Rot3 rotation_;
walberla::mesa_pd::Vec3 angularVelocity_;
walberla::mesa_pd::Mat3 invInertiaBF_;
walberla::mesa_pd::Mat3 inertiaBF_;
walberla::mesa_pd::Vec3 torque_;
walberla::mesa_pd::Vec3 oldTorque_;
walberla::mesa_pd::data::particle_flags::FlagT flags_;
......
//======================================================================================================================
//
// This file is part of waLBerla. waLBerla is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of
// the License, or (at your option) any later version.
//
// waLBerla is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
// for more details.
//
// You should have received a copy of the GNU General Public License along
// with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file
//! \author Sebastian Eibl <sebastian.eibl@fau.de>
//
//======================================================================================================================
//======================================================================================================================
//
// THIS FILE IS GENERATED - PLEASE CHANGE THE TEMPLATE !!!
//
//======================================================================================================================
#include <mesa_pd/data/IAccessor.h>
#include <mesa_pd/kernel/VelocityVerlet.h>
#include <core/UniqueID.h>
#include <map>
namespace walberla {
namespace mesa_pd {
class Accessor : public data::IAccessor
{
public:
~Accessor() override = default;
const walberla::mesa_pd::Vec3& getPosition(const size_t /*p_idx*/) const {return position_;}
void setPosition(const size_t /*p_idx*/, const walberla::mesa_pd::Vec3& v) { position_ = v;}
const walberla::mesa_pd::Vec3& getLinearVelocity(const size_t /*p_idx*/) const {return linearVelocity_;}
void setLinearVelocity(const size_t /*p_idx*/, const walberla::mesa_pd::Vec3& v) { linearVelocity_ = v;}
const walberla::real_t& getInvMass(const size_t /*p_idx*/) const {return invMass_;}
const walberla::mesa_pd::Vec3& getForce(const size_t /*p_idx*/) const {return force_;}
void setForce(const size_t /*p_idx*/, const walberla::mesa_pd::Vec3& v) { force_ = v;}
const walberla::mesa_pd::Vec3& getOldForce(const size_t /*p_idx*/) const {return oldForce_;}
void setOldForce(const size_t /*p_idx*/, const walberla::mesa_pd::Vec3& v) { oldForce_ = v;}
const walberla::mesa_pd::Rot3& getRotation(const size_t /*p_idx*/) const {return rotation_;}
void setRotation(const size_t /*p_idx*/, const walberla::mesa_pd::Rot3& v) { rotation_ = v;}
const walberla::mesa_pd::Vec3& getAngularVelocity(const size_t /*p_idx*/) const {return angularVelocity_;}
void setAngularVelocity(const size_t /*p_idx*/, const walberla::mesa_pd::Vec3& v) { angularVelocity_ = v;}
const walberla::mesa_pd::Mat3& getInvInertiaBF(const size_t /*p_idx*/) const {return invInertiaBF_;}
const walberla::mesa_pd::Vec3& getTorque(const size_t /*p_idx*/) const {return torque_;}
void setTorque(const size_t /*p_idx*/, const walberla::mesa_pd::Vec3& v) { torque_ = v;}
const walberla::mesa_pd::Vec3& getOldTorque(const size_t /*p_idx*/) const {return oldTorque_;}
void setOldTorque(const size_t /*p_idx*/, const walberla::mesa_pd::Vec3& v) { oldTorque_ = v;}
const walberla::mesa_pd::data::particle_flags::FlagT& getFlags(const size_t /*p_idx*/) const {return flags_;}
id_t getInvalidUid() const {return UniqueID<int>::invalidID();}
size_t getInvalidIdx() const {return std::numeric_limits<size_t>::max();}
/**
* @brief Returns the index of particle specified by uid.
* @param uid unique id of the particle to be looked up
* @return the index of the particle or std::numeric_limits<size_t>::max() if the particle is not found
*/
size_t uidToIdx(const id_t& /*uid*/) const {return 0;}
size_t size() const { return 1; }
private:
walberla::mesa_pd::Vec3 position_;
walberla::mesa_pd::Vec3 linearVelocity_;
walberla::real_t invMass_;
walberla::mesa_pd::Vec3 force_;
walberla::mesa_pd::Vec3 oldForce_;
walberla::mesa_pd::Rot3 rotation_;
walberla::mesa_pd::Vec3 angularVelocity_;
walberla::mesa_pd::Mat3 invInertiaBF_;
walberla::mesa_pd::Vec3 torque_;
walberla::mesa_pd::Vec3 oldTorque_;
walberla::mesa_pd::data::particle_flags::FlagT flags_;
};
template void kernel::VelocityVerletPreForceUpdate::operator()(const size_t p_idx1, Accessor& ac) const;
template void kernel::VelocityVerletPostForceUpdate::operator()(const size_t p_idx1, Accessor& ac) const;
} //namespace mesa_pd
} //namespace walberla
\ No newline at end of file
......@@ -21,10 +21,8 @@
#include <mesa_pd/collision_detection/AnalyticContactDetection.h>
#include <mesa_pd/data/ParticleAccessor.h>
#include <mesa_pd/data/ParticleStorage.h>
#include <mesa_pd/data/ShapeStorage.h>
#include <mesa_pd/domain/BlockForestDomain.h>
#include <mesa_pd/kernel/DoubleCast.h>
#include <mesa_pd/kernel/InsertParticleIntoLinkedCells.h>
#include <mesa_pd/kernel/ParticleSelector.h>
#include <mesa_pd/mpi/ContactFilter.h>
#include <mesa_pd/mpi/ReduceContactHistory.h>
......
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