33{
35
38
40 << " outputsolution mesh firstsolution [secondsolution ...]" << std::endl;
41
42 mesh1.read(argv[2]);
44
45 mesh1.print_info();
46
47 es1.read(argv[3],
51 libMesh::out <<
"Loaded first solution " << argv[3] << std::endl;
52
53 es1.print_info();
54
55 std::vector<std::string> sysnames;
56 std::vector<std::unique_ptr<NumericVector<libMesh::Number>>> summed_solutions;
57
58 for (unsigned int s = 0; s != es1.n_systems(); ++s)
59 {
60 sysnames.push_back(es1.get_system(s).name());
61 summed_solutions.emplace_back(es1.get_system(s).solution->clone());
62 }
63
64 for (int i=4; i < argc; ++i)
65 {
68 mesh2.read(argv[2]);
69 es2.read(argv[i],
73 libMesh::out <<
"Loaded next solution " << argv[i] << std::endl;
74
76 {
77 libmesh_error_msg_if(!es2.has_system(sysnames[s]),
78 "EquationSystems object does not have " << sysnames[s]);
79
80 (*summed_solutions[s]) += *es2.get_system(s).solution;
81 }
82 }
83
84 int n_solutions = argc - 3;
85
87 {
88 (*summed_solutions[s]) /= n_solutions;
89 es1.get_system(s).solution->swap(*summed_solutions[s]);
90 es1.get_system(s).solution->close();
91 }
92
94
95 return 0;
96}
This is the EquationSystems class.
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
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 ...
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...