Skip to content
Snippets Groups Projects
Commit 65c1747d authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Implementing mesh function writer.

parent 576521e2
No related branches found
No related tags found
No related merge requests found
......@@ -119,6 +119,9 @@ class tnlMeshFunction :
bool boundLoad( tnlFile& file );
bool write( const tnlString& fileName,
const tnlString& format = "vtk" ) const;
using tnlObject::save;
using tnlObject::load;
......
......@@ -352,6 +352,18 @@ boundLoad( tnlFile& file )
return this->data.boundLoad( file );
}
template< typename Mesh,
int MeshEntityDimensions,
typename Real >
bool
tnlMeshFunction< Mesh, MeshEntityDimensions, Real >::
write( const tnlString& fileName,
const tnlString& format ) const
{
return true;
}
#endif /* TNLMESHFUNCTION_IMPL_H */
......@@ -25,30 +25,60 @@
#include <core/vectors/tnlVector.h>
#include <core/vectors/tnlMultiVector.h>
#include <mesh/tnlGrid.h>
#include <functions/tnlMeshFunction.h>
using namespace std;
bool getOutputFileName( const tnlString& inputFileName,
const tnlString& outputFormat,
tnlString& outputFileName )
{
outputFileName = inputFileName;
RemoveFileExtension( outputFileName );
if( outputFormat == "gnuplot" )
{
outputFileName += ".gplt";
return true;
}
else
{
cerr << "Unknown file format " << outputFormat << ".";
return false;
}
}
template< typename MeshFunction >
bool writeMeshFunctiony( const Mesh& mesh,
const tnlString& inputFileName,
const tnlParameterContainer& parameters )
bool writeMeshFunction( const typename MeshFunction::MeshType& mesh,
const tnlString& inputFileName,
const tnlParameterContainer& parameters )
{
MeshFunction function( mesh );
if( ! funtion.load( inputFileName ) )
if( ! function.load( inputFileName ) )
{
std::cerr << "Unable to load mesh function from a file " << inputFileName << "." << std::endl;
return false;
}
}
}
int verbose = parameters. getParameter< int >( "verbose");
tnlString outputFormat = parameters. getParameter< tnlString >( "output-format" );
tnlString outputFileName;
if( ! getOutputFileName( inputFileName,
outputFormat,
outputFileName ) )
return false;
if( verbose )
cout << " writing to " << outputFileName << " ... " << flush;
return function.write( outputFileName, outputFormat );
}
template< typename Mesh,
int EntityDimensions,
typename Real >
bool setMeshFunctionyRealType( const Mesh& mesh,
const tnlString& inputFileName,
const tnlParameterContainer& parameters )
bool setMeshFunctionRealType( const Mesh& mesh,
const tnlString& inputFileName,
const tnlParameterContainer& parameters )
{
return writeMeshFunction< tnlMeshFunction< Mesh, EntityDimensions, Real > >( mesh, inputFileName, parameters );
}
......@@ -76,7 +106,7 @@ bool setMeshFunction( const Mesh& mesh,
const tnlList< tnlString >& parsedObjectType,
const tnlParameterContainer& parameters )
{
if( parsedObjectType[ 1 ] != mesh.getType() )
if( parsedObjectType[ 1 ] != mesh.getSerializationType() )
{
cerr << "Incompatible mesh type for the mesh function " << inputFileName << "." << endl;
return false;
......@@ -100,24 +130,6 @@ bool setMeshFunction( const Mesh& mesh,
}
bool getOutputFileName( const tnlString& inputFileName,
const tnlString& outputFormat,
tnlString& outputFileName )
{
outputFileName = inputFileName;
RemoveFileExtension( outputFileName );
if( outputFormat == "gnuplot" )
{
outputFileName += ".gplt";
return true;
}
else
{
cerr << "Unknown file format " << outputFormat << ".";
return false;
}
}
template< typename Mesh, typename Element, typename Real, typename Index, int Dimensions >
bool convertObject( const Mesh& mesh,
const tnlString& inputFileName,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment