$extrastylesheet
libMesh::NameBasedIO Class Reference

#include <namebased_io.h>

Inheritance diagram for libMesh::NameBasedIO:

List of all members.

Public Member Functions

 NameBasedIO (const MeshBase &)
 NameBasedIO (MeshBase &)
virtual void read (const std::string &mesh_file)
virtual void write (const std::string &mesh_file)
virtual void write_equation_systems (const std::string &filename, const EquationSystems &es, const std::set< std::string > *system_names=NULL)
virtual void write_nodal_data (const std::string &, const std::vector< Number > &, const std::vector< std::string > &)
bool is_parallel_file_format (const std::string &filename)
unsigned int & ascii_precision ()

Protected Member Functions

MeshBasemesh ()
void set_n_partitions (unsigned int n_parts)
void skip_comment_lines (std::istream &in, const char comment_start)
const MeshBasemesh () const

Protected Attributes

std::vector< bool > elems_of_dimension
const bool _is_parallel_format

Detailed Description

This class supports simple reads and writes in any libMesh-supported format, by dispatching to one of the other I/O classes based on filename.

Other I/O classes may have more advanced features that are not accessible via this interface.

Author:
Roy H. Stogner, 2015

Definition at line 46 of file namebased_io.h.


Constructor & Destructor Documentation

libMesh::NameBasedIO::NameBasedIO ( const MeshBase mesh) [inline, explicit]

Constructor. Takes a reference to a constant mesh object. This constructor will only allow us to write the mesh.

Definition at line 106 of file namebased_io.h.

                                              :
  MeshOutput<MeshBase>    (mesh)
{
}
libMesh::NameBasedIO::NameBasedIO ( MeshBase mesh) [inline, explicit]

Constructor. Takes a writeable reference to a mesh object. This constructor is required to let us read in a mesh.

Definition at line 112 of file namebased_io.h.

                                        :
  MeshInput<MeshBase> (mesh),
  MeshOutput<MeshBase>(mesh)
{
}

Member Function Documentation

unsigned int& libMesh::MeshOutput< MeshBase >::ascii_precision ( ) [inherited]

Return/set the precision to use when writing ASCII files.

By default we use numeric_limits<Real>::digits10 + 2, which should be enough to write out to ASCII and get the exact same Real back when reading in.

Referenced by libMesh::TecplotIO::write_ascii(), libMesh::GMVIO::write_ascii_new_impl(), and libMesh::GMVIO::write_ascii_old_impl().

bool libMesh::NameBasedIO::is_parallel_file_format ( const std::string &  filename) [inline]

Definition at line 120 of file namebased_io.h.

Referenced by read(), and write().

{
  return ((name.rfind(".xda") < name.size()) ||
          (name.rfind(".xdr") < name.size()) ||
          (name.rfind(".nem") < name.size()) ||
          (name.rfind(".n") < name.size())   ||
          (name.rfind(".cp") < name.size())
          );
}
MeshBase & libMesh::MeshInput< MeshBase >::mesh ( ) [protected, inherited]

Returns the object as a writeable reference.

Referenced by libMesh::GMVIO::_read_materials(), libMesh::GMVIO::_read_nodes(), libMesh::GMVIO::_read_one_cell(), libMesh::AbaqusIO::assign_boundary_node_ids(), libMesh::AbaqusIO::assign_sideset_ids(), libMesh::AbaqusIO::assign_subdomain_ids(), libMesh::VTKIO::cells_to_vtk(), libMesh::ExodusII_IO::copy_elemental_solution(), libMesh::ExodusII_IO::copy_nodal_solution(), libMesh::GMVIO::copy_nodal_solution(), libMesh::TetGenIO::element_in(), libMesh::UNVIO::elements_in(), libMesh::UNVIO::elements_out(), libMesh::UNVIO::groups_in(), libMesh::TetGenIO::node_in(), libMesh::UNVIO::nodes_in(), libMesh::UNVIO::nodes_out(), libMesh::VTKIO::nodes_to_vtk(), libMesh::AbaqusIO::read(), read(), libMesh::TetGenIO::read(), libMesh::Nemesis_IO::read(), libMesh::ExodusII_IO::read(), libMesh::GMVIO::read(), libMesh::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::VTKIO::read(), libMesh::LegacyXdrIO::read_ascii(), libMesh::CheckpointIO::read_bcs(), libMesh::CheckpointIO::read_connectivity(), libMesh::AbaqusIO::read_elements(), libMesh::UCDIO::read_implementation(), libMesh::UNVIO::read_implementation(), libMesh::GmshIO::read_mesh(), libMesh::LegacyXdrIO::read_mesh(), libMesh::AbaqusIO::read_nodes(), libMesh::CheckpointIO::read_nodes(), libMesh::CheckpointIO::read_nodesets(), libMesh::XdrIO::read_serialized_bcs(), libMesh::XdrIO::read_serialized_connectivity(), libMesh::XdrIO::read_serialized_nodes(), libMesh::XdrIO::read_serialized_nodesets(), libMesh::XdrIO::read_serialized_subdomain_names(), libMesh::OFFIO::read_stream(), libMesh::MatlabIO::read_stream(), libMesh::CheckpointIO::read_subdomain_names(), write(), libMesh::TetGenIO::write(), libMesh::Nemesis_IO::write(), libMesh::ExodusII_IO::write(), libMesh::CheckpointIO::write(), libMesh::XdrIO::write(), libMesh::GMVIO::write_ascii_new_impl(), libMesh::GMVIO::write_ascii_old_impl(), libMesh::CheckpointIO::write_bcs(), libMesh::GMVIO::write_binary(), libMesh::CheckpointIO::write_connectivity(), libMesh::GMVIO::write_discontinuous_gmv(), libMesh::ExodusII_IO::write_element_data(), libMesh::UCDIO::write_implementation(), libMesh::GmshIO::write_mesh(), libMesh::LegacyXdrIO::write_mesh(), libMesh::UCDIO::write_nodal_data(), libMesh::VTKIO::write_nodal_data(), libMesh::Nemesis_IO::write_nodal_data(), write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data(), libMesh::ExodusII_IO::write_nodal_data_common(), libMesh::ExodusII_IO::write_nodal_data_discontinuous(), libMesh::CheckpointIO::write_nodes(), libMesh::CheckpointIO::write_nodesets(), libMesh::XdrIO::write_parallel(), libMesh::GmshIO::write_post(), libMesh::XdrIO::write_serialized_bcs(), libMesh::XdrIO::write_serialized_connectivity(), libMesh::XdrIO::write_serialized_nodes(), libMesh::XdrIO::write_serialized_nodesets(), libMesh::XdrIO::write_serialized_subdomain_names(), libMesh::LegacyXdrIO::write_soln(), and libMesh::CheckpointIO::write_subdomain_names().

void libMesh::NameBasedIO::read ( const std::string &  mesh_file) [virtual]

This method implements reading a mesh from a specified file.

Implements libMesh::MeshInput< MeshBase >.

Definition at line 64 of file namebased_io.C.

References libMesh::MeshBase::allow_renumbering(), libMesh::XdrIO::binary(), libMesh::MeshCommunication::broadcast(), is_parallel_file_format(), libMesh::XdrIO::legacy(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::ParallelObject::n_processors(), libMesh::Quality::name(), libMesh::ParallelObject::processor_id(), libMesh::AbaqusIO::read(), libMesh::OFFIO::read(), libMesh::UCDIO::read(), libMesh::TetGenIO::read(), libMesh::Nemesis_IO::read(), libMesh::UNVIO::read(), libMesh::ExodusII_IO::read(), libMesh::GmshIO::read(), libMesh::GMVIO::read(), libMesh::CheckpointIO::read(), libMesh::XdrIO::read(), libMesh::VTKIO::read(), libMesh::MatlabIO::read(), libMesh::LegacyXdrIO::read_mgf(), and libMesh::START_LOG().

Referenced by libMesh::UnstructuredMesh::read().

{
  MeshBase& mymesh = MeshInput<MeshBase>::mesh();

  // See if the file exists.  Perform this check on all processors
  // so that the code is terminated properly in the case that the
  // file does not exist.

  // For Nemesis files, the name we try to read will have suffixes
  // identifying processor rank
  if (name.rfind(".nem") + 4 == name.size() ||
      name.rfind(".n") + 2 == name.size())
    {
      std::ostringstream full_name;

      // Find the length of a string which represents the highest processor ID
      full_name << (mymesh.n_processors());
      int field_width = cast_int<int>(full_name.str().size());

      // reset the string stream
      full_name.str("");

      // And build up the full filename
      full_name << name
                << '.' << mymesh.n_processors()
                << '.' << std::setfill('0') << std::setw(field_width) << mymesh.processor_id();

      std::ifstream in (full_name.str().c_str());

      if (!in.good())
        libmesh_error_msg("ERROR: cannot locate specified file:\n\t" << full_name.str());
    }
  else if(name.rfind(".cp")) {} // Do error checking in the reader
  else
    {
      std::ifstream in (name.c_str());

      if (!in.good())
        libmesh_error_msg("ERROR: cannot locate specified file:\n\t" << name);
    }

  // Look for parallel formats first
  if (is_parallel_file_format(name))
    {
      // no need to handle bz2 files here -- the Xdr class does that.
      if ((name.rfind(".xda") < name.size()) ||
          (name.rfind(".xdr") < name.size()))
        {
          XdrIO xdr_io(mymesh);

          // .xda* ==> bzip2/gzip/ASCII flavors
          if (name.rfind(".xda") < name.size())
            {
              xdr_io.binary() = false;
              xdr_io.read (name);
            }
          else // .xdr* ==> true binary XDR file
            {
              xdr_io.binary() = true;
              xdr_io.read (name);
            }

          // The xdr_io object gets constructed with legacy() == false.
          // if legacy() == true then it means that a legacy file was detected and
          // thus processor 0 performed the read. We therefore need to broadcast the
          // mesh.  Further, for this flavor of mesh solution data ordering is tied
          // to the node ordering, so we better not reorder the nodes!
          if (xdr_io.legacy())
            {
              mymesh.allow_renumbering(false);
              MeshCommunication().broadcast(mymesh);
            }

          // libHilbert-enabled libMesh builds should construct files
          // with a canonical node ordering, which libHilbert-enabled
          // builds will be able to read in again regardless of any
          // renumbering.  So in that case we're free to renumber.
          // However, if either the writer or the reader of this file
          // don't have libHilbert, then we'll have to skip
          // renumbering because we need the numbering to remain
          // consistent with any solution file we read in next.
#ifdef LIBMESH_HAVE_LIBHILBERT
          // if (!xdr_io.libhilbert_ordering())
          //   skip_renumber_nodes_and_elements = true;
#else
          mymesh.allow_renumbering(false);
#endif
        }
      else if (name.rfind(".nem") < name.size() ||
               name.rfind(".n")   < name.size())
        Nemesis_IO(mymesh).read (name);
      else if (name.rfind(".cp") < name.size())
        {
          if(name.rfind(".cpa") < name.size())
            CheckpointIO(mymesh, false).read(name);
          else
            CheckpointIO(mymesh, true).read(name);
        }
    }

  // Serial mesh formats
  else
    {
      START_LOG("read()", "NameBasedIO");

      // Read the file based on extension.  Only processor 0
      // needs to read the mesh.  It will then broadcast it and
      // the other processors will pick it up
      if (mymesh.processor_id() == 0)
        {
          std::ostringstream pid_suffix;
          pid_suffix << '_' << getpid();
          // Nasty hack for reading/writing zipped files
          std::string new_name = name;
          if (name.size() - name.rfind(".bz2") == 4)
            {
#ifdef LIBMESH_HAVE_BZIP
              new_name.erase(new_name.end() - 4, new_name.end());
              new_name += pid_suffix.str();
              std::string system_string = "bunzip2 -f -k -c ";
              system_string += name + " > " + new_name;
              START_LOG("system(bunzip2)", "NameBasedIO");
              if (std::system(system_string.c_str()))
                libmesh_file_error(system_string);
              STOP_LOG("system(bunzip2)", "NameBasedIO");
#else
              libmesh_error_msg("ERROR: need bzip2/bunzip2 to open .bz2 file " << name);
#endif
            }
          else if (name.size() - name.rfind(".xz") == 3)
            {
#ifdef LIBMESH_HAVE_XZ
              new_name.erase(new_name.end() - 3, new_name.end());
              new_name += pid_suffix.str();
              std::string system_string = "xz -f -d -k -c ";
              system_string += name + " > " + new_name;
              START_LOG("system(xz -d)", "XdrIO");
              if (std::system(system_string.c_str()))
                libmesh_file_error(system_string);
              STOP_LOG("system(xz -d)", "XdrIO");
#else
              libmesh_error_msg("ERROR: need xz to open .xz file " << name);
#endif
            }

          if (new_name.rfind(".mat") < new_name.size())
            MatlabIO(mymesh).read(new_name);

          else if (new_name.rfind(".ucd") < new_name.size())
            UCDIO(mymesh).read (new_name);

          else if ((new_name.rfind(".off")  < new_name.size()) ||
                   (new_name.rfind(".ogl")  < new_name.size()) ||
                   (new_name.rfind(".oogl") < new_name.size()))
            OFFIO(mymesh).read (new_name);

          else if (new_name.rfind(".mgf") < new_name.size())
            LegacyXdrIO(mymesh,true).read_mgf (new_name);

          else if (new_name.rfind(".unv") < new_name.size())
            UNVIO(mymesh).read (new_name);

          else if ((new_name.rfind(".node")  < new_name.size()) ||
                   (new_name.rfind(".ele")   < new_name.size()))
            TetGenIO(mymesh).read (new_name);

          else if (new_name.rfind(".exd") < new_name.size() ||
                   new_name.rfind(".e") < new_name.size())
            ExodusII_IO(mymesh).read (new_name);

          else if (new_name.rfind(".msh") < new_name.size())
            GmshIO(mymesh).read (new_name);

          else if (new_name.rfind(".gmv") < new_name.size())
            GMVIO(mymesh).read (new_name);

          else if (new_name.rfind(".vtu") < new_name.size())
            VTKIO(mymesh).read(new_name);

          else if (new_name.rfind(".inp") < new_name.size())
            AbaqusIO(mymesh).read(new_name);

          else
            {
              libmesh_error_msg(" ERROR: Unrecognized file extension: " \
                                << name                                 \
                                << "\n   I understand the following:\n\n" \
                                << "     *.e    -- Sandia's ExodusII format\n" \
                                << "     *.exd  -- Sandia's ExodusII format\n" \
                                << "     *.gmv  -- LANL's General Mesh Viewer format\n" \
                                << "     *.mat  -- Matlab triangular ASCII file\n" \
                                << "     *.n    -- Sandia's Nemesis format\n" \
                                << "     *.nem  -- Sandia's Nemesis format\n" \
                                << "     *.off  -- OOGL OFF surface format\n" \
                                << "     *.ucd  -- AVS's ASCII UCD format\n" \
                                << "     *.unv  -- I-deas Universal format\n" \
                                << "     *.vtu  -- Paraview VTK format\n" \
                                << "     *.inp  -- Abaqus .inp format\n" \
                                << "     *.xda  -- libMesh ASCII format\n" \
                                << "     *.xdr  -- libMesh binary format\n" \
                                << "     *.gz   -- any above format gzipped\n" \
                                << "     *.bz2  -- any above format bzip2'ed\n" \
                                << "     *.xz   -- any above format xzipped\n" \
                                << "     *.cpa  -- libMesh Checkpoint ASCII format\n" \
                                << "     *.cpr  -- libMesh Checkpoint binary format\n");
            }

          // If we temporarily decompressed a file, remove the
          // uncompressed version
          if (name.size() - name.rfind(".bz2") == 4)
            std::remove(new_name.c_str());
          if (name.size() - name.rfind(".xz") == 3)
            std::remove(new_name.c_str());
        }


      STOP_LOG("read()", "NameBasedIO");

      // Send the mesh & bcs (which are now only on processor 0) to the other
      // processors
      MeshCommunication().broadcast (mymesh);
    }
}
void libMesh::MeshInput< MeshBase >::set_n_partitions ( unsigned int  n_parts) [inline, protected, inherited]

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 94 of file mesh_input.h.

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

Referenced by libMesh::Nemesis_IO::read(), and libMesh::XdrIO::read().

{ this->mesh().set_n_partitions() = n_parts; }
void libMesh::MeshInput< MeshBase >::skip_comment_lines ( std::istream &  in,
const char  comment_start 
) [protected, inherited]

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

Referenced by libMesh::TetGenIO::read(), and libMesh::UCDIO::read_implementation().

void libMesh::NameBasedIO::write ( const std::string &  mesh_file) [virtual]

This method implements writing a mesh to a specified file.

Implements libMesh::MeshOutput< MeshBase >.

Definition at line 289 of file namebased_io.C.

References libMesh::Parallel::Communicator::barrier(), libMesh::Parallel::Communicator::broadcast(), libMesh::ParallelObject::comm(), libMesh::err, is_parallel_file_format(), libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshBase::n_partitions(), libMesh::Quality::name(), libMesh::GMVIO::partitioning(), libMesh::ParallelObject::processor_id(), libMesh::START_LOG(), libMesh::FroIO::write(), libMesh::DivaIO::write(), libMesh::TecplotIO::write(), libMesh::MEDITIO::write(), libMesh::GMVIO::write(), libMesh::UCDIO::write(), libMesh::TetGenIO::write(), libMesh::Nemesis_IO::write(), libMesh::ExodusII_IO::write(), libMesh::UNVIO::write(), libMesh::GmshIO::write(), libMesh::XdrIO::write(), libMesh::VTKIO::write(), and libMesh::LegacyXdrIO::write_mgf().

Referenced by libMesh::UnstructuredMesh::find_neighbors(), and libMesh::UnstructuredMesh::write().

{
  MeshBase& mymesh = MeshInput<MeshBase>::mesh();

  // parallel formats are special -- they may choose to write
  // separate files, let's not try to handle the zipping here.
  if (is_parallel_file_format(name))
    {
      // no need to handle bz2 files here -- the Xdr class does that.
      if (name.rfind(".xda") < name.size())
        XdrIO(mymesh).write(name);

      else if (name.rfind(".xdr") < name.size())
        XdrIO(mymesh,true).write(name);

      else if (name.rfind(".nem") < name.size() ||
               name.rfind(".n")   < name.size())
        Nemesis_IO(mymesh).write(name);
    }

  // serial file formats
  else
    {
      // Nasty hack for reading/writing zipped files
      std::string new_name = name;
      pid_t pid_0 = 0;
      if (mymesh.processor_id() == 0)
        pid_0 = getpid();
      mymesh.comm().broadcast(pid_0);
      std::ostringstream pid_suffix;
      pid_suffix << '_' << pid_0;

      if (name.size() - name.rfind(".bz2") == 4)
        {
          new_name.erase(new_name.end() - 4, new_name.end());
          new_name += pid_suffix.str();
        }
      else if (name.size() - name.rfind(".xz") == 3)
        {
          new_name.erase(new_name.end() - 3, new_name.end());
          new_name += pid_suffix.str();
        }

      // New scope so that io will close before we try to zip the file
      {
        // Write the file based on extension
        if (new_name.rfind(".dat") < new_name.size())
          TecplotIO(mymesh).write (new_name);

        else if (new_name.rfind(".plt") < new_name.size())
          TecplotIO(mymesh,true).write (new_name);

        else if (new_name.rfind(".ucd") < new_name.size())
          UCDIO (mymesh).write (new_name);

        else if (new_name.rfind(".gmv") < new_name.size())
          if (mymesh.n_partitions() > 1)
            GMVIO(mymesh).write (new_name);
          else
            {
              GMVIO io(mymesh);
              io.partitioning() = false;
              io.write (new_name);
            }

        else if (new_name.rfind(".ugrid") < new_name.size())
          DivaIO(mymesh).write(new_name);
        else if (new_name.rfind(".e") < new_name.size())
          ExodusII_IO(mymesh).write(new_name);
        else if (new_name.rfind(".mgf")  < new_name.size())
          LegacyXdrIO(mymesh,true).write_mgf(new_name);

        else if (new_name.rfind(".unv") < new_name.size())
          UNVIO(mymesh).write (new_name);

        else if (new_name.rfind(".mesh") < new_name.size())
          MEDITIO(mymesh).write (new_name);

        else if (new_name.rfind(".poly") < new_name.size())
          TetGenIO(mymesh).write (new_name);

        else if (new_name.rfind(".msh") < new_name.size())
          GmshIO(mymesh).write (new_name);

        else if (new_name.rfind(".fro") < new_name.size())
          FroIO(mymesh).write (new_name);

        else if (new_name.rfind(".vtu") < new_name.size())
          VTKIO(mymesh).write (new_name);

        else
          {
            libMesh::err
              << " ERROR: Unrecognized file extension: " << name
              << "\n   I understand the following:\n\n"
              << "     *.dat   -- Tecplot ASCII file\n"
              << "     *.e     -- Sandia's ExodusII format\n"
              << "     *.exd   -- Sandia's ExodusII format\n"
              << "     *.fro   -- ACDL's surface triangulation file\n"
              << "     *.gmv   -- LANL's GMV (General Mesh Viewer) format\n"
              << "     *.mesh  -- MEdit mesh format\n"
              << "     *.mgf   -- MGF binary mesh format\n"
              << "     *.msh   -- GMSH ASCII file\n"
              << "     *.n     -- Sandia's Nemesis format\n"
              << "     *.nem   -- Sandia's Nemesis format\n"
              << "     *.plt   -- Tecplot binary file\n"
              << "     *.poly  -- TetGen ASCII file\n"
              << "     *.ucd   -- AVS's ASCII UCD format\n"
              << "     *.ugrid -- Kelly's DIVA ASCII format\n"
              << "     *.unv   -- I-deas Universal format\n"
              << "     *.vtu   -- VTK (paraview-readable) format\n"
              << "     *.xda   -- libMesh ASCII format\n"
              << "     *.xdr   -- libMesh binary format,\n"
              << std::endl
              << "\n Exiting without writing output\n";
          }
      }

      // Nasty hack for reading/writing zipped files
      if (name.size() - name.rfind(".bz2") == 4)
        {
          START_LOG("system(bzip2)", "NameBasedIO");
          if (mymesh.processor_id() == 0)
            {
              std::string system_string = "bzip2 -f -c ";
              system_string += new_name + " > " + name;
              if (std::system(system_string.c_str()))
                libmesh_file_error(system_string);
              std::remove(new_name.c_str());
            }
          mymesh.comm().barrier();
          STOP_LOG("system(bzip2)", "NameBasedIO");
        }
      if (name.size() - name.rfind(".xz") == 3)
        {
          START_LOG("system(xz)", "NameBasedIO");
          if (mymesh.processor_id() == 0)
            {
              std::string system_string = "xz -f -c ";
              system_string += new_name + " > " + name;
              if (std::system(system_string.c_str()))
                libmesh_file_error(system_string);
              std::remove(new_name.c_str());
            }
          mymesh.comm().barrier();
          STOP_LOG("system(xz)", "NameBasedIO");
        }
    }

}
void libMesh::NameBasedIO::write_equation_systems ( const std::string &  filename,
const EquationSystems es,
const std::set< std::string > *  system_names = NULL 
) [virtual]

This method implements writing a mesh with data to a specified file where the data is taken from the EquationSystems object.

We override the default MeshOutput::write_equation_systems because it only outputs nodal data by default, whereas we want to output a proper restart file if the requested filename is an XDA or XDR type.

Reimplemented from libMesh::MeshOutput< MeshBase >.

Definition at line 506 of file namebased_io.C.

References libMesh::ENCODE, libMesh::WRITE, libMesh::EquationSystems::write(), libMesh::EquationSystems::WRITE_ADDITIONAL_DATA, and libMesh::EquationSystems::WRITE_DATA.

{
  // XDA/XDR require a separate code path, and currently only support
  // writing complete restarts
  if (!system_names)
    {
      if (filename.rfind(".xda") < filename.size())
        {
          es.write(filename,WRITE,
                   EquationSystems::WRITE_DATA |
                   EquationSystems::WRITE_ADDITIONAL_DATA);
          return;
        }
      else if (filename.rfind(".xdr") < filename.size())
        {
          es.write(filename,ENCODE,
                   EquationSystems::WRITE_DATA |
                   EquationSystems::WRITE_ADDITIONAL_DATA);
          return;
        }
    }

  // Other formats just use the default "write nodal values" path
  MeshOutput<MeshBase>::write_equation_systems
    (filename, es, system_names);
}
void libMesh::NameBasedIO::write_nodal_data ( const std::string &  name,
const std::vector< Number > &  v,
const std::vector< std::string > &  vn 
) [virtual]

This method implements writing a mesh with nodal data to a specified file where the nodal data and variable names are provided.

Reimplemented from libMesh::MeshOutput< MeshBase >.

Definition at line 441 of file namebased_io.C.

References libMesh::err, libMesh::MeshInput< MeshBase >::mesh(), libMesh::MeshBase::n_subdomains(), libMesh::GMVIO::partitioning(), libMesh::TecplotIO::write_nodal_data(), libMesh::MEDITIO::write_nodal_data(), libMesh::UCDIO::write_nodal_data(), libMesh::VTKIO::write_nodal_data(), libMesh::Nemesis_IO::write_nodal_data(), libMesh::GmshIO::write_nodal_data(), libMesh::GMVIO::write_nodal_data(), and libMesh::ExodusII_IO::write_nodal_data().

Referenced by libMesh::UnstructuredMesh::write().

{
  MeshBase& mymesh = MeshInput<MeshBase>::mesh();

  // Write the file based on extension
  if (name.rfind(".dat") < name.size())
    TecplotIO(mymesh).write_nodal_data (name, v, vn);

  else if (name.rfind(".e") < name.size())
    ExodusII_IO(mymesh).write_nodal_data(name, v, vn);

  else if (name.rfind(".gmv") < name.size())
    {
      if (mymesh.n_subdomains() > 1)
        GMVIO(mymesh).write_nodal_data (name, v, vn);
      else
        {
          GMVIO io(mymesh);
          io.partitioning() = false;
          io.write_nodal_data (name, v, vn);
        }
    }

  else if (name.rfind(".mesh") < name.size())
    MEDITIO(mymesh).write_nodal_data (name, v, vn);

  else if (name.rfind(".msh") < name.size())
    GmshIO(mymesh).write_nodal_data (name, v, vn);

  else if (name.rfind(".nem") < name.size() ||
           name.rfind(".n")   < name.size())
    Nemesis_IO(mymesh).write_nodal_data(name, v, vn);

  else if (name.rfind(".plt") < name.size())
    TecplotIO(mymesh,true).write_nodal_data (name, v, vn);

  else if (name.rfind(".pvtu") < name.size())
    VTKIO(mymesh).write_nodal_data (name, v, vn);

  else if (name.rfind(".ucd") < name.size())
    UCDIO (mymesh).write_nodal_data (name, v, vn);

  else
    {
      libMesh::err
        << " ERROR: Unrecognized file extension: " << name
        << "\n   I understand the following:\n\n"
        << "     *.dat  -- Tecplot ASCII file\n"
        << "     *.e    -- Sandia's ExodusII format\n"
        << "     *.exd  -- Sandia's ExodusII format\n"
        << "     *.gmv  -- LANL's GMV (General Mesh Viewer) format\n"
        << "     *.mesh -- MEdit mesh format\n"
        << "     *.msh  -- GMSH ASCII file\n"
        << "     *.n    -- Sandia's Nemesis format\n"
        << "     *.nem  -- Sandia's Nemesis format\n"
        << "     *.plt  -- Tecplot binary file\n"
        << "     *.pvtu -- Paraview VTK file\n"
        << "     *.ucd  -- AVS's ASCII UCD format\n"
        << "\n Exiting without writing output\n";
    }
}

Member Data Documentation

const bool libMesh::MeshOutput< MeshBase >::_is_parallel_format [protected, inherited]

Flag specifying whether this format is parallel-capable. If this is false (default) I/O is only permitted when the mesh has been serialized.

Definition at line 126 of file mesh_output.h.

Referenced by libMesh::FroIO::write(), libMesh::DivaIO::write(), libMesh::PostscriptIO::write(), and libMesh::EnsightIO::write().


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