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