#include <tecplot_io.h>
Inherits MeshOutput< MeshBase >.
TecplotIO (const MeshBase &, const bool binary=false)
virtual void write (const std::string &)
virtual void write_nodal_data (const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
bool & binary ()
virtual void write_equation_systems (const std::string &, const EquationSystems &)
const MeshBase & mesh () const
void write_ascii (const std::string &, const std::vector< Number > *=NULL, const std::vector< std::string > *=NULL)
void write_binary (const std::string &, const std::vector< Number > *=NULL, const std::vector< std::string > *=NULL)
This class implements writing meshes in the Tecplot format.
Author:
Definition at line 42 of file tecplot_io.h.
Definition at line 111 of file tecplot_io.h.
:
MeshOutput<MeshBase> (mesh),
_binary (binary)
{
}
Definition at line 120 of file tecplot_io.h.
References _binary.
{
return _binary;
}
Referenced by PostscriptIO::write(), FroIO::write(), MEDITIO::write_ascii(), EnsightIO::write_geometry_ascii(), EnsightIO::write_scalar_ascii(), GnuPlotIO::write_solution(), DivaIO::write_stream(), and EnsightIO::write_vector_ascii().
Implements MeshOutput< MeshBase >.
Definition at line 106 of file tecplot_io.C.
References libMesh::processor_id().
Referenced by UnstructuredMesh::write().
{
if (libMesh::processor_id() == 0)
{
if (this->binary())
this->write_binary (fname);
else
this->write_ascii (fname);
}
}
Definition at line 134 of file tecplot_io.C.
References MeshBase::active_elements_begin(), MeshBase::active_elements_end(), MeshBase::mesh_dimension(), MeshBase::n_active_sub_elem(), MeshBase::n_nodes(), System::n_vars(), MeshBase::point(), libMesh::processor_id(), libMeshEnums::TECPLOT, and TypeVector< T >::write_unformatted().
{
// Should only do this on processor 0!
libmesh_assert (libMesh::processor_id() == 0);
// Create an output stream
std::ofstream out(fname.c_str());
// Make sure it opened correctly
if (!out.good())
libmesh_file_error(fname.c_str());
// Get a constant reference to the mesh.
const MeshBase& mesh = MeshOutput<MeshBase>::mesh();
// Write header to stream
{
{
out << '# This file was generated by:
<< '#
<< '# $Id: tecplot_io.C 3391 2009-05-26 03:50:35Z benkirk $
<< '#
<< '# For a description of the Tecplot format see the Tecplot User's guide.
<< '#;
}
out << 'Variables=x,y,z';
if (solution_names != NULL)
for (unsigned int n=0; n<solution_names->size(); n++)
{
#ifdef LIBMESH_USE_REAL_NUMBERS
// Write variable names for real variables
out << ',' << (*solution_names)[n];
#else
// Write variable names for complex variables
out << ',' << 'r_' << (*solution_names)[n]
<< ',' << 'i_' << (*solution_names)[n]
<< ',' << 'a_' << (*solution_names)[n];
#endif
}
out << ';
out << 'Zone f=fepoint, n=' << mesh.n_nodes() << ', e=' << mesh.n_active_sub_elem();
if (mesh.mesh_dimension() == 1)
out << ', et=lineseg';
else if (mesh.mesh_dimension() == 2)
out << ', et=quadrilateral';
else if (mesh.mesh_dimension() == 3)
out << ', et=brick';
else
{
// Dimension other than 1, 2, or 3?
libmesh_error();
}
// Use default mesh color = black
out << ', c=black;
} // finished writing header
for (unsigned int i=0; i<mesh.n_nodes(); i++)
{
// Print the point without a newline
mesh.point(i).write_unformatted(out, false);
if ((v != NULL) && (solution_names != NULL))
{
const unsigned int n_vars = solution_names->size();
for (unsigned int c=0; c<n_vars; c++)
{
#ifdef LIBMESH_USE_REAL_NUMBERS
// Write real data
out << (*v)[i*n_vars + c] << ' ';
#else
// Write complex data
out << (*v)[i*n_vars + c].real() << ' '
<< (*v)[i*n_vars + c].imag() << ' '
<< std::abs((*v)[i*n_vars + c]) << ' ';
#endif
}
}
// Write a new line after the data for this node
out << ';
}
// const_active_elem_iterator it (mesh.elements_begin());
// const const_active_elem_iterator end(mesh.elements_end());
MeshBase::const_element_iterator it = mesh.active_elements_begin();
const MeshBase::const_element_iterator end = mesh.active_elements_end();
for ( ; it != end; ++it)
(*it)->write_connectivity(out, TECPLOT);
}
Definition at line 245 of file tecplot_io.C.
References MeshBase::active_elements_begin(), MeshBase::active_elements_end(), MeshBase::mesh_dimension(), MeshBase::n_active_sub_elem(), MeshBase::n_nodes(), System::n_vars(), System::name(), MeshBase::point(), libMesh::processor_id(), and libMeshEnums::TECPLOT.
{
// Call the ASCII output function if configure did not detect
// the Tecplot binary API
#ifndef LIBMESH_HAVE_TECPLOT_API
std::cerr << 'WARNING: Tecplot Binary files require the Tecplot API.' << std::endl
<< 'Continuing with ASCII output.'
<< std::endl;
if (libMesh::processor_id() == 0)
this->write_ascii (fname, vec, solution_names);
return;
#else
// Get a constant reference to the mesh.
const MeshBase& mesh = MeshOutput<MeshBase>::mesh();
// Tecplot binary output only good for dim=2,3
if (mesh.mesh_dimension() == 1)
{
this->write_ascii (fname, vec, solution_names);
return;
}
// Required variables
std::string tecplot_variable_names;
int is_double = 0,
tec_debug = 0,
cell_type = ((mesh.mesh_dimension()==2) ? (1) : (3));
// Build a string containing all the variable names to pass to Tecplot
{
tecplot_variable_names += 'x, y, z';
if (solution_names != NULL)
{
for (unsigned int name=0; name<solution_names->size(); name++)
{
#ifdef LIBMESH_USE_REAL_NUMBERS
tecplot_variable_names += ', ';
tecplot_variable_names += (*solution_names)[name];
#else
tecplot_variable_names += ', ';
tecplot_variable_names += 'r_';
tecplot_variable_names += (*solution_names)[name];
tecplot_variable_names += ', ';
tecplot_variable_names += 'i_';
tecplot_variable_names += (*solution_names)[name];
tecplot_variable_names += ', ';
tecplot_variable_names += 'a_';
tecplot_variable_names += (*solution_names)[name];
#endif
}
}
}
// Instantiate a TecplotMacros interface. In 2D the most nodes per
// face should be 4, in 3D it's 8.
TecplotMacros tm(mesh.n_nodes(),
#ifdef LIBMESH_USE_REAL_NUMBERS
(3 + ((solution_names == NULL) ? 0 : solution_names->size())),
#else
(3 + 3*((solution_names == NULL) ? 0 : solution_names->size())),
#endif
mesh.n_active_sub_elem(),
((mesh.mesh_dimension() == 2) ? 4 : 8)
);
// Copy the nodes and data to the TecplotMacros class. Note that we store
// everything as a float here since the eye doesn't require a double to
// understand what is going on
for (unsigned int v=0; v<mesh.n_nodes(); v++)
{
tm.nd(0,v) = static_cast<float>(mesh.point(v)(0));
tm.nd(1,v) = static_cast<float>(mesh.point(v)(1));
tm.nd(2,v) = static_cast<float>(mesh.point(v)(2));
if ((vec != NULL) &&
(solution_names != NULL))
{
const unsigned int n_vars = solution_names->size();
for (unsigned int c=0; c<n_vars; c++)
{
#ifdef LIBMESH_USE_REAL_NUMBERS
tm.nd((3+c),v) = static_cast<float>((*vec)[v*n_vars + c]);
#else
tm.nd((3+3*c),v) = static_cast<float>((*vec)[v*n_vars + c].real());
tm.nd((3+3*c+1),v) = static_cast<float>((*vec)[v*n_vars + c].imag());
tm.nd((3+3*c+2),v) = static_cast<float>(std::abs((*vec)[v*n_vars + c]));
#endif
}
}
}
// Copy the connectivity
{
unsigned int te = 0;
// const_active_elem_iterator it (mesh.elements_begin());
// const const_active_elem_iterator end(mesh.elements_end());
MeshBase::const_element_iterator it = mesh.active_elements_begin();
const MeshBase::const_element_iterator end = mesh.active_elements_end();
for ( ; it != end; ++it)
{
std::vector<unsigned int> conn;
for (unsigned int se=0; se<(*it)->n_sub_elem(); se++)
{
(*it)->connectivity(se, TECPLOT, conn);
for (unsigned int node=0; node<conn.size(); node++)
tm.cd(node,te) = conn[node];
te++;
}
}
}
// Ready to call the Tecplot API
{
int ierr = 0,
num_nodes = static_cast<int>(mesh.n_nodes()),
num_cells = static_cast<int>(mesh.n_active_sub_elem());
ierr = TECINI (NULL,
(char*) tecplot_variable_names.c_str(),
(char*) fname.c_str(),
(char*) '.',
&tec_debug,
&is_double);
libmesh_assert (ierr == 0);
ierr = TECZNE (NULL,
&num_nodes,
&num_cells,
&cell_type,
(char*) 'FEBLOCK',
NULL);
libmesh_assert (ierr == 0);
int total =
#ifdef LIBMESH_USE_REAL_NUMBERS
((3 + ((solution_names == NULL) ? 0 : solution_names->size()))*num_nodes);
#else
((3 + 3*((solution_names == NULL) ? 0 : solution_names->size()))*num_nodes);
#endif
ierr = TECDAT (&total,
&tm.nodalData[0],
&is_double);
libmesh_assert (ierr == 0);
ierr = TECNOD (&tm.connData[0]);
libmesh_assert (ierr == 0);
ierr = TECEND ();
libmesh_assert (ierr == 0);
}
#endif
}
Reimplemented from MeshOutput< MeshBase >.
Definition at line 119 of file tecplot_io.C.
References libMesh::processor_id().
Referenced by UnstructuredMesh::write().
{
if (libMesh::processor_id() == 0)
{
if (this->binary())
this->write_binary (fname, &soln, &names);
else
this->write_ascii (fname, &soln, &names);
}
}
Definition at line 103 of file tecplot_io.h.
Referenced by binary().
Generated automatically by Doxygen for libMesh from the source code.