Commit 66dc022b authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Refactoring VectorFieldVTKWriter

Fixes #11
parent 0af3a934
Loading
Loading
Loading
Loading
+12 −16
Original line number Diff line number Diff line
@@ -69,7 +69,6 @@ class MeshFunctionGnuplotWriter
: public MeshFunctionGnuplotWriterBase
{
public:

   using MeshType = typename MeshFunction::MeshType;
   using EntityType = typename MeshType::template EntityType< MeshFunction::getEntitiesDimension() >;
   using GlobalIndex = typename MeshType::GlobalIndexType;
@@ -100,7 +99,6 @@ class MeshFunctionGnuplotWriter< MeshFunction, Meshes::Grid< 2, Real, Device, In
: public MeshFunctionGnuplotWriterBase
{
public:

   using MeshType = typename MeshFunction::MeshType;
   using EntityType = typename MeshType::template EntityType< MeshFunction::getEntitiesDimension() >;
   using GlobalIndex = typename MeshType::GlobalIndexType;
@@ -138,7 +136,6 @@ class MeshFunctionGnuplotWriter< MeshFunction, Meshes::Grid< 3, Real, Device, In
: public MeshFunctionGnuplotWriterBase
{
public:

   using MeshType = typename MeshFunction::MeshType;
   using EntityType = typename MeshType::template EntityType< MeshFunction::getEntitiesDimension() >;
   using GlobalIndex = typename MeshType::GlobalIndexType;
@@ -167,6 +164,5 @@ class MeshFunctionGnuplotWriter< MeshFunction, Meshes::Grid< 3, Real, Device, In
   }
};


} // namespace Functions
} // namespace TNL
+69 −69
Original line number Diff line number Diff line
@@ -16,12 +16,12 @@ 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 );
@@ -38,9 +38,9 @@ template< typename MeshReal,
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;
   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,
@@ -58,9 +58,9 @@ template< typename MeshReal,
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;
   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,
@@ -79,9 +79,9 @@ template< typename MeshReal,
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;
   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,
@@ -99,9 +99,9 @@ template< typename MeshReal,
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;
   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,
@@ -119,9 +119,9 @@ template< typename MeshReal,
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;
   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,
@@ -140,9 +140,9 @@ template< typename MeshReal,
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;
   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,
@@ -160,9 +160,9 @@ template< typename MeshReal,
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;
   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,
@@ -180,9 +180,9 @@ template< typename MeshReal,
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;
   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,
+33 −78
Original line number Diff line number Diff line
@@ -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
+39 −242

File changed.

Preview size limit exceeded, changes collapsed.

+0 −881

File deleted.

Preview size limit exceeded, changes collapsed.

+1 −1

File changed.

Contains only whitespace changes.

Loading