Draws a picture of data in Matlab format and stores the result in a single file. More...

#include <matlab.hh>

Inheritance diagram for graphics::MatlabGraphics:
graphics::OutputBase concepts::OutputOperator

Public Member Functions

template<class F >
 MatlabGraphics (concepts::Mesh &msh, const std::string filename, const concepts::PiecewiseFormulaBase< F > &frm, const uint dim=2, const uint points=noPoints)
 Constructor for output of a scalar formula. More...
 
 MatlabGraphics (concepts::Mesh &msh, const std::string filename, const uint dim=2, const uint points=noPoints)
 Constructor for output of mesh only. More...
 
template<class F , class G >
 MatlabGraphics (const concepts::Space< G > &spc, const std::string filename, const concepts::ElementFormula< F, G > &frm, const uint dim=2)
 Constructor for output of a element formula. More...
 
template<class F , class G >
 MatlabGraphics (const concepts::Space< G > &spc, const std::string filename, const concepts::Vector< F > &sol, const uint dim=2, const concepts::ElementFunction< F, G > *fun=0)
 Constructor for output of solutions and functions of it. More...
 
template<class G >
 MatlabGraphics (const concepts::Space< G > &spc, const std::string filename, const uint dim=2)
 Constructor for output of mesh only. More...
 
template<class F , class G >
void operator() (concepts::Mesh &msh, const concepts::Formula< F > &frm, const uint points=5)
 Application operator for output of a scalar formula. More...
 
template<class F , class G >
void operator() (const concepts::Space< G > &spc, const concepts::Formula< F > &frm)
 Application operator for output of a scalar formula. More...
 
template<class F , class G >
void operator() (const concepts::Space< G > &spc, const concepts::Vector< F > &sol, const concepts::ElementFunction< F, G > *fun=0)
 Application operator for output of solutions and functions of it. More...
 
virtual ~MatlabGraphics ()
 

Static Public Attributes

static uint noPoints
 

Protected Member Functions

virtual std::ostream & info (std::ostream &os) const
 Returns information in an output stream. More...
 

Protected Attributes

std::unique_ptr< std::ofstream > ofs_
 Stream for output file. More...
 

Private Member Functions

void closeStreams_ (const uint &n)
 Closes the streams. More...
 
void createStreams_ (bool data)
 Create the streams. More...
 
template<class F >
void write_ (concepts::GlobalPostprocess< F > &postProcess, BaseOutputCell< F > &matlab, bool data=false)
 Creates standard streams, writes to streams, writes to file and clear and delete all streams. More...
 

Private Attributes

uint cnt_
 Number of vectors written to the files. More...
 
uint dim_
 Spatial dimension of the space. More...
 
std::map< std::string, std::ostream * > s_ptr_
 Pointer to the streams, i.e. *(s_ptr_["vtxmsh"]) for FE mesh. More...
 

Detailed Description

Draws a picture of data in Matlab format and stores the result in a single file.

The data is stored in a Matlab M-file by appending '.m'. The data can be read into Matlab by giving the file name as commands (and ommiting the ending '.m').

In general there is the FE-mesh (cells) and the output mesh, which in hp-FEM is given by the quadrature points. The data points are given in the vertices of the output mesh (x, y).

The FE-mesh of triangles or quadrilaterials is given by edgemsh, while vtxmsh consists of the vertices. For a FE-mesh with cells with only straight edges its more efficient to use vtxmsh instead of edgemesh. In each column there are the numbers of the vertices of one cell given, and can be plotted by

plot(x(edgemsh),y(edgemsh),'k');

The data values are in the variable u. For vector values spaces or repeated set of values the i.th component is U{i} (as well as in u(i,:)). In the following examples of scalar data one can replace u(msh) with U{i}(msh) for plotting one component of vector valued data.

Scalar data is plotted in the view from above with

patch(x(msh),y(msh),u(msh))

whereby in msh the output mesh is given.

Its possible to emphasize the FE-mesh in this diagramme with

patch(x(msh),y(msh),u(msh));
hold on
plot(x(edgemsh),y(edgemsh),'k');

whereby in edgemsh represents the points in the output mesh lying on the FE mesh.

As the command contour is only applicable to tensor product meshes, there is in general no contour plot possible.

Scalar data is plotted in the side view with

fill3(x(msh),y(msh),u(msh),u(msh));

Its possible to emphasize the FE-mesh in this diagramme with

fill3(x(msh),y(msh),u(msh),u(msh));
hold on
plot3(x(edgemsh),y(edgemsh),u(edgemsh),'k','linewidth',2)

The data can be shown unicoloured in side view with

fill3(x(msh),y(msh),u(msh),ones(size(msh)));

For vector valued spaces, the variables of the data values are U{1},..,U{n}.

2D Vectorial data is shown with

quiver(x,y,U{1},U{2});

Its possible to emphasize the FE-mesh in this diagramme with

quiver(x,y,U{1},U{2});
hold on
plot(x(edgemsh),y(edgemsh),'k');
Author
Kersten Schmidt, 2005
Examples
inhomDirichletBCs.cc, inhomDirichletBCsLagrange.cc, inhomNeumannBCs.cc, and RobinBCs.cc.

Definition at line 114 of file matlab.hh.

Constructor & Destructor Documentation

◆ MatlabGraphics() [1/5]

template<class G >
graphics::MatlabGraphics::MatlabGraphics ( const concepts::Space< G > &  spc,
const std::string  filename,
const uint  dim = 2 
)

Constructor for output of mesh only.

Parameters
spcSpace which holds the mesh
filenameName base for the files to be written
dimSpatial dimension of the cells

Definition at line 220 of file matlab.hh.

◆ MatlabGraphics() [2/5]

graphics::MatlabGraphics::MatlabGraphics ( concepts::Mesh msh,
const std::string  filename,
const uint  dim = 2,
const uint  points = noPoints 
)

Constructor for output of mesh only.

Parameters
mshMesh
filenameName base for the files to be written
dimSpatial dimension of the cells

◆ MatlabGraphics() [3/5]

template<class F , class G >
graphics::MatlabGraphics::MatlabGraphics ( const concepts::Space< G > &  spc,
const std::string  filename,
const concepts::Vector< F > &  sol,
const uint  dim = 2,
const concepts::ElementFunction< F, G > *  fun = 0 
)

Constructor for output of solutions and functions of it.

Parameters
spcSpace on which the data should be plotted
filenameName base for the files to be written
solThe first solution set which should be plotted
dimSpatial dimension of the cells
funFunction of the FE function, e.g. itself.

Definition at line 234 of file matlab.hh.

◆ MatlabGraphics() [4/5]

template<class F , class G >
graphics::MatlabGraphics::MatlabGraphics ( const concepts::Space< G > &  spc,
const std::string  filename,
const concepts::ElementFormula< F, G > &  frm,
const uint  dim = 2 
)

Constructor for output of a element formula.

Parameters
spcSpace on which the data should be plotted
filenameName base for the files to be written
frmElement formula
dimSpatial dimension of the cells

Definition at line 251 of file matlab.hh.

◆ MatlabGraphics() [5/5]

template<class F >
graphics::MatlabGraphics::MatlabGraphics ( concepts::Mesh msh,
const std::string  filename,
const concepts::PiecewiseFormulaBase< F > &  frm,
const uint  dim = 2,
const uint  points = noPoints 
)

Constructor for output of a scalar formula.

Parameters
mshMesh
filenameName base for the files to be written
frmFormula
dimSpatial dimension of the cells
pointsNumber of points inside the element (in one direction)

Definition at line 267 of file matlab.hh.

◆ ~MatlabGraphics()

virtual graphics::MatlabGraphics::~MatlabGraphics ( )
inlinevirtual

Definition at line 166 of file matlab.hh.

Member Function Documentation

◆ closeStreams_()

void graphics::MatlabGraphics::closeStreams_ ( const uint &  n)
private

Closes the streams.

◆ createStreams_()

void graphics::MatlabGraphics::createStreams_ ( bool  data)
private

Create the streams.

◆ info()

virtual std::ostream& graphics::MatlabGraphics::info ( std::ostream &  os) const
protectedvirtual

Returns information in an output stream.

Reimplemented from graphics::OutputBase.

◆ operator()() [1/3]

template<class F , class G >
void graphics::MatlabGraphics::operator() ( concepts::Mesh msh,
const concepts::Formula< F > &  frm,
const uint  points = 5 
)

Application operator for output of a scalar formula.

Parameters
mshMesh
frmFormula

Definition at line 296 of file matlab.hh.

◆ operator()() [2/3]

template<class F , class G >
void graphics::MatlabGraphics::operator() ( const concepts::Space< G > &  spc,
const concepts::Formula< F > &  frm 
)

Application operator for output of a scalar formula.

Parameters
spcSpace on which the data should be plotted
frmFormula

Definition at line 290 of file matlab.hh.

◆ operator()() [3/3]

template<class F , class G >
void graphics::MatlabGraphics::operator() ( const concepts::Space< G > &  spc,
const concepts::Vector< F > &  sol,
const concepts::ElementFunction< F, G > *  fun = 0 
)

Application operator for output of solutions and functions of it.

Parameters
spcSpace on which the data should be plotted
solThe first solution set which should be plotted
funFunction of the FE function, e.g. itself.

Definition at line 283 of file matlab.hh.

◆ write_()

template<class F >
void graphics::MatlabGraphics::write_ ( concepts::GlobalPostprocess< F > &  postProcess,
BaseOutputCell< F > &  matlab,
bool  data = false 
)
private

Creates standard streams, writes to streams, writes to file and clear and delete all streams.

Definition at line 303 of file matlab.hh.

Member Data Documentation

◆ cnt_

uint graphics::MatlabGraphics::cnt_
private

Number of vectors written to the files.

Definition at line 216 of file matlab.hh.

◆ dim_

uint graphics::MatlabGraphics::dim_
private

Spatial dimension of the space.

Definition at line 214 of file matlab.hh.

◆ noPoints

uint graphics::MatlabGraphics::noPoints
static

Definition at line 196 of file matlab.hh.

◆ ofs_

std::unique_ptr<std::ofstream> graphics::OutputBase::ofs_
protectedinherited

Stream for output file.

Definition at line 83 of file basis.hh.

◆ s_ptr_

std::map<std::string, std::ostream*> graphics::MatlabGraphics::s_ptr_
private

Pointer to the streams, i.e. *(s_ptr_["vtxmsh"]) for FE mesh.

Definition at line 212 of file matlab.hh.


The documentation for this class was generated from the following file:
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich