Commit ce853620 authored by Marcel Koch's avatar Marcel Koch
Browse files

allows passing temporary work array to getNeighborPrimitives

parent 015d4a1e
......@@ -34,20 +34,22 @@ bool Primitive::neighborPrimitiveExists( const PrimitiveID & primitiveID ) const
return std::find( neighborIDs.begin(), neighborIDs.end(), primitiveID ) != neighborIDs.end();
}
void Primitive::getNeighborPrimitives( std::vector< PrimitiveID > & neighborPrimitives ) const
void Primitive::getNeighborPrimitives( std::vector< PrimitiveID > & neighborPrimitives, std::shared_ptr<std::vector<PrimitiveID>> work ) const
{
getNeighborVertices( neighborPrimitives );
if(!work){
work = std::make_shared<std::vector<PrimitiveID>>();
}
getNeighborVertices( *work );
neighborPrimitives.insert( neighborPrimitives.end(), work->begin(), work->end() );
std::vector< PrimitiveID > someNeighbors;
getNeighborEdges( *work );
neighborPrimitives.insert( neighborPrimitives.end(), work->begin(), work->end() );
getNeighborEdges( someNeighbors );
neighborPrimitives.insert( neighborPrimitives.end(), someNeighbors.begin(), someNeighbors.end() );
getNeighborFaces( *work );
neighborPrimitives.insert( neighborPrimitives.end(), work->begin(), work->end() );
getNeighborFaces( someNeighbors );
neighborPrimitives.insert( neighborPrimitives.end(), someNeighbors.begin(), someNeighbors.end() );
getNeighborCells( someNeighbors );
neighborPrimitives.insert( neighborPrimitives.end(), someNeighbors.begin(), someNeighbors.end() );
getNeighborCells( *work );
neighborPrimitives.insert( neighborPrimitives.end(), work->begin(), work->end() );
}
void Primitive::serialize( walberla::mpi::SendBuffer & sendBuffer ) const
......
......@@ -125,7 +125,7 @@ public:
///@{
bool neighborPrimitiveExists( const PrimitiveID & primitiveID ) const;
void getNeighborPrimitives( std::vector< PrimitiveID > & neighborPrimitives ) const;
void getNeighborPrimitives( std::vector< PrimitiveID > & neighborPrimitives, std::shared_ptr<std::vector<PrimitiveID>> work = nullptr ) const;
void getNeighborVertices( std::vector< PrimitiveID > & neighborVertices ) const { neighborVertices.assign( neighborVertices_.begin(), neighborVertices_.end() ); }
void getNeighborEdges ( std::vector< PrimitiveID > & neighborEdges ) const { neighborEdges.assign ( neighborEdges_.begin(), neighborEdges_.end() ); }
void getNeighborFaces ( std::vector< PrimitiveID > & neighborFaces ) const { neighborFaces.assign ( neighborFaces_.begin(), neighborFaces_.end() ); }
......
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