LifeV
|
MonolithicBlockComposed - Class handling block-structured preconditioners. More...
#include <MonolithicBlockComposed.hpp>
Public Types | |
enum | Block { solid, fluid, mesh } |
Public Types inherited from MonolithicBlock | |
typedef VectorEpetra | vector_Type |
typedef std::shared_ptr< vector_Type > | vectorPtr_Type |
typedef MatrixEpetra< Real > | matrix_Type |
typedef std::shared_ptr< matrix_Type > | matrixPtr_Type |
typedef std::shared_ptr< Epetra_Operator > | epetraOperatorPtr_Type |
typedef std::shared_ptr< Preconditioner > | epetra_preconditioner_ptrtype |
typedef matrix_Type::matrix_type | epetraMatrix_Type |
typedef SolverAztecOO | solver_Type |
typedef std::shared_ptr< SolverAztecOO > | solverPtr_Type |
typedef FESpace< RegionMesh< LinearTetra >, MapEpetra > | fespace_Type |
typedef std::shared_ptr< fespace_Type > | fespacePtr_Type |
typedef std::shared_ptr< MapEpetra > | mapPtr_Type |
typedef std::shared_ptr< BCHandler > | bchandlerPtr_Type |
Public Types | |
typedef MonolithicBlock | super_Type |
typedef super_Type::fespacePtr_Type | fespacePtr_Type |
typedef ComposedOperator< Epetra_Operator > | operatorPtr_Type |
Constructor and Destructor | |
MonolithicBlockComposed (const std::vector< Int > &flags, const std::vector< Int > &order) | |
Constructor. More... | |
~MonolithicBlockComposed () | |
Pure virtual methods | |
virtual int | solveSystem (const vector_Type &rhs, vector_Type &step, solverPtr_Type &linearSolver)=0 |
Solves the preconditioned linear system. More... | |
virtual void | setDataFromGetPot (const GetPot &data, const std::string §ion)=0 |
Sets the parameters needed by the preconditioner from data file. More... | |
virtual bool | set ()=0 |
returns true if the operator is set More... | |
Public Methods | |
void | GlobalAssemble () |
runs GlobalAssemble on the blocks More... | |
virtual void | blockAssembling () |
sums the coupling matrices with the corresponding blocks More... | |
void | coupler (mapPtr_Type &map, const std::map< ID, ID > &locDofMap, const vectorPtr_Type &numerationInterface, const Real &timeStep, const Real &coefficient, const Real &rescaleFactor, UInt couplingBlock) |
adds a default coupling matrix for a specified block. More... | |
virtual void | push_back_matrix (const matrixPtr_Type &Mat, const bool recompute) |
pushes a block at the end of the vector More... | |
virtual void | push_back_oper (MonolithicBlockComposed &Oper) |
Merges an input MonolithicBlockComposed operator with this one. More... | |
virtual void | push_back_coupling (matrixPtr_Type &coupling) |
Pushes an extra coupling matrix at the end of the vector of coupling matrices. More... | |
virtual void | replace_matrix (const matrixPtr_Type &oper, UInt position) |
replaces a block More... | |
virtual void | replace_coupling (const matrixPtr_Type &Mat, UInt index) |
replaces a coupling block More... | |
virtual void | addToCoupling (const matrixPtr_Type &Mat, UInt position) |
pushes a block at the end of the vector More... | |
void | addToCoupling (const Real &entry, UInt row, UInt col, UInt position) |
Get Methods | |
const std::vector< bool > & | recompute () |
returns the vector of flags (by const reference). More... | |
const std::vector< matrixPtr_Type > & | couplingVector () const |
returns the vector of pointers to the coupling blocks (by const reference). More... | |
Set Methods | |
void | setRecompute (UInt position, bool flag) |
turns on/off the recomputation of the preconditioner for a specified factor More... | |
const UInt | whereIsBlock (UInt position) const |
Protected Methods | |
void | blockAssembling (const UInt k) |
sums the coupling matrix in the specified position with the corresponding block More... | |
virtual void | swap (const UInt i, const UInt j) |
swaps the blocks More... | |
Protected Members | |
std::vector< bool > | M_recompute |
vector of flags saying if the matrix is to be recomputed every time More... | |
std::vector< matrixPtr_Type > | M_coupling |
vector of coupling matrices More... | |
std::unique_ptr< std::vector< Int > > | M_couplingFlags |
vector of flags specifying the coupling strategy for each block. More... | |
std::unique_ptr< std::vector< Int > > | M_blockReordering |
vector of reordering for the different blocks. More... | |
Additional Inherited Members | |
Public Member Functions inherited from MonolithicBlock | |
virtual void | replace_bch (bchandlerPtr_Type &, UInt) |
replaces a BCHandler More... | |
virtual void | applyBoundaryConditions (const Real &time) |
Applies the correspondent boundary conditions to every block. More... | |
virtual void | applyBoundaryConditions (const Real &time, const UInt block) |
Applies the correspondent boundary conditions to a specified block. More... | |
virtual void | resetBlocks () |
resets the blocks (frees the shared pointers) More... | |
virtual void | setComm (std::shared_ptr< Epetra_Comm > comm) |
sets the communicator More... | |
virtual void | reset () |
resets the blocks, boundary conditions, FE spaces. More... | |
virtual void | setRobin (matrixPtr_Type &, vectorPtr_Type &) |
Applies the robin preconditioners. More... | |
void | couplingMatrix (matrixPtr_Type &bigMatrix, Int flag, const std::vector< fespacePtr_Type > &problem, const std::vector< UInt > &offset, const std::map< ID, ID > &locDofMap, const vectorPtr_Type &numerationInterface, const Real &timeStep=1.e-3, const Real &value=1., const Real &coefficient=1., const Real &rescaleFactor=1.) |
builds the coupling matrix. More... | |
void | setConditions (std::vector< bchandlerPtr_Type > &vec) |
sets the vector of raw pointer to the BCHandler More... | |
void | setSpaces (std::vector< fespacePtr_Type > &vec) |
sets the vector of raw pointer to the FESpaces More... | |
void | setOffsets (UInt blocks,...) |
sets the vector of raw pointer to the offsets of the different blocks More... | |
void | robinCoupling (MonolithicBlock::matrixPtr_Type &matrix, Real &alphaf, Real &alphas, UInt coupling, const MonolithicBlock::fespacePtr_Type &FESpace1, const UInt &offset1, const MonolithicBlock::fespacePtr_Type &FESpace2, const UInt &offset2, const std::map< ID, ID > &locDofMap, const MonolithicBlock::vectorPtr_Type &numerationInterface) |
computes the Robin coupling matrix More... | |
virtual void | addToBlock (const matrixPtr_Type &Mat, UInt position) |
virtual void | push_back_oper (MonolithicBlock &Oper) |
Pushes a new block. More... | |
MonolithicBlock () | |
Empty Constructor. More... | |
virtual | ~MonolithicBlock () |
Destructor. More... | |
virtual void | setupSolver (solver_Type &, const GetPot &) |
Sets the parameters needed by the preconditioner from data file. More... | |
virtual void | coupler (mapPtr_Type &map, const std::map< ID, ID > &locDofMap, const vectorPtr_Type &numerationInterface, const Real &timeStep, const Real &coefficient, const Real &rescaleFactor)=0 |
Computes the coupling. More... | |
virtual void | replace_precs (const epetraOperatorPtr_Type &, UInt) |
replace a block preconditioner More... | |
virtual void | push_back_precs (const epetraOperatorPtr_Type &) |
pushes back a block preconditioner More... | |
const std::vector< matrixPtr_Type > & | blockVector () |
returns the vector of pointers to the blocks (by const reference). More... | |
const std::vector< bchandlerPtr_Type > & | BChVector () |
returns the vector of pointers to the BCHandlers (by const reference). More... | |
const std::vector< fespacePtr_Type > & | FESpaceVector () |
returns the vector of pointers to the FE spaces (by const reference). More... | |
const std::vector< UInt > & | offsetVector () |
returns the vector of the offsets (by const reference). More... | |
Protected Member Functions inherited from MonolithicBlock | |
template<typename Operator > | |
void | swap (std::shared_ptr< Operator > &operFrom, std::shared_ptr< Operator > &OperTo) |
swaps two std::shared_ptr. The tamplate argument of the shared_ptr is templated More... | |
template<typename Operator > | |
void | insert (std::vector< Operator > &operFrom, std::vector< Operator > &OperTo) |
swaps two std::shared_ptr. The tamplate argument of the shared_ptr is templated More... | |
Protected Attributes inherited from MonolithicBlock | |
std::vector< bchandlerPtr_Type > | M_bch |
std::vector< matrixPtr_Type > | M_blocks |
std::vector< fespacePtr_Type > | M_FESpace |
std::vector< UInt > | M_offset |
vectorPtr_Type | M_numerationInterface |
std::shared_ptr< Epetra_Comm > | M_comm |
MonolithicBlockComposed - Class handling block-structured preconditioners.
Pure virtual class which is suited for handling a block-structured matrix that can be written as a multiplication of a variable number of factors. It contains a vector of pointers for each factor, BCHandler, FESpace and for each coupling part.
It can be used e.g. to build preconditioners for the FSI system which are composed of different factors. It derives from the pure virtual class MonolithicBlock, it is still pure virtual and it is intended to be the base class for every preconditioner that can be split into factors. Notice that the vector of the preconditioned factors is missing, because it has to be implemented in the children. It could be for instance of type ComposedOperator<T> or PreconditionerComposed.
Definition at line 67 of file MonolithicBlockComposed.hpp.
typedef MonolithicBlock super_Type |
Definition at line 75 of file MonolithicBlockComposed.hpp.
Definition at line 76 of file MonolithicBlockComposed.hpp.
Definition at line 77 of file MonolithicBlockComposed.hpp.
enum Block |
Enumerator | |
---|---|
solid | |
fluid | |
mesh |
Definition at line 71 of file MonolithicBlockComposed.hpp.
|
inline |
Constructor.
The coupling and the order have to be specified in input. In particular the order specifies which block go first, second etc.
flags | vector of flags specifying the type of coupling between the different blocks that we chose for this operator |
order | vector specifying the order of the blocks. |
Definition at line 89 of file MonolithicBlockComposed.hpp.
|
inline |
Definition at line 98 of file MonolithicBlockComposed.hpp.
|
pure virtual |
Solves the preconditioned linear system.
Provided the linear solver and the right hand side this method computes the solution and returns it into the result vector.
rhs | right hand side of the linear system |
result | output result |
linearSolver | the linear system |
Implements MonolithicBlock.
Implemented in MonolithicBlockComposedDN, and MonolithicBlockComposedNN.
|
pure virtual |
Sets the parameters needed by the preconditioner from data file.
data | GetPot object reading the text data file |
section | string specifying the path in the data file where to find the options for the operator |
Implements MonolithicBlock.
Implemented in MonolithicBlockComposedDN, and MonolithicBlockComposedNN.
|
pure virtual |
returns true if the operator is set
returns the length of the vector M_blocks
Implements MonolithicBlock.
Implemented in MonolithicBlockComposedDN, and MonolithicBlockComposedNN.
|
virtual |
runs GlobalAssemble on the blocks
Public Methods.
closes and distributes all the blocks in the vector M_blocks, before computing the preconditioner.
Implements MonolithicBlock.
Definition at line 40 of file MonolithicBlockComposed.cpp.
|
virtual |
sums the coupling matrices with the corresponding blocks
Everything (but the boundary conditions assembling) must have been set before calling this
Reimplemented from MonolithicBlock.
Reimplemented in MonolithicBlockComposedDND.
Definition at line 52 of file MonolithicBlockComposed.cpp.
|
virtual |
adds a default coupling matrix for a specified block.
The default coupling matrix it is an identity matrix with zeros on the diagonal corresponding to the specified block. The couplings are specified through the vector M_couplingFlags, as usual. If the coupling block is not the last one in the M_coupling vector then it is inserted at the specified position.
map | global MapEpetra of the problem |
locDofMap | std::map holding the connections between the coupling interface dofs |
numerationInterface | the numeration of the interface dofs |
timeStep | time step |
couplingBlock | UInt specifying the position of the coupling block to be added. Not used in this case, since the coupling flag for each block is contained in the vector M_couplingFlags. See MonolithicBlock::couplingMatrix to understand what the values for this flag correspond to. |
couplingBlock | flag specifying which block is considered (must not exceed the size of the vector of blocks, otherwise a std::bad_alloc exception is thrown). The coupling for each block is specified by a static vector passed to the constructor. |
Implements MonolithicBlock.
Definition at line 66 of file MonolithicBlockComposed.cpp.
|
virtual |
pushes a block at the end of the vector
adds a new block
Mat | block matrix to push |
recompute | flag stating wether the preconditioner for this block have to be recomputed at every time step |
Implements MonolithicBlock.
Reimplemented in MonolithicBlockComposedNN.
Definition at line 91 of file MonolithicBlockComposed.cpp.
|
virtual |
Merges an input MonolithicBlockComposed operator with this one.
pushes the operator vector of the input operator at the end of the operatoe vector of this instance, and does the same for the vector of coupling matrices.
Oper | input operator |
Definition at line 97 of file MonolithicBlockComposed.cpp.
|
virtual |
Pushes an extra coupling matrix at the end of the vector of coupling matrices.
coupling | extra coupling matrix |
Implements MonolithicBlock.
Definition at line 104 of file MonolithicBlockComposed.cpp.
|
virtual |
replaces a block
replaces a block on a specified position in the vector
Mat | block matrix to push |
index | position in the vector |
Implements MonolithicBlock.
Reimplemented in MonolithicBlockComposedNN.
Definition at line 109 of file MonolithicBlockComposed.cpp.
|
virtual |
replaces a coupling block
replaces a coupling block on a specified position in the vector
Mat | block matrix to push |
index | position in the vector |
Implements MonolithicBlock.
Definition at line 114 of file MonolithicBlockComposed.cpp.
|
virtual |
pushes a block at the end of the vector
adds a new block
Mat | block matrix to push |
recompute | flag stating wether the preconditioner for this block have to be recomputed at every time step |
Implements MonolithicBlock.
Definition at line 119 of file MonolithicBlockComposed.cpp.
adds an entry to the coupling matrix
entry | entry |
row | row for the insertion |
col | colon for the insertion |
Implements MonolithicBlock.
Definition at line 125 of file MonolithicBlockComposed.cpp.
|
inline |
returns the vector of flags (by const reference).
Definition at line 231 of file MonolithicBlockComposed.hpp.
|
inline |
returns the vector of pointers to the coupling blocks (by const reference).
Definition at line 237 of file MonolithicBlockComposed.hpp.
|
inlinevirtual |
turns on/off the recomputation of the preconditioner for a specified factor
Reimplemented from MonolithicBlock.
Definition at line 248 of file MonolithicBlockComposed.hpp.
Implements MonolithicBlock.
Definition at line 173 of file MonolithicBlockComposed.cpp.
|
protectedvirtual |
sums the coupling matrix in the specified position with the corresponding block
Protected Methods.
Everything (but the boundary conditions assembling) must have been set before calling this
Reimplemented from MonolithicBlock.
Definition at line 145 of file MonolithicBlockComposed.cpp.
swaps the blocks
swaps two elements in the vectors of blocks, couplings, offsets, BC handlers, FE spaces, flags M_recompute
i | element to swap |
j | element to swap |
Definition at line 157 of file MonolithicBlockComposed.cpp.
|
protected |
vector of flags saying if the matrix is to be recomputed every time
Definition at line 281 of file MonolithicBlockComposed.hpp.
|
protected |
vector of coupling matrices
Definition at line 283 of file MonolithicBlockComposed.hpp.
|
protected |
vector of flags specifying the coupling strategy for each block.
In particular for each block the method couplingMatrix is called with the corresponding flag in this vector. The coupling vector is passed to the constructor when the preconditioner is registered in the factory. So each coupling vector defines a new preconditioner type. It is created statically before the registration, then it is copied into this scoped_ptr.
Definition at line 292 of file MonolithicBlockComposed.hpp.
|
protected |
vector of reordering for the different blocks.
the order in which the factors are allpied is specified by this vector. e.g. the fisrt block to be applied corresponds to the number M_blockReordering[0] in the vector M_blocks of blocks. This vector is assigned in the coupler method of each class.
Definition at line 299 of file MonolithicBlockComposed.hpp.