| 1 |
// ------------------------------------------------------------------------ |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 4 |
// Copyright (C) 2021 - 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 |
|
| 16 |
#ifndef dealii_matrix_free_fe_evaluation_data_h |
| 17 |
#define dealii_matrix_free_fe_evaluation_data_h |
| 18 |
|
| 19 |
|
| 20 |
#include <deal.II/base/config.h> |
| 21 |
|
| 22 |
#include <deal.II/base/array_view.h> |
| 23 |
#include <deal.II/base/exceptions.h> |
| 24 |
#include <deal.II/base/geometry_info.h> |
| 25 |
#include <deal.II/base/observer_pointer.h> |
| 26 |
#include <deal.II/base/signaling_nan.h> |
| 27 |
#include <deal.II/base/std_cxx20/iota_view.h> |
| 28 |
#include <deal.II/base/symmetric_tensor.h> |
| 29 |
#include <deal.II/base/template_constraints.h> |
| 30 |
#include <deal.II/base/tensor.h> |
| 31 |
#include <deal.II/base/vectorization.h> |
| 32 |
|
| 33 |
#include <deal.II/grid/reference_cell.h> |
| 34 |
|
| 35 |
#include <deal.II/matrix_free/dof_info.h> |
| 36 |
#include <deal.II/matrix_free/mapping_info_storage.h> |
| 37 |
#include <deal.II/matrix_free/shape_info.h> |
| 38 |
|
| 39 |
|
| 40 |
DEAL_II_NAMESPACE_OPEN |
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
namespace internal |
| 45 |
{ |
| 46 |
DeclException0(ExcAccessToUninitializedField); |
| 47 |
|
| 48 |
DeclException1( |
| 49 |
ExcMatrixFreeAccessToUninitializedMappingField, |
| 50 |
std::string, |
| 51 |
<< "You are requesting information from an FEEvaluation/FEFaceEvaluation " |
| 52 |
<< "object for which this kind of information has not been computed. What " |
| 53 |
<< "information these objects compute is determined by the update_* flags " |
| 54 |
<< "you pass to MatrixFree::reinit() via MatrixFree::AdditionalData. " |
| 55 |
<< "Here, the operation you are attempting requires the <" << arg1 |
| 56 |
<< "> flag to be set, but it was apparently not specified " |
| 57 |
<< "upon initialization."); |
| 58 |
} // namespace internal |
| 59 |
|
| 60 |
// forward declarations |
| 61 |
template <int dim, |
| 62 |
int fe_degree, |
| 63 |
int n_q_points_1d = fe_degree + 1, |
| 64 |
int n_components_ = 1, |
| 65 |
typename Number = double, |
| 66 |
typename VectorizedArrayType = VectorizedArray<Number>> |
| 67 |
class FEEvaluation; |
| 68 |
|
| 69 |
template <int dim, |
| 70 |
int n_components_, |
| 71 |
typename Number, |
| 72 |
bool = false, |
| 73 |
typename = VectorizedArray<Number>> |
| 74 |
class FEEvaluationBase; |
| 75 |
|
| 76 |
namespace internal |
| 77 |
{ |
| 78 |
namespace MatrixFreeFunctions |
| 79 |
{ |
| 80 |
template <int, typename> |
| 81 |
class MappingDataOnTheFly; |
| 82 |
} |
| 83 |
} // namespace internal |
| 84 |
|
| 85 |
|
| 86 |
/** |
| 87 |
* This base class of the FEEvaluation and FEFaceEvaluation classes handles |
| 88 |
* mapping-related information independent of the degrees of freedom and |
| 89 |
* finite element in use. This class provides access functionality for user |
| 90 |
* code. The main usage is through the class FEEvaluation. However, there is |
| 91 |
* functionality to construct an object of type FEEvaluationData given |
| 92 |
* suitable data pointers to internal data, which allows usage in some |
| 93 |
* scenarios where no full MatrixFree object is available. |
| 94 |
* |
| 95 |
* This class has four template arguments: |
| 96 |
* |
| 97 |
* @tparam dim Dimension in which this class is to be used |
| 98 |
* |
| 99 |
* @tparam Number Number format, usually @p double or @p float |
| 100 |
* |
| 101 |
* @tparam is_face Whether the class is used for a cell integrator (with |
| 102 |
* quadrature dimension the same as the space dimension) or for a face |
| 103 |
* integrator (with quadrature dimension one less) |
| 104 |
* |
| 105 |
* @tparam VectorizedArrayType Type of array to be worked on in a vectorized |
| 106 |
* fashion, defaults to VectorizedArray<Number> |
| 107 |
* |
| 108 |
* @note Currently only VectorizedArray<Number, width> is supported as |
| 109 |
* VectorizedArrayType. |
| 110 |
* |
| 111 |
* |
| 112 |
* @ingroup matrixfree |
| 113 |
*/ |
| 114 |
template <int dim, typename Number, bool is_face> |
| 115 |
class FEEvaluationData |
| 116 |
{ |
| 117 |
using ShapeInfoType = internal::MatrixFreeFunctions::ShapeInfo< |
| 118 |
typename internal::VectorizedArrayTrait<Number>::value_type>; |
| 119 |
using MappingInfoStorageType = internal::MatrixFreeFunctions:: |
| 120 |
MappingInfoStorage<(is_face ? dim - 1 : dim), dim, Number>; |
| 121 |
using DoFInfo = internal::MatrixFreeFunctions::DoFInfo; |
| 122 |
|
| 123 |
public: |
| 124 |
static constexpr unsigned int dimension = dim; |
| 125 |
|
| 126 |
using NumberType = Number; |
| 127 |
using ScalarNumber = |
| 128 |
typename internal::VectorizedArrayTrait<Number>::value_type; |
| 129 |
using shape_info_number_type = ScalarNumber; |
| 130 |
|
| 131 |
static constexpr unsigned int n_lanes = |
| 132 |
internal::VectorizedArrayTrait<Number>::width(); |
| 133 |
|
| 134 |
/** |
| 135 |
* Constructor, taking a single ShapeInfo object to inject the capability |
| 136 |
* for evaluation and set up some data containers, compatible with the |
| 137 |
* internal evaluation kernels of FEEvaluationImpl and friends. For actual |
| 138 |
* use, select one of the derived classes FEEvaluation or FEFaceEvaluation |
| 139 |
* with their respective arguments. |
| 140 |
*/ |
| 141 |
FEEvaluationData(const ShapeInfoType &shape_info, |
| 142 |
const bool is_interior_face = true); |
| 143 |
|
| 144 |
/** |
| 145 |
* Copy constructor. |
| 146 |
*/ |
| 147 |
FEEvaluationData(const FEEvaluationData &other) = default; |
| 148 |
|
| 149 |
/** |
| 150 |
* Copy assignment operator. |
| 151 |
*/ |
| 152 |
FEEvaluationData & |
| 153 |
operator=(const FEEvaluationData &other); |
| 154 |
|
| 155 |
/** |
| 156 |
* Destructor. |
| 157 |
*/ |
| 158 |
virtual ~FEEvaluationData() = default; |
| 159 |
|
| 160 |
/** |
| 161 |
* Sets the pointers for values, gradients, hessians to the central |
| 162 |
* scratch_data_array inside the given scratch array, for a given number of |
| 163 |
* components as provided by one of the derived classes. |
| 164 |
*/ |
| 165 |
void |
| 166 |
set_data_pointers(AlignedVector<Number> *scratch_data, |
| 167 |
const unsigned int n_components); |
| 168 |
|
| 169 |
/** |
| 170 |
* Initialize the indices related to the given face description. Used during |
| 171 |
* the reinit() call of the FEFaceEvaluation class. |
| 172 |
*/ |
| 173 |
void |
| 174 |
reinit_face( |
| 175 |
const internal::MatrixFreeFunctions::FaceToCellTopology<n_lanes> &face); |
| 176 |
|
| 177 |
/** |
| 178 |
* @name Access to geometry data at quadrature points |
| 179 |
*/ |
| 180 |
/** @{ */ |
| 181 |
|
| 182 |
/** |
| 183 |
* Return an ArrayView to internal memory for temporary use. Note that some |
| 184 |
* of this memory is overwritten during evaluate() and integrate() calls so |
| 185 |
* do not assume it to be stable over those calls. The maximum size you can |
| 186 |
* write into is 3*dofs_per_cell+2*n_q_points. |
| 187 |
*/ |
| 188 |
ArrayView<Number> |
| 189 |
get_scratch_data() const; |
| 190 |
|
| 191 |
/** |
| 192 |
* Return the determinant of the Jacobian from the unit to the real cell |
| 193 |
* times the quadrature weight. |
| 194 |
*/ |
| 195 |
Number |
| 196 |
JxW(const unsigned int q_point) const; |
| 197 |
|
| 198 |
/** |
| 199 |
* Returns the q-th quadrature point on the face in real coordinates stored |
| 200 |
* in MappingInfo. |
| 201 |
*/ |
| 202 |
Point<dim, Number> |
| 203 |
quadrature_point(const unsigned int q) const; |
| 204 |
|
| 205 |
/** |
| 206 |
* Return the inverse and transposed version $J^{-\mathrm T}$ of the |
| 207 |
* Jacobian of the mapping between the unit to the real cell defined as |
| 208 |
* $J_{ij} = d x_i / d\hat x_j$. The $(i,j)$ entry of the returned tensor |
| 209 |
* contains $d\hat x_j/dx_i$, i.e., columns refer to reference space |
| 210 |
* coordinates and rows to real cell coordinates. Thus, the returned tensor |
| 211 |
* represents a covariant transformation, which is used in the |
| 212 |
* FEEvaluationBase::get_gradient() function to transform the unit cell |
| 213 |
* gradients to gradients on the real cell by a multiplication $J^{-\mathrm |
| 214 |
* T} \hat{\nabla} u_h$. |
| 215 |
*/ |
| 216 |
Tensor<2, dim, Number> |
| 217 |
inverse_jacobian(const unsigned int q_point) const; |
| 218 |
|
| 219 |
/** |
| 220 |
* Return the unit normal vector on a face. Note that both sides of a face |
| 221 |
* use the same orientation of the normal vector: For the faces enumerated |
| 222 |
* as `interior` in FaceToCellTopology and selected with the |
| 223 |
* `is_interior_face=true` flag of the constructor, this corresponds to the |
| 224 |
* outer normal vector, whereas for faces enumerated as `exterior` in |
| 225 |
* FaceToCellTopology and selected with the `is_interior_face=false` flag of |
| 226 |
* the constructor, the normal points into the element as a consequence of |
| 227 |
* the single normal vector. |
| 228 |
* |
| 229 |
* @note Only implemented in case `is_face == true`. |
| 230 |
*/ |
| 231 |
Tensor<1, dim, Number> |
| 232 |
normal_vector(const unsigned int q_point) const; |
| 233 |
|
| 234 |
/** |
| 235 |
* Same as `normal_vector(const unsigned int q_point)`. |
| 236 |
* |
| 237 |
* @deprecated Use normal_vector() instead. |
| 238 |
*/ |
| 239 |
DEAL_II_DEPRECATED_WITH_COMMENT("Use normal_vector() instead.") |
| 240 |
Tensor<1, dim, Number> |
| 241 |
get_normal_vector(const unsigned int q_point) const; |
| 242 |
|
| 243 |
/** @} */ |
| 244 |
|
| 245 |
/** |
| 246 |
* @name Access to internal data arrays |
| 247 |
*/ |
| 248 |
/** @{ */ |
| 249 |
/** |
| 250 |
* Return a read-only pointer to the first field of the dof values. This is |
| 251 |
* the data field the read_dof_values() functions write into. First come the |
| 252 |
* dof values for the first component, then all values for the second |
| 253 |
* component, and so on. This is related to the internal data structures |
| 254 |
* used in this class. In general, it is safer to use the get_dof_value() |
| 255 |
* function instead. |
| 256 |
*/ |
| 257 |
const Number * |
| 258 |
begin_dof_values() const; |
| 259 |
|
| 260 |
/** |
| 261 |
* Return a read and write pointer to the first field of the dof values. |
| 262 |
* This is the data field the read_dof_values() functions write into. First |
| 263 |
* come the dof values for the first component, then all values for the |
| 264 |
* second component, and so on. This is related to the internal data |
| 265 |
* structures used in this class. In general, it is safer to use the |
| 266 |
* get_dof_value() function instead. |
| 267 |
*/ |
| 268 |
Number * |
| 269 |
begin_dof_values(); |
| 270 |
|
| 271 |
/** |
| 272 |
* Return a read-only pointer to the first field of function values on |
| 273 |
* quadrature points. First come the function values on all quadrature |
| 274 |
* points for the first component, then all values for the second component, |
| 275 |
* and so on. This is related to the internal data structures used in this |
| 276 |
* class. The raw data after a call to @p evaluate only contains unit cell |
| 277 |
* operations, so possible transformations, quadrature weights etc. must be |
| 278 |
* applied manually. In general, it is safer to use the get_value() function |
| 279 |
* instead, which does all the transformation internally. |
| 280 |
*/ |
| 281 |
const Number * |
| 282 |
begin_values() const; |
| 283 |
|
| 284 |
/** |
| 285 |
* Return a read and write pointer to the first field of function values on |
| 286 |
* quadrature points. First come the function values on all quadrature |
| 287 |
* points for the first component, then all values for the second component, |
| 288 |
* and so on. This is related to the internal data structures used in this |
| 289 |
* class. The raw data after a call to @p evaluate only contains unit cell |
| 290 |
* operations, so possible transformations, quadrature weights etc. must be |
| 291 |
* applied manually. In general, it is safer to use the get_value() function |
| 292 |
* instead, which does all the transformation internally. |
| 293 |
*/ |
| 294 |
Number * |
| 295 |
begin_values(); |
| 296 |
|
| 297 |
/** |
| 298 |
* Return a read-only pointer to the first field of function gradients on |
| 299 |
* quadrature points. First comes the x-component of the gradient for the |
| 300 |
* first component on all quadrature points, then the y-component, and so |
| 301 |
* on. Next comes the x-component of the second component, and so on. This |
| 302 |
* is related to the internal data structures used in this class. The raw |
| 303 |
* data after a call to @p evaluate only contains unit cell operations, so |
| 304 |
* possible transformations, quadrature weights etc. must be applied |
| 305 |
* manually. In general, it is safer to use the get_gradient() function |
| 306 |
* instead, which does all the transformation internally. |
| 307 |
*/ |
| 308 |
const Number * |
| 309 |
begin_gradients() const; |
| 310 |
|
| 311 |
/** |
| 312 |
* Return a read and write pointer to the first field of function gradients |
| 313 |
* on quadrature points. First comes the x-component of the gradient for the |
| 314 |
* first component on all quadrature points, then the y-component, and so |
| 315 |
* on. Next comes the x-component of the second component, and so on. This |
| 316 |
* is related to the internal data structures used in this class. The raw |
| 317 |
* data after a call to @p evaluate only contains unit cell operations, so |
| 318 |
* possible transformations, quadrature weights etc. must be applied |
| 319 |
* manually. In general, it is safer to use the get_gradient() function |
| 320 |
* instead, which does all the transformation internally. |
| 321 |
*/ |
| 322 |
Number * |
| 323 |
begin_gradients(); |
| 324 |
|
| 325 |
/** |
| 326 |
* Return a read-only pointer to the first field of function hessians on |
| 327 |
* quadrature points. First comes the xx-component of the hessian for the |
| 328 |
* first component on all quadrature points, then the yy-component, |
| 329 |
* zz-component in (3d), then the xy-component, and so on. Next comes the |
| 330 |
* xx-component of the second component, and so on. This is related to the |
| 331 |
* internal data structures used in this class. The raw data after a call to |
| 332 |
* @p evaluate only contains unit cell operations, so possible |
| 333 |
* transformations, quadrature weights etc. must be applied manually. In |
| 334 |
* general, it is safer to use the get_laplacian() or get_hessian() |
| 335 |
* functions instead, which does all the transformation internally. |
| 336 |
*/ |
| 337 |
const Number * |
| 338 |
begin_hessians() const; |
| 339 |
|
| 340 |
/** |
| 341 |
* Return a read and write pointer to the first field of function hessians |
| 342 |
* on quadrature points. First comes the xx-component of the hessian for the |
| 343 |
* first component on all quadrature points, then the yy-component, |
| 344 |
* zz-component in (3d), then the xy-component, and so on. Next comes the |
| 345 |
* xx-component of the second component, and so on. This is related to the |
| 346 |
* internal data structures used in this class. The raw data after a call to |
| 347 |
* @p evaluate only contains unit cell operations, so possible |
| 348 |
* transformations, quadrature weights etc. must be applied manually. In |
| 349 |
* general, it is safer to use the get_laplacian() or get_hessian() |
| 350 |
* functions instead, which does all the transformation internally. |
| 351 |
*/ |
| 352 |
Number * |
| 353 |
begin_hessians(); |
| 354 |
|
| 355 |
/** @} */ |
| 356 |
|
| 357 |
/** |
| 358 |
* @name Information about the current cell this class operates on |
| 359 |
*/ |
| 360 |
/** @{ */ |
| 361 |
|
| 362 |
/** |
| 363 |
* Return the index offset within the geometry fields for the cell the @p |
| 364 |
* reinit() function has been called for. This index can be used to access |
| 365 |
* an index into a field that has the same compression behavior as the |
| 366 |
* Jacobian of the geometry, e.g., to store an effective coefficient tensors |
| 367 |
* that combines a coefficient with the geometry for lower memory transfer |
| 368 |
* as the available data fields. |
| 369 |
*/ |
| 370 |
unsigned int |
| 371 |
get_mapping_data_index_offset() const; |
| 372 |
|
| 373 |
/** |
| 374 |
* Return the type of the cell the @p reinit() function has been called for. |
| 375 |
* Valid values are @p cartesian for Cartesian cells (which allows for |
| 376 |
* considerable data compression), @p affine for cells with affine mappings, |
| 377 |
* and @p general for general cells without any compressed storage applied. |
| 378 |
*/ |
| 379 |
internal::MatrixFreeFunctions::GeometryType |
| 380 |
get_cell_type() const; |
| 381 |
|
| 382 |
/** |
| 383 |
* Return a reference to the ShapeInfo object currently in use. |
| 384 |
*/ |
| 385 |
const ShapeInfoType & |
| 386 |
get_shape_info() const; |
| 387 |
|
| 388 |
/** |
| 389 |
* Return a reference to the DoFInfo object currently in use. |
| 390 |
*/ |
| 391 |
const internal::MatrixFreeFunctions::DoFInfo & |
| 392 |
get_dof_info() const; |
| 393 |
|
| 394 |
/** |
| 395 |
* Return the numbering of local degrees of freedom within the evaluation |
| 396 |
* routines of FEEvaluation in terms of the standard numbering on finite |
| 397 |
* elements. |
| 398 |
*/ |
| 399 |
const std::vector<unsigned int> & |
| 400 |
get_internal_dof_numbering() const; |
| 401 |
|
| 402 |
/** |
| 403 |
* Return the number of the quadrature formula of the present cell. |
| 404 |
*/ |
| 405 |
unsigned int |
| 406 |
get_quadrature_index() const; |
| 407 |
|
| 408 |
/** |
| 409 |
* Return index of the current cell or face. |
| 410 |
*/ |
| 411 |
unsigned int |
| 412 |
get_current_cell_index() const; |
| 413 |
|
| 414 |
/** |
| 415 |
* Return the active FE index for this class for efficient indexing in the |
| 416 |
* hp-case. |
| 417 |
*/ |
| 418 |
unsigned int |
| 419 |
get_active_fe_index() const; |
| 420 |
|
| 421 |
/** |
| 422 |
* Return the active quadrature index for this class for efficient indexing in |
| 423 |
* the hp-case. |
| 424 |
*/ |
| 425 |
unsigned int |
| 426 |
get_active_quadrature_index() const; |
| 427 |
|
| 428 |
/** |
| 429 |
* Return the first selected component in a multi-component system. |
| 430 |
*/ |
| 431 |
unsigned int |
| 432 |
get_first_selected_component() const; |
| 433 |
|
| 434 |
/** |
| 435 |
* If is_face is true, this function returns the face number of the given lane |
| 436 |
* within a cell for the face this object was initialized to. On cells where |
| 437 |
* the face makes no sense, an exception is thrown. |
| 438 |
* |
| 439 |
* @note Only available for `dof_access_index == dof_access_cell` and |
| 440 |
* `is_interior_face == false`. |
| 441 |
* |
| 442 |
* @note This function depends on the internal representation of data, which |
| 443 |
* is not stable between releases of deal.II, and is hence mostly for |
| 444 |
* internal use. |
| 445 |
*/ |
| 446 |
std::uint8_t |
| 447 |
get_face_no(const unsigned int v = 0) const; |
| 448 |
|
| 449 |
/** |
| 450 |
* If is_face is true, this function returns the index of a subface along a |
| 451 |
* face in case this object was initialized to a face with hanging nodes. On |
| 452 |
* faces On cells where the face makes no sense, an exception is thrown. |
| 453 |
* |
| 454 |
* @note This function depends on the internal representation of data, which |
| 455 |
* is not stable between releases of deal.II, and is hence mostly for |
| 456 |
* internal use. |
| 457 |
*/ |
| 458 |
unsigned int |
| 459 |
get_subface_index() const; |
| 460 |
|
| 461 |
/** |
| 462 |
* If is_face is true, this function returns for a given lane the |
| 463 |
* orientation index within an array of orientations as stored in |
| 464 |
* ShapeInfo for unknowns and quadrature points. |
| 465 |
* |
| 466 |
* @note Only available for `dof_access_index == dof_access_cell` and |
| 467 |
* `is_interior_face == false`. |
| 468 |
*/ |
| 469 |
std::uint8_t |
| 470 |
get_face_orientation(const unsigned int v = 0) const; |
| 471 |
|
| 472 |
/** |
| 473 |
* Return the current index in the access to compressed indices. |
| 474 |
* |
| 475 |
* @note This function depends on the internal representation of data, which |
| 476 |
* is not stable between releases of deal.II, and is hence mostly for |
| 477 |
* internal use. |
| 478 |
*/ |
| 479 |
internal::MatrixFreeFunctions::DoFInfo::DoFAccessIndex |
| 480 |
get_dof_access_index() const; |
| 481 |
|
| 482 |
/** |
| 483 |
* Return whether this object was set up to work on what is called |
| 484 |
* "interior" faces in the evaluation context. |
| 485 |
* |
| 486 |
* @note This function depends on the internal representation of data, which |
| 487 |
* is not stable between releases of deal.II, and is hence mostly for |
| 488 |
* internal use. |
| 489 |
*/ |
| 490 |
bool |
| 491 |
is_interior_face() const; |
| 492 |
|
| 493 |
/** |
| 494 |
* Return the id of the cells this FEEvaluation or FEFaceEvaluation is |
| 495 |
* associated with. |
| 496 |
*/ |
| 497 |
const std::array<unsigned int, n_lanes> & |
| 498 |
get_cell_ids() const |
| 499 |
{ |
| 500 |
// implemented inline to avoid compilation problems on Windows |
| 501 |
if constexpr (running_in_debug_mode()) |
| 502 |
{ |
| 503 |
Assert(is_reinitialized, ExcNotInitialized()); |
| 504 |
} |
| 505 |
return cell_ids; |
| 506 |
} |
| 507 |
|
| 508 |
/** |
| 509 |
* Return the id of the faces this FEFaceEvaluation is |
| 510 |
* associated with. |
| 511 |
*/ |
| 512 |
const std::array<unsigned int, n_lanes> & |
| 513 |
get_face_ids() const |
| 514 |
{ |
| 515 |
// implemented inline to avoid compilation problems on Windows |
| 516 |
if constexpr (running_in_debug_mode()) |
| 517 |
{ |
| 518 |
Assert(is_reinitialized && is_face, ExcNotInitialized()); |
| 519 |
} |
| 520 |
return face_ids; |
| 521 |
} |
| 522 |
|
| 523 |
/** |
| 524 |
* Return the id of the cell/face batch this FEEvaluation/FEFaceEvaluation is |
| 525 |
* associated with. |
| 526 |
*/ |
| 527 |
unsigned int |
| 528 |
get_cell_or_face_batch_id() const |
| 529 |
{ |
| 530 |
// implemented inline to avoid compilation problems on Windows |
| 531 |
if constexpr (running_in_debug_mode()) |
| 532 |
{ |
| 533 |
Assert(is_reinitialized, ExcNotInitialized()); |
| 534 |
} |
| 535 |
|
| 536 |
return cell; |
| 537 |
} |
| 538 |
|
| 539 |
/** |
| 540 |
* Return the id of the cells/faces this FEEvaluation/FEFaceEvaluation is |
| 541 |
* associated with. |
| 542 |
*/ |
| 543 |
const std::array<unsigned int, n_lanes> & |
| 544 |
get_cell_or_face_ids() const |
| 545 |
{ |
| 546 |
// implemented inline to avoid compilation problems on Windows |
| 547 |
if constexpr (running_in_debug_mode()) |
| 548 |
{ |
| 549 |
Assert(is_reinitialized, ExcNotInitialized()); |
| 550 |
} |
| 551 |
|
| 552 |
if (!is_face || dof_access_index == |
| 553 |
internal::MatrixFreeFunctions::DoFInfo::dof_access_cell) |
| 554 |
return cell_ids; |
| 555 |
else |
| 556 |
return face_ids; |
| 557 |
} |
| 558 |
|
| 559 |
/** |
| 560 |
* Return an object that can be thought of as an array containing all indices |
| 561 |
* from zero to @p n_quadrature_points. This allows to write code using |
| 562 |
* range-based for loops. |
| 563 |
*/ |
| 564 |
std_cxx20::ranges::iota_view<unsigned int, unsigned int> |
| 565 |
quadrature_point_indices() const; |
| 566 |
|
| 567 |
/** @} */ |
| 568 |
|
| 569 |
/** |
| 570 |
* @name Functions to access cell- and face-data vectors. |
| 571 |
*/ |
| 572 |
/** @{ */ |
| 573 |
|
| 574 |
/** |
| 575 |
* Provides a unified interface to access data in a vector of |
| 576 |
* VectorizedArray fields of length MatrixFree::n_cell_batches() + |
| 577 |
* MatrixFree::n_ghost_cell_batches() for cell data. It is implemented |
| 578 |
* both for cells and faces (access data to the associated cell). |
| 579 |
* |
| 580 |
* The underlying type can be both the Number type as given by the class |
| 581 |
* template (i.e., VectorizedArrayType) as well as std::array with as many |
| 582 |
* entries as n_lanes. |
| 583 |
*/ |
| 584 |
template <typename T> |
| 585 |
T |
| 586 |
read_cell_data(const AlignedVector<T> &array) const; |
| 587 |
|
| 588 |
/** |
| 589 |
* Provides a unified interface to set data in a vector of |
| 590 |
* VectorizedArray fields of length MatrixFree::n_cell_batches() + |
| 591 |
* MatrixFree::n_ghost_cell_batches() for cell data. It is implemented |
| 592 |
* both for cells and faces (access data to the associated cell). |
| 593 |
*/ |
| 594 |
template <typename T> |
| 595 |
void |
| 596 |
set_cell_data(AlignedVector<T> &array, const T &value) const; |
| 597 |
|
| 598 |
/** |
| 599 |
* Provides a unified interface to access data in a vector of |
| 600 |
* VectorizedArray fields of length MatrixFree::n_inner_face_batches() + |
| 601 |
* MatrixFree::n_boundary_face_batches() + |
| 602 |
* MatrixFree::n_ghost_inner_face_batches() for face data. |
| 603 |
* |
| 604 |
* @note Only implemented for faces. |
| 605 |
*/ |
| 606 |
template <typename T> |
| 607 |
T |
| 608 |
read_face_data(const AlignedVector<T> &array) const; |
| 609 |
|
| 610 |
/** |
| 611 |
* Provides a unified interface to set data in a vector of |
| 612 |
* VectorizedArray fields of length MatrixFree::n_inner_face_batches() + |
| 613 |
* MatrixFree::n_boundary_face_batches() + |
| 614 |
* MatrixFree::n_ghost_inner_face_batches() for face data. |
| 615 |
* |
| 616 |
* @note Only implemented for faces. |
| 617 |
*/ |
| 618 |
template <typename T> |
| 619 |
void |
| 620 |
set_face_data(AlignedVector<T> &array, const T &value) const; |
| 621 |
|
| 622 |
/** @} */ |
| 623 |
|
| 624 |
/** |
| 625 |
* This data structure is used for the initialization by the derived |
| 626 |
* FEEvaluation classes. |
| 627 |
*/ |
| 628 |
struct InitializationData |
| 629 |
{ |
| 630 |
const ShapeInfoType *shape_info; |
| 631 |
const DoFInfo *dof_info; |
| 632 |
const MappingInfoStorageType *mapping_data; |
| 633 |
unsigned int active_fe_index; |
| 634 |
unsigned int active_quad_index; |
| 635 |
const typename MappingInfoStorageType::QuadratureDescriptor *descriptor; |
| 636 |
}; |
| 637 |
|
| 638 |
protected: |
| 639 |
/** |
| 640 |
* Constructor filling information available from a MatrixFree class, |
| 641 |
* collected in an internal data structure to reduce overhead of |
| 642 |
* initialization. Used in derived classes when this class is initialized |
| 643 |
* from a MatrixFree object. |
| 644 |
*/ |
| 645 |
FEEvaluationData(const InitializationData &initialization_data, |
| 646 |
const bool is_interior_face, |
| 647 |
const unsigned int quad_no, |
| 648 |
const unsigned int first_selected_component); |
| 649 |
|
| 650 |
/** |
| 651 |
* Constructor that comes with reduced functionality and works similarly as |
| 652 |
* FEValues. |
| 653 |
*/ |
| 654 |
FEEvaluationData( |
| 655 |
const std::shared_ptr< |
| 656 |
internal::MatrixFreeFunctions::MappingDataOnTheFly<dim, Number>> |
| 657 |
&mapping_data, |
| 658 |
const unsigned int n_fe_components, |
| 659 |
const unsigned int first_selected_component); |
| 660 |
|
| 661 |
/** |
| 662 |
* A pointer to the unit cell shape data, i.e., values, gradients and |
| 663 |
* Hessians in 1d at the quadrature points that constitute the tensor |
| 664 |
* product. Also contained in matrix_info, but it simplifies code if we |
| 665 |
* store a reference to it. |
| 666 |
*/ |
| 667 |
const ShapeInfoType *data; |
| 668 |
|
| 669 |
/** |
| 670 |
* A pointer to the underlying DoF indices and constraint description |
| 671 |
* for the component specified at construction. Also contained in |
| 672 |
* matrix_info, but it simplifies code if we store a reference to it. |
| 673 |
*/ |
| 674 |
const DoFInfo *dof_info; |
| 675 |
|
| 676 |
/** |
| 677 |
* A pointer to the underlying transformation data from unit to real cells |
| 678 |
* for the given quadrature formula specified at construction. Also |
| 679 |
* contained in matrix_info, but it simplifies code if we store a reference |
| 680 |
* to it. |
| 681 |
*/ |
| 682 |
const MappingInfoStorageType *mapping_data; |
| 683 |
|
| 684 |
/** |
| 685 |
* The number of the quadrature formula of the present cell among all |
| 686 |
* quadrature formulas available in the MatrixFree objects pass to derived |
| 687 |
* classes. |
| 688 |
*/ |
| 689 |
const unsigned int quad_no; |
| 690 |
|
| 691 |
/** |
| 692 |
* Stores the number of components in the finite element as detected in the |
| 693 |
* MatrixFree storage class for comparison with the template argument. |
| 694 |
*/ |
| 695 |
const unsigned int n_fe_components; |
| 696 |
|
| 697 |
/** |
| 698 |
* For a FiniteElement with more than one base element, select at which |
| 699 |
* component this data structure should start. |
| 700 |
*/ |
| 701 |
const unsigned int first_selected_component; |
| 702 |
|
| 703 |
/** |
| 704 |
* The active FE index for this class for efficient indexing in the hp-case. |
| 705 |
*/ |
| 706 |
const unsigned int active_fe_index; |
| 707 |
|
| 708 |
/** |
| 709 |
* The active quadrature index for this class for efficient indexing in the |
| 710 |
* hp-case. |
| 711 |
*/ |
| 712 |
const unsigned int active_quad_index; |
| 713 |
|
| 714 |
/** |
| 715 |
* A pointer to the underlying quadrature formula specified at construction. |
| 716 |
* Also contained in mapping_data, but it simplifies code if we store a |
| 717 |
* reference to it. |
| 718 |
*/ |
| 719 |
const typename MappingInfoStorageType::QuadratureDescriptor *descriptor; |
| 720 |
|
| 721 |
/** |
| 722 |
* The number of quadrature points in the current evaluation context. |
| 723 |
*/ |
| 724 |
const unsigned int n_quadrature_points; |
| 725 |
|
| 726 |
/** |
| 727 |
* A pointer to the quadrature-point information of the present cell. |
| 728 |
* Only set to a useful value if on a non-Cartesian cell. |
| 729 |
*/ |
| 730 |
const Point<dim, Number> *quadrature_points; |
| 731 |
|
| 732 |
/** |
| 733 |
* A pointer to the inverse transpose Jacobian information of the present |
| 734 |
* cell. Only the first inverse transpose Jacobian (q_point = 0) is set for |
| 735 |
* Cartesian/affine cells, and the actual Jacobian is stored at index 1 |
| 736 |
* instead. For faces on hypercube elements, the derivatives are reorder s.t. |
| 737 |
* the derivative orthogonal to the face is stored last, i.e for dim = 3 and |
| 738 |
* face_no = 0 or 1, the derivatives are ordered as [dy, dz, dx], face_no = 2 |
| 739 |
* or 3: [dz, dx, dy], and face_no = 5 or 6: [dx, dy, dz]. If the Jacobian |
| 740 |
* also is stored, the components are instead reordered in the same way. |
| 741 |
* Filled from MappingInfoStorage.jacobians in |
| 742 |
* include/deal.II/matrix_free/mapping_info.templates.h |
| 743 |
*/ |
| 744 |
const Tensor<2, dim, Number> *jacobian; |
| 745 |
|
| 746 |
/** |
| 747 |
* A pointer to the gradients of the inverse Jacobian transformation of the |
| 748 |
* present cell. |
| 749 |
*/ |
| 750 |
const Tensor<1, dim *(dim + 1) / 2, Tensor<1, dim, Number>> |
| 751 |
*jacobian_gradients; |
| 752 |
|
| 753 |
/** |
| 754 |
* A pointer to the gradients of the Jacobian transformation of the |
| 755 |
* present cell. |
| 756 |
*/ |
| 757 |
const Tensor<1, dim *(dim + 1) / 2, Tensor<1, dim, Number>> |
| 758 |
*jacobian_gradients_non_inverse; |
| 759 |
|
| 760 |
/** |
| 761 |
* A pointer to the Jacobian determinant of the present cell. If on a |
| 762 |
* Cartesian cell or on a cell with constant Jacobian, this is just the |
| 763 |
* Jacobian determinant, otherwise the Jacobian determinant times the |
| 764 |
* quadrature weight. |
| 765 |
*/ |
| 766 |
const Number *J_value; |
| 767 |
|
| 768 |
/** |
| 769 |
* A pointer to the normal vectors at faces. |
| 770 |
*/ |
| 771 |
const Tensor<1, dim, Number> *normal_vectors; |
| 772 |
|
| 773 |
/** |
| 774 |
* A pointer to the normal vectors times the Jacobian at faces. |
| 775 |
*/ |
| 776 |
const Tensor<1, dim, Number> *normal_x_jacobian; |
| 777 |
|
| 778 |
/** |
| 779 |
* A pointer to the quadrature weights of the underlying quadrature formula. |
| 780 |
*/ |
| 781 |
const ScalarNumber *quadrature_weights; |
| 782 |
|
| 783 |
/** |
| 784 |
* This is the user-visible part of FEEvaluationBase::scratch_data_array, |
| 785 |
* only showing the part that can be consumed by various users. It is set |
| 786 |
* during the allocation of the internal data structures in |
| 787 |
* FEEvaluationBase. |
| 788 |
*/ |
| 789 |
mutable ArrayView<Number> scratch_data; |
| 790 |
|
| 791 |
/** |
| 792 |
* This field stores the values for local degrees of freedom (e.g. after |
| 793 |
* reading out from a vector but before applying unit cell transformations |
| 794 |
* or before distributing them into a result vector). The methods |
| 795 |
* get_dof_value() and submit_dof_value() read from or write to this field. |
| 796 |
* |
| 797 |
* The values of this array are stored in the start section of |
| 798 |
* @p scratch_data_array. Due to its access as a thread local memory, the |
| 799 |
* memory can get reused between different calls. |
| 800 |
*/ |
| 801 |
Number *values_dofs; |
| 802 |
|
| 803 |
/** |
| 804 |
* This field stores the values of the finite element function on quadrature |
| 805 |
* points after applying unit cell transformations or before integrating. |
| 806 |
* The methods get_value() and submit_value() access this field. |
| 807 |
* |
| 808 |
* The values of this array are stored in the start section of |
| 809 |
* @p scratch_data_array. Due to its access as a thread local memory, the |
| 810 |
* memory can get reused between different calls. |
| 811 |
*/ |
| 812 |
Number *values_quad; |
| 813 |
|
| 814 |
/** |
| 815 |
* This field stores the values of the finite element function on |
| 816 |
* quadrature points after applying unit cell transformations or before |
| 817 |
* integrating. This field is accessed when performing the contravariant |
| 818 |
* Piola transform for gradients on general cells. This is done by the |
| 819 |
* functions get_gradient() and submit_gradient() when using a H(div)- |
| 820 |
* conforming finite element such as FE_RaviartThomasNodal. |
| 821 |
* |
| 822 |
* The values of this array are stored in the start section of |
| 823 |
* @p scratch_data_array. Due to its access as a thread local memory, the |
| 824 |
* memory can get reused between different calls. |
| 825 |
*/ |
| 826 |
Number *values_from_gradients_quad; |
| 827 |
|
| 828 |
/** |
| 829 |
* This field stores the gradients of the finite element function on |
| 830 |
* quadrature points after applying unit cell transformations or before |
| 831 |
* integrating. The methods get_gradient() and submit_gradient() (as well as |
| 832 |
* some specializations like get_symmetric_gradient() or get_divergence()) |
| 833 |
* access this field. |
| 834 |
* |
| 835 |
* The values of this array are stored in the start section of |
| 836 |
* @p scratch_data_array. Due to its access as a thread local memory, the |
| 837 |
* memory can get reused between different calls. |
| 838 |
*/ |
| 839 |
Number *gradients_quad; |
| 840 |
|
| 841 |
/** |
| 842 |
* This field stores the gradients of the finite element function on |
| 843 |
* quadrature points after applying unit cell transformations or before |
| 844 |
* integrating. The methods get_hessian() and submit_hessian() (as well as |
| 845 |
* some specializations like get_hessian_diagonal() or get_laplacian()) |
| 846 |
* access this field for general cell/face types. |
| 847 |
* |
| 848 |
* The values of this array are stored in the start section of |
| 849 |
* @p scratch_data_array. Due to its access as a thread local memory, the |
| 850 |
* memory can get reused between different calls. |
| 851 |
*/ |
| 852 |
Number *gradients_from_hessians_quad; |
| 853 |
|
| 854 |
/** |
| 855 |
* This field stores the Hessians of the finite element function on |
| 856 |
* quadrature points after applying unit cell transformations. The methods |
| 857 |
* get_hessian(), get_laplacian(), get_hessian_diagonal() access this field. |
| 858 |
* |
| 859 |
* The values of this array are stored in the start section of |
| 860 |
* @p scratch_data_array. Due to its access as a thread local memory, the |
| 861 |
* memory can get reused between different calls. |
| 862 |
*/ |
| 863 |
Number *hessians_quad; |
| 864 |
|
| 865 |
/** |
| 866 |
* Debug information to track whether the reinit() function of derived classes |
| 867 |
* was called. |
| 868 |
*/ |
| 869 |
bool is_reinitialized; |
| 870 |
|
| 871 |
/** |
| 872 |
* Debug information to track whether dof values have been initialized |
| 873 |
* before accessed. Used to control exceptions when uninitialized data is |
| 874 |
* used. |
| 875 |
*/ |
| 876 |
bool dof_values_initialized; |
| 877 |
|
| 878 |
/** |
| 879 |
* Debug information to track whether values on quadrature points have been |
| 880 |
* initialized before accessed. Used to control exceptions when |
| 881 |
* uninitialized data is used. |
| 882 |
*/ |
| 883 |
bool values_quad_initialized; |
| 884 |
|
| 885 |
/** |
| 886 |
* Debug information to track whether gradients on quadrature points have |
| 887 |
* been initialized before accessed. Used to control exceptions when |
| 888 |
* uninitialized data is used. |
| 889 |
*/ |
| 890 |
bool gradients_quad_initialized; |
| 891 |
|
| 892 |
/** |
| 893 |
* Debug information to track whether Hessians on quadrature points have |
| 894 |
* been initialized before accessed. Used to control exceptions when |
| 895 |
* uninitialized data is used. |
| 896 |
*/ |
| 897 |
bool hessians_quad_initialized; |
| 898 |
|
| 899 |
/** |
| 900 |
* Debug information to track whether values on quadrature points have been |
| 901 |
* submitted for integration before the integration is actually stared. Used |
| 902 |
* to control exceptions when uninitialized data is used. |
| 903 |
*/ |
| 904 |
bool values_quad_submitted; |
| 905 |
|
| 906 |
/** |
| 907 |
* Debug information to track whether gradients on quadrature points have |
| 908 |
* been submitted for integration before the integration is actually stared. |
| 909 |
* Used to control exceptions when uninitialized data is used. |
| 910 |
*/ |
| 911 |
bool gradients_quad_submitted; |
| 912 |
|
| 913 |
/** |
| 914 |
* Debug information to track whether hessians on quadrature points have |
| 915 |
* been submitted for integration before the integration is actually stared. |
| 916 |
* Used to control exceptions when uninitialized data is used. |
| 917 |
*/ |
| 918 |
bool hessians_quad_submitted; |
| 919 |
|
| 920 |
/** |
| 921 |
* After a call to reinit(), stores the number of the cell we are currently |
| 922 |
* working with. |
| 923 |
*/ |
| 924 |
unsigned int cell; |
| 925 |
|
| 926 |
/** |
| 927 |
* Flag holding information whether a face is an interior or exterior face |
| 928 |
* according to the defined direction of the normal. For cells it defines if |
| 929 |
* the dof values should be read from the actual cell corresponding to the |
| 930 |
* interior face or the neighboring cell corresponding to the exterior face. |
| 931 |
*/ |
| 932 |
bool interior_face; |
| 933 |
|
| 934 |
/** |
| 935 |
* Stores the index an FEFaceEvaluation object is currently pointing into |
| 936 |
* (interior face, exterior face, data associated with cell). |
| 937 |
*/ |
| 938 |
internal::MatrixFreeFunctions::DoFInfo::DoFAccessIndex dof_access_index; |
| 939 |
|
| 940 |
/** |
| 941 |
* Stores the (non-vectorized) number of faces within cells in case of ECL |
| 942 |
* for the exterior cells where the single number `face_no` is not enough to |
| 943 |
* cover all cases. |
| 944 |
* |
| 945 |
* @note Only available for `dof_access_index == dof_access_cell` and |
| 946 |
* `is_interior_face == false`. |
| 947 |
*/ |
| 948 |
std::array<std::uint8_t, n_lanes> face_numbers; |
| 949 |
|
| 950 |
/** |
| 951 |
* Store the orientation of the neighbor's faces with respect to the current |
| 952 |
* cell for the case of exterior faces on ECL with possibly different |
| 953 |
* orientations behind different cells. |
| 954 |
* |
| 955 |
* @note Only available for `dof_access_index == dof_access_cell` and |
| 956 |
* `is_interior_face == false`. |
| 957 |
*/ |
| 958 |
std::array<std::uint8_t, n_lanes> face_orientations; |
| 959 |
|
| 960 |
/** |
| 961 |
* Stores the subface index of the given face. Usually, this variable takes |
| 962 |
* the value numbers::invalid_unsigned_int to indicate integration over the |
| 963 |
* full face, but in case the current physical face has a neighbor that is |
| 964 |
* more refined, it is a subface and must scale the entries in ShapeInfo |
| 965 |
* appropriately. |
| 966 |
*/ |
| 967 |
unsigned int subface_index; |
| 968 |
|
| 969 |
/** |
| 970 |
* Stores the type of the cell we are currently working with after a call to |
| 971 |
* reinit(). Valid values are @p cartesian, @p affine and @p general, which |
| 972 |
* have different implications on how the Jacobian transformations are |
| 973 |
* stored internally in MappingInfo. |
| 974 |
*/ |
| 975 |
internal::MatrixFreeFunctions::GeometryType cell_type; |
| 976 |
|
| 977 |
/** |
| 978 |
* Stores the (non-vectorized) id of the cells or faces this object is |
| 979 |
* initialized to. Relevant for ECL. |
| 980 |
*/ |
| 981 |
std::array<unsigned int, n_lanes> cell_ids; |
| 982 |
|
| 983 |
/** |
| 984 |
* Stores the (non-vectorized) id of the cells or faces this object is |
| 985 |
* initialized to. Relevant for ECL. |
| 986 |
*/ |
| 987 |
std::array<unsigned int, n_lanes> face_ids; |
| 988 |
|
| 989 |
/** |
| 990 |
* Geometry data that can be generated FEValues on the fly with the |
| 991 |
* respective constructor, as an alternative to the entry point with |
| 992 |
* MatrixFree. |
| 993 |
*/ |
| 994 |
std::shared_ptr< |
| 995 |
internal::MatrixFreeFunctions::MappingDataOnTheFly<dim, Number>> |
| 996 |
mapped_geometry; |
| 997 |
|
| 998 |
/** |
| 999 |
* Bool indicating if the divergence is requested. Used internally in the case |
| 1000 |
* of the Piola transform. |
| 1001 |
*/ |
| 1002 |
bool divergence_is_requested; |
| 1003 |
|
| 1004 |
// Make FEEvaluation and FEEvaluationBase objects friends for access to |
| 1005 |
// protected member mapped_geometry. |
| 1006 |
template <int, int, typename, bool, typename> |
| 1007 |
friend class FEEvaluationBase; |
| 1008 |
|
| 1009 |
template <int, int, int, int, typename, typename> |
| 1010 |
friend class FEEvaluation; |
| 1011 |
}; |
| 1012 |
|
| 1013 |
|
| 1014 |
/** |
| 1015 |
* This class is equivalent to FEEvaluationData and exists merely for backward |
| 1016 |
* compatibility. |
| 1017 |
*/ |
| 1018 |
template <int dim, |
| 1019 |
typename Number, |
| 1020 |
bool is_face, |
| 1021 |
typename VectorizedArrayType = VectorizedArray<Number>> |
| 1022 |
using FEEvaluationBaseData = |
| 1023 |
FEEvaluationData<dim, VectorizedArrayType, is_face>; |
| 1024 |
|
| 1025 |
|
| 1026 |
/*----------------------- Inline functions ----------------------------------*/ |
| 1027 |
|
| 1028 |
#ifndef DOXYGEN |
| 1029 |
|
| 1030 |
template <int dim, typename Number, bool is_face> |
| 1031 |
inline FEEvaluationData<dim, Number, is_face>::FEEvaluationData( |
| 1032 |
const ShapeInfoType &shape_info, |
| 1033 |
const bool is_interior_face) |
| 1034 |
: FEEvaluationData( |
| 1035 |
InitializationData{&shape_info, nullptr, nullptr, 0, 0, nullptr}, |
| 1036 |
is_interior_face, |
| 1037 |
0, |
| 1038 |
0) |
| 1039 |
{} |
| 1040 |
|
| 1041 |
|
| 1042 |
template <int dim, typename Number, bool is_face> |
| 1043 |
inline FEEvaluationData<dim, Number, is_face>::FEEvaluationData( |
| 1044 |
const InitializationData &initialization_data, |
| 1045 |
const bool is_interior_face, |
| 1046 |
const unsigned int quad_no, |
| 1047 |
const unsigned int first_selected_component) |
| 1048 |
: data(initialization_data.shape_info) |
| 1049 |
, dof_info(initialization_data.dof_info) |
| 1050 |
, mapping_data(initialization_data.mapping_data) |
| 1051 |
, quad_no(quad_no) |
| 1052 |
, n_fe_components(dof_info != nullptr ? dof_info->start_components.back() : 0) |
| 1053 |
, first_selected_component(first_selected_component) |
| 1054 |
, active_fe_index(initialization_data.active_fe_index) |
| 1055 |
, active_quad_index(initialization_data.active_quad_index) |
| 1056 |
, descriptor(initialization_data.descriptor) |
| 1057 |
, n_quadrature_points(descriptor == nullptr ? |
| 1058 |
(is_face ? data->n_q_points_face : data->n_q_points) : |
| 1059 |
descriptor->n_q_points) |
| 1060 |
, quadrature_points(nullptr) |
| 1061 |
, jacobian(nullptr) |
| 1062 |
, jacobian_gradients(nullptr) |
| 1063 |
, jacobian_gradients_non_inverse(nullptr) |
| 1064 |
, J_value(nullptr) |
| 1065 |
, normal_vectors(nullptr) |
| 1066 |
, normal_x_jacobian(nullptr) |
| 1067 |
, quadrature_weights( |
| 1068 |
descriptor != nullptr ? descriptor->quadrature_weights.begin() : nullptr) |
| 1069 |
# ifdef DEBUG |
| 1070 |
, is_reinitialized(false) |
| 1071 |
, dof_values_initialized(false) |
| 1072 |
, values_quad_initialized(false) |
| 1073 |
, gradients_quad_initialized(false) |
| 1074 |
, hessians_quad_initialized(false) |
| 1075 |
, values_quad_submitted(false) |
| 1076 |
, gradients_quad_submitted(false) |
| 1077 |
# endif |
| 1078 |
, cell(numbers::invalid_unsigned_int) |
| 1079 |
, interior_face(is_interior_face) |
| 1080 |
, dof_access_index( |
| 1081 |
is_face ? |
| 1082 |
(is_interior_face ? |
| 1083 |
internal::MatrixFreeFunctions::DoFInfo::dof_access_face_interior : |
| 1084 |
internal::MatrixFreeFunctions::DoFInfo::dof_access_face_exterior) : |
| 1085 |
internal::MatrixFreeFunctions::DoFInfo::dof_access_cell) |
| 1086 |
, subface_index(0) |
| 1087 |
, cell_type(internal::MatrixFreeFunctions::general) |
| 1088 |
, divergence_is_requested(false) |
| 1089 |
{ |
| 1090 |
Assert(!data->data.empty(), ExcInternalError()); |
| 1091 |
} |
| 1092 |
|
| 1093 |
|
| 1094 |
|
| 1095 |
template <int dim, typename Number, bool is_face> |
| 1096 |
inline FEEvaluationData<dim, Number, is_face>::FEEvaluationData( |
| 1097 |
const std::shared_ptr< |
| 1098 |
internal::MatrixFreeFunctions::MappingDataOnTheFly<dim, Number>> |
| 1099 |
&mapped_geometry, |
| 1100 |
const unsigned int n_fe_components, |
| 1101 |
const unsigned int first_selected_component) |
| 1102 |
: data(nullptr) |
| 1103 |
, dof_info(nullptr) |
| 1104 |
, mapping_data(nullptr) |
| 1105 |
, quad_no(numbers::invalid_unsigned_int) |
| 1106 |
, n_fe_components(n_fe_components) |
| 1107 |
, first_selected_component(first_selected_component) |
| 1108 |
, active_fe_index(numbers::invalid_unsigned_int) |
| 1109 |
, active_quad_index(numbers::invalid_unsigned_int) |
| 1110 |
, descriptor(nullptr) |
| 1111 |
, n_quadrature_points( |
| 1112 |
mapped_geometry->get_data_storage().descriptor[0].n_q_points) |
| 1113 |
, quadrature_points(nullptr) |
| 1114 |
, jacobian(nullptr) |
| 1115 |
, jacobian_gradients(nullptr) |
| 1116 |
, jacobian_gradients_non_inverse(nullptr) |
| 1117 |
, J_value(nullptr) |
| 1118 |
, normal_vectors(nullptr) |
| 1119 |
, normal_x_jacobian(nullptr) |
| 1120 |
, quadrature_weights(nullptr) |
| 1121 |
, cell(0) |
| 1122 |
, cell_type(internal::MatrixFreeFunctions::general) |
| 1123 |
, interior_face(true) |
| 1124 |
, dof_access_index(internal::MatrixFreeFunctions::DoFInfo::dof_access_cell) |
| 1125 |
, mapped_geometry(mapped_geometry) |
| 1126 |
, is_reinitialized(false) |
| 1127 |
, divergence_is_requested(false) |
| 1128 |
{ |
| 1129 |
mapping_data = &mapped_geometry->get_data_storage(); |
| 1130 |
jacobian = mapped_geometry->get_data_storage().jacobians[0].begin(); |
| 1131 |
J_value = mapped_geometry->get_data_storage().JxW_values.begin(); |
| 1132 |
jacobian_gradients = |
| 1133 |
mapped_geometry->get_data_storage().jacobian_gradients[0].begin(); |
| 1134 |
jacobian_gradients_non_inverse = mapped_geometry->get_data_storage() |
| 1135 |
.jacobian_gradients_non_inverse[0] |
| 1136 |
.begin(); |
| 1137 |
quadrature_points = |
| 1138 |
mapped_geometry->get_data_storage().quadrature_points.begin(); |
| 1139 |
} |
| 1140 |
|
| 1141 |
|
| 1142 |
|
| 1143 |
template <int dim, typename Number, bool is_face> |
| 1144 |
inline FEEvaluationData<dim, Number, is_face> & |
| 1145 |
FEEvaluationData<dim, Number, is_face>::operator=(const FEEvaluationData &other) |
| 1146 |
{ |
| 1147 |
AssertDimension(quad_no, other.quad_no); |
| 1148 |
AssertDimension(n_fe_components, other.n_fe_components); |
| 1149 |
AssertDimension(first_selected_component, other.first_selected_component); |
| 1150 |
AssertDimension(active_fe_index, other.active_fe_index); |
| 1151 |
AssertDimension(active_quad_index, other.active_quad_index); |
| 1152 |
AssertDimension(n_quadrature_points, descriptor->n_q_points); |
| 1153 |
|
| 1154 |
data = other.data; |
| 1155 |
dof_info = other.dof_info; |
| 1156 |
mapping_data = other.mapping_data; |
| 1157 |
descriptor = other.descriptor; |
| 1158 |
jacobian = nullptr; |
| 1159 |
J_value = nullptr; |
| 1160 |
normal_vectors = nullptr; |
| 1161 |
normal_x_jacobian = nullptr; |
| 1162 |
jacobian_gradients = nullptr; |
| 1163 |
jacobian_gradients_non_inverse = nullptr; |
| 1164 |
quadrature_points = nullptr; |
| 1165 |
quadrature_weights = other.quadrature_weights; |
| 1166 |
|
| 1167 |
if constexpr (running_in_debug_mode()) |
| 1168 |
{ |
| 1169 |
is_reinitialized = false; |
| 1170 |
dof_values_initialized = false; |
| 1171 |
values_quad_initialized = false; |
| 1172 |
gradients_quad_initialized = false; |
| 1173 |
hessians_quad_initialized = false; |
| 1174 |
values_quad_submitted = false; |
| 1175 |
gradients_quad_submitted = false; |
| 1176 |
} |
| 1177 |
|
| 1178 |
cell = numbers::invalid_unsigned_int; |
| 1179 |
interior_face = other.is_interior_face(); |
| 1180 |
dof_access_index = |
| 1181 |
is_face ? |
| 1182 |
(is_interior_face() ? |
| 1183 |
internal::MatrixFreeFunctions::DoFInfo::dof_access_face_interior : |
| 1184 |
internal::MatrixFreeFunctions::DoFInfo::dof_access_face_exterior) : |
| 1185 |
internal::MatrixFreeFunctions::DoFInfo::dof_access_cell; |
| 1186 |
face_numbers[0] = 0; |
| 1187 |
face_orientations[0] = 0; |
| 1188 |
subface_index = 0; |
| 1189 |
cell_type = internal::MatrixFreeFunctions::general; |
| 1190 |
divergence_is_requested = false; |
| 1191 |
|
| 1192 |
return *this; |
| 1193 |
} |
| 1194 |
|
| 1195 |
|
| 1196 |
|
| 1197 |
template <int dim, typename Number, bool is_face> |
| 1198 |
inline void |
| 1199 |
FEEvaluationData<dim, Number, is_face>::set_data_pointers( |
| 1200 |
AlignedVector<Number> *scratch_data_array, |
| 1201 |
const unsigned int n_components) |
| 1202 |
{ |
| 1203 |
Assert(scratch_data_array != nullptr, ExcInternalError()); |
| 1204 |
Assert(data != nullptr, ExcInternalError()); |
| 1205 |
Assert(!data->data.empty(), ExcInternalError()); |
| 1206 |
|
| 1207 |
|
| 1208 |
const unsigned int tensor_dofs_per_component = |
| 1209 |
Utilities::fixed_power<dim>(data->data.front().fe_degree + 1); |
| 1210 |
const unsigned int dofs_per_component = data->dofs_per_component_on_cell; |
| 1211 |
|
| 1212 |
const unsigned int size_scratch_data = |
| 1213 |
std::max(tensor_dofs_per_component + 1, dofs_per_component) * n_components * |
| 1214 |
4 + |
| 1215 |
2 * n_quadrature_points; |
| 1216 |
const unsigned int size_data_arrays = |
| 1217 |
n_components * dofs_per_component + |
| 1218 |
(n_components * ((dim * (dim + 1)) / 2 + 2 * dim + 2) * |
| 1219 |
n_quadrature_points); |
| 1220 |
|
| 1221 |
// include 12 extra fields to insert some padding between values, gradients |
| 1222 |
// and hessians, which helps to reduce the probability of cache conflicts |
| 1223 |
const unsigned int allocated_size = size_scratch_data + size_data_arrays + 12; |
| 1224 |
if constexpr (running_in_debug_mode()) |
| 1225 |
{ |
| 1226 |
scratch_data_array->clear(); |
| 1227 |
scratch_data_array->resize( |
| 1228 |
allocated_size, Number(numbers::signaling_nan<ScalarNumber>())); |
| 1229 |
} |
| 1230 |
else |
| 1231 |
{ |
| 1232 |
scratch_data_array->resize_fast(allocated_size); |
| 1233 |
} |
| 1234 |
scratch_data.reinit(scratch_data_array->begin() + size_data_arrays + 12, |
| 1235 |
size_scratch_data); |
| 1236 |
|
| 1237 |
// set the pointers to the correct position in the data array |
| 1238 |
values_dofs = scratch_data_array->begin(); |
| 1239 |
values_quad = |
| 1240 |
scratch_data_array->begin() + 4 + n_components * dofs_per_component; |
| 1241 |
values_from_gradients_quad = |
| 1242 |
scratch_data_array->begin() + 6 + |
| 1243 |
n_components * (dofs_per_component + n_quadrature_points); |
| 1244 |
gradients_quad = |
| 1245 |
scratch_data_array->begin() + 8 + |
| 1246 |
n_components * (dofs_per_component + 2 * n_quadrature_points); |
| 1247 |
gradients_from_hessians_quad = |
| 1248 |
scratch_data_array->begin() + 12 + |
| 1249 |
n_components * (dofs_per_component + (dim + 2) * n_quadrature_points); |
| 1250 |
hessians_quad = |
| 1251 |
scratch_data_array->begin() + 12 + |
| 1252 |
n_components * (dofs_per_component + (2 * dim + 2) * n_quadrature_points); |
| 1253 |
} |
| 1254 |
|
| 1255 |
|
| 1256 |
|
| 1257 |
template <int dim, typename Number, bool is_face> |
| 1258 |
inline void |
| 1259 |
FEEvaluationData<dim, Number, is_face>::reinit_face( |
| 1260 |
const internal::MatrixFreeFunctions::FaceToCellTopology<n_lanes> &face) |
| 1261 |
{ |
| 1262 |
Assert(is_face == true, |
| 1263 |
ExcMessage("Faces can only be set if the is_face template parameter " |
| 1264 |
"is true")); |
| 1265 |
face_numbers[0] = |
| 1266 |
(is_interior_face() ? face.interior_face_no : face.exterior_face_no); |
| 1267 |
subface_index = is_interior_face() == true ? |
| 1268 |
GeometryInfo<dim>::max_children_per_cell : |
| 1269 |
face.subface_index; |
| 1270 |
|
| 1271 |
// First check if interior or exterior cell has non-standard orientation |
| 1272 |
// (i.e. the third bit is one or not). Then set zero if this cell has |
| 1273 |
// standard-orientation else copy the first three bits |
| 1274 |
// (which is equivalent to modulo 8). See also the documentation of |
| 1275 |
// internal::MatrixFreeFunctions::FaceToCellTopology::face_orientation. |
| 1276 |
face_orientations[0] = (is_interior_face() == (face.face_orientation >= 8)) ? |
| 1277 |
(face.face_orientation % 8) : |
| 1278 |
0; |
| 1279 |
|
| 1280 |
if (is_interior_face()) |
| 1281 |
cell_ids = face.cells_interior; |
| 1282 |
else |
| 1283 |
cell_ids = face.cells_exterior; |
| 1284 |
} |
| 1285 |
|
| 1286 |
|
| 1287 |
|
| 1288 |
template <int dim, typename Number, bool is_face> |
| 1289 |
inline DEAL_II_ALWAYS_INLINE Tensor<1, dim, Number> |
| 1290 |
FEEvaluationData<dim, Number, is_face>::normal_vector( |
| 1291 |
const unsigned int q_point) const |
| 1292 |
{ |
| 1293 |
AssertIndexRange(q_point, n_quadrature_points); |
| 1294 |
Assert(normal_vectors != nullptr, |
| 1295 |
internal::ExcMatrixFreeAccessToUninitializedMappingField( |
| 1296 |
"update_normal_vectors")); |
| 1297 |
if (cell_type <= internal::MatrixFreeFunctions::flat_faces) |
| 1298 |
return normal_vectors[0]; |
| 1299 |
else |
| 1300 |
return normal_vectors[q_point]; |
| 1301 |
} |
| 1302 |
|
| 1303 |
|
| 1304 |
|
| 1305 |
// This function is deprecated. |
| 1306 |
template <int dim, typename Number, bool is_face> |
| 1307 |
inline DEAL_II_ALWAYS_INLINE Tensor<1, dim, Number> |
| 1308 |
FEEvaluationData<dim, Number, is_face>::get_normal_vector( |
| 1309 |
const unsigned int q_point) const |
| 1310 |
{ |
| 1311 |
return normal_vector(q_point); |
| 1312 |
} |
| 1313 |
|
| 1314 |
|
| 1315 |
|
| 1316 |
template <int dim, typename Number, bool is_face> |
| 1317 |
inline DEAL_II_ALWAYS_INLINE Number |
| 1318 |
FEEvaluationData<dim, Number, is_face>::JxW(const unsigned int q_point) const |
| 1319 |
{ |
| 1320 |
AssertIndexRange(q_point, n_quadrature_points); |
| 1321 |
Assert(J_value != nullptr, |
| 1322 |
internal::ExcMatrixFreeAccessToUninitializedMappingField( |
| 1323 |
"update_values|update_gradients")); |
| 1324 |
if (cell_type <= internal::MatrixFreeFunctions::affine) |
| 1325 |
{ |
| 1326 |
Assert(quadrature_weights != nullptr, ExcNotInitialized()); |
| 1327 |
return J_value[0] * quadrature_weights[q_point]; |
| 1328 |
} |
| 1329 |
else |
| 1330 |
return J_value[q_point]; |
| 1331 |
} |
| 1332 |
|
| 1333 |
|
| 1334 |
|
| 1335 |
template <int dim, typename Number, bool is_face> |
| 1336 |
inline DEAL_II_ALWAYS_INLINE Point<dim, Number> |
| 1337 |
FEEvaluationData<dim, Number, is_face>::quadrature_point( |
| 1338 |
const unsigned int q) const |
| 1339 |
{ |
| 1340 |
AssertIndexRange(q, this->n_quadrature_points); |
| 1341 |
Assert(this->quadrature_points != nullptr, |
| 1342 |
internal::ExcMatrixFreeAccessToUninitializedMappingField( |
| 1343 |
"update_quadrature_points")); |
| 1344 |
|
| 1345 |
// Cartesian/affine mesh: only first vertex of cell is stored, we must |
| 1346 |
// compute it through the Jacobian (which is stored in non-inverted and |
| 1347 |
// non-transposed form as index '1' in the jacobian field) |
| 1348 |
if (is_face == false && |
| 1349 |
this->cell_type <= internal::MatrixFreeFunctions::affine) |
| 1350 |
{ |
| 1351 |
Assert(this->jacobian != nullptr, ExcNotInitialized()); |
| 1352 |
Point<dim, Number> point = this->quadrature_points[0]; |
| 1353 |
|
| 1354 |
const Tensor<2, dim, Number> &jac = this->jacobian[1]; |
| 1355 |
if (this->cell_type == internal::MatrixFreeFunctions::cartesian) |
| 1356 |
for (unsigned int d = 0; d < dim; ++d) |
| 1357 |
point[d] += jac[d][d] * static_cast<typename Number::value_type>( |
| 1358 |
this->descriptor->quadrature.point(q)[d]); |
| 1359 |
else |
| 1360 |
for (unsigned int d = 0; d < dim; ++d) |
| 1361 |
for (unsigned int e = 0; e < dim; ++e) |
| 1362 |
point[d] += jac[d][e] * static_cast<typename Number::value_type>( |
| 1363 |
this->descriptor->quadrature.point(q)[e]); |
| 1364 |
return point; |
| 1365 |
} |
| 1366 |
else |
| 1367 |
return this->quadrature_points[q]; |
| 1368 |
} |
| 1369 |
|
| 1370 |
|
| 1371 |
|
| 1372 |
template <int dim, typename Number, bool is_face> |
| 1373 |
inline DEAL_II_ALWAYS_INLINE Tensor<2, dim, Number> |
| 1374 |
FEEvaluationData<dim, Number, is_face>::inverse_jacobian( |
| 1375 |
const unsigned int q_point) const |
| 1376 |
{ |
| 1377 |
AssertIndexRange(q_point, n_quadrature_points); |
| 1378 |
Assert(jacobian != nullptr, |
| 1379 |
internal::ExcMatrixFreeAccessToUninitializedMappingField( |
| 1380 |
"update_gradients")); |
| 1381 |
if (cell_type <= internal::MatrixFreeFunctions::affine) |
| 1382 |
return jacobian[0]; |
| 1383 |
else |
| 1384 |
return jacobian[q_point]; |
| 1385 |
} |
| 1386 |
|
| 1387 |
|
| 1388 |
|
| 1389 |
template <int dim, typename Number, bool is_face> |
| 1390 |
inline const Number * |
| 1391 |
FEEvaluationData<dim, Number, is_face>::begin_dof_values() const |
| 1392 |
{ |
| 1393 |
return values_dofs; |
| 1394 |
} |
| 1395 |
|
| 1396 |
|
| 1397 |
|
| 1398 |
template <int dim, typename Number, bool is_face> |
| 1399 |
inline Number * |
| 1400 |
FEEvaluationData<dim, Number, is_face>::begin_dof_values() |
| 1401 |
{ |
| 1402 |
if constexpr (running_in_debug_mode()) |
| 1403 |
{ |
| 1404 |
dof_values_initialized = true; |
| 1405 |
} |
| 1406 |
return values_dofs; |
| 1407 |
} |
| 1408 |
|
| 1409 |
|
| 1410 |
|
| 1411 |
template <int dim, typename Number, bool is_face> |
| 1412 |
inline const Number * |
| 1413 |
FEEvaluationData<dim, Number, is_face>::begin_values() const |
| 1414 |
{ |
| 1415 |
if constexpr (running_in_debug_mode()) |
| 1416 |
{ |
| 1417 |
Assert(values_quad_initialized || values_quad_submitted, |
| 1418 |
ExcNotInitialized()); |
| 1419 |
} |
| 1420 |
return values_quad; |
| 1421 |
} |
| 1422 |
|
| 1423 |
|
| 1424 |
|
| 1425 |
template <int dim, typename Number, bool is_face> |
| 1426 |
inline Number * |
| 1427 |
FEEvaluationData<dim, Number, is_face>::begin_values() |
| 1428 |
{ |
| 1429 |
if constexpr (running_in_debug_mode()) |
| 1430 |
{ |
| 1431 |
values_quad_initialized = true; |
| 1432 |
values_quad_submitted = true; |
| 1433 |
} |
| 1434 |
return values_quad; |
| 1435 |
} |
| 1436 |
|
| 1437 |
|
| 1438 |
|
| 1439 |
template <int dim, typename Number, bool is_face> |
| 1440 |
inline const Number * |
| 1441 |
FEEvaluationData<dim, Number, is_face>::begin_gradients() const |
| 1442 |
{ |
| 1443 |
if constexpr (running_in_debug_mode()) |
| 1444 |
{ |
| 1445 |
Assert(gradients_quad_initialized || gradients_quad_submitted, |
| 1446 |
ExcNotInitialized()); |
| 1447 |
} |
| 1448 |
return gradients_quad; |
| 1449 |
} |
| 1450 |
|
| 1451 |
|
| 1452 |
|
| 1453 |
template <int dim, typename Number, bool is_face> |
| 1454 |
inline Number * |
| 1455 |
FEEvaluationData<dim, Number, is_face>::begin_gradients() |
| 1456 |
{ |
| 1457 |
if constexpr (running_in_debug_mode()) |
| 1458 |
{ |
| 1459 |
gradients_quad_submitted = true; |
| 1460 |
gradients_quad_initialized = true; |
| 1461 |
} |
| 1462 |
return gradients_quad; |
| 1463 |
} |
| 1464 |
|
| 1465 |
|
| 1466 |
|
| 1467 |
template <int dim, typename Number, bool is_face> |
| 1468 |
inline const Number * |
| 1469 |
FEEvaluationData<dim, Number, is_face>::begin_hessians() const |
| 1470 |
{ |
| 1471 |
if constexpr (running_in_debug_mode()) |
| 1472 |
{ |
| 1473 |
Assert(hessians_quad_initialized, ExcNotInitialized()); |
| 1474 |
} |
| 1475 |
return hessians_quad; |
| 1476 |
} |
| 1477 |
|
| 1478 |
|
| 1479 |
|
| 1480 |
template <int dim, typename Number, bool is_face> |
| 1481 |
inline Number * |
| 1482 |
FEEvaluationData<dim, Number, is_face>::begin_hessians() |
| 1483 |
{ |
| 1484 |
if constexpr (running_in_debug_mode()) |
| 1485 |
{ |
| 1486 |
hessians_quad_initialized = true; |
| 1487 |
} |
| 1488 |
return hessians_quad; |
| 1489 |
} |
| 1490 |
|
| 1491 |
|
| 1492 |
|
| 1493 |
template <int dim, typename Number, bool is_face> |
| 1494 |
inline unsigned int |
| 1495 |
FEEvaluationData<dim, Number, is_face>::get_mapping_data_index_offset() const |
| 1496 |
{ |
| 1497 |
Assert(mapping_data != nullptr, ExcInternalError()); |
| 1498 |
|
| 1499 |
if (dof_info == nullptr) |
| 1500 |
return 0; |
| 1501 |
else |
| 1502 |
{ |
| 1503 |
AssertIndexRange(cell, mapping_data->data_index_offsets.size()); |
| 1504 |
return mapping_data->data_index_offsets[cell]; |
| 1505 |
} |
| 1506 |
} |
| 1507 |
|
| 1508 |
|
| 1509 |
|
| 1510 |
template <int dim, typename Number, bool is_face> |
| 1511 |
inline internal::MatrixFreeFunctions::GeometryType |
| 1512 |
FEEvaluationData<dim, Number, is_face>::get_cell_type() const |
| 1513 |
{ |
| 1514 |
if constexpr (running_in_debug_mode()) |
| 1515 |
{ |
| 1516 |
Assert(is_reinitialized, ExcNotInitialized()); |
| 1517 |
} |
| 1518 |
return cell_type; |
| 1519 |
} |
| 1520 |
|
| 1521 |
|
| 1522 |
|
| 1523 |
template <int dim, typename Number, bool is_face> |
| 1524 |
inline const typename FEEvaluationData<dim, Number, is_face>::ShapeInfoType & |
| 1525 |
FEEvaluationData<dim, Number, is_face>::get_shape_info() const |
| 1526 |
{ |
| 1527 |
Assert(data != nullptr, ExcInternalError()); |
| 1528 |
return *data; |
| 1529 |
} |
| 1530 |
|
| 1531 |
|
| 1532 |
|
| 1533 |
template <int dim, typename Number, bool is_face> |
| 1534 |
inline const internal::MatrixFreeFunctions::DoFInfo & |
| 1535 |
FEEvaluationData<dim, Number, is_face>::get_dof_info() const |
| 1536 |
{ |
| 1537 |
Assert(dof_info != nullptr, |
| 1538 |
ExcMessage( |
| 1539 |
"FEEvaluation was not initialized with a MatrixFree object!")); |
| 1540 |
return *dof_info; |
| 1541 |
} |
| 1542 |
|
| 1543 |
|
| 1544 |
|
| 1545 |
template <int dim, typename Number, bool is_face> |
| 1546 |
inline const std::vector<unsigned int> & |
| 1547 |
FEEvaluationData<dim, Number, is_face>::get_internal_dof_numbering() const |
| 1548 |
{ |
| 1549 |
return data->lexicographic_numbering; |
| 1550 |
} |
| 1551 |
|
| 1552 |
|
| 1553 |
|
| 1554 |
template <int dim, typename Number, bool is_face> |
| 1555 |
inline unsigned int |
| 1556 |
FEEvaluationData<dim, Number, is_face>::get_quadrature_index() const |
| 1557 |
{ |
| 1558 |
return quad_no; |
| 1559 |
} |
| 1560 |
|
| 1561 |
|
| 1562 |
|
| 1563 |
template <int dim, typename Number, bool is_face> |
| 1564 |
inline unsigned int |
| 1565 |
FEEvaluationData<dim, Number, is_face>::get_current_cell_index() const |
| 1566 |
{ |
| 1567 |
if (is_face && dof_access_index == |
| 1568 |
internal::MatrixFreeFunctions::DoFInfo::dof_access_cell) |
| 1569 |
return cell * ReferenceCells::max_n_faces<dim>() + face_numbers[0]; |
| 1570 |
else |
| 1571 |
return cell; |
| 1572 |
} |
| 1573 |
|
| 1574 |
|
| 1575 |
|
| 1576 |
template <int dim, typename Number, bool is_face> |
| 1577 |
inline unsigned int |
| 1578 |
FEEvaluationData<dim, Number, is_face>::get_active_fe_index() const |
| 1579 |
{ |
| 1580 |
return active_fe_index; |
| 1581 |
} |
| 1582 |
|
| 1583 |
|
| 1584 |
|
| 1585 |
template <int dim, typename Number, bool is_face> |
| 1586 |
inline unsigned int |
| 1587 |
FEEvaluationData<dim, Number, is_face>::get_active_quadrature_index() const |
| 1588 |
{ |
| 1589 |
return active_quad_index; |
| 1590 |
} |
| 1591 |
|
| 1592 |
|
| 1593 |
|
| 1594 |
template <int dim, typename Number, bool is_face> |
| 1595 |
inline unsigned int |
| 1596 |
FEEvaluationData<dim, Number, is_face>::get_first_selected_component() const |
| 1597 |
{ |
| 1598 |
return first_selected_component; |
| 1599 |
} |
| 1600 |
|
| 1601 |
|
| 1602 |
|
| 1603 |
template <int dim, typename Number, bool is_face> |
| 1604 |
inline ArrayView<Number> |
| 1605 |
FEEvaluationData<dim, Number, is_face>::get_scratch_data() const |
| 1606 |
{ |
| 1607 |
return scratch_data; |
| 1608 |
} |
| 1609 |
|
| 1610 |
|
| 1611 |
|
| 1612 |
template <int dim, typename Number, bool is_face> |
| 1613 |
inline std::uint8_t |
| 1614 |
FEEvaluationData<dim, Number, is_face>::get_face_no(const unsigned int v) const |
| 1615 |
{ |
| 1616 |
Assert(is_face, ExcNotInitialized()); |
| 1617 |
Assert(v == 0 || (cell != numbers::invalid_unsigned_int && |
| 1618 |
dof_access_index == |
| 1619 |
internal::MatrixFreeFunctions::DoFInfo::dof_access_cell && |
| 1620 |
is_interior_face() == false), |
| 1621 |
ExcMessage("All face numbers can only be queried for ECL at exterior " |
| 1622 |
"faces. Use get_face_no() in other cases.")); |
| 1623 |
|
| 1624 |
return face_numbers[v]; |
| 1625 |
} |
| 1626 |
|
| 1627 |
|
| 1628 |
|
| 1629 |
template <int dim, typename Number, bool is_face> |
| 1630 |
inline unsigned int |
| 1631 |
FEEvaluationData<dim, Number, is_face>::get_subface_index() const |
| 1632 |
{ |
| 1633 |
return subface_index; |
| 1634 |
} |
| 1635 |
|
| 1636 |
|
| 1637 |
|
| 1638 |
template <int dim, typename Number, bool is_face> |
| 1639 |
inline std::uint8_t |
| 1640 |
FEEvaluationData<dim, Number, is_face>::get_face_orientation( |
| 1641 |
const unsigned int v) const |
| 1642 |
{ |
| 1643 |
Assert(is_face, ExcNotInitialized()); |
| 1644 |
Assert(v == 0 || (cell != numbers::invalid_unsigned_int && |
| 1645 |
dof_access_index == |
| 1646 |
internal::MatrixFreeFunctions::DoFInfo::dof_access_cell && |
| 1647 |
is_interior_face() == false), |
| 1648 |
ExcMessage("All face numbers can only be queried for ECL at exterior " |
| 1649 |
"faces. Use get_face_no() in other cases.")); |
| 1650 |
|
| 1651 |
return face_orientations[v]; |
| 1652 |
} |
| 1653 |
|
| 1654 |
|
| 1655 |
|
| 1656 |
template <int dim, typename Number, bool is_face> |
| 1657 |
inline internal::MatrixFreeFunctions::DoFInfo::DoFAccessIndex |
| 1658 |
FEEvaluationData<dim, Number, is_face>::get_dof_access_index() const |
| 1659 |
{ |
| 1660 |
return dof_access_index; |
| 1661 |
} |
| 1662 |
|
| 1663 |
|
| 1664 |
|
| 1665 |
template <int dim, typename Number, bool is_face> |
| 1666 |
inline bool |
| 1667 |
FEEvaluationData<dim, Number, is_face>::is_interior_face() const |
| 1668 |
{ |
| 1669 |
return interior_face; |
| 1670 |
} |
| 1671 |
|
| 1672 |
|
| 1673 |
|
| 1674 |
template <int dim, typename Number, bool is_face> |
| 1675 |
inline std_cxx20::ranges::iota_view<unsigned int, unsigned int> |
| 1676 |
FEEvaluationData<dim, Number, is_face>::quadrature_point_indices() const |
| 1677 |
{ |
| 1678 |
return std_cxx20::ranges::iota_view<unsigned int, unsigned int>( |
| 1679 |
0U, n_quadrature_points); |
| 1680 |
} |
| 1681 |
|
| 1682 |
|
| 1683 |
|
| 1684 |
namespace internal |
| 1685 |
{ |
| 1686 |
template <std::size_t N, |
| 1687 |
typename VectorOfArrayType, |
| 1688 |
typename ArrayType, |
| 1689 |
typename FU> |
| 1690 |
inline void |
| 1691 |
process_cell_or_face_data(const std::array<unsigned int, N> indices, |
| 1692 |
VectorOfArrayType &array, |
| 1693 |
ArrayType &out, |
| 1694 |
const FU &fu) |
| 1695 |
{ |
| 1696 |
for (unsigned int i = 0; i < N; ++i) |
| 1697 |
if (indices[i] != numbers::invalid_unsigned_int) |
| 1698 |
{ |
| 1699 |
AssertIndexRange(indices[i] / N, array.size()); |
| 1700 |
fu(out[i], array[indices[i] / N][indices[i] % N]); |
| 1701 |
} |
| 1702 |
} |
| 1703 |
|
| 1704 |
template <std::size_t N, typename VectorOfArrayType, typename ArrayType> |
| 1705 |
inline void |
| 1706 |
set_valid_element_to_array(const std::array<unsigned int, N> indices, |
| 1707 |
const VectorOfArrayType &array, |
| 1708 |
ArrayType &out) |
| 1709 |
{ |
| 1710 |
AssertDimension(indices.size(), out.size()); |
| 1711 |
AssertDimension(indices.size(), array[0].size()); |
| 1712 |
// set all entries in array to a valid element |
| 1713 |
std::size_t index = 0; |
| 1714 |
for (; index < N; ++index) |
| 1715 |
if (indices[index] != numbers::invalid_unsigned_int) |
| 1716 |
break; |
| 1717 |
for (unsigned int i = 0; i < N; ++i) |
| 1718 |
out[i] = array[indices[index] / N][indices[index] % N]; |
| 1719 |
} |
| 1720 |
} // namespace internal |
| 1721 |
|
| 1722 |
|
| 1723 |
|
| 1724 |
template <int dim, typename Number, bool is_face> |
| 1725 |
template <typename T> |
| 1726 |
inline T |
| 1727 |
FEEvaluationData<dim, Number, is_face>::read_cell_data( |
| 1728 |
const AlignedVector<T> &array) const |
| 1729 |
{ |
| 1730 |
T out; |
| 1731 |
internal::set_valid_element_to_array(this->get_cell_ids(), array, out); |
| 1732 |
internal::process_cell_or_face_data(this->get_cell_ids(), |
| 1733 |
array, |
| 1734 |
out, |
| 1735 |
[](auto &local, const auto &global) { |
| 1736 |
local = global; |
| 1737 |
}); |
| 1738 |
return out; |
| 1739 |
} |
| 1740 |
|
| 1741 |
|
| 1742 |
|
| 1743 |
template <int dim, typename Number, bool is_face> |
| 1744 |
template <typename T> |
| 1745 |
inline void |
| 1746 |
FEEvaluationData<dim, Number, is_face>::set_cell_data(AlignedVector<T> &array, |
| 1747 |
const T &in) const |
| 1748 |
{ |
| 1749 |
internal::process_cell_or_face_data(this->get_cell_ids(), |
| 1750 |
array, |
| 1751 |
in, |
| 1752 |
[](const auto &local, auto &global) { |
| 1753 |
global = local; |
| 1754 |
}); |
| 1755 |
} |
| 1756 |
|
| 1757 |
|
| 1758 |
|
| 1759 |
template <int dim, typename Number, bool is_face> |
| 1760 |
template <typename T> |
| 1761 |
inline T |
| 1762 |
FEEvaluationData<dim, Number, is_face>::read_face_data( |
| 1763 |
const AlignedVector<T> &array) const |
| 1764 |
{ |
| 1765 |
T out; |
| 1766 |
internal::set_valid_element_to_array(this->get_cell_ids(), array, out); |
| 1767 |
internal::process_cell_or_face_data(this->get_face_ids(), |
| 1768 |
array, |
| 1769 |
out, |
| 1770 |
[](auto &local, const auto &global) { |
| 1771 |
local = global; |
| 1772 |
}); |
| 1773 |
return out; |
| 1774 |
} |
| 1775 |
|
| 1776 |
|
| 1777 |
|
| 1778 |
template <int dim, typename Number, bool is_face> |
| 1779 |
template <typename T> |
| 1780 |
inline void |
| 1781 |
FEEvaluationData<dim, Number, is_face>::set_face_data(AlignedVector<T> &array, |
| 1782 |
const T &in) const |
| 1783 |
{ |
| 1784 |
internal::process_cell_or_face_data(this->get_face_ids(), |
| 1785 |
array, |
| 1786 |
in, |
| 1787 |
[](const auto &local, auto &global) { |
| 1788 |
global = local; |
| 1789 |
}); |
| 1790 |
} |
| 1791 |
|
| 1792 |
|
| 1793 |
|
| 1794 |
#endif // ifndef DOXYGEN |
| 1795 |
|
| 1796 |
|
| 1797 |
DEAL_II_NAMESPACE_CLOSE |
| 1798 |
|
| 1799 |
#endif |