| 1 |
// ------------------------------------------------------------------------ |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 4 |
// Copyright (C) 1998 - 2025 by the deal.II authors |
| 5 |
// |
| 6 |
// This file is part of the deal.II library. |
| 7 |
// |
| 8 |
// Part of the source code is dual licensed under Apache-2.0 WITH |
| 9 |
// LLVM-exception OR LGPL-2.1-or-later. Detailed license information |
| 10 |
// governing the source code and code contributions can be found in |
| 11 |
// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II. |
| 12 |
// |
| 13 |
// ------------------------------------------------------------------------ |
| 14 |
|
| 15 |
#ifndef dealii_dof_levels_h |
| 16 |
#define dealii_dof_levels_h |
| 17 |
|
| 18 |
|
| 19 |
#include <deal.II/base/config.h> |
| 20 |
|
| 21 |
#include <deal.II/base/exceptions.h> |
| 22 |
#include <deal.II/base/memory_consumption.h> |
| 23 |
#include <deal.II/base/types.h> |
| 24 |
|
| 25 |
#include <deal.II/dofs/dof_objects.h> |
| 26 |
|
| 27 |
#include <vector> |
| 28 |
|
| 29 |
|
| 30 |
DEAL_II_NAMESPACE_OPEN |
| 31 |
|
| 32 |
|
| 33 |
namespace internal |
| 34 |
{ |
| 35 |
namespace DoFHandlerImplementation |
| 36 |
{ |
| 37 |
/** |
| 38 |
* Structure for storing degree of freedom information for cells, |
| 39 |
* organized by levels. |
| 40 |
* |
| 41 |
* Note that vertices use a storage scheme that is entirely separate from |
| 42 |
* the one used for the cells. The indices of degrees of freedom located |
| 43 |
* on vertices are therefore not stored here, but rather in member |
| 44 |
* variables of the DoFHandler class. |
| 45 |
* |
| 46 |
* The indices of degrees of freedom located on lower dimensional objects, |
| 47 |
* i.e. on lines for 2d and on quads and lines for 3d are treated |
| 48 |
* similarly than that on cells. However, these geometrical objects, which |
| 49 |
* are called faces as a generalization, are not organised in a |
| 50 |
* hierarchical structure of levels. Therefore, the degrees of freedom |
| 51 |
* located on these objects are stored in separate classes, namely the |
| 52 |
* <tt>DoFFaces</tt> classes. |
| 53 |
* |
| 54 |
* Access to this object is usually through the |
| 55 |
* DoFAccessor::set_dof_index() and DoFAccessor::dof_index() functions or |
| 56 |
* similar functions of derived classes that in turn access the member |
| 57 |
* variables using the DoFHandler::get_dof_index() and corresponding |
| 58 |
* setter functions. Knowledge of the actual data format is therefore |
| 59 |
* encapsulated to the present hierarchy of classes as well as the |
| 60 |
* DoFHandler class. |
| 61 |
*/ |
| 62 |
template <int dim> |
| 63 |
class DoFLevel |
| 64 |
{ |
| 65 |
public: |
| 66 |
/** |
| 67 |
* Cache for the DoF indices on cells. The size of this array equals the |
| 68 |
* number of cells on a given level times selected_fe.n_dofs_per_cell(). |
| 69 |
*/ |
| 70 |
std::vector<types::global_dof_index> cell_dof_indices_cache; |
| 71 |
|
| 72 |
/** |
| 73 |
* The object containing dof-indices and related access-functions |
| 74 |
*/ |
| 75 |
DoFObjects<dim> dof_object; |
| 76 |
|
| 77 |
/** |
| 78 |
* Return a pointer to the beginning of the DoF indices cache for a |
| 79 |
* given cell. |
| 80 |
* |
| 81 |
* @param obj_index The number of the cell we are looking at. |
| 82 |
* @param dofs_per_cell The number of DoFs per cell for this cell. |
| 83 |
* @return A pointer to the first DoF index for the current cell. The |
| 84 |
* next dofs_per_cell indices are for the current cell. |
| 85 |
*/ |
| 86 |
const types::global_dof_index * |
| 87 |
get_cell_cache_start(const unsigned int obj_index, |
| 88 |
const unsigned int dofs_per_cell) const; |
| 89 |
|
| 90 |
/** |
| 91 |
* Determine an estimate for the memory consumption (in bytes) of this |
| 92 |
* object. |
| 93 |
*/ |
| 94 |
std::size_t |
| 95 |
memory_consumption() const; |
| 96 |
|
| 97 |
/** |
| 98 |
* Read or write the data of this object to or from a stream for the |
| 99 |
* purpose of serialization using the [BOOST serialization |
| 100 |
* library](https://www.boost.org/doc/libs/1_74_0/libs/serialization/doc/index.html). |
| 101 |
*/ |
| 102 |
template <class Archive> |
| 103 |
void |
| 104 |
serialize(Archive &ar, const unsigned int version); |
| 105 |
}; |
| 106 |
|
| 107 |
|
| 108 |
|
| 109 |
template <int dim> |
| 110 |
inline const types::global_dof_index * |
| 111 |
DoFLevel<dim>::get_cell_cache_start(const unsigned int obj_index, |
| 112 |
const unsigned int dofs_per_cell) const |
| 113 |
{ |
| 114 |
Assert(obj_index * dofs_per_cell + dofs_per_cell <= |
| 115 |
cell_dof_indices_cache.size(), |
| 116 |
ExcInternalError()); |
| 117 |
|
| 118 |
return cell_dof_indices_cache.data() + (obj_index * dofs_per_cell); |
| 119 |
} |
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
template <int dim> |
| 124 |
inline std::size_t |
| 125 |
DoFLevel<dim>::memory_consumption() const |
| 126 |
{ |
| 127 |
return (MemoryConsumption::memory_consumption(cell_dof_indices_cache) + |
| 128 |
MemoryConsumption::memory_consumption(dof_object)); |
| 129 |
} |
| 130 |
|
| 131 |
|
| 132 |
template <int dim> |
| 133 |
template <class Archive> |
| 134 |
inline void |
| 135 |
DoFLevel<dim>::serialize(Archive &ar, const unsigned int) |
| 136 |
{ |
| 137 |
ar &cell_dof_indices_cache; |
| 138 |
ar &dof_object; |
| 139 |
} |
| 140 |
} // namespace DoFHandlerImplementation |
| 141 |
} // namespace internal |
| 142 |
|
| 143 |
DEAL_II_NAMESPACE_CLOSE |
| 144 |
|
| 145 |
#endif |