libMesh
Loading...
Searching...
No Matches
meshplot.C
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 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// libmesh includes
19#include "libmesh/libmesh.h"
20#include "libmesh/equation_systems.h"
21#include "libmesh/mesh.h"
22#include "libmesh/namebased_io.h"
23
24using namespace libMesh;
25
26// Open the mesh and solution file named in command line arguments,
27// and plot them out to the given filename.
28int main(int argc, char ** argv)
29{
30 LibMeshInit init(argc, argv);
31
32 Mesh mesh(init.comm());
34
35 if (argc < 3 || argc > 4)
36 libmesh_error_msg
37 ("Usage: " << argv[0] <<
38 " inputmesh [inputsolution] outputplot");
39
40 LOG_CALL("mesh.read()", "main", mesh.read(argv[1]));
41
42 libMesh::out << "Loaded mesh " << argv[1] << std::endl;
44
45 if (argc > 3)
46 {
47 std::string solnname = argv[2];
48
49 LOG_CALL("es.read()", "main",
50 es.read(solnname,
55
56 libMesh::out << "Loaded solution " << solnname << std::endl;
57 es.print_info();
58 }
59
60 std::string outputname(argv[argc-1]);
61 {
62 LOG_SCOPE("write_equation_systems()", "main");
63 if ((outputname.find(".xda") != std::string::npos) ||
64 (outputname.find(".xdr") != std::string::npos))
65 {
66 mesh.write("mesh-"+outputname);
67 es.write("soln-"+outputname);
68 }
69 else
70 NameBasedIO(mesh).write_equation_systems (outputname, es);
71 }
72
73 libMesh::out << "Wrote output " << outputname << std::endl;
74
75 return 0;
76}
This is the EquationSystems class.
void print_info(std::ostream &os=libMesh::out) const
Prints information about the equation systems, by default to libMesh::out.
void write(std::string_view name, const XdrMODE, const unsigned int write_flags=(WRITE_DATA), bool partition_agnostic=true) const
Write the systems to disk using the XDR data format.
void read(std::string_view name, const XdrMODE, const unsigned int read_flags=(READ_HEADER|READ_DATA), bool partition_agnostic=true)
Read & initialize the systems from disk using the XDR data format.
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
Definition libmesh.h:92
virtual void write(const std::string &name) const =0
virtual void read(const std::string &name, void *mesh_data=nullptr, bool skip_renumber_nodes_and_elements=false, bool skip_find_neighbors=false, bool skip_detect_interior_parents=false)=0
Interfaces for reading/writing a mesh to/from a file.
void print_info(std::ostream &os=libMesh::out, const unsigned int verbosity=0, const bool global=true) const
Prints relevant information about the mesh.
Definition mesh_base.C:1755
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
Definition mesh.h:51
This class supports simple reads and writes in any libMesh-supported format, by dispatching to one of...
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 ...
MeshBase & mesh
The libMesh namespace provides an interface to certain functionality in the library.
OStreamProxy out
int main()