LifeV
ExpressionExtract2.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 for the extraction of a component from a matrix.
30 
31  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
32 
33  @date 07-2011
34  */
35 
36 #ifndef EXPRESSION_EXTRACT2_HPP
37 #define EXPRESSION_EXTRACT2_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 
45 #include <iostream>
46 
47 namespace LifeV
48 {
49 
50 namespace ExpressionAssembly
51 {
52 
53 //! class ExpressionExtract2 Class for representing the extraction of a component from a matrix (2 indexes specified).
54 /*!
55  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
56 
57  This class represents the extraction of a component from a matrix in the expression tree.
58 
59  <b> Template parameters </b>
60 
61  <i>ExpressionType</i>: The expression from which we want to extract
62 
63  <b> Template requirements </b>
64 
65  <i>ExpressionType</i>: Copiable, static display method
66 */
67 
68 template< typename ExpressionType >
69 class ExpressionExtract2 : public ExpressionBase<ExpressionExtract2< ExpressionType > >
70 {
71 public:
72 
73  //! @name Public Types
74  //@{
75 
76  // Base class, typedef useful to make the code cleaner
77  typedef ExpressionBase<ExpressionExtract2< ExpressionType > > base_Type;
78 
79  //@}
80 
81 
82  //! @name Constructors & Destructor
83  //@{
84 
85  //! Full constructor, with the expression and the specification of the position of the row to be extracted
86  ExpressionExtract2 (const ExpressionType& ex, const UInt& i, const UInt& j)
87  : base_Type(),
88  M_ex (ex),
89  M_i (i),
90  M_j (j)
91  {}
92 
93  //! Copy constructor
94  ExpressionExtract2 (const ExpressionExtract2<ExpressionType>& expr)
95  : base_Type(),
96  M_ex (expr.M_ex),
97  M_i (expr.M_i),
98  M_j (expr.M_j)
99  {}
100 
101  //! Destructor
102  ~ExpressionExtract2() {}
103 
104  //@}
105 
106 
107  //! @name Methods
108  //@{
109 
110  //! Display method
111  static void display (std::ostream& out = std::cout)
112  {
113  out << "Extraction from ";
114  ExpressionType::display (out);
115  }
116 
117  //@}
118 
119 
120  //! @name Get Methods
121  //@{
122 
123  //! Getter for the row index
124  UInt indexI() const
125  {
126  return M_i;
127  }
128 
129  //! Getter for the column index
130  UInt indexJ() const
131  {
132  return M_j;
133  }
134 
135  //! Getter for the expression from which we extract
136  const ExpressionType& exprEx() const
137  {
138  return M_ex;
139  }
140 
141  //@}
142 
143 private:
144 
145  //! @name Private Methods
146  //@{
147 
148  //! No empty constructor
149  ExpressionExtract2();
150 
151  //@}
152 
153  // Storage for the row index
154  UInt M_i;
155 
156  // Storage for the column index
157  UInt M_j;
158 
159  // Storage for the expression from which we extract
160  ExpressionType M_ex;
161 };
162 
163 //! extract The generic function for the extraction
164 /*!
165  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
166 
167  Function used in construction of the expression tree. To avoid shadowing
168  other functions, it uses the ExpressionBase type to distinguish expressions
169  from other types.
170 
171  <b> Template parameters </b>
172 
173  <i>ExpressionType</i>: The expression from which we extract
174 
175  <b> Template requirements </b>
176 
177  <i>ExpressionType</i>: Same as LifeV::ExpressionExtract2
178 */
179 
180 template< typename ExpressionType >
181 inline ExpressionExtract2<ExpressionType>
182 extract (const ExpressionBase<ExpressionType>& ex, const UInt& i, const UInt& j)
183 {
184  return ExpressionExtract2<ExpressionType> (ex.cast(), i, j);
185 }
186 
187 
188 } // Namespace ExpressionAssembly
189 
190 } // Namespace LifeV
191 
192 #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