LifeV
FastAssembler.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 the LifeV library
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
21  License along with this library; if not, see <http://www.gnu.org/licenses/>
22 
23 
24 *******************************************************************************
25 */
26 //@HEADER
27 
28 /*!
29  * @file
30  @brief This file contains the definition of the FastAssembler class.
31 
32  This function is used to perform an efficient assembly of FE matrices
33  where the test and trial functions are the same.
34 
35  @date 06/2016
36  @author Davide Forti <davide.forti@epfl.ch>
37  */
38 
39 #ifndef FASTASSEMBLER_HPP
40 #define FASTASSEMBLER_HPP
41 
42 #include <lifev/core/LifeV.hpp>
43 #include <lifev/core/mesh/RegionMesh.hpp>
44 #include <lifev/core/array/VectorEpetra.hpp>
45 #include <lifev/core/array/MatrixEpetra.hpp>
46 #include <lifev/core/fem/QuadratureRule.hpp>
47 #include <lifev/core/fem/ReferenceFE.hpp>
48 #include <lifev/core/fem/CurrentFE.hpp>
49 #include <lifev/core/fem/FESpace.hpp>
50 
51 namespace LifeV
52 {
53 
55 {
56 public:
57 
59  typedef boost::shared_ptr<mesh_Type> meshPtr_Type;
60 
62  typedef boost::shared_ptr<vector_Type> vectorPtr_Type;
63 
65  typedef boost::shared_ptr<matrix_Type> matrixPtr_Type;
66 
68  typedef boost::shared_ptr< comm_Type > commPtr_Type;
69 
71  typedef boost::shared_ptr< qr_Type > qrPtr_Type;
72 
73  typedef FESpace<mesh_Type, MapEpetra> fespace_Type;
74  typedef boost::shared_ptr<fespace_Type> fespacePtr_Type;
75 
76 
77  //! Constructor
78  /*!
79  * @param mesh - input mesh
80  * @param comm - communicator
81  * @param refFE - reference FE space of test functions
82  * @param qr - quadrature rule to be used for the integration
83  */
84  FastAssembler( const meshPtr_Type& mesh, const commPtr_Type& comm, const ReferenceFE* refFE, const qr_Type* qr );
85 
86  //! Destructor
87  ~FastAssembler();
88 
89  //! @name Methods
90  //@{
91 
92  //! Allocate space for members before the assembly
93  /*!
94  * @param numElements - data file
95  * @param fe - current FE
96  * @param fespace - FE space
97  */
98  void allocateSpace( const int& numElements, CurrentFE* fe, const fespacePtr_Type& fespace );
99 
100  //! Allocate space for members before the assembly
101  /*!
102  * @param numElements - data file
103  * @param fe - current FE
104  * @param fespace - FE space
105  * @param meshSub_elements - list of indices if one wants to allocate space only for a portion of the elements of the mesh
106  */
107  void allocateSpace( const int& numElements, CurrentFE* fe, const fespacePtr_Type& fespace, const UInt* meshSub_elements );
108 
109  //! Allocate space for supg before the assembly
110  /*!
111  * @param fe - current FE
112  */
113  void allocateSpace_SUPG( CurrentFE* fe );
114 
115  //! FE Assembly of scalar grad-grad
116  /*!
117  * @param matrix - global matrix
118  */
119  void assembleGradGrad_scalar( matrixPtr_Type& matrix );
120 
121  //! FE Assembly of vectorial grad-grad
122  /*!
123  * @param matrix - global matrix
124  */
126 
127  //! FE Assembly of vectorial mass matrix
128  /*!
129  * @param matrix - global matrix
130  */
131  void assembleMass_vectorial( matrixPtr_Type& matrix );
132 
133  //! FE Assembly of scalar mass matrix
134  /*!
135  * @param matrix - global matrix
136  */
137  void assembleMass_scalar( matrixPtr_Type& matrix );
138 
139  //! FE Assembly of laplacian PhiI laplacian PhiJ
140  /*!
141  * @param matrix - global matrix
142  */
144 
145  //! FE Assembly of NS constant terms (no scaling by coefficients like density or bdf)
146  /*!
147  * @param matrix - global matrix
148  */
149  void NS_constant_terms_00( matrixPtr_Type& matrix ); // Navier-Stokes constant terms belonging to block (0,0): mass + stiffness
150 
151  //! FE Assembly of NS constant terms (no scaling by coefficients like viscosity)
152  /*!
153  * @param matrix - global matrix
154  * @param u_h - velocity vector
155  */
156  void assembleConvective( matrix_Type& matrix, const vector_Type& u_h );
157 
158  //! FE Assembly of NS constant terms (no scaling by coefficients like viscosity)
159  /*!
160  * @param matrix - global matrix
161  * @param u_h - velocity vector
162  */
163  void assembleConvective( matrixPtr_Type& matrix, const vector_Type& u_h );
164 
165  //! FE Assembly of SUPG terms - block (0,0)
166  /*!
167  * @param matrix - global matrix
168  * @param u_h - vector extrapolapolated velocity
169  */
170  void assemble_SUPG_block00( matrixPtr_Type& matrix, const vector_Type& u_h );
171 
172  //! FE Assembly of SUPG terms - block (1,1)
173  /*!
174  * @param matrix - global matrix
175  * @param u_h - vector extrapolapolated velocity
176  */
177  void assemble_SUPG_block11( matrixPtr_Type& matrix, const vector_Type& u_h );
178 
179  //! Set physical parameters for NS
180  /*!
181  * @param density - density of the fluid
182  * @param viscosity - viscosity of the fluid
183  * @param timestep - timestep for the simulation
184  * @param orderBDF - order time integrator BDF
185  * @param C_I - is 30 for P1 and 60 for P2
186  */
187  void setConstants_NavierStokes( const Real& density, const Real& viscosity, const Real& timestep, const Real& orderBDF, const Real& C_I );
188 
189  //@}
190 
191 private:
192 
195 
199 
200  double * M_detJacobian;
201  double *** M_invJacobian;
202 
203  double ** M_phi;
204  double *** M_dphi;
205  double **** M_d2phi;
206  double ** M_elements;
207 
208  const qr_Type* M_qr;
210 
211  double*** M_vals;
212  double***** M_vals_supg;
213  int** M_rows;
214  int** M_cols;
215  int** M_rows_tmp;
216  int** M_cols_tmp;
217 
218  bool M_useSUPG;
219  double *** M_G; // metric tensor
220  double ** M_g; // metric vector
221  double ** M_Tau_M; // coefficient Tau_M
222  double ** M_Tau_C; // coefficient Tau_C
223 
224  double M_density;
225  double M_viscosity;
226  double M_timestep;
227  double M_orderBDF;
228  double M_C_I;
229 };
230 
231 } // Namespace LifeV
232 
233 #endif // FASTASSEMBLER_HPP
FastAssembler(const meshPtr_Type &mesh, const commPtr_Type &comm, const ReferenceFE *refFE, const qr_Type *qr)
Constructor.
void assemble_SUPG_block00(matrixPtr_Type &matrix, const vector_Type &u_h)
FE Assembly of SUPG terms - block (0,0)
void allocateSpace(const int &numElements, CurrentFE *fe, const fespacePtr_Type &fespace, const UInt *meshSub_elements)
Allocate space for members before the assembly.
boost::shared_ptr< matrix_Type > matrixPtr_Type
VectorEpetra - The Epetra Vector format Wrapper.
void assembleMass_vectorial(matrixPtr_Type &matrix)
FE Assembly of vectorial mass matrix.
void assembleGradGrad_vectorial(matrixPtr_Type &matrix)
FE Assembly of vectorial grad-grad.
FESpace< mesh_Type, MapEpetra > fespace_Type
boost::shared_ptr< fespace_Type > fespacePtr_Type
void importFromHDF5(std::string const &fileName, std::string const &matrixName="matrix")
Read a matrix from a HDF5 (.h5) file.
void NS_constant_terms_00(matrixPtr_Type &matrix)
FE Assembly of NS constant terms (no scaling by coefficients like density or bdf) ...
void assembleGradGrad_scalar(matrixPtr_Type &matrix)
FE Assembly of scalar grad-grad.
boost::shared_ptr< vector_Type > vectorPtr_Type
boost::shared_ptr< comm_Type > commPtr_Type
double ***** M_vals_supg
void assembleConvective(matrix_Type &matrix, const vector_Type &u_h)
FE Assembly of NS constant terms (no scaling by coefficients like viscosity)
~FastAssembler()
Destructor.
boost::shared_ptr< mesh_Type > meshPtr_Type
MatrixEpetra< Real > matrix_Type
void updateInverseJacobian(const UInt &iQuadPt)
QuadratureRule qr_Type
VectorEpetra vector_Type
Epetra_Import const & importer()
Getter for the Epetra_Import.
Definition: MapEpetra.cpp:394
void assemble_SUPG_block11(matrixPtr_Type &matrix, const vector_Type &u_h)
FE Assembly of SUPG terms - block (1,1)
void allocateSpace_SUPG(CurrentFE *fe)
Allocate space for supg before the assembly.
void allocateSpace(const int &numElements, CurrentFE *fe, const fespacePtr_Type &fespace)
Allocate space for members before the assembly.
boost::shared_ptr< qr_Type > qrPtr_Type
double Real
Generic real data.
Definition: LifeV.hpp:175
CurrentFE - A primordial class for the assembly of the local matrices/vectors retaining the values on...
Definition: CurrentFE.hpp:243
The class for a reference Lagrangian finite element.
void setConstants_NavierStokes(const Real &density, const Real &viscosity, const Real &timestep, const Real &orderBDF, const Real &C_I)
Set physical parameters for NS.
RegionMesh< LinearTetra > mesh_Type
const ReferenceFE * M_referenceFE
void assembleConvective(matrixPtr_Type &matrix, const vector_Type &u_h)
FE Assembly of NS constant terms (no scaling by coefficients like viscosity)
const qr_Type * M_qr
QuadratureRule - The basis class for storing and accessing quadrature rules.
void assembleMass_scalar(matrixPtr_Type &matrix)
FE Assembly of scalar mass matrix.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191
void assembleLaplacianPhiILaplacianPhiJ_vectorial(matrixPtr_Type &matrix)
FE Assembly of laplacian PhiI laplacian PhiJ.