| 1 |
// ------------------------------------------------------------------------ |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 4 |
// Copyright (C) 2001 - 2024 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_mapping_q_h |
| 16 |
#define dealii_mapping_q_h |
| 17 |
|
| 18 |
|
| 19 |
#include <deal.II/base/config.h> |
| 20 |
|
| 21 |
#include <deal.II/base/derivative_form.h> |
| 22 |
#include <deal.II/base/polynomial.h> |
| 23 |
#include <deal.II/base/quadrature_lib.h> |
| 24 |
#include <deal.II/base/table.h> |
| 25 |
#include <deal.II/base/vectorization.h> |
| 26 |
|
| 27 |
#include <deal.II/fe/mapping.h> |
| 28 |
|
| 29 |
#include <deal.II/grid/tria_iterator.h> |
| 30 |
|
| 31 |
#include <deal.II/matrix_free/shape_info.h> |
| 32 |
|
| 33 |
#include <array> |
| 34 |
#include <cmath> |
| 35 |
|
| 36 |
DEAL_II_NAMESPACE_OPEN |
| 37 |
|
| 38 |
#ifndef DOXYGEN |
| 39 |
template <int, int> |
| 40 |
class MappingQCache; |
| 41 |
#endif |
| 42 |
|
| 43 |
/** |
| 44 |
* @addtogroup mapping |
| 45 |
* @{ |
| 46 |
*/ |
| 47 |
|
| 48 |
/** |
| 49 |
* This class implements the functionality for polynomial mappings $Q_p$ of |
| 50 |
* polynomial degree $p$ that will be used on all cells of the mesh. In order |
| 51 |
* to get a genuine higher-order mapping for all cells, it is important to |
| 52 |
* provide information about how interior edges and faces of the mesh should |
| 53 |
* be curved. This is typically done by associating a Manifold with interior |
| 54 |
* cells and edges. A simple example of this is discussed in the "Results" |
| 55 |
* section of step-6; a full discussion of manifolds is provided in |
| 56 |
* step-53. If manifolds are only attached to the boundaries of a domain, the |
| 57 |
* current class with higher polynomial degrees will provide the same |
| 58 |
* information as a mere MappingQ1 object. If you are working on meshes that |
| 59 |
* describe a (curved) manifold embedded in higher space dimensions, i.e., if |
| 60 |
* dim!=spacedim, then every cell is at the boundary of the domain you will |
| 61 |
* likely already have attached a manifold object to all cells that can then |
| 62 |
* also be used by the mapping classes for higher order mappings. |
| 63 |
* |
| 64 |
* <h4>Behavior along curved boundaries and with different manifolds</h4> |
| 65 |
* |
| 66 |
* For a number of applications, one only knows a manifold description of a |
| 67 |
* surface but not the interior of the computational domain. In such a case, a |
| 68 |
* FlatManifold object will be assigned to the interior entities that |
| 69 |
* describes a usual planar coordinate system where the additional points for |
| 70 |
* the higher order mapping are placed exactly according to a bi-/trilinear |
| 71 |
* mapping. When combined with a non-flat manifold on the boundary, for |
| 72 |
* example a circle bulging into the interior of a square cell, the two |
| 73 |
* manifold descriptions are in general incompatible. For example, a |
| 74 |
* FlatManifold defined solely through the cell's vertices would put an |
| 75 |
* interior point located at some small distance epsilon away from the |
| 76 |
* boundary along a straight line and thus in general outside the concave part |
| 77 |
* of a circle. If the polynomial degree of MappingQ is sufficiently high, the |
| 78 |
* transformation from the reference cell to such a cell would in general |
| 79 |
* contain inverted regions close to the boundary. |
| 80 |
* |
| 81 |
* In order to avoid this situation, this class applies an algorithm for |
| 82 |
* making this transition smooth using a so-called transfinite interpolation |
| 83 |
* that is essentially a linear blend between the descriptions along the |
| 84 |
* surrounding entities. In the algorithm that computes additional points, the |
| 85 |
* compute_mapping_support_points() method, all the entities of the cells are |
| 86 |
* passed through hierarchically, starting from the lines to the quads and |
| 87 |
* finally hexes. Points on objects higher up in the hierarchy are obtained |
| 88 |
* from the manifold associated with that object, taking into account all the |
| 89 |
* points previously computed by the manifolds associated with the |
| 90 |
* lower-dimensional objects, not just the vertices. If only a line is |
| 91 |
* assigned a curved boundary but the adjacent quad is on a flat manifold, the |
| 92 |
* flat manifold on the quad will take the points on the deformed line into |
| 93 |
* account when interpolating the position of the additional points inside the |
| 94 |
* quad and thus always result in a well-defined transformation. |
| 95 |
* |
| 96 |
* The interpolation scheme used in this class makes sure that curved |
| 97 |
* descriptions can go over to flat descriptions within a single layer of |
| 98 |
* elements, maintaining the overall optimal convergence rates of the finite |
| 99 |
* element interpolation. However, this only helps as long as opposite faces |
| 100 |
* of a cell are far enough away from each other: If a curved part is indeed |
| 101 |
* curved to the extent that it would come close or even intersect some of the |
| 102 |
* other faces, as is often the case with long and sliver cells, the current |
| 103 |
* approach still leads to bad mesh quality. Therefore, the recommended way is |
| 104 |
* to spread the transition between curved boundaries and flat interior |
| 105 |
* domains over a larger range as the mesh is refined. This is provided by the |
| 106 |
* special manifold TransfiniteInterpolationManifold. |
| 107 |
*/ |
| 108 |
template <int dim, int spacedim = dim> |
| 109 |
class MappingQ : public Mapping<dim, spacedim> |
| 110 |
{ |
| 111 |
public: |
| 112 |
/** |
| 113 |
* Constructor. @p polynomial_degree denotes the polynomial degree of the |
| 114 |
* polynomials that are used to map cells from the reference to the real |
| 115 |
* cell. |
| 116 |
*/ |
| 117 |
MappingQ(const unsigned int polynomial_degree); |
| 118 |
|
| 119 |
/** |
| 120 |
* Copy constructor. |
| 121 |
*/ |
| 122 |
MappingQ(const MappingQ<dim, spacedim> &mapping); |
| 123 |
|
| 124 |
// for documentation, see the Mapping base class |
| 125 |
virtual std::unique_ptr<Mapping<dim, spacedim>> |
| 126 |
clone() const override; |
| 127 |
|
| 128 |
/** |
| 129 |
* Return the degree of the mapping, i.e. the value which was passed to the |
| 130 |
* constructor. |
| 131 |
*/ |
| 132 |
unsigned int |
| 133 |
get_degree() const; |
| 134 |
|
| 135 |
/** |
| 136 |
* Always returns @p true because the default implementation of functions in |
| 137 |
* this class preserves vertex locations. |
| 138 |
*/ |
| 139 |
virtual bool |
| 140 |
preserves_vertex_locations() const override; |
| 141 |
|
| 142 |
// for documentation, see the Mapping base class |
| 143 |
virtual BoundingBox<spacedim> |
| 144 |
get_bounding_box(const typename Triangulation<dim, spacedim>::cell_iterator |
| 145 |
&cell) const override; |
| 146 |
|
| 147 |
virtual bool |
| 148 |
is_compatible_with(const ReferenceCell &reference_cell) const override; |
| 149 |
|
| 150 |
/** |
| 151 |
* @name Mapping points between reference and real cells |
| 152 |
* @{ |
| 153 |
*/ |
| 154 |
|
| 155 |
// for documentation, see the Mapping base class |
| 156 |
virtual Point<spacedim> |
| 157 |
transform_unit_to_real_cell( |
| 158 |
const typename Triangulation<dim, spacedim>::cell_iterator &cell, |
| 159 |
const Point<dim> &p) const override; |
| 160 |
|
| 161 |
// for documentation, see the Mapping base class |
| 162 |
virtual Point<dim> |
| 163 |
transform_real_to_unit_cell( |
| 164 |
const typename Triangulation<dim, spacedim>::cell_iterator &cell, |
| 165 |
const Point<spacedim> &p) const override; |
| 166 |
|
| 167 |
// for documentation, see the Mapping base class |
| 168 |
virtual void |
| 169 |
transform_points_real_to_unit_cell( |
| 170 |
const typename Triangulation<dim, spacedim>::cell_iterator &cell, |
| 171 |
const ArrayView<const Point<spacedim>> &real_points, |
| 172 |
const ArrayView<Point<dim>> &unit_points) const override; |
| 173 |
|
| 174 |
/** |
| 175 |
* @} |
| 176 |
*/ |
| 177 |
|
| 178 |
/** |
| 179 |
* @name Functions to transform tensors from reference to real coordinates |
| 180 |
* @{ |
| 181 |
*/ |
| 182 |
|
| 183 |
// for documentation, see the Mapping base class |
| 184 |
virtual void |
| 185 |
transform(const ArrayView<const Tensor<1, dim>> &input, |
| 186 |
const MappingKind kind, |
| 187 |
const typename Mapping<dim, spacedim>::InternalDataBase &internal, |
| 188 |
const ArrayView<Tensor<1, spacedim>> &output) const override; |
| 189 |
|
| 190 |
// for documentation, see the Mapping base class |
| 191 |
virtual void |
| 192 |
transform(const ArrayView<const DerivativeForm<1, dim, spacedim>> &input, |
| 193 |
const MappingKind kind, |
| 194 |
const typename Mapping<dim, spacedim>::InternalDataBase &internal, |
| 195 |
const ArrayView<Tensor<2, spacedim>> &output) const override; |
| 196 |
|
| 197 |
// for documentation, see the Mapping base class |
| 198 |
virtual void |
| 199 |
transform(const ArrayView<const Tensor<2, dim>> &input, |
| 200 |
const MappingKind kind, |
| 201 |
const typename Mapping<dim, spacedim>::InternalDataBase &internal, |
| 202 |
const ArrayView<Tensor<2, spacedim>> &output) const override; |
| 203 |
|
| 204 |
// for documentation, see the Mapping base class |
| 205 |
virtual void |
| 206 |
transform(const ArrayView<const DerivativeForm<2, dim, spacedim>> &input, |
| 207 |
const MappingKind kind, |
| 208 |
const typename Mapping<dim, spacedim>::InternalDataBase &internal, |
| 209 |
const ArrayView<Tensor<3, spacedim>> &output) const override; |
| 210 |
|
| 211 |
// for documentation, see the Mapping base class |
| 212 |
virtual void |
| 213 |
transform(const ArrayView<const Tensor<3, dim>> &input, |
| 214 |
const MappingKind kind, |
| 215 |
const typename Mapping<dim, spacedim>::InternalDataBase &internal, |
| 216 |
const ArrayView<Tensor<3, spacedim>> &output) const override; |
| 217 |
|
| 218 |
/** |
| 219 |
* @} |
| 220 |
*/ |
| 221 |
|
| 222 |
/** |
| 223 |
* As opposed to the other fill_fe_values() and fill_fe_face_values() |
| 224 |
* functions that rely on pre-computed information of InternalDataBase, this |
| 225 |
* function chooses the flexible evaluation path on the cell and points |
| 226 |
* passed in to the current function. |
| 227 |
* |
| 228 |
* @param[in] cell The cell where to evaluate the mapping |
| 229 |
* |
| 230 |
* @param[in] unit_points The points in reference coordinates where the |
| 231 |
* transformation (Jacobians, positions) should be computed. |
| 232 |
* |
| 233 |
* @param[in] update_flags The kind of information that should be computed. |
| 234 |
* |
| 235 |
* @param[out] output_data A struct containing the evaluated quantities such |
| 236 |
* as the Jacobian resulting from application of the mapping on the given |
| 237 |
* cell with its underlying manifolds. |
| 238 |
*/ |
| 239 |
void |
| 240 |
fill_mapping_data_for_generic_points( |
| 241 |
const typename Triangulation<dim, spacedim>::cell_iterator &cell, |
| 242 |
const ArrayView<const Point<dim>> &unit_points, |
| 243 |
const UpdateFlags update_flags, |
| 244 |
internal::FEValuesImplementation::MappingRelatedData<dim, spacedim> |
| 245 |
&output_data) const; |
| 246 |
|
| 247 |
/** |
| 248 |
* As opposed to the fill_fe_face_values() |
| 249 |
* function that relies on pre-computed information of InternalDataBase, this |
| 250 |
* function chooses the flexible evaluation path on the cell and points |
| 251 |
* passed in to the current function. |
| 252 |
* |
| 253 |
* @param[in] cell The cell where to evaluate the mapping. |
| 254 |
* |
| 255 |
* @param[in] face_number The face number where to evaluate the mapping. |
| 256 |
* |
| 257 |
* @param[in] face_quadrature The quadrature points where the |
| 258 |
* transformation (Jacobians, positions) should be computed. |
| 259 |
* |
| 260 |
* @param[in] internal_data A reference to an object previously created |
| 261 |
* that may be used to store information the mapping can compute once on the |
| 262 |
* reference cell. See the documentation of the Mapping::InternalDataBase |
| 263 |
* class for an extensive description of the purpose of these objects. |
| 264 |
* |
| 265 |
* @param[out] output_data A struct containing the evaluated quantities such |
| 266 |
* as the Jacobian resulting from application of the mapping on the given |
| 267 |
* cell with its underlying manifolds. |
| 268 |
*/ |
| 269 |
void |
| 270 |
fill_mapping_data_for_face_quadrature( |
| 271 |
const typename Triangulation<dim, spacedim>::cell_iterator &cell, |
| 272 |
const unsigned int face_number, |
| 273 |
const Quadrature<dim - 1> &face_quadrature, |
| 274 |
const typename Mapping<dim, spacedim>::InternalDataBase &internal_data, |
| 275 |
internal::FEValuesImplementation::MappingRelatedData<dim, spacedim> |
| 276 |
&output_data) const; |
| 277 |
|
| 278 |
/** |
| 279 |
* @name Interface with FEValues and friends |
| 280 |
* @{ |
| 281 |
*/ |
| 282 |
|
| 283 |
/** |
| 284 |
* Storage for internal data of polynomial mappings. See |
| 285 |
* Mapping::InternalDataBase for an extensive description. |
| 286 |
* |
| 287 |
* For the current class, the InternalData class stores data that is |
| 288 |
* computed once when the object is created (in get_data()) as well as data |
| 289 |
* the class wants to store from between the call to fill_fe_values(), |
| 290 |
* fill_fe_face_values(), or fill_fe_subface_values() until possible later |
| 291 |
* calls from the finite element to functions such as transform(). The |
| 292 |
* latter class of member variables are marked as 'mutable'. |
| 293 |
*/ |
| 294 |
class InternalData : public Mapping<dim, spacedim>::InternalDataBase |
| 295 |
{ |
| 296 |
public: |
| 297 |
/** |
| 298 |
* Constructor. The argument denotes the polynomial degree of the mapping |
| 299 |
* to which this object will correspond. |
| 300 |
*/ |
| 301 |
InternalData(const unsigned int polynomial_degree); |
| 302 |
|
| 303 |
// Documentation see Mapping::InternalDataBase. |
| 304 |
virtual void |
| 305 |
reinit(const UpdateFlags update_flags, |
| 306 |
const Quadrature<dim> &quadrature) override; |
| 307 |
|
| 308 |
/** |
| 309 |
* Initialize the object's member variables related to cell and face data |
| 310 |
* based on the given arguments. In order to initialize cell data, this |
| 311 |
* function calls initialize(). |
| 312 |
*/ |
| 313 |
void |
| 314 |
initialize_face(const UpdateFlags update_flags, |
| 315 |
const Quadrature<dim> &quadrature, |
| 316 |
const unsigned int n_original_q_points); |
| 317 |
|
| 318 |
/** |
| 319 |
* Return an estimate (in bytes) for the memory consumption of this object. |
| 320 |
*/ |
| 321 |
virtual std::size_t |
| 322 |
memory_consumption() const override; |
| 323 |
|
| 324 |
/** |
| 325 |
* Location of quadrature points of faces or subfaces in 3d with all |
| 326 |
* possible orientations. Can be accessed with the correct offset provided |
| 327 |
* via QProjector::DataSetDescriptor. Not needed/used for cells. |
| 328 |
*/ |
| 329 |
std::vector<Point<dim>> quadrature_points; |
| 330 |
|
| 331 |
/** |
| 332 |
* Unit tangential vectors. Used for the computation of boundary forms and |
| 333 |
* normal vectors. |
| 334 |
* |
| 335 |
* This array has `(dim-1) * GeometryInfo::faces_per_cell` entries. The |
| 336 |
* first GeometryInfo::faces_per_cell contain the vectors in the first |
| 337 |
* tangential direction for each face; the second set of |
| 338 |
* GeometryInfo::faces_per_cell entries contain the vectors in the second |
| 339 |
* tangential direction (only in 3d, since there we have 2 tangential |
| 340 |
* directions per face), etc. |
| 341 |
* |
| 342 |
* Filled once. |
| 343 |
*/ |
| 344 |
std::array<std::vector<Tensor<1, dim>>, |
| 345 |
GeometryInfo<dim>::faces_per_cell *(dim - 1)> |
| 346 |
unit_tangentials; |
| 347 |
|
| 348 |
/** |
| 349 |
* The polynomial degree of the mapping. Since the objects here are also |
| 350 |
* used (with minor adjustments) by MappingQ, we need to store this. |
| 351 |
*/ |
| 352 |
const unsigned int polynomial_degree; |
| 353 |
|
| 354 |
/** |
| 355 |
* Number of shape functions. If this is a Q1 mapping, then it is simply |
| 356 |
* the number of vertices per cell. However, since also derived classes |
| 357 |
* use this class (e.g. the Mapping_Q() class), the number of shape |
| 358 |
* functions may also be different. |
| 359 |
* |
| 360 |
* In general, it is $(p+1)^\text{dim}$, where $p$ is the polynomial |
| 361 |
* degree of the mapping. |
| 362 |
*/ |
| 363 |
const unsigned int n_shape_functions; |
| 364 |
|
| 365 |
/* |
| 366 |
* The default line support points. Is used in when the shape function |
| 367 |
* values are computed. |
| 368 |
* |
| 369 |
* The number of quadrature points depends on the degree of this |
| 370 |
* class, and it matches the number of degrees of freedom of an |
| 371 |
* FE_Q<1>(this->degree). |
| 372 |
*/ |
| 373 |
QGaussLobatto<1> line_support_points; |
| 374 |
|
| 375 |
/** |
| 376 |
* For the fast tensor-product path of the MappingQ class, we choose SIMD |
| 377 |
* vectors that are as wide as possible to minimize the number of |
| 378 |
* arithmetic operations. However, we do not want to choose it wider than |
| 379 |
* necessary, e.g., we avoid something like 8-wide AVX-512 when we only |
| 380 |
* compute 3 components of a 3d computation. This is because the |
| 381 |
* additional lanes would not do useful work, but a few operations on very |
| 382 |
* wide vectors can already lead to a lower clock frequency of processors |
| 383 |
* over long time spans (thousands of clock cycles). Hence, we choose |
| 384 |
* 2-wide SIMD for 1D and 2d and 4-wide SIMD for 3d. Note that we do not |
| 385 |
* immediately fall back to no SIMD for 1d because all architectures that |
| 386 |
* support SIMD also support 128-bit vectors (and none is reported to |
| 387 |
* reduce clock frequency for 128-bit SIMD). |
| 388 |
*/ |
| 389 |
using VectorizedArrayType = |
| 390 |
VectorizedArray<double, |
| 391 |
std::min<std::size_t>(VectorizedArray<double>::size(), |
| 392 |
(dim <= 2 ? 2 : 4))>; |
| 393 |
|
| 394 |
/** |
| 395 |
* In case the quadrature rule given represents a tensor product |
| 396 |
* we need to store the evaluations of the 1d polynomials at |
| 397 |
* the 1d quadrature points. That is what this variable is for. |
| 398 |
*/ |
| 399 |
internal::MatrixFreeFunctions::ShapeInfo<double> shape_info; |
| 400 |
|
| 401 |
/** |
| 402 |
* In case the quadrature rule given represents a tensor product |
| 403 |
* we need to store temporary data in this object. |
| 404 |
*/ |
| 405 |
mutable AlignedVector<VectorizedArrayType> scratch; |
| 406 |
|
| 407 |
/** |
| 408 |
* Indicates whether the given Quadrature object is a tensor product. |
| 409 |
*/ |
| 410 |
bool tensor_product_quadrature; |
| 411 |
|
| 412 |
/** |
| 413 |
* Auxiliary vectors for internal use. |
| 414 |
*/ |
| 415 |
mutable std::vector<AlignedVector<Tensor<1, spacedim>>> aux; |
| 416 |
|
| 417 |
/** |
| 418 |
* Stores the support points of the mapping shape functions on the @p |
| 419 |
* cell_of_current_support_points. |
| 420 |
*/ |
| 421 |
mutable std::vector<Point<spacedim>> mapping_support_points; |
| 422 |
|
| 423 |
/** |
| 424 |
* Stores the cell of which the @p mapping_support_points are stored. |
| 425 |
*/ |
| 426 |
mutable typename Triangulation<dim, spacedim>::cell_iterator |
| 427 |
cell_of_current_support_points; |
| 428 |
|
| 429 |
/** |
| 430 |
* The determinant of the Jacobian in each quadrature point. Filled if |
| 431 |
* #update_volume_elements. |
| 432 |
*/ |
| 433 |
mutable AlignedVector<double> volume_elements; |
| 434 |
|
| 435 |
/** |
| 436 |
* Pointer to the mapping output data that holds most of the arrays, |
| 437 |
* including the Jacobians representing the covariant and contravariant |
| 438 |
* transformations. |
| 439 |
*/ |
| 440 |
mutable internal::FEValuesImplementation::MappingRelatedData<dim, spacedim> |
| 441 |
*output_data; |
| 442 |
}; |
| 443 |
|
| 444 |
protected: |
| 445 |
// documentation can be found in Mapping::requires_update_flags() |
| 446 |
virtual UpdateFlags |
| 447 |
requires_update_flags(const UpdateFlags update_flags) const override; |
| 448 |
|
| 449 |
// documentation can be found in Mapping::get_data() |
| 450 |
virtual std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase> |
| 451 |
get_data(const UpdateFlags, const Quadrature<dim> &quadrature) const override; |
| 452 |
|
| 453 |
using Mapping<dim, spacedim>::get_face_data; |
| 454 |
|
| 455 |
// documentation can be found in Mapping::get_face_data() |
| 456 |
virtual std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase> |
| 457 |
get_face_data(const UpdateFlags flags, |
| 458 |
const hp::QCollection<dim - 1> &quadrature) const override; |
| 459 |
|
| 460 |
// documentation can be found in Mapping::get_subface_data() |
| 461 |
virtual std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase> |
| 462 |
get_subface_data(const UpdateFlags flags, |
| 463 |
const Quadrature<dim - 1> &quadrature) const override; |
| 464 |
|
| 465 |
// documentation can be found in Mapping::fill_fe_values() |
| 466 |
virtual CellSimilarity::Similarity |
| 467 |
fill_fe_values( |
| 468 |
const typename Triangulation<dim, spacedim>::cell_iterator &cell, |
| 469 |
const CellSimilarity::Similarity cell_similarity, |
| 470 |
const Quadrature<dim> &quadrature, |
| 471 |
const typename Mapping<dim, spacedim>::InternalDataBase &internal_data, |
| 472 |
internal::FEValuesImplementation::MappingRelatedData<dim, spacedim> |
| 473 |
&output_data) const override; |
| 474 |
|
| 475 |
using Mapping<dim, spacedim>::fill_fe_face_values; |
| 476 |
|
| 477 |
// documentation can be found in Mapping::fill_fe_face_values() |
| 478 |
virtual void |
| 479 |
fill_fe_face_values( |
| 480 |
const typename Triangulation<dim, spacedim>::cell_iterator &cell, |
| 481 |
const unsigned int face_no, |
| 482 |
const hp::QCollection<dim - 1> &quadrature, |
| 483 |
const typename Mapping<dim, spacedim>::InternalDataBase &internal_data, |
| 484 |
internal::FEValuesImplementation::MappingRelatedData<dim, spacedim> |
| 485 |
&output_data) const override; |
| 486 |
|
| 487 |
// documentation can be found in Mapping::fill_fe_subface_values() |
| 488 |
virtual void |
| 489 |
fill_fe_subface_values( |
| 490 |
const typename Triangulation<dim, spacedim>::cell_iterator &cell, |
| 491 |
const unsigned int face_no, |
| 492 |
const unsigned int subface_no, |
| 493 |
const Quadrature<dim - 1> &quadrature, |
| 494 |
const typename Mapping<dim, spacedim>::InternalDataBase &internal_data, |
| 495 |
internal::FEValuesImplementation::MappingRelatedData<dim, spacedim> |
| 496 |
&output_data) const override; |
| 497 |
|
| 498 |
// documentation can be found in Mapping::fill_fe_immersed_surface_values() |
| 499 |
virtual void |
| 500 |
fill_fe_immersed_surface_values( |
| 501 |
const typename Triangulation<dim, spacedim>::cell_iterator &cell, |
| 502 |
const NonMatching::ImmersedSurfaceQuadrature<dim> &quadrature, |
| 503 |
const typename Mapping<dim, spacedim>::InternalDataBase &internal_data, |
| 504 |
internal::FEValuesImplementation::MappingRelatedData<dim, spacedim> |
| 505 |
&output_data) const override; |
| 506 |
|
| 507 |
/** |
| 508 |
* @} |
| 509 |
*/ |
| 510 |
|
| 511 |
/** |
| 512 |
* The degree of the polynomials used as shape functions for the mapping of |
| 513 |
* cells. |
| 514 |
*/ |
| 515 |
const unsigned int polynomial_degree; |
| 516 |
|
| 517 |
/* |
| 518 |
* The default line support points. These are used when computing the |
| 519 |
* location in real space of the support points on lines and quads, which |
| 520 |
* are needed by the Manifold<dim,spacedim> class. |
| 521 |
* |
| 522 |
* The number of points depends on the degree of this class, and it matches |
| 523 |
* the number of degrees of freedom of an FE_Q<1>(this->degree). |
| 524 |
*/ |
| 525 |
const std::vector<Point<1>> line_support_points; |
| 526 |
|
| 527 |
/* |
| 528 |
* The one-dimensional polynomials defined as Lagrange polynomials from the |
| 529 |
* line support points. These are used for point evaluations and match the |
| 530 |
* polynomial space of an FE_Q<1>(this->degree). |
| 531 |
*/ |
| 532 |
const std::vector<Polynomials::Polynomial<double>> polynomials_1d; |
| 533 |
|
| 534 |
/* |
| 535 |
* The numbering from the lexicographic to the hierarchical ordering used |
| 536 |
* when expanding the tensor product with the mapping support points (which |
| 537 |
* come in hierarchical numbers). |
| 538 |
*/ |
| 539 |
const std::vector<unsigned int> renumber_lexicographic_to_hierarchic; |
| 540 |
|
| 541 |
/* |
| 542 |
* The support points in reference coordinates. These are used for |
| 543 |
* constructing approximations of the output of |
| 544 |
* compute_mapping_support_points() when evaluating the mapping on the fly, |
| 545 |
* rather than going through the FEValues interface provided by |
| 546 |
* InternalData. |
| 547 |
* |
| 548 |
* The number of points depends on the degree of this class, and it matches |
| 549 |
* the number of degrees of freedom of an FE_Q<dim>(this->degree). |
| 550 |
*/ |
| 551 |
const std::vector<Point<dim>> unit_cell_support_points; |
| 552 |
|
| 553 |
/** |
| 554 |
* A vector of tables of weights by which we multiply the locations of the |
| 555 |
* support points on the perimeter of an object (line, quad, hex) to get the |
| 556 |
* location of interior support points. |
| 557 |
* |
| 558 |
* Access into this table is by @p [structdim-1], i.e., use 0 to access the |
| 559 |
* support point weights on a line (i.e., the interior points of the |
| 560 |
* GaussLobatto quadrature), use 1 to access the support point weights from |
| 561 |
* to perimeter to the interior of a quad, and use 2 to access the support |
| 562 |
* point weights from the perimeter to the interior of a hex. |
| 563 |
* |
| 564 |
* The table itself contains as many columns as there are surrounding points |
| 565 |
* to a particular object (2 for a line, <code>4 + 4*(degree-1)</code> for |
| 566 |
* a quad, <code>8 + 12*(degree-1) + 6*(degree-1)*(degree-1)</code> for a |
| 567 |
* hex) and as many rows as there are strictly interior points. |
| 568 |
* |
| 569 |
* For the definition of this table see equation (8) of the `mapping' |
| 570 |
* report. |
| 571 |
*/ |
| 572 |
const std::vector<Table<2, double>> |
| 573 |
support_point_weights_perimeter_to_interior; |
| 574 |
|
| 575 |
/** |
| 576 |
* A table of weights by which we multiply the locations of the vertex |
| 577 |
* points of the cell to get the location of all additional support points, |
| 578 |
* both on lines, quads, and hexes (as appropriate). This data structure is |
| 579 |
* used when we fill all support points at once, which is the case if the |
| 580 |
* same manifold is attached to all sub-entities of a cell. This way, we can |
| 581 |
* avoid some of the overhead in transforming data for mappings. |
| 582 |
* |
| 583 |
* The table has as many rows as there are vertices to the cell (2 in 1d, 4 |
| 584 |
* in 2d, 8 in 3d), and as many rows as there are additional support points |
| 585 |
* in the mapping, i.e., <code>(degree+1)^dim - 2^dim</code>. |
| 586 |
*/ |
| 587 |
const Table<2, double> support_point_weights_cell; |
| 588 |
|
| 589 |
/** |
| 590 |
* Return the locations of support points for the mapping. For example, for |
| 591 |
* $Q_1$ mappings these are the vertices, and for higher order polynomial |
| 592 |
* mappings they are the vertices plus interior points on edges, faces, and |
| 593 |
* the cell interior that are placed in consultation with the Manifold |
| 594 |
* description of the domain and its boundary. However, other classes may |
| 595 |
* override this function differently. In particular, the MappingQ1Eulerian |
| 596 |
* class does exactly this by not computing the support points from the |
| 597 |
* geometry of the current cell but instead evaluating an externally given |
| 598 |
* displacement field in addition to the geometry of the cell. |
| 599 |
* |
| 600 |
* The default implementation of this function is appropriate for most |
| 601 |
* cases. It takes the locations of support points on the boundary of the |
| 602 |
* cell from the underlying manifold. Interior support points (ie. support |
| 603 |
* points in quads for 2d, in hexes for 3d) are then computed using an |
| 604 |
* interpolation from the lower-dimensional entities (lines, quads) in order |
| 605 |
* to make the transformation as smooth as possible without introducing |
| 606 |
* additional boundary layers within the cells due to the placement of |
| 607 |
* support points. |
| 608 |
* |
| 609 |
* The function works its way from the vertices (which it takes from the |
| 610 |
* given cell) via the support points on the line (for which it calls the |
| 611 |
* add_line_support_points() function) and the support points on the quad |
| 612 |
* faces (in 3d, for which it calls the add_quad_support_points() function). |
| 613 |
* It then adds interior support points that are either computed by |
| 614 |
* interpolation from the surrounding points using weights for transfinite |
| 615 |
* interpolation, or if dim<spacedim, it asks the underlying manifold for |
| 616 |
* the locations of interior points. |
| 617 |
*/ |
| 618 |
virtual std::vector<Point<spacedim>> |
| 619 |
compute_mapping_support_points( |
| 620 |
const typename Triangulation<dim, spacedim>::cell_iterator &cell) const; |
| 621 |
|
| 622 |
/** |
| 623 |
* Transform the point @p p on the real cell to the corresponding point on |
| 624 |
* the unit cell @p cell by a Newton iteration. |
| 625 |
*/ |
| 626 |
Point<dim> |
| 627 |
transform_real_to_unit_cell_internal( |
| 628 |
const typename Triangulation<dim, spacedim>::cell_iterator &cell, |
| 629 |
const Point<spacedim> &p, |
| 630 |
const Point<dim> &initial_p_unit) const; |
| 631 |
|
| 632 |
/** |
| 633 |
* Append the support points of all shape functions located on bounding |
| 634 |
* lines of the given cell to the vector @p a. Points located on the |
| 635 |
* vertices of a line are not included. |
| 636 |
* |
| 637 |
* This function uses the underlying manifold object of the line (or, if |
| 638 |
* none is set, of the cell) for the location of the requested points. This |
| 639 |
* function is usually called by compute_mapping_support_points() function. |
| 640 |
* |
| 641 |
* This function is made virtual in order to allow derived classes to choose |
| 642 |
* shape function support points differently than the present class, which |
| 643 |
* chooses the points as interpolation points on the boundary. |
| 644 |
*/ |
| 645 |
virtual void |
| 646 |
add_line_support_points( |
| 647 |
const typename Triangulation<dim, spacedim>::cell_iterator &cell, |
| 648 |
std::vector<Point<spacedim>> &a) const; |
| 649 |
|
| 650 |
/** |
| 651 |
* Append the support points of all shape functions located on bounding |
| 652 |
* faces (quads in 3d) of the given cell to the vector @p a. This function |
| 653 |
* is only defined for <tt>dim=3</tt>. Points located on the vertices or |
| 654 |
* lines of a quad are not included. |
| 655 |
* |
| 656 |
* This function uses the underlying manifold object of the quad (or, if |
| 657 |
* none is set, of the cell) for the location of the requested points. This |
| 658 |
* function is usually called by compute_mapping_support_points(). |
| 659 |
* |
| 660 |
* This function is made virtual in order to allow derived classes to choose |
| 661 |
* shape function support points differently than the present class, which |
| 662 |
* chooses the points as interpolation points on the boundary. |
| 663 |
*/ |
| 664 |
virtual void |
| 665 |
add_quad_support_points( |
| 666 |
const typename Triangulation<dim, spacedim>::cell_iterator &cell, |
| 667 |
std::vector<Point<spacedim>> &a) const; |
| 668 |
|
| 669 |
// Make MappingQCache a friend since it needs to call the |
| 670 |
// compute_mapping_support_points() function. |
| 671 |
template <int, int> |
| 672 |
friend class MappingQCache; |
| 673 |
}; |
| 674 |
|
| 675 |
|
| 676 |
|
| 677 |
/** |
| 678 |
* A class that implements a polynomial mapping $Q_p$ of degree $p$ on all |
| 679 |
* cells. This class is completely equivalent to the MappingQ class and there |
| 680 |
* for backward compatibility. |
| 681 |
*/ |
| 682 |
template <int dim, int spacedim = dim> |
| 683 |
using MappingQGeneric = MappingQ<dim, spacedim>; |
| 684 |
|
| 685 |
/** @} */ |
| 686 |
|
| 687 |
|
| 688 |
/*----------------------------------------------------------------------*/ |
| 689 |
|
| 690 |
#ifndef DOXYGEN |
| 691 |
|
| 692 |
template <int dim, int spacedim> |
| 693 |
inline bool |
| 694 |
MappingQ<dim, spacedim>::preserves_vertex_locations() const |
| 695 |
{ |
| 696 |
return true; |
| 697 |
} |
| 698 |
|
| 699 |
#endif // DOXYGEN |
| 700 |
|
| 701 |
/* -------------- declaration of explicit specializations ------------- */ |
| 702 |
|
| 703 |
|
| 704 |
DEAL_II_NAMESPACE_CLOSE |
| 705 |
|
| 706 |
#endif |