libMesh
namebased_io.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #ifndef LIBMESH_NAMEBASED_IO_H
21 #define LIBMESH_NAMEBASED_IO_H
22 
23 // Local includes
24 #include "libmesh/mesh_output.h"
25 #include "libmesh/mesh_input.h"
26 
27 namespace libMesh
28 {
29 
30 // Forward declarations
31 class MeshBase;
32 
44 class NameBasedIO : public MeshInput<MeshBase>,
45  public MeshOutput<MeshBase>
46 {
47 public:
48 
53  explicit
54  NameBasedIO (const MeshBase &);
55 
60  explicit
62 
66  virtual void read (const std::string & mesh_file) libmesh_override;
67 
71  virtual void write (const std::string & mesh_file) libmesh_override;
72 
82  virtual void write_equation_systems (const std::string & filename,
83  const EquationSystems & es,
84  const std::set<std::string> * system_names=libmesh_nullptr) libmesh_override;
85 
91 
96  virtual void write_nodal_data (const std::string &,
97  const std::vector<Number> &,
98  const std::vector<std::string> &) libmesh_override;
99 
100  // Certain mesh formats can support parallel I/O, including the
101  // "new" Xdr format and the Nemesis format.
102  bool is_parallel_file_format (const std::string & filename);
103 };
104 
105 
106 
107 // ------------------------------------------------------------
108 // NameBasedIO inline members
109 inline
111  MeshOutput<MeshBase> (mesh)
112 {
113 }
114 
115 inline
117  MeshInput<MeshBase> (mesh),
118  MeshOutput<MeshBase>(mesh)
119 {
120 }
121 
122 inline
123 bool
125 {
126  return ((name.rfind(".xda") < name.size()) ||
127  (name.rfind(".xdr") < name.size()) ||
128  (name.rfind(".nem") + 4 == name.size()) ||
129  (name.rfind(".n") + 2 == name.size()) ||
130  (name.rfind(".cp") < name.size())
131  );
132 }
133 
134 
135 } // namespace libMesh
136 
137 
138 #endif // LIBMESH_NAMEBASED_IO_H
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
virtual void read(const std::string &mesh_file) libmesh_override
This method implements reading a mesh from a specified file.
Definition: namebased_io.C:62
This class supports simple reads and writes in any libMesh-supported format, by dispatching to one of...
Definition: namebased_io.h:44
This is the EquationSystems class.
virtual void write_nodal_data(const std::string &, const std::vector< Number > &, const std::vector< std::string > &) libmesh_override
This method implements writing a mesh with nodal data to a specified file where the nodal data and va...
Definition: namebased_io.C:425
const class libmesh_nullptr_t libmesh_nullptr
This class defines an abstract interface for Mesh output.
Definition: mesh_output.h:53
The libMesh namespace provides an interface to certain functionality in the library.
NameBasedIO(const MeshBase &)
Constructor.
Definition: namebased_io.h:110
This is the MeshBase class.
Definition: mesh_base.h:68
virtual void write(const std::string &mesh_file) libmesh_override
This method implements writing a mesh to a specified file.
Definition: namebased_io.C:279
This class defines an abstract interface for Mesh input.
Definition: mesh_base.h:50
virtual void write_equation_systems(const std::string &filename, const EquationSystems &es, const std::set< std::string > *system_names=libmesh_nullptr) libmesh_override
This method implements writing a mesh with data to a specified file where the data is taken from the ...
Definition: namebased_io.C:490
bool is_parallel_file_format(const std::string &filename)
Definition: namebased_io.h:124