ExaDG
Loading...
Searching...
No Matches
project_velocity.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 EXADG_CONVECTION_DIFFUSION_SPATIAL_DISCRETIZATION_PROJECT_VELOCITY_H_
23#define EXADG_CONVECTION_DIFFUSION_SPATIAL_DISCRETIZATION_PROJECT_VELOCITY_H_
24
25// ExaDG
26#include <exadg/functions_and_boundary_conditions/evaluate_functions.h>
27#include <exadg/matrix_free/integrators.h>
28#include <exadg/operators/inverse_mass_operator.h>
29
30namespace ExaDG
31{
32template<int dim, typename Number>
34{
35private:
36 typedef dealii::LinearAlgebra::distributed::Vector<Number> VectorType;
37
38 typedef CellIntegrator<dim, dim, Number> IntegratorCell;
39
40 typedef std::pair<unsigned int, unsigned int> Range;
41
42public:
43 /*
44 * (v_h, u_h)_Omega^e = (v_h, f)_Omega^e -> M * U = RHS -> U = M^{-1} * RHS
45 */
46 void
47 apply(dealii::MatrixFree<dim, Number> const & matrix_free,
48 InverseMassOperatorData<Number> const inverse_mass_operator_data,
49 std::shared_ptr<dealii::Function<dim>> const function,
50 double const & time,
51 VectorType & vector)
52 {
53 this->dof_index = inverse_mass_operator_data.dof_index;
54 this->quad_index = inverse_mass_operator_data.quad_index;
55 this->function = function;
56 this->time = time;
57
58 // calculate RHS
59 VectorType src;
60 matrix_free.cell_loop(&VelocityProjection<dim, Number>::cell_loop, this, vector, src);
61
62 // construct and apply M^{-1}
64 inverse_mass.initialize(matrix_free, inverse_mass_operator_data);
65 inverse_mass.apply(vector, vector);
66 }
67
68private:
69 void
70 cell_loop(dealii::MatrixFree<dim, Number> const & matrix_free,
71 VectorType & dst,
72 VectorType const & src,
73 Range const & cell_range) const
74 {
75 (void)src;
76
77 IntegratorCell integrator(matrix_free, dof_index, quad_index);
78
79 for(unsigned int cell = cell_range.first; cell < cell_range.second; ++cell)
80 {
81 integrator.reinit(cell);
82
83 for(unsigned int q = 0; q < integrator.n_q_points; ++q)
84 {
85 integrator.submit_value(
86 FunctionEvaluator<1, dim, Number>::value(*function, integrator.quadrature_point(q), time),
87 q);
88 }
89
90 integrator.integrate(dealii::EvaluationFlags::values);
91
92 integrator.distribute_local_to_global(dst);
93 }
94 }
95
96 unsigned int dof_index;
97 unsigned int quad_index;
98 std::shared_ptr<dealii::Function<dim>> function;
99 double time;
100};
101
102} // namespace ExaDG
103
104#endif /* EXADG_CONVECTION_DIFFUSION_SPATIAL_DISCRETIZATION_PROJECT_VELOCITY_H_ */
Definition inverse_mass_operator.h:70
Definition project_velocity.h:34
Definition driver.cpp:33
Definition inverse_mass_operator.h:41