NLMech  0.1.0
rw::writer::MshWriter Class Reference

A .msh writer for simple point data and complex fem mesh data. More...

#include <mshWriter.h>

Collaboration diagram for rw::writer::MshWriter:
Collaboration graph

Public Member Functions

void close ()
 Closes the file and store it to the hard disk.
 
 MshWriter (const std::string &filename, const std::string &compress_type="")
 Constructor. More...
 
Mesh data
void appendNodes (const std::vector< util::Point3 > *nodes, const std::vector< util::Point3 > *u=nullptr)
 Writes the nodes to the file. More...
 
void appendMesh (const std::vector< util::Point3 > *nodes, const size_t &element_type, const std::vector< size_t > *en_con, const std::vector< util::Point3 > *u=nullptr)
 Writes the mesh data to file. More...
 
Point data
void appendPointData (const std::string &name, const std::vector< uint8_t > *data)
 Writes the scalar point data to the file. More...
 
void appendPointData (const std::string &name, const std::vector< size_t > *data)
 Writes the scalar point data to the file. More...
 
void appendPointData (const std::string &name, const std::vector< int > *data)
 Writes the scalar point data to the file. More...
 
void appendPointData (const std::string &name, const std::vector< float > *data)
 Writes the scalar point data to the file. More...
 
void appendPointData (const std::string &name, const std::vector< double > *data)
 Writes the scalar point data to the file. More...
 
void appendPointData (const std::string &name, const std::vector< util::Point3 > *data)
 Writes the vector point data to the file. More...
 
void appendPointData (const std::string &name, const std::vector< util::SymMatrix3 > *data)
 Writes the symmetric matrix data associated to nodes to the file. More...
 
Cell data
void appendCellData (const std::string &name, const std::vector< float > *data)
 Writes the float data associated to cells to the file. More...
 
void appendCellData (const std::string &name, const std::vector< util::SymMatrix3 > *data)
 Writes the symmetric matrix data associated to cells to the file. More...
 
Field data
void appendFieldData (const std::string &name, const double &data)
 Writes the scalar field data to the file. More...
 
void appendFieldData (const std::string &name, const float &data)
 Writes the scalar field data to the file. More...
 
void addTimeStep (const double &timestep)
 Writes the time step to the file. More...
 

Private Member Functions

void writeMshDataHeader (const std::string &name, int field_type, size_t num_data, bool is_node_data=true)
 utility function More...
 

Private Attributes

std::string d_compressType
 compression_type Specify the compressor (if any)
 
FILE * d_file
 vtk/vtu file
 
std::string d_filename
 filename
 

Detailed Description

A .msh writer for simple point data and complex fem mesh data.

We are using Gmsh 2.0 format.

Constructor & Destructor Documentation

◆ MshWriter()

rw::writer::MshWriter::MshWriter ( const std::string &  filename,
const std::string &  compress_type = "" 
)
explicit

Constructor.

Creates and opens .vtu file of name given by filename. The file remains open till the close() function is invoked.

Parameters
filenameName of file which will be created
compress_typeCompression method (optional)

Member Function Documentation

◆ addTimeStep()

void rw::writer::MshWriter::addTimeStep ( const double &  timestep)

Writes the time step to the file.

Parameters
timestepCurrent time step of the simulation

◆ appendCellData() [1/2]

void rw::writer::MshWriter::appendCellData ( const std::string &  name,
const std::vector< float > *  data 
)

Writes the float data associated to cells to the file.

Parameters
nameName of the data
dataVector containing the data

◆ appendCellData() [2/2]

void rw::writer::MshWriter::appendCellData ( const std::string &  name,
const std::vector< util::SymMatrix3 > *  data 
)

Writes the symmetric matrix data associated to cells to the file.

Parameters
nameName of the data
dataVector containing the data

◆ appendFieldData() [1/2]

void rw::writer::MshWriter::appendFieldData ( const std::string &  name,
const double &  data 
)

Writes the scalar field data to the file.

Parameters
nameName of the data
dataValue

◆ appendFieldData() [2/2]

void rw::writer::MshWriter::appendFieldData ( const std::string &  name,
const float &  data 
)

Writes the scalar field data to the file.

Parameters
nameName of the data
dataValue

◆ appendMesh()

void rw::writer::MshWriter::appendMesh ( const std::vector< util::Point3 > *  nodes,
const size_t &  element_type,
const std::vector< size_t > *  en_con,
const std::vector< util::Point3 > *  u = nullptr 
)

Writes the mesh data to file.

Parameters
nodesVector of nodal coordinates
element_typeType of element
en_conVector of element-node connectivity
uVector of nodal displacement

◆ appendNodes()

void rw::writer::MshWriter::appendNodes ( const std::vector< util::Point3 > *  nodes,
const std::vector< util::Point3 > *  u = nullptr 
)

Writes the nodes to the file.

Parameters
nodesReference positions of the nodes
uNodal displacements

◆ appendPointData() [1/7]

void rw::writer::MshWriter::appendPointData ( const std::string &  name,
const std::vector< double > *  data 
)

Writes the scalar point data to the file.

Parameters
nameName of the data
dataVector containing the data

◆ appendPointData() [2/7]

void rw::writer::MshWriter::appendPointData ( const std::string &  name,
const std::vector< float > *  data 
)

Writes the scalar point data to the file.

Parameters
nameName of the data
dataVector containing the data

◆ appendPointData() [3/7]

void rw::writer::MshWriter::appendPointData ( const std::string &  name,
const std::vector< int > *  data 
)

Writes the scalar point data to the file.

Parameters
nameName of the data
dataVector containing the data

◆ appendPointData() [4/7]

void rw::writer::MshWriter::appendPointData ( const std::string &  name,
const std::vector< size_t > *  data 
)

Writes the scalar point data to the file.

Parameters
nameName of the data
dataVector containing the data

◆ appendPointData() [5/7]

void rw::writer::MshWriter::appendPointData ( const std::string &  name,
const std::vector< uint8_t > *  data 
)

Writes the scalar point data to the file.

Parameters
nameName of the data
dataVector containing the data

◆ appendPointData() [6/7]

void rw::writer::MshWriter::appendPointData ( const std::string &  name,
const std::vector< util::Point3 > *  data 
)

Writes the vector point data to the file.

Parameters
nameName of the data
dataVector containing the data

◆ appendPointData() [7/7]

void rw::writer::MshWriter::appendPointData ( const std::string &  name,
const std::vector< util::SymMatrix3 > *  data 
)

Writes the symmetric matrix data associated to nodes to the file.

Parameters
nameName of the data
dataVector containing the data

◆ writeMshDataHeader()

void rw::writer::MshWriter::writeMshDataHeader ( const std::string &  name,
int  field_type,
size_t  num_data,
bool  is_node_data = true 
)
private

utility function

field_type:

  • 1 - scalar with 1 component
  • 2 - vector with 2 component
  • 3 - vector with 3 component
  • 6 - symmetric tensor with 6 component
Parameters
name
field_type
num_data
is_node_data

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