ExaDG
Loading...
Searching...
No Matches
operator_base.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_OPERATORS_OPERATOR_BASE_H_
23#define EXADG_OPERATORS_OPERATOR_BASE_H_
24
25// deal.II
26#include <deal.II/base/subscriptor.h>
27#include <deal.II/dofs/dof_handler.h>
28#include <deal.II/lac/affine_constraints.h>
29#include <deal.II/lac/la_parallel_vector.h>
30#include <deal.II/lac/lapack_full_matrix.h>
31#ifdef DEAL_II_WITH_TRILINOS
32# include <deal.II/lac/trilinos_sparse_matrix.h>
33#endif
34#ifdef DEAL_II_WITH_PETSC
35# include <deal.II/lac/petsc_sparse_matrix.h>
36#endif
37#include <deal.II/matrix_free/matrix_free.h>
38
39// ExaDG
40#include <exadg/matrix_free/categorization.h>
41#include <exadg/matrix_free/integrators.h>
42
43#include <exadg/solvers_and_preconditioners/preconditioners/elementwise_preconditioners.h>
44#include <exadg/solvers_and_preconditioners/preconditioners/enum_types.h>
45#include <exadg/solvers_and_preconditioners/solvers/enum_types.h>
46#include <exadg/solvers_and_preconditioners/solvers/wrapper_elementwise_solvers.h>
47#include <exadg/solvers_and_preconditioners/utilities/invert_diagonal.h>
48
49#include <exadg/utilities/lazy_ptr.h>
50
51#include <exadg/operators/elementwise_operator.h>
52#include <exadg/operators/enum_types.h>
53#include <exadg/operators/integrator_flags.h>
54#include <exadg/operators/mapping_flags.h>
55#include <exadg/operators/operator_type.h>
56
57namespace ExaDG
58{
59struct OperatorBaseData
60{
61 OperatorBaseData()
62 : dof_index(0),
63 dof_index_inhomogeneous(dealii::numbers::invalid_unsigned_int),
64 quad_index(0),
65 use_matrix_based_operator_level(false),
66 sparse_matrix_type(SparseMatrixType::Undefined),
67 operator_is_singular(false),
68 use_cell_based_loops(false),
69 implement_block_diagonal_preconditioner_matrix_free(false),
70 solver_block_diagonal(Elementwise::Solver::GMRES),
71 preconditioner_block_diagonal(Elementwise::Preconditioner::InverseMassMatrix),
72 solver_data_block_diagonal(SolverData(1000, 1.e-12, 1.e-2, 1000))
73 {
74 }
75
76 unsigned int dof_index;
77
78 // In addition to the "standard" dof_index above, we need a separate dof index to evaluate
79 // inhomogeneous boundary data correctly. This "inhomogeneous" dof index corresponds to an
80 // AffineConstraints object that only applies periodicity and hanging node constraints.
81 unsigned int dof_index_inhomogeneous;
82
83 unsigned int quad_index;
84
85 // this parameter can be used to use sparse matrices for the vmult() operation. The default
86 // case is to use a matrix-free implementation, i.e. use_matrix_based_operator_level = false.
87 bool use_matrix_based_operator_level;
88
89 SparseMatrixType sparse_matrix_type;
90
91 // Solution of linear systems of equations and preconditioning
92 bool operator_is_singular;
93
94 bool use_cell_based_loops;
95
96 // block Jacobi preconditioner
97 bool implement_block_diagonal_preconditioner_matrix_free;
98
99 // elementwise iterative solution of block Jacobi problems
100 Elementwise::Solver solver_block_diagonal;
101 Elementwise::Preconditioner preconditioner_block_diagonal;
102 SolverData solver_data_block_diagonal;
103};
104
105template<int dim, typename Number, int n_components = 1>
106class OperatorBase : public dealii::EnableObserverPointer
107{
108public:
109 typedef OperatorBase<dim, Number, n_components> This;
110
111 typedef dealii::LinearAlgebra::distributed::Vector<Number> VectorType;
112 typedef std::pair<unsigned int, unsigned int> Range;
113 typedef CellIntegrator<dim, n_components, Number> IntegratorCell;
114 typedef FaceIntegrator<dim, n_components, Number> IntegratorFace;
115
116 static unsigned int const dimension = dim;
117 static unsigned int const vectorization_length = dealii::VectorizedArray<Number>::size();
118
119 typedef dealii::LAPACKFullMatrix<Number> LAPACKMatrix;
120
121 typedef dealii::FullMatrix<dealii::TrilinosScalar> FullMatrix_;
122
123 OperatorBase();
124
125 virtual ~OperatorBase()
126 {
127 if(data.sparse_matrix_type == SparseMatrixType::PETSc)
128 {
129#ifdef DEAL_II_WITH_PETSC
130 if(system_matrix_petsc.m() > 0)
131 {
132 PetscErrorCode ierr = VecDestroy(&petsc_vector_dst);
133 AssertThrow(ierr == 0, dealii::ExcPETScError(ierr));
134 ierr = VecDestroy(&petsc_vector_src);
135 AssertThrow(ierr == 0, dealii::ExcPETScError(ierr));
136 }
137#endif
138 }
139 }
140
141 /*
142 * Getters and setters.
143 */
144 void
145 set_time(double const time) const;
146
147 double
148 get_time() const;
149
150 unsigned int
151 get_level() const;
152
153 dealii::AffineConstraints<Number> const &
154 get_affine_constraints() const;
155
156 dealii::MatrixFree<dim, Number> const &
157 get_matrix_free() const;
158
159 unsigned int
160 get_dof_index() const;
161
162 unsigned int
163 get_dof_index_inhomogeneous() const;
164
165 unsigned int
166 get_quad_index() const;
167
168 /*
169 * Returns whether the operator is singular, e.g., the Laplace operator with pure Neumann boundary
170 * conditions is singular.
171 */
172 bool
173 operator_is_singular() const;
174
175 void
176 vmult(VectorType & dst, VectorType const & src) const;
177
178 void
179 vmult_add(VectorType & dst, VectorType const & src) const;
180
181 void
182 vmult_interface_down(VectorType & dst, VectorType const & src) const;
183
184 void
185 vmult_add_interface_up(VectorType & dst, VectorType const & src) const;
186
187 dealii::types::global_dof_index
188 m() const;
189
190 dealii::types::global_dof_index
191 n() const;
192
193 Number
194 el(unsigned int const, unsigned int const) const;
195
196 bool
197 is_empty_locally() const;
198
199 void
200 initialize_dof_vector(VectorType & vector) const;
201
202 /*
203 * For time-dependent problems, the function set_time() needs to be called prior to the present
204 * function.
205 */
206 virtual void
207 set_inhomogeneous_constrained_values(VectorType & solution) const;
208
209 void
210 set_constrained_dofs_to_zero(VectorType & vector) const;
211
212 void
213 calculate_inverse_diagonal(VectorType & diagonal) const;
214
215 /*
216 * Initialize block diagonal preconditioner: initialize everything related to block diagonal
217 * preconditioner.
218 */
219 void
220 initialize_block_diagonal_preconditioner(bool const initialize) const;
221
222 /*
223 * Update block diagonal preconditioner: Recompute block matrices in case of matrix-based
224 * implementation.
225 */
226 void
227 update_block_diagonal_preconditioner() const;
228
233 void
234 apply_inverse_block_diagonal(VectorType & dst, VectorType const & src) const;
235
236 /*
237 * Algebraic multigrid (AMG): sparse matrix (Trilinos) methods
238 */
239#ifdef DEAL_II_WITH_TRILINOS
240 void
241 init_system_matrix(dealii::TrilinosWrappers::SparseMatrix & system_matrix,
242 MPI_Comm const & mpi_comm) const;
243
244 void
245 calculate_system_matrix(dealii::TrilinosWrappers::SparseMatrix & system_matrix) const;
246#endif
247
248 /*
249 * Algebraic multigrid (AMG): sparse matrix (PETSc) methods
250 */
251#ifdef DEAL_II_WITH_PETSC
252 void
253 init_system_matrix(dealii::PETScWrappers::MPI::SparseMatrix & system_matrix,
254 MPI_Comm const & mpi_comm) const;
255
256 void
257 calculate_system_matrix(dealii::PETScWrappers::MPI::SparseMatrix & system_matrix) const;
258#endif
259
260 /*
261 * Provide near null space basis vectors used e.g. in AMG setup. ExaDG assumes a scalar Laplace
262 * operator as default, filling `constant_modes`, which can be overwritten in derived classes if
263 * necessary. `constant_modes_values` may alternatively be used to provide non-trivial modes.
264 */
265 virtual void
266 get_constant_modes(std::vector<std::vector<bool>> & constant_modes,
267 std::vector<std::vector<double>> & constant_modes_values) const;
268
269 /*
270 * Evaluate the homogeneous part of an operator. The homogeneous operator is the operator that is
271 * obtained for homogeneous boundary conditions. This operation is typically applied in linear
272 * iterative solvers (as well as multigrid preconditioners and smoothers). Operations of this type
273 * are called apply_...() and vmult_...() as required by deal.II interfaces.
274 */
275 void
276 apply(VectorType & dst, VectorType const & src) const;
277
278 /*
279 * See function apply() for a description.
280 */
281 void
282 apply_add(VectorType & dst, VectorType const & src) const;
283
284 void
285 assemble_matrix_if_matrix_based() const;
286
287 /*
288 * Matrix-based version of the apply function. This function is used if
289 * use_matrix_based_operator_level = true.
290 */
291 void
292 apply_matrix_based(VectorType & dst, VectorType const & src) const;
293
294 /*
295 * See function apply_matrix_based() for a description.
296 */
297 void
298 apply_matrix_based_add(VectorType & dst, VectorType const & src) const;
299
300 /*
301 * evaluate inhomogeneous parts of operator related to inhomogeneous boundary face integrals.
302 * Operations of this type are called rhs_...() since these functions are called to calculate the
303 * vector forming the right-hand side vector of linear systems of equations. Functions of type
304 * rhs only make sense for linear operators (but they have e.g. no meaning for linearized
305 * operators of nonlinear problems). For this reason, these functions are currently defined
306 * 'virtual' to provide the opportunity to override and assert these functions in derived classes.
307 *
308 * For continuous Galerkin discretizations, this function calls internally the member function
309 * set_inhomogeneous_constrained_values(). Hence, prior to calling this function, one needs to
310 * call set_time() for a correct evaluation in case of time-dependent problems.
311 *
312 * This function sets the dst vector to zero, and afterwards calls rhs_add().
313 */
314 virtual void
315 rhs(VectorType & dst) const;
316
317 /*
318 * See function rhs() for a description.
319 */
320 virtual void
321 rhs_add(VectorType & dst) const;
322
323 /*
324 * Evaluate the operator including homogeneous and inhomogeneous contributions. The typical use
325 * case would be explicit time integration where a splitting into homogeneous and inhomogeneous
326 * contributions is not required. Functions of type evaluate only make sense for linear operators
327 * (but they have e.g. no meaning for linearized operators of nonlinear problems). For this
328 * reason, these functions are currently defined 'virtual' to provide the opportunity to override
329 * and assert these functions in derived classes.
330 *
331 * Unlike the function rhs(), this function does not internally call the function
332 * set_inhomogeneous_constrained_values() prior to evaluation. Hence, one needs to explicitly call
333 * the function set_inhomogeneous_constrained_values() in case of continuous Galerkin
334 * discretizations with inhomogeneous Dirichlet boundary conditions before calling the present
335 * function.
336 */
337 virtual void
338 evaluate(VectorType & dst, VectorType const & src) const;
339
340 /*
341 * See function evaluate() for a description.
342 */
343 virtual void
344 evaluate_add(VectorType & dst, VectorType const & src) const;
345
346 /*
347 * point Jacobi preconditioner (diagonal)
348 */
349 void
350 calculate_diagonal(VectorType & diagonal) const;
351
352 void
353 add_diagonal(VectorType & diagonal) const;
354
355 /*
356 * block Jacobi preconditioner (block-diagonal)
357 */
358 void
359 add_block_diagonal_matrices(std::vector<LAPACKMatrix> & matrices) const;
360
361 void
362 apply_inverse_block_diagonal_matrix_based(VectorType & dst, VectorType const & src) const;
363
364 // matrix-free implementation
365
366 // This function has to initialize everything related to the block diagonal preconditioner when
367 // using the matrix-free variant with elementwise iterative solvers and matrix-free operator
368 // evaluation.
369 void
370 initialize_block_diagonal_preconditioner_matrix_free(bool const initialize) const;
371
372 // updates block diagonal preconditioner when using the matrix-free variant with elementwise
373 // iterative solvers and matrix-free operator evaluation.
374 void
375 update_block_diagonal_preconditioner_matrix_free() const;
376
377 // initializes block diagonal preconditioner for matrix-based variant
378 void
379 initialize_block_diagonal_preconditioner_matrix_based(bool const initialize) const;
380
381 // updates block diagonal preconditioner for matrix-based variant
382 void
383 update_block_diagonal_preconditioner_matrix_based() const;
384
385 void
386 apply_add_block_diagonal_elementwise(unsigned int const cell,
387 dealii::VectorizedArray<Number> * const dst,
388 dealii::VectorizedArray<Number> const * const src,
389 unsigned int const problem_size) const;
390
391 /*
392 * additive Schwarz preconditioner (cellwise block-diagonal)
393 */
394 virtual void
395 compute_factorized_additive_schwarz_matrices() const;
396
397 void
398 apply_inverse_additive_schwarz_matrices(VectorType & dst, VectorType const & src) const;
399
400protected:
401 void
402 reinit(dealii::MatrixFree<dim, Number> const & matrix_free,
403 dealii::AffineConstraints<Number> const & constraints,
404 OperatorBaseData const & data);
405
406 void
407 reinit_cell(IntegratorCell & integrator, unsigned int const cell) const;
408
409 void
410 reinit_face(IntegratorFace & integrator_m,
411 IntegratorFace & integrator_p,
412 unsigned int const face) const;
413
414 void
415 reinit_boundary_face(IntegratorFace & integrator_m, unsigned int const face) const;
416
417 void
418 reinit_face_cell_based(IntegratorFace & integrator_m,
419 IntegratorFace & integrator_p,
420 unsigned int const cell,
421 unsigned int const face,
422 dealii::types::boundary_id const boundary_id) const;
423
424 /*
425 * These methods have to be overwritten by derived classes because these functions are
426 * operator-specific and define how the operator looks like.
427 */
428
429 // standard integration procedure with separate loops for cell and face integrals
430 virtual void
431 do_cell_integral(IntegratorCell & integrator) const;
432
433 virtual void
434 do_face_integral(IntegratorFace & integrator_m, IntegratorFace & integrator_p) const;
435
436 virtual void
437 do_boundary_integral(IntegratorFace & integrator,
438 OperatorType const & operator_type,
439 dealii::types::boundary_id const & boundary_id) const;
440
441 virtual void
442 do_boundary_integral_continuous(IntegratorFace & integrator,
443 dealii::types::boundary_id const & boundary_id) const;
444
445 // The computation of the diagonal and block-diagonal requires face integrals of type
446 // interior (int) and exterior (ext)
447 virtual void
448 do_face_int_integral(IntegratorFace & integrator_m, IntegratorFace & integrator_p) const;
449
450 virtual void
451 do_face_ext_integral(IntegratorFace & integrator_m, IntegratorFace & integrator_p) const;
452
453 // This function is currently only needed due to limitations of deal.II which do
454 // currently not allow to access neighboring data in case of cell-based face loops.
455 // Once this functionality is available, this function should be removed again.
456 // Since only special operators need to evaluate neighboring data, this function
457 // simply redirects to do_face_int_integral() if this function is not overwritten
458 // by a derived class (such as convective terms that require an additional
459 // evaluation of velocity fields for example).
460 virtual void
461 do_face_int_integral_cell_based(IntegratorFace & integrator_m,
462 IntegratorFace & integrator_p) const;
463
464 /*
465 * Matrix-free object.
466 */
468
469 /*
470 * Physical time (required for time-dependent problems).
471 */
472 mutable double time;
473
474 /*
475 * Constraint matrix.
476 */
478
479 mutable dealii::AffineConstraints<double> constraint_double;
480
481 /*
482 * Cell and face integrator flags.
483 */
484 IntegratorFlags integrator_flags;
485
486private:
487 /*
488 * Is the operator used as a multigrid level operator?
489 */
490 bool is_mg;
491
492protected:
493 /*
494 * Is the discretization based on discontinuous Galerkin method?
495 */
496 bool is_dg;
497
498 /*
499 * Block Jacobi preconditioner/smoother: matrix-free version with elementwise iterative solver
500 */
501 typedef Elementwise::OperatorBase<dim, Number, This> ElementwiseOperator;
503 ElementwisePreconditionerBase;
504 typedef Elementwise::
505 IterativeSolver<dim, n_components, Number, ElementwiseOperator, ElementwisePreconditionerBase>
506 ElementwiseSolver;
507
508 mutable std::shared_ptr<ElementwiseOperator> elementwise_operator;
509 mutable std::shared_ptr<ElementwisePreconditionerBase> elementwise_preconditioner;
510 mutable std::shared_ptr<ElementwiseSolver> elementwise_solver;
511
512private:
513 virtual void
514 reinit_cell_derived(IntegratorCell & integrator, unsigned int const cell) const;
515
516 virtual void
517 reinit_face_derived(IntegratorFace & integrator_m,
518 IntegratorFace & integrator_p,
519 unsigned int const face) const;
520
521 virtual void
522 reinit_boundary_face_derived(IntegratorFace & integrator_m, unsigned int const face) const;
523
524 virtual void
525 reinit_face_cell_based_derived(IntegratorFace & integrator_m,
526 IntegratorFace & integrator_p,
527 unsigned int const cell,
528 unsigned int const face,
529 dealii::types::boundary_id const boundary_id) const;
530
531 /*
532 * Helper functions:
533 *
534 * The diagonal, block-diagonal, as well as the system matrix (assembled into a sparse matrix) are
535 * computed columnwise. This means that column i of the block-matrix is computed by evaluating the
536 * operator for a unit vector which takes a value of 1 in row i and is 0 for all other entries.
537 */
538 void
539 create_standard_basis(unsigned int j, IntegratorCell & integrator) const;
540
541 void
542 create_standard_basis(unsigned int j, IntegratorFace & integrator) const;
543
544 void
545 create_standard_basis(unsigned int j,
546 IntegratorFace & integrator_1,
547 IntegratorFace & integrator_2) const;
548
549 /*
550 * This function calculates cell integrals for the full (= homogeneous + inhomogeneous) part,
551 * where inhomogeneous part may occur for continuous Galerkin discretizations due to inhomogeneous
552 * Dirichlet BCs. A prerequisite to call this function is to set inhomogeneous Dirichlet degrees
553 * of freedom appropriately in the DoF-vector src. In case the DoF-vector src is zero apart from
554 * the inhomogeneous Dirichlet degrees of freedom, this function calculates only the inhomogeneous
555 * part of the operator, because the homogeneous operator is zero in this case. For DG
556 * discretizations, this function is equivalent to cell_loop().
557 */
558 void
559 cell_loop_full_operator(dealii::MatrixFree<dim, Number> const & matrix_free,
560 VectorType & dst,
561 VectorType const & src,
562 Range const & range) const;
563
564 /*
565 * This function loops over all cells and calculates cell integrals.
566 */
567 void
568 cell_loop(dealii::MatrixFree<dim, Number> const & matrix_free,
569 VectorType & dst,
570 VectorType const & src,
571 Range const & range) const;
572
573 /*
574 * This function loops over all interior faces and calculates face integrals.
575 */
576 void
577 face_loop(dealii::MatrixFree<dim, Number> const & matrix_free,
578 VectorType & dst,
579 VectorType const & src,
580 Range const & range) const;
581
582 /*
583 * The following functions loop over all boundary faces and calculate boundary face integrals.
584 * Depending on the operator type, we distinguish between boundary face integrals of type
585 * homogeneous, inhomogeneous, and full.
586 */
587
588 // homogeneous operator
589 void
590 boundary_face_loop_hom_operator(dealii::MatrixFree<dim, Number> const & matrix_free,
591 VectorType & dst,
592 VectorType const & src,
593 Range const & range) const;
594
595 // inhomogeneous operator
596 void
597 boundary_face_loop_inhom_operator(dealii::MatrixFree<dim, Number> const & matrix_free,
598 VectorType & dst,
599 VectorType const & src,
600 Range const & range) const;
601
602 // full operator
603 void
604 boundary_face_loop_full_operator(dealii::MatrixFree<dim, Number> const & matrix_free,
605 VectorType & dst,
606 VectorType const & src,
607 Range const & range) const;
608
609 /*
610 * inhomogeneous operator: For the inhomogeneous operator, we only have to calculate boundary face
611 * integrals. The matrix-free implementation, however, does not offer interfaces for boundary face
612 * integrals only. Hence we have to provide empty functions for cell and interior face integrals.
613 */
614 void
615 cell_loop_empty(dealii::MatrixFree<dim, Number> const & matrix_free,
616 VectorType & dst,
617 VectorType const & src,
618 Range const & range) const;
619
620 void
621 face_loop_empty(dealii::MatrixFree<dim, Number> const & matrix_free,
622 VectorType & dst,
623 VectorType const & src,
624 Range const & range) const;
625
626 /*
627 * Calculate diagonal.
628 */
629 void
630 cell_loop_diagonal(dealii::MatrixFree<dim, Number> const & matrix_free,
631 VectorType & dst,
632 VectorType const & src,
633 Range const & range) const;
634
635 void
636 face_loop_diagonal(dealii::MatrixFree<dim, Number> const & matrix_free,
637 VectorType & dst,
638 VectorType const & src,
639 Range const & range) const;
640
641 void
642 boundary_face_loop_diagonal(dealii::MatrixFree<dim, Number> const & matrix_free,
643 VectorType & dst,
644 VectorType const & src,
645 Range const & range) const;
646
647 void
648 cell_based_loop_diagonal(dealii::MatrixFree<dim, Number> const & matrix_free,
649 VectorType & dst,
650 VectorType const & src,
651 Range const & range) const;
652
653 /*
654 * Calculate (assemble) block diagonal.
655 */
656 void
657 cell_loop_block_diagonal(dealii::MatrixFree<dim, Number> const & matrix_free,
658 std::vector<LAPACKMatrix> & matrices,
659 std::vector<LAPACKMatrix> const & src,
660 Range const & range) const;
661
662 void
663 face_loop_block_diagonal(dealii::MatrixFree<dim, Number> const & matrix_free,
664 std::vector<LAPACKMatrix> & matrices,
665 std::vector<LAPACKMatrix> const & src,
666 Range const & range) const;
667
668 void
669 boundary_face_loop_block_diagonal(dealii::MatrixFree<dim, Number> const & matrix_free,
670 std::vector<LAPACKMatrix> & matrices,
671 std::vector<LAPACKMatrix> const & src,
672 Range const & range) const;
673
674 // cell-based variant for computation of both cell and face integrals
675 void
676 cell_based_loop_block_diagonal(dealii::MatrixFree<dim, Number> const & matrix_free,
677 std::vector<LAPACKMatrix> & matrices,
678 std::vector<LAPACKMatrix> const & src,
679 Range const & range) const;
680
681 /*
682 * Apply inverse block diagonal:
683 *
684 * we compute dst = B^{-1} * src
685 */
686 void
687 cell_loop_apply_inverse_block_diagonal_matrix_based(
688 dealii::MatrixFree<dim, Number> const & matrix_free,
689 VectorType & dst,
690 VectorType const & src,
691 Range const & range) const;
692
693 /*
694 * Set up sparse matrix internally for templated matrix type (Trilinos or
695 * PETSc matrices)
696 */
697 template<typename SparseMatrix>
698 void
699 internal_init_system_matrix(SparseMatrix & system_matrix,
700 dealii::DynamicSparsityPattern & dsp,
701 MPI_Comm const & mpi_comm) const;
702
703 template<typename SparseMatrix>
704 void
705 internal_calculate_system_matrix(SparseMatrix & system_matrix) const;
706
707 /*
708 * Calculate sparse matrix.
709 */
710 template<typename SparseMatrix>
711 void
712 cell_loop_calculate_system_matrix(dealii::MatrixFree<dim, Number> const & matrix_free,
713 SparseMatrix & dst,
714 SparseMatrix const & src,
715 Range const & range) const;
716
717 template<typename SparseMatrix>
718 void
719 face_loop_calculate_system_matrix(dealii::MatrixFree<dim, Number> const & matrix_free,
720 SparseMatrix & dst,
721 SparseMatrix const & src,
722 Range const & range) const;
723
724 template<typename SparseMatrix>
725 void
726 boundary_face_loop_calculate_system_matrix(dealii::MatrixFree<dim, Number> const & matrix_free,
727 SparseMatrix & dst,
728 SparseMatrix const & src,
729 Range const & range) const;
730
731 /*
732 * This function sets entries of the DoF-vector corresponding to constraint DoFs to one.
733 */
734 void
735 set_constrained_dofs_to_one(VectorType & vector) const;
736
737 /*
738 * Do we have to evaluate (boundary) face integrals for this operator? For example, operators
739 * such as the mass operator only involve cell integrals.
740 */
741 bool
742 evaluate_face_integrals() const;
743
744 /*
745 * Compute factorized additive Schwarz matrices.
746 */
747 template<typename SparseMatrix>
748 void
749 internal_compute_factorized_additive_schwarz_matrices() const;
750
751 /*
752 * Data structure containing all operator-specific data.
753 */
754 OperatorBaseData data;
755
756 /*
757 * Multigrid level: 0 <= level <= max_level. If the operator is not used as a multigrid
758 * level operator, this variable takes a value of dealii::numbers::invalid_unsigned_int.
759 */
760 unsigned int level;
761
762 /*
763 * Vector of matrices for block-diagonal preconditioners.
764 */
765 mutable std::vector<LAPACKMatrix> matrices;
766
767 /*
768 * Vector with weights for additive Schwarz preconditioner.
769 */
770 mutable VectorType weights;
771
772 unsigned int n_mpi_processes;
773
774 // sparse matrices for matrix-based vmult
775 mutable bool system_matrix_based_been_initialized;
776
777#ifdef DEAL_II_WITH_TRILINOS
778 mutable dealii::TrilinosWrappers::SparseMatrix system_matrix_trilinos;
779#endif
780
781#ifdef DEAL_II_WITH_PETSC
782 mutable dealii::PETScWrappers::MPI::SparseMatrix system_matrix_petsc;
783
784 // PETSc vector objects to avoid re-allocation in every vmult() operation
785 mutable Vec petsc_vector_src;
786 mutable Vec petsc_vector_dst;
787#endif
788};
789
790} // namespace ExaDG
791
792#endif /* EXADG_OPERATORS_OPERATOR_BASE_H_ */
Definition elementwise_operator.h:34
Definition elementwise_preconditioners.h:41
void apply_inverse_block_diagonal(VectorType &dst, VectorType const &src) const
Definition operator_base.cpp:676
Definition lazy_ptr.h:29
Definition driver.cpp:33
Definition integrator_flags.h:31
Definition operator_base.h:60
Definition solver_data.h:34