LifeV
ALESolver.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  @file
28  @brief Classes to hold algorithms for the mesh motion, for instance, involved in a ALE formulation.
29  @author D. Forti
30  @author G. Fourestey
31  @date 01-10-2007
32 
33  @contributor Simone Deparis <simone.deparis@epfl.ch>
34  @contributor Davide Forti <davide.forti@epfl.ch>
35  @maintainer Simone Deparis <simone.deparis@epfl.ch>
36 
37  This file contains classes which may be used to compute the extension inside the reference domain of a given
38  displacement at a specified interface. The techniques implemented are the harmonic extension and the
39  equations of lineary elasticity.
40 
41 */
42 
43 #ifndef ALESOLVER_H_
44 #define ALESOLVER_H_
45 
46 #include <lifev/core/LifeV.hpp>
47 #include <lifev/core/filter/GetPot.hpp>
48 #include <lifev/core/fem/DOF.hpp>
49 #include <lifev/core/array/MatrixElemental.hpp>
50 #include <lifev/core/fem/AssemblyElemental.hpp>
51 #include <lifev/core/fem/Assembly.hpp>
52 #include <lifev/core/fem/BCManage.hpp>
53 #include <lifev/core/fem/FESpace.hpp>
54 #include <lifev/core/util/Displayer.hpp>
55 #include <lifev/eta/fem/ETFESpace.hpp>
56 #include <lifev/eta/expression/Integrate.hpp>
57 
58 namespace LifeV
59 {
60 /*!
61  \class ALESolver
62 
63  Base class which provides the harmonic extension of a given displacement on a specified part
64  of the mesh boundary
65 
66  In order to deal with harmonic extensions, we have to provide a mesh (to be moved), the parameters
67  involved in the laplacian discretization: viscosity, quadrature rules and boundary conditions.
68  This class contains a PhysVectUnknown objet wich will hold the extension of the interface displacement.
69  The constructor of the class built the global matrix of the discretized laplacian. The extension of the
70  displacement is computed by calling the public method update. Finally, this extension can be recovered by
71  calling method getDisplacement.
72 
73 */
74 
75 class ALESolver
76 {
77 public:
78 
79  //! @name Public Types
80  //@{
81 
82  typedef RegionMesh<LinearTetra> mesh_Type;
83  typedef MatrixEpetra<Real> matrix_Type;
84  typedef std::shared_ptr<matrix_Type> matrixPtr_Type;
85  typedef VectorEpetra vector_Type;
86  typedef std::shared_ptr<vector_Type> vectorPtr_Type;
87  typedef ETFESpace< mesh_Type, MapEpetra, 3, 3 > ETFESpaceAle_Type;
88  typedef std::shared_ptr<ETFESpaceAle_Type> ETFESpaceAlePtr_Type;
89 
90  //@}
91 
92 
93  //! @name Constructor & Destructor
94  //@{
95 
96  //! Constructors for an harmonics extensions
97  /*!
98  \param mmFESpace the FEspace that describes the problem
99  \param comm the Epetra_Comm to be used for communication
100  */
101 
102  ALESolver ( FESpace<mesh_Type, MapEpetra>& mmFESpace, std::shared_ptr<Epetra_Comm> comm);
103 
104  //! Constructors for an harmonics extensions with offset
105  /*!
106  \param mmFESpace the FEspace that describes the problem
107  \param comm the Epetra_Comm to be used for communication
108  \param localMap use localMap instead of M_FESpace.map()
109  \param offset use this offset to fill the matrix (both: row and column offset)
110  */
111  ALESolver ( FESpace<mesh_Type, MapEpetra>& mmFESpace,
112  std::shared_ptr<Epetra_Comm> comm,
113  MapEpetra& localMap,
114  UInt offset = 0
115  );
116 
117  //! virtual destructor
118  virtual ~ALESolver() {};
119 
120  //@}
121 
122  //! @name Methods
123  //@{
124 
125  //! Set up data from GetPot
126  /*!
127  @param dataFile GetPot object
128  */
129  void setUp ( const GetPot& dataFile );
130 
131  //! Update convective term, boundary condition and solve the linearized ns system
132  /*!
133  @param bcHandler BC handler
134  */
135  void iterate (BCHandler& BCh);
136 
137  //! returns wheter this processor is the leader.
138  bool isLeader() const
139  {
140  return M_displayer.comm()->MyPID() == 0;
141  }
142 
143  //! manually rescale the system matrix by dt
144  void rescaleMatrix (Real& dt)
145  {
146  *M_matrHE *= dt;
147  }
148 
149  matrixPtr_Type const& matrix() const
150  {
151  return M_matrHE_BC;
152  }
153 
154  matrixPtr_Type const& matrix_noBC() const
155  {
156  return M_matrHE;
157  }
158 
159  void updateShapeDerivatives(Real& alpha,
160  const Real& density,
161  const Real& viscosity,
162  const vector_Type& un,
163  const vector_Type& uk,
164  //const vector_Type& disp,
165  const vector_Type& w,
166  FESpace<mesh_Type, MapEpetra>& velocityFESpace,
167  FESpace<mesh_Type, MapEpetra>& pressureFESpace,
168  bool wImplicit,
169  bool convectiveTermDerivative,
170  BCHandler& BCh);
171 
172  matrixPtr_Type const& shapeDerivativesVelocity() const
173  {
174  return M_matrShapeDerVel;
175  }
176 
177  matrixPtr_Type const& shapeDerivativesPressure() const
178  {
179  return M_matrShapeDerPressure;
180  }
181 
182  //! Adds the system matrix to the argument
183  void addSystemMatrixTo (matrixPtr_Type matr) const
184  {
185  *matr += *M_matrHE;
186  }
187 
188  //! Apply boundary conditions.
189  /*!
190  @param rightHandSide
191  @param bcHandler
192  */
193  void applyBoundaryConditions (vector_Type& rhs, BCHandler& BCh);
194 
195  //! Apply boundary conditions to the matrix.
196  /*!
197  @param bcHandler
198  */
199  void applyBoundaryConditions (BCHandler& BCh);
200 
201  void computeMatrix();
202  void updateDispDiff();
203 
204  //@}
205 
206 
207  //! @name Get Methods
208  //@{
209  vector_Type const& disp() const
210  {
211  return *M_disp;
212  }
213  vector_Type& disp()
214  {
215  return *M_disp;
216  }
217 
218  MapEpetra const& getMap() const
219  {
220  return M_localMap;
221  }
222 
223  FESpace<mesh_Type, MapEpetra> const& mFESpace() const
224  {
225  return M_FESpace;
226  }
227 
228  const std::shared_ptr<Epetra_Comm>& comm() const
229  {
230  return M_displayer.comm();
231  }
232  //@}
233 
234 private:
235 
236  //! Finite Element Space
237 
238  FESpace<mesh_Type, MapEpetra>& M_FESpace;
239 
240  //! local map
241  MapEpetra M_localMap;
242 
243  //! The matrix holding the values
244  matrixPtr_Type M_matrHE;
245  matrixPtr_Type M_matrHE_BC;
246 
247  //! The matrix holding the shape derivatives
248  matrixPtr_Type M_matrShapeDerVel;
249  matrixPtr_Type M_matrShapeDerPressure;
250 
251 
252  Displayer M_displayer;
253  int M_me;
254  bool M_verbose;
255 
256  //! Elementary matrix : 3 blocks
257  MatrixElemental M_elmat;
258 
259  //! The actual extension of the displacement
260  vectorPtr_Type M_disp;
261 
262  //! Auxiliary vector holding the second right hand of the system
263  vectorPtr_Type M_secondRHS;
264 
265  //! Diffusion coefficient for the laplacian operator
266  Real M_diffusion;
267 
268  UInt M_offset;
269 
270  bool M_linearElasticity;
271  Real M_young;
272  Real M_poisson;
273  ETFESpaceAlePtr_Type M_aleFESpace_ETA;
274 };
275 
276 } // namespace LifeV
277 #endif // ALESOLVER_H_