LifeV
Stabilization.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 Stabilization - Abstract interface of stabilizations for Navier-Stokes
30 
31  @author Davide Forti <davide.forti@epfl.ch>
32  @date 08-12-2014
33 
34  @maintainer Davide Forti <davide.Forti@epfl.ch>
35  */
36 
37 #ifndef STABILIZATION_HPP
38 #define STABILIZATION_HPP 1
39 
40 #include <lifev/core/util/Factory.hpp>
41 #include <lifev/core/util/FactorySingleton.hpp>
42 
43 #include <lifev/core/fem/FESpace.hpp>
44 #include <lifev/core/fem/ReferenceFE.hpp>
45 
46 #include <lifev/eta/fem/ETFESpace.hpp>
47 
48 #include <lifev/core/array/MatrixEpetra.hpp>
49 #include <lifev/core/filter/ExporterHDF5.hpp>
50 
51 #include <lifev/navier_stokes_blocks/solver/FastAssemblerNS.hpp>
52 
53 namespace LifeV
54 {
55 
57 {
58 public:
59 
62 
63  typedef VectorEpetra vector_Type;
65 
68 
71 
74 
77 
78  Stabilization();
79 
80  virtual ~Stabilization();
81 
82  //! @name Methods
83  //@{
84 
85  //! Adds to the residual the contribution coming from the SUPG stabilization
86  // in Navier-Stokes simulations in fixed coordinates
87  /*!
88  @param residual_velocity velocity component of the residual
89  @param residual_pressure pressure component of the residual
90  @param velocity_previous_newton_step velocity from the previous Newton step
91  @param pressure_previous_newton_step pressure from the previous Newton step
92  @param velocity_rhs velocity term from approximation time derivative
93  */
94  virtual void apply_vector( vectorPtr_Type& /*residual_velocity*/,
95  vectorPtr_Type& /*residual_pressure*/,
96  const vector_Type& /*velocity_previous_newton_step*/,
97  const vector_Type& /*pressure_previous_newton_step*/,
98  const vector_Type& /*velocity_rhs*/) {};
99 
100  //! Updates the system matrix in Navier-Stokes simulations in fixed coordinates
101  // with semi-implicit treatment of the convective term.
102  /*!
103  @param velocityExtrapolated extrapolation of the fluid velocity
104  */
105  virtual void apply_matrix( const vector_Type& /*velocityExtrapolated*/ ) {};
106 
107  //! Updates the system matrix in Navier-Stokes simulations in ALE coordinates
108  // with semi-implicit treatment of the convective term.
109  /*!
110  @param velocityExtrapolated extrapolation of the fluid velocity
111  @param velocityALE ALE velocity
112  */
113  virtual void apply_matrix( const vector_Type& /*velocityExtrapolated*/, const vector_Type& /*velocityALE*/ ) {};
114 
115 
116  //! Adds to the right hand side the contribution coming from the SUPG stabilization
117  // in Navier-Stokes simulations in fixed coordinates. Usef for NS semi-implicit
118  /*!
119  @param rhs_velocity velocity component of the right hand side
120  @param rhs_pressure pressure component of the right hand side
121  @param velocity_extrapolated velocity extrapolated
122  @param velocity_rhs velocity term from approximation time derivative
123  */
124  virtual void apply_vector( vectorPtr_Type& /*rhs_velocity*/,
125  vectorPtr_Type& /*rhs_pressure*/,
126  const vector_Type& /*velocity_extrapolated*/,
127  const vector_Type& /*velocity_rhs*/) {};
128 
129  //! Updates the system matrix in Navier-Stokes simulations in fixed coordinates
130  // with semi-implicit treatment of the convective term.
131  /*!
132  @param velocityExtrapolated extrapolation of the fluid velocity
133  @param pressureExtrapolated extrapolation of the fluid pressure
134  @param velocity_rhs velocity term from approximation time derivative
135  */
136  virtual void apply_matrix( const vector_Type& /*velocityExtrapolated*/,
137  const vector_Type& /*pressureExtrapolated*/,
138  const vector_Type& /*velocity_rhs*/) {};
139 
140  //! Updates the jacobian matrix in Navier-Stokes simulations in ALE coordinates
141  /*!
142  * @param convective_velocity_previous_newton_step convective velocity from the previous Newton step
143  * @param velocity_previous_newton_step velocity from the previous Newton step
144  * @param pressure_previous_newton_step pressure from the previous Newton step
145  * @param velocity_rhs velocity term from approximation time derivative
146  */
147  virtual void apply_matrix( const vector_Type& /*convective_velocity_previous_newton_step*/,
148  const vector_Type& /*velocity_previous_newton_step*/,
149  const vector_Type& /*pressure_previous_newton_step*/,
150  const vector_Type& /*velocity_rhs*/ ) {};
151 
152  //! Adds to the residual the contribution coming from the SUPG stabilization
153  // in Navier-Stokes simulations in ALE coordinates
154  /*!
155  * @param residual_velocity velocity component of the residual
156  * @param residual_pressure pressure component of the residual
157  * @param convective_velocity_previous_newton_step convective velocity from the previous Newton step
158  * @param velocity_previous_newton_step velocity from the previous Newton step
159  * @param pressure_previous_newton_step pressure from the previous Newton step
160  * @param velocity_rhs velocity term from approximation time derivative
161  */
162  virtual void apply_vector( vectorPtr_Type& /*residual_velocity*/,
163  vectorPtr_Type& /*residual_pressure*/,
164  const vector_Type& /*convective_velocity_previous_newton_step*/,
165  const vector_Type& /*velocity_previous_newton_step*/,
166  const vector_Type& /*pressure_previous_newton_step*/,
167  const vector_Type& /*velocity_rhs*/) {};
168 
169  //@}
170 
171  //! @name Setters
172  //@{
173 
174  //! Set the constant C_I for the stabilization
175  /*!
176  * @param value order of FE used for velocity
177  */
178  virtual void setConstant (const int & value) = 0;;
179 
180  //! Build the graphs of each single block
181  virtual void buildGraphs() {};
182 
183  //! Set the fluid density
184  /*!
185  * @param value order of FE used for velocity
186  */
187  virtual void setDensity (const Real & density) = 0;
188 
189  //! Set the bdf order
190  /*!
191  * @param bdfOrder order of BDF scheme used
192  */
193  virtual void setBDForder (const Real & bdfOrder) = 0;
194 
195  //! Set the alpha coefficient of the BDF scheme used
196  /*!
197  * @param alpha coefficient BDF in front of u^{n+1}
198  */
199  virtual void setAlpha (const Real & alpha) = 0;
200 
201  //! Set the fluid dynamic viscosity
202  /*!
203  * @param viscosity value of fluid viscosity
204  */
205  virtual void setViscosity (const Real & viscosity) = 0;
206 
207  //! Set the Epetra communicator
208  /*!
209  * @param comm Epetra communicator
210  */
211  virtual void setCommunicator (std::shared_ptr<Epetra_Comm> comm) = 0;
212 
213  //! Set the time step size
214  /*!
215  * @param timestep time step size
216  */
217  virtual void setTimeStep (const Real & timestep) = 0;
218 
219  //! Set FE space for velocity
220  /*!
221  * @param velocityFESpace FE space for velocity
222  */
223  virtual void setVelocitySpace(fespacePtr_Type velocityFESpace) = 0;
224 
225  //! Set Expression Template FE space for velocity
226  /*!
227  * @param pressureFESpace FE space for pressure
228  */
229  virtual void setPressureSpace(fespacePtr_Type pressureFESpace) = 0;
230 
231  //! Set Expression Template FE space for velocity
232  /*!
233  * @param velocityEta_fespace Expression Template FE space for velocity
234  */
235  virtual void setETvelocitySpace(const ETFESpacePtr_velocity & velocityEta_fespace) = 0;
236 
237  //! Set Expression Template FE space for velocity
238  /*!
239  * @param pressureEta_fespace Expression Template FE space for pressure
240  */
241  virtual void setETpressureSpace(const ETFESpacePtr_pressure & pressureEta_fespace) = 0;
242 
243  //! Set if using the graph
244  /*!
245  * @param useGraph true it uses the graph, false it does not use the graph
246  */
247  virtual void setUseGraph (const bool& /*useGraph*/) {};
248 
249  //! Set if using dynamic fine scale model
250  virtual void setUseODEfineScale ( const bool& /*M_useODEfineScale*/ ) {};
251 
252  //! Set if the user wants to export the fine scale component
253  virtual void setExportFineScaleVelocity ( ExporterHDF5<mesh_Type> & /*exporter*/, const int& /*numElementsTotal*/ ) {};
254 
255  //! Set if using the fast assembler
256  virtual void setFastAssembler ( std::shared_ptr<FastAssemblerNS>& /*fast_assembler*/) {};
257 
258  //@}
259 
260  //! @name Getters
261  //@{
262 
263  //! Get block00 of the stabilization matrix
264  virtual matrixPtr_Type const& block_00() const = 0;
265 
266  //! Get block01 of the stabilization matrix
267  virtual matrixPtr_Type const& block_01() const = 0;
268 
269  //! Get block10 of the stabilization matrix
270  virtual matrixPtr_Type const& block_10() const = 0;
271 
272  //! Get block11 of the stabilization matrix
273  virtual matrixPtr_Type const& block_11() const = 0;
274 
275  //! Get name of stabilization being used
276  virtual std::string label () = 0;
277 
278  //! Updates the fine scale component
279  virtual void updateODEfineScale ( const vectorPtr_Type& /*velocity*/, const vectorPtr_Type& /*pressure*/ ) {};
280 
281  //! Updates the fine scale component
282  virtual void updateODEfineScale ( const vectorPtr_Type& /*velocity*/, const vectorPtr_Type& /*pressure*/, const vectorPtr_Type& /*vel_extrap*/ ) {};
283 
284  //@}
285 
286 private:
287 
288  //! @name Private methods
289  //@{
290 
291  //! Setup of the fine scale component
292  virtual void setupODEfineScale () {};
293 
294  //! Compute the fine component of the velocity and pressure
295  virtual void computeFineScales ( const vectorPtr_Type& /*velocity*/, const vectorPtr_Type& /*pressure*/, const vectorPtr_Type& /*vel_extrap*/ ) {};
296 
297  //! Compute the fine component of the velocity and pressure for visualization
298  virtual void computeFineScalesForVisualization ( const vectorPtr_Type& /*velocity*/, const vectorPtr_Type& /*pressure*/, const vectorPtr_Type& /*vel_extrap*/ ) {};
299 
300  //@}
301 
302 };
303 
305 {
306 }
307 
309 {
310 }
311 
313 
314 } // namespace LifeV
315 
316 
317 #endif // STABILIZATION_HPP
FESpace< mesh_Type, map_Type > fespace_Type
std::shared_ptr< ETFESpace_velocity > ETFESpacePtr_velocity
std::shared_ptr< vector_Type > vectorPtr_Type
FESpace - Short description here please!
Definition: FESpace.hpp:78
ETFESpace< mesh_Type, map_Type, 3, 1 > ETFESpace_pressure
virtual void setAlpha(const Real &alpha)=0
Set the alpha coefficient of the BDF scheme used.
void importFromHDF5(std::string const &fileName, std::string const &matrixName="matrix")
Read a matrix from a HDF5 (.h5) file.
virtual void buildGraphs()
Build the graphs of each single block.
virtual void apply_matrix(const vector_Type &, const vector_Type &, const vector_Type &)
Updates the system matrix in Navier-Stokes simulations in fixed coordinates.
std::shared_ptr< ETFESpace_pressure > ETFESpacePtr_pressure
virtual void setETvelocitySpace(const ETFESpacePtr_velocity &velocityEta_fespace)=0
Set Expression Template FE space for velocity.
virtual void setExportFineScaleVelocity(ExporterHDF5< mesh_Type > &, const int &)
Set if the user wants to export the fine scale component.
virtual matrixPtr_Type const & block_01() const =0
Get block01 of the stabilization matrix.
RegionMesh< LinearTetra > mesh_Type
FactorySingleton< Factory< Stabilization, std::string > > StabilizationFactory
virtual void setUseODEfineScale(const bool &)
Set if using dynamic fine scale model.
std::shared_ptr< matrix_Type > matrixPtr_Type
virtual void apply_matrix(const vector_Type &, const vector_Type &, const vector_Type &, const vector_Type &)
Updates the jacobian matrix in Navier-Stokes simulations in ALE coordinates.
virtual void setFastAssembler(std::shared_ptr< FastAssemblerNS > &)
Set if using the fast assembler.
Epetra_Import const & importer()
Getter for the Epetra_Import.
Definition: MapEpetra.cpp:394
virtual void setViscosity(const Real &viscosity)=0
Set the fluid dynamic viscosity.
virtual void apply_vector(vectorPtr_Type &, vectorPtr_Type &, const vector_Type &, const vector_Type &, const vector_Type &, const vector_Type &)
Adds to the residual the contribution coming from the SUPG stabilization.
virtual void apply_matrix(const vector_Type &, const vector_Type &)
Updates the system matrix in Navier-Stokes simulations in ALE coordinates.
virtual std::string label()=0
Get name of stabilization being used.
virtual void setVelocitySpace(fespacePtr_Type velocityFESpace)=0
Set FE space for velocity.
virtual void updateODEfineScale(const vectorPtr_Type &, const vectorPtr_Type &)
Updates the fine scale component.
virtual void computeFineScales(const vectorPtr_Type &, const vectorPtr_Type &, const vectorPtr_Type &)
Compute the fine component of the velocity and pressure.
virtual void setupODEfineScale()
Setup of the fine scale component.
virtual void setBDForder(const Real &bdfOrder)=0
Set the bdf order.
MatrixEpetra< Real > matrix_Type
virtual matrixPtr_Type const & block_10() const =0
Get block10 of the stabilization matrix.
virtual void setPressureSpace(fespacePtr_Type pressureFESpace)=0
Set Expression Template FE space for velocity.
virtual void setUseGraph(const bool &)
Set if using the graph.
ETFESpace< mesh_Type, map_Type, 3, 3 > ETFESpace_velocity
double Real
Generic real data.
Definition: LifeV.hpp:175
virtual matrixPtr_Type const & block_00() const =0
Get block00 of the stabilization matrix.
virtual void setDensity(const Real &density)=0
Set the fluid density.
VectorEpetra vector_Type
virtual void apply_matrix(const vector_Type &)
Updates the system matrix in Navier-Stokes simulations in fixed coordinates.
virtual void setConstant(const int &value)=0
Set the constant C_I for the stabilization.
virtual void setETpressureSpace(const ETFESpacePtr_pressure &pressureEta_fespace)=0
Set Expression Template FE space for velocity.
virtual void apply_vector(vectorPtr_Type &, vectorPtr_Type &, const vector_Type &, const vector_Type &)
Adds to the right hand side the contribution coming from the SUPG stabilization.
virtual void apply_vector(vectorPtr_Type &, vectorPtr_Type &, const vector_Type &, const vector_Type &, const vector_Type &)
Adds to the residual the contribution coming from the SUPG stabilization.
virtual void setTimeStep(const Real &timestep)=0
Set the time step size.
std::shared_ptr< fespace_Type > fespacePtr_Type
virtual void computeFineScalesForVisualization(const vectorPtr_Type &, const vectorPtr_Type &, const vectorPtr_Type &)
Compute the fine component of the velocity and pressure for visualization.
class ETFESpace A light, templated version of the FESpace
Definition: ETFESpace.hpp:93
virtual matrixPtr_Type const & block_11() const =0
Get block11 of the stabilization matrix.
virtual void setCommunicator(std::shared_ptr< Epetra_Comm > comm)=0
Set the Epetra communicator.
virtual void updateODEfineScale(const vectorPtr_Type &, const vectorPtr_Type &, const vectorPtr_Type &)
Updates the fine scale component.