16#include "libmesh/preconditioner.h"
17#include "libmesh/linear_implicit_system.h"
18#include "libmesh/enum_preconditioner_type.h"
19#include "libmesh/mesh_base.h"
20#include "libmesh/petsc_matrix.h"
21#include "libmesh/parallel_object.h"
58 virtual void apply(
const NumericVector<Number> & y, NumericVector<Number> & x);
79 void findZeroDiagonals(SparseMatrix<Number> & mat, std::vector<dof_id_type> & indices);
90 PetscMatrix<Number> & original_mat,
91 const std::vector<dof_id_type> & rows,
92 const std::vector<dof_id_type> & cols,
93 const std::vector<dof_id_type> & grows,
94 const std::vector<dof_id_type> & gcols,
95 PetscMatrix<Number> & block_mat);
101 PetscMatrix<Number> & original_mat,
102 const std::vector<dof_id_type> & grows,
103 PetscMatrix<Number> & block_mat);
118 void getCondensedXY(
const NumericVector<Number> & y, NumericVector<Number> & x);
128 void getFullSolution(
const NumericVector<Number> & y, NumericVector<Number> & x);
139 std::vector<PetscInt> & c);
171 std::unique_ptr<PetscMatrix<Number>>
_D,
_M,
_K;
MooseMesh wraps a libMesh::Mesh object and enhances its capabilities by caching additional data and s...
Base class for MOOSE preconditioners.
Nonlinear system to be solved.
Interface for condensing out LMs for the dual mortar approach.
std::vector< unsigned int > _primary_var_ids
std::unordered_map< dof_id_type, dof_id_type > _map_global_lm_primary
Maps to keep track of the dof orders for keeping nonzero diagonal entries of the condensed system _ma...
virtual void init()
Initialize data structures if not done so already.
std::unordered_map< dof_id_type, dof_id_type > _map_global_primary_order
void condenseSystem()
Reconstruct the equation system.
std::unique_ptr< NumericVector< Number > > _x_hat
_x_hat, _y_hat: condensed solution and RHS vectors _primary_rhs_vec: part of the RHS vector that corr...
virtual void setup()
This is called every time the "operator might have changed".
std::vector< dof_id_type > _global_cols
const bool _is_lm_coupling_diagonal
Whether the coupling is diagonal.
std::vector< dof_id_type > _primary_dofs
const std::vector< std::string > _lm_var_names
Name and ID of the variables that are to be condensed out (usually the Lagrange multiplier variable)
void computeDInverseDiag(Mat &mat)
Compute (approximate) inverse of D by inverting its diagonal entries.
virtual void apply(const NumericVector< Number > &y, NumericVector< Number > &x)
Computes the preconditioned vector "x" based on input "y".
std::unique_ptr< NumericVector< Number > > _lm_sol_vec
void getFullSolution(const NumericVector< Number > &y, NumericVector< Number > &x)
Assemble the full solution vector.
const bool _adaptive_condensation
Whether to condense all specified variable.
PerfID _init_timer
Timers.
static InputParameters validParams()
std::vector< dof_id_type > _lm_dofs
std::unique_ptr< PetscMatrix< Number > > _D
Submatrices that are frequently needed while computing the condensed system _D: the submatrix that co...
std::unique_ptr< Preconditioner< Number > > _preconditioner
Holds one Preconditioner object for the condensed system to solve.
libMesh::PreconditionerType _pre_type
Which preconditioner to use for the solve.
std::vector< dof_id_type > _global_lm_dofs
Vectors of DoFs: indices associated with lagrange multipliers, and its coupled primary variable globa...
void preallocateCondensedJacobian(PetscMatrix< Number > &condensed_mat, PetscMatrix< Number > &original_mat, const std::vector< dof_id_type > &rows, const std::vector< dof_id_type > &cols, const std::vector< dof_id_type > &grows, const std::vector< dof_id_type > &gcols, PetscMatrix< Number > &block_mat)
Preallocate memory for the condensed Jacobian matrix.
bool _need_condense
Whether the DoFs associated the variable are to be condensed.
std::unique_ptr< NumericVector< Number > > _primary_rhs_vec
std::unique_ptr< PetscMatrix< Number > > _M
const libMesh::DofMap & _dofmap
DofMap for easy reference.
MooseMesh & _mesh
Mesh object for easy reference.
std::unordered_map< dof_id_type, dof_id_type > _rows_to_idx
virtual void clear()
Release all memory and clear data structures.
std::vector< unsigned int > _lm_var_ids
void computeCondensedJacobian(PetscMatrix< Number > &condensed_mat, PetscMatrix< Number > &original_mat, const std::vector< dof_id_type > &grows, PetscMatrix< Number > &block_mat)
The condensed Jacobian matrix is computed in this function.
std::unordered_map< dof_id_type, dof_id_type > _global_cols_to_idx
void mergeArrays(const PetscInt *a, const PetscInt *b, const PetscInt &na, const PetscInt &nb, std::vector< PetscInt > &c)
Find the common part of arrays a and b and save it in c.
std::unique_ptr< PetscMatrix< Number > > _J_condensed
Condensed Jacobian.
std::vector< dof_id_type > _global_rows
row and column indices for the condensed system
virtual ~VariableCondensationPreconditioner()
void computeDInverse(Mat &mat)
Compute inverse of D using LU.
std::unordered_map< dof_id_type, dof_id_type > _global_rows_to_idx
Maps to keep track of row and col indices from the original Jacobian matrix to the condensed Jacobian...
void computeCondensedVariables()
Compute condensed variables (Lagrange multipliers) values using updated solution vector.
void getDofToCondense()
Get dofs for the variable to be condensed out.
std::unique_ptr< NumericVector< Number > > _y_hat
std::vector< dof_id_type > _rows
std::unordered_map< dof_id_type, dof_id_type > _cols_to_idx
void getCondensedXY(const NumericVector< Number > &y, NumericVector< Number > &x)
Get condensed x and y.
const std::vector< std::string > _primary_var_names
Name and ID of the corresponding coupled variable.
void getDofColRow()
Get row and col dofs for the condensed system.
std::vector< dof_id_type > _cols
void findZeroDiagonals(SparseMatrix< Number > &mat, std::vector< dof_id_type > &indices)
Check if the original jacobian has zero diagonal entries and save the row indices.
NonlinearSystemBase & _nl
The nonlinear system this PC is associated with (convenience reference)
std::unique_ptr< PetscMatrix< Number > > _K
std::vector< dof_id_type > _global_primary_dofs
const unsigned int _n_vars
Number of variables.
std::vector< dof_id_type > _zero_rows
The row indices that correspond to the zero diagonal entries in the original Jacobian matrix This is ...