21#include "libmesh/libmesh.h"
22#include "libmesh/equation_systems.h"
23#include "libmesh/mesh.h"
24#include "libmesh/namebased_io.h"
25#include "libmesh/numeric_vector.h"
26#include "libmesh/int_range.h"
32int main(
int argc,
char ** argv)
40 <<
" outputsolution mesh firstsolution [secondsolution ...]" << std::endl;
51 libMesh::out <<
"Loaded first solution " << argv[3] << std::endl;
55 std::vector<std::string> sysnames;
56 std::vector<std::unique_ptr<NumericVector<libMesh::Number>>> summed_solutions;
58 for (
unsigned int s = 0; s != es1.
n_systems(); ++s)
61 summed_solutions.emplace_back(es1.
get_system(s).solution->clone());
64 for (
int i=4; i < argc; ++i)
73 libMesh::out <<
"Loaded next solution " << argv[i] << std::endl;
77 libmesh_error_msg_if(!es2.
has_system(sysnames[s]),
78 "EquationSystems object does not have " << sysnames[s]);
80 (*summed_solutions[s]) += *es2.
get_system(s).solution;
84 int n_solutions = argc - 3;
88 (*summed_solutions[s]) /= n_solutions;
89 es1.
get_system(s).solution->swap(*summed_solutions[s]);
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.
unsigned int n_systems() const
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.
bool has_system(std::string_view name) const
const T_sys & get_system(std::string_view name) const
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
void print_info(std::ostream &os=libMesh::out, const unsigned int verbosity=0, const bool global=true) const
Prints relevant information about the mesh.
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
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 ...
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) override
Reads the file specified by name.
The libMesh namespace provides an interface to certain functionality in the library.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...