ASPECT
stokes_matrix_free_global_coarsening.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2011 - 2025 by the authors of the ASPECT code.
3 
4  This file is part of ASPECT.
5 
6  ASPECT is free software; you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation; either version 2, or (at your option)
9  any later version.
10 
11  ASPECT is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with ASPECT; see the file LICENSE. If not see
18  <http://www.gnu.org/licenses/>.
19 */
20 
21 #ifndef _aspect_simulator_solver_stokes_matrix_free_global_coarsening_h
22 #define _aspect_simulator_solver_stokes_matrix_free_global_coarsening_h
23 
24 #include <aspect/global.h>
27 
28 #include <deal.II/matrix_free/matrix_free.h>
29 #include <deal.II/matrix_free/operators.h>
30 #include <deal.II/matrix_free/fe_evaluation.h>
31 
32 #include <deal.II/multigrid/mg_constrained_dofs.h>
33 #include <deal.II/multigrid/multigrid.h>
34 #include <deal.II/multigrid/mg_transfer_matrix_free.h>
35 #include <deal.II/multigrid/mg_transfer_global_coarsening.templates.h>
36 #include <deal.II/multigrid/mg_tools.h>
37 #include <deal.II/multigrid/mg_coarse.h>
38 #include <deal.II/multigrid/mg_smoother.h>
39 #include <deal.II/multigrid/mg_matrix.h>
40 
41 namespace aspect
42 {
53  template <int dim, int velocity_degree>
55  {
56  public:
63  const Parameters<dim> &parameters);
64 
69 
73  void initialize() override;
74 
78  std::string name() const override;
79 
100  solve(const LinearAlgebra::BlockSparseMatrix &system_matrix,
101  const LinearAlgebra::BlockVector &system_rhs,
102  const bool solve_newton_system,
103  const double last_pressure_normalization_adjustment,
104  LinearAlgebra::BlockVector &solution_vector) override;
105 
110  void setup_dofs() override;
111 
119  void assemble() override;
120 
125  void build_preconditioner() override;
126 
130  static
131  void declare_parameters (ParameterHandler &prm);
132 
136  void parse_parameters (ParameterHandler &prm) override;
137 
141  std::size_t get_dof_handler_memory_consumption() const override;
142 
146  std::size_t get_mg_transfer_memory_consumption() const override;
147 
151  std::size_t get_constraint_memory_consumption() const override;
152 
157  std::size_t get_cell_data_memory_consumption() const override;
158 
159  private:
166 
171  void correct_stokes_rhs();
172 
173 
175 
177 
183 
189 
190  FESystem<dim> fe_v;
191  FESystem<dim> fe_p;
192  FESystem<dim> fe_projection;
193 
198 
202  MGLevelObject<MatrixFreeStokesOperators::OperatorCellData<dim, GMGNumberType>> level_cell_data;
203 
210 
215 
216  MGLevelObject<GMGABlockMatrixType> mg_matrices_A_block;
217  MGLevelObject<GMGSchurComplementMatrixType> mg_matrices_Schur_complement;
218 
219  MGConstrainedDoFs mg_constrained_dofs_A_block;
222 
223  unsigned int min_level;
224  unsigned int max_level;
225 
226  std::vector<std::shared_ptr<MatrixFree<dim,double>>> matrix_free_objects;
227 
228  std::vector<std::shared_ptr<const Triangulation<dim, dim>>> trias;
229 
230  MGLevelObject<DoFHandler<dim>> dofhandlers_v;
231  MGLevelObject<DoFHandler<dim>> dofhandlers_p;
232  MGLevelObject<DoFHandler<dim>> dofhandlers_projection;
233 
234  MGLevelObject<AffineConstraints<double>> constraints_v;
235  MGLevelObject<AffineConstraints<double>> constraints_p;
236 
237 #if DEAL_II_VERSION_GTE(9,6,0)
239 #else
240  using transfer_t = MGTransferGlobalCoarsening<dim, ::LinearAlgebra::distributed::Vector<GMGNumberType>>;
241 #endif
242  MGLevelObject<MGTwoLevelTransfer<dim, ::LinearAlgebra::distributed::Vector<GMGNumberType>>> transfers_v;
243  MGLevelObject<MGTwoLevelTransfer<dim, ::LinearAlgebra::distributed::Vector<GMGNumberType>>> transfers_p;
244  std::unique_ptr<transfer_t> mg_transfer_A_block;
245  std::unique_ptr<transfer_t> mg_transfer_Schur_complement;
246  };
247 }
248 
249 #endif
void parse_parameters(ParameterHandler &prm) override
const Simulator< dim > * simulator
::TrilinosWrappers::MPI::BlockVector BlockVector
Definition: global.h:269
std::vector< std::shared_ptr< const Triangulation< dim, dim > > > trias
MGTransferGlobalCoarsening< dim, ::LinearAlgebra::distributed::Vector< GMGNumberType >> transfer_t
MGLevelObject< MatrixFreeStokesOperators::OperatorCellData< dim, GMGNumberType > > level_cell_data
StokesSolver::SolverOutputs solve(const LinearAlgebra::BlockSparseMatrix &system_matrix, const LinearAlgebra::BlockVector &system_rhs, const bool solve_newton_system, const double last_pressure_normalization_adjustment, LinearAlgebra::BlockVector &solution_vector) override
MGLevelObject< MGTwoLevelTransfer< dim, ::LinearAlgebra::distributed::Vector< GMGNumberType > > > transfers_p
::TrilinosWrappers::BlockSparseMatrix BlockSparseMatrix
Definition: global.h:280
MatrixFreeStokesOperators::OperatorCellData< dim, GMGNumberType > active_cell_data
double GMGNumberType
::MGTransferMatrixFree< dim, NumberType > MGTransferMF
Definition: compat.h:64
MGLevelObject< MGTwoLevelTransfer< dim, ::LinearAlgebra::distributed::Vector< GMGNumberType > > > transfers_v
std::vector< std::shared_ptr< MatrixFree< dim, double > > > matrix_free_objects
StokesMatrixFreeHandlerGlobalCoarseningImplementation(Simulator< dim > &simulator, const Parameters< dim > &parameters)