LifeV
ExpressionInterpolateLaplacian.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 File for the definition of the expression used to interpolate FE functions.
30 
31  @author Davide Forti <davide.forti@epfl.ch>
32 
33  @date 11-2014
34  */
35 
36 #ifndef EXPRESSION_INTERPOLATE_LAPLACIAN_HPP
37 #define EXPRESSION_INTERPOLATE_LAPLACIAN_HPP
38 
39 #include <lifev/core/LifeV.hpp>
40 
41 #include <lifev/core/array/VectorEpetra.hpp>
42 
43 #include <lifev/eta/expression/ExpressionBase.hpp>
44 
45 #include <lifev/eta/fem/ETFESpace.hpp>
46 
47 #include <iostream>
48 
49 namespace LifeV
50 {
51 
52 namespace ExpressionAssembly
53 {
54 
55 //! class ExpressionInterpolateLaplacian Class representing an interpolation in an expression.
56 /*!
57  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
58 
59  This class is meant to be used only in the expression tree, it does not perform
60  any computation.
61 
62  <b> Template parameters </b>
63 
64  <i>MeshType</i>: The type of the mesh
65 
66  <i>MapType</i>: The type of the algebraic map (for parallel computations)
67 
68  <i>SpaceDim</i>: The ambiant space (for the finite element space)
69 
70  <i>FieldDim</i>: The dimension of the field to interpolate (scalar vs vectorial)
71 
72  <b> Template requirements </b>
73 
74  <i>MeshType</i>: Same as in LifeV::ETFESpace
75 
76  <i>MapType</i>: Same as in LifeV::ETFESpace
77 
78 */
79 template<typename MeshType, typename MapType, UInt SpaceDim, UInt FieldDim>
80 class ExpressionInterpolateLaplacian
81  : public ExpressionBase<ExpressionInterpolateLaplacian < MeshType, MapType, SpaceDim, FieldDim > >
82 {
83 public:
84 
85  //! @name Public Types
86  //@{
87 
88  // Base class, used only to make the code cleaner
89  typedef ExpressionBase<ExpressionInterpolateLaplacian < MeshType, MapType, SpaceDim, FieldDim > > base_Type;
90 
91  //! Type of the finite element space
92  typedef ETFESpace<MeshType, MapType, SpaceDim, FieldDim> fespace_Type;
93 
94  //! Type for the pointer on the finite element space
95  typedef std::shared_ptr<fespace_Type> fespacePtr_Type;
96 
97  //! Data vector type
98  typedef VectorEpetra vector_Type;
99 
100  //@}
101 
102 
103  //! @name Constructors & Destructor
104  //@{
105 
106  //! Constructor using the finite element space and the data vector
107  ExpressionInterpolateLaplacian (fespacePtr_Type fespace, const vector_Type& vector, const UInt& offset)
108  : base_Type(), M_fespace (fespace), M_vector (vector), M_offset (offset) {}
109 
110  //! Copy constructor
111  ExpressionInterpolateLaplacian (const ExpressionInterpolateLaplacian<MeshType, MapType, SpaceDim, FieldDim>& expr)
112  : base_Type(), M_fespace (expr.M_fespace), M_vector (expr.M_vector), M_offset (expr.M_offset) {}
113 
114  //! Destructor
115  ~ExpressionInterpolateLaplacian() {}
116 
117  //@}
118 
119 
120  //! @name Methods
121  //@{
122 
123  //! Display method
124  static void display (std::ostream& out = std::cout)
125  {
126  out << "interpolated_grad[" << FieldDim << "] ";
127  }
128 
129  //@}
130 
131 
132  //! @name Get Methods
133  //@{
134 
135  //! Getter for the finite element space
136  fespacePtr_Type fespace() const
137  {
138  return M_fespace;
139  }
140 
141  //! Getter for the data vector
142  const vector_Type vector() const
143  {
144  return M_vector;
145  }
146 
147  //! Getter for the data vector
148  const UInt offset() const
149  {
150  return M_offset;
151  }
152 
153  // @}
154 
155 private:
156 
157  //! @name Private Methods
158  //@{
159 
160  //! No default constructor
161  ExpressionInterpolateLaplacian();
162 
163  //@}
164 
165  // Storage for the finite element space
166  fespacePtr_Type M_fespace;
167 
168  // Storage for the data vector
169  vector_Type M_vector;
170 
171  //Offset to pick up the right portion of the vector
172  UInt M_offset;
173 };
174 
175 //! Simple function to be used in the construction of an expression
176 /*!
177  @author Davide Forti <davide.forti@epfl.ch>
178 
179  <b> Template parameters </b>
180 
181  <i>MeshType</i>: The type of the mesh stored in the finite element space
182 
183  <i>MapType</i>: The type of map used in the finite element space
184 
185  <i>SpaceDim</i>: The dimension of the ambient space.
186 
187  <i>FieldDim</i>: The dimension of the finite element space (scalar vs vectorial)
188 
189  <b> Template requirements </b>
190 
191  <i>MeshType</i>: Same as in LifeV::ETFESpace
192 
193  <i>MapType</i>: Same as in LifeV::ETFESpace
194 
195 */
196 template<typename MeshType, typename MapType, UInt SpaceDim, UInt FieldDim>
197 inline ExpressionInterpolateLaplacian<MeshType, MapType, SpaceDim, FieldDim>
198 laplacian (
199  std::shared_ptr< ETFESpace<MeshType, MapType, SpaceDim, FieldDim> > fespace,
200  const VectorEpetra& vector,
201  const UInt& offset = 0
202 )
203 {
204  return ExpressionInterpolateLaplacian<MeshType, MapType, SpaceDim, FieldDim> (fespace, vector, offset);
205 }
206 
207 
208 } // Namespace ExpressionAssembly
209 
210 } // Namespace LifeV
211 
212 #endif
VectorEpetra - The Epetra Vector format Wrapper.
void updateInverseJacobian(const UInt &iQuadPt)
class ExpressionBase Base class (static polymorphism, CRTP sense) for all the expressions used in ass...
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191