LifeV
MonolithicBlockComposed Class Referenceabstract

MonolithicBlockComposed - Class handling block-structured preconditioners. More...

#include <MonolithicBlockComposed.hpp>

+ Inheritance diagram for MonolithicBlockComposed:
+ Collaboration diagram for MonolithicBlockComposed:

Public Types

enum  Block { solid, fluid, mesh }
 
- Public Types inherited from MonolithicBlock
typedef VectorEpetra vector_Type
 
typedef std::shared_ptr< vector_TypevectorPtr_Type
 
typedef MatrixEpetra< Realmatrix_Type
 
typedef std::shared_ptr< matrix_TypematrixPtr_Type
 
typedef std::shared_ptr< Epetra_OperatorepetraOperatorPtr_Type
 
typedef std::shared_ptr< Preconditionerepetra_preconditioner_ptrtype
 
typedef matrix_Type::matrix_type epetraMatrix_Type
 
typedef SolverAztecOO solver_Type
 
typedef std::shared_ptr< SolverAztecOOsolverPtr_Type
 
typedef FESpace< RegionMesh< LinearTetra >, MapEpetrafespace_Type
 
typedef std::shared_ptr< fespace_TypefespacePtr_Type
 
typedef std::shared_ptr< MapEpetramapPtr_Type
 
typedef std::shared_ptr< BCHandlerbchandlerPtr_Type
 

Public Types

typedef MonolithicBlock super_Type
 
typedef super_Type::fespacePtr_Type fespacePtr_Type
 
typedef ComposedOperator< Epetra_OperatoroperatorPtr_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 &section)=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_TypeM_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_TypeM_bch
 
std::vector< matrixPtr_TypeM_blocks
 
std::vector< fespacePtr_TypeM_FESpace
 
std::vector< UIntM_offset
 
vectorPtr_Type M_numerationInterface
 
std::shared_ptr< Epetra_Comm > M_comm
 

Detailed Description

MonolithicBlockComposed - Class handling block-structured preconditioners.

Author
Paolo Crosetto see [4]

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.

Member Typedef Documentation

◆ super_Type

Definition at line 75 of file MonolithicBlockComposed.hpp.

◆ fespacePtr_Type

◆ operatorPtr_Type

Member Enumeration Documentation

◆ Block

enum Block
Enumerator
solid 
fluid 
mesh 

Definition at line 71 of file MonolithicBlockComposed.hpp.

Constructor & Destructor Documentation

◆ MonolithicBlockComposed()

MonolithicBlockComposed ( const std::vector< Int > &  flags,
const std::vector< Int > &  order 
)
inline

Constructor.

The coupling and the order have to be specified in input. In particular the order specifies which block go first, second etc.

Parameters
flagsvector of flags specifying the type of coupling between the different blocks that we chose for this operator
ordervector specifying the order of the blocks.

Definition at line 89 of file MonolithicBlockComposed.hpp.

◆ ~MonolithicBlockComposed()

Definition at line 98 of file MonolithicBlockComposed.hpp.

Member Function Documentation

◆ solveSystem()

virtual int solveSystem ( const vector_Type rhs,
vector_Type step,
solverPtr_Type linearSolver 
)
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.

Parameters
rhsright hand side of the linear system
resultoutput result
linearSolverthe linear system

Implements MonolithicBlock.

Implemented in MonolithicBlockComposedDN, and MonolithicBlockComposedNN.

◆ setDataFromGetPot()

virtual void setDataFromGetPot ( const GetPot data,
const std::string &  section 
)
pure virtual

Sets the parameters needed by the preconditioner from data file.

Parameters
dataGetPot object reading the text data file
sectionstring specifying the path in the data file where to find the options for the operator

Implements MonolithicBlock.

Implemented in MonolithicBlockComposedDN, and MonolithicBlockComposedNN.

◆ set()

virtual bool set ( )
pure virtual

returns true if the operator is set

returns the length of the vector M_blocks

Implements MonolithicBlock.

Implemented in MonolithicBlockComposedDN, and MonolithicBlockComposedNN.

◆ GlobalAssemble()

void GlobalAssemble ( )
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.

◆ blockAssembling() [1/2]

void blockAssembling ( )
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.

◆ coupler()

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 
)
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.

Parameters
mapglobal MapEpetra of the problem
locDofMapstd::map holding the connections between the coupling interface dofs
numerationInterfacethe numeration of the interface dofs
timeSteptime step
couplingBlockUInt 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.
couplingBlockflag 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.

◆ push_back_matrix()

void push_back_matrix ( const matrixPtr_Type Mat,
const bool  recompute 
)
virtual

pushes a block at the end of the vector

adds a new block

Parameters
Matblock matrix to push
recomputeflag 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.

◆ push_back_oper()

void push_back_oper ( MonolithicBlockComposed Oper)
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.

Parameters
Operinput operator

Definition at line 97 of file MonolithicBlockComposed.cpp.

◆ push_back_coupling()

void push_back_coupling ( matrixPtr_Type coupling)
virtual

Pushes an extra coupling matrix at the end of the vector of coupling matrices.

Parameters
couplingextra coupling matrix

Implements MonolithicBlock.

Definition at line 104 of file MonolithicBlockComposed.cpp.

◆ replace_matrix()

void replace_matrix ( const matrixPtr_Type oper,
UInt  position 
)
virtual

replaces a block

replaces a block on a specified position in the vector

Parameters
Matblock matrix to push
indexposition in the vector

Implements MonolithicBlock.

Reimplemented in MonolithicBlockComposedNN.

Definition at line 109 of file MonolithicBlockComposed.cpp.

◆ replace_coupling()

void replace_coupling ( const matrixPtr_Type Mat,
UInt  index 
)
virtual

replaces a coupling block

replaces a coupling block on a specified position in the vector

Parameters
Matblock matrix to push
indexposition in the vector

Implements MonolithicBlock.

Definition at line 114 of file MonolithicBlockComposed.cpp.

◆ addToCoupling() [1/2]

void addToCoupling ( const matrixPtr_Type Mat,
UInt  position 
)
virtual

pushes a block at the end of the vector

adds a new block

Parameters
Matblock matrix to push
recomputeflag 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.

◆ addToCoupling() [2/2]

void addToCoupling ( const Real entry,
UInt  row,
UInt  col,
UInt  position 
)
virtual

adds an entry to the coupling matrix

Parameters
entryentry
rowrow for the insertion
colcolon for the insertion

Implements MonolithicBlock.

Definition at line 125 of file MonolithicBlockComposed.cpp.

◆ recompute()

const std::vector<bool>& recompute ( )
inline

returns the vector of flags (by const reference).

Definition at line 231 of file MonolithicBlockComposed.hpp.

◆ couplingVector()

const std::vector<matrixPtr_Type>& couplingVector ( ) const
inline

returns the vector of pointers to the coupling blocks (by const reference).

Definition at line 237 of file MonolithicBlockComposed.hpp.

◆ setRecompute()

void setRecompute ( UInt  position,
bool  flag 
)
inlinevirtual

turns on/off the recomputation of the preconditioner for a specified factor

Reimplemented from MonolithicBlock.

Definition at line 248 of file MonolithicBlockComposed.hpp.

◆ whereIsBlock()

const UInt whereIsBlock ( UInt  position) const
virtual

Implements MonolithicBlock.

Definition at line 173 of file MonolithicBlockComposed.cpp.

◆ blockAssembling() [2/2]

void blockAssembling ( const UInt  k)
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.

◆ swap()

void swap ( const UInt  i,
const UInt  j 
)
protectedvirtual

swaps the blocks

swaps two elements in the vectors of blocks, couplings, offsets, BC handlers, FE spaces, flags M_recompute

Parameters
ielement to swap
jelement to swap

Definition at line 157 of file MonolithicBlockComposed.cpp.

Field Documentation

◆ M_recompute

std::vector<bool> M_recompute
protected

vector of flags saying if the matrix is to be recomputed every time

Definition at line 281 of file MonolithicBlockComposed.hpp.

◆ M_coupling

std::vector<matrixPtr_Type> M_coupling
protected

vector of coupling matrices

Definition at line 283 of file MonolithicBlockComposed.hpp.

◆ M_couplingFlags

std::unique_ptr<std::vector<Int> > M_couplingFlags
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.

◆ M_blockReordering

std::unique_ptr<std::vector<Int> > M_blockReordering
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.


The documentation for this class was generated from the following files: