libMesh
namebased_io.h
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2024 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) override;
67 
71  virtual void write (const std::string & mesh_file) override;
72 
82  virtual void write_equation_systems (const std::string & filename,
83  const EquationSystems & es,
84  const std::set<std::string> * system_names=nullptr) override;
85 
91 
96  virtual void write_nodal_data (const std::string &,
97  const std::vector<Number> &,
98  const std::vector<std::string> &) 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 (std::string_view filename);
103 };
104 
105 
106 
107 // ------------------------------------------------------------
108 // NameBasedIO inline members
109 inline
112 {
113 }
114 
115 inline
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") == name.size() - 4) ||
129  (name.rfind(".n") == name.size() - 2) ||
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:42
This class supports simple reads and writes in any libMesh-supported format, by dispatching to one of...
Definition: namebased_io.h:44
virtual void write_equation_systems(const std::string &filename, const EquationSystems &es, const std::set< std::string > *system_names=nullptr) override
This method implements writing a mesh with data to a specified file where the data is taken from the ...
Definition: namebased_io.C:533
This is the EquationSystems class.
bool is_parallel_file_format(std::string_view filename)
Definition: namebased_io.h:124
virtual void read(const std::string &mesh_file) override
This method implements reading a mesh from a specified file.
Definition: namebased_io.C:80
MeshBase & mesh
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:74
This class defines an abstract interface for Mesh input.
Definition: mesh_base.h:56
virtual void write(const std::string &mesh_file) override
This method implements writing a mesh to a specified file.
Definition: namebased_io.C:310
virtual void write_nodal_data(const std::string &, const std::vector< Number > &, const std::vector< std::string > &) override
This method implements writing a mesh with nodal data to a specified file where the nodal data and va...
Definition: namebased_io.C:467