/usr/include/deal.II/hp/dof_level.h is in libdeal.ii-dev 8.1.0-6ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 | // ---------------------------------------------------------------------
// $Id: dof_level.h 31932 2013-12-08 02:15:54Z heister $
//
// Copyright (C) 2003 - 2013 by the deal.II authors
//
// This file is part of the deal.II library.
//
// The deal.II library is free software; you can use it, redistribute
// it, and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// The full text of the license can be found in the file LICENSE at
// the top level of the deal.II distribution.
//
// ---------------------------------------------------------------------
#ifndef __deal2__hp_dof_level_h
#define __deal2__hp_dof_level_h
#include <deal.II/base/config.h>
#include <deal.II/base/exceptions.h>
#include <vector>
DEAL_II_NAMESPACE_OPEN
namespace hp
{
template <int, int> class DoFHandler;
template <int, int> class FECollection;
}
namespace internal
{
namespace hp
{
namespace DoFHandler
{
struct Implementation;
}
}
namespace DoFCellAccessor
{
struct Implementation;
}
}
namespace internal
{
namespace hp
{
/**
* This is the class that stores the degrees of freedom on cells in a hp
* hierarchy. Compared to faces and edges, the task here is simple since
* each cell can only have a single active finite element index. Consequently,
* all we need is one long array with DoF indices and one array of offsets
* where each cell's indices start within the array of indices. This is in
* contrast to the DoFObjects class where each face or edge may have more than
* one associated finite element with corresponding degrees of freedom.
*
* The data stored here is represented by three arrays
* - The @p active_fe_indices array stores for each cell which
* finite element is used on this cell. Since some cells are not active
* on the current level, some entries in this array may represent an
* invalid value.
* - The @p dof_indices array stores for each active cell on the current
* level the dofs that associated with the <i>interior</i> of the cell,
* i.e., the @p dofs_per_line dofs associated with the line in 1d, and
* @p dofs_per_quad and @p dofs_per_hex in 2d and 3d. These numbers are
* in general smaller than @p dofs_per_cell.
* - The @p dof_offsets array stores, for each cell, the starting point
* of the dof indices corresponding to this cell in the @p dof_indices
* array. This is analogous to how we store data in compressed row storage
* for sparse matrices. For cells that are not active on the current level,
* we store an invalid value for the starting index.
*
* <h3>Compression</h3>
*
* It is common for the indices stored in @p dof_indices for one cell to be
* numbered consecutively. For example, using the standard numbering (without
* renumbering DoFs), the quad dofs on the first cell of a mesh when using a
* $Q_3$ element will be numbered <tt>12, 13, 14, 15</tt>. This allows for
* compression if we only store the first entry and have some way to mark
* the DoFs on this object as compressed. Here, compression means that we
* know that subsequent DoF indices can be obtained from the previous ones
* by just incrementing them by one -- in other words, we use a variant of doing
* run-length encoding. The way to do this is that we
* use positive FE indices for uncompressed sets of DoFs and if a set of indices
* is compressed, then we instead store the FE index in binary complement (which
* we can identify by looking at the sign bit when interpreting the number as a
* signed one). There are two functions, compress_data() and uncompress_data()
* that convert between the two possible representations.
*
* Note that compression is not always possible. For example, if one renumbered
* the example above using DoFRenumbering::downstream with $(1,0)^T$ as
* direction, then they would likely be numbered <tt>12, 14, 13, 15</tt>, which
* can not be compressed using run-length encoding.
*/
class DoFLevel
{
private:
/**
* The type in which we store the offsets into the dof_indices array.
*/
typedef unsigned int offset_type;
/**
* The type in which we store the active FE index.
*/
typedef unsigned short int active_fe_index_type;
/**
* A signed type that matches the type in which we store the active FE
* index. We use this in computing binary complements.
*/
typedef signed short int signed_active_fe_index_type;
/**
* Indices specifying the finite element of hp::FECollection to
* use for the different cells on the current level. The vector
* stores one element per cell since the active_fe_index is
* unique for cells.
*
* If a cell is not active on the level corresponding to the
* current object (i.e., it has children on higher levels) then
* it does not have an associated fe index and we store
* an invalid fe index marker instead.
*/
std::vector<active_fe_index_type> active_fe_indices;
/**
* Store the start index for the degrees of freedom of each
* object in the @p dof_indices array. If the cell corresponding to
* a particular index in this array is not active on this level,
* then we do not store any DoFs for it. In that case, the offset
* we store here must be an invalid number and indeed we store
* <code>(std::vector<types::global_dof_index>::size_type)(-1)</code>
* for it.
*
* The type we store is then obviously the type the @p dof_indices array
* uses for indexing.
*/
std::vector<offset_type> dof_offsets;
/**
* Store the global indices of the degrees of freedom.
* information. The dof_offsets field determines where each
* (active) cell's data is stored.
*/
std::vector<types::global_dof_index> dof_indices;
/**
* The offsets for each cell of the cache that holds all DoF indices.
*/
std::vector<offset_type> cell_cache_offsets;
/**
* Cache for the DoF indices
* on cells. The size of this
* array equals the sum over all cells of selected_fe[active_fe_index[cell]].dofs_per_cell.
*/
std::vector<types::global_dof_index> cell_dof_indices_cache;
public:
/**
* Set the global index of
* the @p local_index-th
* degree of freedom located
* on the object with number @p
* obj_index to the value
* given by @p global_index. The @p
* dof_handler argument is
* used to access the finite
* element that is to be used
* to compute the location
* where this data is stored.
*
* The third argument, @p
* fe_index, denotes which of
* the finite elements
* associated with this
* object we shall
* access. Refer to the
* general documentation of
* the internal::hp::DoFLevel
* class template for more
* information.
*/
void
set_dof_index (const unsigned int obj_index,
const unsigned int fe_index,
const unsigned int local_index,
const types::global_dof_index global_index);
/**
* Return the global index of
* the @p local_index-th
* degree of freedom located
* on the object with number @p
* obj_index. The @p
* dof_handler argument is
* used to access the finite
* element that is to be used
* to compute the location
* where this data is stored.
*
* The third argument, @p
* fe_index, denotes which of
* the finite elements
* associated with this
* object we shall
* access. Refer to the
* general documentation of
* the internal::hp::DoFLevel
* class template for more
* information.
*/
types::global_dof_index
get_dof_index (const unsigned int obj_index,
const unsigned int fe_index,
const unsigned int local_index) const;
/**
* Return the fe_index of the
* active finite element
* on this object.
*/
unsigned int
active_fe_index (const unsigned int obj_index) const;
/**
* Check whether a given
* finite element index is
* used on the present
* object or not.
*/
bool
fe_index_is_active (const unsigned int obj_index,
const unsigned int fe_index) const;
/**
* Set the fe_index of the
* active finite element
* on this object.
*/
void
set_active_fe_index (const unsigned int obj_index,
const unsigned int fe_index);
/**
* Return a pointer to the beginning of the DoF indices cache
* for a given cell.
*
* @param obj_index The number of the cell we are looking at.
* @param dofs_per_cell The number of DoFs per cell for this cell. This
* is not used for the hp case but necessary to keep the interface
* the same as for the non-hp case.
* @return A pointer to the first DoF index for the current cell. The
* next dofs_per_cell indices are for the current cell.
*/
const types::global_dof_index *
get_cell_cache_start (const unsigned int obj_index,
const unsigned int dofs_per_cell) const;
/**
* Determine an estimate for the
* memory consumption (in bytes)
* of this object.
*/
std::size_t memory_consumption () const;
private:
/**
* Compress the arrays that store dof indices by using a variant
* of run-length encoding. See the general documentation of this
* class for more information.
*
* @param fe_collection The object that can tell us how many
* degrees of freedom each of the finite elements has that we
* store in this object.
*/
template <int dim, int spacedim>
void compress_data (const dealii::hp::FECollection<dim,spacedim> &fe_collection);
/**
* Uncompress the arrays that store dof indices by using a variant
* of run-length encoding. See the general documentation of this
* class for more information.
*
* @param fe_collection The object that can tell us how many
* degrees of freedom each of the finite elements has that we
* store in this object.
*/
template <int dim, int spacedim>
void uncompress_data (const dealii::hp::FECollection<dim,spacedim> &fe_collection);
/**
* Make hp::DoFHandler and its auxiliary class a friend since it
* is the class that needs to create these data structures.
*/
template <int, int> friend class dealii::hp::DoFHandler;
friend struct dealii::internal::hp::DoFHandler::Implementation;
friend struct dealii::internal::DoFCellAccessor::Implementation;
};
// -------------------- template functions --------------------------------
inline
types::global_dof_index
DoFLevel::
get_dof_index (const unsigned int obj_index,
const unsigned int fe_index,
const unsigned int local_index) const
{
Assert (obj_index < dof_offsets.size(),
ExcIndexRange (obj_index, 0, dof_offsets.size()));
// make sure we are on an
// object for which DoFs have
// been allocated at all
Assert (dof_offsets[obj_index] != (offset_type)(-1),
ExcMessage ("You are trying to access degree of freedom "
"information for an object on which no such "
"information is available"));
Assert (fe_index == active_fe_indices[obj_index],
ExcMessage ("FE index does not match that of the present cell"));
// see if the dof_indices array has been compressed for this
// particular cell
if ((signed_active_fe_index_type)active_fe_indices[obj_index]>=0)
return dof_indices[dof_offsets[obj_index]+local_index];
else
return dof_indices[dof_offsets[obj_index]]+local_index;
}
inline
void
DoFLevel::
set_dof_index (const unsigned int obj_index,
const unsigned int fe_index,
const unsigned int local_index,
const types::global_dof_index global_index)
{
Assert (obj_index < dof_offsets.size(),
ExcIndexRange (obj_index, 0, dof_offsets.size()));
// make sure we are on an
// object for which DoFs have
// been allocated at all
Assert (dof_offsets[obj_index] != (offset_type)(-1),
ExcMessage ("You are trying to access degree of freedom "
"information for an object on which no such "
"information is available"));
Assert ((signed_active_fe_index_type)active_fe_indices[obj_index]>=0,
ExcMessage ("This function can no longer be called after compressing the dof_indices array"));
Assert (fe_index == active_fe_indices[obj_index],
ExcMessage ("FE index does not match that of the present cell"));
dof_indices[dof_offsets[obj_index]+local_index] = global_index;
}
inline
unsigned int
DoFLevel::
active_fe_index (const unsigned int obj_index) const
{
Assert (obj_index < active_fe_indices.size(),
ExcIndexRange (obj_index, 0, active_fe_indices.size()));
if (((signed_active_fe_index_type)active_fe_indices[obj_index]) >= 0)
return active_fe_indices[obj_index];
else
return (active_fe_index_type)~(signed_active_fe_index_type)active_fe_indices[obj_index];
}
inline
bool
DoFLevel::
fe_index_is_active (const unsigned int obj_index,
const unsigned int fe_index) const
{
return (fe_index == active_fe_index(obj_index));
}
inline
void
DoFLevel::
set_active_fe_index (const unsigned int obj_index,
const unsigned int fe_index)
{
Assert (obj_index < active_fe_indices.size(),
ExcIndexRange (obj_index, 0, active_fe_indices.size()));
active_fe_indices[obj_index] = fe_index;
}
inline
const types::global_dof_index *
DoFLevel::get_cell_cache_start (const unsigned int obj_index,
const unsigned int dofs_per_cell) const
{
Assert (obj_index < cell_cache_offsets.size(),
ExcInternalError());
Assert (cell_cache_offsets[obj_index]+dofs_per_cell
<=
cell_dof_indices_cache.size(),
ExcInternalError());
return &cell_dof_indices_cache[cell_cache_offsets[obj_index]];
}
} // namespace hp
} // namespace internal
DEAL_II_NAMESPACE_CLOSE
#endif
|