LifeV
ExpressionOuterProduct.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 element-wise multiplication between expressions are defined.
30 
31  @author Helene Ruffieux <samuel.quinodoz@epfl.ch>
32 
33  @date 08-2012
34  */
35 
36 #ifndef EXPRESSION_OUTERPRODUCT_HPP
37 #define EXPRESSION_OUTERPRODUCT_HPP
38 
39 #include <lifev/core/LifeV.hpp>
40 
41 #include <lifev/eta/expression/ExpressionBase.hpp>
42 #include <lifev/eta/expression/ExpressionScalar.hpp>
43 #include <lifev/eta/expression/ExpressionVector.hpp>
44 #include <lifev/eta/expression/ExpressionMatrix.hpp>
45 
46 namespace LifeV
47 {
48 
49 namespace ExpressionAssembly
50 {
51 
52 //! class ExpressionOuterProduct Class for representing a vector product multiplication between two vector expressions.
53 /*!
54  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
55 
56  This class represents the element-wise multiplication in the expression tree.
57 
58  <b> Template parameters </b>
59 
60  <i>LExpressionType</i>: The expression on the left side of the emult operation.
61 
62  <i>RExpressionType</i>: The expression on the right side of the emult operation.
63 
64  <b> Template requirements </b>
65 
66  <i>LExpressionType</i>: Copiable, static display method
67 
68  <i>RExpressionType</i>: Copiable, static display method
69 
70 */
71 template <typename LExpressionType, typename RExpressionType>
72 class ExpressionOuterProduct : public ExpressionBase< ExpressionOuterProduct<LExpressionType, RExpressionType> >
73 {
74 public:
75 
76  //! @name Public Types
77  //@{
78 
79  // No real need, just for ease of coding
80  typedef ExpressionBase< ExpressionOuterProduct <LExpressionType, RExpressionType> > base_Type;
81 
82  //@}
83 
84 
85  //! @name Constructors & Destructor
86  //@{
87 
88  //! Full constructor, with the two expressions.
89  ExpressionOuterProduct (const LExpressionType& l, const RExpressionType& r)
90  : base_Type(), M_l (l), M_r (r) {}
91 
92  //! Copy constructor
93  ExpressionOuterProduct (const ExpressionOuterProduct<LExpressionType, RExpressionType>& expression)
94  : base_Type(), M_l (expression.M_l), M_r (expression.M_r) {}
95 
96  //! Destructor
97  ~ExpressionOuterProduct() {}
98 
99  //@}
100 
101 
102  //! @name Methods
103  //@{
104 
105  //! Display method
106  static void display (std::ostream& out = std::cout)
107  {
108  LExpressionType::display (out);
109  out << " outerProduct ";
110  RExpressionType::display (out);
111  }
112 
113  //@}
114 
115 
116  //! @name Get Methods
117  //@{
118 
119  //! Getter for the left hand side of the emult operation
120  const LExpressionType& left() const
121  {
122  return M_l;
123  }
124 
125  //! Getter for the right hand side of the emult operation
126  const RExpressionType& right() const
127  {
128  return M_r;
129  }
130 
131  //@}
132 
133 private:
134 
135  //! @name Private Methods
136  //@{
137 
138  //! No default constructor
139  ExpressionOuterProduct();
140 
141  //@}
142 
143  // Left hand side
144  LExpressionType M_l;
145 
146  // Right hand side
147  RExpressionType M_r;
148 };
149 
150 
151 // emult The generic function for the vector product between vector expressions.
152 /*!
153  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
154 
155  Function used in construction of the expression tree. To avoid shadowing
156  other functions, it uses the ExpressionBase type to distinguish expressions
157  from other types.
158 
159  <b> Template parameters </b>
160 
161  <i>LExpressionType</i>: The expression on the left side of the emult operation.
162 
163  <i>RExpressionType</i>: The expression on the right side of the emult operation.
164 
165  <b> Template requirements </b>
166 
167  <i>LExpressionType</i>: Same as in LifeV::ExpressionOuterProduct
168 
169  <i>RExpressionType</i>: Same as in LifeV::ExpressionOuterProduct
170 
171 */
172 template< typename LExpressionType, typename RExpressionType >
173 ExpressionOuterProduct<LExpressionType, RExpressionType>
174 outerProduct (const ExpressionBase<LExpressionType>& l, const ExpressionBase<RExpressionType>& r)
175 {
176  return ExpressionOuterProduct<LExpressionType, RExpressionType> (l.cast(), r.cast() );
177 }
178 
179 
180 // Specialization for the matricial constants
181 template< typename RExpressionType , UInt Dim1 >
182 ExpressionOuterProduct<ExpressionVector<Dim1>, RExpressionType>
183 outerProduct (const VectorSmall<Dim1>& l, const ExpressionBase<RExpressionType>& r)
184 {
185  return ExpressionOuterProduct<ExpressionVector<Dim1>, RExpressionType> (ExpressionVector<Dim1> (l), r.cast() );
186 }
187 
188 template< typename LExpressionType, UInt Dim1 >
189 ExpressionOuterProduct<LExpressionType, ExpressionVector<Dim1> >
190 outerProduct (const ExpressionBase<LExpressionType>& l, const VectorSmall<Dim1>& r)
191 {
192  return ExpressionOuterProduct<LExpressionType, ExpressionVector<Dim1> > (l.cast(), ExpressionVector<Dim1> (r) );
193 }
194 
195 // Specialization for the matricial constants
196 template< UInt Dim1 >
197 ExpressionOuterProduct<ExpressionVector<Dim1>, ExpressionVector<Dim1> >
198 outerProduct (const VectorSmall<Dim1>& l, const VectorSmall<Dim1>& r)
199 {
200  return ExpressionOuterProduct<ExpressionVector<Dim1>, ExpressionVector<Dim1> > (ExpressionVector<Dim1> (l), ExpressionVector<Dim1> (r) );
201 }
202 
203 
204 } // Namespace ExpressionAssembly
205 
206 } // Namespace LifeV
207 #endif
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