QuOc

 

Public Member Functions | Private Attributes

aol::PlotDataFileHandler< RealType > Class Template Reference

#include <gnuplotter.h>

List of all members.

Public Member Functions

 PlotDataFileHandler ()
 ~PlotDataFileHandler ()
void generateColoredVectorfieldData (const qc::Array< RealType > &VectorfieldX, const qc::Array< RealType > &VectorfieldY, const std::vector< const qc::BitArray< qc::QC_2D > * > &MaskVector, const RealType Spacing=0.1)
void generateColoredVectorfieldData (const aol::MultiVector< RealType > &Vectorfield, const int SizeX, const int SizeY, const std::vector< const qc::BitArray< qc::QC_2D > * > &MaskVector, const RealType Spacing=0.1)
void generateColoredVectorfieldData (const aol::MultiVector< RealType > &Vectorfield, const qc::GridStructure &Grid, const std::vector< const qc::BitArray< qc::QC_2D > * > &MaskVector, const RealType Spacing=0.1)
template<typename ConfiguratorType >
void generateIsolineData (const aol::Vector< RealType > &levelsetFunction, const typename ConfiguratorType::InitType &Grid, const ConfiguratorType &, const double Isovalue=0.)
 Unfortunately the ConfiguratorType dummy argument is necessary as workaround for a GCC bug.
template<typename ConfiguratorType >
void generateIsolineData (const aol::MultiVector< RealType > &levelsetFunctions, const typename ConfiguratorType::InitType &Grid, const ConfiguratorType &ConfDummy, const double Isovalue=0.)
 Unfortunately the ConfiguratorType dummy argument is necessary as workaround for a GCC bug.
void generateFunctionPlot (const aol::Vector< RealType > &FunctionPositions, const aol::Vector< RealType > &FunctionValues)
void generateFunctionPlot (const aol::Vector< RealType > &FunctionValues, const RealType A=0, const RealType B=1)
template<typename FunctionType >
void generateFunctionAndDerivativePlot (const FunctionType &Function, const RealType A, const RealType B, const int NumberOfPoints)
const std::vector< std::string > & getDataFileNames () const
const std::vector< PlotStyle > & getDataFileStyles () const

Private Attributes

std::vector< std::string > _datafileFileNameVector
std::vector< PlotStyle_datafilePlotStyleVector

Detailed Description

template<typename RealType>
class aol::PlotDataFileHandler< RealType >

Class to automatically generate gnuplot comaptible data files. Can be used in conjunction with aol::Plotter.

Deletes all files created upon destruction.

Author:
Berkels

Definition at line 41 of file gnuplotter.h.


Constructor & Destructor Documentation

template<typename RealType>
aol::PlotDataFileHandler< RealType >::PlotDataFileHandler (  )  [inline]

Definition at line 45 of file gnuplotter.h.

{}

template<typename RealType>
aol::PlotDataFileHandler< RealType >::~PlotDataFileHandler (  )  [inline]

Definition at line 46 of file gnuplotter.h.

References aol::PlotDataFileHandler< RealType >::_datafileFileNameVector.

                         {
    for ( unsigned int i = 0; i < _datafileFileNameVector.size(); i++ )
      remove ( _datafileFileNameVector[i].c_str() );
  }


Member Function Documentation

template<typename RealType>
void aol::PlotDataFileHandler< RealType >::generateColoredVectorfieldData ( const qc::Array< RealType > &  VectorfieldX,
const qc::Array< RealType > &  VectorfieldY,
const std::vector< const qc::BitArray< qc::QC_2D > * > &  MaskVector,
const RealType  Spacing = 0.1 
) [inline]

Definition at line 50 of file gnuplotter.h.

References aol::PlotDataFileHandler< RealType >::_datafileFileNameVector, aol::PlotDataFileHandler< RealType >::_datafilePlotStyleVector, aol::generateTemporaryFile(), and aol::GNUPLOT_VECTOR.

Referenced by aol::PlotDataFileHandler< RealType >::generateColoredVectorfieldData(), and qc::QuocTimestepSaver< ConfiguratorType >::plotVectorField().

                                                                      {
    char vectorFieldTempFileName[1024];
    for ( unsigned int i = 0; i < MaskVector.size(); i++ ) {
      // The segment is defined, but empty. Don't try to draw it or gnuplot will complain.
      if ( (MaskVector[i] != NULL) && MaskVector[i]->numTrue() == 0 )
        continue;

      ofstream vectorFieldTempOutFile;
      sprintf ( vectorFieldTempFileName, "vectorField.datXXXXXX" );
      generateTemporaryFile ( vectorFieldTempFileName, vectorFieldTempOutFile );
      qc::WriteVectorFieldAsGnuplotFile<RealType>( vectorFieldTempOutFile, VectorfieldX, VectorfieldY, Spacing, MaskVector[i] );
      vectorFieldTempOutFile.close();
      std::string vectorFieldTempFileNameString = vectorFieldTempFileName;
      _datafileFileNameVector.push_back(vectorFieldTempFileName);
      _datafilePlotStyleVector.push_back(GNUPLOT_VECTOR);
    }
  }

template<typename RealType>
void aol::PlotDataFileHandler< RealType >::generateColoredVectorfieldData ( const aol::MultiVector< RealType > &  Vectorfield,
const int  SizeX,
const int  SizeY,
const std::vector< const qc::BitArray< qc::QC_2D > * > &  MaskVector,
const RealType  Spacing = 0.1 
) [inline]

Definition at line 70 of file gnuplotter.h.

References aol::PlotDataFileHandler< RealType >::generateColoredVectorfieldData().

                                                                      {
    qc::Array<RealType> vectorfieldX ( Vectorfield[0], SizeX, SizeY );
    qc::Array<RealType> vectorfieldY ( Vectorfield[1], SizeX, SizeY );
    generateColoredVectorfieldData ( vectorfieldX, vectorfieldY, MaskVector, Spacing );
  }

template<typename RealType>
void aol::PlotDataFileHandler< RealType >::generateColoredVectorfieldData ( const aol::MultiVector< RealType > &  Vectorfield,
const qc::GridStructure Grid,
const std::vector< const qc::BitArray< qc::QC_2D > * > &  MaskVector,
const RealType  Spacing = 0.1 
) [inline]
template<typename RealType>
template<typename FunctionType >
void aol::PlotDataFileHandler< RealType >::generateFunctionAndDerivativePlot ( const FunctionType &  Function,
const RealType  A,
const RealType  B,
const int  NumberOfPoints 
) [inline]

Plots Function and its derivative in the interval [A,B], discretized with NumberOfPoints points. Function needs to have the member functions evaluate and evaluateDerivative. For example useful to plot aol::ZeroOneIntervalPenaltyFunction.

Definition at line 145 of file gnuplotter.h.

References aol::PlotDataFileHandler< RealType >::generateFunctionPlot(), and QUOC_ASSERT.

                                                                      {
    QUOC_ASSERT ( NumberOfPoints > 0 );
    aol::Vector<RealType> functionValues ( NumberOfPoints );
    aol::Vector<RealType> derivativeValues ( NumberOfPoints );
    aol::Vector<RealType> positions ( NumberOfPoints );
    for ( int i = 0; i < NumberOfPoints; ++i ) {
      const RealType position = A + static_cast<RealType>(i)/(NumberOfPoints-1) * ( B - A );
      functionValues[i] = Function.evaluate ( position );
      derivativeValues[i] = Function.evaluateDerivative ( position );
      positions[i] = position;
    }
    generateFunctionPlot(positions, functionValues);
    generateFunctionPlot(positions, derivativeValues);
  }

template<typename RealType>
void aol::PlotDataFileHandler< RealType >::generateFunctionPlot ( const aol::Vector< RealType > &  FunctionValues,
const RealType  A = 0,
const RealType  B = 1 
) [inline]

Definition at line 130 of file gnuplotter.h.

References aol::PlotDataFileHandler< RealType >::generateFunctionPlot(), and aol::Vector< _DataType >::size().

                                                                                                                      {
    const int numberOfPoints = FunctionValues.size();
    aol::Vector<RealType> positions ( numberOfPoints );
    for ( int i = 0; i < numberOfPoints; ++i ) {
      positions[i] = A + static_cast<RealType>(i)/(numberOfPoints-1) * ( B - A );
    }
    generateFunctionPlot(positions, FunctionValues);
  }

template<typename RealType>
void aol::PlotDataFileHandler< RealType >::generateFunctionPlot ( const aol::Vector< RealType > &  FunctionPositions,
const aol::Vector< RealType > &  FunctionValues 
) [inline]

Definition at line 116 of file gnuplotter.h.

References aol::PlotDataFileHandler< RealType >::_datafileFileNameVector, aol::PlotDataFileHandler< RealType >::_datafilePlotStyleVector, aol::generateTemporaryFile(), aol::GNUPLOT_LINE, QUOC_ASSERT, and aol::Vector< _DataType >::size().

Referenced by aol::PlotDataFileHandler< RealType >::generateFunctionAndDerivativePlot(), aol::PlotDataFileHandler< RealType >::generateFunctionPlot(), and qc::plotLineOf2DArray().

                                                                          {
    QUOC_ASSERT ( FunctionPositions.size() == FunctionValues.size() );
    char tempFileName[1024];
    sprintf ( tempFileName, "function.datXXXXXX" );
    ofstream tempOutFile;
    generateTemporaryFile ( tempFileName, tempOutFile );
    for ( int i = 0; i < FunctionPositions.size(); ++i )
      tempOutFile << FunctionPositions[i] << " " << FunctionValues[i] << endl;
    tempOutFile.close();
    std::string tempFileNameString = tempFileName;
    _datafileFileNameVector.push_back(tempFileNameString);
    _datafilePlotStyleVector.push_back(GNUPLOT_LINE);
  }

template<typename RealType>
template<typename ConfiguratorType >
void aol::PlotDataFileHandler< RealType >::generateIsolineData ( const aol::MultiVector< RealType > &  levelsetFunctions,
const typename ConfiguratorType::InitType &  Grid,
const ConfiguratorType &  ConfDummy,
const double  Isovalue = 0. 
) [inline]

Unfortunately the ConfiguratorType dummy argument is necessary as workaround for a GCC bug.

Definition at line 109 of file gnuplotter.h.

References aol::PlotDataFileHandler< RealType >::generateIsolineData(), and aol::MultiVector< _DataType >::numComponents().

                                                          {
    for ( int i = 0; i < levelsetFunctions.numComponents(); i++ )
      generateIsolineData ( levelsetFunctions[i], Grid, ConfDummy, Isovalue );
  }

template<typename RealType>
template<typename ConfiguratorType >
void aol::PlotDataFileHandler< RealType >::generateIsolineData ( const aol::Vector< RealType > &  levelsetFunction,
const typename ConfiguratorType::InitType &  Grid,
const ConfiguratorType &  ,
const double  Isovalue = 0. 
) [inline]

Unfortunately the ConfiguratorType dummy argument is necessary as workaround for a GCC bug.

Definition at line 87 of file gnuplotter.h.

References aol::PlotDataFileHandler< RealType >::_datafileFileNameVector, aol::PlotDataFileHandler< RealType >::_datafilePlotStyleVector, qc::LevelSetDrawer< ConfiguratorType >::drawToGnuplot(), aol::generateTemporaryFile(), aol::Vector< _DataType >::getMaxValue(), aol::Vector< _DataType >::getMinValue(), and aol::GNUPLOT_LINE.

Referenced by aol::PlotDataFileHandler< RealType >::generateIsolineData(), qc::QuocTimestepSaver< ConfiguratorType >::plotVectorField(), and qc::QuocTimestepSaver< ConfiguratorType >::saveIsolineWithGnuplot().

                                                          {
    // The isoline is empty. Don't try to draw it or gnuplot will complain.
    if ( (levelsetFunction.getMaxValue() <= Isovalue) || (levelsetFunction.getMinValue() >= Isovalue) )
      return;

    qc::LevelSetDrawer<ConfiguratorType> drawer ( Grid );
    qc::ScalarArray<RealType, qc::QC_2D> levelsetFunctionArray ( levelsetFunction, Grid );
    char tempFileName[1024];
    sprintf ( tempFileName, "isoline.datXXXXXX" );
    ofstream tempOutFile;
    generateTemporaryFile ( tempFileName, tempOutFile );
    drawer.drawToGnuplot ( levelsetFunctionArray, tempOutFile, Isovalue, true, true );
    tempOutFile.close();
    std::string tempFileNameString = tempFileName;
    _datafileFileNameVector.push_back(tempFileNameString);
    _datafilePlotStyleVector.push_back(GNUPLOT_LINE);
  }

template<typename RealType>
const std::vector<std::string>& aol::PlotDataFileHandler< RealType >::getDataFileNames (  )  const [inline]
template<typename RealType>
const std::vector<PlotStyle>& aol::PlotDataFileHandler< RealType >::getDataFileStyles (  )  const [inline]

Member Data Documentation

template<typename RealType>
std::vector<std::string> aol::PlotDataFileHandler< RealType >::_datafileFileNameVector [private]
template<typename RealType>
std::vector<PlotStyle> aol::PlotDataFileHandler< RealType >::_datafilePlotStyleVector [private]

The documentation for this class was generated from the following file:

Generated on Fri Sep 9 2011 21:09:04 for QuocMesh by doxygen 1.7.1