Commit 0a6b923b authored by Andreas Wagner's avatar Andreas Wagner
Browse files

moves DGFunction and FaceDoFFunction implementations into cpp file

parent 515e7d5c
/*
* Copyright (c) 2017-2019 Boerge Struempfel, Daniel Drzisga, Dominik Thoennes, Nils Kohl.
*
* This file is part of HyTeG
* (see https://i10git.cs.fau.de/hyteg/hyteg).
*
* This program 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.
*
* This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "hyteg/dgfunctionspace/DGFunction.hpp"
#include "hyteg/dgfunctionspace/DGFunctionMacroEdge.hpp"
#include "hyteg/dgfunctionspace/DGFunctionMacroFace.hpp"
#include "hyteg/dgfunctionspace/DGFunctionMacroVertex.hpp"
namespace hyteg {
template < typename ValueType >
void DGFunction< ValueType >::projectP1( P1Function< ValueType >& src, uint_t level, DoFType flag, UpdateType updateType )
{
this->startTiming( "projectP1" );
src.template startCommunication< Edge, Vertex >( level );
src.template startCommunication< Face, Edge >( level );
src.template endCommunication< Edge, Vertex >( level );
for ( auto& it : this->getStorage()->getVertices() )
{
Vertex& vertex = *it.second;
const DoFType vertexBC = this->getBoundaryCondition().getBoundaryType( vertex.getMeshBoundaryFlag() );
if ( testFlag( vertexBC, flag ) )
{
dgfunction::macrovertex::projectP1< ValueType >(
level, vertex, this->getStorage(), src.getVertexDataID(), this->getVertexDataID(), updateType );
}
}
this->template startCommunication< Vertex, Edge >( level );
src.template endCommunication< Face, Edge >( level );
for ( auto& it : this->getStorage()->getEdges() )
{
Edge& edge = *it.second;
const DoFType edgeBC = this->getBoundaryCondition().getBoundaryType( edge.getMeshBoundaryFlag() );
if ( testFlag( edgeBC, flag ) )
{
dgfunction::macroedge::projectP1< ValueType >(
level, edge, this->getStorage(), src.getEdgeDataID(), this->getEdgeDataID(), updateType );
}
}
this->template endCommunication< Vertex, Edge >( level );
this->template startCommunication< Edge, Face >( level );
for ( auto& it : this->getStorage()->getFaces() )
{
Face& face = *it.second;
const DoFType faceBC = this->getBoundaryCondition().getBoundaryType( face.getMeshBoundaryFlag() );
if ( testFlag( faceBC, flag ) )
{
dgfunction::macroface::projectP1< ValueType >(
level, face, this->getStorage(), src.getFaceDataID(), this->getFaceDataID(), updateType );
}
}
this->template endCommunication< Edge, Face >( level );
this->stopTiming( "projectP1" );
}
template class DGFunction< real_t >;
template class DGFunction< int32_t >;
template class DGFunction< int64_t >;
} // namespace hyteg
......@@ -20,9 +20,6 @@
#pragma once
#include "hyteg/facedofspace/FaceDoFFunction.hpp"
#include "hyteg/dgfunctionspace/DGFunctionMacroEdge.hpp"
#include "hyteg/dgfunctionspace/DGFunctionMacroFace.hpp"
#include "hyteg/dgfunctionspace/DGFunctionMacroVertex.hpp"
namespace hyteg {
......@@ -39,66 +36,7 @@ class DGFunction : public FaceDoFFunction< ValueType >
: FaceDoFFunction< ValueType >( name, storage, minLevel, maxLevel )
{}
inline void projectP1( P1Function< real_t >& src, uint_t level, DoFType flag, UpdateType updateType = Replace );
void projectP1( P1Function< ValueType >& src, uint_t level, DoFType flag, UpdateType updateType = Replace );
};
template < typename ValueType >
void DGFunction< ValueType >::projectP1( P1Function< real_t >& src, uint_t level, DoFType flag, UpdateType updateType )
{
this->startTiming( "projectP1" );
src.startCommunication< Edge, Vertex >( level );
src.startCommunication< Face, Edge >( level );
src.endCommunication< Edge, Vertex >( level );
for ( auto& it : this->getStorage()->getVertices() )
{
Vertex& vertex = *it.second;
const DoFType vertexBC = this->getBoundaryCondition().getBoundaryType( vertex.getMeshBoundaryFlag() );
if ( testFlag( vertexBC, flag ) )
{
dgfunction::macrovertex::projectP1< real_t >(
level, vertex, this->getStorage(), src.getVertexDataID(), this->getVertexDataID(), updateType );
}
}
this->template startCommunication< Vertex, Edge >( level );
src.endCommunication< Face, Edge >( level );
for ( auto& it : this->getStorage()->getEdges() )
{
Edge& edge = *it.second;
const DoFType edgeBC = this->getBoundaryCondition().getBoundaryType( edge.getMeshBoundaryFlag() );
if ( testFlag( edgeBC, flag ) )
{
dgfunction::macroedge::projectP1< real_t >(
level, edge, this->getStorage(), src.getEdgeDataID(), this->getEdgeDataID(), updateType );
}
}
this->template endCommunication< Vertex, Edge >( level );
this->template startCommunication< Edge, Face >( level );
for ( auto& it : this->getStorage()->getFaces() )
{
Face& face = *it.second;
const DoFType faceBC = this->getBoundaryCondition().getBoundaryType( face.getMeshBoundaryFlag() );
if ( testFlag( faceBC, flag ) )
{
dgfunction::macroface::projectP1< real_t >(
level, face, this->getStorage(), src.getFaceDataID(), this->getFaceDataID(), updateType );
}
}
this->template endCommunication< Edge, Face >( level );
this->stopTiming( "projectP1" );
}
} // namespace hyteg
......@@ -18,9 +18,11 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "hyteg/facedofspace/FaceDoFIndexing.hpp"
#include "hyteg/p1functionspace/VertexDoFIndexing.hpp"
namespace hyteg {
namespace dgfunction {
namespace macroedge {
......
......@@ -22,6 +22,9 @@
#include <array>
#include "hyteg/dgfunctionspace/DGFunction.hpp"
#include "hyteg/dgfunctionspace/DGFunctionMacroEdge.hpp"
#include "hyteg/dgfunctionspace/DGFunctionMacroFace.hpp"
#include "hyteg/dgfunctionspace/DGFunctionMacroVertex.hpp"
#include "hyteg/operators/Operator.hpp"
#include "hyteg/types/pointnd.hpp"
......@@ -30,7 +33,7 @@ namespace hyteg {
template < class VelocityBaseType >
class DGUpwindOperator : public Operator< DGFunction< real_t >, DGFunction< real_t > >
{
typedef std::array< VelocityBaseType , 2 > VelocityType;
typedef std::array< VelocityBaseType, 2 > VelocityType;
public:
DGUpwindOperator( const std::shared_ptr< PrimitiveStorage >& storage,
......@@ -61,61 +64,61 @@ class DGUpwindOperator : public Operator< DGFunction< real_t >, DGFunction< real
// end pulling vertex halos
src.endCommunication< Edge, Vertex >( level );
for( auto velocityComponent : velocity_ )
for ( auto velocityComponent : velocity_ )
{
velocityComponent.template startCommunication< Edge, Vertex >( level );
}
for( auto velocityComponent : velocity_ )
for ( auto velocityComponent : velocity_ )
{
velocityComponent.template startCommunication< Face, Edge >( level );
}
for( auto velocityComponent : velocity_ )
for ( auto velocityComponent : velocity_ )
{
velocityComponent.template endCommunication< Edge, Vertex >( level );
}
for( auto& it : storage_->getVertices() )
for ( auto& it : storage_->getVertices() )
{
Vertex& vertex = *it.second;
const DoFType vertexBC = dst.getBoundaryCondition().getBoundaryType( vertex.getMeshBoundaryFlag() );
if( testFlag( vertexBC, flag ) )
if ( testFlag( vertexBC, flag ) )
{
dgfunction::macrovertex::upwind< real_t >( level,
vertex,
storage_,
src.getVertexDataID(),
dst.getVertexDataID(),
std::array< PrimitiveDataID< FunctionMemory< real_t >, Vertex >, 2 >{
{velocity_[0].getVertexDataID(), velocity_[1].getVertexDataID()}},
updateType );
vertex,
storage_,
src.getVertexDataID(),
dst.getVertexDataID(),
std::array< PrimitiveDataID< FunctionMemory< real_t >, Vertex >, 2 >{
{ velocity_[0].getVertexDataID(), velocity_[1].getVertexDataID() } },
updateType );
}
}
dst.startCommunication< Vertex, Edge >( level );
for( auto velocityComponent : velocity_ )
for ( auto velocityComponent : velocity_ )
{
velocityComponent.template endCommunication< Face, Edge >( level );
}
for( auto& it : storage_->getEdges() )
for ( auto& it : storage_->getEdges() )
{
Edge& edge = *it.second;
const DoFType edgeBC = dst.getBoundaryCondition().getBoundaryType( edge.getMeshBoundaryFlag() );
if( testFlag( edgeBC, flag ) )
if ( testFlag( edgeBC, flag ) )
{
dgfunction::macroedge::upwind< real_t >( level,
edge,
storage_,
src.getEdgeDataID(),
dst.getEdgeDataID(),
std::array< PrimitiveDataID< FunctionMemory< real_t >, Edge >, 2 >{
{velocity_[0].getEdgeDataID(), velocity_[1].getEdgeDataID()}},
updateType );
edge,
storage_,
src.getEdgeDataID(),
dst.getEdgeDataID(),
std::array< PrimitiveDataID< FunctionMemory< real_t >, Edge >, 2 >{
{ velocity_[0].getEdgeDataID(), velocity_[1].getEdgeDataID() } },
updateType );
}
}
......@@ -123,21 +126,21 @@ class DGUpwindOperator : public Operator< DGFunction< real_t >, DGFunction< real
dst.startCommunication< Edge, Face >( level );
for( auto& it : storage_->getFaces() )
for ( auto& it : storage_->getFaces() )
{
Face& face = *it.second;
const DoFType faceBC = dst.getBoundaryCondition().getBoundaryType( face.getMeshBoundaryFlag() );
if( testFlag( faceBC, flag ) )
if ( testFlag( faceBC, flag ) )
{
dgfunction::macroface::upwind< real_t >( level,
face,
storage_,
src.getFaceDataID(),
dst.getFaceDataID(),
std::array< PrimitiveDataID< FunctionMemory< real_t >, Face >, 2 >{
{velocity_[0].getFaceDataID(), velocity_[1].getFaceDataID()}},
updateType );
face,
storage_,
src.getFaceDataID(),
dst.getFaceDataID(),
std::array< PrimitiveDataID< FunctionMemory< real_t >, Face >, 2 >{
{ velocity_[0].getFaceDataID(), velocity_[1].getFaceDataID() } },
updateType );
}
}
......
......@@ -26,81 +26,73 @@
namespace hyteg {
template< typename ValueType >
class VertexFaceDoFMemoryDataHandling : public FunctionMemoryDataHandling< FunctionMemory < ValueType >, Vertex >
template < typename ValueType >
class VertexFaceDoFMemoryDataHandling : public FunctionMemoryDataHandling< FunctionMemory< ValueType >, Vertex >
{
public:
VertexFaceDoFMemoryDataHandling( const uint_t & minLevel, const uint_t & maxLevel )
: minLevel_( minLevel ),
maxLevel_( maxLevel )
{}
public:
VertexFaceDoFMemoryDataHandling( const uint_t& minLevel, const uint_t& maxLevel )
: minLevel_( minLevel )
, maxLevel_( maxLevel )
{}
std::shared_ptr< FunctionMemory< ValueType > > initialize( const Vertex * const vertex ) const override;
private:
uint_t minLevel_;
uint_t maxLevel_;
std::shared_ptr< FunctionMemory< ValueType > > initialize( const Vertex* const vertex ) const override;
private:
uint_t minLevel_;
uint_t maxLevel_;
};
template< typename ValueType >
class EdgeFaceDoFMemoryDataHandling : public FunctionMemoryDataHandling< FunctionMemory < ValueType >, Edge >
template < typename ValueType >
class EdgeFaceDoFMemoryDataHandling : public FunctionMemoryDataHandling< FunctionMemory< ValueType >, Edge >
{
public:
EdgeFaceDoFMemoryDataHandling( const uint_t & minLevel, const uint_t & maxLevel )
: minLevel_( minLevel ),
maxLevel_( maxLevel )
{}
std::shared_ptr< FunctionMemory< ValueType > > initialize( const Edge * const vertex ) const override;
private:
public:
EdgeFaceDoFMemoryDataHandling( const uint_t& minLevel, const uint_t& maxLevel )
: minLevel_( minLevel )
, maxLevel_( maxLevel )
{}
uint_t minLevel_;
uint_t maxLevel_;
std::shared_ptr< FunctionMemory< ValueType > > initialize( const Edge* const vertex ) const override;
private:
uint_t minLevel_;
uint_t maxLevel_;
};
template< typename ValueType >
class FaceFaceDoFMemoryDataHandling : public FunctionMemoryDataHandling< FunctionMemory < ValueType >, Face >
template < typename ValueType >
class FaceFaceDoFMemoryDataHandling : public FunctionMemoryDataHandling< FunctionMemory< ValueType >, Face >
{
public:
FaceFaceDoFMemoryDataHandling( const uint_t & minLevel, const uint_t & maxLevel )
: minLevel_( minLevel ),
maxLevel_( maxLevel )
{}
public:
FaceFaceDoFMemoryDataHandling( const uint_t& minLevel, const uint_t& maxLevel )
: minLevel_( minLevel )
, maxLevel_( maxLevel )
{}
std::shared_ptr<FunctionMemory<ValueType>> initialize( const Face *const face) const override;
private:
uint_t minLevel_;
uint_t maxLevel_;
std::shared_ptr< FunctionMemory< ValueType > > initialize( const Face* const face ) const override;
private:
uint_t minLevel_;
uint_t maxLevel_;
};
template< typename ValueType >
template < typename ValueType >
std::shared_ptr< FunctionMemory< ValueType > >
VertexFaceDoFMemoryDataHandling< ValueType >::initialize( const Vertex * const vertex ) const
VertexFaceDoFMemoryDataHandling< ValueType >::initialize( const Vertex* const vertex ) const
{
return std::make_shared< FunctionMemory< ValueType > >( faceDoFMacroVertexFunctionMemorySize, *vertex, minLevel_, maxLevel_ );
return std::make_shared< FunctionMemory< ValueType > >( faceDoFMacroVertexFunctionMemorySize, *vertex, minLevel_, maxLevel_ );
}
template< typename ValueType >
template < typename ValueType >
std::shared_ptr< FunctionMemory< ValueType > >
EdgeFaceDoFMemoryDataHandling< ValueType >::initialize( const Edge * const edge ) const
EdgeFaceDoFMemoryDataHandling< ValueType >::initialize( const Edge* const edge ) const
{
return std::make_shared< FunctionMemory< ValueType > >( faceDoFMacroEdgeFunctionMemorySize, *edge, minLevel_, maxLevel_ );
return std::make_shared< FunctionMemory< ValueType > >( faceDoFMacroEdgeFunctionMemorySize, *edge, minLevel_, maxLevel_ );
}
template< typename ValueType >
template < typename ValueType >
std::shared_ptr< FunctionMemory< ValueType > >
FaceFaceDoFMemoryDataHandling< ValueType >::initialize( const Face * const face ) const
FaceFaceDoFMemoryDataHandling< ValueType >::initialize( const Face* const face ) const
{
return std::make_shared< FunctionMemory< ValueType > >( faceDoFMacroFaceFunctionMemorySize, *face, minLevel_, maxLevel_ );
return std::make_shared< FunctionMemory< ValueType > >( faceDoFMacroFaceFunctionMemorySize, *face, minLevel_, maxLevel_ );
}
}
} // namespace hyteg
This diff is collapsed.
This diff is collapsed.
......@@ -241,13 +241,13 @@ inline void assign( const uint_t&
}
template < typename ValueType >
inline real_t getMaxValue( const uint_t& level, Face& face, const PrimitiveDataID< FunctionMemory< ValueType >, Face >& srcId )
inline ValueType getMaxValue( const uint_t& level, Face& face, const PrimitiveDataID< FunctionMemory< ValueType >, Face >& srcId )
{
size_t rowsize = levelinfo::num_microvertices_per_edge( level );
size_t inner_rowsize = rowsize;
auto src = face.getData( srcId )->getPointer( level );
real_t localMax = -std::numeric_limits< ValueType >::max();
ValueType localMax = -std::numeric_limits< ValueType >::max();
// gray cells
for ( size_t j = 1; j < rowsize - 2; ++j )
......@@ -276,13 +276,13 @@ inline real_t getMaxValue( const uint_t& level, Face& face, const PrimitiveDataI
}
template < typename ValueType >
inline real_t getMinValue( const uint_t& level, Face& face, const PrimitiveDataID< FunctionMemory< ValueType >, Face >& srcId )
inline ValueType getMinValue( const uint_t& level, Face& face, const PrimitiveDataID< FunctionMemory< ValueType >, Face >& srcId )
{
size_t rowsize = levelinfo::num_microvertices_per_edge( level );
size_t inner_rowsize = rowsize;
auto src = face.getData( srcId )->getPointer( level );
real_t localMin = std::numeric_limits< ValueType >::max();
ValueType localMin = std::numeric_limits< ValueType >::max();
// gray cells
for ( size_t j = 1; j < rowsize - 2; ++j )
......@@ -311,14 +311,14 @@ inline real_t getMinValue( const uint_t& level, Face& face, const PrimitiveDataI
}
template < typename ValueType >
inline real_t
inline ValueType
getMaxMagnitude( const uint_t& level, Face& face, const PrimitiveDataID< FunctionMemory< ValueType >, Face >& srcId )
{
size_t rowsize = levelinfo::num_microvertices_per_edge( level );
size_t inner_rowsize = rowsize;
auto src = face.getData( srcId )->getPointer( level );
real_t localMax = real_t( 0.0 );
ValueType localMax = ValueType( 0.0 );
// gray cells
for ( size_t j = 1; j < rowsize - 2; ++j )
......
......@@ -19,9 +19,10 @@
*/
#pragma once
#include "hyteg/Levelinfo.hpp"
#include "core/debug/CheckFunctions.h"
#include "hyteg/Levelinfo.hpp"
namespace hyteg {
using walberla::uint_t;
......@@ -30,23 +31,22 @@ using walberla::uint_t;
/// the vertex memory has two entries for each adjacent face,
/// where the first entry is the Gray Face DoF and the Second one is the Blue Face DoF
/// the Gray Face DoF is owned by the Vertex and the Blue Face DoF is owned by the Face
inline uint_t faceDoFMacroVertexFunctionMemorySize( const uint_t & level, const Primitive & primitive )
inline uint_t faceDoFMacroVertexFunctionMemorySize( const uint_t& level, const Primitive& primitive )
{
WALBERLA_UNUSED( level );
return primitive.getNumNeighborFaces() * 2;
WALBERLA_UNUSED( level );
return primitive.getNumNeighborFaces() * 2;
}
inline uint_t faceDoFMacroEdgeFunctionMemorySize( const uint_t & level, const Primitive & primitive )
inline uint_t faceDoFMacroEdgeFunctionMemorySize( const uint_t& level, const Primitive& primitive )
{
const size_t num_cell_dofs = primitive.getNumNeighborFaces() * ( 2 * levelinfo::num_microedges_per_edge( level ) - 1 );
return num_cell_dofs;
const size_t num_cell_dofs = primitive.getNumNeighborFaces() * ( 2 * levelinfo::num_microedges_per_edge( level ) - 1 );
return num_cell_dofs;
}
inline uint_t faceDoFMacroFaceFunctionMemorySize( const uint_t & level, const Primitive & primitive )
inline uint_t faceDoFMacroFaceFunctionMemorySize( const uint_t& level, const Primitive& primitive )
{
WALBERLA_UNUSED( primitive );
return levelinfo::num_microfaces_per_face( level );
WALBERLA_UNUSED( primitive );
return levelinfo::num_microfaces_per_face( level );
}
}
} // namespace hyteg
This diff is collapsed.
......@@ -40,12 +40,12 @@ void checkComm(const std::string& meshfile,const uint_t maxLevel, bool bufferCom
const uint_t minLevel = 2;
//const uint_t maxLevel = 4;
hyteg::FaceDoFFunction< uint_t > x("x", storage, minLevel, maxLevel);
hyteg::FaceDoFFunction< int32_t > x("x", storage, minLevel, maxLevel);
if(bufferComm) {
x.setLocalCommunicationMode(communication::BufferedCommunicator::BUFFERED_MPI);
}
size_t num = 1;
int32_t num = 1;
x.enumerate(maxLevel,num);
uint_t numberOfChecks = 0;
......@@ -66,12 +66,12 @@ void checkComm(const std::string& meshfile,const uint_t maxLevel, bool bufferCom
for (auto &edgeIt : storage->getEdges()) {
Edge &edge = *edgeIt.second;
//BubbleEdge::printFunctionMemory(edge,x.getEdgeDataID(),maxLevel);
uint_t *edgeData = edge.getData(x.getEdgeDataID())->getPointer(maxLevel);
int32_t *edgeData = edge.getData(x.getEdgeDataID())->getPointer(maxLevel);
std::vector<PrimitiveID> nbrVertices;
edge.getNeighborVertices(nbrVertices);
for(auto& vertexIt : nbrVertices){
Vertex* vertex = storage->getVertex(vertexIt.getID());
uint_t* vertexData = vertex->getData(x.getVertexDataID())->getPointer(maxLevel);
int32_t * vertexData = vertex->getData(x.getVertexDataID())->getPointer(maxLevel);
uint_t vPerEdge = levelinfo::num_microvertices_per_edge(maxLevel);
uint_t pos = std::numeric_limits< uint_t >::max();
if(edge.vertex_index(vertex->getID()) == 0){
......@@ -117,12 +117,12 @@ void checkComm(const std::string& meshfile,const uint_t maxLevel, bool bufferCom
for (auto &faceIt : storage->getFaces()) {
Face &face = *faceIt.second;
uint_t *faceData = face.getData(x.getFaceDataID())->getPointer(maxLevel);
int32_t *faceData = face.getData(x.getFaceDataID())->getPointer(maxLevel);
std::vector<PrimitiveID> nbrEdges;
face.getNeighborEdges(nbrEdges);
for(uint_t i = 0; i < nbrEdges.size(); ++i){
Edge* edge = storage->getEdge(nbrEdges[0].getID());
uint_t* edgeData = edge->getData(x.getEdgeDataID())->getPointer(maxLevel);
int32_t* edgeData = edge->getData(x.getEdgeDataID())->getPointer(maxLevel);
uint_t idxCounter = 0;
uint_t faceIdOnEdge = edge->face_index(face.getID());
//////////////////// GRAY CELL //////////////////////
......