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" 30 unsigned char dim = 2;
32 int 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)
60 sysnames.push_back(es1.get_system(s).name());
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]);
90 es1.get_system(s).solution->close();
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 ...
This is the EquationSystems class.
int main(int argc, char **argv)
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
The libMesh namespace provides an interface to certain functionality in the library.
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...