Skip to content
Snippets Groups Projects
Commit 6985b1e0 authored by Christian Godenschwager's avatar Christian Godenschwager
Browse files

Refactor for C++14

parent 54d7ba3d
Branches
Tags
No related merge requests found
......@@ -66,9 +66,9 @@ void BoundarySetup::allocateOrResetVoxelizationField()
{
if( voxelizationFieldId_ )
{
for( auto blockIt = structuredBlockStorage_->begin(); blockIt != structuredBlockStorage_->end(); ++blockIt )
for( auto & block : *structuredBlockStorage_ )
{
VoxelizationField * voxelizationField = blockIt->getData< VoxelizationField >( *voxelizationFieldId_ );
VoxelizationField * voxelizationField = block.getData< VoxelizationField >( *voxelizationFieldId_ );
voxelizationField->setWithGhostLayer( uint8_t(0) );
}
}
......@@ -93,15 +93,15 @@ void BoundarySetup::voxelize()
{
allocateOrResetVoxelizationField();
for( auto blockIt = structuredBlockStorage_->begin(); blockIt != structuredBlockStorage_->end(); ++blockIt )
for( auto & block : *structuredBlockStorage_ )
{
VoxelizationField * voxelizationField = blockIt->getData< VoxelizationField >( *voxelizationFieldId_ );
VoxelizationField * voxelizationField = block.getData< VoxelizationField >( *voxelizationFieldId_ );
WALBERLA_ASSERT_NOT_NULLPTR( voxelizationField );
WALBERLA_ASSERT_EQUAL( numGhostLayers_, voxelizationField->nrOfGhostLayers() );
CellInterval blockCi = voxelizationField->xyzSizeWithGhostLayer();
structuredBlockStorage_->transformBlockLocalToGlobalCellInterval( blockCi, *blockIt );
structuredBlockStorage_->transformBlockLocalToGlobalCellInterval( blockCi, block );
std::queue< CellInterval > ciQueue;
ciQueue.push( blockCi );
......@@ -112,7 +112,7 @@ void BoundarySetup::voxelize()
WALBERLA_ASSERT( !curCi.empty(), "Cell Interval: " << curCi );
AABB curAABB = structuredBlockStorage_->getAABBFromCellBB( curCi, structuredBlockStorage_->getLevel( *blockIt ) );
AABB curAABB = structuredBlockStorage_->getAABBFromCellBB( curCi, structuredBlockStorage_->getLevel( block ) );
WALBERLA_ASSERT( !curAABB.empty(), "AABB: " << curAABB );
......@@ -125,7 +125,7 @@ void BoundarySetup::voxelize()
if( ( sqSignedDistance < real_t(0) ) )
{
Cell localCell;
structuredBlockStorage_->transformGlobalToBlockLocalCell( localCell, *blockIt, curCi.min() );
structuredBlockStorage_->transformGlobalToBlockLocalCell( localCell, block, curCi.min() );
voxelizationField->get( localCell ) = uint8_t(1);
}
......@@ -140,7 +140,7 @@ void BoundarySetup::voxelize()
{
// clearly the cell interval is fully covered by the mesh
CellInterval localCi;
structuredBlockStorage_->transformGlobalToBlockLocalCellInterval( localCi, *blockIt, curCi );
structuredBlockStorage_->transformGlobalToBlockLocalCellInterval( localCi, block, curCi );
std::fill( voxelizationField->beginSliceXYZ( localCi ), voxelizationField->end(), uint8_t(1) );
ciQueue.pop();
......
......@@ -82,9 +82,9 @@ private:
shared_ptr< StructuredBlockStorage > structuredBlockStorage_;
shared_ptr< BlockDataID > voxelizationFieldId_;
DistanceFunction distanceFunction_; // function providing the squared signed distance to an object
DistanceFunction distanceFunction_; /// function providing the squared signed distance to an object
uint_t numGhostLayers_;
size_t cellVectorChunkSize_;
size_t cellVectorChunkSize_; /// Number of boundary cells which are setup simultaneously
};
......@@ -92,12 +92,12 @@ private:
template< typename BoundaryHandlingType >
void BoundarySetup::setDomainCells( const BlockDataID boundaryHandlingId, const Location domainLocation )
{
for( auto blockIt = structuredBlockStorage_->begin(); blockIt != structuredBlockStorage_->end(); ++blockIt )
for( auto & block : *structuredBlockStorage_ )
{
BoundaryHandlingType * boundaryHandling = blockIt->getData< BoundaryHandlingType >( boundaryHandlingId );
BoundaryHandlingType * boundaryHandling = block.getData< BoundaryHandlingType >( boundaryHandlingId );
WALBERLA_CHECK_NOT_NULLPTR( boundaryHandling, "boundaryHandlingId invalid!" );
const VoxelizationField * voxelizationField = blockIt->getData< VoxelizationField >( *voxelizationFieldId_ );
const VoxelizationField * voxelizationField = block.getData< VoxelizationField >( *voxelizationFieldId_ );
WALBERLA_ASSERT_NOT_NULLPTR( voxelizationField );
WALBERLA_CHECK_LESS_EQUAL( numGhostLayers_, boundaryHandling->getFlagField()->nrOfGhostLayers(), "You want to use mesh boundary setup with " \
<< numGhostLayers_ << " but your flag field has only " << boundaryHandling->getFlagField()->nrOfGhostLayers() << " ghost layers!" );
......@@ -111,7 +111,7 @@ void BoundarySetup::setDomainCells( const BlockDataID boundaryHandlingId, const
for( cell_idx_t x = -cell_idx_c( numGhostLayers_ ); x < cell_idx_c( voxelizationField->xSize() + numGhostLayers_ ); ++x )
{
if( voxelizationField->get( x, y, z ) == domainValue )
domainCells.push_back( Cell(x,y,z) );
domainCells.emplace_back( x, y, z );
if( domainCells.size() > cellVectorChunkSize_ )
{
......@@ -128,13 +128,13 @@ void BoundarySetup::setDomainCells( const BlockDataID boundaryHandlingId, const
template<typename FlagField_T>
void BoundarySetup::setFlag( const BlockDataID flagFieldID, field::FlagUID flagUID, Location boundaryLocation )
{
for( auto blockIt = structuredBlockStorage_->begin(); blockIt != structuredBlockStorage_->end(); ++blockIt )
for( auto & block : *structuredBlockStorage_ )
{
FlagField_T * flagField = blockIt->getData< FlagField_T >( flagFieldID );
FlagField_T * flagField = block.getData< FlagField_T >( flagFieldID );
WALBERLA_CHECK_NOT_NULLPTR( flagField, "flagFieldID invalid!" );
auto flag = flagField->getFlag(flagUID);
const VoxelizationField * voxelizationField = blockIt->getData< VoxelizationField >( *voxelizationFieldId_ );
const VoxelizationField * voxelizationField = block.getData< VoxelizationField >( *voxelizationFieldId_ );
WALBERLA_ASSERT_NOT_NULLPTR( voxelizationField );
WALBERLA_CHECK_LESS_EQUAL( numGhostLayers_, flagField->nrOfGhostLayers(), "You want to use mesh boundary setup with " \
<< numGhostLayers_ << " but your flag field has only " << flagField->nrOfGhostLayers() << " ghost layers!" );
......@@ -155,12 +155,12 @@ void BoundarySetup::setFlag( const BlockDataID flagFieldID, field::FlagUID flagU
template< typename BoundaryHandlingType, typename BoundaryFunction, typename Stencil >
void BoundarySetup::setBoundaries( const BlockDataID boundaryHandlingID, const BoundaryFunction & boundaryFunction, Location boundaryLocation )
{
for( auto blockIt = structuredBlockStorage_->begin(); blockIt != structuredBlockStorage_->end(); ++blockIt )
for( auto & block : *structuredBlockStorage_ )
{
BoundaryHandlingType * boundaryHandling = blockIt->getData< BoundaryHandlingType >( boundaryHandlingID );
BoundaryHandlingType * boundaryHandling = block.getData< BoundaryHandlingType >( boundaryHandlingID );
WALBERLA_CHECK_NOT_NULLPTR( boundaryHandling, "boundaryHandlingId invalid!" );
const VoxelizationField * voxelizationField = blockIt->getData< VoxelizationField >( *voxelizationFieldId_ );
const VoxelizationField * voxelizationField = block.getData< VoxelizationField >( *voxelizationFieldId_ );
WALBERLA_ASSERT_NOT_NULLPTR( voxelizationField );
WALBERLA_CHECK_LESS_EQUAL( numGhostLayers_, boundaryHandling->getFlagField()->nrOfGhostLayers(), "You want to use mesh boundary setup with " \
<< numGhostLayers_ << " but your flag field has only " << boundaryHandling->getFlagField()->nrOfGhostLayers() << " ghost layers!" );
......@@ -182,7 +182,7 @@ void BoundarySetup::setBoundaries( const BlockDataID boundaryHandlingID, const B
const Cell neighborCell = cell + *dirIt;
if( blockCi.contains( neighborCell ) && voxelizationField->get( neighborCell ) == domainValue )
{
const Vector3< real_t > cellCenter = structuredBlockStorage_->getBlockLocalCellCenter( *blockIt, cell );
const Vector3< real_t > cellCenter = structuredBlockStorage_->getBlockLocalCellCenter( block, cell );
const BoundaryInfo & bi = boundaryFunction( cellCenter );
const auto boundaryMask = boundaryHandling->getBoundaryMask( bi.getUid() );
......
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