Lethe Open-Source Library version 1.2.0
Developer Guide
Loading...
Searching...
No Matches
fluid_dynamics_matrix_free.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) 2023-2026 The Lethe Authors
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
3
4#ifndef lethe_fluid_dynamics_matrix_free_h
5#define lethe_fluid_dynamics_matrix_free_h
6
7#include <core/exceptions.h>
8#include <core/multiphysics.h>
9
12
13#include <deal.II/lac/precondition.h>
14#include <deal.II/lac/solver_gmres.h>
15#include <deal.II/lac/trilinos_precondition.h>
16
17#include <deal.II/multigrid/mg_coarse.h>
18#include <deal.II/multigrid/mg_constrained_dofs.h>
19#include <deal.II/multigrid/mg_matrix.h>
20#include <deal.II/multigrid/mg_smoother.h>
21#include <deal.II/multigrid/mg_transfer_global_coarsening.h>
22#include <deal.II/multigrid/mg_transfer_matrix_free.h>
23#include <deal.II/multigrid/multigrid.h>
24
25using namespace dealii;
26
27template <typename VectorType>
29
30template <typename VectorType, typename VectorTypePrecondition>
32
33namespace dealii
34{
35 template <class VectorType, class PreconditionerType>
37}
38
39template <int dim, typename MGNumber>
41
42/**
43 * @brief A geometric multigrid preconditioner compatible with the
44 * matrix-free solver.
45 */
46template <int dim>
48{
49protected:
50 using Number = double;
51
52#ifndef LETHE_GMG_USE_FLOAT
53 using MGNumber = double;
54#else
55 using MGNumber = float;
56#endif
57
58 using VectorType = LinearAlgebra::distributed::Vector<Number>;
59 using MGVectorType = LinearAlgebra::distributed::Vector<MGNumber>;
60 using TrilinosVectorType = LinearAlgebra::distributed::Vector<double>;
62#if DEAL_II_VERSION_GTE(9, 8, 0)
63 using GCTransferType = MGTransferMatrixFree<dim, MGNumber>;
64#else
65 using GCTransferType = MGTransferGlobalCoarsening<dim, MGVectorType>;
66#endif
70 PreconditionRelaxation<OperatorType, SmootherPreconditionerType>;
72 PreconditionChebyshev<OperatorType,
76 PreconditionMG<dim, MGVectorType, LSTransferType>;
78 PreconditionMG<dim, MGVectorType, GCTransferType>;
79
80 using CoarseGridSolverApply = MGCoarseGridApplyOperator<
83
84public:
85 /**
86 * @brief Construct a new precondition GMG object. Sets constraints,
87 * operators and transfer objects.
88 *
89 * @param[in] simulation_parameters Object containing all parameters specified
90 * in input file.
91 * @param[in] dof_handler Describes the layout of DoFs and the type of FE.
92 * @param[in] dof_handler_fe_q_iso_q1 Describes the layout of DoFs for
93 * FE_Q_iso_Q1 elements.
94 */
97 const DoFHandler<dim> &dof_handler,
98 const DoFHandler<dim> &dof_handler_fe_q_iso_q1);
99
100 /**
101 * @brief Default destructor.
102 */
103
105
106 /**
107 * @brief Initializes geometric multigrid preconditioner and pre-calculate terms that are constant.
108 *
109 * @param[in] mapping Describes the transformations from unit to real cell.
110 * @param[in] cell_quadrature Required for local operations on cells.
111 * @param[in] forcing_function Function specified in parameter file as source
112 * term.
113 * @param[in] simulation_control Required to get the time stepping method.
114 * @param[in] physical_properties_manager Required to have the updated values
115 * of physical properties in case of ramp or viscous initial conditions.
116 * @param[in] fe Describes the FE system for the vector-valued problem.
117 */
118 void
119 reinit(const std::shared_ptr<Mapping<dim>> &mapping,
120 const std::shared_ptr<Quadrature<dim>> &cell_quadrature,
121 const std::shared_ptr<Function<dim>> &forcing_function,
122 const std::shared_ptr<SimulationControl> &simulation_control,
123 const std::shared_ptr<PhysicalPropertiesManager>
124 &physical_properties_manager,
125 const std::shared_ptr<FESystem<dim>> &fe);
126
127 /**
128 * @brief Creates the operator for a given level.
129 *
130 * @param[in] level Identifier of the level to be created
131 */
132 virtual void
133 create_level_operator(const unsigned int level) = 0;
134
135 /**
136 * @brief Initialize smoother, coarse grid solver and multigrid object
137 * needed for the geometric multigrid preconditioner.
138 */
139 void
140 initialize();
141
142 /**
143 * @brief Calls the v cycle function of the multigrid object.
144 *
145 * @param[in,out] dst Destination vector holding the result.
146 * @param[in] src Input source vector.
147 */
148 void
149 vmult(VectorType &dst, const VectorType &src) const;
150
151 /**
152 * @brief Prints relevant multigrid information
153 *
154 */
155 void
156 print_relevant_info() const;
157
158 /**
159 * @brief Getter function for all level operators.
160 *
161 * @return Multigrid object that contains all level operators.
162 */
163 const MGLevelObject<std::shared_ptr<OperatorType>> &
164 get_mg_operators() const;
165
166
167 /**
168 * @brief Getter function for all level smoother preconditioners.
169 *
170 * @return Multigrid object that contains all level smoother preconditioners.
171 */
172 const MGLevelObject<std::shared_ptr<PreconditionBase<MGVectorType>>> &
174
175protected:
176 /**
177 * @brief Set up AMG object needed for coarse-grid solver or
178 * preconditioning.
179 *
180 */
181 void
182 setup_AMG();
183
184 /**
185 * @brief Set up ILU object needed for coarse-grid solver or
186 * preconditioning.
187 *
188 */
189 void
190 setup_ILU();
191
192 /// Min level of the multigrid hierarchy
193 unsigned int minlevel;
194
195 /// Max level of the multigrid hierarchy
196 unsigned int maxlevel;
197
198 /// Intermediate level of the multigrid hierarchy
199 unsigned int intlevel;
200
201 /// Triangulations for the global coarsening case
202 std::vector<std::shared_ptr<const Triangulation<dim>>>
204
205 /// DoF handlers for each of the levels of the global coarsening algorithm
206 MGLevelObject<DoFHandler<dim>> dof_handlers;
207
208 /// MappingQCache for each of the levels of the global coarsening algorithm
209 MGLevelObject<std::shared_ptr<MappingQCache<dim>>> mappings;
210
211 /// Transfers for each of the levels of the global coarsening algorithm
212 MGLevelObject<MGTwoLevelTransfer<dim, MGVectorType>> transfers;
213
214 /// Level operators for the geometric multigrid
215 MGLevelObject<std::shared_ptr<OperatorType>> mg_operators;
216
217 /// Multigrid level object storing all operators
218 std::shared_ptr<mg::Matrix<MGVectorType>> mg_matrix;
219
220 /// Interface edge matrix needed only for local smoothing
221 std::shared_ptr<mg::Matrix<MGVectorType>> mg_interface_matrix_in;
222 MGLevelObject<MatrixFreeOperators::MGInterfaceOperator<OperatorType>>
224 MGLevelObject<MatrixFreeOperators::MGInterfaceOperator<OperatorType>>
226
227 /// Preconditioners associated to smoothers
228 mutable MGLevelObject<std::shared_ptr<PreconditionBase<MGVectorType>>>
230
231 /// Smoother object. Stored through the type-erased base so that either a
232 /// relaxation-based (PreconditionRelaxation) or a Chebyshev-based
233 /// (PreconditionChebyshev) smoother can be selected at runtime.
234 std::shared_ptr<MGSmootherBase<MGVectorType>> mg_smoother;
235
236 /// Collection of boundary constraints and refinement edge constrations for
237 /// the different levels in the local smoothing approach.
238 MGLevelObject<MGConstrainedDoFs> mg_constrained_dofs;
239
240 /// Transfer operator for local smoothing
241 std::shared_ptr<LSTransferType> mg_transfer_ls;
242
243 /// Transfer operator for global coarsening
244 std::shared_ptr<GCTransferType> mg_transfer_gc;
245
246 /// Coarse grid solver (algebraic multigrid, ILU, direct solver)
247 std::shared_ptr<PreconditionAdapter<MGVectorType, TrilinosVectorType>>
249
250 /// Solver control for the coarse grid solver
251 std::shared_ptr<SolverControl> coarse_grid_solver_control;
252
253 /// Solver control for the direct solver
254 std::shared_ptr<SolverControl> direct_solver_control;
255
256 /// GMRES as coarse grid solver
257 std::shared_ptr<SolverGMRES<TrilinosVectorType>> coarse_grid_solver;
258
259 /// Multigrid wrapper for the coarse grid solver
260 std::shared_ptr<MGCoarseGridBase<MGVectorType>> mg_coarse;
261
262 /// Solver control for the coarse grid solver (intermediate level)
263 std::shared_ptr<SolverControl> coarse_grid_solver_control_intermediate;
264
265 /// Multigrid wrapper for the coarse grid solver (intermediate level)
266 std::shared_ptr<MGCoarseGridBase<MGVectorType>> mg_coarse_intermediate;
267
268 /// GMRES as coarse grid solver (intermediate level)
269 std::shared_ptr<SolverGMRES<MGVectorType>> coarse_grid_solver_intermediate;
270
271 /// Multigrid method (intermediate level)
272 std::shared_ptr<Multigrid<MGVectorType>> mg_intermediate;
273
274 /// Global coarsening multigrid preconditioner object (intermediate level)
275 std::shared_ptr<PreconditionMG<dim, MGVectorType, GCTransferType>>
277
278 /// Local smoothing multigrid preconditioner object (intermediate level)
279 std::shared_ptr<PreconditionMG<dim, MGVectorType, LSTransferType>>
281
282 /// Multigrid method
283 std::shared_ptr<Multigrid<MGVectorType>> mg;
284
285 /// Local smoothing multigrid preconditioner object
286 std::shared_ptr<PreconditionMG<dim, MGVectorType, LSTransferType>>
288
289 /// Global coarsening multigrid preconditioner object
290 std::shared_ptr<PreconditionMG<dim, MGVectorType, GCTransferType>>
292
293 /// Conditional Ostream
294 ConditionalOStream pcout;
295
296 /// Simulation parameters
298
299 /// Describes the layout of DoFs and the type of FE.
300 const DoFHandler<dim> &dof_handler;
301
302 /// Describes the layout of DoFs for FE_Q_iso_Q1 elements.
303 DoFHandler<dim> dof_handler_fe_q_iso_q1;
304
305 /// Vector holding number of coarse grid iterations
306 mutable std::vector<unsigned int> coarse_grid_iterations;
307
308 /// Temperature DoF handlers for each of the levels of the global coarsening
309 /// algorithm
310 MGLevelObject<DoFHandler<dim>> temperature_dof_handlers;
311
312 /// Temperature transfers for each of the levels of the global coarsening
313 /// algorithm
314 MGLevelObject<MGTwoLevelTransfer<dim, MGVectorType>> transfers_temperature;
315
316 /// Transfer operator for global coarsening for the temperature
317 std::shared_ptr<GCTransferType> mg_transfer_gc_temperature;
318
319 /// Boolean that indicates whether manifolds are used for the normal vectors
320 /// computation in slip BCs
322
323public:
324 /// Timer for specific geometric multigrid components.
325 mutable TimerOutput mg_setup_timer;
326
327 /// Internal timer for vmult timings
328 mutable TimerOutput mg_vmult_timer;
329};
330
331/**
332 * @brief A geometric multigrid preconditioner implementation for
333 * incompressible flow.
334 */
335template <int dim>
338{
339public:
345#if DEAL_II_VERSION_GTE(9, 8, 0)
346 using GCTransferType = MGTransferMatrixFree<dim, MGNumber>;
347#else
348 using GCTransferType = MGTransferGlobalCoarsening<dim, MGVectorType>;
349#endif
350
351 /**
352 * Constructor.
353 */
356 const DoFHandler<dim> &dof_handler,
357 const DoFHandler<dim> &dof_handler_fe_q_iso_q1);
358
359 /*
360 * @brief Creates the operator for one level
361 *
362 * @param[in] level Level to be created.
363 */
364 void
365 create_level_operator(const unsigned int level) override;
366
367 /*
368 * @brief Initialize smoother, coarse grid solver and multigrid object
369 * needed for the geometric multigrid preconditioner.
370 *
371 * @param[in] simulation_control Required to get the time stepping method.
372 * @param[in] flow_control Required for dynamic flow control.
373 * @param[in] present_solution Previous solution needed to evaluate the non
374 * linear term.
375 * @param[in] time_derivative_previous_solutions Vector storing time
376 * derivatives of previous solutions.
377 */
378 void
379 initialize(const std::shared_ptr<SimulationControl> &simulation_control,
380 FlowControl<dim> &flow_control,
381 const VectorType &present_solution,
382 const VectorType &time_derivative_previous_solutions);
383
384 /**
385 * @brief Transfer the current temperature solution to the different multigrid levels and compute the thermal buoyancy term in each of the multigrid operators.
386 *
387 * @param[in] temperature_dof_handler DoF Handler used for the heat transfer.
388 * @param[in] temperature_present_solution Present solution of the temperature
389 * as given by the multiphysics interface.
390 */
391 void
392 initialize_auxiliary_physics(const DoFHandler<dim> &temperature_dof_handler,
393 const VectorType &temperature_present_solution);
394};
395
396/**
397 * @brief A solver for the incompressible Navier-Stokes equations implemented
398 * in a matrix-free fashion.
399 *
400 * A matrix-free stabilized solver for the incompressible Navier-Stokes
401 * equations implemented in a matrix-free fashion with a sum-factorization
402 * approach. It uses a continuous Galerkin discretization and solves the
403 * fully-coupled discretized problem in a monolithic way using multigrid
404 * preconditioners.
405 *
406 * @tparam dim An integer that denotes the dimension of the space in which
407 * the flow is solved.
408 */
409template <int dim>
411 : public NavierStokesBase<dim,
412 LinearAlgebra::distributed::Vector<double>,
413 IndexSet>
414{
415 using VectorType = LinearAlgebra::distributed::Vector<double>;
416
417public:
418 /**
419 * @brief Constructor that sets the finite element degree and system operator
420 * according to simulation parameters.
421 *
422 * @param[in] nsparam Relevant parameters for the solver.
423 * @param[in] fluid_dynamics_formulation The formulation of the fluid dynamics
424 * equations. Whether the solver solves the volume-averaged Navier-Stokes
425 * (VANS) equations or the standard Navier-Stokes equations.
426 */
429 const FluidDynamicsFormulation fluid_dynamics_formulation =
431
432 /**
433 * @brief Destructor.
434 *
435 */
437
438 /**
439 * @brief Solve the problem defined by simulation parameters by iterating
440 * through time or through the mesh refinements.
441 */
442 virtual void
443 solve();
444
445protected:
446 /**
447 * @brief Setup the degrees of freedom, system constraints, system operator
448 * and solution vectors.
449 */
450 virtual void
451 setup_dofs_fd() override;
452
453 /**
454 * @brief Update the sum_over_previous_stages variable to use it in the solver.
455 *
456 * @param stage An unsigned integer which gives the index of the current stage
457 * @param method SDIRK method for now (BDF methods are single stage)
458 */
459 void
461 unsigned int stage,
463
464 /**
465 * @brief Calculate \f$ k_i \f$ from \f$ u*_i : k_i = \frac{u*_i - u_n}{time_step*a_ii} - \sum{j=1}^{i-1} a_ij * k_j \f$
466 * Update \f$ \sum_{i=1}^{N_{stages}} b_i * k_i \f$
467 *
468 * @param stage An unsigned integer which gives the index of the current stage
469 * @param method SDIRK methods for now (BDF methods are single stage)
470 * @param time_step Current time step value
471 */
472 virtual void
474 unsigned int stage,
476 double time_step) override;
477
478 /**
479 * @brief \f$ u_{n+1} = u_n + time_step * \sum_{i=1}^{N_{stages}} b_i * k_i \f$
480 *
481 * @param time_step The current time step to build the solution at the next time step
482 */
483 virtual void
484 update_multi_stage_solution(double time_step) override;
485
486 /**
487 * @brief Set the time of the forcing function and of the time-dependent
488 * boundary conditions to the current time and re-impose the non-zero
489 * constraints. The forcing term is precomputed by the matrix-free operator,
490 * so it is also recomputed here for a time-dependent forcing function to be
491 * accounted for.
492 */
493 void
495
496 /**
497 * restarted from a checkpoint, the initial solution setting is bypassed
498 * and the checkpoint is instead read.
499 *
500 * @param[in] initial_condition_type The type of initial condition to be
501 * set.
502 *
503 * @param[in] restart A boolean that indicates if the simulation is being
504 * restarted. If set to true, the initial conditions are never set, but are
505 * instead overriden by the read_checkpoint functionality.
506 *
507 **/
508 virtual void
511 bool restart = false) override;
512
513 /**
514 * @brief Assemble the matrix associated with the solver. Only required for
515 * compilation and it is not used for the matrix free solver.
516 */
517 virtual void
518 assemble_system_matrix() override;
519
520 /**
521 * @brief Assemble the system right hand side associated with the solver.
522 */
523 virtual void
524 assemble_system_rhs() override;
525
526 /**
527 * @brief Update mortar configuration.
528 *
529 * When the rotor domain is rotated, the mortar cells need to be reinitialized
530 * according to the new rotor-stator interface configuration.
531 */
532 virtual void
534
535 /**
536 * @brief Initialize mortar coupling manager, operator, and evaluator for the matrix-free
537 * solver.
538 */
539 void
541
542 /**
543 * @brief Update the average velocity field solution in the multiphyscics interface.
544 */
545 virtual void
547
548
549 /**
550 * @brief Provide present and previous flow solutions to the multiphysics
551 * interface. These solutions can be accessed through the multiphysics
552 * interface by the different physics.
553 */
554 virtual void
556
557
558 /**
559 * @brief Provide present multiphysics solutions from the multiphysics
560 * interface to the fluid dynamics.
561 */
562 virtual void
564
565 /**
566 * @brief Calculate and store time derivatives of previous solutions according to
567 * time-stepping scheme to use them in the operator.
568 */
569 void
571
572 /**
573 * @brief Set up appropriate preconditioner.
574 *
575 */
576 void
577 setup_preconditioner() override;
578
579 /**
580 * @brief Solve the linear system of equations using the method specified in
581 * the simulation parameters.
582 */
583 void
584 solve_linear_system() override;
585
586private:
587 /**
588 * @brief Assemble a L2 projection matrix for the velocity and the pressure,
589 * which can be used to set the initial condition for the Navier-Stokes
590 * problem. Currently not implemented for this solver.
591 */
592 void
594
595 /**
596 * @brief GMRES solver with preconditioning.
597 *
598 * @param[in] absolute_residual Used to define the linear solver tolerance.
599 *
600 * @param[in] relative_residual Used to define the linear solver tolerance.
601 */
602 void
603 solve_system_GMRES(const double absolute_residual,
604 const double relative_residual);
605
606 /**
607 * @brief BiCGStab solver with preconditioning.
608 *
609 * @param[in] absolute_residual Used to define the linear solver tolerance.
610 *
611 * @param[in] relative_residual Used to define the linear solver tolerance.
612 */
613 void
614 solve_system_BiCGStab(const double absolute_residual,
615 const double relative_residual);
616
617 /**
618 * @brief Direct solver using TrilinosWrappers::SolverDirect
619 *
620 * @param[in] absolute_residual Used to define the linear solver tolerance.
621 *
622 * @param[in] relative_residual Used to define the linear solver tolerance.
623 */
624 void
625 solve_system_direct(const double absolute_residual,
626 const double relative_residual);
627 /**
628 * @brief Create the geometric multigrid preconditioner.
629 */
630 virtual void
631 create_GMG();
632
633 /**
634 * @brief Intialize the geometric multigrid preconditioner.
635 */
636 virtual void
638
639 /**
640 * @brief Setup the geometric multigrid preconditioner.
641 */
642 void
643 setup_GMG();
644
645 /**
646 * @brief Setup the implicit LU preconditioner and call the solve function of the
647 * linear solver. Attention: an actual matrix needs to be constructed using
648 * the matrix-free operator.
649 */
650 void
651 setup_ILU();
652
653
654
655protected:
656 /**
657 * @brief Prints the setup times for the geometric multigrid preconditioner.
658 *
659 */
660 void
662
663 /**
664 * @brief Matrix-free operator in used for all the matrix-vector multiplications calls (vmult).
665 *
666 */
667 std::shared_ptr<NavierStokesOperatorBase<dim, double>> system_operator;
668
669 /**
670 * @brief Geometric multigrid preconditioner.
671 *
672 */
673 std::shared_ptr<MFNavierStokesPreconditionGMGBase<dim>> gmg_preconditioner;
674
675 /**
676 * @brief Implicit LU preconditioner.
677 *
678 */
679 std::shared_ptr<TrilinosWrappers::PreconditionILU> ilu_preconditioner;
680
681 /**
682 * @brief Vector to store the time derivatives of the previous solutions at the end
683 * of each time step for time-dependent simulations.
684 *
685 */
687
688 /**
689 * @brief Describes the layout of DoFs for FE_Q_iso_Q1 elements.
690 *
691 */
692 DoFHandler<dim> dof_handler_fe_q_iso_q1;
693
694 /**
695 * @brief Trilinos vector storing the average velocities that are provided to other
696 * physics.
697 *
698 */
699 TrilinosWrappers::MPI::Vector multiphysics_average_velocities;
700
701 /**
702 * @brief Trilinos vector storing the present solution that is provided to other physics.
703 *
704 */
705 std::shared_ptr<TrilinosWrappers::MPI::Vector> multiphysics_present_solution;
706
707 /**
708 * @brief Vector storing trilinos vectors containing the previous solutions that are
709 * provided to other physics.
710 *
711 */
712 std::shared_ptr<std::vector<TrilinosWrappers::MPI::Vector>>
714
715 /**
716 * @brief Vector storing the present temperature solution from the heat transfer solver.
717 *
718 */
720
721 /**
722 * @brief Pointer to the physical properties object
723 *
724 */
725 std::shared_ptr<PhysicalPropertiesManager> physical_properties_manager;
726};
727
728#endif
Dynamic flow controller that drives the average velocity of the flow towards a target value.
virtual void initialize_GMG()
Intialize the geometric multigrid preconditioner.
virtual void solve()
Solve the problem defined by simulation parameters by iterating through time or through the mesh refi...
void reinit_mortar_operators_mf()
Initialize mortar coupling manager, operator, and evaluator for the matrix-free solver.
TrilinosWrappers::MPI::Vector multiphysics_average_velocities
Trilinos vector storing the average velocities that are provided to other physics.
void solve_system_GMRES(const double absolute_residual, const double relative_residual)
GMRES solver with preconditioning.
void setup_ILU()
Setup the implicit LU preconditioner and call the solve function of the linear solver....
void print_mg_setup_times()
Prints the setup times for the geometric multigrid preconditioner.
std::shared_ptr< PhysicalPropertiesManager > physical_properties_manager
Pointer to the physical properties object.
std::shared_ptr< std::vector< TrilinosWrappers::MPI::Vector > > multiphysics_previous_solutions
Vector storing trilinos vectors containing the previous solutions that are provided to other physics.
virtual void update_solutions_for_fluid_dynamics() override
Provide present multiphysics solutions from the multiphysics interface to the fluid dynamics.
DoFHandler< dim > dof_handler_fe_q_iso_q1
Describes the layout of DoFs for FE_Q_iso_Q1 elements.
void update_forcing_and_boundary_conditions() override
Set the time of the forcing function and of the time-dependent boundary conditions to the current tim...
virtual void set_initial_condition_fd(Parameters::FluidDynamicsInitialConditionType initial_condition_type, bool restart=false) override
VectorType temperature_present_solution
Vector storing the present temperature solution from the heat transfer solver.
VectorType time_derivative_previous_solutions
Vector to store the time derivatives of the previous solutions at the end of each time step for time-...
void setup_preconditioner() override
Set up appropriate preconditioner.
virtual void update_solutions_for_multiphysics() override
Provide present and previous flow solutions to the multiphysics interface. These solutions can be acc...
virtual void update_multiphysics_time_average_solution() override
Update the average velocity field solution in the multiphyscics interface.
virtual void update_mortar_configuration() override
Update mortar configuration.
std::shared_ptr< TrilinosWrappers::MPI::Vector > multiphysics_present_solution
Trilinos vector storing the present solution that is provided to other physics.
virtual void assemble_system_rhs() override
Assemble the system right hand side associated with the solver.
std::shared_ptr< NavierStokesOperatorBase< dim, double > > system_operator
Matrix-free operator in used for all the matrix-vector multiplications calls (vmult).
void solve_system_direct(const double absolute_residual, const double relative_residual)
Direct solver using TrilinosWrappers::SolverDirect.
std::shared_ptr< MFNavierStokesPreconditionGMGBase< dim > > gmg_preconditioner
Geometric multigrid preconditioner.
void multi_stage_preresolution(unsigned int stage, Parameters::SimulationControl::TimeSteppingMethod method) override
Update the sum_over_previous_stages variable to use it in the solver.
void solve_system_BiCGStab(const double absolute_residual, const double relative_residual)
BiCGStab solver with preconditioning.
void calculate_time_derivative_previous_solutions()
Calculate and store time derivatives of previous solutions according to time-stepping scheme to use t...
virtual void create_GMG()
Create the geometric multigrid preconditioner.
FluidDynamicsMatrixFree(SimulationParameters< dim > &nsparam, const FluidDynamicsFormulation fluid_dynamics_formulation=FluidDynamicsFormulation::standard)
Constructor that sets the finite element degree and system operator according to simulation parameter...
void setup_GMG()
Setup the geometric multigrid preconditioner.
std::shared_ptr< TrilinosWrappers::PreconditionILU > ilu_preconditioner
Implicit LU preconditioner.
virtual void update_multi_stage_solution(double time_step) override
virtual void setup_dofs_fd() override
Setup the degrees of freedom, system constraints, system operator and solution vectors.
virtual void assemble_system_matrix() override
Assemble the matrix associated with the solver. Only required for compilation and it is not used for ...
void solve_linear_system() override
Solve the linear system of equations using the method specified in the simulation parameters.
virtual void multi_stage_postresolution(unsigned int stage, Parameters::SimulationControl::TimeSteppingMethod method, double time_step) override
Calculate from Update .
LinearAlgebra::distributed::Vector< double > VectorType
void assemble_L2_projection()
Assemble a L2 projection matrix for the velocity and the pressure, which can be used to set the initi...
MGLevelObject< std::shared_ptr< PreconditionBase< MGVectorType > > > mg_smoother_preconditioners
Preconditioners associated to smoothers.
std::shared_ptr< SolverControl > coarse_grid_solver_control_intermediate
Solver control for the coarse grid solver (intermediate level).
MGTransferGlobalCoarsening< dim, MGVectorType > GCTransferType
MGLevelObject< std::shared_ptr< OperatorType > > mg_operators
Level operators for the geometric multigrid.
PreconditionMG< dim, MGVectorType, GCTransferType > PreconditionerTypeGC
MGLevelObject< DoFHandler< dim > > temperature_dof_handlers
PreconditionRelaxation< OperatorType, SmootherPreconditionerType > SmootherType
std::shared_ptr< PreconditionMG< dim, MGVectorType, GCTransferType > > gc_multigrid_preconditioner
Global coarsening multigrid preconditioner object.
PreconditionChebyshev< OperatorType, MGVectorType, SmootherPreconditionerType > ChebyshevSmootherType
SimulationParameters< dim > simulation_parameters
Simulation parameters.
virtual ~MFNavierStokesPreconditionGMGBase()=default
Default destructor.
void setup_AMG()
Set up AMG object needed for coarse-grid solver or preconditioning.
TimerOutput mg_vmult_timer
Internal timer for vmult timings.
unsigned int maxlevel
Max level of the multigrid hierarchy.
std::shared_ptr< PreconditionAdapter< MGVectorType, TrilinosVectorType > > coarse_grid_precondition
Coarse grid solver (algebraic multigrid, ILU, direct solver).
void setup_ILU()
Set up ILU object needed for coarse-grid solver or preconditioning.
std::shared_ptr< Multigrid< MGVectorType > > mg
Multigrid method.
std::shared_ptr< mg::Matrix< MGVectorType > > mg_interface_matrix_in
Interface edge matrix needed only for local smoothing.
std::shared_ptr< SolverControl > direct_solver_control
Solver control for the direct solver.
MGTransferMatrixFreeWrapper< dim, MGNumber > LSTransferType
TimerOutput mg_setup_timer
Timer for specific geometric multigrid components.
LinearAlgebra::distributed::Vector< Number > VectorType
void initialize()
Initialize smoother, coarse grid solver and multigrid object needed for the geometric multigrid preco...
LinearAlgebra::distributed::Vector< double > TrilinosVectorType
std::shared_ptr< MGCoarseGridBase< MGVectorType > > mg_coarse_intermediate
Multigrid wrapper for the coarse grid solver (intermediate level).
std::shared_ptr< MGCoarseGridBase< MGVectorType > > mg_coarse
Multigrid wrapper for the coarse grid solver.
std::shared_ptr< SolverGMRES< MGVectorType > > coarse_grid_solver_intermediate
GMRES as coarse grid solver (intermediate level).
MGCoarseGridApplyOperator< MGVectorType, PreconditionAdapter< MGVectorType, TrilinosVectorType > > CoarseGridSolverApply
std::shared_ptr< SolverControl > coarse_grid_solver_control
Solver control for the coarse grid solver.
const DoFHandler< dim > & dof_handler
Describes the layout of DoFs and the type of FE.
std::shared_ptr< LSTransferType > mg_transfer_ls
Transfer operator for local smoothing.
PreconditionBase< MGVectorType > SmootherPreconditionerType
std::shared_ptr< mg::Matrix< MGVectorType > > mg_matrix
Multigrid level object storing all operators.
LinearAlgebra::distributed::Vector< MGNumber > MGVectorType
MFNavierStokesPreconditionGMGBase(const SimulationParameters< dim > &simulation_parameters, const DoFHandler< dim > &dof_handler, const DoFHandler< dim > &dof_handler_fe_q_iso_q1)
Construct a new precondition GMG object. Sets constraints, operators and transfer objects.
std::shared_ptr< PreconditionMG< dim, MGVectorType, GCTransferType > > gc_multigrid_preconditioner_intermediate
Global coarsening multigrid preconditioner object (intermediate level).
std::shared_ptr< GCTransferType > mg_transfer_gc_temperature
Transfer operator for global coarsening for the temperature.
unsigned int minlevel
Min level of the multigrid hierarchy.
void vmult(VectorType &dst, const VectorType &src) const
Calls the v cycle function of the multigrid object.
const MGLevelObject< std::shared_ptr< OperatorType > > & get_mg_operators() const
Getter function for all level operators.
void reinit(const std::shared_ptr< Mapping< dim > > &mapping, const std::shared_ptr< Quadrature< dim > > &cell_quadrature, const std::shared_ptr< Function< dim > > &forcing_function, const std::shared_ptr< SimulationControl > &simulation_control, const std::shared_ptr< PhysicalPropertiesManager > &physical_properties_manager, const std::shared_ptr< FESystem< dim > > &fe)
Initializes geometric multigrid preconditioner and pre-calculate terms that are constant.
std::vector< std::shared_ptr< const Triangulation< dim > > > coarse_grid_triangulations
Triangulations for the global coarsening case.
MGLevelObject< MGTwoLevelTransfer< dim, MGVectorType > > transfers_temperature
DoFHandler< dim > dof_handler_fe_q_iso_q1
Describes the layout of DoFs for FE_Q_iso_Q1 elements.
void print_relevant_info() const
Prints relevant multigrid information.
NavierStokesOperatorBase< dim, MGNumber > OperatorType
PreconditionMG< dim, MGVectorType, LSTransferType > PreconditionerTypeLS
std::vector< unsigned int > coarse_grid_iterations
Vector holding number of coarse grid iterations.
MGLevelObject< MatrixFreeOperators::MGInterfaceOperator< OperatorType > > ls_mg_operators
const MGLevelObject< std::shared_ptr< PreconditionBase< MGVectorType > > > & get_mg_smoother_preconditioners() const
Getter function for all level smoother preconditioners.
MGLevelObject< MGTwoLevelTransfer< dim, MGVectorType > > transfers
Transfers for each of the levels of the global coarsening algorithm.
MGLevelObject< MatrixFreeOperators::MGInterfaceOperator< OperatorType > > ls_mg_interface_in
std::shared_ptr< GCTransferType > mg_transfer_gc
Transfer operator for global coarsening.
std::shared_ptr< Multigrid< MGVectorType > > mg_intermediate
Multigrid method (intermediate level).
MGLevelObject< MGConstrainedDoFs > mg_constrained_dofs
ConditionalOStream pcout
Conditional Ostream.
std::shared_ptr< MGSmootherBase< MGVectorType > > mg_smoother
std::shared_ptr< PreconditionMG< dim, MGVectorType, LSTransferType > > ls_multigrid_preconditioner
Local smoothing multigrid preconditioner object.
MGLevelObject< std::shared_ptr< MappingQCache< dim > > > mappings
MappingQCache for each of the levels of the global coarsening algorithm.
std::shared_ptr< PreconditionMG< dim, MGVectorType, LSTransferType > > ls_multigrid_preconditioner_intermediate
Local smoothing multigrid preconditioner object (intermediate level).
unsigned int intlevel
Intermediate level of the multigrid hierarchy.
std::shared_ptr< SolverGMRES< TrilinosVectorType > > coarse_grid_solver
GMRES as coarse grid solver.
virtual void create_level_operator(const unsigned int level)=0
Creates the operator for a given level.
MGLevelObject< DoFHandler< dim > > dof_handlers
DoF handlers for each of the levels of the global coarsening algorithm.
void create_level_operator(const unsigned int level) override
Creates the operator for a given level.
typename MFNavierStokesPreconditionGMGBase< dim >::MGVectorType MGVectorType
typename MFNavierStokesPreconditionGMGBase< dim >::MGNumber MGNumber
MGTransferGlobalCoarsening< dim, MGVectorType > GCTransferType
MFNavierStokesPreconditionGMG(const SimulationParameters< dim > &simulation_parameters, const DoFHandler< dim > &dof_handler, const DoFHandler< dim > &dof_handler_fe_q_iso_q1)
typename MFNavierStokesPreconditionGMGBase< dim >::VectorType VectorType
void initialize_auxiliary_physics(const DoFHandler< dim > &temperature_dof_handler, const VectorType &temperature_present_solution)
Transfer the current temperature solution to the different multigrid levels and compute the thermal b...
NavierStokesBase(SimulationParameters< dim > &nsparam, const FluidDynamicsFormulation fluid_dynamics_formulation=FluidDynamicsFormulation::standard)
A class that serves as base for all the matrix-free Navier-Stokes operators.
A wrapper class around a preconditioner to be able to handle vector types that are not supported by t...
A base class of preconditioners used by the smoother.
Common exception declarations shared across multiple solvers in Lethe.
Identifiers for multiphysics modules and their solution fields.
FluidDynamicsFormulation
Formulation of the fluid dynamics equations solved by a Navier-Stokes solver.
@ standard
Standard Navier-Stokes equations.