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

Implemented MeshFunctionGnuplotWriter for 3D grids

parent 0865f702
No related branches found
No related tags found
No related merge requests found
......@@ -13,7 +13,7 @@
#include <TNL/Meshes/Grid.h>
namespace TNL {
namespace Functions {
namespace Functions {
template< typename, int, typename > class MeshFunction;
......@@ -62,6 +62,7 @@ class MeshFunctionGnuplotWriter< MeshFunction< Meshes::Grid< 1, MeshReal, Device
std::ostream& str );
};
/***
* 2D grids cells
*/
......@@ -98,7 +99,6 @@ class MeshFunctionGnuplotWriter< MeshFunction< Meshes::Grid< 2, MeshReal, Device
std::ostream& str );
};
/***
* 2D grids vertices
*/
......@@ -117,6 +117,61 @@ class MeshFunctionGnuplotWriter< MeshFunction< Meshes::Grid< 2, MeshReal, Device
std::ostream& str );
};
/***
* 3D grids cells
*/
template< typename MeshReal,
typename Device,
typename MeshIndex,
typename Real >
class MeshFunctionGnuplotWriter< MeshFunction< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, 3, Real > >
{
public:
typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType;
typedef Real RealType;
typedef Functions::MeshFunction< MeshType, 3, RealType > MeshFunctionType;
static bool write( const MeshFunctionType& function,
std::ostream& str );
};
/***
* 3D grids faces
*/
template< typename MeshReal,
typename Device,
typename MeshIndex,
typename Real >
class MeshFunctionGnuplotWriter< MeshFunction< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, 2, Real > >
{
public:
typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType;
typedef Real RealType;
typedef Functions::MeshFunction< MeshType, 2, RealType > MeshFunctionType;
static bool write( const MeshFunctionType& function,
std::ostream& str );
};
/***
* 3D grids vertices
*/
template< typename MeshReal,
typename Device,
typename MeshIndex,
typename Real >
class MeshFunctionGnuplotWriter< MeshFunction< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, 0, Real > >
{
public:
typedef Meshes::Grid< 3, MeshReal, Device, MeshIndex > MeshType;
typedef Real RealType;
typedef Functions::MeshFunction< MeshType, 0, RealType > MeshFunctionType;
static bool write( const MeshFunctionType& function,
std::ostream& str );
};
} // namespace Functions
} // namespace TNL
......@@ -11,7 +11,7 @@
#pragma once
namespace TNL {
namespace Functions {
namespace Functions {
template< typename MeshFunction >
bool
......@@ -124,7 +124,7 @@ write( const MeshFunctionType& function,
typedef typename MeshType::Face EntityType;
typedef typename EntityType::EntityOrientationType EntityOrientation;
EntityType entity( mesh );
entity.setOrientation( EntityOrientation( 1.0, 0.0 ) );
for( entity.getCoordinates().y() = 0;
entity.getCoordinates().y() < mesh.getDimensions().y();
......@@ -141,7 +141,7 @@ write( const MeshFunctionType& function,
}
str << std::endl;
}
entity.setOrientation( EntityOrientation( 0.0, 1.0 ) );
for( entity.getCoordinates().x() = 0;
entity.getCoordinates().x() < mesh.getDimensions().x();
......@@ -196,6 +196,157 @@ write( const MeshFunctionType& function,
return true;
}
/****
* 3D grid, cells
*/
template< typename MeshReal,
typename Device,
typename MeshIndex,
typename Real >
bool
MeshFunctionGnuplotWriter< MeshFunction< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, 3, Real > >::
write( const MeshFunctionType& function,
std::ostream& str )
{
const MeshType& mesh = function.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() ++ )
{
for( entity.getCoordinates().x() = 0;
entity.getCoordinates().x() < mesh.getDimensions().x();
entity.getCoordinates().x() ++ )
{
entity.refresh();
typename MeshType::VertexType v = entity.getCenter();
str << v.x() << " " << v.y() << " " << v.z() << " "
<< function.getData().getElement( entity.getIndex() ) << std::endl;
}
str << std::endl;
}
return true;
}
/****
* 3D grid, faces
*/
template< typename MeshReal,
typename Device,
typename MeshIndex,
typename Real >
bool
MeshFunctionGnuplotWriter< MeshFunction< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, 2, Real > >::
write( const MeshFunctionType& function,
std::ostream& str )
{
const MeshType& mesh = function.getMesh();
typedef typename MeshType::Face EntityType;
typedef typename EntityType::EntityOrientationType EntityOrientation;
EntityType entity( mesh );
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( entity.getCoordinates().x() = 0;
entity.getCoordinates().x() <= mesh.getDimensions().x();
entity.getCoordinates().x() ++ )
{
entity.refresh();
typename MeshType::VertexType v = entity.getCenter();
str << v.x() << " " << v.y() << " " << v.z() << " "
<< function.getData().getElement( entity.getIndex() ) << std::endl;
}
str << std::endl;
}
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( entity.getCoordinates().y() = 0;
entity.getCoordinates().y() <= mesh.getDimensions().y();
entity.getCoordinates().y() ++ )
{
entity.refresh();
typename MeshType::VertexType v = entity.getCenter();
str << v.x() << " " << v.y() << " " << v.z() << " "
<< function.getData().getElement( entity.getIndex() ) << std::endl;
}
str << std::endl;
}
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( entity.getCoordinates().z() = 0;
entity.getCoordinates().z() < mesh.getDimensions().z();
entity.getCoordinates().z() ++ )
{
entity.refresh();
typename MeshType::VertexType v = entity.getCenter();
str << v.x() << " " << v.y() << " " << v.z() << " "
<< function.getData().getElement( entity.getIndex() ) << std::endl;
}
str << std::endl;
}
return true;
}
/****
* 3D grid, vertices
*/
template< typename MeshReal,
typename Device,
typename MeshIndex,
typename Real >
bool
MeshFunctionGnuplotWriter< MeshFunction< Meshes::Grid< 3, MeshReal, Device, MeshIndex >, 0, Real > >::
write( const MeshFunctionType& function,
std::ostream& str )
{
const MeshType& mesh = function.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() ++ )
{
for( entity.getCoordinates().x() = 0;
entity.getCoordinates().x() <= mesh.getDimensions().x();
entity.getCoordinates().x() ++ )
{
entity.refresh();
typename MeshType::VertexType v = entity.getCenter();
str << v.x() << " " << v.y() << " " << v.z() << " "
<< function.getData().getElement( entity.getIndex() ) << std::endl;
}
str << std::endl;
}
return true;
}
} // namespace Functions
} // namespace TNL
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment