LifeV
StabilizationSUPG.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 SUPG stabilization.
29  @author Davide Forti <davide.forti@epfl.ch>
30  @maintainer Davide Forti <davide.forti@epfl.ch>
31  @date 03-02-2015
32 
33  This file contains an ETA implementation of SUPG (for fixed domains), fully implicit.
34 
35  For reference, see Paper Y. Bazilevs, V.M. Calo, J.A. Cottrell, T.J.R. Hughes, A. Reali, and G. Scovazzi. <i>Variational multiscale
36  residual-based turbulence modeling for large eddy simulation of incompressible flows</i>. Comput. Methods Appl. Mech. Engr. 197(1):173–201, 2007.
37 
38  If using this class to generate your results, please <b>cite</b>:
39  - D. Forti, L. Dede'. <i> Semi-implicit BDF time discretization of the Navier–Stokes equations with VMS-LES modeling in a High Performance Computing framework</i>.
40  Comput. Fluids. 197(1):168-182, 2015.
41 
42 */
43 
44 #ifndef _STABILIZATIONSUPG_HPP_
45 #define _STABILIZATIONSUPG_HPP_ 1
46 
47 // Tell the compiler to ignore specific kind of warnings:
48 #pragma GCC diagnostic ignored "-Wunused-variable"
49 #pragma GCC diagnostic ignored "-Wunused-parameter"
50 
51 #include <Epetra_ConfigDefs.h>
52 #ifdef EPETRA_MPI
53  #include <mpi.h>
54  #include <Epetra_MpiComm.h>
55 #else
56  #include <Epetra_SerialComm.h>
57 #endif
58 
59 #include <Epetra_FECrsMatrix.h>
60 
61 //Tell the compiler to restore the warning previously silented
62 #pragma GCC diagnostic warning "-Wunused-variable"
63 #pragma GCC diagnostic warning "-Wunused-parameter"
64 
65 #include <lifev/navier_stokes_blocks/solver/Stabilization.hpp>
66 
67 #include <lifev/core/fem/FESpace.hpp>
68 #include <lifev/core/fem/ReferenceFE.hpp>
69 
70 #include <lifev/eta/fem/ETFESpace.hpp>
71 
72 // includes for building the matrix graph
73 #include <Epetra_FECrsGraph.h>
74 #include <lifev/eta/expression/Integrate.hpp>
75 #include <lifev/eta/expression/BuildGraph.hpp>
76 
77 namespace LifeV
78 {
79 
80 
82 {
83 public:
84  typedef Real return_Type;
85 
86  inline return_Type operator() (const Real& a)
87  {
88  return std::sqrt(a);
89  }
90 
92  SquareRoot (const SquareRoot&) {}
93  ~SquareRoot() {}
94 };
95 
97 {
98 public:
99 
100  //@name Public Types
101  //@{
102 
105 
106  typedef VectorEpetra vector_Type;
108 
111 
114 
117 
120 
123 
124  //@}
125 
126  //! @name Constructor and Destructor
127  //@{
128 
129  //! Default Constructor
131 
132  //! ~Destructor
133  virtual ~StabilizationSUPG(){}
134 
135  //@}
136 
137  //! @name Methods
138  //@{
139 
140  //! Updates the jacobian matrix
141  /*!
142  @param velocity_previous_newton_step velocity from the previous Newton step
143  @param pressure_previous_newton_step pressure from the previous Newton step
144  @param velocity_rhs velocity term from approximation time derivative
145  */
146  void apply_matrix( const vector_Type& velocity_previous_newton_step,
147  const vector_Type& pressure_previous_newton_step,
148  const vector_Type& velocity_rhs );
149 
150  //! Adds to the residual the contribution coming from the SUPG stabilization
151  /*!
152  @param residual_velocity velocity component of the residual
153  @param residual_pressure pressure component of the residual
154  @param velocity_previous_newton_step velocity from the previous Newton step
155  @param pressure_previous_newton_step pressure from the previous Newton step
156  @param velocity_rhs velocity term from approximation time derivative
157  */
158  void apply_vector( vectorPtr_Type& residual_velocity,
159  vectorPtr_Type& residual_pressure,
160  const vector_Type& velocity_previous_newton_step,
161  const vector_Type& pressure_previous_newton_step,
162  const vector_Type& velocity_rhs);
163 
164  //! Build the graphs of each single block
165  void buildGraphs();
166 
167  //@}
168 
169  //! @name Setters
170  //@{
171 
172  //! Set velocity FE space
173  /*!
174  * @param velocityFESpace FE space velocity
175  */
176  void setVelocitySpace(fespacePtr_Type velocityFESpace){ M_uFESpace = velocityFESpace;}
177 
178  //! Set pressure FE space
179  /*!
180  * @param pressureFESpace FE space velocity
181  */
182  void setPressureSpace(fespacePtr_Type pressureFESpace){ M_pFESpace = pressureFESpace;}
183 
184  //! Set the constant C_I for the supg
185  /*!
186  * @param value order of velocity FE degree used
187  */
188  void setConstant (const int & value);
189 
190  //! Set the fluid density
191  /*!
192  * @param density value of density
193  */
194  void setDensity (const Real & density) { M_density = density;}
195 
196  //! Set the bdf order
197  /*!
198  * @param bdfOrder order BDF scheme
199  */
200  void setBDForder (const Real & bdfOrder) { M_bdfOrder = bdfOrder;}
201 
202  //! Set the bdf order
203  /*!
204  * @param alpha value of alpha (coefficient in front of u^n+1) of the BDF scheme
205  */
206  void setAlpha (const Real & alpha) { M_alpha = alpha;}
207 
208  //! Set the fluid dynamic viscosity
209  /*!
210  * @param viscosity value of the dynamic viscosity
211  */
212  void setViscosity (const Real & viscosity) { M_viscosity = viscosity;}
213 
214  //! Set the Epetra communicator
215  /*!
216  * @param comm communicator
217  */
218  void setCommunicator (std::shared_ptr<Epetra_Comm> comm) { M_comm = comm;}
219 
220  //! Set the time step size
221  /*!
222  * @param timestep time step size
223  */
224  void setTimeStep (const Real & timestep) { M_timestep = timestep;}
225 
226  //! Set Expression Template FE space for velocity
227  /*!
228  * @param velocityEta_fespace Expression Template FE space for velocity
229  */
230  void setETvelocitySpace(const ETFESpacePtr_velocity & velocityEta_fespace){ M_fespaceUETA = velocityEta_fespace;}
231 
232  //! Set Expression Template FE space for pressure
233  /*!
234  * @param pressureEta_fespace Expression Template FE space for pressure
235  */
236  void setETpressureSpace(const ETFESpacePtr_pressure & pressureEta_fespace){ M_fespacePETA = pressureEta_fespace;}
237 
238  //! Set if using matrix graph
239  /*!
240  * @param useGraph true or false
241  */
242  void setUseGraph (const bool& useGraph) { M_useGraph = useGraph; }
243 
244  //@}
245 
246  //! @name Getters
247  //@{
248 
249  //! Get block00 of the stabilization matrix
250  /*!
251  * @return M_block_00 block00 of the stabilization matrix
252  */
253  matrixPtr_Type const& block_00() const
254  {
255  return M_block_00;
256  }
257 
258  //! Get block01 of the stabilization matrix
259  /*!
260  * @return M_block_01 block01 of the stabilization matrix
261  */
262  matrixPtr_Type const& block_01() const
263  {
264  return M_block_01;
265  }
266 
267  //! Get block10 of the stabilization matrix
268  /*!
269  * @return M_block_10 block10 of the stabilization matrix
270  */
271  matrixPtr_Type const& block_10() const
272  {
273  return M_block_10;
274  }
275 
276  //! Get block11 of the stabilization matrix
277  /*!
278  * @return M_block_11 block11 of the stabilization matrix
279  */
280  matrixPtr_Type const& block_11() const
281  {
282  return M_block_11;
283  }
284 
285  //! Get name of stabilization used
286  /*!
287  * @return M_label name of stabilization used
288  */
289  std::string label () { return M_label; }
290 
291  //@}
292 
293 private:
294 
295  //! @name Private Attributes
296  //@{
297 
298  //! finite element spaces for velocity and pressure
301 
304 
305  //! Epetra communicator
307 
308  //! fluid dynamic viscosity @f$\nu@f$
310 
311  //! fluid density @f$\nu@f$
313 
314  //! stabilization parameters for the momentum and continuity equations
319 
321 
322  // Graphs
327 
328  // Matrices
333 
335 
337 
338  //@}
339 }; // class StabilizationSUPG
340 
341 //! Factory create function
343 {
344  return new StabilizationSUPG();
345 }
346 namespace
347 {
349 }
350 
351 } // namespace LifeV
352 
353 #endif /* _STABILIZATIONSUPG_HPP_ */
std::shared_ptr< fespace_Type > fespacePtr_Type
void setUseGraph(const bool &useGraph)
Set if using matrix graph.
void apply_matrix(const vector_Type &velocity_previous_newton_step, const vector_Type &pressure_previous_newton_step, const vector_Type &velocity_rhs)
Updates the jacobian matrix.
fespacePtr_Type M_uFESpace
finite element spaces for velocity and pressure
StabilizationSUPG * createStabilizationSUPG()
Factory create function.
return_Type operator()(const Real &a)
std::string label()
Get name of stabilization used.
Real M_density
fluid density
FESpace - Short description here please!
Definition: FESpace.hpp:78
ETFESpacePtr_pressure M_fespacePETA
std::shared_ptr< Epetra_Comm > M_comm
Epetra communicator.
void importFromHDF5(std::string const &fileName, std::string const &matrixName="matrix")
Read a matrix from a HDF5 (.h5) file.
void setConstant(const int &value)
Set the constant C_I for the supg.
std::shared_ptr< ETFESpace_velocity > ETFESpacePtr_velocity
void setViscosity(const Real &viscosity)
Set the fluid dynamic viscosity.
Real M_viscosity
fluid dynamic viscosity
matrixPtr_Type const & block_00() const
Get block00 of the stabilization matrix.
std::shared_ptr< ETFESpace_pressure > ETFESpacePtr_pressure
void setETpressureSpace(const ETFESpacePtr_pressure &pressureEta_fespace)
Set Expression Template FE space for pressure.
void setTimeStep(const Real &timestep)
Set the time step size.
ETFESpace< mesh_Type, map_Type, 3, 3 > ETFESpace_velocity
void setPressureSpace(fespacePtr_Type pressureFESpace)
Set pressure FE space.
void buildGraphs()
Build the graphs of each single block.
matrixPtr_Type const & block_10() const
Get block10 of the stabilization matrix.
void setVelocitySpace(fespacePtr_Type velocityFESpace)
Set velocity FE space.
Epetra_Import const & importer()
Getter for the Epetra_Import.
Definition: MapEpetra.cpp:394
void setCommunicator(std::shared_ptr< Epetra_Comm > comm)
Set the Epetra communicator.
void setAlpha(const Real &alpha)
Set the bdf order.
Real M_timestep
stabilization parameters for the momentum and continuity equations
virtual ~StabilizationSUPG()
~Destructor
SquareRoot(const SquareRoot &)
std::shared_ptr< Epetra_FECrsGraph > graphPtr_Type
matrixPtr_Type const & block_11() const
Get block11 of the stabilization matrix.
double Real
Generic real data.
Definition: LifeV.hpp:175
MatrixEpetra< Real > matrix_Type
void setETvelocitySpace(const ETFESpacePtr_velocity &velocityEta_fespace)
Set Expression Template FE space for velocity.
std::shared_ptr< matrix_Type > matrixPtr_Type
StabilizationSUPG()
Default Constructor.
ETFESpacePtr_velocity M_fespaceUETA
void setBDForder(const Real &bdfOrder)
Set the bdf order.
RegionMesh< LinearTetra > mesh_Type
void setDensity(const Real &density)
Set the fluid density.
void apply_vector(vectorPtr_Type &residual_velocity, vectorPtr_Type &residual_pressure, const vector_Type &velocity_previous_newton_step, const vector_Type &pressure_previous_newton_step, const vector_Type &velocity_rhs)
Adds to the residual the contribution coming from the SUPG stabilization.
FESpace< mesh_Type, map_Type > fespace_Type
class ETFESpace A light, templated version of the FESpace
Definition: ETFESpace.hpp:93
std::shared_ptr< vector_Type > vectorPtr_Type
ETFESpace< mesh_Type, map_Type, 3, 1 > ETFESpace_pressure
matrixPtr_Type const & block_01() const
Get block01 of the stabilization matrix.