Commit 6d17baa3 authored by Jakub Klinkovský's avatar Jakub Klinkovský

Refactoring VectorFieldVTKWriter

Fixes #11
parent 4675fbdf
......@@ -68,11 +68,10 @@ template< typename MeshFunction,
class MeshFunctionGnuplotWriter
: public MeshFunctionGnuplotWriterBase
{
public:
using MeshType = typename MeshFunction::MeshType;
using EntityType = typename MeshType::template EntityType< MeshFunction::getEntitiesDimension() >;
using GlobalIndex = typename MeshType::GlobalIndexType;
public:
using MeshType = typename MeshFunction::MeshType;
using EntityType = typename MeshType::template EntityType< MeshFunction::getEntitiesDimension() >;
using GlobalIndex = typename MeshType::GlobalIndexType;
static bool write( const MeshFunction& function,
std::ostream& str,
......@@ -99,11 +98,10 @@ template< typename MeshFunction,
class MeshFunctionGnuplotWriter< MeshFunction, Meshes::Grid< 2, Real, Device, Index >, EntityDimension >
: public MeshFunctionGnuplotWriterBase
{
public:
using MeshType = typename MeshFunction::MeshType;
using EntityType = typename MeshType::template EntityType< MeshFunction::getEntitiesDimension() >;
using GlobalIndex = typename MeshType::GlobalIndexType;
public:
using MeshType = typename MeshFunction::MeshType;
using EntityType = typename MeshType::template EntityType< MeshFunction::getEntitiesDimension() >;
using GlobalIndex = typename MeshType::GlobalIndexType;
static bool write( const MeshFunction& function,
std::ostream& str,
......@@ -137,11 +135,10 @@ template< typename MeshFunction,
class MeshFunctionGnuplotWriter< MeshFunction, Meshes::Grid< 3, Real, Device, Index >, EntityDimension >
: public MeshFunctionGnuplotWriterBase
{
public:
using MeshType = typename MeshFunction::MeshType;
using EntityType = typename MeshType::template EntityType< MeshFunction::getEntitiesDimension() >;
using GlobalIndex = typename MeshType::GlobalIndexType;
public:
using MeshType = typename MeshFunction::MeshType;
using EntityType = typename MeshType::template EntityType< MeshFunction::getEntitiesDimension() >;
using GlobalIndex = typename MeshType::GlobalIndexType;
static bool write( const MeshFunction& function,
std::ostream& str,
......@@ -167,6 +164,5 @@ class MeshFunctionGnuplotWriter< MeshFunction, Meshes::Grid< 3, Real, Device, In
}
};
} // namespace Functions
} // namespace TNL
......@@ -13,7 +13,7 @@
#include <TNL/Meshes/Writers/VTKWriter.h>
namespace TNL {
namespace Functions {
namespace Functions {
template< typename MeshFunction >
class MeshFunctionVTKWriter
......
......@@ -16,15 +16,15 @@ namespace TNL {
namespace Functions {
template< int, typename > class VectorField;
template< typename, int, typename > class MeshFunction;
template< typename VectorField >
class VectorFieldGnuplotWriter
{
public:
static bool write( const VectorField& function,
std::ostream& str,
const double& scale );
public:
static bool write( const VectorField& function,
std::ostream& str,
const double& scale );
};
/***
......@@ -37,14 +37,14 @@ template< typename MeshReal,
int VectorFieldSize >
class VectorFieldGnuplotWriter< VectorField< VectorFieldSize, MeshFunction< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, 1, Real > > >
{
public:
typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType;
typedef Real RealType;
typedef Functions::VectorField< VectorFieldSize, MeshFunction< MeshType, 1, RealType > > VectorFieldType;
static bool write( const VectorFieldType& function,
std::ostream& str,
const double& scale );
public:
using MeshType = Meshes::Grid< 1, MeshReal, Device, MeshIndex >;
using RealType = Real;
using VectorFieldType = Functions::VectorField< VectorFieldSize, MeshFunction< MeshType, 1, RealType > >;
static bool write( const VectorFieldType& function,
std::ostream& str,
const double& scale );
};
/***
......@@ -57,14 +57,14 @@ template< typename MeshReal,
int VectorFieldSize >
class VectorFieldGnuplotWriter< VectorField< VectorFieldSize, MeshFunction< Meshes::Grid< 1, MeshReal, Device, MeshIndex >, 0, Real > > >
{
public:
typedef Meshes::Grid< 1, MeshReal, Device, MeshIndex > MeshType;
typedef Real RealType;
typedef Functions::VectorField< VectorFieldSize, MeshFunction< MeshType, 0, RealType > > VectorFieldType;
static bool write( const VectorFieldType& function,
std::ostream& str,
const double& scale );
public:
using MeshType = Meshes::Grid< 1, MeshReal, Device, MeshIndex >;
using RealType = Real;
using VectorFieldType = Functions::VectorField< VectorFieldSize, MeshFunction< MeshType, 0, RealType > >;
static bool write( const VectorFieldType& function,
std::ostream& str,
const double& scale );
};
......@@ -78,14 +78,14 @@ template< typename MeshReal,
int VectorFieldSize >
class VectorFieldGnuplotWriter< VectorField< VectorFieldSize, MeshFunction< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, 2, Real > > >
{
public:
typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType;
typedef Real RealType;
typedef Functions::VectorField< VectorFieldSize, MeshFunction< MeshType, 2, RealType > > VectorFieldType;
static bool write( const VectorFieldType& function,
std::ostream& str,
const double& scale );
public:
using MeshType = Meshes::Grid< 2, MeshReal, Device, MeshIndex >;
using RealType = Real;
using VectorFieldType = Functions::VectorField< VectorFieldSize, MeshFunction< MeshType, 2, RealType > >;
static bool write( const VectorFieldType& function,
std::ostream& str,
const double& scale );
};
/***
......@@ -98,14 +98,14 @@ template< typename MeshReal,
int VectorFieldSize >
class VectorFieldGnuplotWriter< VectorField< VectorFieldSize, MeshFunction< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, 1, Real > > >
{
public:
typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType;
typedef Real RealType;
typedef Functions::VectorField< VectorFieldSize, MeshFunction< MeshType, 1, RealType > > VectorFieldType;
static bool write( const VectorFieldType& function,
std::ostream& str,
const double& scale );
public:
using MeshType = Meshes::Grid< 2, MeshReal, Device, MeshIndex >;
using RealType = Real;
using VectorFieldType = Functions::VectorField< VectorFieldSize, MeshFunction< MeshType, 1, RealType > >;
static bool write( const VectorFieldType& function,
std::ostream& str,
const double& scale );
};
/***
......@@ -118,14 +118,14 @@ template< typename MeshReal,
int VectorFieldSize >
class VectorFieldGnuplotWriter< VectorField< VectorFieldSize, MeshFunction< Meshes::Grid< 2, MeshReal, Device, MeshIndex >, 0, Real > > >
{
public:
typedef Meshes::Grid< 2, MeshReal, Device, MeshIndex > MeshType;
typedef Real RealType;
typedef Functions::VectorField< VectorFieldSize, MeshFunction< MeshType, 0, RealType > > VectorFieldType;
static bool write( const VectorFieldType& function,
std::ostream& str,
const double& scale );
public:
using MeshType = Meshes::Grid< 2, MeshReal, Device, MeshIndex >;
using RealType = Real;
using VectorFieldType = Functions::VectorField< VectorFieldSize, MeshFunction< MeshType, 0, RealType > >;
static bool write( const VectorFieldType& function,
std::ostream& str,
const double& scale );
};
......@@ -139,14 +139,14 @@ template< typename MeshReal,
int VectorFieldSize >
class VectorFieldGnuplotWriter< VectorField< VectorFieldSize, MeshFunction< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, 3, Real > > >
{
public:
typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType;
typedef Real RealType;
typedef Functions::VectorField< VectorFieldSize, MeshFunction< MeshType, 3, RealType > > VectorFieldType;
static bool write( const VectorFieldType& function,
std::ostream& str,
const double& scale );
public:
using MeshType = Meshes::Grid< 3, MeshReal, Device, MeshIndex >;
using RealType = Real;
using VectorFieldType = Functions::VectorField< VectorFieldSize, MeshFunction< MeshType, 3, RealType > >;
static bool write( const VectorFieldType& function,
std::ostream& str,
const double& scale );
};
/***
......@@ -159,14 +159,14 @@ template< typename MeshReal,
int VectorFieldSize >
class VectorFieldGnuplotWriter< VectorField< VectorFieldSize, MeshFunction< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, 2, Real > > >
{
public:
typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType;
typedef Real RealType;
typedef Functions::VectorField< VectorFieldSize, MeshFunction< MeshType, 2, RealType > > VectorFieldType;
static bool write( const VectorFieldType& function,
std::ostream& str,
const double& scale );
public:
using MeshType = Meshes::Grid< 3, MeshReal, Device, MeshIndex >;
using RealType = Real;
using VectorFieldType = Functions::VectorField< VectorFieldSize, MeshFunction< MeshType, 2, RealType > >;
static bool write( const VectorFieldType& function,
std::ostream& str,
const double& scale );
};
/***
......@@ -179,14 +179,14 @@ template< typename MeshReal,
int VectorFieldSize >
class VectorFieldGnuplotWriter< VectorField< VectorFieldSize, MeshFunction< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, 0, Real > > >
{
public:
typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType;
typedef Real RealType;
typedef Functions::VectorField< VectorFieldSize, MeshFunction< MeshType, 0, RealType > > VectorFieldType;
static bool write( const VectorFieldType& function,
std::ostream& str,
const double& scale );
public:
using MeshType = Meshes::Grid< 3, MeshReal, Device, MeshIndex >;
using RealType = Real;
using VectorFieldType = Functions::VectorField< VectorFieldSize, MeshFunction< MeshType, 0, RealType > >;
static bool write( const VectorFieldType& function,
std::ostream& str,
const double& scale );
};
} // namespace Functions
......
......@@ -43,9 +43,8 @@ write( const VectorFieldType& vectorField,
{
const MeshType& mesh = vectorField.getMesh();
typename MeshType::Cell entity( mesh );
for( entity.getCoordinates().x() = 0;
entity.getCoordinates().x() < mesh.getDimensions().x();
entity.getCoordinates().x() ++ )
auto& c = entity.getCoordinates();
for( c.x() = 0; c.x() < mesh.getDimensions().x(); c.x()++ )
{
entity.refresh();
typename MeshType::PointType v = entity.getCenter();
......@@ -73,9 +72,8 @@ write( const VectorFieldType& vectorField,
{
const MeshType& mesh = vectorField.getMesh();
typename MeshType::Vertex entity( mesh );
for( entity.getCoordinates().x() = 0;
entity.getCoordinates().x() <= mesh.getDimensions().x();
entity.getCoordinates().x() ++ )
auto& c = entity.getCoordinates();
for( c.x() = 0; c.x() <= mesh.getDimensions().x(); c.x()++ )
{
entity.refresh();
typename MeshType::PointType v = entity.getCenter();
......@@ -104,13 +102,10 @@ write( const VectorFieldType& vectorField,
{
const MeshType& mesh = vectorField.getMesh();
typename MeshType::Cell entity( mesh );
for( entity.getCoordinates().y() = 0;
entity.getCoordinates().y() < mesh.getDimensions().y();
entity.getCoordinates().y() ++ )
auto& c = entity.getCoordinates();
for( c.y() = 0; c.y() < mesh.getDimensions().y(); c.y()++ )
{
for( entity.getCoordinates().x() = 0;
entity.getCoordinates().x() < mesh.getDimensions().x();
entity.getCoordinates().x() ++ )
for( c.x() = 0; c.x() < mesh.getDimensions().x(); c.x()++ )
{
entity.refresh();
typename MeshType::PointType v = entity.getCenter();
......@@ -142,15 +137,12 @@ write( const VectorFieldType& vectorField,
typedef typename MeshType::Face EntityType;
typedef typename EntityType::EntityOrientationType EntityOrientation;
EntityType entity( mesh );
auto& c = entity.getCoordinates();
entity.setOrientation( EntityOrientation( 1.0, 0.0 ) );
for( entity.getCoordinates().y() = 0;
entity.getCoordinates().y() < mesh.getDimensions().y();
entity.getCoordinates().y() ++ )
for( c.y() = 0; c.y() < mesh.getDimensions().y(); c.y()++ )
{
for( entity.getCoordinates().x() = 0;
entity.getCoordinates().x() <= mesh.getDimensions().x();
entity.getCoordinates().x() ++ )
for( c.x() = 0; c.x() <= mesh.getDimensions().x(); c.x()++ )
{
entity.refresh();
typename MeshType::PointType v = entity.getCenter();
......@@ -163,15 +155,9 @@ write( const VectorFieldType& vectorField,
}
entity.setOrientation( EntityOrientation( 0.0, 1.0 ) );
for( entity.getCoordinates().x() = 0;
entity.getCoordinates().x() < mesh.getDimensions().x();
entity.getCoordinates().x() ++ )
for( c.x() = 0; c.x() < mesh.getDimensions().x(); c.x()++ )
{
for( entity.getCoordinates().y() = 0;
entity.getCoordinates().y() <= mesh.getDimensions().y();
entity.getCoordinates().y() ++ )
for( c.y() = 0; c.y() <= mesh.getDimensions().y(); c.y()++ )
{
entity.refresh();
typename MeshType::PointType v = entity.getCenter();
......@@ -202,13 +188,10 @@ write( const VectorFieldType& vectorField,
{
const MeshType& mesh = vectorField.getMesh();
typename MeshType::Vertex entity( mesh );
for( entity.getCoordinates().y() = 0;
entity.getCoordinates().y() <= mesh.getDimensions().y();
entity.getCoordinates().y() ++ )
auto& c = entity.getCoordinates();
for( c.y() = 0; c.y() <= mesh.getDimensions().y(); c.y()++ )
{
for( entity.getCoordinates().x() = 0;
entity.getCoordinates().x() <= mesh.getDimensions().x();
entity.getCoordinates().x() ++ )
for( c.x() = 0; c.x() <= mesh.getDimensions().x(); c.x()++ )
{
entity.refresh();
typename MeshType::PointType v = entity.getCenter();
......@@ -239,16 +222,11 @@ write( const VectorFieldType& vectorField,
{
const MeshType& mesh = vectorField.getMesh();
typename MeshType::Cell entity( mesh );
for( entity.getCoordinates().z() = 0;
entity.getCoordinates().z() < mesh.getDimensions().z();
entity.getCoordinates().z() ++ )
for( entity.getCoordinates().y() = 0;
entity.getCoordinates().y() < mesh.getDimensions().y();
entity.getCoordinates().y() ++ )
auto& c = entity.getCoordinates();
for( c.z() = 0; c.z() < mesh.getDimensions().z(); c.z()++ )
for( c.y() = 0; c.y() < mesh.getDimensions().y(); c.y()++ )
{
for( entity.getCoordinates().x() = 0;
entity.getCoordinates().x() < mesh.getDimensions().x();
entity.getCoordinates().x() ++ )
for( c.x() = 0; c.x() < mesh.getDimensions().x(); c.x()++ )
{
entity.refresh();
typename MeshType::PointType v = entity.getCenter();
......@@ -280,18 +258,13 @@ write( const VectorFieldType& vectorField,
typedef typename MeshType::Face EntityType;
typedef typename EntityType::EntityOrientationType EntityOrientation;
EntityType entity( mesh );
auto& c = entity.getCoordinates();
entity.setOrientation( EntityOrientation( 1.0, 0.0, 0.0 ) );
for( entity.getCoordinates().z() = 0;
entity.getCoordinates().z() < mesh.getDimensions().z();
entity.getCoordinates().z() ++ )
for( entity.getCoordinates().y() = 0;
entity.getCoordinates().y() < mesh.getDimensions().y();
entity.getCoordinates().y() ++ )
for( c.z() = 0; c.z() < mesh.getDimensions().z(); c.z()++ )
for( c.y() = 0; c.y() < mesh.getDimensions().y(); c.y()++ )
{
for( entity.getCoordinates().x() = 0;
entity.getCoordinates().x() <= mesh.getDimensions().x();
entity.getCoordinates().x() ++ )
for( c.x() = 0; c.x() <= mesh.getDimensions().x(); c.x()++ )
{
entity.refresh();
typename MeshType::PointType v = entity.getCenter();
......@@ -304,16 +277,10 @@ write( const VectorFieldType& vectorField,
}
entity.setOrientation( EntityOrientation( 0.0, 1.0, 0.0 ) );
for( entity.getCoordinates().z() = 0;
entity.getCoordinates().z() < mesh.getDimensions().z();
entity.getCoordinates().z() ++ )
for( entity.getCoordinates().x() = 0;
entity.getCoordinates().x() < mesh.getDimensions().x();
entity.getCoordinates().x() ++ )
for( c.z() = 0; c.z() < mesh.getDimensions().z(); c.z()++ )
for( c.x() = 0; c.x() < mesh.getDimensions().x(); c.x()++ )
{
for( entity.getCoordinates().y() = 0;
entity.getCoordinates().y() <= mesh.getDimensions().y();
entity.getCoordinates().y() ++ )
for( c.y() = 0; c.y() <= mesh.getDimensions().y(); c.y()++ )
{
entity.refresh();
typename MeshType::PointType v = entity.getCenter();
......@@ -326,16 +293,10 @@ write( const VectorFieldType& vectorField,
}
entity.setOrientation( EntityOrientation( 0.0, 0.0, 1.0 ) );
for( entity.getCoordinates().x() = 0;
entity.getCoordinates().x() < mesh.getDimensions().x();
entity.getCoordinates().x() ++ )
for( entity.getCoordinates().y() = 0;
entity.getCoordinates().y() <= mesh.getDimensions().y();
entity.getCoordinates().y() ++ )
for( c.x() = 0; c.x() < mesh.getDimensions().x(); c.x()++ )
for( c.y() = 0; c.y() <= mesh.getDimensions().y(); c.y()++ )
{
for( entity.getCoordinates().z() = 0;
entity.getCoordinates().z() < mesh.getDimensions().z();
entity.getCoordinates().z() ++ )
for( c.z() = 0; c.z() < mesh.getDimensions().z(); c.z()++ )
{
entity.refresh();
typename MeshType::PointType v = entity.getCenter();
......@@ -366,16 +327,11 @@ write( const VectorFieldType& vectorField,
{
const MeshType& mesh = vectorField.getMesh();
typename MeshType::Vertex entity( mesh );
for( entity.getCoordinates().z() = 0;
entity.getCoordinates().z() <= mesh.getDimensions().z();
entity.getCoordinates().z() ++ )
for( entity.getCoordinates().y() = 0;
entity.getCoordinates().y() <= mesh.getDimensions().y();
entity.getCoordinates().y() ++ )
auto& c = entity.getCoordinates();
for( c.z() = 0; c.z() <= mesh.getDimensions().z(); c.z()++ )
for( c.y() = 0; c.y() <= mesh.getDimensions().y(); c.y()++ )
{
for( entity.getCoordinates().x() = 0;
entity.getCoordinates().x() <= mesh.getDimensions().x();
entity.getCoordinates().x() ++ )
for( c.x() = 0; c.x() <= mesh.getDimensions().x(); c.x()++ )
{
entity.refresh();
typename MeshType::PointType v = entity.getCenter();
......@@ -391,4 +347,3 @@ write( const VectorFieldType& vectorField,
} // namespace Functions
} // namespace TNL
This diff is collapsed.
This diff is collapsed.
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