Commit dc1f0eab authored by Tomáš Oberhuber's avatar Tomáš Oberhuber
Browse files

Implementing mesh function gnuplot writer.

parent 7704809f
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -19,7 +19,6 @@ SET( headers tnlConstantFunction.h
             tnlMeshFunctionVTKWriter_impl.h
             tnlMeshFunctionNormGetter.h
             tnlOperatorFunction.h
             tnlOperatorFunction_impl.h
             tnlSinBumpsFunction.h
             tnlSinBumpsFunction_impl.h
             tnlSinWaveFunction.h
+22 −14
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@ tnlMeshFunctionGnuplotWriter< MeshFunction >::
write( const MeshFunction& function,
       ostream& str )
{
   std::cerr << "Gnuplot writer for mesh functions defined on mesh type " << MeshFunction::Mesh::getType() << " is not (yet) implmeneted." << std::endl;
   std::cerr << "Gnuplot writer for mesh functions defined on mesh type " << MeshFunction::MeshType::getType() << " is not (yet) implemented." << std::endl;
   return false;   
}

@@ -46,9 +46,10 @@ write( const MeshFunctionType& function,
        entity.getCoordinates().x() < mesh.getDimensions().x();
        entity.getCoordinates().x() ++ )
   {
      entity.refresh();
      typename MeshType::VertexType v = entity.getCenter();
      str << v << " " 
          << function.getElement( entity.getIndex() ) << std::endl;
          << function.getData().getElement( entity.getIndex() ) << std::endl;
   }
}

@@ -70,9 +71,10 @@ write( const MeshFunctionType& function,
        entity.getCoordinates().x() <= mesh.getDimensions().x();
        entity.getCoordinates().x() ++ )
   {
      entity.refresh();
      typename MeshType::VertexType v = entity.getCenter();
      str << v << " " 
          << function.getElement( entity.getIndex() ) << std::endl;      
          << function.getData().getElement( entity.getIndex() ) << std::endl;      
   }
}

@@ -99,9 +101,10 @@ write( const MeshFunctionType& function,
           entity.getCoordinates().x() < mesh.getDimensions().x();
           entity.getCoordinates().x() ++ )
      {
         entity.refresh();
         typename MeshType::VertexType v = entity.getCenter();
         str << v.x() << " " << v.y() << " "
             << function.getElement( entity.getIndex() ) << std::endl;      
             << function.getData().getElement( entity.getIndex() ) << std::endl;      
      }
      str << std::endl;
   }
@@ -121,7 +124,7 @@ write( const MeshFunctionType& function,
{
   const MeshType& mesh = function.getMesh();
   typedef typename MeshType::Face EntityType;
   typedef typename EntityType::EntityOrientation EntityOrientation;
   typedef typename EntityType::EntityOrientationType EntityOrientation;
   EntityType entity( mesh );
   
   entity.setOrientation( EntityOrientation( 1.0, 0.0 ) );
@@ -133,25 +136,29 @@ write( const MeshFunctionType& function,
           entity.getCoordinates().x() <= mesh.getDimensions().x();
           entity.getCoordinates().x() ++ )
      {
         entity.refresh();
         typename MeshType::VertexType v = entity.getCenter();
         str << v.x() << " " << v.y() << " "
             << function.getElement( entity.getIndex() ) << std::endl;      
             << function.getData().getElement( entity.getIndex() ) << std::endl;      
      }
      str << std::endl;
   }
   
   entity.setOrientation( EntityOrientation( 0.0, 1.0 ) );
   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() ++ )

   {
            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() << " "
             << function.getElement( entity.getIndex() ) << std::endl;      
             << function.getData().getElement( entity.getIndex() ) << std::endl;      
      }
      str << std::endl;
   }   
@@ -180,9 +187,10 @@ write( const MeshFunctionType& function,
           entity.getCoordinates().x() <= mesh.getDimensions().x();
           entity.getCoordinates().x() ++ )
      {
         entity.refresh();
         typename MeshType::VertexType v = entity.getCenter();
         str << v.x() << " " << v.y() << " "
             << function.getElement( entity.getIndex() ) << std::endl;      
             << function.getData().getElement( entity.getIndex() ) << std::endl;      
      }
      str << std::endl;
   }
+3 −3
Original line number Diff line number Diff line
@@ -23,10 +23,10 @@ class tnlMeshFunctionVTKWriter
{
   public:
      
      bool write( const MeshFunction& function,
      static bool write( const MeshFunction& function,
                         ostream& str )
      {
         std::cerr << "VTK writer for mesh functions defined on mesh type " << MeshFunction::Mesh::getType() << " is not (yet) implmeneted." << std::endl;
         std::cerr << "VTK writer for mesh functions defined on mesh type " << MeshFunction::MeshType::getType() << " is not (yet) implmeneted." << std::endl;
         return false;
      }
};
+3 −2
Original line number Diff line number Diff line
@@ -362,8 +362,9 @@ tnlMeshFunction< Mesh, MeshEntityDimensions, Real >::
write( const tnlString& fileName,
       const tnlString& format ) const
{
   fstream file;
   if( file.open( fileName.getString(), ios::out ) )
   std::fstream file;
   file.open( fileName.getString(), std::ios::out );
   if( ! file )
   {
      std::cerr << "Unbable to open a file " << fileName << "." << std::endl;
      return false;
+14 −6
Original line number Diff line number Diff line
@@ -59,30 +59,38 @@ getError( const ExactOperator& exactOperator,
   BoundaryOperatorFunction boundaryOperatorFunction( boundaryConditions, u );
   
   tnlString meshSizeString( mesh.getDimensions().x() );
   tnlString dimensionsString;
   if( MeshType::getDimensionsCount() == 1 )
      dimensionsString = "1D-";
   if( MeshType::getDimensionsCount() == 2 )
      dimensionsString = "2D-";
   if( MeshType::getDimensionsCount() == 3 )
      dimensionsString = "3D-";
   
   if( writeFunctions )
      mesh.save( "mesh-" + meshSizeString + ".tnl" );
      mesh.save( "mesh-" + dimensionsString + meshSizeString + ".tnl" );
      
   //cerr << "Evaluating exact u... " << endl;
   exactU = exactOperatorFunction;
   if( writeFunctions )
      exactU.save( "exact-result-" + meshSizeString + ".tnl" );
      exactU.save( "exact-result-" + dimensionsString + meshSizeString + ".tnl" );
   
   //cerr << "Projecting test function ..." << endl;
   v = function;
   if( writeFunctions )
      v.save( "test-function-" + meshSizeString + ".tnl" ) ;
      v.save( "test-function-" + dimensionsString + meshSizeString + ".tnl" ) ;
   
   //cerr << "Evaluating approximate u ... " << endl;
   u = operatorFunction;
   tnlBoundaryConditionsSetter< MeshFunction, DirichletBoundaryConditions >::template apply< MeshEntity >( boundaryConditions, 0.0, u );
   if( writeFunctions )
      u.save( "approximate-result-" + meshSizeString + ".tnl" ) ;
      u.save( "approximate-result-" + dimensionsString + meshSizeString + ".tnl" ) ;

   //cerr << "Evaluate difference ... " << endl;
   u -= exactU;   
   tnlBoundaryConditionsSetter< MeshFunction, DirichletBoundaryConditions >::template apply< MeshEntity >( boundaryConditions, 0.0, u );
   if( writeFunctions )
      u.save( "difference-" + meshSizeString + ".tnl" ) ;
      u.save( "difference-" + dimensionsString + meshSizeString + ".tnl" ) ;
   l1Err = u.getLpNorm( 1.0 );
   l2Err = u.getLpNorm( 2.0 );   
   maxErr = u.getMaxNorm();
Loading