Commit c95e416e authored by Sebastian Eibl's avatar Sebastian Eibl
Browse files

[BUGFIX] illegal pointer access

parent b73eb2df
Pipeline #19659 passed with stages
in 517 minutes and 15 seconds
......@@ -50,7 +50,7 @@ if __name__ == '__main__':
ps.addProperty("nextParticle", "int", defValue="-1", syncMode="NEVER")
ps.addInclude("blockforest/BlockForest.h")
ps.addProperty("currentBlock", "blockforest::Block*", defValue="nullptr", syncMode="NEVER")
ps.addProperty("currentBlock", "blockforest::BlockID", defValue="", syncMode="NEVER")
kernels = []
kernels.append( kernel.DoubleCast(shapes) )
......
......@@ -49,7 +49,7 @@ if __name__ == '__main__':
ps.addProperty("oldTorque", "walberla::mesa_pd::Vec3", defValue="real_t(0)", syncMode="MIGRATION")
ps.addInclude("blockforest/BlockForest.h")
ps.addProperty("currentBlock", "blockforest::Block*", defValue="nullptr", syncMode="NEVER")
ps.addProperty("currentBlock", "blockforest::BlockID", defValue="", syncMode="NEVER")
ps.addProperty("type", "uint_t", defValue="0", syncMode="COPY")
......
......@@ -108,9 +108,9 @@ public:
walberla::mesa_pd::Vec3& getOldTorqueRef(const size_t p_idx) {return ps_->getOldTorqueRef(p_idx);}
void setOldTorque(const size_t p_idx, walberla::mesa_pd::Vec3 const & v) { ps_->setOldTorque(p_idx, v);}
blockforest::Block* const & getCurrentBlock(const size_t p_idx) const {return ps_->getCurrentBlock(p_idx);}
blockforest::Block*& getCurrentBlockRef(const size_t p_idx) {return ps_->getCurrentBlockRef(p_idx);}
void setCurrentBlock(const size_t p_idx, blockforest::Block* const & v) { ps_->setCurrentBlock(p_idx, v);}
blockforest::BlockID const & getCurrentBlock(const size_t p_idx) const {return ps_->getCurrentBlock(p_idx);}
blockforest::BlockID& getCurrentBlockRef(const size_t p_idx) {return ps_->getCurrentBlockRef(p_idx);}
void setCurrentBlock(const size_t p_idx, blockforest::BlockID const & v) { ps_->setCurrentBlock(p_idx, v);}
uint_t const & getType(const size_t p_idx) const {return ps_->getType(p_idx);}
uint_t& getTypeRef(const size_t p_idx) {return ps_->getTypeRef(p_idx);}
......@@ -253,9 +253,9 @@ public:
void setOldTorque(const size_t /*p_idx*/, walberla::mesa_pd::Vec3 const & v) { oldTorque_ = v;}
walberla::mesa_pd::Vec3& getOldTorqueRef(const size_t /*p_idx*/) {return oldTorque_;}
blockforest::Block* const & getCurrentBlock(const size_t /*p_idx*/) const {return currentBlock_;}
void setCurrentBlock(const size_t /*p_idx*/, blockforest::Block* const & v) { currentBlock_ = v;}
blockforest::Block*& getCurrentBlockRef(const size_t /*p_idx*/) {return currentBlock_;}
blockforest::BlockID const & getCurrentBlock(const size_t /*p_idx*/) const {return currentBlock_;}
void setCurrentBlock(const size_t /*p_idx*/, blockforest::BlockID const & v) { currentBlock_ = v;}
blockforest::BlockID& getCurrentBlockRef(const size_t /*p_idx*/) {return currentBlock_;}
uint_t const & getType(const size_t /*p_idx*/) const {return type_;}
void setType(const size_t /*p_idx*/, uint_t const & v) { type_ = v;}
......@@ -319,7 +319,7 @@ private:
walberla::mesa_pd::Vec3 force_;
walberla::mesa_pd::Vec3 oldForce_;
walberla::mesa_pd::Vec3 oldTorque_;
blockforest::Block* currentBlock_;
blockforest::BlockID currentBlock_;
uint_t type_;
int nextParticle_;
std::map<walberla::id_t, walberla::mesa_pd::data::ContactHistory> oldContactHistory_;
......
......@@ -86,7 +86,7 @@ public:
using force_type = walberla::mesa_pd::Vec3;
using oldForce_type = walberla::mesa_pd::Vec3;
using oldTorque_type = walberla::mesa_pd::Vec3;
using currentBlock_type = blockforest::Block*;
using currentBlock_type = blockforest::BlockID;
using type_type = uint_t;
using nextParticle_type = int;
using oldContactHistory_type = std::map<walberla::id_t, walberla::mesa_pd::data::ContactHistory>;
......@@ -273,7 +273,7 @@ public:
using force_type = walberla::mesa_pd::Vec3;
using oldForce_type = walberla::mesa_pd::Vec3;
using oldTorque_type = walberla::mesa_pd::Vec3;
using currentBlock_type = blockforest::Block*;
using currentBlock_type = blockforest::BlockID;
using type_type = uint_t;
using nextParticle_type = int;
using oldContactHistory_type = std::map<walberla::id_t, walberla::mesa_pd::data::ContactHistory>;
......@@ -722,7 +722,7 @@ inline ParticleStorage::iterator ParticleStorage::create(const id_t& uid)
force_.emplace_back(real_t(0));
oldForce_.emplace_back(real_t(0));
oldTorque_.emplace_back(real_t(0));
currentBlock_.emplace_back(nullptr);
currentBlock_.emplace_back();
type_.emplace_back(0);
nextParticle_.emplace_back(-1);
oldContactHistory_.emplace_back();
......@@ -1214,10 +1214,10 @@ public:
class SelectParticleCurrentBlock
{
public:
using return_type = blockforest::Block*;
blockforest::Block*& operator()(data::Particle& p) const {return p.getCurrentBlockRef();}
blockforest::Block*& operator()(data::Particle&& p) const {return p.getCurrentBlockRef();}
blockforest::Block* const & operator()(const data::Particle& p) const {return p.getCurrentBlock();}
using return_type = blockforest::BlockID;
blockforest::BlockID& operator()(data::Particle& p) const {return p.getCurrentBlockRef();}
blockforest::BlockID& operator()(data::Particle&& p) const {return p.getCurrentBlockRef();}
blockforest::BlockID const & operator()(const data::Particle& p) const {return p.getCurrentBlock();}
};
///Predicate that selects a certain property from a Particle
class SelectParticleType
......
......@@ -54,7 +54,7 @@ template <typename Accessor>
inline void AssocToBlock::operator()(const size_t idx,
Accessor& ac) const
{
blockforest::Block*& currentBlock = ac.getCurrentBlockRef(idx);
blockforest::Block* currentBlock = bf_->getBlock(ac.getCurrentBlock(idx));
if (currentBlock != nullptr)
{
......@@ -71,6 +71,7 @@ inline void AssocToBlock::operator()(const size_t idx,
{
if (blk.second->getAABB().contains(ac.getPosition(idx)))
{
ac.setCurrentBlock(idx, blk.second->getId());
currentBlock = blk.second.get();
return;
}
......@@ -85,6 +86,8 @@ inline void AssocToBlock::operator()(const size_t idx,
{
WALBERLA_LOG_DEVEL(blk.second->getAABB());
}
using namespace walberla::mesa_pd::data::particle_flags;
WALBERLA_LOG_DEVEL_VAR(isSet(ac.getFlags(idx), GHOST));
}
WALBERLA_CHECK_NOT_NULLPTR(currentBlock, ac.getPosition(idx));
}
......
......@@ -18,12 +18,6 @@
//
//======================================================================================================================
//======================================================================================================================
//
// THIS FILE IS GENERATED - PLEASE CHANGE THE TEMPLATE !!!
//
//======================================================================================================================
#include "SyncNextNeighborsBlockForest.h"
#include <mesa_pd/domain/BlockForestDomain.h>
......@@ -122,8 +116,8 @@ void SyncNextNeighborsBlockForest::generateSynchronizationMessages(data::Particl
continue;
}
auto& currentBlock = pIt->getCurrentBlockRef();
WALBERLA_CHECK_NOT_NULLPTR(currentBlock);
auto currentBlock = bf->getBlock(pIt->getCurrentBlock());
WALBERLA_CHECK_NOT_NULLPTR(currentBlock, *pIt);
if (isInsideAABB(pIt->getPosition(), pIt->getInteractionRadius() + dx, currentBlock->getAABB()))
{
//no sync needed
......
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