LifeV
ExpressionScalar.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 containing the definition of the scalar expression.
30 
31  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
32 
33  @date 07-2011
34  */
35 
36 #ifndef EXPRESSION_SCALAR_HPP
37 #define EXPRESSION_SCALAR_HPP
38 
39 #include <lifev/core/LifeV.hpp>
40 
41 #include <lifev/eta/expression/ExpressionBase.hpp>
42 
43 #include <iostream>
44 
45 namespace LifeV
46 {
47 
48 namespace ExpressionAssembly
49 {
50 
51 //! class ExpressionScalar Class representing a scalar constant in an expression.
52 /*!
53  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
54 */
55 class ExpressionScalar : public ExpressionBase<ExpressionScalar>
56 {
57 public:
58 
59  //! @name Public Types
60  //@{
61 
62  typedef ExpressionBase<ExpressionScalar> base_Type;
63 
64  //@}
65 
66 
67  //! @name Constructors & Destructor
68  //@{
69 
70  //! Constructor using the value of the scalar
71  ExpressionScalar (const Real& myValue);
72 
73  //! Copy constructor
74  ExpressionScalar (const ExpressionScalar& expr);
75 
76  //! Destructor
77  ~ExpressionScalar();
78 
79  //@}
80 
81 
82  //! @name Methods
83  //@{
84 
85  //! Display method
86  static void display (std::ostream& out = std::cout);
87 
88  //@}
89 
90 
91  //! @name Get Methods
92  //@{
93 
94  //! Getter for the value of the scalar
95  const Real& value() const;
96 
97  //@}
98 
99 private:
100 
101  //! @name Private Methods
102  //@{
103 
104  //! No empty constructor
105  ExpressionScalar();
106 
107  //@}
108 
109  Real M_value;
110 };
111 
112 //! Simple function to be used in the construction of an expression
113 /*!
114  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
115 */
116 inline ExpressionScalar
117 value (const Real& myValue)
118 {
119  return ExpressionScalar (myValue);
120 }
121 
122 
123 //! class ExpressionScalar Class representing a scalar constant in an expression.
124 /*!
125  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
126 */
127 
128 template<typename VectorType>
129 class ExpressionExtractScalar : public ExpressionBase<ExpressionExtractScalar<VectorType> >
130 {
131 public:
132 
133  //! @name Public Types
134  //@{
135 
136  typedef ExpressionBase<ExpressionExtractScalar<VectorType> > base_Type;
137  typedef std::shared_ptr<VectorType> containerPtr_Type;
138 
139  //@}
140 
141 
142  //! @name Constructors & Destructor
143  //@{
144 
145  //! Constructor using the value of the scalar
146  ExpressionExtractScalar (const VectorType& myVector)
147  : base_Type(), M_vector (new VectorType (myVector) ) {}
148 
149  //! Copy constructor
150  ExpressionExtractScalar (const ExpressionExtractScalar<VectorType>& expr)
151  : base_Type(), M_vector ( expr.vector() ) {}
152 
153  //! Destructor
154  ~ExpressionExtractScalar() {}
155 
156  //@}
157 
158 
159  //! @name Methods
160  //@{
161 
162  //! Display method
163  static void display (std::ostream& out = std::cout);
164 
165  //@}
166 
167 
168  //! @name Get Methods
169  //@{
170 
171  //! Getter for the value of the scalar
172  const containerPtr_Type vector() const
173  {
174  return M_vector;
175  } ;
176 
177  //@}
178 
179 private:
180 
181  //! @name Private Methods
182  //@{
183 
184  //! No empty constructor
185  ExpressionExtractScalar();
186 
187  //@}
188 
189  containerPtr_Type M_vector;
190 };
191 
192 //! Simple function to be used in the construction of an expression
193 /*!
194  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
195 */
196 template<typename VectorType>
197 inline ExpressionExtractScalar<VectorType>
198 parameter (const VectorType& myVector)
199 {
200  return ExpressionExtractScalar<VectorType> ( myVector );
201 }
202 
203 } // Namespace ExpressionAssembly
204 
205 } // Namespace LifeV
206 
207 #endif
void updateInverseJacobian(const UInt &iQuadPt)
double Real
Generic real data.
Definition: LifeV.hpp:175
class ExpressionBase Base class (static polymorphism, CRTP sense) for all the expressions used in ass...