45 <<
" coarsemesh coarsesolution finemesh finesolution [outputdiff]" << std::endl;
50 coarse_mesh.read(argv[1]);
51 libMesh::out <<
"Loaded coarse mesh " << argv[1] << std::endl;
52 coarse_es.read(argv[2]);
53 libMesh::out <<
"Loaded coarse solution " << argv[2] << std::endl;
54 fine_mesh.read(argv[3]);
55 libMesh::out <<
"Loaded fine mesh " << argv[3] << std::endl;
56 fine_es.read(argv[4]);
57 libMesh::out <<
"Loaded fine solution " << argv[4] << std::endl;
60 exact_sol.attach_reference_solution(&fine_es);
62 std::vector<std::string> sysnames;
63 sysnames.reserve(coarse_es.n_systems());
65 for (
unsigned int i = 0; i != coarse_es.n_systems(); ++i)
66 if (fine_es.has_system(coarse_es.get_system(i).name()))
67 sysnames.push_back(coarse_es.get_system(i).name());
70 << coarse_es.get_system(i).name()
71 <<
" not found in fine solution!" << std::endl;
73 for (
unsigned int i = 0; i != fine_es.n_systems(); ++i)
74 if (!coarse_es.has_system(fine_es.get_system(i).name()))
76 << fine_es.get_system(i).name()
77 <<
" not found in coarse solution!" << std::endl;
79 if (!coarse_es.n_systems() && !fine_es.n_systems())
80 libMesh::out <<
"No systems found in fine or coarse solution!" 85 const std::string sysname = sysnames[i];
86 const System & coarse_sys = coarse_es.get_system(sysname);
87 const System & fine_sys = fine_es.get_system(sysname);
89 for (
unsigned int j = 0; j != coarse_sys.
n_vars(); ++j)
96 <<
" variable " << varname
97 <<
" not found in coarse solution!" << std::endl;
102 exact_sol.compute_error(sysname, varname);
104 libMesh::out <<
"Errors in system " << sysname <<
", variable " << varname <<
":" << std::endl;
105 libMesh::out <<
"L2 error: " << exact_sol.l2_error(sysname, varname)
108 libMesh::out <<
"H1 error: " << exact_sol.h1_error(sysname, varname)
111 libMesh::out <<
"H2 error: " << exact_sol.h2_error(sysname, varname)
116 for (
unsigned int j = 0; j != fine_sys.
n_vars(); ++j)
123 <<
" variable " << varname
124 <<
" not found in fine solution!" << std::endl;
130 libMesh::out <<
"No variables found in fine or coarse solution system " 131 << sysname <<
'!' << std::endl;
136 libMesh::out <<
"Writing diff solution " << argv[5] << std::endl;
140 const std::string sysname = sysnames[i];
141 const System & coarse_sys = coarse_es.get_system(sysname);
142 const System & fine_sys = fine_es.get_system(sysname);
144 std::unique_ptr<NumericVector<Number>> fine_solution = fine_sys.
solution->clone();
147 std::vector<unsigned int>
150 for (
unsigned int j = 0; j != fine_sys.
n_vars(); ++j)
160 coarse_sys.
get_dof_map(), std::move(var_remapping));
161 coarse_solution.
init();
163 coarse_solution.enable_out_of_mesh_mode(oom_value);
166 *fine_sys.
solution -= *fine_solution;
This class handles the computation of the L2 and/or H1 error for the Systems in the EquationSystems o...
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.
const unsigned int invalid_uint
A number which is used quite often to represent an invalid or uninitialized value for an unsigned int...
The LibMeshInit class, when constructed, initializes the dependent libraries (e.g.
unsigned int variable_number(std::string_view var) const
void project_solution(FunctionBase< Number > *f, FunctionBase< Gradient > *g=nullptr) const
Projects arbitrary functions onto the current solution.
bool has_variable(std::string_view var) const
Manages consistently variables, degrees of freedom, and coefficient vectors.
std::unique_ptr< NumericVector< Number > > solution
Data structure to hold solution values.
Real calculate_norm(const NumericVector< Number > &v, unsigned int var, FEMNormType norm_type, std::set< unsigned int > *skip_dimensions=nullptr) const
void init(triangulateio &t)
Initializes the fields of t to nullptr/0 as necessary.
virtual void init() override
Override the FunctionBase::init() member function.
const std::string & variable_name(const unsigned int i) const
This class provides function-like objects for data distributed over a mesh.
unsigned int n_vars() const
The Mesh class is a thin wrapper, around the ReplicatedMesh class by default.
const DofMap & get_dof_map() const
auto index_range(const T &sizable)
Helper function that returns an IntRange<std::size_t> representing all the indices of the passed-in v...