| 1 |
// ------------------------------------------------------------------------ |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 4 |
// Copyright (C) 2009 - 2022 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_integration_info_templates_h |
| 16 |
#define dealii_integration_info_templates_h |
| 17 |
|
| 18 |
|
| 19 |
#include <deal.II/base/config.h> |
| 20 |
|
| 21 |
#include <deal.II/base/quadrature_lib.h> |
| 22 |
|
| 23 |
#include <deal.II/meshworker/dof_info.h> |
| 24 |
#include <deal.II/meshworker/integration_info.h> |
| 25 |
|
| 26 |
DEAL_II_NAMESPACE_OPEN |
| 27 |
|
| 28 |
|
| 29 |
namespace MeshWorker |
| 30 |
{ |
| 31 |
template <int dim, int sdim> |
| 32 |
void |
| 33 |
IntegrationInfo<dim, sdim>::initialize_data( |
| 34 |
const std::shared_ptr<VectorDataBase<dim, sdim>> &data) |
| 35 |
{ |
| 36 |
global_data = data; |
| 37 |
const unsigned int nqp = fevalv[0]->n_quadrature_points; |
| 38 |
|
| 39 |
values.resize(global_data->n_values()); |
| 40 |
// For all selected finite element functions |
| 41 |
for (auto &function_values : values) |
| 42 |
{ |
| 43 |
function_values.resize(n_components); |
| 44 |
// For all components |
| 45 |
for (auto &component_values : function_values) |
| 46 |
{ |
| 47 |
component_values.resize(nqp); |
| 48 |
} |
| 49 |
} |
| 50 |
|
| 51 |
gradients.resize(global_data->n_gradients()); |
| 52 |
// For all selected finite element functions |
| 53 |
for (auto &function_gradients : gradients) |
| 54 |
{ |
| 55 |
function_gradients.resize(n_components); |
| 56 |
// For all components |
| 57 |
for (auto &component_gradients : function_gradients) |
| 58 |
{ |
| 59 |
component_gradients.resize(nqp); |
| 60 |
} |
| 61 |
} |
| 62 |
|
| 63 |
hessians.resize(global_data->n_hessians()); |
| 64 |
// For all selected finite element functions |
| 65 |
for (auto &function_hessians : hessians) |
| 66 |
{ |
| 67 |
function_hessians.resize(n_components); |
| 68 |
// For all components |
| 69 |
for (auto &component_hessians : function_hessians) |
| 70 |
{ |
| 71 |
component_hessians.resize(nqp); |
| 72 |
} |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
|
| 77 |
template <int dim, int sdim> |
| 78 |
void |
| 79 |
IntegrationInfo<dim, sdim>::clear() |
| 80 |
{ |
| 81 |
fevalv.resize(0); |
| 82 |
} |
| 83 |
|
| 84 |
|
| 85 |
|
| 86 |
template <int dim, int sdim> |
| 87 |
template <typename number> |
| 88 |
void |
| 89 |
IntegrationInfo<dim, sdim>::fill_local_data( |
| 90 |
const DoFInfo<dim, sdim, number> &info, |
| 91 |
bool split_fevalues) |
| 92 |
{ |
| 93 |
if (split_fevalues) |
| 94 |
{ |
| 95 |
unsigned int comp = 0; |
| 96 |
// Loop over all blocks |
| 97 |
for (unsigned int b = 0; b < info.block_info->local().size(); ++b) |
| 98 |
{ |
| 99 |
const unsigned int fe_no = info.block_info->base_element(b); |
| 100 |
const FEValuesBase<dim, sdim> &fe = this->fe_values(fe_no); |
| 101 |
const unsigned int n_comp = fe.get_fe().n_components(); |
| 102 |
const unsigned int block_start = |
| 103 |
info.block_info->local().block_start(b); |
| 104 |
const unsigned int block_size = |
| 105 |
info.block_info->local().block_size(b); |
| 106 |
|
| 107 |
if (info.level_cell) |
| 108 |
this->global_data->mg_fill(values, |
| 109 |
gradients, |
| 110 |
hessians, |
| 111 |
fe, |
| 112 |
info.cell->level(), |
| 113 |
info.indices, |
| 114 |
comp, |
| 115 |
n_comp, |
| 116 |
block_start, |
| 117 |
block_size); |
| 118 |
else |
| 119 |
this->global_data->fill(values, |
| 120 |
gradients, |
| 121 |
hessians, |
| 122 |
fe, |
| 123 |
info.indices, |
| 124 |
comp, |
| 125 |
n_comp, |
| 126 |
block_start, |
| 127 |
block_size); |
| 128 |
comp += n_comp; |
| 129 |
} |
| 130 |
} |
| 131 |
else |
| 132 |
{ |
| 133 |
const FEValuesBase<dim, sdim> &fe = this->fe_values(0); |
| 134 |
const unsigned int n_comp = fe.get_fe().n_components(); |
| 135 |
if (info.level_cell) |
| 136 |
this->global_data->mg_fill(values, |
| 137 |
gradients, |
| 138 |
hessians, |
| 139 |
fe, |
| 140 |
info.cell->level(), |
| 141 |
info.indices, |
| 142 |
0, |
| 143 |
n_comp, |
| 144 |
0, |
| 145 |
info.indices.size()); |
| 146 |
else |
| 147 |
this->global_data->fill(values, |
| 148 |
gradients, |
| 149 |
hessians, |
| 150 |
fe, |
| 151 |
info.indices, |
| 152 |
0, |
| 153 |
n_comp, |
| 154 |
0, |
| 155 |
info.indices.size()); |
| 156 |
} |
| 157 |
} |
| 158 |
|
| 159 |
|
| 160 |
template <int dim, int sdim> |
| 161 |
std::size_t |
| 162 |
IntegrationInfo<dim, sdim>::memory_consumption() const |
| 163 |
{ |
| 164 |
std::size_t mem = sizeof(*this) + |
| 165 |
MemoryConsumption::memory_consumption(fevalv) - |
| 166 |
sizeof(fevalv); |
| 167 |
for (unsigned int i = 0; i < fevalv.size(); ++i) |
| 168 |
mem += fevalv[i]->memory_consumption(); |
| 169 |
return mem; |
| 170 |
} |
| 171 |
|
| 172 |
//----------------------------------------------------------------------// |
| 173 |
|
| 174 |
template <int dim, int sdim> |
| 175 |
IntegrationInfoBox<dim, sdim>::IntegrationInfoBox() |
| 176 |
{ |
| 177 |
cell_flags = update_default; |
| 178 |
boundary_flags = update_default; |
| 179 |
face_flags = update_default; |
| 180 |
neighbor_flags = update_default; |
| 181 |
} |
| 182 |
|
| 183 |
|
| 184 |
template <int dim, int sdim> |
| 185 |
void |
| 186 |
IntegrationInfoBox<dim, sdim>::initialize_update_flags(bool neighbor_geometry) |
| 187 |
{ |
| 188 |
cell_flags |= update_JxW_values; |
| 189 |
boundary_flags |= UpdateFlags(update_JxW_values | update_normal_vectors); |
| 190 |
face_flags |= boundary_flags; |
| 191 |
neighbor_flags |= neighbor_geometry ? boundary_flags : update_default; |
| 192 |
|
| 193 |
if (cell_selector.has_values()) |
| 194 |
cell_flags |= update_values; |
| 195 |
if (cell_selector.has_gradients()) |
| 196 |
cell_flags |= update_gradients; |
| 197 |
if (cell_selector.has_hessians()) |
| 198 |
cell_flags |= update_hessians; |
| 199 |
|
| 200 |
if (boundary_selector.has_values()) |
| 201 |
boundary_flags |= update_values; |
| 202 |
if (boundary_selector.has_gradients()) |
| 203 |
boundary_flags |= update_gradients; |
| 204 |
if (boundary_selector.has_hessians()) |
| 205 |
boundary_flags |= update_hessians; |
| 206 |
|
| 207 |
if (face_selector.has_values()) |
| 208 |
face_flags |= update_values; |
| 209 |
if (face_selector.has_gradients()) |
| 210 |
face_flags |= update_gradients; |
| 211 |
if (face_selector.has_hessians()) |
| 212 |
face_flags |= update_hessians; |
| 213 |
|
| 214 |
if (face_selector.has_values()) |
| 215 |
neighbor_flags |= update_values; |
| 216 |
if (face_selector.has_gradients()) |
| 217 |
neighbor_flags |= update_gradients; |
| 218 |
if (face_selector.has_hessians()) |
| 219 |
neighbor_flags |= update_hessians; |
| 220 |
} |
| 221 |
|
| 222 |
|
| 223 |
template <int dim, int sdim> |
| 224 |
void |
| 225 |
IntegrationInfoBox<dim, sdim>::add_update_flags(const UpdateFlags flags, |
| 226 |
bool cell, |
| 227 |
bool boundary, |
| 228 |
bool face, |
| 229 |
bool neighbor) |
| 230 |
{ |
| 231 |
if (cell) |
| 232 |
cell_flags |= flags; |
| 233 |
if (boundary) |
| 234 |
boundary_flags |= flags; |
| 235 |
if (face) |
| 236 |
face_flags |= flags; |
| 237 |
if (neighbor) |
| 238 |
neighbor_flags |= flags; |
| 239 |
} |
| 240 |
|
| 241 |
|
| 242 |
template <int dim, int sdim> |
| 243 |
std::size_t |
| 244 |
IntegrationInfoBox<dim, sdim>::memory_consumption() const |
| 245 |
{ |
| 246 |
std::size_t mem = |
| 247 |
sizeof(*this) + MemoryConsumption::memory_consumption(cell_quadrature) - |
| 248 |
sizeof(cell_quadrature) + |
| 249 |
MemoryConsumption::memory_consumption(boundary_quadrature) - |
| 250 |
sizeof(boundary_quadrature) + |
| 251 |
MemoryConsumption::memory_consumption(face_quadrature) - |
| 252 |
sizeof(face_quadrature) + |
| 253 |
MemoryConsumption::memory_consumption(cell_selector) - |
| 254 |
sizeof(cell_selector) + |
| 255 |
MemoryConsumption::memory_consumption(boundary_selector) - |
| 256 |
sizeof(boundary_selector) + |
| 257 |
MemoryConsumption::memory_consumption(face_selector) - |
| 258 |
sizeof(face_selector) + MemoryConsumption::memory_consumption(cell) - |
| 259 |
sizeof(cell) + MemoryConsumption::memory_consumption(boundary) - |
| 260 |
sizeof(boundary) + MemoryConsumption::memory_consumption(face) - |
| 261 |
sizeof(face) + MemoryConsumption::memory_consumption(subface) - |
| 262 |
sizeof(subface) + MemoryConsumption::memory_consumption(neighbor) - |
| 263 |
sizeof(neighbor); |
| 264 |
// if (cell_data != 0) |
| 265 |
// mem += MemoryConsumption::memory_consumption(*cell_data); |
| 266 |
// if (boundary_data != 0) |
| 267 |
// mem += MemoryConsumption::memory_consumption(*boundary_data); |
| 268 |
// if (face_data != 0) |
| 269 |
// mem += MemoryConsumption::memory_consumption(*face_data); |
| 270 |
|
| 271 |
return mem; |
| 272 |
} |
| 273 |
} // namespace MeshWorker |
| 274 |
|
| 275 |
|
| 276 |
DEAL_II_NAMESPACE_CLOSE |
| 277 |
|
| 278 |
#endif |