ExaDG
Loading...
Searching...
No Matches
divergence_and_mass_error.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_EXADG_INCOMPRESSIBLE_NAVIER_STOKES_POSTPROCESSOR_DIVERGENCE_AND_MASS_ERROR_H_
23#define INCLUDE_EXADG_INCOMPRESSIBLE_NAVIER_STOKES_POSTPROCESSOR_DIVERGENCE_AND_MASS_ERROR_H_
24
25// deal.II
26#include <deal.II/lac/la_parallel_vector.h>
27
28// ExaDG
29#include <exadg/matrix_free/integrators.h>
30#include <exadg/postprocessor/time_control.h>
31#include <exadg/utilities/print_functions.h>
32
33namespace ExaDG
34{
35namespace IncNS
36{
38{
39 MassConservationData() : directory("output/"), filename("mass"), reference_length_scale(1.0)
40 {
41 }
42
43 void
44 print(dealii::ConditionalOStream & pcout, const bool unsteady)
45 {
46 if(time_control_data.is_active)
47 {
48 pcout << " Analysis of divergence and mass error:" << std::endl;
49 time_control_data.print(pcout, unsteady);
50 print_parameter(pcout, "Directory", directory);
51 print_parameter(pcout, "Filename", filename);
52 }
53 }
54
55 TimeControlData time_control_data;
56
57 std::string directory;
58 std::string filename;
59 double reference_length_scale;
60};
61
62template<int dim, typename Number>
64{
65public:
66 typedef dealii::LinearAlgebra::distributed::Vector<Number> VectorType;
67
68 typedef CellIntegrator<dim, dim, Number> CellIntegratorU;
69 typedef FaceIntegrator<dim, dim, Number> FaceIntegratorU;
70
71 typedef dealii::VectorizedArray<Number> scalar;
72 typedef dealii::Tensor<1, dim, dealii::VectorizedArray<Number>> vector;
73
75
76 DivergenceAndMassErrorCalculator(MPI_Comm const & comm);
77
78 void
79 setup(dealii::MatrixFree<dim, Number> const & matrix_free_in,
80 unsigned int const dof_index_in,
81 unsigned int const quad_index_in,
82 MassConservationData const & data_in);
83
84 void
85 evaluate(VectorType const & velocity, double const time, bool const unsteady);
86
87 TimeControl time_control;
88
89private:
90 /*
91 * This function calculates the divergence error and the error of mass flux
92 * over interior element faces.
93 *
94 * Divergence error: L * (1,|divu|)_Omega, L is a reference length scale
95 * Reference value for divergence error: (1,|| u ||)_Omega
96 *
97 * and
98 *
99 * Mass error: (1,|(um - up)*n|)_dOmegaI
100 * Reference value for mass error: (1,|0.5(um + up)*n|)_dOmegaI
101 */
102 void
103 do_evaluate(dealii::MatrixFree<dim, Number> const & matrix_free,
104 VectorType const & velocity,
105 Number & div_error,
106 Number & div_error_reference,
107 Number & mass_error,
108 Number & mass_error_reference);
109
110 void
111 local_compute_div(dealii::MatrixFree<dim, Number> const & data,
112 std::vector<Number> & dst,
113 VectorType const & source,
114 const std::pair<unsigned int, unsigned int> & cell_range);
115
116 void
117 local_compute_div_face(dealii::MatrixFree<dim, Number> const & data,
118 std::vector<Number> & dst,
119 VectorType const & source,
120 const std::pair<unsigned int, unsigned int> & face_range);
121
122 // not needed
123 void
124 local_compute_div_boundary_face(dealii::MatrixFree<dim, Number> const &,
125 std::vector<Number> &,
126 VectorType const &,
127 const std::pair<unsigned int, unsigned int> &);
128
129 void
130 analyze_div_and_mass_error_unsteady(VectorType const & velocity, double const time);
131
132 void
133 analyze_div_and_mass_error_steady(VectorType const & velocity);
134
135 MPI_Comm const mpi_comm;
136
137 bool clear_files_mass_error;
138 int number_of_samples;
139 Number divergence_sample;
140 Number mass_sample;
141
142 dealii::MatrixFree<dim, Number> const * matrix_free;
143 unsigned int dof_index, quad_index;
145};
146
147
148} // namespace IncNS
149} // namespace ExaDG
150
151#endif /* INCLUDE_EXADG_INCOMPRESSIBLE_NAVIER_STOKES_POSTPROCESSOR_DIVERGENCE_AND_MASS_ERROR_H_ */
Definition divergence_and_mass_error.h:64
Definition time_control.h:64
Definition driver.cpp:33
Definition divergence_and_mass_error.h:38
Definition time_control.h:40