PTEMS  0.1.0-dev+git.81fd0e4
PolyTopic Element Method Solver
ptems::MatlabMATFileWriter< DIM > Class Template Reference

File writer for writing output data to MATLAB .mat files. More...

#include <ptems/io/matlabmatfilewriter.hpp>

Inheritance diagram for ptems::MatlabMATFileWriter< DIM >:
Collaboration diagram for ptems::MatlabMATFileWriter< DIM >:

Public Types

template<typename T >
using ContinuousFunction = std::function< T(const Vector< DIM > &)>
 Type used for an argument denoting a continuous function. More...
 
template<typename T >
using PiecewiseFunction = std::function< T(std::size_t, const Vector< DIM > &)>
 Type used for an argument denoting a piecewise function on a mesh. More...
 
template<typename T >
using PiecewiseConstantFunction = std::function< T(std::size_t)>
 Type used for an argument denoting a piecewise constant function on a mesh. More...
 

Public Member Functions

 MatlabMATFileWriter (std::ostream &file, const std::shared_ptr< FEMesh< DIM >> &mesh, bool discontinuous)
 Create object for writing data to a MATLAB .mat file. More...
 
virtual bool HasError () const override
 Checks if the writer is invalid (as error) More...
 
virtual void OutputFunction (const std::string &name, const ContinuousFunction< int64_t > &func) override
 Write out a continuous function of integer values. More...
 
virtual void OutputFunction (const std::string &name, const ContinuousFunction< double > &func) override
 Write out a continuous function of double values. More...
 
virtual void OutputFunction (const std::string &name, const ContinuousFunction< std::complex< double >> func) override
 Write out a continuous function of complex values. More...
 
virtual void OutputPiecewiseFunction (const std::string &name, const PiecewiseFunction< int64_t > &func, bool continuous) override
 Write out a piecewise function of integer values which is defined over a mesh (continuous on each element) More...
 
virtual void OutputPiecewiseFunction (const std::string &name, const PiecewiseFunction< double > &func, bool continuous) override
 Write out a piecewise function of double values which is defined over a mesh (continuous on each element) More...
 
virtual void OutputPiecewiseFunction (const std::string &name, const PiecewiseFunction< std::complex< double >> &func, bool continuous) override
 Write out a piecewise function of complex values which is defined over a mesh (continuous on each element) More...
 
virtual void OutputPiecewiseConstantFunction (const std::string &name, const PiecewiseConstantFunction< int64_t > &func) override
 Write out a piecewise constant function of integer values which is defined over a mesh (constant for each each element) More...
 
virtual void OutputPiecewiseConstantFunction (const std::string &name, const PiecewiseConstantFunction< double > &func) override
 Write out a piecewise constant function of double values which is defined over a mesh (constant for each each element) More...
 
virtual void OutputPiecewiseConstantFunction (const std::string &name, const PiecewiseConstantFunction< std::complex< double >> &func) override
 Write out a piecewise constant function of complex values which is defined over a mesh (constant for each each element) More...
 
virtual operator bool () const
 Checks if the writer is still valid. More...
 
template<typename T >
void OutputFunction (const std::string &name, const T &func)
 Write out a continuous function. More...
 
template<typename T >
void OutputPiecewiseFunction (const std::string &name, const T &func, bool continuous)
 Write out a continuous function. More...
 
template<typename T >
void OutputPiecewiseConstantFunction (const std::string &name, const T &func)
 Write out a continuous function. More...
 

Detailed Description

template<std::size_t DIM>
class ptems::MatlabMATFileWriter< DIM >

File writer for writing output data to MATLAB .mat files.

https://www.mathworks.com/help/pdf_doc/matlab/matfile_format.pdf

Todo:
Hack code - still work in progress
Todo:
We write this manually for now - but maybe we should use the MAT-file interface available in MATLAB
Todo:
Document MAT file format!

Member Typedef Documentation

◆ ContinuousFunction

template<std::size_t DIM>
template<typename T >
using ptems::DataFileWriter< DIM >::ContinuousFunction = std::function<T(const Vector<DIM>&)>
inherited

Type used for an argument denoting a continuous function.

Template Parameters
TThe return type of the function

◆ PiecewiseConstantFunction

template<std::size_t DIM>
template<typename T >
using ptems::DataFileWriter< DIM >::PiecewiseConstantFunction = std::function<T(std::size_t)>
inherited

Type used for an argument denoting a piecewise constant function on a mesh.

Template Parameters
TThe return type of the function

◆ PiecewiseFunction

template<std::size_t DIM>
template<typename T >
using ptems::DataFileWriter< DIM >::PiecewiseFunction = std::function<T(std::size_t, const Vector<DIM>&)>
inherited

Type used for an argument denoting a piecewise function on a mesh.

Template Parameters
TThe return type of the function

Constructor & Destructor Documentation

◆ MatlabMATFileWriter()

template<std::size_t DIM>
ptems::MatlabMATFileWriter< DIM >::MatlabMATFileWriter ( std::ostream file,
const std::shared_ptr< FEMesh< DIM >> &  mesh,
bool  discontinuous 
)
inline

Create object for writing data to a MATLAB .mat file.

Parameters
fileThe stream to write to, must be opened in binary mode
meshThe mesh to write to the file
discontinuousSpecifies whether data can be written as discontinuous data

Member Function Documentation

◆ HasError()

template<std::size_t DIM>
virtual bool ptems::MatlabMATFileWriter< DIM >::HasError ( ) const
inlineoverridevirtual

Checks if the writer is invalid (as error)

Returns
true if error; false otherwise

Implements ptems::DataFileWriter< DIM >.

◆ operator bool()

template<std::size_t DIM>
virtual ptems::DataFileWriter< DIM >::operator bool ( ) const
inlineexplicitvirtualinherited

Checks if the writer is still valid.

Returns
true if valid; false otherwise

◆ OutputFunction() [1/4]

template<std::size_t DIM>
virtual void ptems::MatlabMATFileWriter< DIM >::OutputFunction ( const std::string name,
const ContinuousFunction< double > &  func 
)
inlineoverridevirtual

Write out a continuous function of double values.

Parameters
nameName of the function
funcFunctor which takes a point and returns the function value at that point

Implements ptems::DataFileWriter< DIM >.

◆ OutputFunction() [2/4]

template<std::size_t DIM>
virtual void ptems::MatlabMATFileWriter< DIM >::OutputFunction ( const std::string name,
const ContinuousFunction< int64_t > &  func 
)
inlineoverridevirtual

Write out a continuous function of integer values.

Parameters
nameName of the function
funcFunctor which takes a point and returns the function value at that point

Implements ptems::DataFileWriter< DIM >.

◆ OutputFunction() [3/4]

template<std::size_t DIM>
virtual void ptems::MatlabMATFileWriter< DIM >::OutputFunction ( const std::string name,
const ContinuousFunction< std::complex< double >>  func 
)
inlineoverridevirtual

Write out a continuous function of complex values.

Parameters
nameName of the function
funcFunctor which takes a point and returns the function value at that point

Implements ptems::DataFileWriter< DIM >.

◆ OutputFunction() [4/4]

template<std::size_t DIM>
template<typename T >
void ptems::DataFileWriter< DIM >::OutputFunction ( const std::string name,
const T &  func 
)
inlineinherited

Write out a continuous function.

Template Parameters
TType of the functor
Parameters
nameName of the function
funcFunctor which takes a point and returns the function value at that point

◆ OutputPiecewiseConstantFunction() [1/4]

template<std::size_t DIM>
virtual void ptems::MatlabMATFileWriter< DIM >::OutputPiecewiseConstantFunction ( const std::string name,
const PiecewiseConstantFunction< double > &  func 
)
inlineoverridevirtual

Write out a piecewise constant function of double values which is defined over a mesh (constant for each each element)

Parameters
nameName of the function
funcFunctor which takes an element index and returns the constant function value for that element

Implements ptems::DataFileWriter< DIM >.

◆ OutputPiecewiseConstantFunction() [2/4]

template<std::size_t DIM>
virtual void ptems::MatlabMATFileWriter< DIM >::OutputPiecewiseConstantFunction ( const std::string name,
const PiecewiseConstantFunction< int64_t > &  func 
)
inlineoverridevirtual

Write out a piecewise constant function of integer values which is defined over a mesh (constant for each each element)

Parameters
nameName of the function
funcFunctor which takes an element index and returns the constant function value for that element

Implements ptems::DataFileWriter< DIM >.

◆ OutputPiecewiseConstantFunction() [3/4]

template<std::size_t DIM>
virtual void ptems::MatlabMATFileWriter< DIM >::OutputPiecewiseConstantFunction ( const std::string name,
const PiecewiseConstantFunction< std::complex< double >> &  func 
)
inlineoverridevirtual

Write out a piecewise constant function of complex values which is defined over a mesh (constant for each each element)

Parameters
nameName of the function
funcFunctor which takes an element index and returns the constant function value for that element

Implements ptems::DataFileWriter< DIM >.

◆ OutputPiecewiseConstantFunction() [4/4]

template<std::size_t DIM>
template<typename T >
void ptems::DataFileWriter< DIM >::OutputPiecewiseConstantFunction ( const std::string name,
const T &  func 
)
inlineinherited

Write out a continuous function.

Template Parameters
TType of the functor
Parameters
nameName of the function
funcFunctor which takes a point and returns the function value at that point

◆ OutputPiecewiseFunction() [1/4]

template<std::size_t DIM>
virtual void ptems::MatlabMATFileWriter< DIM >::OutputPiecewiseFunction ( const std::string name,
const PiecewiseFunction< double > &  func,
bool  continuous 
)
inlineoverridevirtual

Write out a piecewise function of double values which is defined over a mesh (continuous on each element)

Parameters
nameName of the function
funcFunctor which takes an element index and a point in the element's local coordinate system and returns the function value at that point
continuousSpecifies if the function is continuous

Implements ptems::DataFileWriter< DIM >.

◆ OutputPiecewiseFunction() [2/4]

template<std::size_t DIM>
virtual void ptems::MatlabMATFileWriter< DIM >::OutputPiecewiseFunction ( const std::string name,
const PiecewiseFunction< int64_t > &  func,
bool  continuous 
)
inlineoverridevirtual

Write out a piecewise function of integer values which is defined over a mesh (continuous on each element)

Parameters
nameName of the function
funcFunctor which takes an element index and a point in the element's local coordinate system and returns the function value at that point
continuousSpecifies if the function is continuous

Implements ptems::DataFileWriter< DIM >.

◆ OutputPiecewiseFunction() [3/4]

template<std::size_t DIM>
virtual void ptems::MatlabMATFileWriter< DIM >::OutputPiecewiseFunction ( const std::string name,
const PiecewiseFunction< std::complex< double >> &  func,
bool  continuous 
)
inlineoverridevirtual

Write out a piecewise function of complex values which is defined over a mesh (continuous on each element)

Parameters
nameName of the function
funcFunctor which takes an element index and a point in the element's local coordinate system and returns the function value at that point
continuousSpecifies if the function is continuous

Implements ptems::DataFileWriter< DIM >.

◆ OutputPiecewiseFunction() [4/4]

template<std::size_t DIM>
template<typename T >
void ptems::DataFileWriter< DIM >::OutputPiecewiseFunction ( const std::string name,
const T &  func,
bool  continuous 
)
inlineinherited

Write out a continuous function.

Template Parameters
TType of the functor
Parameters
nameName of the function
funcFunctor which takes a point and returns the function value at that point
continuousSpecifies if the function is continuous

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