www.mooseframework.org
PhysicsBasedPreconditioner.h
Go to the documentation of this file.
1 /****************************************************************/
2 /* DO NOT MODIFY THIS HEADER */
3 /* MOOSE - Multiphysics Object Oriented Simulation Environment */
4 /* */
5 /* (c) 2010 Battelle Energy Alliance, LLC */
6 /* ALL RIGHTS RESERVED */
7 /* */
8 /* Prepared by Battelle Energy Alliance, LLC */
9 /* Under Contract No. DE-AC07-05ID14517 */
10 /* With the U. S. Department of Energy */
11 /* */
12 /* See COPYRIGHT for full restrictions */
13 /****************************************************************/
14 
15 #ifndef PHYSICSBASEDPRECONDITIONER_H
16 #define PHYSICSBASEDPRECONDITIONER_H
17 
18 // MOOSE includes
19 #include "MoosePreconditioner.h"
20 
21 #include "libmesh/preconditioner.h"
22 #include "libmesh/linear_implicit_system.h"
23 
24 // C++ includes
25 #include <vector>
26 
27 // Forward declarations
30 
31 template <>
33 
37 class PhysicsBasedPreconditioner : public MoosePreconditioner, public Preconditioner<Number>
38 {
39 public:
45 
50  // FIXME: use better name
51  void addSystem(unsigned int var,
52  std::vector<unsigned int> off_diag,
53  PreconditionerType type = AMG_PRECOND);
54 
59  virtual void apply(const NumericVector<Number> & x, NumericVector<Number> & y);
60 
64  virtual void clear();
65 
69  virtual void init();
70 
76  virtual void setup();
77 
78 protected:
82  std::vector<LinearImplicitSystem *> _systems;
84  std::vector<Preconditioner<Number> *> _preconditioners;
86  std::vector<unsigned int> _solve_order;
88  std::vector<PreconditionerType> _pre_type;
90  std::vector<std::vector<unsigned int>> _off_diag;
91 
99  std::vector<std::vector<SparseMatrix<Number> *>> _off_diag_mats;
100 };
101 
102 #endif // PHYSICSBASEDPRECONDITIONER_H
virtual void setup()
This is called every time the "operator might have changed".
virtual void apply(const NumericVector< Number > &x, NumericVector< Number > &y)
Computes the preconditioned vector "y" based on input "x".
std::vector< std::vector< unsigned int > > _off_diag
Holds which off diagonal blocks to compute.
NonlinearSystemBase & _nl
The nonlinear system this PBP is associated with (convenience reference)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
std::vector< Preconditioner< Number > * > _preconditioners
Holds one Preconditioner object per small system to solve.
std::vector< PreconditionerType > _pre_type
Which preconditioner to use for each solve.
std::vector< LinearImplicitSystem * > _systems
List of linear system that build up the preconditioner.
static PetscErrorCode Vec x
virtual void clear()
Release all memory and clear data structures.
Base class for MOOSE preconditioners.
virtual void init()
Initialize data structures if not done so already.
Nonlinear system to be solved.
PhysicsBasedPreconditioner(const InputParameters &params)
Constructor.
Implements a segregated solve preconditioner.
std::vector< std::vector< SparseMatrix< Number > * > > _off_diag_mats
Holds pointers to the off-diagonal matrices.
void addSystem(unsigned int var, std::vector< unsigned int > off_diag, PreconditionerType type=AMG_PRECOND)
Add a diagonal system + possibly off-diagonals ones as well, also specifying type of preconditioning...
MatType type
std::vector< unsigned int > _solve_order
Holds the order the blocks are solved for.
InputParameters validParams< PhysicsBasedPreconditioner >()