LifeV
FSIExactJacobian.hpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3 *******************************************************************************
4 
5  Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
6  Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
7 
8  This file is part of LifeV.
9 
10  LifeV is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  LifeV is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with LifeV. If not, see <http://www.gnu.org/licenses/>.
22 
23 *******************************************************************************
24 */
25 //@HEADER
26 
27 /*!
28  @file
29  @brief Implementation of an FSI (Operator) with Newton algorithm.
30 
31  @author Miguel Fernandez
32  @author Gilles Fourestey
33  @author Paolo Crosetto <paolo.crosetto@epfl.ch>
34  @date 10-06-2010
35 
36  @contributor Simone Deparis <simone.deparis@epfl.ch>
37  @maintainer Simone Deparis <simone.deparis@epfl.ch>
38  */
39 
40 
41 #ifndef FSIEXACTJACOBIAN_HPP
42 #define FSIEXACTJACOBIAN_HPP
43 
44 #include <lifev/fsi/solver/FSIOperator.hpp>
45 
46 namespace LifeV
47 {
48 
49 //! FSIModelExactJacobian - Implementation of an FSI (Operator) with Newton algorithm.
50 /*!
51  @author Miguel Fernandez
52  @author Gilles Fourestey
53  @author Paolo Crosetto <paolo.crosetto@epfl.ch>
54  @see \cite FernandezMoubachir2005
55  FSIOperator
56 
57  This class implements an FSIOperator whose Jacobian is computed exacly, i.e., using
58  shape dericatives.
59 
60 */
61 
62 class FSIExactJacobian : public FSIOperator
63 {
64 public:
65 
66  //! @name Public Types
67  //@{
68  typedef FSIOperator super;
69 
70  typedef super::vector_Type vector_Type;
71  typedef super::vectorPtr_Type vectorPtr_type;
72 
75 
76  //typedef super::fluid_Type fluid_Type;
77  typedef super::solid_Type solid_Type;
78 
79  //@}
80 
81 
82  //! @name Constructor & Destructor
83  //@{
84 
85  //! Empty Constructor
87 
88  //! Destructor
90  //@}
91 
92  //! @name Methods
93  //@{
94 
95  //! solves the Jacobian system
96  /**
97  The implementation of this method distinguish the various FSI formulations which derive from this class.
98  For this reason it must be pure virtual, snd implemented in the child classes.
99  \param muk: unknown solution at the k-th nonlinear iteration
100  \param res: residual vector (the right hand side of the Jacobian system)
101  \param linearRelTol: tolerance for the nonlinear solver
102  \todo{replace Real with Real& }
103  */
104  void solveJac (vector_Type& _muk,
105  const vector_Type& _res,
106  const Real _linearRelTol);
107 
108  //! Evaluates the nonlinear residual of the FSI system
109  /**
110  The implementation of this method also depends on the child classes, though it does not characterize them.
111  \param res: residual vector to be computed
112  \param disp: current unknown solution
113  \param iter: nonlinear iteration counter. The part of th rhs related to the time discretization is computed only for iter=0
114  */
115  void evalResidual (vector_Type& _res,
116  const vector_Type& _disp,
117  const UInt _iter);
118 
119  //! Solves the linear fluid problem
120  /** this method is called only by the class Epetra_ExactJacobian
121  */
122  void solveLinearFluid();
123 
124  //! Solves the linear structure problem
125  /** this method is called only by the class Epetra_ExactJacobian
126  */
127  void solveLinearSolid();
128 
129  //! sets the space discretization parameters
130  /*!
131  The FE discretization is set accordingly to what specified in the FSIdata member (order of accuracy for the fluid
132  pressure, velocity and for the structure).
133  */
134  void setupFEspace();
135 
136  //! setup of the fluid and solid solver classes
137  /**
138  This method computes the number of fluxes assigned at the boundaries and calls setupFluidSolid(UInt fluxes)
139  */
140  void setupFluidSolid();
141 
142  //! initializes the GetPot data file
143  void setDataFile ( GetPot const& data );
144 
145  //! should call bcManage for a vector, but the implementation is empty
146  void bcManageVec ( super::fluidBchandler_Type& /*bch*/, vector_Type& /*rhs*/ ) {};
147 
148  //! register the product for the factory
149  void registerMyProducts( );
150 
151  //@}
152 
153 private:
154 
155  //! @name Private Methods
156  //@{
157 
158  UInt imposeFlux( );
159 
160  void eval (const vector_Type& _res, UInt status);
161 
162 
163  //@}
164 
165  //! Epetra_ExactJacobian This class implements an Epetra_Operator to be passed to AztecOO.
166  /*!
167 
168  @author Gilles Fourestey
169  @see
170  exactJacobian
171 
172  This class relies on exactJacobian to solve the linear jacobian problem
173 
174  */
175 
177  public Epetra_Operator
178  {
179 
180  public:
181 
182  typedef FSIExactJacobian::vector_Type vector_Type;
185 
186  // OBSOLETE typedef
187  // typedef exactJacobian::vector_Type vector_Type;
188 
189  //! @name Constructor & Destructor
190  //@{
191  //! Empty Constructor
193 
194  //! Destructor
195  virtual ~Epetra_ExactJacobian() {};
196  //@}
197 
198  //! @name Methods
199  //@{
200 
201  //! sets the exactJacobian pointer and some contents thereof
202  void setOperator (FSIExactJacobian* ej);
203 
204  //! apply the jacobian to X and returns the result in Y
205  int Apply (const Epetra_MultiVector& X, Epetra_MultiVector& Y) const;
206 
207  //! These are the methods necessary to implement Epetra_Operator but that are not used.
208  int SetUseTranspose (bool /*UseTranspose*/)
209  {
210  std::cout << "********* EJ : transpose not available\n";
211  return -1;
212  }
213 
214  int ApplyInverse (const Epetra_MultiVector& /*X*/, Epetra_MultiVector& /*Y*/) const
215  {
216  std::cout << "********* EJ : inverse not available\n";
217  return -1;
218  }
219  double NormInf () const
220  {
221  std::cout << "********* EJ : NormInf not available\n";
222  return 1.;
223  }
224  const char* Label () const
225  {
226  return "exactJacobian";
227  }
228  bool UseTranspose () const
229  {
230  return false;
231  }
232  bool HasNormInf () const
233  {
234  return false;
235  }
236 
237  const Epetra_Comm& Comm () const
238  {
239  return *M_comm;
240  }
242  {
243  return *M_operatorDomainMap;
244  }
245  const Epetra_Map& OperatorRangeMap () const
246  {
247  return *M_operatorRangeMap;
248  }
249  //@}
250 
251 
252  private:
253 
255 
258 
260 
261  }; // end of class Epetra_ExactJacobian
262 
263 
264  vectorPtr_Type M_rhsNew;
265  vectorPtr_Type M_beta;
266 
267  NonLinearAitken<vector_Type> M_aitkFS;
268 
269  SolverAztecOO M_linearSolver;
271 
274 
275 
276 }; // end class exactJacobian
277 
278 
279 inline FSIOperator* createEJ()
280 {
281  return new FSIExactJacobian();
282 }
283 
284 namespace
285 {
286 //static bool registerEJ = FSIOperator::FSIFactory_Type::instance().registerProduct( "exactJacobian", &createEJ );
287 }
288 
289 } // Namespace LifeV
290 
291 #endif // EXACTJACOBIANBASE_HPP
void setOperator(FSIExactJacobian *ej)
sets the exactJacobian pointer and some contents thereof
void solveLinearSolid()
Solves the linear structure problem.
void assignFunction(bcBase_Type &base)
Assign the function to the base of the BCHandler.
super::vectorPtr_Type vectorPtr_type
void registerMyProducts()
register the product for the factory
void eval(const vector_Type &_res, UInt status)
void solveLinearFluid()
Solves the linear fluid problem.
FSIExactJacobian()
Empty Constructor.
void setDataFile(GetPot const &data)
initializes the GetPot data file
FSIOperator * createEJ()
void bcManageVec(super::fluidBchandler_Type &, vector_Type &)
should call bcManage for a vector, but the implementation is empty
NonLinearAitken - LifeV class for the non-linear generalized Aitken algorithm.
Epetra_ExactJacobian This class implements an Epetra_Operator to be passed to AztecOO.
double Real
Generic real data.
Definition: LifeV.hpp:175
FSIModelExactJacobian - Implementation of an FSI (Operator) with Newton algorithm.
int ApplyInverse(const Epetra_MultiVector &, Epetra_MultiVector &) const
void setupFluidSolid()
setup of the fluid and solid solver classes
void setupFEspace()
sets the space discretization parameters
void evalResidual(vector_Type &_res, const vector_Type &_disp, const UInt _iter)
Evaluates the nonlinear residual of the FSI system.
int SetUseTranspose(bool)
These are the methods necessary to implement Epetra_Operator but that are not used.
int Apply(const Epetra_MultiVector &X, Epetra_MultiVector &Y) const
apply the jacobian to X and returns the result in Y
NonLinearAitken< vector_Type > M_aitkFS
Epetra_ExactJacobian M_epetraOper
fluid_Type::matrixPtr_Type matrixPtr_Type
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
fluid_Type::matrix_Type matrix_Type
void solveJac(vector_Type &_muk, const vector_Type &_res, const Real _linearRelTol)
solves the Jacobian system