ExaDG
Loading...
Searching...
No Matches
operator.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_LAPLACE_DG_LAPLACE_OPERATION_H_
23#define INCLUDE_LAPLACE_DG_LAPLACE_OPERATION_H_
24
25// ExaDG
26#include <exadg/grid/grid.h>
27#include <exadg/matrix_free/matrix_free_data.h>
28#include <exadg/operators/rhs_operator.h>
29#include <exadg/poisson/spatial_discretization/laplace_operator.h>
30#include <exadg/poisson/user_interface/analytical_solution.h>
31#include <exadg/poisson/user_interface/boundary_descriptor.h>
32#include <exadg/poisson/user_interface/field_functions.h>
33#include <exadg/poisson/user_interface/parameters.h>
34#include <exadg/solvers_and_preconditioners/preconditioners/preconditioner_base.h>
35
36namespace ExaDG
37{
38namespace Poisson
39{
40template<int dim, int n_components, typename Number>
41class Operator : public dealii::Subscriptor
42{
43private:
44 static unsigned int const rank =
45 (n_components == 1) ? 0 : ((n_components == dim) ? 1 : dealii::numbers::invalid_unsigned_int);
46
48
49 typedef dealii::LinearAlgebra::distributed::Vector<Number> VectorType;
50 typedef dealii::LinearAlgebra::distributed::Vector<double> VectorTypeDouble;
51
52public:
53 Operator(std::shared_ptr<Grid<dim> const> grid,
54 std::shared_ptr<dealii::Mapping<dim> const> mapping,
55 std::shared_ptr<MultigridMappings<dim, Number>> const multigrid_mappings,
56 std::shared_ptr<BoundaryDescriptor<rank, dim> const> boundary_descriptor,
57 std::shared_ptr<FieldFunctions<dim> const> field_functions,
58 Parameters const & param,
59 std::string const & field,
60 MPI_Comm const & mpi_comm);
61
62 void
63 fill_matrix_free_data(MatrixFreeData<dim, Number> & matrix_free_data) const;
64
68 void
69 setup();
70
76 void
77 setup(std::shared_ptr<dealii::MatrixFree<dim, Number> const> matrix_free,
78 std::shared_ptr<MatrixFreeData<dim, Number> const> matrix_free_data);
79
80 void
81 initialize_dof_vector(VectorType & src) const;
82
83 /*
84 * Prescribe initial conditions using a specified analytical function.
85 */
86 void
87 prescribe_initial_conditions(VectorType & src) const;
88
89 void
90 rhs(VectorType & dst, double const time = 0.0) const;
91
92 void
93 vmult(VectorType & dst, VectorType const & src) const;
94
95 void
96 evaluate(VectorType & dst, VectorType const & src, double const time = 0.0) const;
97
98 unsigned int
99 solve(VectorType & sol, VectorType const & rhs, double const time) const;
100
101 /*
102 * Setters and getters.
103 */
104
105 std::shared_ptr<dealii::MatrixFree<dim, Number> const>
106 get_matrix_free() const;
107
108 dealii::DoFHandler<dim> const &
109 get_dof_handler() const;
110
111 dealii::types::global_dof_index
112 get_number_of_dofs() const;
113
114 double
115 get_n10() const;
116
117 double
118 get_average_convergence_rate() const;
119
120 // Multiphysics coupling via "Cached" boundary conditions
121 std::shared_ptr<ContainerInterfaceData<rank, dim, double>>
122 get_container_interface_data() const;
123
124 std::shared_ptr<TimerTree>
125 get_timings() const;
126
127 std::shared_ptr<dealii::Mapping<dim> const>
128 get_mapping() const;
129
130 // TODO: we currently need this function public for precice-based FSI
131 unsigned int
132 get_dof_index() const;
133
134 unsigned int
135 get_quad_index() const;
136
137private:
138 std::string
139 get_dof_name() const;
140
141 unsigned int
142 get_dof_index_periodicity_and_hanging_node_constraints() const;
143
144 std::string
145 get_dof_name_periodicity_and_hanging_node_constraints() const;
146
147 std::string
148 get_quad_name() const;
149
150 std::string
151 get_quad_gauss_lobatto_name() const;
152
153 unsigned int
154 get_quad_index_gauss_lobatto() const;
155
156 void
157 initialize_dof_handler_and_constraints();
158
159 void
160 setup_coupling_boundary_conditions();
161
162 void
163 setup_operators();
164
165 void
166 setup_preconditioner_and_solver();
167
168 /*
169 * Grid
170 */
171 std::shared_ptr<Grid<dim> const> grid;
172
173 /*
174 * Mapping
175 */
176 std::shared_ptr<dealii::Mapping<dim> const> mapping;
177
178 std::shared_ptr<MultigridMappings<dim, Number>> const multigrid_mappings;
179
180 /*
181 * User interface: Boundary conditions and field functions.
182 */
183 std::shared_ptr<BoundaryDescriptor<rank, dim> const> boundary_descriptor;
184 std::shared_ptr<FieldFunctions<dim> const> field_functions;
185
186 /*
187 * List of parameters.
188 */
189 Parameters const & param;
190
191 std::string const field;
192
193 /*
194 * Basic finite element ingredients.
195 */
196 std::shared_ptr<dealii::FiniteElement<dim>> fe;
197
198 dealii::DoFHandler<dim> dof_handler;
199
200 // This AffineConstraints object applies homogeneous boundary conditions as needed by vmult()/
201 // apply() functions in iterative solvers for linear systems of equations and preconditioners
202 // such as multigrid, implemented via dealii::MatrixFree and FEEvaluation::read_dof_values()
203 // (or gather_evaluate()).
204 // To deal with inhomogeneous boundary data, a separate object of type AffineConstraints is
205 // needed (see below).
206 mutable dealii::AffineConstraints<Number> affine_constraints;
207
208 // To treat inhomogeneous Dirichlet BCs correctly in the context of matrix-free operator
209 // evaluation using dealii::MatrixFree/FEEvaluation, we need a separate AffineConstraints
210 // object containing only periodicity and hanging node constraints. This is only relevant
211 // for continuous Galerkin discretizations.
212 dealii::AffineConstraints<Number> affine_constraints_periodicity_and_hanging_nodes;
213
214 std::string const dof_index = "dof";
215 std::string const dof_index_periodicity_and_handing_node_constraints =
216 "dof_periodicity_hanging_nodes";
217
218 std::string const quad_index = "quad";
219 std::string const quad_index_gauss_lobatto = "quad_gauss_lobatto";
220
221 std::shared_ptr<dealii::MatrixFree<dim, Number> const> matrix_free;
222 std::shared_ptr<MatrixFreeData<dim, Number> const> matrix_free_data;
223
224 /*
225 * Interface coupling
226 */
227 // TODO: The PDE operator should only have read access to interface data
228 mutable std::shared_ptr<ContainerInterfaceData<rank, dim, double>>
229 interface_data_dirichlet_cached;
230
232
233 Laplace laplace_operator;
234
235 std::shared_ptr<PreconditionerBase<Number>> preconditioner;
236 std::shared_ptr<Krylov::SolverBase<VectorType>> iterative_solver;
237
238 /*
239 * MPI
240 */
241 MPI_Comm const mpi_comm;
242
243 /*
244 * Output to screen.
245 */
246 dealii::ConditionalOStream pcout;
247};
248} // namespace Poisson
249} // namespace ExaDG
250
251#endif
Definition grid.h:40
Definition grid.h:84
Definition laplace_operator.h:229
Definition operator.h:42
void setup()
Definition operator.cpp:259
Definition parameters.h:36
Definition rhs_operator.h:107
Definition driver.cpp:33
Definition matrix_free_data.h:40
Definition boundary_descriptor.h:46
Definition field_functions.h:30