ExaDG
Loading...
Searching...
No Matches
error_calculation.h
1/* ______________________________________________________________________
2 *
3 * ExaDG - High-Order Discontinuous Galerkin for the Exa-Scale
4 *
5 * Copyright (C) 2021 by the ExaDG authors
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 * ______________________________________________________________________
20 */
21
22#ifndef INCLUDE_COMPRESSIBLE_NAVIER_STOKES_POSTPROCESSOR_ERROR_CALCULATION_H_
23#define INCLUDE_COMPRESSIBLE_NAVIER_STOKES_POSTPROCESSOR_ERROR_CALCULATION_H_
24
25// deal.II
26#include <deal.II/base/function.h>
27#include <deal.II/dofs/dof_handler.h>
28#include <deal.II/fe/mapping_q.h>
29#include <deal.II/lac/la_parallel_vector.h>
30
31// ExaDG
32#include <exadg/postprocessor/time_control.h>
33#include <exadg/utilities/print_functions.h>
34
35namespace ExaDG
36{
37template<int dim>
39{
41 : calculate_relative_errors(true),
42 calculate_H1_seminorm_error(false),
43 write_errors_to_file(false),
44 spatially_weight_error(false),
45 weight(nullptr),
46 directory("output/"),
47 name("all fields")
48 {
49 }
50
51 void
52 print(dealii::ConditionalOStream & pcout, bool unsteady)
53 {
54 print_parameter(pcout, "Error calculation", unsteady == true and analytical_solution);
55 if(unsteady == true and time_control_data.is_active)
56 {
57 print(pcout, unsteady, time_control_data);
58 print_parameter(pcout, "Calculate relative errors", calculate_relative_errors);
59 print_parameter(pcout, "Calculate H1-seminorm error", calculate_H1_seminorm_error);
60 print_parameter(pcout, "Write errors to file", write_errors_to_file);
61 if(write_errors_to_file)
62 print_parameter(pcout, "Directory", directory);
63 print_parameter(pcout, "Name", name);
64 }
65 }
66
67 std::shared_ptr<dealii::Function<dim>> analytical_solution;
68
69 // relative or absolute errors?
70 // If calculate_relative_errors == false, this implies that absolute errors are calculated
71 bool calculate_relative_errors;
72
73 // by default, only the L2-error is computed. Other norms have to be explicitly specified by the
74 // user.
75 bool calculate_H1_seminorm_error;
76
77 // data used to control the output
78 TimeControlData time_control_data;
79
80 // write errors to file?
81 bool write_errors_to_file;
82
83 // If true, a spatially weighted norm is computed.
84 bool spatially_weight_error;
85 // Weight used to compute spatially weighted error.
86 std::shared_ptr<dealii::Function<dim>> weight;
87
88 // directory and name (used as filename and as identifier for screen output)
89 std::string directory;
90 std::string name;
91};
92
93template<int dim, typename Number>
95{
96public:
97 typedef dealii::LinearAlgebra::distributed::Vector<Number> VectorType;
98
99 ErrorCalculator(MPI_Comm const & comm);
100
101 void
102 setup(dealii::DoFHandler<dim> const & dof_handler,
103 dealii::Mapping<dim> const & mapping,
104 ErrorCalculationData<dim> const & error_data);
105
106 void
107 evaluate(VectorType const & solution, double const time, bool const unsteady);
108
109 TimeControl time_control;
110
111private:
112 void
113 do_evaluate(VectorType const & solution_vector, double const time);
114
115 MPI_Comm const mpi_comm;
116
117 bool clear_files_L2, clear_files_H1_seminorm;
118
119 dealii::SmartPointer<dealii::DoFHandler<dim> const> dof_handler;
120 dealii::SmartPointer<dealii::Mapping<dim> const> mapping;
121
122 ErrorCalculationData<dim> error_data;
123};
124
125} // namespace ExaDG
126
127#endif /* INCLUDE_COMPRESSIBLE_NAVIER_STOKES_POSTPROCESSOR_ERROR_CALCULATION_H_ */
Definition error_calculation.h:95
Definition time_control.h:64
Definition driver.cpp:33
Definition error_calculation.h:39
Definition time_control.h:40