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