Flow123d
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
flow123d
src
fem
dofhandler.hh
Go to the documentation of this file.
1
/*!
2
*
3
* Copyright (C) 2007 Technical University of Liberec. All rights reserved.
4
*
5
* Please make a following refer to Flow123d on your project site if you use the program for any purpose,
6
* especially for academic research:
7
* Flow123d, Research Centre: Advanced Remedial Technologies, Technical University of Liberec, Czech Republic
8
*
9
* This program is free software; you can redistribute it and/or modify it under the terms
10
* of the GNU General Public License version 3 as published by the Free Software Foundation.
11
*
12
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
13
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14
* See the GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License along with this program; if not,
17
* write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 021110-1307, USA.
18
*
19
*
20
* $Id$
21
* $Revision$
22
* $LastChangedBy$
23
* $LastChangedDate$
24
*
25
* @file
26
* @brief Declaration of class which handles the ordering of degrees of freedom (dof) and mappings between local and global dofs.
27
* @author Jan Stebel
28
*/
29
30
#ifndef DOFHANDLER_HH_
31
#define DOFHANDLER_HH_
32
33
#include <map>
34
#include <petscmat.h>
35
#include "
mesh/mesh_types.hh
"
36
#include "
mesh/elements.h
"
37
#include "
la/distribution.hh
"
38
39
40
template
<
unsigned
int
dim,
unsigned
int
spacedim>
class
FiniteElement
;
41
class
Mesh
;
42
class
Distribution
;
43
44
/**
45
* Class DOFHandlerBase provides an abstract interface for various dof handlers:
46
* - basic handler for a given spatial dimension
47
* - multi-dimensional handler for all spatial dimensions (1D-3D)
48
* - handler for a specific region / part of mesh
49
*/
50
class
DOFHandlerBase
{
51
public
:
52
53
/**
54
* @brief Constructor.
55
* @param _mesh The mesh.
56
*/
57
DOFHandlerBase
(
Mesh
&_mesh) :
global_dof_offset
(0),
n_dofs
(0),
lsize_
(0),
mesh_
(&_mesh) {};
58
59
/**
60
* @brief Alias for iterator over cells.
61
*
62
* TODO: Notation to be fixed: element or cell
63
* TODO: Iterator goes through cells of all dimensions, but
64
* should go only through dim-dimensional ones.
65
*/
66
typedef
ElementFullIter
CellIterator
;
67
68
/**
69
* @brief Getter for the number of all mesh dofs required by the given
70
* finite element.
71
*/
72
const
unsigned
int
n_global_dofs
()
const
{
return
n_dofs
; }
73
74
/**
75
* @brief Returns the number of the first global dof handled by this
76
* DOFHandler.
77
*/
78
const
unsigned
int
offset
()
const
{
return
global_dof_offset
; }
79
80
/**
81
* @brief Returns the number of dofs on the current process.
82
*/
83
const
unsigned
int
lsize
()
const
{
return
lsize_
; }
84
85
/**
86
* @brief Returns the offset of the local part of dofs.
87
*/
88
const
unsigned
int
loffset
()
const
{
return
loffset_
; }
89
90
Distribution
*
distr
()
const
{
return
ds_
; }
91
92
Mesh
*
mesh
()
const
{
return
mesh_
; }
93
94
/**
95
* @brief Returns the global indices of dofs associated to the @p cell.
96
*
97
* @param cell The cell.
98
* @param indices Array of dof indices on the cell.
99
*/
100
virtual
void
get_dof_indices
(
const
CellIterator
&cell,
unsigned
int
indices[])
const
= 0;
101
102
/**
103
* @brief Returns the dof values associated to the @p cell.
104
*
105
* @param cell The cell.
106
* @param values The global vector of values.
107
* @param local_values Array of values at local dofs.
108
*/
109
virtual
void
get_dof_values
(
const
CellIterator
&cell,
const
Vec &values,
110
double
local_values[])
const
= 0;
111
112
/// Destructor.
113
virtual
~DOFHandlerBase
() {};
114
115
protected
:
116
117
/**
118
* @brief Index of first global dof.
119
*
120
* Positive value indicates that the first @p global_dof_offset
121
* entries in the global dof vector are reserved for a different
122
* DOFHandler.
123
*/
124
unsigned
int
global_dof_offset
;
125
126
/**
127
* @brief Number of global dofs assigned by the handler.
128
*/
129
unsigned
int
n_dofs
;
130
131
/**
132
* @brief Number of dofs associated to local process.
133
*/
134
unsigned
int
lsize_
;
135
136
/**
137
* @brief Index of the first dof on the local process.
138
*/
139
unsigned
int
loffset_
;
140
141
/**
142
* @brief Pointer to the mesh to which the dof handler is associated.
143
*/
144
Mesh
*
mesh_
;
145
146
/**
147
* @brief Distribution of dofs associated to local process.
148
*/
149
Distribution
*
ds_
;
150
151
};
152
153
154
155
156
///**
157
// * @brief Provides the numbering of the finite element degrees of freedom
158
// * on the computational mesh.
159
// *
160
// * Class DOFHandler distributes the degrees of freedom (dof) for
161
// * a particular finite element on the computational mesh
162
// * and provides mappings between local and global dofs.
163
// * The template parameter @p dim denotes the spatial dimension of
164
// * the reference finite element.
165
// *
166
// * Currently the functionality is restricted to discontinuous
167
// * finite elements, i.e. when the neighboring elements do not
168
// * share any common dof.
169
// */
170
//template<unsigned int dim, unsigned int spacedim>
171
//class DOFHandler : public DOFHandlerBase {
172
//public:
173
//
174
// /**
175
// * @brief Constructor.
176
// * @param _mesh The mesh.
177
// */
178
// DOFHandler(Mesh &_mesh);
179
//
180
// /**
181
// * @brief Alias for iterator over cells.
182
// *
183
// * TODO: Notation to be fixed: element or cell
184
// * TODO: Iterator goes through cells of all dimensions, but
185
// * should go only through dim-dimensional ones.
186
// */
187
// typedef ElementFullIter CellIterator;
188
//
189
// /**
190
// * @brief Distributes degrees of freedom on the mesh needed
191
// * for the given finite element.
192
// *
193
// * The additional parameter @p offset allows to reserve space
194
// * for another finite element dofs in the beginning of the
195
// * global dof vector.
196
// *
197
// * @param fe The finite element.
198
// * @param offset The offset.
199
// */
200
// void distribute_dofs(FiniteElement<dim,spacedim> &fe, const unsigned int offset = 0);
201
//
202
// /**
203
// * @brief Getter for the number of dofs at a single cell.
204
// *
205
// * This value depends on the given finite element.
206
// */
207
// const unsigned int n_local_dofs();
208
//
209
// /**
210
// * @brief Returns the global indices of dofs associated to the @p cell.
211
// *
212
// * @param cell The cell.
213
// * @param indices Array of dof indices on the cell.
214
// */
215
// void get_dof_indices(const CellIterator &cell, unsigned int indices[]);
216
//
217
// /**
218
// * @brief Returns the dof values associated to the @p cell.
219
// *
220
// * @param cell The cell.
221
// * @param values The global vector of values.
222
// * @param local_values Array of values at local dofs.
223
// */
224
// void get_dof_values(const CellIterator &cell, const Vec &values,
225
// double local_values[]);
226
//
227
// /// Destructor.
228
// ~DOFHandler();
229
//
230
//private:
231
//
232
// /**
233
// * @brief Pointer to the finite element class for which the handler
234
// * distributes dofs.
235
// */
236
// FiniteElement<dim,spacedim> *finite_element;
237
//
238
// /**
239
// * @brief Number of dofs associated to geometrical entities.
240
// *
241
// * Global numbers of dofs associated to nodes (object_dofs[0]),
242
// * 1D edges (object_dofs[1]), 2D faces (object_difs[2]) and
243
// * volumes (object_dofs[3]).
244
// */
245
// int ***object_dofs;
246
//
247
//};
248
249
250
251
class
DOFHandlerMultiDim
:
public
DOFHandlerBase
{
252
public
:
253
254
/**
255
* @brief Constructor.
256
* @param _mesh The mesh.
257
*/
258
DOFHandlerMultiDim
(
Mesh
&_mesh);
259
260
/**
261
* @brief Alias for iterator over cells.
262
*
263
* TODO: Notation to be fixed: element or cell
264
*/
265
typedef
ElementFullIter
CellIterator
;
266
267
/**
268
* @brief Distributes degrees of freedom on the mesh needed
269
* for the given finite elements.
270
*
271
* The additional parameter @p offset allows to reserve space
272
* for another finite element dofs in the beginning of the
273
* global dof vector.
274
*
275
* @param fe1d The 1D finite element.
276
* @param fe2d The 2D finite element.
277
* @param fe3d The 3D finite element.
278
* @param offset The offset.
279
*/
280
void
distribute_dofs
(
FiniteElement<1,3>
&fe1d,
281
FiniteElement<2,3>
&fe2d,
282
FiniteElement<3,3>
&fe3d,
283
const
unsigned
int
offset
= 0);
284
285
/**
286
* @brief Returns the global indices of dofs associated to the @p cell.
287
*
288
* @param cell The cell.
289
* @param indices Array of dof indices on the cell.
290
*/
291
void
get_dof_indices
(
const
CellIterator
&cell,
unsigned
int
indices[])
const override
;
292
293
/**
294
* @brief Returns the dof values associated to the @p cell.
295
*
296
* @param cell The cell.
297
* @param values The global vector of values.
298
* @param local_values Array of values at local dofs.
299
*/
300
void
get_dof_values
(
const
CellIterator
&cell,
const
Vec &values,
301
double
local_values[])
const override
;
302
303
/**
304
* @brief Returns the distribution of number of element to local processes.
305
*/
306
inline
Distribution
*
el_ds
()
const
{
return
el_ds_
; }
307
308
/**
309
* @brief Returns the global index of local element.
310
*
311
* @param loc_el Local index of element.
312
*/
313
inline
int
el_index
(
int
loc_el)
const
{
return
el_4_loc
[loc_el]; }
314
315
/**
316
* @brief Returns the global index of local edge.
317
*
318
* @param loc_edg Local index of edge.
319
*/
320
inline
int
edge_index
(
int
loc_edg)
const
{
return
edg_4_loc
[loc_edg]; }
321
322
/**
323
* @brief Returns the global index of local neighbour.
324
*
325
* @param loc_nb Local index of neighbour.
326
*/
327
inline
int
nb_index
(
int
loc_nb)
const
{
return
nb_4_loc
[loc_nb]; }
328
329
/**
330
* @brief Returns number of local edges.
331
*/
332
inline
unsigned
int
n_loc_edges
()
const
{
return
edg_4_loc
.size(); }
333
334
/**
335
* @brief Returns number of local neighbours.
336
*/
337
inline
unsigned
int
n_loc_nb
()
const
{
return
nb_4_loc
.size(); }
338
339
/**
340
* Returns true if element is on local process.
341
* @param index Global element index.
342
*/
343
bool
el_is_local
(
int
index)
const
;
344
345
template
<
unsigned
int
dim>
346
FiniteElement<dim,3>
*
fe
()
const
;
347
348
/// Destructor.
349
~DOFHandlerMultiDim
()
override
;
350
351
private
:
352
353
/**
354
* @brief Prepare parallel distribution of elements, edges and neighbours.
355
*/
356
void
make_elem_partitioning
();
357
358
/**
359
* @brief Pointer to the finite element class for which the handler
360
* distributes dofs.
361
*/
362
FiniteElement<1,3>
*
fe1d_
;
363
FiniteElement<2,3>
*
fe2d_
;
364
FiniteElement<3,3>
*
fe3d_
;
365
366
/**
367
* @brief Number of dofs associated to geometrical entities.
368
*
369
* Global numbers of dofs associated to nodes (object_dofs[0]),
370
* 1D edges (object_dofs[1]), 2D faces (object_difs[2]) and
371
* volumes (object_dofs[3]).
372
*/
373
int
***
object_dofs
;
374
375
376
/// Global element index -> index according to partitioning
377
int
*
row_4_el
;
378
/// Local element index -> global element index
379
int
*
el_4_loc
;
380
/// Distribution of elements
381
Distribution
*
el_ds_
;
382
383
/// Local edge index -> global edge index
384
vector<int>
edg_4_loc
;
385
386
/// Local neighbour index -> global neighbour index
387
vector<int>
nb_4_loc
;
388
389
};
390
391
392
393
394
#endif
/* DOFHANDLER_HH_ */
Generated on Thu May 29 2014 23:14:47 for Flow123d by
1.8.4