libMesh
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
libMesh::MatlabIO Class Reference

This class implements reading meshes in the Matlab PDE toolkit in a proprietary format. More...

#include <matlab_io.h>

Inheritance diagram for libMesh::MatlabIO:
[legend]

Public Member Functions

 MatlabIO (MeshBase &)
 Constructor. More...
 
virtual void read (const std::string &name) override
 Reads in a matlab data file based on the string you pass it. More...
 

Protected Member Functions

MeshBasemesh ()
 
void set_n_partitions (unsigned int n_parts)
 Sets the number of partitions in the mesh. More...
 
void skip_comment_lines (std::istream &in, const char comment_start)
 Reads input from in, skipping all the lines that start with the character comment_start. More...
 

Protected Attributes

std::vector< bool > elems_of_dimension
 A vector of bools describing what dimension elements have been encountered when reading a mesh. More...
 

Private Member Functions

void read_stream (std::istream &in)
 Implementation of the read() function. More...
 

Detailed Description

This class implements reading meshes in the Matlab PDE toolkit in a proprietary format.

A VALID INPUT FILE for this type of mesh should be generated in Matlab with the following steps: 1.) Draw the domain and triangulate it in the GUI 2.) Export the mesh to matlab using Mesh->Export Mesh 3.) Create a file with this script:

fid = fopen('filename', 'w');
fprintf(fid, '%d %d \n', length(p), length(t));
fprintf(fid, '%f %f \n', p);
fprintf(fid, '%d %d %d %d \n', t);
fclose(fid);

What's going on here? There is no standard for exporting PDE toolkit meshes to files in Matlab. When you choose "export mesh" in the GUI, it returns three matrices that it likes to call p, e, and t. All meshes (as far as I can tell) that come from the PDE toolkit are 2D triangle meshes.

p is the point matrix... Row 1: x coordinate Row 2: y coordinate

e is the edge matrix ... Row 1: starting point number (dummy) Row 2: ending point number (dummy) Row 3: starting parameter value (?) (dummy) Row 4: ending parameter value (?) (dummy) Row 5: boundary segment number (?) (dummy) Row 6: left-hand subdomain number (dummy) Row 7: right-hand subdomain number (dummy)

t is the triangle matrix ... Row 1: Node number 1 Row 2: Node number 2 Row 3: Node number 3 Row 4: subdomain number (dummy)

There are some important things to notice here: o The implied ordering of the p matrix is 1..N o The e matrix is entirely irrelevant in this code o All of the matrices are row based

Author
John W. Peterson
Date
2004

Definition at line 85 of file matlab_io.h.

Constructor & Destructor Documentation

◆ MatlabIO()

libMesh::MatlabIO::MatlabIO ( MeshBase mesh_in)
explicit

Constructor.

Takes a non-const Mesh reference which it will fill up with elements.

Definition at line 114 of file matlab_io.h.

114  :
115  MeshInput<MeshBase> (mesh_in)
116 {}

Member Function Documentation

◆ mesh()

MeshBase & libMesh::MeshInput< MeshBase >::mesh ( )
protectedinherited
Returns
The object as a writable reference.

Definition at line 169 of file mesh_input.h.

Referenced by libMesh::XdrIO::write_parallel().

170 {
171  if (_obj == nullptr)
172  libmesh_error_msg("ERROR: _obj should not be nullptr!");
173  return *_obj;
174 }
MeshBase * _obj
A pointer to a non-const object object.
Definition: mesh_input.h:114

◆ read()

virtual void libMesh::MatlabIO::read ( const std::string &  name)
overridevirtual

Reads in a matlab data file based on the string you pass it.

Implements libMesh::MeshInput< MeshBase >.

◆ read_stream()

void libMesh::MatlabIO::read_stream ( std::istream &  in)
private

Implementation of the read() function.

This function is called by the public interface function and implements reading the file.

◆ set_n_partitions()

void libMesh::MeshInput< MeshBase >::set_n_partitions ( unsigned int  n_parts)
protectedinherited

Sets the number of partitions in the mesh.

Typically this gets done by the partitioner, but some parallel file formats begin "pre-partitioned".

Definition at line 91 of file mesh_input.h.

References libMesh::MeshInput< MT >::mesh().

91 { this->mesh().set_n_partitions() = n_parts; }
unsigned int & set_n_partitions()
Definition: mesh_base.h:1371

◆ skip_comment_lines()

void libMesh::MeshInput< MeshBase >::skip_comment_lines ( std::istream &  in,
const char  comment_start 
)
protectedinherited

Reads input from in, skipping all the lines that start with the character comment_start.

Definition at line 179 of file mesh_input.h.

181 {
182  char c, line[256];
183 
184  while (in.get(c), c==comment_start)
185  in.getline (line, 255);
186 
187  // put back first character of
188  // first non-comment line
189  in.putback (c);
190 }

Member Data Documentation

◆ elems_of_dimension

std::vector<bool> libMesh::MeshInput< MeshBase >::elems_of_dimension
protectedinherited

A vector of bools describing what dimension elements have been encountered when reading a mesh.

Definition at line 97 of file mesh_input.h.


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