Commit 4b77bcf2 authored by Christoph Rettinger's avatar Christoph Rettinger
Browse files

Changed shared_ptr to weak_ptr to break dependencies

parent 10d7138a
......@@ -37,7 +37,7 @@ namespace field {
* \ingroup field
*
* Distributor_T: A distributor that has a constructor
* ( const shared_ptr<StructuredBlockStorage> & blockStorage, const IBlock & block, const BaseField_T & baseField,
* ( const weak_ptr<StructuredBlockStorage> & blockStorage, const IBlock & block, const BaseField_T & baseField,
* const FlagField_T & flagField, const flag_t & evaluationMask )
* and distribution functions:
* template< typename ForwardIterator_T > inline void distribute( const Vector3<real_t> & position, ForwardIterator_T distributeValueBegin )
......@@ -58,7 +58,7 @@ class DistributorHandling : public blockforest::AlwaysInitializeBlockDataHandlin
{
public:
DistributorHandling( const shared_ptr<StructuredBlockStorage> & blockStorage,
DistributorHandling( const weak_ptr<StructuredBlockStorage> & blockStorage,
const BlockDataID & distributionDestinationFieldID,
const ConstBlockDataID & flagFieldID,
const Set< FlagUID > & cellsToEvaluate ) :
......@@ -82,7 +82,7 @@ public:
private:
shared_ptr<StructuredBlockStorage> blockStorage_;
weak_ptr<StructuredBlockStorage> blockStorage_;
BlockDataID distributionDestinationFieldID_;
ConstBlockDataID flagFieldID_;
Set< FlagUID > cellsToEvaluate_;
......
......@@ -54,7 +54,7 @@ public:
typedef typename FlagField_T::flag_t flag_t;
typedef KernelDistributor<Field_T,FlagField_T> OwnType;
KernelDistributor( const shared_ptr<StructuredBlockStorage> & blockStorage, const IBlock & block,
KernelDistributor( const weak_ptr<StructuredBlockStorage> & blockStorage, const IBlock & block,
BaseField_T & baseField, const FlagField_T & flagField,
const flag_t & evaluationMask )
: blockStorage_( blockStorage ), block_( block ), baseField_( baseField ), flagField_( flagField ), evaluationMask_( evaluationMask )
......@@ -76,11 +76,14 @@ public:
WALBERLA_ASSERT(block_.getAABB().contains(x,y,z),
"Distribution position <" << x << ", " << y << ", " << z << "> is not contained inside the block of this distributor with AABB " << block_.getAABB() << " !");
Cell centerCell = blockStorage_->getBlockLocalCell( block_, x, y, z );
WALBERLA_CHECK( !blockStorage_.expired() );
auto blockStorage = blockStorage_.lock();
const real_t dx = blockStorage_->dx( blockStorage_->getLevel( block_ ) );
const real_t dy = blockStorage_->dy( blockStorage_->getLevel( block_ ) );
const real_t dz = blockStorage_->dz( blockStorage_->getLevel( block_ ) );
Cell centerCell = blockStorage->getBlockLocalCell( block_, x, y, z );
const real_t dx = blockStorage->dx( blockStorage->getLevel( block_ ) );
const real_t dy = blockStorage->dy( blockStorage->getLevel( block_ ) );
const real_t dz = blockStorage->dz( blockStorage->getLevel( block_ ) );
const uint_t neighborhoodSize = cell_idx_t(1);
......@@ -97,7 +100,7 @@ public:
// get distribution weights and count available cells in surrounding cells
for( auto cellIt = cellNeighborhood.begin(); cellIt != cellNeighborhood.end(); ++cellIt )
{
Vector3<real_t> curCellCenter = blockStorage_->getBlockLocalCellCenter( block_, *cellIt );
Vector3<real_t> curCellCenter = blockStorage->getBlockLocalCellCenter( block_, *cellIt );
if( flagField_.isPartOfMaskSet( *cellIt, evaluationMask_ ) )
{
weights[counter] = kernelweights::kernelWeightFunction( x, y, z, curCellCenter[0], curCellCenter[1], curCellCenter[2], dx, dy, dz );
......@@ -142,7 +145,7 @@ private:
}
}
shared_ptr<StructuredBlockStorage> blockStorage_;
weak_ptr<StructuredBlockStorage> blockStorage_;
const IBlock & block_;
BaseField_T & baseField_;
const FlagField_T & flagField_;
......
......@@ -53,7 +53,7 @@ public:
typedef typename FlagField_T::flag_t flag_t;
typedef NearestNeighborDistributor<Field_T,FlagField_T> OwnType;
NearestNeighborDistributor( const shared_ptr<StructuredBlockStorage> & blockStorage, const IBlock & block,
NearestNeighborDistributor( const weak_ptr<StructuredBlockStorage> & blockStorage, const IBlock & block,
BaseField_T & baseField, const FlagField_T & flagField,
const flag_t & evaluationMask )
: blockStorage_( blockStorage ), block_( block ), baseField_( baseField ), flagField_( flagField ), evaluationMask_( evaluationMask )
......@@ -73,7 +73,10 @@ public:
WALBERLA_ASSERT(block_.getAABB().contains(x,y,z),
"Distribution position <" << x << ", " << y << ", " << z << "> is not contained inside the block of this distributor with AABB " << block_.getAABB() << " !");
Cell nearestCell = blockStorage_->getBlockLocalCell( block_, x, y, z );
WALBERLA_CHECK( !blockStorage_.expired() );
auto blockStorage = blockStorage_.lock();
Cell nearestCell = blockStorage->getBlockLocalCell( block_, x, y, z );
if( flagField_.isPartOfMaskSet( nearestCell, evaluationMask_ ) )
{
......@@ -90,7 +93,7 @@ public:
CellInterval fieldXYZSize = baseField_.xyzSize();
Vector3<real_t> nearestCellCenter = blockStorage_->getBlockLocalCellCenter( block_, nearestCell );
Vector3<real_t> nearestCellCenter = blockStorage->getBlockLocalCellCenter( block_, nearestCell );
const cell_idx_t xNeighbor = cell_idx_c( floor( x - nearestCellCenter[0] ) );
const cell_idx_t yNeighbor = cell_idx_c( floor( y - nearestCellCenter[1] ) );
const cell_idx_t zNeighbor = cell_idx_c( floor( z - nearestCellCenter[2] ) );
......@@ -126,7 +129,7 @@ public:
private:
shared_ptr<StructuredBlockStorage> blockStorage_;
weak_ptr<StructuredBlockStorage> blockStorage_;
const IBlock & block_;
BaseField_T & baseField_;
const FlagField_T & flagField_;
......
......@@ -37,7 +37,7 @@ namespace field {
* \ingroup field
*
* Interpolator_T: A field interpolator that has a constructor
* ( const shared_ptr<StructuredBlockStorage> & blockStorage, const IBlock & block, const BaseField_T & baseField,
* ( const weak_ptr<StructuredBlockStorage> & blockStorage, const IBlock & block, const BaseField_T & baseField,
* const FlagField_T & flagField, const flag_t & evaluationMask )
* and getter functions:
* template< typename ForwardIterator_T > inline void get( const Vector3<real_t> & position, ForwardIterator_T interpolationResultBegin )
......@@ -57,7 +57,7 @@ class InterpolatorHandling : public blockforest::AlwaysInitializeBlockDataHandli
{
public:
InterpolatorHandling( const shared_ptr<StructuredBlockStorage> & blockStorage,
InterpolatorHandling( const weak_ptr<StructuredBlockStorage> & blockStorage,
const ConstBlockDataID & interpolatedFieldID,
const ConstBlockDataID & flagFieldID,
const Set< FlagUID > & cellsToEvaluate ) :
......@@ -81,7 +81,7 @@ public:
private:
shared_ptr<StructuredBlockStorage> blockStorage_;
weak_ptr<StructuredBlockStorage> blockStorage_;
ConstBlockDataID interpolatedFieldID_;
ConstBlockDataID flagFieldID_;
Set< FlagUID > cellsToEvaluate_;
......
......@@ -96,7 +96,7 @@ public:
typedef typename FlagField_T::flag_t flag_t;
typedef KernelFieldInterpolator<Field_T,FlagField_T> OwnType;
KernelFieldInterpolator( const shared_ptr<StructuredBlockStorage> & blockStorage, const IBlock & block,
KernelFieldInterpolator( const weak_ptr<StructuredBlockStorage> & blockStorage, const IBlock & block,
const BaseField_T & baseField, const FlagField_T & flagField,
const flag_t & evaluationMask )
: blockStorage_( blockStorage ), block_( block ), baseField_( baseField ), flagField_( flagField ), evaluationMask_( evaluationMask )
......@@ -116,14 +116,18 @@ public:
template< typename ForwardIterator_T >
inline void get( const real_t & x, const real_t & y, const real_t & z, ForwardIterator_T interpolationResultBegin )
{
WALBERLA_ASSERT(block_.getAABB().contains(x,y,z),
"Interpolation position <" << x << ", " << y << ", " << z << "> is not contained inside the block of this interpolator with AABB " << block_.getAABB() << " !");
Cell centerCell = blockStorage_->getBlockLocalCell( block_, x, y, z );
WALBERLA_CHECK( !blockStorage_.expired() );
auto blockStorage = blockStorage_.lock();
Cell centerCell = blockStorage->getBlockLocalCell( block_, x, y, z );
const real_t dx = blockStorage_->dx( blockStorage_->getLevel( block_ ) );
const real_t dy = blockStorage_->dy( blockStorage_->getLevel( block_ ) );
const real_t dz = blockStorage_->dz( blockStorage_->getLevel( block_ ) );
const real_t dx = blockStorage->dx( blockStorage->getLevel( block_ ) );
const real_t dy = blockStorage->dy( blockStorage->getLevel( block_ ) );
const real_t dz = blockStorage->dz( blockStorage->getLevel( block_ ) );
const uint_t neighborhoodSize = uint_t(1);
......@@ -142,7 +146,7 @@ public:
cell_idx_t cellIdx0z = cellNeighborhood.zMin();
uint_t nx = kernelSizeOneDirection;
uint_t nxy = kernelSizeOneDirection * kernelSizeOneDirection;
Vector3<real_t> cellCenter0 = blockStorage_->getBlockLocalCellCenter( block_, Cell(cellIdx0x, cellIdx0y, cellIdx0z) ); // = cell in neighborhood with smallest x-, y-, and z-indices
Vector3<real_t> cellCenter0 = blockStorage->getBlockLocalCellCenter( block_, Cell(cellIdx0x, cellIdx0y, cellIdx0z) ); // = cell in neighborhood with smallest x-, y-, and z-indices
// calculate kernel weights of all cells in neighborhood
for( uint_t k = uint_t(0); k < kernelSizeOneDirection; ++k)
......@@ -256,7 +260,7 @@ private:
}
}
shared_ptr<StructuredBlockStorage> blockStorage_;
weak_ptr<StructuredBlockStorage> blockStorage_;
const IBlock & block_;
const BaseField_T & baseField_;
const FlagField_T & flagField_;
......
......@@ -50,7 +50,7 @@ public:
typedef typename FlagField_T::flag_t flag_t;
typedef NearestNeighborFieldInterpolator<Field_T,FlagField_T> OwnType;
NearestNeighborFieldInterpolator( const shared_ptr<StructuredBlockStorage> & blockStorage, const IBlock & block,
NearestNeighborFieldInterpolator( const weak_ptr<StructuredBlockStorage> & blockStorage, const IBlock & block,
const BaseField_T & baseField, const FlagField_T & flagField,
const flag_t & evaluationMask )
: blockStorage_( blockStorage ), block_( block ), baseField_( baseField ), flagField_( flagField ), evaluationMask_( evaluationMask )
......@@ -72,7 +72,10 @@ public:
WALBERLA_ASSERT(block_.getAABB().contains(x,y,z),
"Interpolation position <" << x << ", " << y << ", " << z << "> is not contained inside the block of this interpolator with AABB " << block_.getAABB() << " !");
Cell nearestCell = blockStorage_->getBlockLocalCell( block_, x, y, z );
WALBERLA_CHECK( !blockStorage_.expired() );
auto blockStorage = blockStorage_.lock();
Cell nearestCell = blockStorage->getBlockLocalCell( block_, x, y, z );
if( flagField_.isPartOfMaskSet( nearestCell, evaluationMask_ ) )
{
......@@ -89,7 +92,7 @@ public:
CellInterval fieldXYZSize = baseField_.xyzSize();
Vector3<real_t> nearestCellCenter = blockStorage_->getBlockLocalCellCenter( block_, nearestCell );
Vector3<real_t> nearestCellCenter = blockStorage->getBlockLocalCellCenter( block_, nearestCell );
const cell_idx_t xNeighbor = cell_idx_c( floor( x - nearestCellCenter[0] ) );
const cell_idx_t yNeighbor = cell_idx_c( floor( y - nearestCellCenter[1] ) );
const cell_idx_t zNeighbor = cell_idx_c( floor( z - nearestCellCenter[2] ) );
......@@ -128,7 +131,7 @@ public:
private:
shared_ptr<StructuredBlockStorage> blockStorage_;
weak_ptr<StructuredBlockStorage> blockStorage_;
const IBlock & block_;
const BaseField_T & baseField_;
const FlagField_T & flagField_;
......
......@@ -52,7 +52,7 @@ public:
typedef typename FlagField_T::flag_t flag_t;
typedef TrilinearFieldInterpolator<Field_T,FlagField_T> OwnType;
TrilinearFieldInterpolator( const shared_ptr<StructuredBlockStorage> & blockStorage, const IBlock & block,
TrilinearFieldInterpolator( const weak_ptr<StructuredBlockStorage> & blockStorage, const IBlock & block,
const BaseField_T & baseField, const FlagField_T & flagField,
const flag_t & evaluationMask )
: blockStorage_( blockStorage ), block_( block ), baseField_( baseField ), flagField_( flagField ), evaluationMask_( evaluationMask ),
......@@ -76,12 +76,15 @@ public:
WALBERLA_ASSERT(block_.getAABB().contains(x,y,z),
"Interpolation position <" << x << ", " << y << ", " << z << "> is not contained inside the block of this interpolator with AABB " << block_.getAABB() << " !");
const real_t dx = blockStorage_->dx( blockStorage_->getLevel( block_ ) );
const real_t dy = blockStorage_->dy( blockStorage_->getLevel( block_ ) );
const real_t dz = blockStorage_->dz( blockStorage_->getLevel( block_ ) );
WALBERLA_CHECK( !blockStorage_.expired() );
auto blockStorage = blockStorage_.lock();
Cell containingCell = blockStorage_->getBlockLocalCell( block_, x, y, z );
Vector3<real_t> containingCellCenter = blockStorage_->getBlockLocalCellCenter( block_, containingCell );
const real_t dx = blockStorage->dx( blockStorage->getLevel( block_ ) );
const real_t dy = blockStorage->dy( blockStorage->getLevel( block_ ) );
const real_t dz = blockStorage->dz( blockStorage->getLevel( block_ ) );
Cell containingCell = blockStorage->getBlockLocalCell( block_, x, y, z );
Vector3<real_t> containingCellCenter = blockStorage->getBlockLocalCellCenter( block_, containingCell );
const cell_idx_t xNeighbor1 = cell_idx_c( floor( x - containingCellCenter[0] ) );
const cell_idx_t xNeighbor2 = xNeighbor1 + cell_idx_t(1);
......@@ -114,7 +117,7 @@ public:
// trilinear interpolation can be applied
const real_t inv_totalVolume = real_t(1) / ( dx * dy * dz );
Vector3<real_t> cccCellCenter = blockStorage_->getBlockLocalCellCenter( block_, ccc );
Vector3<real_t> cccCellCenter = blockStorage->getBlockLocalCellCenter( block_, ccc );
// weighting = volume of opposing volume element / total volume
real_t weighting(0.0);
......@@ -173,7 +176,7 @@ private:
}
}
shared_ptr<StructuredBlockStorage> blockStorage_;
weak_ptr<StructuredBlockStorage> blockStorage_;
const IBlock & block_;
const BaseField_T & baseField_;
const FlagField_T & flagField_;
......
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