Logo  0.95.0-final
Finite Element Embedded Library and Language in C++
Feel++ Feel++ on Github Feel++ community
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
dof.hpp
Go to the documentation of this file.
1 /* -*- mode: c++; coding: utf-8; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; show-trailing-whitespace: t -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2 
3  This file is part of the Feel library
4 
5  Author(s): Christophe Prud'homme <christophe.prudhomme@feelpp.org>
6  Date: 2010-04-20
7 
8  Copyright (C) 2013 Feel++ Consortium
9 
10  This library is free software; you can redistribute it and/or
11  modify it under the terms of the GNU Lesser General Public
12  License as published by the Free Software Foundation; either
13  version 2.1 of the License, or (at your option) any later version.
14 
15  This library 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, write to the Free Software
22  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */
29 #ifndef __Dof_H
30 #define __Dof_H 1
31 
32 #include <boost/tuple/tuple.hpp>
33 #include <boost/multi_index_container.hpp>
34 #include <boost/multi_index/member.hpp>
35 #include <boost/multi_index/composite_key.hpp>
36 #include <boost/multi_index/mem_fun.hpp>
37 #include <boost/multi_index/ordered_index.hpp>
38 
39 namespace Feel
40 {
48 class Dof : public boost::tuple<size_type, int16_type, bool, uint16_type, bool, size_type>
49 {
50  typedef boost::tuple<size_type, int16_type, bool, uint16_type, bool, size_type> super;
51 public:
52 
53 
57 
58 
60 
64 
65 
67 
71 
73  Dof()
74  :
75  super()
76  {
77  }
78 
79  Dof( size_type gid )
80  :
81  super( )
82  {
83  this->get<0>() = gid;
84  this->get<1>() = 1;
85  this->get<2>() = false;
86 
87  }
88 
89  Dof( boost::tuple<size_type, int16_type, bool> const& t )
90  :
91  super( )
92  {
93  this->get<0>() = t.get<0>();
94  this->get<1>() = t.get<1>();
95  this->get<2>() = t.get<2>();
96 
97  }
98 
99 
103  Dof( size_type _index, int16_type _sign, bool per, uint16_type _entity = 0, bool _location = false, size_type _marker = 0 )
104  :
105  super(_index, _sign, per, _entity, _location, _marker)
106  {
107  }
108 
110  Dof( Dof const & dof )
111  :
112  super( dof )
113  {}
114 
117  {}
118 
120 
124 
126  Dof& operator=( Dof const & o )
127  {
128  if ( this != &o )
129  {
130  super::operator=( o );
131  }
132 
133  return *this;
134  }
135  Dof& operator=( size_type t )
136  {
137  this->get<0>() = t;
138  this->get<1>() = 1;
139  this->get<2>() = false;
140  return *this;
141  }
142  Dof& operator=( boost::tuple<size_type, int16_type, bool> const& t )
143  {
144  this->get<0>() = t.get<0>();
145  this->get<1>() = t.get<1>();
146  this->get<2>() = t.get<2>();
147  return *this;
148  }
150 
154 
156  size_type index() const
157  {
158  return this->get<0>();
159  }
160 
162  int16_type sign() const
163  {
164  return this->get<1>();
165  }
167  bool isPeriodic() const
168  {
169  return this->get<2>();
170  }
171 
173  uint16_type entity() const
174  {
175  return this->get<3>();
176  }
177 
179  bool isOnBoundary() const
180  {
181  return this->get<4>();
182  }
183 
186  {
187  return this->get<5>();
188  }
189 
193  ublas::vector<double> const& coords() const
194  {
195  return M_coords;
196  }
197 
199 
203  // set the global dof id
204  void setIndex( size_type id )
205  {
206  this->get<0>() = id;
207  }
208 
212  void
213  setCoordinates( ublas::vector<double> const& coords )
214  {
215  M_coords = coords;
216  }
218 
219 
223 
224 
226 
227 
228 
229 protected:
230 
231 private:
232  ublas::vector<double> M_coords;
233 };
234 #if 0
235 typedef multi_index::multi_index_container<
236 Dof,
237 multi_index::indexed_by<
238 
239 // sort by less<int> on index()
240 multi_index::ordered_unique<multi_index::const_mem_fun<Dof,
241 size_type,
242 &Dof::index> >,
243 
244 // sort by less<int> on entity()
245 multi_index::ordered_non_unique<multi_index::tag<detail::by_entity>,
246 multi_index::const_mem_fun<Dof,
247 uint16_type,
248 &Dof::entity> >,
249 // sort by less<int> on location()
250 multi_index::ordered_non_unique<multi_index::tag<detail::by_location>,
251 multi_index::const_mem_fun<Dof,
252 bool,
254 // sort by less<int> on marker()
255 multi_index::ordered_non_unique<multi_index::tag<detail::by_marker>,
256 multi_index::const_mem_fun<Dof,
257 Marker1,
258 &Dof::marker> >
259 > > dof_container_type;
260 #endif
261 
262 class LocalDof: public std::pair<size_type,uint16_type>
263 {
264 public:
265  typedef std::pair<size_type,uint16_type> super;
266  LocalDof()
267  :
268  super( std::make_pair( 0, 0 ) )
269  {}
270  LocalDof( size_type e, uint16_type l )
271  :
272  super( std::make_pair( e, l ) )
273  {}
274  LocalDof( std::pair<int,int> const& p )
275  :
276  super( p )
277  {}
278  size_type elementId() const { return this->first; }
279  size_type localDof() const { return this->second; }
280 };
281 
282 class LocalDofSet : public std::vector<LocalDof>
283 {
284 public:
285  typedef std::vector<LocalDof> super;
286  LocalDofSet()
287  :
288  super()
289  {}
290 
291  LocalDofSet( size_type eid, uint16_type nLocalDof )
292  :
293  super(nLocalDof)
294  {
295  for(uint16_type i = 0; i < nLocalDof; ++i )
296  {
297  this->at( i ) = LocalDof( eid, i );
298  }
299  }
300  LocalDofSet const& update( size_type eid )
301  {
302  DCHECK( !this->empty() ) << "Invalid Local Dof Set";
303  std::for_each( this->begin(), this->end(), [eid]( LocalDof& d ) { d.first = eid; } );
304  return *this;
305  }
306 };
307 } // Feel
308 #endif /* __Dof_H */
uint16_type entity() const
Definition: dof.hpp:173
Dof()
default constructor
Definition: dof.hpp:73
bool isPeriodic() const
Definition: dof.hpp:167
size_type marker() const
Definition: dof.hpp:185
class that represents a degree of freedom
Definition: dof.hpp:48
int16_type sign() const
Definition: dof.hpp:162
size_t size_type
Indices (starting from 0)
Definition: feelcore/feel.hpp:319
Dof(Dof const &dof)
copy constructor
Definition: dof.hpp:110
bool isOnBoundary() const
Definition: dof.hpp:179
Elements & operator=(Elements const &e)
Definition: elements.hpp:335
ublas::vector< double > const & coords() const
Definition: dof.hpp:193
void setCoordinates(ublas::vector< double > const &coords)
Definition: dof.hpp:213
Dof & operator=(Dof const &o)
copy operator
Definition: dof.hpp:126
~Dof()
destructor
Definition: dof.hpp:116
size_type index() const
Definition: dof.hpp:156

Generated on Sun Dec 22 2013 13:10:58 for Feel++ by doxygen 1.8.5