#include <matlab_io.h>
Inherits MeshInput< MeshBase >.
MatlabIO (MeshBase &)
virtual void read (const std::string &name)
MeshBase & mesh ()
void skip_comment_lines (std::istream &in, const char comment_start)
virtual void read_stream (std::istream &in)
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
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:
Definition at line 86 of file matlab_io.h.
Definition at line 114 of file matlab_io.h.
:
MeshInput<MeshBase> (mesh)
{}
Referenced by GMVIO::_read_materials(), GMVIO::_read_nodes(), GMVIO::_read_one_cell(), GMVIO::add_cell_centered_data(), GMVIO::copy_nodal_solution(), UNVIO::element_in(), TetGenIO::element_in(), UNVIO::element_out(), UNVIO::node_in(), TetGenIO::node_in(), UNVIO::node_out(), XdrIO::read(), VTKIO::read(), GMVIO::read(), ExodusII_IO::read(), LegacyXdrIO::read_ascii(), LegacyXdrIO::read_binary(), UCDIO::read_implementation(), LegacyXdrIO::read_mesh(), GmshIO::read_mesh(), XdrIO::read_serialized_bcs(), XdrIO::read_serialized_connectivity(), XdrIO::read_serialized_nodes(), OFFIO::read_stream(), read_stream(), VTKIO::solution_to_vtk(), XdrIO::write(), VTKIO::write(), TetGenIO::write(), GMVIO::write_ascii_new_impl(), GMVIO::write_ascii_old_impl(), GMVIO::write_binary(), GMVIO::write_discontinuous_gmv(), UNVIO::write_implementation(), UCDIO::write_implementation(), LegacyXdrIO::write_mesh(), GmshIO::write_mesh(), GmshIO::write_post(), XdrIO::write_serialized_bcs(), XdrIO::write_serialized_connectivity(), XdrIO::write_serialized_nodes(), and LegacyXdrIO::write_soln().
Implements MeshInput< MeshBase >.
Definition at line 32 of file matlab_io.C.
References read_stream().
Referenced by UnstructuredMesh::read().
{
std::ifstream in (name.c_str());
this->read_stream(in);
}
Definition at line 40 of file matlab_io.C.
References MeshBase::add_elem(), MeshBase::add_point(), MeshBase::clear(), MeshInput< MeshBase >::mesh(), MeshBase::mesh_dimension(), MeshBase::node_ptr(), libMesh::processor_id(), DofObject::set_id(), and Elem::set_node().
Referenced by read().
{
// This is a serial-only process for now;
// the Mesh should be read on processor 0 and
// broadcast later
libmesh_assert(libMesh::processor_id() == 0);
// Get a reference to the mesh
MeshBase& mesh = MeshInput<MeshBase>::mesh();
// Clear any existing mesh data
mesh.clear();
// PDE toolkit only works in 2D
libmesh_assert(mesh.mesh_dimension() == 2);
// Check the input buffer
libmesh_assert (in.good());
unsigned int nNodes=0, nElem=0;
in >> nNodes // Read the number of nodes
>> nElem; // Read the number of elements
// Sort of check that it worked
libmesh_assert(nNodes > 0);
libmesh_assert(nElem > 0);
// Read the nodal coordinates
{
Real x=0., y=0., z=0.;
for (unsigned int i=0; i<nNodes; i++)
{
in >> x // x-coordinate value
>> y; // y-coordinate value
mesh.add_point ( Point(x,y,z), i);
}
}
// Read the elements (elements)
{
unsigned int node=0, dummy=0;
for (unsigned int i=0; i<nElem; i++)
{
Elem* elem = new Tri3; // Always build a triangle
elem->set_id(i);
mesh.add_elem (elem);
for (unsigned int n=0; n<3; n++) // Always read three 3 nodes
{
in >> node;
elem->set_node(n) = mesh.node_ptr(node-1); // Assign the node number
}
// There is an additional subdomain number here,
// so we read it and get rid of it!
in >> dummy;
}
}
}
Referenced by TetGenIO::read(), and UCDIO::read_implementation().
Generated automatically by Doxygen for libMesh from the source code.