Skip to content
Snippets Groups Projects
Commit 165475cc authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Adjusted interface of Mesh

parent a5959f74
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,7 @@
#include <ostream>
#include <TNL/Object.h>
#include <TNL/Logger.h>
#include <TNL/Meshes/MeshEntity.h>
#include <TNL/Meshes/MeshDetails/traits/MeshTraits.h>
#include <TNL/Meshes/MeshDetails/layers/MeshStorageLayer.h>
......@@ -42,9 +43,8 @@ class Mesh
using DeviceType = typename MeshTraitsType::DeviceType;
using GlobalIndexType = typename MeshTraitsType::GlobalIndexType;
using LocalIndexType = typename MeshTraitsType::LocalIndexType;
using CellType = typename MeshTraitsType::CellType;
using VertexType = typename MeshTraitsType::VertexType;
using PointType = typename MeshTraitsType::PointType;
using RealType = typename PointType::RealType;
template< int Dimension >
using EntityTraits = typename MeshTraitsType::template EntityTraits< Dimension >;
......@@ -52,6 +52,13 @@ class Mesh
template< int Dimension >
using EntityType = typename EntityTraits< Dimension >::EntityType;
static constexpr int getMeshDimension();
// types of common entities
using Cell = EntityType< getMeshDimension() >;
using Face = EntityType< getMeshDimension() - 1 >;
using Vertex = EntityType< 0 >;
static String getType();
virtual String getTypeVirtual() const;
......@@ -60,8 +67,6 @@ class Mesh
virtual String getSerializationTypeVirtual() const;
static constexpr int getMeshDimension();
using StorageBaseType::isBoundaryEntity;
using StorageBaseType::getBoundaryEntitiesCount;
using StorageBaseType::getBoundaryEntityIndex;
......@@ -80,6 +85,18 @@ class Mesh
template< int Dimension >
const EntityType< Dimension >& getEntity( const GlobalIndexType& entityIndex ) const;
// duplicated for compatibility with grids
template< typename EntityType >
GlobalIndexType getEntitiesCount() const;
template< typename EntityType >
EntityType& getEntity( const GlobalIndexType& entityIndex );
template< typename EntityType >
const EntityType& getEntity( const GlobalIndexType& entityIndex ) const;
bool save( File& file ) const;
bool load( File& file );
......@@ -95,6 +112,8 @@ class Mesh
bool init( typename MeshTraitsType::PointArrayType& points,
typename MeshTraitsType::CellSeedArrayType& cellSeeds );
void writeProlog( Logger& logger );
protected:
// Methods for the mesh initializer
using StorageBaseType::setNumberOfEntities;
......
......@@ -21,6 +21,14 @@
namespace TNL {
namespace Meshes {
template< typename MeshConfig >
constexpr int
Mesh< MeshConfig >::
getMeshDimension()
{
return MeshTraitsType::meshDimension;
}
template< typename MeshConfig >
String
Mesh< MeshConfig >::
......@@ -53,14 +61,6 @@ getSerializationTypeVirtual() const
return this->getSerializationType();
}
template< typename MeshConfig >
constexpr int
Mesh< MeshConfig >::
getMeshDimension()
{
return MeshTraitsType::meshDimension;
}
template< typename MeshConfig >
template< int Dimension >
constexpr bool
......@@ -100,6 +100,36 @@ getEntity( const GlobalIndexType& entityIndex ) const
return StorageBaseType::getEntity( DimensionTag< Dimension >(), entityIndex );
}
// duplicated for compatibility with grids
template< typename MeshConfig >
template< typename Entity >
typename Mesh< MeshConfig >::GlobalIndexType
Mesh< MeshConfig >::
getEntitiesCount() const
{
return getEntitiesCount< Entity::getEntityDimension() >();
}
template< typename MeshConfig >
template< typename Entity >
Entity&
Mesh< MeshConfig >::
getEntity( const GlobalIndexType& entityIndex )
{
return getEntity< Entity::getEntityDimension() >( entityIndex );
}
template< typename MeshConfig >
template< typename Entity >
const Entity&
Mesh< MeshConfig >::
getEntity( const GlobalIndexType& entityIndex ) const
{
return getEntity< Entity::getEntityDimension() >( entityIndex );
}
template< typename MeshConfig >
bool
Mesh< MeshConfig >::
......@@ -159,6 +189,17 @@ init( typename MeshTraitsType::PointArrayType& points,
return true;
}
template< typename MeshConfig >
void
Mesh< MeshConfig >::
writeProlog( Logger& logger )
{
logger.writeParameter( "Dimension:", getMeshDimension() );
logger.writeParameter( "Number of cells:", getEntitiesCount< getMeshDimension() >() );
logger.writeParameter( "Number of vertices:", getEntitiesCount< 0 >() );
// TODO: more parameters?
}
template< typename MeshConfig >
std::ostream& operator<<( std::ostream& str, const Mesh< MeshConfig >& mesh )
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment