LifeV
MonolithicBlockComposedNN.hpp
Go to the documentation of this file.
1 /* -*- mode: c++ -*- */
2 //@HEADER
3 /*
4 *******************************************************************************
5 
6  Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
7  Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
8 
9  This file is part of LifeV.
10 
11  LifeV is free software; you can redistribute it and/or modify
12  it under the terms of the GNU Lesser General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  LifeV is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  Lesser General Public License for more details.
20 
21  You should have received a copy of the GNU Lesser General Public License
22  along with LifeV. If not, see <http://www.gnu.org/licenses/>.
23 
24 *******************************************************************************
25 */
26 //@HEADER
27 
28 /*!
29  @file
30  @brief Block (a little exotic) preconditioner.
31 
32  @author Paolo Crosetto <crosetto@iacspc70.epfl.ch>
33  @date 29 Jun 2010
34 
35  It is the sum of the inverse of 2 Dirichlet and 2 Neumann problems.
36  */
37 
38 #ifndef COMPOSEDNN_H
39 #define COMPOSEDNN_H 1
40 
41 #include <lifev/fsi/solver/MonolithicBlockComposed.hpp>
42 
43 namespace LifeV
44 {
45 //! MonolithicBlockComposedNN - Short description of the class
46 /*!
47  @author Paolo Crosetto
48 
49  Class implementing a Neumann-Neumann composed preconditioner of the following type:
50  given the matrix \f$A=A_1A_2+A_3A_4\approx P_1P_2+P_3P_4\f$ then we compute the preconditioner
51  \f$P^1=P_4^{-1}P_3^{-1}+P_2^{-1}P_1^{-1}\f$.
52  In particular in this case we use for \f$A_1\f$ and \f$A_2\f$ Dirichlet problems, for \f$A_3\f$ and \f$A_4\f$ Neumann problems.
53 
54  Notice that if \f$P^{-1}=(2A)^{-1}+(2A)^{-1}=A^{-1}\f$. Thus the factors that we push_back in the preconditioners should be as close as possible to \f$2A\f$
55  */
56 class MonolithicBlockComposedNN: public MonolithicBlockComposed
57 {
58 public:
59 
60  enum Block { solid1, fluid1, solid2, fluid2 };
61  typedef MonolithicBlockComposed super_Type;
62  typedef ComposedOperator<Ifpack_Preconditioner> composed_prec;
63 
64 
65  //! @name Constructor & Destructor
66  //@{
67 
68  //! Empty Constructor
69  MonolithicBlockComposedNN (const std::vector<Int>& flag, const std::vector<Int>& order) :
70  super_Type ( flag, order ),
71  M_blockPrecs(),
72  M_prec()
73  {}
74 
75 
76  //! Destructor
77  ~MonolithicBlockComposedNN() {}
78 
79  //@}
80 
81 
82 
83  //! @name Public Methods
84  //@{
85 
86 
87  //! Sets the parameters needed by the preconditioner from data file (creates the Ifpack list)
88  /*!
89  @param data GetPot object reading the text data file
90  @param section string specifying the path in the data file where to find the options for the operator
91  */
92  void setDataFromGetPot ( const GetPot& data, const std::string& section );
93 
94  //! Solves the preconditioned linear system (used only when dealing with a preconditioner)
95  /*!
96  Provided the linear solver and the right hand side this method computes the preconditioners, builds the composed
97  operator (of type ComposedOperator) and solves the preconditioned linear system.
98  @param rhs right hand side of the linear system
99  @param result output result
100  @param linearSolver the linear system
101  */
102  virtual int solveSystem ( const vector_Type& rhs, vector_Type& step, solverPtr_Type& linearSolver);
103 
104 
105  //! Computes the coupling
106  /*!
107  computes all the coupling blocks specific for the chosen preconditioner. The coupling is handled
108  through an augmented formulation, introducing new variables (multipliers). Needs as input: the global map of the problem,
109  the FESpaces of the subproblems to be coupled with their offsets, a std::map holding the two numerations of the
110  interface between the two subproblems (the numeration can be different but the nodes must be matching in each
111  subdomain), an EpetraVector defined on the multipliers map containing the corresponding dof at the interface (NB: the multipliers map should be constructed from the second numeration in the std::map).
112  Note that the FESpaces and the offsets have to be set before calling this method.
113  @param map the map of the global problem
114  @param locDofMap std::map with the correspondence between the interface dofs for the two different maps in
115  the subproblems
116  @param numerationInterface vector containing the correspondence of the Lagrange multipliers with the interface dofs
117  */
118  virtual void coupler ( mapPtr_Type& map,
119  const std::map<ID, ID>& locDofMap,
120  const vectorPtr_Type& numerationInterface,
121  const Real& timeStep,
122  const Real& coefficient,
123  const Real& rescaleFactor);
124 
125  //!Applies the correspondent boundary conditions to every block
126  /*!
127  note that this method must be called after blockAssembling(), that sums the coupling conditions to the blocks. For
128  this type of preconditioners this method is overloaded. In fact in the diagonalization for the essential boundary
129  conditions the value replaced on the diagonal must be 2 instead of 1.
130  \param time: time
131  */
132  void applyBoundaryConditions (const Real& time, const UInt i);
133 
134  //! Multiplies the block times 2 and calls super_Type::push_back_matrix(...)
135  /*!
136  \param Mat: block matrix
137  \param recompute: flag stating if the matrix need to be recomputed
138  */
139  void push_back_matrix ( const matrixPtr_Type& Mat, const bool recompute );
140 
141  /*! Multiplies the block times 2 and calls super_Type::replace_matrix(...) in the position "position" specified in
142  input and in the shifted position "position"+2
143  \param oper: input matrix
144  \param position: position
145  */
146  void replace_matrix ( const matrixPtr_Type& oper, UInt position );
147 
148  bool set()
149  {
150  return (bool) M_blockPrecs.get() && M_blockPrecs->number();
151  }
152 
153 
154  //@}
155  //!@name Factory Method
156  //@{
157 
158  static MonolithicBlock* createComposedNN()
159  {
160  const Int order[] = { MonolithicBlockComposedNN::fluid1, MonolithicBlockComposedNN::solid1, MonolithicBlockComposedNN::fluid2, MonolithicBlockComposedNN::solid2};
161  const Int couplingsNN[] = { 8, 4, 1, 2};
162  const std::vector<Int> couplingVectorNN (couplingsNN, couplingsNN + 4);
163  const std::vector<Int> orderVector (order, order + 4);
164  return new MonolithicBlockComposedNN ( couplingVectorNN, orderVector );
165  }
166 
167  //@}
168 
169 
170 protected:
171 
172  //! @name Protected Members
173  //@{
174 
175  std::shared_ptr<ComposedOperator<ComposedOperator<Ifpack_Preconditioner> > > M_blockPrecs;
176  Teuchos::ParameterList M_list;
177  std::vector<std::shared_ptr<Ifpack_Preconditioner> > M_prec;
178 
179  //@}
180 
181 private:
182 
183  //! @name Private Members
184  //@{
185 
186  std::shared_ptr< composed_prec > M_firstCompPrec ;
187  std::shared_ptr< composed_prec > M_secondCompPrec;
188 
189  std::vector<matrix_Type> M_matrixVector; // \todo temporary, should be avoided
190  int M_overlapLevel;
191  std::string M_precType;
192 #ifdef HAVE_IFPACK_DYNAMIC_FACTORY
193  Ifpack_DynamicFactory M_factory;
194 #else
195  Ifpack M_factory;
196 #endif
197 
198  //@}
199 };
200 
201 } // Namespace LifeV
202 
203 #endif /* COMPOSEDNN_H */
void assignFunction(bcBase_Type &base)
Assign the function to the base of the BCHandler.
int32_type Int
Generic integer data.
Definition: LifeV.hpp:188
double Real
Generic real data.
Definition: LifeV.hpp:175
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191