ug4
local_dof_set.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010-2015: G-CSC, Goethe University Frankfurt
3  * Author: Andreas Vogel
4  *
5  * This file is part of UG4.
6  *
7  * UG4 is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License version 3 (as published by the
9  * Free Software Foundation) with the following additional attribution
10  * requirements (according to LGPL/GPL v3 §7):
11  *
12  * (1) The following notice must be displayed in the Appropriate Legal Notices
13  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14  *
15  * (2) The following notice must be displayed at a prominent place in the
16  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17  *
18  * (3) The following bibliography is recommended for citation and must be
19  * preserved in all covered files:
20  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21  * parallel geometric multigrid solver on hierarchically distributed grids.
22  * Computing and visualization in science 16, 4 (2013), 151-164"
23  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24  * flexible software system for simulating pde based models on high performance
25  * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26  *
27  * This program is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  * GNU Lesser General Public License for more details.
31  */
32 
33 #ifndef __H__UG__LIB_DISC__LOCAL_FINITE_ELEMENT__LOCAL_DOF_SET__
34 #define __H__UG__LIB_DISC__LOCAL_FINITE_ELEMENT__LOCAL_DOF_SET__
35 
36 #include <vector>
37 #include <map>
38 
42 
43 namespace ug{
44 
47 
57 class LocalDoF
58 {
59  public:
61  LocalDoF() : m_dim(-1), m_id(0), m_offset(0) {}
62 
64 
74  LocalDoF(int dim, size_t id, size_t offset)
76  {}
77 
79  void set(int dim, size_t id, size_t offset)
80  {
81  m_dim = dim; m_id = id; m_offset = offset;
82  }
83 
85  inline int dim() const {return m_dim;}
86 
88  inline size_t id() const {return m_id;}
89 
91  inline size_t offset() const {return m_offset;}
92 
94  bool operator==(const LocalDoF& v) const{
95  return dim() == v.dim() && id() == v.id() && offset() == v.offset();
96  }
97 
99  bool operator!=(const LocalDoF& v) const {return !((*this)==v);}
100 
101  protected:
103  int m_dim;
104 
106  size_t m_id;
107 
109  size_t m_offset;
110 };
111 
113 std::ostream& operator<<(std::ostream& out, const LocalDoF& v);
114 
120 {
121  public:
123  int dim() const;
124 
126  virtual ReferenceObjectID roid() const = 0;
127 
130  size_t num_dof() const {return num_sh();}
131  virtual size_t num_sh() const;
133 
135  virtual size_t num_dof(ReferenceObjectID roid) const = 0;
136 
138  virtual const LocalDoF& local_dof(size_t dof) const = 0;
139 
141  size_t num_dof(int d, size_t id) const;
142 
144  bool operator==(const LocalDoFSet& v) const;
145 
147  bool operator!=(const LocalDoFSet& v) const {return !((*this)==v);}
148 
150  virtual ~LocalDoFSet() {};
151 };
152 
156 template <int TDim>
158 {
159  public:
161  DimLocalDoFSet();
162 
164  virtual bool exact_position_available() const = 0;
165 
167 
174  virtual bool position(size_t i, MathVector<TDim>& pos) const = 0;
175 
177  bool operator==(const DimLocalDoFSet<TDim>& v) const;
178 
180  bool operator!=(const DimLocalDoFSet<TDim>& v) const {return !((*this)==v);}
181 };
182 
184 
186 std::ostream& operator<<(std::ostream& out, const LocalDoFSet& v);
188 template <int dim>
189 std::ostream& operator<<(std::ostream& out, const DimLocalDoFSet<dim>& v);
190 
195 {
196  public:
198  enum{NOT_SPECIFIED = -1};
199 
202 
204  void clear();
205 
207  void add(const LocalDoFSet& set);
208 
210  int num_dof(ReferenceObjectID roid) const {return m_vNumDoF[roid];}
211 
212  protected:
214 };
215 
217 std::ostream& operator<<(std::ostream& out, const CommonLocalDoFSet& v);
218 
219 
220 } // end namespace ug
221 
222 #endif /* __H__UG__LIB_DISC__LOCAL_FINITE_ELEMENT__LOCAL_DOF_SET__ */
Definition: local_dof_set.h:195
CommonLocalDoFSet()
constructor
Definition: local_dof_set.h:201
void clear()
reset all numbers of dofs to not set
Definition: local_dof_set.cpp:114
int num_dof(ReferenceObjectID roid) const
number of dofs on a reference element type
Definition: local_dof_set.h:210
void add(const LocalDoFSet &set)
add a local dof set to the intersection
Definition: local_dof_set.cpp:122
int m_vNumDoF[NUM_REFERENCE_OBJECTS]
Definition: local_dof_set.h:213
@ NOT_SPECIFIED
Definition: local_dof_set.h:198
Definition: local_dof_set.h:158
bool operator!=(const DimLocalDoFSet< TDim > &v) const
inequality check
Definition: local_dof_set.h:180
virtual bool position(size_t i, MathVector< TDim > &pos) const =0
local position of DoF i
bool operator==(const DimLocalDoFSet< TDim > &v) const
equality check
Definition: local_dof_set.cpp:87
DimLocalDoFSet()
constructor
Definition: local_dof_set.cpp:83
virtual bool exact_position_available() const =0
returns if the local dof position are exact
Definition: local_dof_set.h:58
int m_dim
dimension of sub-geometric object
Definition: local_dof_set.h:103
size_t id() const
returns the index for the geometric object (w.r.t reference element numbering)
Definition: local_dof_set.h:88
size_t m_id
id of sub-geometric object in counting of reference element
Definition: local_dof_set.h:106
LocalDoF()
default constructor
Definition: local_dof_set.h:61
LocalDoF(int dim, size_t id, size_t offset)
constructor
Definition: local_dof_set.h:74
size_t m_offset
offset if several DoFs associated to the same geometric object
Definition: local_dof_set.h:109
bool operator!=(const LocalDoF &v) const
inequality check
Definition: local_dof_set.h:99
bool operator==(const LocalDoF &v) const
equality check
Definition: local_dof_set.h:94
size_t offset() const
returns the offset for the geometric object
Definition: local_dof_set.h:91
void set(int dim, size_t id, size_t offset)
sets the values
Definition: local_dof_set.h:79
int dim() const
returns the dimension of associated geometric object
Definition: local_dof_set.h:85
Definition: local_dof_set.h:120
virtual size_t num_dof(ReferenceObjectID roid) const =0
returns the number of DoFs on a sub-geometric object type
virtual size_t num_sh() const
Definition: local_dof_set.cpp:46
bool operator!=(const LocalDoFSet &v) const
inequality check
Definition: local_dof_set.h:147
virtual ~LocalDoFSet()
virtual destructor
Definition: local_dof_set.h:150
int dim() const
returns the reference dimension
Definition: local_dof_set.cpp:42
size_t num_dof() const
Definition: local_dof_set.h:130
bool operator==(const LocalDoFSet &v) const
equality check
Definition: local_dof_set.cpp:60
virtual const LocalDoF & local_dof(size_t dof) const =0
returns the DoFs storage
virtual ReferenceObjectID roid() const =0
returns the Reference object id of the corresponding grid object
a mathematical Vector with N entries.
Definition: math_vector.h:97
std::ostream & operator<<(std::ostream &outStream, const ug::MathMatrix< 2, 2 > &m)
Definition: math_matrix.cpp:38
the ug namespace
ReferenceObjectID
these ids are used to identify the shape of a geometric object.
Definition: grid_base_objects.h:74
@ NUM_REFERENCE_OBJECTS
Definition: grid_base_objects.h:85