LifeV
BCIdentifier.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 Classes for identifiers
30 
31  @date 01-07-2002
32  @author M. A. Fernandez & Luca Formaggia
33  @contributor Luca Bertagna <lbertag@emory.edu>
34 
35  This classes hold a identifier that allow us to impose a specific boundary condition.
36  Each type of boundary condition needs a specic information on the boundary. Thus, the
37  key is to use inheritance by adding, to the base class, the information requested for
38  imposing the BC.
39  */
40 
41 #ifndef BCIDENTIFIER_H
42 #define BCIDENTIFIER_H 1
43 
44 #include <lifev/core/LifeV.hpp>
45 
46 namespace LifeV
47 {
48 
49 //! BCIdentifierBase - Base class holding DOF identifiers for implementing BC
50 
52 {
53 public:
54 
55  //! @name Constructor & Destructor
56  //@{
57 
58  //! Empty Constructor
60  {
61  // Nothing to be done here
62  }
63 
64  //! Constructor given the ID
65  /*!
66  Creates an BCIdentifier with a given ID
67  @param i Usually the id of the DOF, or the id of a boundary face, etc...
68  */
69  explicit BCIdentifierBase ( ID const& i ) : M_id ( i )
70  {
71  // Nothing to be done here
72  }
73 
74  //! Copy constructor
75  BCIdentifierBase ( BCIdentifierBase const& id );
76 
77  //! Destructor
78  virtual ~BCIdentifierBase()
79  {
80  // Nothing to be done here
81  }
82 
83  //@}
84 
85  //! @name Methods
86  //@{
87 
88  //! Display method
89  virtual void showMe ( std::ostream& output = std::cout ) const;
90 
91  //@}
92 
93  //! @name Operators
94  //@{
95 
96  //! Conversion operator to unsigned int
97  operator unsigned int()
98  {
99  return id();
100  }
101 
102  //! Conversion operator to int
103  operator int()
104  {
105  return ( int ) id();
106  }
107 
108  //@}
109 
110 
111  //! @name Get Methods
112  //@{
113 
114  //! Returns the ID of the BCIdentifier
115  const ID& id() const
116  {
117  return M_id;
118  }
119 
120  //@}
121 
122 protected:
123 
125 };
126 
127 //! BCIdentifierComp - Functor for ordering operations (required in set STL container)
128 
130 {
131 public:
132 
133  //! @name Operators
134  //@{
135 
136  //! Comparison operator for BCIdentifier objects
137  /*!
138  @return Boolean which is true if the ID of the first BCIdentifier is smaller
139  than the ID of the second BCIdentifier
140  */
141  bool operator() ( const BCIdentifierBase* i1, const BCIdentifierBase* i2 ) const
142  {
143  return ( i1->id() < i2->id() );
144  }
145 
146  //! Comparison operator for shared pointers to BCIdentifier objects
147  /*!
148  @return Boolean which is true if the ID of the first BCIdentifier is smaller
149  than the ID of the second BCIdentifier
150  */
152  {
153  return ( i1.get()->id() < i2.get()->id() );
154  }
155 
156  //@}
157 };
158 
159 //! Overloading == operator for objects of type BCIdentifier
160 /*!
161  @param first The first BCIdentifier
162  @param second The second BCIdentifier
163  @return A bool which is 1 if the ID of the two BCIdentifier objects are the same
164  */
165 inline bool operator== ( const BCIdentifierBase& first, const BCIdentifierBase& second )
166 {
167  return first.id() == second.id();
168 }
169 
170 //! BCIdentifierEssential - BCIdentifier for implementing Essential Boundary Conditions
171 /*!
172 
173  This class holds the DOF identifier and its coordinates for implementing Essential
174  Boundary Conditions
175 
176  */
177 
179 {
180 public:
181 
182  //! Constructor & Destructor
183  //@{
184 
185  //! Empty Constructor
187  {
188  // Nothing to be done here
189  }
190 
191  //! Constructor given the ID and the coordinates
192  /*!
193  * Creates an BCIdentifier with a given ID and given coordinates
194  @paramx x x-coordinate of the node where this BC applies
195  @paramx y y-coordinate of the node where this BC applies
196  @paramx z z-coordinate of the node where this BC applies
197  */
198  BCIdentifierEssential ( const ID& id, const Real& x, const Real& y, const Real& z ) :
199  BCIdentifierBase ( id ),
200  M_x ( x ),
201  M_y ( y ),
202  M_z ( z )
203  {
204  // Nothing to be done here
205  }
206 
207  //! Copy Constructor
209 
210  //@}
211 
212  //! @name Methods
213  //@{
214 
215  //! Display method
216  virtual void showMe ( std::ostream& output = std::cout ) const;
217 
218  //@}
219 
220  //! @name Get Methods
221  //@{
222 
223  //! Recovering the node's x-coordinate
224  /*!
225  @return The x-coordinate of the node
226  */
227  const Real& x() const
228  {
229  return M_x;
230  }
231 
232  //! Recovering the node's y-coordinate
233  /*!
234  @return The y-coordinate of the node
235  */
236  const Real& y() const
237  {
238  return M_y;
239  }
240 
241  //! Recovering the node's z-coordinate
242  /*!
243  @return The z-coordinate of the node
244  */
245  const Real& z() const
246  {
247  return M_z;
248  }
249 
250  //@}
251 
252 private:
253 
255 };
256 
257 
258 //! BCIdentifierNatural - Idenifier for Natural and Robin Boundary Condiions
259 /*!
260 
261  This class holds the DOF identifier and the bdLocalToGlobal information for implementing
262  Natural and Robin boundary conditions
263 
264  */
265 
267 {
268 public:
269 
270  //! @name Constructor & Destructor
271  //@{
272 
273  //! Empty Constructor
275  {
276  // Nothing to be done here
277  }
278 
279  //! Constructor given ID and bdLocalToGlobal map
280  /*!
281  Creates an BCIdentifier with a given ID and a given local-to-global map
282  @param i The number of the boundary face
283  @param localToGlobal A vector holding the local-to-global map on this face
284  */
285  BCIdentifierNatural ( const ID& i, const std::vector<ID>& localToGlobal );
286 
287  //! Constructor given the ID
288  /*!
289  @param id The ID of the dof
290  */
291  explicit BCIdentifierNatural ( const ID& id );
292 
293  //! Copy Constructor
295 
296  //! Destructor
298  {
299  // Nothing to be done here
300  }
301 
302  //@}
303 
304  //! @name Methods
305  //@{
306 
307  //! Display method
308  virtual void showMe (std::ostream& output = std::cout ) const;
309 
310  //@}
311 
312  //! @name Get Methods
313  //@{
314 
315  //! Return the global DOF corresponding tho the i-th local DOF in the face
316  /*!
317  @param i The local DOF in the face
318  */
319  ID boundaryLocalToGlobalMap ( const ID& i ) const
320  {
321  return M_localToGlobal [i ];
322  }
323 
324  //@}
325 
326 private:
327 
329 };
330 
331 } // Namespace LifeV
332 
333 #endif /* BCIDENTIFIER_H */
BCIdentifierBase(BCIdentifierBase const &id)
Copy constructor.
const Real & y() const
Recovering the node&#39;s y-coordinate.
BCIdentifierBase(ID const &i)
Constructor given the ID.
const Real & z() const
Recovering the node&#39;s z-coordinate.
virtual void showMe(std::ostream &output=std::cout) const
Display method.
bool operator==(const BCIdentifierBase &first, const BCIdentifierBase &second)
Overloading == operator for objects of type BCIdentifier.
operator int()
Conversion operator to int.
BCIdentifierEssential(const ID &id, const Real &x, const Real &y, const Real &z)
Constructor given the ID and the coordinates.
virtual ~BCIdentifierNatural()
Destructor.
void updateInverseJacobian(const UInt &iQuadPt)
virtual void showMe(std::ostream &output=std::cout) const
Display method.
std::vector< ID > M_localToGlobal
uint32_type ID
IDs.
Definition: LifeV.hpp:194
bool operator()(const BCIdentifierBase *i1, const BCIdentifierBase *i2) const
Comparison operator for BCIdentifier objects.
operator unsigned int()
Conversion operator to unsigned int.
BCIdentifierComp - Functor for ordering operations (required in set STL container) ...
ID boundaryLocalToGlobalMap(const ID &i) const
Return the global DOF corresponding tho the i-th local DOF in the face.
BCIdentifierBase - Base class holding DOF identifiers for implementing BC.
BCIdentifierNatural()
Empty Constructor.
double Real
Generic real data.
Definition: LifeV.hpp:175
BCIdentifierNatural(const ID &i, const std::vector< ID > &localToGlobal)
Constructor given ID and bdLocalToGlobal map.
BCIdentifierEssential(BCIdentifierEssential const &id)
Copy Constructor.
BCIdentifierNatural(const ID &id)
Constructor given the ID.
const ID & id() const
Returns the ID of the BCIdentifier.
BCIdentifierEssential - BCIdentifier for implementing Essential Boundary Conditions.
const Real & x() const
Recovering the node&#39;s x-coordinate.
BCIdentifierBase()
Empty Constructor.
BCIdentifierEssential()
Constructor & Destructor.
BCIdentifierNatural(BCIdentifierNatural const &id)
Copy Constructor.
BCIdentifierNatural - Idenifier for Natural and Robin Boundary Condiions.
bool operator()(std::shared_ptr< BCIdentifierBase > const &i1, std::shared_ptr< BCIdentifierBase > const &i2) const
Comparison operator for shared pointers to BCIdentifier objects.
virtual void showMe(std::ostream &output=std::cout) const
Display method.
virtual ~BCIdentifierBase()
Destructor.