Line data Source code
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 :
39 : #include "local_finite_element_id.h"
40 : #include "lib_disc/reference_element/reference_element_traits.h"
41 : #include "lib_grid/grid/grid_base_objects.h"
42 :
43 : namespace ug{
44 :
45 : /// \ingroup lib_disc_local_finite_elements
46 : /// @{
47 :
48 : /**
49 : * This class is used to store for a single degree of freedom (DoF) the location
50 : * within an element. For continuous finite elements the DoFs are usually
51 : * associated with a sub-geometric object of the element itself (e.g. a vertex).
52 : * This can be requested from this class, which stores the dimension of the
53 : * sub-element the DoF is located on, the id of the sub-element (w.r.t. to the
54 : * numbering in the reference elements) and an offset > 0 if there are more than
55 : * one DoFs associated with the same sub-element.
56 : */
57 : class LocalDoF
58 : {
59 : public:
60 : /// default constructor
61 0 : LocalDoF() : m_dim(-1), m_id(0), m_offset(0) {}
62 :
63 : /// constructor
64 : /**
65 : * Create a pair describing the position of a DoF within the reference element.
66 : *
67 : * \param[in] dim dimension of sub-geometric object
68 : * \param[in] id number of sub-geometric object (in the numbering
69 : * used by the reference element)
70 : * \param[in] offset if several DoFs are associated with the same
71 : * sub-geometric object the offset specifies the number
72 : * within all DoFs on that geometric object
73 : */
74 : LocalDoF(int dim, size_t id, size_t offset)
75 259 : : m_dim(dim), m_id(id), m_offset(offset)
76 : {}
77 :
78 : /// sets the values
79 : void set(int dim, size_t id, size_t offset)
80 : {
81 : m_dim = dim; m_id = id; m_offset = offset;
82 : }
83 :
84 : /// returns the dimension of associated geometric object
85 0 : inline int dim() const {return m_dim;}
86 :
87 : /// returns the index for the geometric object (w.r.t reference element numbering)
88 0 : inline size_t id() const {return m_id;}
89 :
90 : /// returns the offset for the geometric object
91 0 : inline size_t offset() const {return m_offset;}
92 :
93 : /// equality check
94 : bool operator==(const LocalDoF& v) const{
95 0 : return dim() == v.dim() && id() == v.id() && offset() == v.offset();
96 : }
97 :
98 : /// inequality check
99 : bool operator!=(const LocalDoF& v) const {return !((*this)==v);}
100 :
101 : protected:
102 : /// dimension of sub-geometric object
103 : int m_dim;
104 :
105 : /// id of sub-geometric object in counting of reference element
106 : size_t m_id;
107 :
108 : /// offset if several DoFs associated to the same geometric object
109 : size_t m_offset;
110 : };
111 :
112 : /// writes to the output stream
113 : std::ostream& operator<<(std::ostream& out, const LocalDoF& v);
114 :
115 : /**
116 : * This class provides the interface for the storage of degrees of freedom
117 : * on a finite element.
118 : */
119 0 : class LocalDoFSet
120 : {
121 : public:
122 : /// returns the reference dimension
123 : int dim() const;
124 :
125 : /// returns the Reference object id of the corresponding grid object
126 : virtual ReferenceObjectID roid() const = 0;
127 :
128 : /// returns the total number of dofs on the finite element
129 : /// \{
130 0 : size_t num_dof() const {return num_sh();}
131 : virtual size_t num_sh() const;
132 : /// \}
133 :
134 : /// returns the number of DoFs on a sub-geometric object type
135 : virtual size_t num_dof(ReferenceObjectID roid) const = 0;
136 :
137 : /// returns the DoFs storage
138 : virtual const LocalDoF& local_dof(size_t dof) const = 0;
139 :
140 : /// returns the number of DoFs on a sub-geometric object of dim and id
141 : size_t num_dof(int d, size_t id) const;
142 :
143 : /// equality check
144 : bool operator==(const LocalDoFSet& v) const;
145 :
146 : /// inequality check
147 0 : bool operator!=(const LocalDoFSet& v) const {return !((*this)==v);}
148 :
149 : /// virtual destructor
150 : virtual ~LocalDoFSet() {};
151 : };
152 :
153 : /**
154 : * Local DoF Set also providing to local position of the dofs (iff available)
155 : */
156 : template <int TDim>
157 : class DimLocalDoFSet : public LocalDoFSet
158 : {
159 : public:
160 : /// constructor
161 : DimLocalDoFSet();
162 :
163 : /// returns if the local dof position are exact
164 : virtual bool exact_position_available() const = 0;
165 :
166 : /// local position of DoF i
167 : /**
168 : * This function returns the local position of a DoF if possible.
169 : * \param[in] i number of DoF
170 : * \param[out] pos Position of DoF
171 : * \retval true if position exists
172 : * \retval false if no meaningful position available
173 : */
174 : virtual bool position(size_t i, MathVector<TDim>& pos) const = 0;
175 :
176 : /// equality check
177 : bool operator==(const DimLocalDoFSet<TDim>& v) const;
178 :
179 : /// inequality check
180 0 : bool operator!=(const DimLocalDoFSet<TDim>& v) const {return !((*this)==v);}
181 : };
182 :
183 : /// @}
184 :
185 : /// writes to the output stream
186 : std::ostream& operator<<(std::ostream& out, const LocalDoFSet& v);
187 : /// writes to the output stream
188 : template <int dim>
189 : std::ostream& operator<<(std::ostream& out, const DimLocalDoFSet<dim>& v);
190 :
191 : /**
192 : * Intersection of local dof sets
193 : */
194 : class CommonLocalDoFSet
195 : {
196 : public:
197 : /// indicate not set value
198 : enum{NOT_SPECIFIED = -1};
199 :
200 : /// constructor
201 0 : CommonLocalDoFSet() {clear();}
202 :
203 : /// reset all numbers of dofs to not set
204 : void clear();
205 :
206 : /// add a local dof set to the intersection
207 : void add(const LocalDoFSet& set);
208 :
209 : /// number of dofs on a reference element type
210 0 : int num_dof(ReferenceObjectID roid) const {return m_vNumDoF[roid];}
211 :
212 : protected:
213 : int m_vNumDoF[NUM_REFERENCE_OBJECTS];
214 : };
215 :
216 : /// writes to the output stream
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__ */
|