LifeV
ExpressionPower.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 where the structures for the product between expressions are defined.
30 
31  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
32 
33  @date 07-2011
34  */
35 
36 #ifndef EXPRESSION_POWER_HPP
37 #define EXPRESSION_POWER_HPP
38 
39 #include <lifev/core/LifeV.hpp>
40 
41 #include <lifev/eta/expression/ExpressionBase.hpp>
42 #include <lifev/eta/expression/ExpressionDeterminant.hpp>
43 #include <lifev/eta/expression/ExpressionTrace.hpp>
44 
45 namespace LifeV
46 {
47 
48 namespace ExpressionAssembly
49 {
50 
51 //! class ExpressionPower Class for representing a product between two expressions.
52 /*!
53  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
54 
55  This class represents the product in the expression tree.
56 
57  <b> Template parameters </b>
58 
59  <i>LExpressionType</i>: The expression on the left side of the product operation.
60 
61  <i>RExpressionType</i>: The expression on the right side of the product operation.
62 
63  <b> Template requirements </b>
64 
65  <i>LExpressionType</i>: Copiable, static display method
66 
67  <i>RExpressionType</i>: Copiable, static display method
68 
69 */
70 template <typename BaseExpressionType>
71 class ExpressionPower : public ExpressionBase< ExpressionPower<BaseExpressionType> >
72 {
73 public:
74 
75  //! @name Public Types
76  //@{
77 
78  // No direct use, just ease of coding
79  typedef ExpressionBase< ExpressionPower <BaseExpressionType> > base_Type;
80 
81  //@}
82 
83  //! @name Constructors & Destructor
84  //@{
85 
86  //! Full constructor using the two expressions
87  ExpressionPower (const BaseExpressionType& l, const Real exponent)
88  : base_Type(), M_l (l), M_exponent (exponent) {}
89 
90  //! Copy constructor
91  ExpressionPower (const ExpressionPower<BaseExpressionType>& expression)
92  : base_Type(), M_l (expression.M_l), M_exponent (expression.M_exponent) {}
93 
94  //! Destructor
95  ~ExpressionPower() {}
96 
97  //@}
98 
99 
100  //! @name Methods
101  //@{
102 
103  //! Display method
104  static void display (std::ostream& out = std::cout)
105  {
106  BaseExpressionType::display (out);
107  out << " ^ ";
108  }
109 
110  //@}
111 
112 
113  //! @name Private Methods
114  //@{
115 
116  //! Getter for the left hand side
117  const BaseExpressionType& base() const
118  {
119  return M_l;
120  }
121 
122  //! Getter for the right hand side
123  const Real& exponent() const
124  {
125  return M_exponent;
126  }
127 
128  //@}
129 
130 private:
131 
132  //! @name Private Methods
133  //@{
134 
135  ExpressionPower();
136 
137  //@}
138 
139 
140  // Left hand side
141  BaseExpressionType M_l;
142 
143  // Right hand side
144  Real M_exponent;
145 };
146 
147 
148 //! operator* The generic operator for the product between expressions.
149 /*!
150  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
151 
152  Operator used in construction of the expression tree. To avoid shadowing
153  other operator*, it uses the ExpressionBase type to distinguish expressions
154  from other types.
155 
156  <b> Template parameters </b>
157 
158  <i>LExpressionType</i>: The expression on the left side of the product operation.
159 
160  <i>RExpressionType</i>: The expression on the right side of the product operation.
161 
162  <b> Template requirements </b>
163 
164  <i>LExpressionType</i>: Same as in LifeV::ExpressionProduct
165 
166  <i>RExpressionType</i>: Same as in LifeV::ExpressionProduct
167 
168 */
169 
170 template< typename ExpressionType>
171 ExpressionPower<ExpressionType>
172 pow (const ExpressionBase<ExpressionType>& l, const Real& r)
173 {
174  return ExpressionPower<ExpressionType> (l.cast(), r);
175 }
176 
177 
178 } // Namespace ExpressionAssembly
179 
180 } // Namespace LifeV
181 
182 #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...