LifeV
EvaluationIfCrossed.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 the LifeV library
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
21  License along with this library; if not, see <http://www.gnu.org/licenses/>
22 
23 
24 *******************************************************************************
25 */
26 //@HEADER
27 
28 /*!
29  * @file
30  @brief This file contains the definition of the EvaluationInterpolateValue class.
31 
32  @date 06/2011
33  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
34  */
35 
36 #ifndef EVALUATION_IF_CROSSED_HPP
37 #define EVALUATION_IF_CROSSED_HPP
38 
39 #include <lifev/core/array/VectorEpetra.hpp>
40 #include <lifev/core/array/VectorSmall.hpp>
41 
42 #include <lifev/core/LifeV.hpp>
43 
44 #include <lifev/eta/fem/ETCurrentFE.hpp>
45 #include <lifev/eta/fem/ETCurrentFlag.hpp>
46 #include <lifev/eta/fem/ETFESpace.hpp>
47 #include <lifev/core/fem/QuadratureRule.hpp>
48 
49 #include <lifev/eta/expression/ExpressionIfCrossed.hpp>
50 
51 #include <boost/shared_ptr.hpp>
52 
53 
54 namespace LifeV
55 {
56 
57 namespace ExpressionAssembly
58 {
59 
60 //! Evaluation for the interpolation of a FE function
61 /*!
62  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
63  */
64 template<typename MeshType, typename MapType, UInt SpaceDim>
65 class EvaluationIfCrossed
66 {
67 public:
68 
69  //! @name Public Types
70  //@{
71 
72  //! Type of the value returned by this class
73  typedef Real return_Type;
74 
75  //! Type of the FESpace that has to be used with this class
76  typedef ETFESpace<MeshType, MapType, SpaceDim, 1> fespace_Type;
77 
78  //! Pointer on the FESpace
79  typedef std::shared_ptr<fespace_Type> fespacePtr_Type;
80 
81  //! Vector of the values
82  typedef VectorEpetra vector_Type;
83 
84  //@}
85 
86 
87  //! @name Static constants
88  //@{
89 
90  //! Flag for the global current FE
91  const static flag_Type S_globalUpdateFlag;
92 
93  //! Flag for the test current FE
94  const static flag_Type S_testUpdateFlag;
95 
96  //! Flag for the solution current FE
97  const static flag_Type S_solutionUpdateFlag;
98 
99  //@}
100 
101 
102  //! @name Constructors, destructor
103  //@{
104 
105  //! Copy constructor
106  EvaluationIfCrossed (const EvaluationIfCrossed<MeshType, MapType, SpaceDim>& evaluation)
107  :
108  M_fespace ( evaluation.M_fespace),
109  M_vector ( evaluation.M_vector, Repeated),
110  M_value ( evaluation.M_value)
111  {}
112 
113  //! Expression-based constructor
114  explicit EvaluationIfCrossed (const ExpressionIfCrossed<MeshType, MapType, SpaceDim>& expression)
115  :
116  M_fespace ( expression.fespace() ),
117  M_vector ( expression.vector(), Repeated ),
118  M_value (0.0)
119  {}
120 
121  //! Destructor
122  ~EvaluationIfCrossed()
123  {}
124 
125  //@}
126 
127 
128  //! @name Methods
129  //@{
130 
131  //! Interal update, computes the interpolated values.
132  void update (const UInt& iElement)
133  {
134  bool existPositive (false);
135  bool existNegative (false);
136 
137  for (UInt i (0); i < 4; ++i)
138  {
139  UInt globalID (M_fespace->dof().localToGlobalMap (iElement, i) );
140 
141  Real interpolatedValue = M_vector[globalID];
142 
143  if (interpolatedValue >= 0)
144  {
145  existPositive = true;
146  }
147  else
148  {
149  existNegative = true;
150  }
151  }
152 
153  if (existPositive && existNegative)
154  {
155  M_value = 1.0;
156  }
157  else
158  {
159  M_value = 0.0;
160  }
161  }
162 
163  //! Display method
164  static void display (std::ostream& out = std::cout)
165  {
166  out << "ifCrossed";
167  }
168 
169  //@}
170 
171 
172  //! @name Set Methods
173  //@{
174 
175  //! Do nothing setter for the global current FE
176  template< typename CFEType >
177  void setGlobalCFE (const CFEType* /*globalCFE*/)
178  {}
179 
180  //! Do nothing setter for the test current FE
181  template< typename CFEType >
182  void setTestCFE (const CFEType* /*testCFE*/)
183  {}
184 
185  //! Do nothing setter for the solution current FE
186  template< typename CFEType >
187  void setSolutionCFE (const CFEType* /*solutionCFE*/)
188  {}
189 
190  //! Setter for the quadrature rule (deep copy)
191  void setQuadrature (const QuadratureRule& )
192  {}
193 
194  //@}
195 
196 
197  //! @name Get Methods
198  //@{
199 
200  //! Getter for a value
201  return_Type value_q (const UInt& /*q*/) const
202  {
203  return M_value;
204  }
205 
206  //! Getter for the value for a vector
207  return_Type value_qi (const UInt& /*q*/, const UInt& /*i*/) const
208  {
209  return M_value;
210  }
211 
212  //! Getter for the value for a matrix
213  return_Type value_qij (const UInt& /*q*/, const UInt& /*i*/, const UInt& /*j*/) const
214  {
215  return M_value;
216  }
217 
218  //@}
219 
220 private:
221 
222  //! @name Private Methods
223  //@{
224 
225  //! No empty constructor
226  EvaluationIfCrossed();
227 
228  //@}
229 
230  fespacePtr_Type M_fespace;
231  vector_Type M_vector;
232 
233  Real M_value;
234 };
235 
236 template<typename MeshType, typename MapType, UInt SpaceDim>
237 const flag_Type
238 EvaluationIfCrossed<MeshType, MapType, SpaceDim>::
239 S_globalUpdateFlag = ET_UPDATE_NONE;
240 
241 template<typename MeshType, typename MapType, UInt SpaceDim>
242 const flag_Type
243 EvaluationIfCrossed<MeshType, MapType, SpaceDim>::
244 S_testUpdateFlag = ET_UPDATE_NONE;
245 
246 template<typename MeshType, typename MapType, UInt SpaceDim>
247 const flag_Type
248 EvaluationIfCrossed<MeshType, MapType, SpaceDim>::
249 S_solutionUpdateFlag = ET_UPDATE_NONE;
250 
251 
252 } // Namespace ExpressionAssembly
253 
254 } // Namespace LifeV
255 #endif
VectorEpetra - The Epetra Vector format Wrapper.
uint32_type flag_Type
bit-flag with up to 32 different flags
Definition: LifeV.hpp:197
void updateInverseJacobian(const UInt &iQuadPt)
double Real
Generic real data.
Definition: LifeV.hpp:175
QuadratureRule - The basis class for storing and accessing quadrature rules.
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191