| 1 |
// ------------------------------------------------------------------------ |
| 2 |
// |
| 3 |
// SPDX-License-Identifier: LGPL-2.1-or-later |
| 4 |
// Copyright (C) 2015 - 2025 by the deal.II authors |
| 5 |
// |
| 6 |
// This file is part of the deal.II library. |
| 7 |
// |
| 8 |
// Part of the source code is dual licensed under Apache-2.0 WITH |
| 9 |
// LLVM-exception OR LGPL-2.1-or-later. Detailed license information |
| 10 |
// governing the source code and code contributions can be found in |
| 11 |
// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II. |
| 12 |
// |
| 13 |
// ------------------------------------------------------------------------ |
| 14 |
|
| 15 |
#ifndef dealii_mapping_fe_field_templates_h |
| 16 |
#define dealii_mapping_fe_field_templates_h |
| 17 |
|
| 18 |
#include <deal.II/base/array_view.h> |
| 19 |
#include <deal.II/base/memory_consumption.h> |
| 20 |
#include <deal.II/base/polynomial.h> |
| 21 |
#include <deal.II/base/qprojector.h> |
| 22 |
#include <deal.II/base/quadrature.h> |
| 23 |
#include <deal.II/base/quadrature_lib.h> |
| 24 |
#include <deal.II/base/tensor_product_polynomials.h> |
| 25 |
#include <deal.II/base/utilities.h> |
| 26 |
|
| 27 |
#include <deal.II/dofs/dof_accessor.h> |
| 28 |
|
| 29 |
#include <deal.II/fe/fe_q.h> |
| 30 |
#include <deal.II/fe/fe_system.h> |
| 31 |
#include <deal.II/fe/fe_tools.h> |
| 32 |
#include <deal.II/fe/fe_values.h> |
| 33 |
#include <deal.II/fe/mapping.h> |
| 34 |
#include <deal.II/fe/mapping_fe_field.h> |
| 35 |
#include <deal.II/fe/mapping_internal.h> |
| 36 |
|
| 37 |
#include <deal.II/grid/tria_iterator.h> |
| 38 |
|
| 39 |
#include <deal.II/lac/block_vector.h> |
| 40 |
#include <deal.II/lac/full_matrix.h> |
| 41 |
#include <deal.II/lac/la_parallel_block_vector.h> |
| 42 |
#include <deal.II/lac/la_parallel_vector.h> |
| 43 |
#include <deal.II/lac/petsc_block_vector.h> |
| 44 |
#include <deal.II/lac/petsc_vector.h> |
| 45 |
#include <deal.II/lac/trilinos_epetra_vector.h> |
| 46 |
#include <deal.II/lac/trilinos_parallel_block_vector.h> |
| 47 |
#include <deal.II/lac/trilinos_tpetra_block_vector.h> |
| 48 |
#include <deal.II/lac/trilinos_tpetra_vector.h> |
| 49 |
#include <deal.II/lac/trilinos_vector.h> |
| 50 |
#include <deal.II/lac/vector.h> |
| 51 |
|
| 52 |
#include <deal.II/numerics/vector_tools.h> |
| 53 |
|
| 54 |
#include <fstream> |
| 55 |
#include <memory> |
| 56 |
#include <numeric> |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
DEAL_II_NAMESPACE_OPEN |
| 61 |
|
| 62 |
|
| 63 |
template <int dim, int spacedim, typename VectorType> |
| 64 |
MappingFEField<dim, spacedim, VectorType>::InternalData::InternalData( |
| 65 |
const FiniteElement<dim, spacedim> &fe, |
| 66 |
const ComponentMask &mask) |
| 67 |
: fe(&fe) |
| 68 |
, unit_tangentials() |
| 69 |
, n_shape_functions(fe.n_dofs_per_cell()) |
| 70 |
, mask(mask) |
| 71 |
, local_dof_indices(fe.n_dofs_per_cell()) |
| 72 |
, local_dof_values(fe.n_dofs_per_cell()) |
| 73 |
{} |
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
template <int dim, int spacedim, typename VectorType> |
| 78 |
void |
| 79 |
MappingFEField<dim, spacedim, VectorType>::InternalData::reinit( |
| 80 |
const UpdateFlags update_flags, |
| 81 |
const Quadrature<dim> &quadrature) |
| 82 |
{ |
| 83 |
// store the flags in the internal data object so we can access them |
| 84 |
// in fill_fe_*_values(). use the transitive hull of the required |
| 85 |
// flags |
| 86 |
this->update_each = update_flags; |
| 87 |
|
| 88 |
const unsigned int n_q_points = quadrature.size(); |
| 89 |
const std::vector<Point<dim>> &points = quadrature.get_points(); |
| 90 |
|
| 91 |
// see if we need the (transformation) shape function values |
| 92 |
// and/or gradients and resize the necessary arrays |
| 93 |
if (update_flags & update_quadrature_points) |
| 94 |
{ |
| 95 |
shape_values.resize(n_shape_functions * n_q_points); |
| 96 |
for (unsigned int point = 0; point < n_q_points; ++point) |
| 97 |
for (unsigned int i = 0; i < n_shape_functions; ++i) |
| 98 |
shape(point, i) = fe->shape_value(i, points[point]); |
| 99 |
} |
| 100 |
|
| 101 |
if (update_flags & |
| 102 |
(update_covariant_transformation | update_contravariant_transformation | |
| 103 |
update_JxW_values | update_boundary_forms | update_normal_vectors | |
| 104 |
update_jacobians | update_jacobian_grads | update_inverse_jacobians)) |
| 105 |
{ |
| 106 |
shape_derivatives.resize(n_shape_functions * n_q_points); |
| 107 |
for (unsigned int point = 0; point < n_q_points; ++point) |
| 108 |
for (unsigned int i = 0; i < n_shape_functions; ++i) |
| 109 |
derivative(point, i) = fe->shape_grad(i, points[point]); |
| 110 |
} |
| 111 |
|
| 112 |
if (update_flags & update_covariant_transformation) |
| 113 |
covariant.resize(n_q_points); |
| 114 |
|
| 115 |
if (update_flags & update_contravariant_transformation) |
| 116 |
contravariant.resize(n_q_points); |
| 117 |
|
| 118 |
if (update_flags & update_volume_elements) |
| 119 |
volume_elements.resize(n_q_points); |
| 120 |
|
| 121 |
if (update_flags & |
| 122 |
(update_jacobian_grads | update_jacobian_pushed_forward_grads)) |
| 123 |
{ |
| 124 |
shape_second_derivatives.resize(n_shape_functions * n_q_points); |
| 125 |
for (unsigned int point = 0; point < n_q_points; ++point) |
| 126 |
for (unsigned int i = 0; i < n_shape_functions; ++i) |
| 127 |
second_derivative(point, i) = fe->shape_grad_grad(i, points[point]); |
| 128 |
} |
| 129 |
|
| 130 |
if (update_flags & (update_jacobian_2nd_derivatives | |
| 131 |
update_jacobian_pushed_forward_2nd_derivatives)) |
| 132 |
{ |
| 133 |
shape_third_derivatives.resize(n_shape_functions * n_q_points); |
| 134 |
for (unsigned int point = 0; point < n_q_points; ++point) |
| 135 |
for (unsigned int i = 0; i < n_shape_functions; ++i) |
| 136 |
third_derivative(point, i) = |
| 137 |
fe->shape_3rd_derivative(i, points[point]); |
| 138 |
} |
| 139 |
|
| 140 |
if (update_flags & (update_jacobian_3rd_derivatives | |
| 141 |
update_jacobian_pushed_forward_3rd_derivatives)) |
| 142 |
{ |
| 143 |
shape_fourth_derivatives.resize(n_shape_functions * n_q_points); |
| 144 |
for (unsigned int point = 0; point < n_q_points; ++point) |
| 145 |
for (unsigned int i = 0; i < n_shape_functions; ++i) |
| 146 |
fourth_derivative(point, i) = |
| 147 |
fe->shape_4th_derivative(i, points[point]); |
| 148 |
} |
| 149 |
|
| 150 |
// This (for face values and simplices) can be different for different |
| 151 |
// calls, so always copy |
| 152 |
quadrature_weights = quadrature.get_weights(); |
| 153 |
} |
| 154 |
|
| 155 |
|
| 156 |
|
| 157 |
template <int dim, int spacedim, typename VectorType> |
| 158 |
std::size_t |
| 159 |
MappingFEField<dim, spacedim, VectorType>::InternalData::memory_consumption() |
| 160 |
const |
| 161 |
{ |
| 162 |
DEAL_II_NOT_IMPLEMENTED(); |
| 163 |
return 0; |
| 164 |
} |
| 165 |
|
| 166 |
|
| 167 |
|
| 168 |
template <int dim, int spacedim, typename VectorType> |
| 169 |
double & |
| 170 |
MappingFEField<dim, spacedim, VectorType>::InternalData::shape( |
| 171 |
const unsigned int qpoint, |
| 172 |
const unsigned int shape_nr) |
| 173 |
{ |
| 174 |
AssertIndexRange(qpoint * n_shape_functions + shape_nr, shape_values.size()); |
| 175 |
return shape_values[qpoint * n_shape_functions + shape_nr]; |
| 176 |
} |
| 177 |
|
| 178 |
|
| 179 |
template <int dim, int spacedim, typename VectorType> |
| 180 |
const Tensor<1, dim> & |
| 181 |
MappingFEField<dim, spacedim, VectorType>::InternalData::derivative( |
| 182 |
const unsigned int qpoint, |
| 183 |
const unsigned int shape_nr) const |
| 184 |
{ |
| 185 |
AssertIndexRange(qpoint * n_shape_functions + shape_nr, |
| 186 |
shape_derivatives.size()); |
| 187 |
return shape_derivatives[qpoint * n_shape_functions + shape_nr]; |
| 188 |
} |
| 189 |
|
| 190 |
|
| 191 |
|
| 192 |
template <int dim, int spacedim, typename VectorType> |
| 193 |
Tensor<1, dim> & |
| 194 |
MappingFEField<dim, spacedim, VectorType>::InternalData::derivative( |
| 195 |
const unsigned int qpoint, |
| 196 |
const unsigned int shape_nr) |
| 197 |
{ |
| 198 |
AssertIndexRange(qpoint * n_shape_functions + shape_nr, |
| 199 |
shape_derivatives.size()); |
| 200 |
return shape_derivatives[qpoint * n_shape_functions + shape_nr]; |
| 201 |
} |
| 202 |
|
| 203 |
|
| 204 |
template <int dim, int spacedim, typename VectorType> |
| 205 |
const Tensor<2, dim> & |
| 206 |
MappingFEField<dim, spacedim, VectorType>::InternalData::second_derivative( |
| 207 |
const unsigned int qpoint, |
| 208 |
const unsigned int shape_nr) const |
| 209 |
{ |
| 210 |
AssertIndexRange(qpoint * n_shape_functions + shape_nr, |
| 211 |
shape_second_derivatives.size()); |
| 212 |
return shape_second_derivatives[qpoint * n_shape_functions + shape_nr]; |
| 213 |
} |
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
template <int dim, int spacedim, typename VectorType> |
| 218 |
Tensor<2, dim> & |
| 219 |
MappingFEField<dim, spacedim, VectorType>::InternalData::second_derivative( |
| 220 |
const unsigned int qpoint, |
| 221 |
const unsigned int shape_nr) |
| 222 |
{ |
| 223 |
AssertIndexRange(qpoint * n_shape_functions + shape_nr, |
| 224 |
shape_second_derivatives.size()); |
| 225 |
return shape_second_derivatives[qpoint * n_shape_functions + shape_nr]; |
| 226 |
} |
| 227 |
|
| 228 |
|
| 229 |
template <int dim, int spacedim, typename VectorType> |
| 230 |
const Tensor<3, dim> & |
| 231 |
MappingFEField<dim, spacedim, VectorType>::InternalData::third_derivative( |
| 232 |
const unsigned int qpoint, |
| 233 |
const unsigned int shape_nr) const |
| 234 |
{ |
| 235 |
AssertIndexRange(qpoint * n_shape_functions + shape_nr, |
| 236 |
shape_third_derivatives.size()); |
| 237 |
return shape_third_derivatives[qpoint * n_shape_functions + shape_nr]; |
| 238 |
} |
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
template <int dim, int spacedim, typename VectorType> |
| 243 |
Tensor<3, dim> & |
| 244 |
MappingFEField<dim, spacedim, VectorType>::InternalData::third_derivative( |
| 245 |
const unsigned int qpoint, |
| 246 |
const unsigned int shape_nr) |
| 247 |
{ |
| 248 |
AssertIndexRange(qpoint * n_shape_functions + shape_nr, |
| 249 |
shape_third_derivatives.size()); |
| 250 |
return shape_third_derivatives[qpoint * n_shape_functions + shape_nr]; |
| 251 |
} |
| 252 |
|
| 253 |
|
| 254 |
template <int dim, int spacedim, typename VectorType> |
| 255 |
const Tensor<4, dim> & |
| 256 |
MappingFEField<dim, spacedim, VectorType>::InternalData::fourth_derivative( |
| 257 |
const unsigned int qpoint, |
| 258 |
const unsigned int shape_nr) const |
| 259 |
{ |
| 260 |
AssertIndexRange(qpoint * n_shape_functions + shape_nr, |
| 261 |
shape_fourth_derivatives.size()); |
| 262 |
return shape_fourth_derivatives[qpoint * n_shape_functions + shape_nr]; |
| 263 |
} |
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
template <int dim, int spacedim, typename VectorType> |
| 268 |
Tensor<4, dim> & |
| 269 |
MappingFEField<dim, spacedim, VectorType>::InternalData::fourth_derivative( |
| 270 |
const unsigned int qpoint, |
| 271 |
const unsigned int shape_nr) |
| 272 |
{ |
| 273 |
AssertIndexRange(qpoint * n_shape_functions + shape_nr, |
| 274 |
shape_fourth_derivatives.size()); |
| 275 |
return shape_fourth_derivatives[qpoint * n_shape_functions + shape_nr]; |
| 276 |
} |
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
template <int dim, int spacedim, typename VectorType> |
| 281 |
MappingFEField<dim, spacedim, VectorType>::MappingFEField( |
| 282 |
const DoFHandler<dim, spacedim> &euler_dof_handler, |
| 283 |
const VectorType &euler_vector, |
| 284 |
const ComponentMask &mask) |
| 285 |
: reference_cell(euler_dof_handler.get_fe().reference_cell()) |
| 286 |
, uses_level_dofs(false) |
| 287 |
, euler_vector({&euler_vector}) |
| 288 |
, euler_dof_handler(&euler_dof_handler) |
| 289 |
, fe_mask(mask.size() != 0u ? |
| 290 |
mask : |
| 291 |
ComponentMask( |
| 292 |
euler_dof_handler.get_fe().get_nonzero_components(0).size(), |
| 293 |
true)) |
| 294 |
, fe_to_real(fe_mask.size(), numbers::invalid_unsigned_int) |
| 295 |
, fe_values(this->euler_dof_handler->get_fe(), |
| 296 |
reference_cell.template get_nodal_type_quadrature<dim>(), |
| 297 |
update_values) |
| 298 |
{ |
| 299 |
AssertDimension(euler_dof_handler.n_dofs(), euler_vector.size()); |
| 300 |
unsigned int size = 0; |
| 301 |
for (unsigned int i = 0; i < fe_mask.size(); ++i) |
| 302 |
{ |
| 303 |
if (fe_mask[i]) |
| 304 |
fe_to_real[i] = size++; |
| 305 |
} |
| 306 |
AssertDimension(size, spacedim); |
| 307 |
} |
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
template <int dim, int spacedim, typename VectorType> |
| 312 |
MappingFEField<dim, spacedim, VectorType>::MappingFEField( |
| 313 |
const DoFHandler<dim, spacedim> &euler_dof_handler, |
| 314 |
const std::vector<VectorType> &euler_vector, |
| 315 |
const ComponentMask &mask) |
| 316 |
: reference_cell(euler_dof_handler.get_fe().reference_cell()) |
| 317 |
, uses_level_dofs(true) |
| 318 |
, euler_dof_handler(&euler_dof_handler) |
| 319 |
, fe_mask(mask.size() != 0u ? |
| 320 |
mask : |
| 321 |
ComponentMask( |
| 322 |
euler_dof_handler.get_fe().get_nonzero_components(0).size(), |
| 323 |
true)) |
| 324 |
, fe_to_real(fe_mask.size(), numbers::invalid_unsigned_int) |
| 325 |
, fe_values(this->euler_dof_handler->get_fe(), |
| 326 |
reference_cell.template get_nodal_type_quadrature<dim>(), |
| 327 |
update_values) |
| 328 |
{ |
| 329 |
unsigned int size = 0; |
| 330 |
for (unsigned int i = 0; i < fe_mask.size(); ++i) |
| 331 |
{ |
| 332 |
if (fe_mask[i]) |
| 333 |
fe_to_real[i] = size++; |
| 334 |
} |
| 335 |
AssertDimension(size, spacedim); |
| 336 |
|
| 337 |
Assert(euler_dof_handler.has_level_dofs(), |
| 338 |
ExcMessage("The underlying DoFHandler object did not call " |
| 339 |
"distribute_mg_dofs(). In this case, the construction via " |
| 340 |
"level vectors does not make sense.")); |
| 341 |
AssertDimension(euler_vector.size(), |
| 342 |
euler_dof_handler.get_triangulation().n_global_levels()); |
| 343 |
this->euler_vector.clear(); |
| 344 |
this->euler_vector.resize(euler_vector.size()); |
| 345 |
for (unsigned int i = 0; i < euler_vector.size(); ++i) |
| 346 |
{ |
| 347 |
AssertDimension(euler_dof_handler.n_dofs(i), euler_vector[i].size()); |
| 348 |
this->euler_vector[i] = &euler_vector[i]; |
| 349 |
} |
| 350 |
} |
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
template <int dim, int spacedim, typename VectorType> |
| 355 |
MappingFEField<dim, spacedim, VectorType>::MappingFEField( |
| 356 |
const DoFHandler<dim, spacedim> &euler_dof_handler, |
| 357 |
const MGLevelObject<VectorType> &euler_vector, |
| 358 |
const ComponentMask &mask) |
| 359 |
: reference_cell(euler_dof_handler.get_fe().reference_cell()) |
| 360 |
, uses_level_dofs(true) |
| 361 |
, euler_dof_handler(&euler_dof_handler) |
| 362 |
, fe_mask(mask.size() != 0u ? |
| 363 |
mask : |
| 364 |
ComponentMask( |
| 365 |
euler_dof_handler.get_fe().get_nonzero_components(0).size(), |
| 366 |
true)) |
| 367 |
, fe_to_real(fe_mask.size(), numbers::invalid_unsigned_int) |
| 368 |
, fe_values(this->euler_dof_handler->get_fe(), |
| 369 |
reference_cell.template get_nodal_type_quadrature<dim>(), |
| 370 |
update_values) |
| 371 |
{ |
| 372 |
unsigned int size = 0; |
| 373 |
for (unsigned int i = 0; i < fe_mask.size(); ++i) |
| 374 |
{ |
| 375 |
if (fe_mask[i]) |
| 376 |
fe_to_real[i] = size++; |
| 377 |
} |
| 378 |
AssertDimension(size, spacedim); |
| 379 |
|
| 380 |
Assert(euler_dof_handler.has_level_dofs(), |
| 381 |
ExcMessage("The underlying DoFHandler object did not call " |
| 382 |
"distribute_mg_dofs(). In this case, the construction via " |
| 383 |
"level vectors does not make sense.")); |
| 384 |
AssertDimension(euler_vector.max_level() + 1, |
| 385 |
euler_dof_handler.get_triangulation().n_global_levels()); |
| 386 |
this->euler_vector.clear(); |
| 387 |
this->euler_vector.resize( |
| 388 |
euler_dof_handler.get_triangulation().n_global_levels()); |
| 389 |
for (unsigned int i = euler_vector.min_level(); i <= euler_vector.max_level(); |
| 390 |
++i) |
| 391 |
{ |
| 392 |
AssertDimension(euler_dof_handler.n_dofs(i), euler_vector[i].size()); |
| 393 |
this->euler_vector[i] = &euler_vector[i]; |
| 394 |
} |
| 395 |
} |
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
template <int dim, int spacedim, typename VectorType> |
| 400 |
MappingFEField<dim, spacedim, VectorType>::MappingFEField( |
| 401 |
const MappingFEField<dim, spacedim, VectorType> &mapping) |
| 402 |
: reference_cell(mapping.reference_cell) |
| 403 |
, uses_level_dofs(mapping.uses_level_dofs) |
| 404 |
, euler_vector(mapping.euler_vector) |
| 405 |
, euler_dof_handler(mapping.euler_dof_handler) |
| 406 |
, fe_mask(mapping.fe_mask) |
| 407 |
, fe_to_real(mapping.fe_to_real) |
| 408 |
, fe_values(mapping.euler_dof_handler->get_fe(), |
| 409 |
reference_cell.template get_nodal_type_quadrature<dim>(), |
| 410 |
update_values) |
| 411 |
{} |
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
template <int dim, int spacedim, typename VectorType> |
| 416 |
inline const double & |
| 417 |
MappingFEField<dim, spacedim, VectorType>::InternalData::shape( |
| 418 |
const unsigned int qpoint, |
| 419 |
const unsigned int shape_nr) const |
| 420 |
{ |
| 421 |
AssertIndexRange(qpoint * n_shape_functions + shape_nr, shape_values.size()); |
| 422 |
return shape_values[qpoint * n_shape_functions + shape_nr]; |
| 423 |
} |
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
template <int dim, int spacedim, typename VectorType> |
| 428 |
bool |
| 429 |
MappingFEField<dim, spacedim, VectorType>::preserves_vertex_locations() const |
| 430 |
{ |
| 431 |
return false; |
| 432 |
} |
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
template <int dim, int spacedim, typename VectorType> |
| 437 |
bool |
| 438 |
MappingFEField<dim, spacedim, VectorType>::is_compatible_with( |
| 439 |
const ReferenceCell &reference_cell) const |
| 440 |
{ |
| 441 |
Assert(dim == reference_cell.get_dimension(), |
| 442 |
ExcMessage("The dimension of your mapping (" + |
| 443 |
Utilities::to_string(dim) + |
| 444 |
") and the reference cell cell_type (" + |
| 445 |
Utilities::to_string(reference_cell.get_dimension()) + |
| 446 |
" ) do not agree.")); |
| 447 |
|
| 448 |
return this->reference_cell == reference_cell; |
| 449 |
} |
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
template <int dim, int spacedim, typename VectorType> |
| 454 |
boost::container::small_vector<Point<spacedim>, |
| 455 |
#ifndef _MSC_VER |
| 456 |
ReferenceCells::max_n_vertices<dim>() |
| 457 |
#else |
| 458 |
GeometryInfo<dim>::vertices_per_cell |
| 459 |
#endif |
| 460 |
> |
| 461 |
MappingFEField<dim, spacedim, VectorType>::get_vertices( |
| 462 |
const typename Triangulation<dim, spacedim>::cell_iterator &cell) const |
| 463 |
{ |
| 464 |
// we transform our tria iterator into a dof iterator so we can access |
| 465 |
// data not associated with triangulations |
| 466 |
const typename DoFHandler<dim, spacedim>::cell_iterator dof_cell( |
| 467 |
*cell, euler_dof_handler); |
| 468 |
|
| 469 |
Assert(uses_level_dofs || dof_cell->is_active() == true, ExcInactiveCell()); |
| 470 |
AssertDimension(cell->n_vertices(), fe_values.n_quadrature_points); |
| 471 |
AssertDimension(fe_to_real.size(), |
| 472 |
euler_dof_handler->get_fe().n_components()); |
| 473 |
if (uses_level_dofs) |
| 474 |
{ |
| 475 |
AssertIndexRange(cell->level(), euler_vector.size()); |
| 476 |
AssertDimension(euler_vector[cell->level()]->size(), |
| 477 |
euler_dof_handler->n_dofs(cell->level())); |
| 478 |
} |
| 479 |
else |
| 480 |
AssertDimension(euler_vector[0]->size(), euler_dof_handler->n_dofs()); |
| 481 |
|
| 482 |
{ |
| 483 |
std::lock_guard<std::mutex> lock(fe_values_mutex); |
| 484 |
fe_values.reinit(dof_cell); |
| 485 |
} |
| 486 |
const unsigned int dofs_per_cell = |
| 487 |
euler_dof_handler->get_fe().n_dofs_per_cell(); |
| 488 |
std::vector<types::global_dof_index> dof_indices(dofs_per_cell); |
| 489 |
if (uses_level_dofs) |
| 490 |
dof_cell->get_mg_dof_indices(dof_indices); |
| 491 |
else |
| 492 |
dof_cell->get_dof_indices(dof_indices); |
| 493 |
|
| 494 |
const VectorType &vector = |
| 495 |
uses_level_dofs ? *euler_vector[cell->level()] : *euler_vector[0]; |
| 496 |
|
| 497 |
boost::container::small_vector<Point<spacedim>, |
| 498 |
#ifndef _MSC_VER |
| 499 |
ReferenceCells::max_n_vertices<dim>() |
| 500 |
#else |
| 501 |
GeometryInfo<dim>::vertices_per_cell |
| 502 |
#endif |
| 503 |
> |
| 504 |
vertices(cell->n_vertices()); |
| 505 |
for (unsigned int i = 0; i < dofs_per_cell; ++i) |
| 506 |
{ |
| 507 |
const unsigned int comp = fe_to_real |
| 508 |
[euler_dof_handler->get_fe().system_to_component_index(i).first]; |
| 509 |
if (comp != numbers::invalid_unsigned_int) |
| 510 |
{ |
| 511 |
typename VectorType::value_type value = |
| 512 |
internal::ElementAccess<VectorType>::get(vector, dof_indices[i]); |
| 513 |
if (euler_dof_handler->get_fe().is_primitive(i)) |
| 514 |
for (const unsigned int v : cell->vertex_indices()) |
| 515 |
vertices[v][comp] += fe_values.shape_value(i, v) * value; |
| 516 |
else |
| 517 |
DEAL_II_NOT_IMPLEMENTED(); |
| 518 |
} |
| 519 |
} |
| 520 |
|
| 521 |
return vertices; |
| 522 |
} |
| 523 |
|
| 524 |
|
| 525 |
|
| 526 |
template <int dim, int spacedim, typename VectorType> |
| 527 |
UpdateFlags |
| 528 |
MappingFEField<dim, spacedim, VectorType>::requires_update_flags( |
| 529 |
const UpdateFlags in) const |
| 530 |
{ |
| 531 |
// add flags if the respective quantities are necessary to compute |
| 532 |
// what we need. note that some flags appear in both conditions and |
| 533 |
// in subsequent set operations. this leads to some circular |
| 534 |
// logic. the only way to treat this is to iterate. since there are |
| 535 |
// 5 if-clauses in the loop, it will take at most 4 iterations to |
| 536 |
// converge. do them: |
| 537 |
UpdateFlags out = in; |
| 538 |
for (unsigned int i = 0; i < 5; ++i) |
| 539 |
{ |
| 540 |
// The following is a little incorrect: |
| 541 |
// If not applied on a face, |
| 542 |
// update_boundary_forms does not |
| 543 |
// make sense. On the other hand, |
| 544 |
// it is necessary on a |
| 545 |
// face. Currently, |
| 546 |
// update_boundary_forms is simply |
| 547 |
// ignored for the interior of a |
| 548 |
// cell. |
| 549 |
if (out & (update_JxW_values | update_normal_vectors)) |
| 550 |
out |= update_boundary_forms; |
| 551 |
|
| 552 |
if (out & |
| 553 |
(update_covariant_transformation | update_jacobian_grads | |
| 554 |
update_jacobians | update_boundary_forms | update_normal_vectors)) |
| 555 |
out |= update_contravariant_transformation; |
| 556 |
|
| 557 |
if (out & |
| 558 |
(update_inverse_jacobians | update_jacobian_pushed_forward_grads | |
| 559 |
update_jacobian_pushed_forward_2nd_derivatives | |
| 560 |
update_jacobian_pushed_forward_3rd_derivatives)) |
| 561 |
out |= update_covariant_transformation; |
| 562 |
|
| 563 |
// The contravariant transformation is used in the Piola |
| 564 |
// transformation, which requires the determinant of the Jacobi |
| 565 |
// matrix of the transformation. Because we have no way of |
| 566 |
// knowing here whether the finite element wants to use the |
| 567 |
// contravariant or the Piola transforms, we add the volume elements |
| 568 |
// to the list of flags to be updated for each cell. |
| 569 |
if (out & update_contravariant_transformation) |
| 570 |
out |= update_volume_elements; |
| 571 |
|
| 572 |
if (out & update_normal_vectors) |
| 573 |
out |= update_volume_elements; |
| 574 |
} |
| 575 |
|
| 576 |
return out; |
| 577 |
} |
| 578 |
|
| 579 |
|
| 580 |
template <int dim, int spacedim, typename VectorType> |
| 581 |
void |
| 582 |
MappingFEField<dim, spacedim, VectorType>::compute_face_data( |
| 583 |
const unsigned int n_original_q_points, |
| 584 |
InternalData &data) const |
| 585 |
{ |
| 586 |
// Set to the size of a single quadrature object for faces, as the size set |
| 587 |
// in in reinit() is for all points |
| 588 |
if (data.update_each & update_covariant_transformation) |
| 589 |
data.covariant.resize(n_original_q_points); |
| 590 |
|
| 591 |
if (data.update_each & update_contravariant_transformation) |
| 592 |
data.contravariant.resize(n_original_q_points); |
| 593 |
|
| 594 |
if (data.update_each & update_volume_elements) |
| 595 |
data.volume_elements.resize(n_original_q_points); |
| 596 |
|
| 597 |
if (dim > 1) |
| 598 |
{ |
| 599 |
if (data.update_each & update_boundary_forms) |
| 600 |
{ |
| 601 |
data.aux.resize( |
| 602 |
dim - 1, std::vector<Tensor<1, spacedim>>(n_original_q_points)); |
| 603 |
|
| 604 |
|
| 605 |
// TODO: only a single reference cell type possible... |
| 606 |
const auto n_faces = reference_cell.n_faces(); |
| 607 |
|
| 608 |
// Compute tangentials to the unit cell. |
| 609 |
for (unsigned int i = 0; i < n_faces; ++i) |
| 610 |
{ |
| 611 |
data.unit_tangentials[i].resize(n_original_q_points); |
| 612 |
std::fill(data.unit_tangentials[i].begin(), |
| 613 |
data.unit_tangentials[i].end(), |
| 614 |
reference_cell.template face_tangent_vector<dim>(i, 0)); |
| 615 |
if (dim > 2) |
| 616 |
{ |
| 617 |
data.unit_tangentials[n_faces + i].resize( |
| 618 |
n_original_q_points); |
| 619 |
std::fill( |
| 620 |
data.unit_tangentials[n_faces + i].begin(), |
| 621 |
data.unit_tangentials[n_faces + i].end(), |
| 622 |
reference_cell.template face_tangent_vector<dim>(i, 1)); |
| 623 |
} |
| 624 |
} |
| 625 |
} |
| 626 |
} |
| 627 |
} |
| 628 |
|
| 629 |
|
| 630 |
|
| 631 |
template <int dim, int spacedim, typename VectorType> |
| 632 |
typename std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase> |
| 633 |
MappingFEField<dim, spacedim, VectorType>::get_data( |
| 634 |
const UpdateFlags update_flags, |
| 635 |
const Quadrature<dim> &quadrature) const |
| 636 |
{ |
| 637 |
std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase> data_ptr = |
| 638 |
std::make_unique<InternalData>(euler_dof_handler->get_fe(), fe_mask); |
| 639 |
data_ptr->reinit(requires_update_flags(update_flags), quadrature); |
| 640 |
|
| 641 |
return data_ptr; |
| 642 |
} |
| 643 |
|
| 644 |
|
| 645 |
|
| 646 |
template <int dim, int spacedim, typename VectorType> |
| 647 |
std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase> |
| 648 |
MappingFEField<dim, spacedim, VectorType>::get_face_data( |
| 649 |
const UpdateFlags update_flags, |
| 650 |
const hp::QCollection<dim - 1> &quadrature) const |
| 651 |
{ |
| 652 |
AssertDimension(quadrature.size(), 1); |
| 653 |
|
| 654 |
std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase> data_ptr = |
| 655 |
std::make_unique<InternalData>(euler_dof_handler->get_fe(), fe_mask); |
| 656 |
auto &data = dynamic_cast<InternalData &>(*data_ptr); |
| 657 |
|
| 658 |
const Quadrature<dim> q( |
| 659 |
QProjector<dim>::project_to_all_faces(reference_cell, quadrature[0])); |
| 660 |
data.reinit(requires_update_flags(update_flags), q); |
| 661 |
this->compute_face_data(quadrature[0].size(), data); |
| 662 |
|
| 663 |
return data_ptr; |
| 664 |
} |
| 665 |
|
| 666 |
|
| 667 |
template <int dim, int spacedim, typename VectorType> |
| 668 |
std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase> |
| 669 |
MappingFEField<dim, spacedim, VectorType>::get_subface_data( |
| 670 |
const UpdateFlags update_flags, |
| 671 |
const Quadrature<dim - 1> &quadrature) const |
| 672 |
{ |
| 673 |
std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase> data_ptr = |
| 674 |
std::make_unique<InternalData>(euler_dof_handler->get_fe(), fe_mask); |
| 675 |
auto &data = dynamic_cast<InternalData &>(*data_ptr); |
| 676 |
|
| 677 |
const Quadrature<dim> q( |
| 678 |
QProjector<dim>::project_to_all_subfaces(reference_cell, quadrature)); |
| 679 |
data.reinit(requires_update_flags(update_flags), q); |
| 680 |
this->compute_face_data(quadrature.size(), data); |
| 681 |
|
| 682 |
return data_ptr; |
| 683 |
} |
| 684 |
|
| 685 |
|
| 686 |
|
| 687 |
namespace internal |
| 688 |
{ |
| 689 |
namespace MappingFEFieldImplementation |
| 690 |
{ |
| 691 |
/** |
| 692 |
* Compute the locations of quadrature points on the object described by |
| 693 |
* the first argument (and the cell for which the mapping support points |
| 694 |
* have already been set), but only if the update_flags of the @p data |
| 695 |
* argument indicate so. |
| 696 |
*/ |
| 697 |
template <int dim, int spacedim, typename VectorType> |
| 698 |
void |
| 699 |
maybe_compute_q_points( |
| 700 |
const typename dealii::QProjector<dim>::DataSetDescriptor data_set, |
| 701 |
const typename dealii::MappingFEField<dim, spacedim, VectorType>:: |
| 702 |
InternalData &data, |
| 703 |
const FiniteElement<dim, spacedim> &fe, |
| 704 |
const ComponentMask &fe_mask, |
| 705 |
const std::vector<unsigned int> &fe_to_real, |
| 706 |
std::vector<Point<spacedim>> &quadrature_points) |
| 707 |
{ |
| 708 |
const UpdateFlags update_flags = data.update_each; |
| 709 |
|
| 710 |
if (update_flags & update_quadrature_points) |
| 711 |
{ |
| 712 |
for (unsigned int point = 0; point < quadrature_points.size(); |
| 713 |
++point) |
| 714 |
{ |
| 715 |
Point<spacedim> result; |
| 716 |
const double *shape = &data.shape(point + data_set, 0); |
| 717 |
|
| 718 |
for (unsigned int k = 0; k < data.n_shape_functions; ++k) |
| 719 |
{ |
| 720 |
const unsigned int comp_k = |
| 721 |
fe.system_to_component_index(k).first; |
| 722 |
if (fe_mask[comp_k]) |
| 723 |
result[fe_to_real[comp_k]] += |
| 724 |
data.local_dof_values[k] * shape[k]; |
| 725 |
} |
| 726 |
|
| 727 |
quadrature_points[point] = result; |
| 728 |
} |
| 729 |
} |
| 730 |
} |
| 731 |
|
| 732 |
/** |
| 733 |
* Update the co- and contravariant matrices as well as their determinant, |
| 734 |
* for the cell described stored in the data object, but only if the |
| 735 |
* update_flags of the @p data argument indicate so. |
| 736 |
* |
| 737 |
* Skip the computation if possible as indicated by the first argument. |
| 738 |
*/ |
| 739 |
template <int dim, int spacedim, typename VectorType> |
| 740 |
void |
| 741 |
maybe_update_Jacobians( |
| 742 |
const typename dealii::QProjector<dim>::DataSetDescriptor data_set, |
| 743 |
const typename dealii::MappingFEField<dim, spacedim, VectorType>:: |
| 744 |
InternalData &data, |
| 745 |
const FiniteElement<dim, spacedim> &fe, |
| 746 |
const ComponentMask &fe_mask, |
| 747 |
const std::vector<unsigned int> &fe_to_real) |
| 748 |
{ |
| 749 |
const UpdateFlags update_flags = data.update_each; |
| 750 |
|
| 751 |
// then Jacobians |
| 752 |
if (update_flags & update_contravariant_transformation) |
| 753 |
{ |
| 754 |
const unsigned int n_q_points = data.contravariant.size(); |
| 755 |
|
| 756 |
Assert(data.n_shape_functions > 0, ExcInternalError()); |
| 757 |
|
| 758 |
for (unsigned int point = 0; point < n_q_points; ++point) |
| 759 |
{ |
| 760 |
const Tensor<1, dim> *data_derv = |
| 761 |
&data.derivative(point + data_set, 0); |
| 762 |
|
| 763 |
Tensor<1, dim> result[spacedim]; |
| 764 |
|
| 765 |
for (unsigned int k = 0; k < data.n_shape_functions; ++k) |
| 766 |
{ |
| 767 |
const unsigned int comp_k = |
| 768 |
fe.system_to_component_index(k).first; |
| 769 |
if (fe_mask[comp_k]) |
| 770 |
result[fe_to_real[comp_k]] += |
| 771 |
data.local_dof_values[k] * data_derv[k]; |
| 772 |
} |
| 773 |
|
| 774 |
// write result into contravariant data |
| 775 |
for (unsigned int i = 0; i < spacedim; ++i) |
| 776 |
{ |
| 777 |
data.contravariant[point][i] = result[i]; |
| 778 |
} |
| 779 |
} |
| 780 |
} |
| 781 |
|
| 782 |
if (update_flags & update_covariant_transformation) |
| 783 |
{ |
| 784 |
AssertDimension(data.covariant.size(), data.contravariant.size()); |
| 785 |
for (unsigned int point = 0; point < data.contravariant.size(); |
| 786 |
++point) |
| 787 |
data.covariant[point] = |
| 788 |
(data.contravariant[point]).covariant_form(); |
| 789 |
} |
| 790 |
|
| 791 |
if (update_flags & update_volume_elements) |
| 792 |
{ |
| 793 |
AssertDimension(data.contravariant.size(), |
| 794 |
data.volume_elements.size()); |
| 795 |
for (unsigned int point = 0; point < data.contravariant.size(); |
| 796 |
++point) |
| 797 |
data.volume_elements[point] = |
| 798 |
data.contravariant[point].determinant(); |
| 799 |
} |
| 800 |
} |
| 801 |
|
| 802 |
/** |
| 803 |
* Update the Hessian of the transformation from unit to real cell, the |
| 804 |
* Jacobian gradients. |
| 805 |
* |
| 806 |
* Skip the computation if possible as indicated by the first argument. |
| 807 |
*/ |
| 808 |
template <int dim, int spacedim, typename VectorType> |
| 809 |
void |
| 810 |
maybe_update_jacobian_grads( |
| 811 |
const typename dealii::QProjector<dim>::DataSetDescriptor data_set, |
| 812 |
const typename dealii::MappingFEField<dim, spacedim, VectorType>:: |
| 813 |
InternalData &data, |
| 814 |
const FiniteElement<dim, spacedim> &fe, |
| 815 |
const ComponentMask &fe_mask, |
| 816 |
const std::vector<unsigned int> &fe_to_real, |
| 817 |
std::vector<DerivativeForm<2, dim, spacedim>> &jacobian_grads) |
| 818 |
{ |
| 819 |
const UpdateFlags update_flags = data.update_each; |
| 820 |
if (update_flags & update_jacobian_grads) |
| 821 |
{ |
| 822 |
const unsigned int n_q_points = jacobian_grads.size(); |
| 823 |
|
| 824 |
for (unsigned int point = 0; point < n_q_points; ++point) |
| 825 |
{ |
| 826 |
const Tensor<2, dim> *second = |
| 827 |
&data.second_derivative(point + data_set, 0); |
| 828 |
|
| 829 |
DerivativeForm<2, dim, spacedim> result; |
| 830 |
|
| 831 |
for (unsigned int k = 0; k < data.n_shape_functions; ++k) |
| 832 |
{ |
| 833 |
const unsigned int comp_k = |
| 834 |
fe.system_to_component_index(k).first; |
| 835 |
if (fe_mask[comp_k]) |
| 836 |
for (unsigned int j = 0; j < dim; ++j) |
| 837 |
for (unsigned int l = 0; l < dim; ++l) |
| 838 |
result[fe_to_real[comp_k]][j][l] += |
| 839 |
(second[k][j][l] * data.local_dof_values[k]); |
| 840 |
} |
| 841 |
|
| 842 |
// never touch any data for j=dim in case dim<spacedim, so |
| 843 |
// it will always be zero as it was initialized |
| 844 |
for (unsigned int i = 0; i < spacedim; ++i) |
| 845 |
for (unsigned int j = 0; j < dim; ++j) |
| 846 |
for (unsigned int l = 0; l < dim; ++l) |
| 847 |
jacobian_grads[point][i][j][l] = result[i][j][l]; |
| 848 |
} |
| 849 |
} |
| 850 |
} |
| 851 |
|
| 852 |
/** |
| 853 |
* Update the Hessian of the transformation from unit to real cell, the |
| 854 |
* Jacobian gradients, pushed forward to the real cell coordinates. |
| 855 |
* |
| 856 |
* Skip the computation if possible as indicated by the first argument. |
| 857 |
*/ |
| 858 |
template <int dim, int spacedim, typename VectorType> |
| 859 |
void |
| 860 |
maybe_update_jacobian_pushed_forward_grads( |
| 861 |
const typename dealii::QProjector<dim>::DataSetDescriptor data_set, |
| 862 |
const typename dealii::MappingFEField<dim, spacedim, VectorType>:: |
| 863 |
InternalData &data, |
| 864 |
const FiniteElement<dim, spacedim> &fe, |
| 865 |
const ComponentMask &fe_mask, |
| 866 |
const std::vector<unsigned int> &fe_to_real, |
| 867 |
std::vector<Tensor<3, spacedim>> &jacobian_pushed_forward_grads) |
| 868 |
{ |
| 869 |
const UpdateFlags update_flags = data.update_each; |
| 870 |
if (update_flags & update_jacobian_pushed_forward_grads) |
| 871 |
{ |
| 872 |
const unsigned int n_q_points = jacobian_pushed_forward_grads.size(); |
| 873 |
|
| 874 |
double tmp[spacedim][spacedim][spacedim]; |
| 875 |
for (unsigned int point = 0; point < n_q_points; ++point) |
| 876 |
{ |
| 877 |
const Tensor<2, dim> *second = |
| 878 |
&data.second_derivative(point + data_set, 0); |
| 879 |
|
| 880 |
DerivativeForm<2, dim, spacedim> result; |
| 881 |
|
| 882 |
for (unsigned int k = 0; k < data.n_shape_functions; ++k) |
| 883 |
{ |
| 884 |
const unsigned int comp_k = |
| 885 |
fe.system_to_component_index(k).first; |
| 886 |
if (fe_mask[comp_k]) |
| 887 |
for (unsigned int j = 0; j < dim; ++j) |
| 888 |
for (unsigned int l = 0; l < dim; ++l) |
| 889 |
result[fe_to_real[comp_k]][j][l] += |
| 890 |
(second[k][j][l] * data.local_dof_values[k]); |
| 891 |
} |
| 892 |
|
| 893 |
// first push forward the j-components |
| 894 |
for (unsigned int i = 0; i < spacedim; ++i) |
| 895 |
for (unsigned int j = 0; j < spacedim; ++j) |
| 896 |
for (unsigned int l = 0; l < dim; ++l) |
| 897 |
{ |
| 898 |
tmp[i][j][l] = |
| 899 |
result[i][0][l] * data.covariant[point][j][0]; |
| 900 |
for (unsigned int jr = 1; jr < dim; ++jr) |
| 901 |
{ |
| 902 |
tmp[i][j][l] += |
| 903 |
result[i][jr][l] * data.covariant[point][j][jr]; |
| 904 |
} |
| 905 |
} |
| 906 |
|
| 907 |
// now, pushing forward the l-components |
| 908 |
for (unsigned int i = 0; i < spacedim; ++i) |
| 909 |
for (unsigned int j = 0; j < spacedim; ++j) |
| 910 |
for (unsigned int l = 0; l < spacedim; ++l) |
| 911 |
{ |
| 912 |
jacobian_pushed_forward_grads[point][i][j][l] = |
| 913 |
tmp[i][j][0] * data.covariant[point][l][0]; |
| 914 |
for (unsigned int lr = 1; lr < dim; ++lr) |
| 915 |
{ |
| 916 |
jacobian_pushed_forward_grads[point][i][j][l] += |
| 917 |
tmp[i][j][lr] * data.covariant[point][l][lr]; |
| 918 |
} |
| 919 |
} |
| 920 |
} |
| 921 |
} |
| 922 |
} |
| 923 |
|
| 924 |
/** |
| 925 |
* Update the third derivative of the transformation from unit to real |
| 926 |
* cell, the Jacobian hessians. |
| 927 |
* |
| 928 |
* Skip the computation if possible as indicated by the first argument. |
| 929 |
*/ |
| 930 |
template <int dim, int spacedim, typename VectorType> |
| 931 |
void |
| 932 |
maybe_update_jacobian_2nd_derivatives( |
| 933 |
const typename dealii::QProjector<dim>::DataSetDescriptor data_set, |
| 934 |
const typename dealii::MappingFEField<dim, spacedim, VectorType>:: |
| 935 |
InternalData &data, |
| 936 |
const FiniteElement<dim, spacedim> &fe, |
| 937 |
const ComponentMask &fe_mask, |
| 938 |
const std::vector<unsigned int> &fe_to_real, |
| 939 |
std::vector<DerivativeForm<3, dim, spacedim>> &jacobian_2nd_derivatives) |
| 940 |
{ |
| 941 |
const UpdateFlags update_flags = data.update_each; |
| 942 |
if (update_flags & update_jacobian_2nd_derivatives) |
| 943 |
{ |
| 944 |
const unsigned int n_q_points = jacobian_2nd_derivatives.size(); |
| 945 |
|
| 946 |
for (unsigned int point = 0; point < n_q_points; ++point) |
| 947 |
{ |
| 948 |
const Tensor<3, dim> *third = |
| 949 |
&data.third_derivative(point + data_set, 0); |
| 950 |
|
| 951 |
DerivativeForm<3, dim, spacedim> result; |
| 952 |
|
| 953 |
for (unsigned int k = 0; k < data.n_shape_functions; ++k) |
| 954 |
{ |
| 955 |
const unsigned int comp_k = |
| 956 |
fe.system_to_component_index(k).first; |
| 957 |
if (fe_mask[comp_k]) |
| 958 |
for (unsigned int j = 0; j < dim; ++j) |
| 959 |
for (unsigned int l = 0; l < dim; ++l) |
| 960 |
for (unsigned int m = 0; m < dim; ++m) |
| 961 |
result[fe_to_real[comp_k]][j][l][m] += |
| 962 |
(third[k][j][l][m] * data.local_dof_values[k]); |
| 963 |
} |
| 964 |
|
| 965 |
// never touch any data for j=dim in case dim<spacedim, so |
| 966 |
// it will always be zero as it was initialized |
| 967 |
for (unsigned int i = 0; i < spacedim; ++i) |
| 968 |
for (unsigned int j = 0; j < dim; ++j) |
| 969 |
for (unsigned int l = 0; l < dim; ++l) |
| 970 |
for (unsigned int m = 0; m < dim; ++m) |
| 971 |
jacobian_2nd_derivatives[point][i][j][l][m] = |
| 972 |
result[i][j][l][m]; |
| 973 |
} |
| 974 |
} |
| 975 |
} |
| 976 |
|
| 977 |
/** |
| 978 |
* Update the third derivative of the transformation from unit to real |
| 979 |
* cell, the Jacobian hessians, pushed forward to the real cell |
| 980 |
* coordinates. |
| 981 |
* |
| 982 |
* Skip the computation if possible as indicated by the first argument. |
| 983 |
*/ |
| 984 |
template <int dim, int spacedim, typename VectorType> |
| 985 |
void |
| 986 |
maybe_update_jacobian_pushed_forward_2nd_derivatives( |
| 987 |
const typename dealii::QProjector<dim>::DataSetDescriptor data_set, |
| 988 |
const typename dealii::MappingFEField<dim, spacedim, VectorType>:: |
| 989 |
InternalData &data, |
| 990 |
const FiniteElement<dim, spacedim> &fe, |
| 991 |
const ComponentMask &fe_mask, |
| 992 |
const std::vector<unsigned int> &fe_to_real, |
| 993 |
std::vector<Tensor<4, spacedim>> &jacobian_pushed_forward_2nd_derivatives) |
| 994 |
{ |
| 995 |
const UpdateFlags update_flags = data.update_each; |
| 996 |
if (update_flags & update_jacobian_pushed_forward_2nd_derivatives) |
| 997 |
{ |
| 998 |
const unsigned int n_q_points = |
| 999 |
jacobian_pushed_forward_2nd_derivatives.size(); |
| 1000 |
|
| 1001 |
double tmp[spacedim][spacedim][spacedim][spacedim]; |
| 1002 |
for (unsigned int point = 0; point < n_q_points; ++point) |
| 1003 |
{ |
| 1004 |
const Tensor<3, dim> *third = |
| 1005 |
&data.third_derivative(point + data_set, 0); |
| 1006 |
|
| 1007 |
DerivativeForm<3, dim, spacedim> result; |
| 1008 |
|
| 1009 |
for (unsigned int k = 0; k < data.n_shape_functions; ++k) |
| 1010 |
{ |
| 1011 |
const unsigned int comp_k = |
| 1012 |
fe.system_to_component_index(k).first; |
| 1013 |
if (fe_mask[comp_k]) |
| 1014 |
for (unsigned int j = 0; j < dim; ++j) |
| 1015 |
for (unsigned int l = 0; l < dim; ++l) |
| 1016 |
for (unsigned int m = 0; m < dim; ++m) |
| 1017 |
result[fe_to_real[comp_k]][j][l][m] += |
| 1018 |
(third[k][j][l][m] * data.local_dof_values[k]); |
| 1019 |
} |
| 1020 |
|
| 1021 |
// push forward the j-coordinate |
| 1022 |
for (unsigned int i = 0; i < spacedim; ++i) |
| 1023 |
for (unsigned int j = 0; j < spacedim; ++j) |
| 1024 |
for (unsigned int l = 0; l < dim; ++l) |
| 1025 |
for (unsigned int m = 0; m < dim; ++m) |
| 1026 |
{ |
| 1027 |
jacobian_pushed_forward_2nd_derivatives |
| 1028 |
[point][i][j][l][m] = |
| 1029 |
result[i][0][l][m] * data.covariant[point][j][0]; |
| 1030 |
for (unsigned int jr = 1; jr < dim; ++jr) |
| 1031 |
jacobian_pushed_forward_2nd_derivatives[point][i][j] |
| 1032 |
[l][m] += |
| 1033 |
result[i][jr][l][m] * data.covariant[point][j][jr]; |
| 1034 |
} |
| 1035 |
|
| 1036 |
// push forward the l-coordinate |
| 1037 |
for (unsigned int i = 0; i < spacedim; ++i) |
| 1038 |
for (unsigned int j = 0; j < spacedim; ++j) |
| 1039 |
for (unsigned int l = 0; l < spacedim; ++l) |
| 1040 |
for (unsigned int m = 0; m < dim; ++m) |
| 1041 |
{ |
| 1042 |
tmp[i][j][l][m] = |
| 1043 |
jacobian_pushed_forward_2nd_derivatives[point][i][j] |
| 1044 |
[0][m] * |
| 1045 |
data.covariant[point][l][0]; |
| 1046 |
for (unsigned int lr = 1; lr < dim; ++lr) |
| 1047 |
tmp[i][j][l][m] += |
| 1048 |
jacobian_pushed_forward_2nd_derivatives[point][i][j] |
| 1049 |
[lr][m] * |
| 1050 |
data.covariant[point][l][lr]; |
| 1051 |
} |
| 1052 |
|
| 1053 |
// push forward the m-coordinate |
| 1054 |
for (unsigned int i = 0; i < spacedim; ++i) |
| 1055 |
for (unsigned int j = 0; j < spacedim; ++j) |
| 1056 |
for (unsigned int l = 0; l < spacedim; ++l) |
| 1057 |
for (unsigned int m = 0; m < spacedim; ++m) |
| 1058 |
{ |
| 1059 |
jacobian_pushed_forward_2nd_derivatives |
| 1060 |
[point][i][j][l][m] = |
| 1061 |
tmp[i][j][l][0] * data.covariant[point][m][0]; |
| 1062 |
for (unsigned int mr = 1; mr < dim; ++mr) |
| 1063 |
jacobian_pushed_forward_2nd_derivatives[point][i][j] |
| 1064 |
[l][m] += |
| 1065 |
tmp[i][j][l][mr] * data.covariant[point][m][mr]; |
| 1066 |
} |
| 1067 |
} |
| 1068 |
} |
| 1069 |
} |
| 1070 |
|
| 1071 |
/** |
| 1072 |
* Update the fourth derivative of the transformation from unit to real |
| 1073 |
* cell, the Jacobian hessian gradients. |
| 1074 |
* |
| 1075 |
* Skip the computation if possible as indicated by the first argument. |
| 1076 |
*/ |
| 1077 |
template <int dim, int spacedim, typename VectorType> |
| 1078 |
void |
| 1079 |
maybe_update_jacobian_3rd_derivatives( |
| 1080 |
const typename dealii::QProjector<dim>::DataSetDescriptor data_set, |
| 1081 |
const typename dealii::MappingFEField<dim, spacedim, VectorType>:: |
| 1082 |
InternalData &data, |
| 1083 |
const FiniteElement<dim, spacedim> &fe, |
| 1084 |
const ComponentMask &fe_mask, |
| 1085 |
const std::vector<unsigned int> &fe_to_real, |
| 1086 |
std::vector<DerivativeForm<4, dim, spacedim>> &jacobian_3rd_derivatives) |
| 1087 |
{ |
| 1088 |
const UpdateFlags update_flags = data.update_each; |
| 1089 |
if (update_flags & update_jacobian_3rd_derivatives) |
| 1090 |
{ |
| 1091 |
const unsigned int n_q_points = jacobian_3rd_derivatives.size(); |
| 1092 |
|
| 1093 |
for (unsigned int point = 0; point < n_q_points; ++point) |
| 1094 |
{ |
| 1095 |
const Tensor<4, dim> *fourth = |
| 1096 |
&data.fourth_derivative(point + data_set, 0); |
| 1097 |
|
| 1098 |
DerivativeForm<4, dim, spacedim> result; |
| 1099 |
|
| 1100 |
for (unsigned int k = 0; k < data.n_shape_functions; ++k) |
| 1101 |
{ |
| 1102 |
const unsigned int comp_k = |
| 1103 |
fe.system_to_component_index(k).first; |
| 1104 |
if (fe_mask[comp_k]) |
| 1105 |
for (unsigned int j = 0; j < dim; ++j) |
| 1106 |
for (unsigned int l = 0; l < dim; ++l) |
| 1107 |
for (unsigned int m = 0; m < dim; ++m) |
| 1108 |
for (unsigned int n = 0; n < dim; ++n) |
| 1109 |
result[fe_to_real[comp_k]][j][l][m][n] += |
| 1110 |
(fourth[k][j][l][m][n] * |
| 1111 |
data.local_dof_values[k]); |
| 1112 |
} |
| 1113 |
|
| 1114 |
// never touch any data for j,l,m,n=dim in case |
| 1115 |
// dim<spacedim, so it will always be zero as it was |
| 1116 |
// initialized |
| 1117 |
for (unsigned int i = 0; i < spacedim; ++i) |
| 1118 |
for (unsigned int j = 0; j < dim; ++j) |
| 1119 |
for (unsigned int l = 0; l < dim; ++l) |
| 1120 |
for (unsigned int m = 0; m < dim; ++m) |
| 1121 |
for (unsigned int n = 0; n < dim; ++n) |
| 1122 |
jacobian_3rd_derivatives[point][i][j][l][m][n] = |
| 1123 |
result[i][j][l][m][n]; |
| 1124 |
} |
| 1125 |
} |
| 1126 |
} |
| 1127 |
|
| 1128 |
/** |
| 1129 |
* Update the fourth derivative of the transformation from unit to real |
| 1130 |
* cell, the Jacobian hessian gradients, pushed forward to the real cell |
| 1131 |
* coordinates. |
| 1132 |
* |
| 1133 |
* Skip the computation if possible as indicated by the first argument. |
| 1134 |
*/ |
| 1135 |
template <int dim, int spacedim, typename VectorType> |
| 1136 |
void |
| 1137 |
maybe_update_jacobian_pushed_forward_3rd_derivatives( |
| 1138 |
const typename dealii::QProjector<dim>::DataSetDescriptor data_set, |
| 1139 |
const typename dealii::MappingFEField<dim, spacedim, VectorType>:: |
| 1140 |
InternalData &data, |
| 1141 |
const FiniteElement<dim, spacedim> &fe, |
| 1142 |
const ComponentMask &fe_mask, |
| 1143 |
const std::vector<unsigned int> &fe_to_real, |
| 1144 |
std::vector<Tensor<5, spacedim>> &jacobian_pushed_forward_3rd_derivatives) |
| 1145 |
{ |
| 1146 |
const UpdateFlags update_flags = data.update_each; |
| 1147 |
if (update_flags & update_jacobian_pushed_forward_3rd_derivatives) |
| 1148 |
{ |
| 1149 |
const unsigned int n_q_points = |
| 1150 |
jacobian_pushed_forward_3rd_derivatives.size(); |
| 1151 |
|
| 1152 |
double tmp[spacedim][spacedim][spacedim][spacedim][spacedim]; |
| 1153 |
for (unsigned int point = 0; point < n_q_points; ++point) |
| 1154 |
{ |
| 1155 |
const Tensor<4, dim> *fourth = |
| 1156 |
&data.fourth_derivative(point + data_set, 0); |
| 1157 |
|
| 1158 |
DerivativeForm<4, dim, spacedim> result; |
| 1159 |
|
| 1160 |
for (unsigned int k = 0; k < data.n_shape_functions; ++k) |
| 1161 |
{ |
| 1162 |
const unsigned int comp_k = |
| 1163 |
fe.system_to_component_index(k).first; |
| 1164 |
if (fe_mask[comp_k]) |
| 1165 |
for (unsigned int j = 0; j < dim; ++j) |
| 1166 |
for (unsigned int l = 0; l < dim; ++l) |
| 1167 |
for (unsigned int m = 0; m < dim; ++m) |
| 1168 |
for (unsigned int n = 0; n < dim; ++n) |
| 1169 |
result[fe_to_real[comp_k]][j][l][m][n] += |
| 1170 |
(fourth[k][j][l][m][n] * |
| 1171 |
data.local_dof_values[k]); |
| 1172 |
} |
| 1173 |
|
| 1174 |
// push-forward the j-coordinate |
| 1175 |
for (unsigned int i = 0; i < spacedim; ++i) |
| 1176 |
for (unsigned int j = 0; j < spacedim; ++j) |
| 1177 |
for (unsigned int l = 0; l < dim; ++l) |
| 1178 |
for (unsigned int m = 0; m < dim; ++m) |
| 1179 |
for (unsigned int n = 0; n < dim; ++n) |
| 1180 |
{ |
| 1181 |
tmp[i][j][l][m][n] = |
| 1182 |
result[i][0][l][m][n] * data.covariant[point][j][0]; |
| 1183 |
for (unsigned int jr = 1; jr < dim; ++jr) |
| 1184 |
tmp[i][j][l][m][n] += result[i][jr][l][m][n] * |
| 1185 |
data.covariant[point][j][jr]; |
| 1186 |
} |
| 1187 |
|
| 1188 |
// push-forward the l-coordinate |
| 1189 |
for (unsigned int i = 0; i < spacedim; ++i) |
| 1190 |
for (unsigned int j = 0; j < spacedim; ++j) |
| 1191 |
for (unsigned int l = 0; l < spacedim; ++l) |
| 1192 |
for (unsigned int m = 0; m < dim; ++m) |
| 1193 |
for (unsigned int n = 0; n < dim; ++n) |
| 1194 |
{ |
| 1195 |
jacobian_pushed_forward_3rd_derivatives |
| 1196 |
[point][i][j][l][m][n] = |
| 1197 |
tmp[i][j][0][m][n] * data.covariant[point][l][0]; |
| 1198 |
for (unsigned int lr = 1; lr < dim; ++lr) |
| 1199 |
jacobian_pushed_forward_3rd_derivatives[point][i][j] |
| 1200 |
[l][m][n] += |
| 1201 |
tmp[i][j][lr][m][n] * |
| 1202 |
data.covariant[point][l][lr]; |
| 1203 |
} |
| 1204 |
|
| 1205 |
// push-forward the m-coordinate |
| 1206 |
for (unsigned int i = 0; i < spacedim; ++i) |
| 1207 |
for (unsigned int j = 0; j < spacedim; ++j) |
| 1208 |
for (unsigned int l = 0; l < spacedim; ++l) |
| 1209 |
for (unsigned int m = 0; m < spacedim; ++m) |
| 1210 |
for (unsigned int n = 0; n < dim; ++n) |
| 1211 |
{ |
| 1212 |
tmp[i][j][l][m][n] = |
| 1213 |
jacobian_pushed_forward_3rd_derivatives[point][i][j] |
| 1214 |
[l][0][n] * |
| 1215 |
data.covariant[point][m][0]; |
| 1216 |
for (unsigned int mr = 1; mr < dim; ++mr) |
| 1217 |
tmp[i][j][l][m][n] += |
| 1218 |
jacobian_pushed_forward_3rd_derivatives[point][i] |
| 1219 |
[j][l][mr] |
| 1220 |
[n] * |
| 1221 |
data.covariant[point][m][mr]; |
| 1222 |
} |
| 1223 |
|
| 1224 |
// push-forward the n-coordinate |
| 1225 |
for (unsigned int i = 0; i < spacedim; ++i) |
| 1226 |
for (unsigned int j = 0; j < spacedim; ++j) |
| 1227 |
for (unsigned int l = 0; l < spacedim; ++l) |
| 1228 |
for (unsigned int m = 0; m < spacedim; ++m) |
| 1229 |
for (unsigned int n = 0; n < spacedim; ++n) |
| 1230 |
{ |
| 1231 |
jacobian_pushed_forward_3rd_derivatives |
| 1232 |
[point][i][j][l][m][n] = |
| 1233 |
tmp[i][j][l][m][0] * data.covariant[point][n][0]; |
| 1234 |
for (unsigned int nr = 1; nr < dim; ++nr) |
| 1235 |
jacobian_pushed_forward_3rd_derivatives[point][i][j] |
| 1236 |
[l][m][n] += |
| 1237 |
tmp[i][j][l][m][nr] * |
| 1238 |
data.covariant[point][n][nr]; |
| 1239 |
} |
| 1240 |
} |
| 1241 |
} |
| 1242 |
} |
| 1243 |
|
| 1244 |
|
| 1245 |
/** |
| 1246 |
* Depending on what information is called for in the update flags of the |
| 1247 |
* @p data object, compute the various pieces of information that is |
| 1248 |
* required by the fill_fe_face_values() and fill_fe_subface_values() |
| 1249 |
* functions. This function simply unifies the work that would be done by |
| 1250 |
* those two functions. |
| 1251 |
* |
| 1252 |
* The resulting data is put into the @p output_data argument. |
| 1253 |
*/ |
| 1254 |
template <int dim, int spacedim, typename VectorType> |
| 1255 |
void |
| 1256 |
maybe_compute_face_data( |
| 1257 |
const dealii::Mapping<dim, spacedim> &mapping, |
| 1258 |
const typename dealii::Triangulation<dim, spacedim>::cell_iterator &cell, |
| 1259 |
const unsigned int face_no, |
| 1260 |
const unsigned int subface_no, |
| 1261 |
const typename QProjector<dim>::DataSetDescriptor data_set, |
| 1262 |
const typename dealii::MappingFEField<dim, spacedim, VectorType>:: |
| 1263 |
InternalData &data, |
| 1264 |
internal::FEValuesImplementation::MappingRelatedData<dim, spacedim> |
| 1265 |
&output_data) |
| 1266 |
{ |
| 1267 |
const UpdateFlags update_flags = data.update_each; |
| 1268 |
|
| 1269 |
if (update_flags & update_boundary_forms) |
| 1270 |
{ |
| 1271 |
const unsigned int n_q_points = output_data.boundary_forms.size(); |
| 1272 |
if (update_flags & update_normal_vectors) |
| 1273 |
AssertDimension(output_data.normal_vectors.size(), n_q_points); |
| 1274 |
if (update_flags & update_JxW_values) |
| 1275 |
AssertDimension(output_data.JxW_values.size(), n_q_points); |
| 1276 |
|
| 1277 |
// map the unit tangentials to the real cell. checking for d!=dim-1 |
| 1278 |
// eliminates compiler warnings regarding unsigned int expressions < |
| 1279 |
// 0. |
| 1280 |
for (unsigned int d = 0; d != dim - 1; ++d) |
| 1281 |
{ |
| 1282 |
Assert(face_no + cell->n_faces() * d < |
| 1283 |
data.unit_tangentials.size(), |
| 1284 |
ExcInternalError()); |
| 1285 |
Assert( |
| 1286 |
data.aux[d].size() <= |
| 1287 |
data.unit_tangentials[face_no + cell->n_faces() * d].size(), |
| 1288 |
ExcInternalError()); |
| 1289 |
|
| 1290 |
mapping.transform( |
| 1291 |
make_array_view( |
| 1292 |
data.unit_tangentials[face_no + cell->n_faces() * d]), |
| 1293 |
mapping_contravariant, |
| 1294 |
data, |
| 1295 |
make_array_view(data.aux[d])); |
| 1296 |
} |
| 1297 |
|
| 1298 |
// if dim==spacedim, we can use the unit tangentials to compute the |
| 1299 |
// boundary form by simply taking the cross product |
| 1300 |
if (dim == spacedim) |
| 1301 |
{ |
| 1302 |
for (unsigned int i = 0; i < n_q_points; ++i) |
| 1303 |
switch (dim) |
| 1304 |
{ |
| 1305 |
case 1: |
| 1306 |
// in 1d, we don't have access to any of the data.aux |
| 1307 |
// fields (because it has only dim-1 components), but we |
| 1308 |
// can still compute the boundary form by simply looking |
| 1309 |
// at the number of the face |
| 1310 |
output_data.boundary_forms[i][0] = |
| 1311 |
(face_no == 0 ? -1 : +1); |
| 1312 |
break; |
| 1313 |
case 2: |
| 1314 |
output_data.boundary_forms[i] = |
| 1315 |
cross_product_2d(data.aux[0][i]); |
| 1316 |
break; |
| 1317 |
case 3: |
| 1318 |
output_data.boundary_forms[i] = |
| 1319 |
cross_product_3d(data.aux[0][i], data.aux[1][i]); |
| 1320 |
break; |
| 1321 |
default: |
| 1322 |
DEAL_II_NOT_IMPLEMENTED(); |
| 1323 |
} |
| 1324 |
} |
| 1325 |
else //(dim < spacedim) |
| 1326 |
{ |
| 1327 |
// in the codim-one case, the boundary form results from the |
| 1328 |
// cross product of all the face tangential vectors and the cell |
| 1329 |
// normal vector |
| 1330 |
// |
| 1331 |
// to compute the cell normal, use the same method used in |
| 1332 |
// fill_fe_values for cells above |
| 1333 |
AssertDimension(data.contravariant.size(), n_q_points); |
| 1334 |
|
| 1335 |
for (unsigned int point = 0; point < n_q_points; ++point) |
| 1336 |
{ |
| 1337 |
if (dim == 1) |
| 1338 |
{ |
| 1339 |
// J is a tangent vector |
| 1340 |
output_data.boundary_forms[point] = |
| 1341 |
data.contravariant[point].transpose()[0]; |
| 1342 |
output_data.boundary_forms[point] /= |
| 1343 |
(face_no == 0 ? -1. : +1.) * |
| 1344 |
output_data.boundary_forms[point].norm(); |
| 1345 |
} |
| 1346 |
|
| 1347 |
if (dim == 2) |
| 1348 |
{ |
| 1349 |
const DerivativeForm<1, spacedim, dim> DX_t = |
| 1350 |
data.contravariant[point].transpose(); |
| 1351 |
|
| 1352 |
Tensor<1, spacedim> cell_normal = |
| 1353 |
cross_product_3d(DX_t[0], DX_t[1]); |
| 1354 |
cell_normal /= cell_normal.norm(); |
| 1355 |
|
| 1356 |
// then compute the face normal from the face tangent |
| 1357 |
// and the cell normal: |
| 1358 |
output_data.boundary_forms[point] = |
| 1359 |
cross_product_3d(data.aux[0][point], cell_normal); |
| 1360 |
} |
| 1361 |
} |
| 1362 |
} |
| 1363 |
|
| 1364 |
if (update_flags & (update_normal_vectors | update_JxW_values)) |
| 1365 |
for (unsigned int i = 0; i < output_data.boundary_forms.size(); ++i) |
| 1366 |
{ |
| 1367 |
if (update_flags & update_JxW_values) |
| 1368 |
{ |
| 1369 |
output_data.JxW_values[i] = |
| 1370 |
output_data.boundary_forms[i].norm() * |
| 1371 |
data.quadrature_weights[i + data_set]; |
| 1372 |
|
| 1373 |
if (subface_no != numbers::invalid_unsigned_int) |
| 1374 |
{ |
| 1375 |
// TODO |
| 1376 |
const double area_ratio = |
| 1377 |
GeometryInfo<dim>::subface_ratio( |
| 1378 |
cell->subface_case(face_no), subface_no); |
| 1379 |
output_data.JxW_values[i] *= area_ratio; |
| 1380 |
} |
| 1381 |
} |
| 1382 |
|
| 1383 |
if (update_flags & update_normal_vectors) |
| 1384 |
output_data.normal_vectors[i] = |
| 1385 |
Point<spacedim>(output_data.boundary_forms[i] / |
| 1386 |
output_data.boundary_forms[i].norm()); |
| 1387 |
} |
| 1388 |
} |
| 1389 |
} |
| 1390 |
|
| 1391 |
/** |
| 1392 |
* Do the work of MappingFEField::fill_fe_face_values() and |
| 1393 |
* MappingFEField::fill_fe_subface_values() in a generic way, using the |
| 1394 |
* 'data_set' to differentiate whether we will work on a face (and if so, |
| 1395 |
* which one) or subface. |
| 1396 |
*/ |
| 1397 |
template <int dim, int spacedim, typename VectorType> |
| 1398 |
void |
| 1399 |
do_fill_fe_face_values( |
| 1400 |
const dealii::Mapping<dim, spacedim> &mapping, |
| 1401 |
const typename dealii::Triangulation<dim, spacedim>::cell_iterator &cell, |
| 1402 |
const unsigned int face_no, |
| 1403 |
const unsigned int subface_no, |
| 1404 |
const typename dealii::QProjector<dim>::DataSetDescriptor data_set, |
| 1405 |
const typename dealii::MappingFEField<dim, spacedim, VectorType>:: |
| 1406 |
InternalData &data, |
| 1407 |
const FiniteElement<dim, spacedim> &fe, |
| 1408 |
const ComponentMask &fe_mask, |
| 1409 |
const std::vector<unsigned int> &fe_to_real, |
| 1410 |
internal::FEValuesImplementation::MappingRelatedData<dim, spacedim> |
| 1411 |
&output_data) |
| 1412 |
{ |
| 1413 |
maybe_compute_q_points<dim, spacedim, VectorType>( |
| 1414 |
data_set, data, fe, fe_mask, fe_to_real, output_data.quadrature_points); |
| 1415 |
|
| 1416 |
maybe_update_Jacobians<dim, spacedim, VectorType>( |
| 1417 |
data_set, data, fe, fe_mask, fe_to_real); |
| 1418 |
|
| 1419 |
const UpdateFlags update_flags = data.update_each; |
| 1420 |
const unsigned int n_q_points = data.contravariant.size(); |
| 1421 |
|
| 1422 |
if (update_flags & update_jacobians) |
| 1423 |
for (unsigned int point = 0; point < n_q_points; ++point) |
| 1424 |
output_data.jacobians[point] = data.contravariant[point]; |
| 1425 |
|
| 1426 |
if (update_flags & update_inverse_jacobians) |
| 1427 |
for (unsigned int point = 0; point < n_q_points; ++point) |
| 1428 |
output_data.inverse_jacobians[point] = |
| 1429 |
data.covariant[point].transpose(); |
| 1430 |
|
| 1431 |
maybe_update_jacobian_grads<dim, spacedim, VectorType>( |
| 1432 |
data_set, data, fe, fe_mask, fe_to_real, output_data.jacobian_grads); |
| 1433 |
|
| 1434 |
maybe_update_jacobian_pushed_forward_grads<dim, spacedim, VectorType>( |
| 1435 |
data_set, |
| 1436 |
data, |
| 1437 |
fe, |
| 1438 |
fe_mask, |
| 1439 |
fe_to_real, |
| 1440 |
output_data.jacobian_pushed_forward_grads); |
| 1441 |
|
| 1442 |
maybe_update_jacobian_2nd_derivatives<dim, spacedim, VectorType>( |
| 1443 |
data_set, |
| 1444 |
data, |
| 1445 |
fe, |
| 1446 |
fe_mask, |
| 1447 |
fe_to_real, |
| 1448 |
output_data.jacobian_2nd_derivatives); |
| 1449 |
|
| 1450 |
maybe_update_jacobian_pushed_forward_2nd_derivatives<dim, |
| 1451 |
spacedim, |
| 1452 |
VectorType>( |
| 1453 |
data_set, |
| 1454 |
data, |
| 1455 |
fe, |
| 1456 |
fe_mask, |
| 1457 |
fe_to_real, |
| 1458 |
output_data.jacobian_pushed_forward_2nd_derivatives); |
| 1459 |
|
| 1460 |
maybe_update_jacobian_3rd_derivatives<dim, spacedim, VectorType>( |
| 1461 |
data_set, |
| 1462 |
data, |
| 1463 |
fe, |
| 1464 |
fe_mask, |
| 1465 |
fe_to_real, |
| 1466 |
output_data.jacobian_3rd_derivatives); |
| 1467 |
|
| 1468 |
maybe_update_jacobian_pushed_forward_3rd_derivatives<dim, |
| 1469 |
spacedim, |
| 1470 |
VectorType>( |
| 1471 |
data_set, |
| 1472 |
data, |
| 1473 |
fe, |
| 1474 |
fe_mask, |
| 1475 |
fe_to_real, |
| 1476 |
output_data.jacobian_pushed_forward_3rd_derivatives); |
| 1477 |
|
| 1478 |
maybe_compute_face_data<dim, spacedim, VectorType>( |
| 1479 |
mapping, cell, face_no, subface_no, data_set, data, output_data); |
| 1480 |
} |
| 1481 |
} // namespace MappingFEFieldImplementation |
| 1482 |
} // namespace internal |
| 1483 |
|
| 1484 |
|
| 1485 |
// Note that the CellSimilarity flag is modifiable, since MappingFEField can |
| 1486 |
// need to recalculate data even when cells are similar. |
| 1487 |
template <int dim, int spacedim, typename VectorType> |
| 1488 |
CellSimilarity::Similarity |
| 1489 |
MappingFEField<dim, spacedim, VectorType>::fill_fe_values( |
| 1490 |
const typename Triangulation<dim, spacedim>::cell_iterator &cell, |
| 1491 |
const CellSimilarity::Similarity, |
| 1492 |
const Quadrature<dim> &quadrature, |
| 1493 |
const typename Mapping<dim, spacedim>::InternalDataBase &internal_data, |
| 1494 |
internal::FEValuesImplementation::MappingRelatedData<dim, spacedim> |
| 1495 |
&output_data) const |
| 1496 |
{ |
| 1497 |
// convert data object to internal data for this class. fails with an |
| 1498 |
// exception if that is not possible |
| 1499 |
Assert(dynamic_cast<const InternalData *>(&internal_data) != nullptr, |
| 1500 |
ExcInternalError()); |
| 1501 |
const InternalData &data = static_cast<const InternalData &>(internal_data); |
| 1502 |
|
| 1503 |
const unsigned int n_q_points = quadrature.size(); |
| 1504 |
|
| 1505 |
update_internal_dofs(cell, data); |
| 1506 |
|
| 1507 |
internal::MappingFEFieldImplementation:: |
| 1508 |
maybe_compute_q_points<dim, spacedim, VectorType>( |
| 1509 |
QProjector<dim>::DataSetDescriptor::cell(), |
| 1510 |
data, |
| 1511 |
euler_dof_handler->get_fe(), |
| 1512 |
fe_mask, |
| 1513 |
fe_to_real, |
| 1514 |
output_data.quadrature_points); |
| 1515 |
|
| 1516 |
internal::MappingFEFieldImplementation:: |
| 1517 |
maybe_update_Jacobians<dim, spacedim, VectorType>( |
| 1518 |
QProjector<dim>::DataSetDescriptor::cell(), |
| 1519 |
data, |
| 1520 |
euler_dof_handler->get_fe(), |
| 1521 |
fe_mask, |
| 1522 |
fe_to_real); |
| 1523 |
|
| 1524 |
const UpdateFlags update_flags = data.update_each; |
| 1525 |
const std::vector<double> &weights = quadrature.get_weights(); |
| 1526 |
|
| 1527 |
// Multiply quadrature weights by absolute value of Jacobian determinants or |
| 1528 |
// the area element g=sqrt(DX^t DX) in case of codim > 0 |
| 1529 |
|
| 1530 |
if (update_flags & (update_normal_vectors | update_JxW_values)) |
| 1531 |
{ |
| 1532 |
AssertDimension(output_data.JxW_values.size(), n_q_points); |
| 1533 |
|
| 1534 |
Assert(!(update_flags & update_normal_vectors) || |
| 1535 |
(output_data.normal_vectors.size() == n_q_points), |
| 1536 |
ExcDimensionMismatch(output_data.normal_vectors.size(), |
| 1537 |
n_q_points)); |
| 1538 |
|
| 1539 |
|
| 1540 |
for (unsigned int point = 0; point < n_q_points; ++point) |
| 1541 |
{ |
| 1542 |
if (dim == spacedim) |
| 1543 |
{ |
| 1544 |
const double det = data.volume_elements[point]; |
| 1545 |
|
| 1546 |
// check for distorted cells. |
| 1547 |
|
| 1548 |
// TODO: this allows for anisotropies of up to 1e6 in 3d and |
| 1549 |
// 1e12 in 2d. might want to find a finer |
| 1550 |
// (dimension-independent) criterion |
| 1551 |
Assert(det > 1e-12 * Utilities::fixed_power<dim>( |
| 1552 |
cell->diameter() / std::sqrt(double(dim))), |
| 1553 |
(typename Mapping<dim, spacedim>::ExcDistortedMappedCell( |
| 1554 |
cell->center(), det, point))); |
| 1555 |
output_data.JxW_values[point] = weights[point] * det; |
| 1556 |
} |
| 1557 |
// if dim==spacedim, then there is no cell normal to |
| 1558 |
// compute. since this is for FEValues (and not FEFaceValues), |
| 1559 |
// there are also no face normals to compute |
| 1560 |
else // codim>0 case |
| 1561 |
{ |
| 1562 |
Tensor<1, spacedim> DX_t[dim]; |
| 1563 |
for (unsigned int i = 0; i < spacedim; ++i) |
| 1564 |
for (unsigned int j = 0; j < dim; ++j) |
| 1565 |
DX_t[j][i] = data.contravariant[point][i][j]; |
| 1566 |
|
| 1567 |
Tensor<2, dim> G; // First fundamental form |
| 1568 |
for (unsigned int i = 0; i < dim; ++i) |
| 1569 |
for (unsigned int j = 0; j < dim; ++j) |
| 1570 |
G[i][j] = DX_t[i] * DX_t[j]; |
| 1571 |
|
| 1572 |
output_data.JxW_values[point] = |
| 1573 |
std::sqrt(determinant(G)) * weights[point]; |
| 1574 |
|
| 1575 |
if (update_flags & update_normal_vectors) |
| 1576 |
{ |
| 1577 |
Assert(spacedim - dim == 1, |
| 1578 |
ExcMessage("There is no cell normal in codim 2.")); |
| 1579 |
|
| 1580 |
if (dim == 1) |
| 1581 |
output_data.normal_vectors[point] = |
| 1582 |
cross_product_2d(-DX_t[0]); |
| 1583 |
else |
| 1584 |
{ |
| 1585 |
Assert(dim == 2, ExcInternalError()); |
| 1586 |
|
| 1587 |
// dim-1==1 for the second argument, but this |
| 1588 |
// avoids a compiler warning about array bounds: |
| 1589 |
output_data.normal_vectors[point] = |
| 1590 |
cross_product_3d(DX_t[0], DX_t[dim - 1]); |
| 1591 |
} |
| 1592 |
|
| 1593 |
output_data.normal_vectors[point] /= |
| 1594 |
output_data.normal_vectors[point].norm(); |
| 1595 |
|
| 1596 |
if (cell->direction_flag() == false) |
| 1597 |
output_data.normal_vectors[point] *= -1.; |
| 1598 |
} |
| 1599 |
} // codim>0 case |
| 1600 |
} |
| 1601 |
} |
| 1602 |
|
| 1603 |
// copy values from InternalData to vector given by reference |
| 1604 |
if (update_flags & update_jacobians) |
| 1605 |
{ |
| 1606 |
AssertDimension(output_data.jacobians.size(), n_q_points); |
| 1607 |
for (unsigned int point = 0; point < n_q_points; ++point) |
| 1608 |
output_data.jacobians[point] = data.contravariant[point]; |
| 1609 |
} |
| 1610 |
|
| 1611 |
// copy values from InternalData to vector given by reference |
| 1612 |
if (update_flags & update_inverse_jacobians) |
| 1613 |
{ |
| 1614 |
AssertDimension(output_data.inverse_jacobians.size(), n_q_points); |
| 1615 |
for (unsigned int point = 0; point < n_q_points; ++point) |
| 1616 |
output_data.inverse_jacobians[point] = |
| 1617 |
data.covariant[point].transpose(); |
| 1618 |
} |
| 1619 |
|
| 1620 |
// calculate derivatives of the Jacobians |
| 1621 |
internal::MappingFEFieldImplementation:: |
| 1622 |
maybe_update_jacobian_grads<dim, spacedim, VectorType>( |
| 1623 |
QProjector<dim>::DataSetDescriptor::cell(), |
| 1624 |
data, |
| 1625 |
euler_dof_handler->get_fe(), |
| 1626 |
fe_mask, |
| 1627 |
fe_to_real, |
| 1628 |
output_data.jacobian_grads); |
| 1629 |
|
| 1630 |
// calculate derivatives of the Jacobians pushed forward to real cell |
| 1631 |
// coordinates |
| 1632 |
internal::MappingFEFieldImplementation:: |
| 1633 |
maybe_update_jacobian_pushed_forward_grads<dim, spacedim, VectorType>( |
| 1634 |
QProjector<dim>::DataSetDescriptor::cell(), |
| 1635 |
data, |
| 1636 |
euler_dof_handler->get_fe(), |
| 1637 |
fe_mask, |
| 1638 |
fe_to_real, |
| 1639 |
output_data.jacobian_pushed_forward_grads); |
| 1640 |
|
| 1641 |
// calculate hessians of the Jacobians |
| 1642 |
internal::MappingFEFieldImplementation:: |
| 1643 |
maybe_update_jacobian_2nd_derivatives<dim, spacedim, VectorType>( |
| 1644 |
QProjector<dim>::DataSetDescriptor::cell(), |
| 1645 |
data, |
| 1646 |
euler_dof_handler->get_fe(), |
| 1647 |
fe_mask, |
| 1648 |
fe_to_real, |
| 1649 |
output_data.jacobian_2nd_derivatives); |
| 1650 |
|
| 1651 |
// calculate hessians of the Jacobians pushed forward to real cell coordinates |
| 1652 |
internal::MappingFEFieldImplementation:: |
| 1653 |
maybe_update_jacobian_pushed_forward_2nd_derivatives<dim, |
| 1654 |
spacedim, |
| 1655 |
VectorType>( |
| 1656 |
QProjector<dim>::DataSetDescriptor::cell(), |
| 1657 |
data, |
| 1658 |
euler_dof_handler->get_fe(), |
| 1659 |
fe_mask, |
| 1660 |
fe_to_real, |
| 1661 |
output_data.jacobian_pushed_forward_2nd_derivatives); |
| 1662 |
|
| 1663 |
// calculate gradients of the hessians of the Jacobians |
| 1664 |
internal::MappingFEFieldImplementation:: |
| 1665 |
maybe_update_jacobian_3rd_derivatives<dim, spacedim, VectorType>( |
| 1666 |
QProjector<dim>::DataSetDescriptor::cell(), |
| 1667 |
data, |
| 1668 |
euler_dof_handler->get_fe(), |
| 1669 |
fe_mask, |
| 1670 |
fe_to_real, |
| 1671 |
output_data.jacobian_3rd_derivatives); |
| 1672 |
|
| 1673 |
// calculate gradients of the hessians of the Jacobians pushed forward to real |
| 1674 |
// cell coordinates |
| 1675 |
internal::MappingFEFieldImplementation:: |
| 1676 |
maybe_update_jacobian_pushed_forward_3rd_derivatives<dim, |
| 1677 |
spacedim, |
| 1678 |
VectorType>( |
| 1679 |
QProjector<dim>::DataSetDescriptor::cell(), |
| 1680 |
data, |
| 1681 |
euler_dof_handler->get_fe(), |
| 1682 |
fe_mask, |
| 1683 |
fe_to_real, |
| 1684 |
output_data.jacobian_pushed_forward_3rd_derivatives); |
| 1685 |
|
| 1686 |
return CellSimilarity::invalid_next_cell; |
| 1687 |
} |
| 1688 |
|
| 1689 |
|
| 1690 |
|
| 1691 |
template <int dim, int spacedim, typename VectorType> |
| 1692 |
void |
| 1693 |
MappingFEField<dim, spacedim, VectorType>::fill_fe_face_values( |
| 1694 |
const typename Triangulation<dim, spacedim>::cell_iterator &cell, |
| 1695 |
const unsigned int face_no, |
| 1696 |
const hp::QCollection<dim - 1> &quadrature, |
| 1697 |
const typename Mapping<dim, spacedim>::InternalDataBase &internal_data, |
| 1698 |
internal::FEValuesImplementation::MappingRelatedData<dim, spacedim> |
| 1699 |
&output_data) const |
| 1700 |
{ |
| 1701 |
AssertDimension(quadrature.size(), 1); |
| 1702 |
|
| 1703 |
// convert data object to internal data for this class. fails with an |
| 1704 |
// exception if that is not possible |
| 1705 |
Assert(dynamic_cast<const InternalData *>(&internal_data) != nullptr, |
| 1706 |
ExcInternalError()); |
| 1707 |
const InternalData &data = static_cast<const InternalData &>(internal_data); |
| 1708 |
|
| 1709 |
update_internal_dofs(cell, data); |
| 1710 |
|
| 1711 |
internal::MappingFEFieldImplementation:: |
| 1712 |
do_fill_fe_face_values<dim, spacedim, VectorType>( |
| 1713 |
*this, |
| 1714 |
cell, |
| 1715 |
face_no, |
| 1716 |
numbers::invalid_unsigned_int, |
| 1717 |
QProjector<dim>::DataSetDescriptor::face(reference_cell, |
| 1718 |
face_no, |
| 1719 |
cell->combined_face_orientation( |
| 1720 |
face_no), |
| 1721 |
quadrature[0].size()), |
| 1722 |
data, |
| 1723 |
euler_dof_handler->get_fe(), |
| 1724 |
fe_mask, |
| 1725 |
fe_to_real, |
| 1726 |
output_data); |
| 1727 |
} |
| 1728 |
|
| 1729 |
|
| 1730 |
template <int dim, int spacedim, typename VectorType> |
| 1731 |
void |
| 1732 |
MappingFEField<dim, spacedim, VectorType>::fill_fe_subface_values( |
| 1733 |
const typename Triangulation<dim, spacedim>::cell_iterator &cell, |
| 1734 |
const unsigned int face_no, |
| 1735 |
const unsigned int subface_no, |
| 1736 |
const Quadrature<dim - 1> &quadrature, |
| 1737 |
const typename Mapping<dim, spacedim>::InternalDataBase &internal_data, |
| 1738 |
internal::FEValuesImplementation::MappingRelatedData<dim, spacedim> |
| 1739 |
&output_data) const |
| 1740 |
{ |
| 1741 |
// convert data object to internal data for this class. fails with an |
| 1742 |
// exception if that is not possible |
| 1743 |
Assert(dynamic_cast<const InternalData *>(&internal_data) != nullptr, |
| 1744 |
ExcInternalError()); |
| 1745 |
const InternalData &data = static_cast<const InternalData &>(internal_data); |
| 1746 |
|
| 1747 |
update_internal_dofs(cell, data); |
| 1748 |
|
| 1749 |
internal::MappingFEFieldImplementation::do_fill_fe_face_values<dim, |
| 1750 |
spacedim, |
| 1751 |
VectorType>( |
| 1752 |
*this, |
| 1753 |
cell, |
| 1754 |
face_no, |
| 1755 |
numbers::invalid_unsigned_int, |
| 1756 |
QProjector<dim>::DataSetDescriptor::subface(reference_cell, |
| 1757 |
face_no, |
| 1758 |
subface_no, |
| 1759 |
cell->combined_face_orientation( |
| 1760 |
face_no), |
| 1761 |
quadrature.size(), |
| 1762 |
cell->subface_case(face_no)), |
| 1763 |
data, |
| 1764 |
euler_dof_handler->get_fe(), |
| 1765 |
fe_mask, |
| 1766 |
fe_to_real, |
| 1767 |
output_data); |
| 1768 |
} |
| 1769 |
|
| 1770 |
|
| 1771 |
|
| 1772 |
template <int dim, int spacedim, typename VectorType> |
| 1773 |
void |
| 1774 |
MappingFEField<dim, spacedim, VectorType>::fill_fe_immersed_surface_values( |
| 1775 |
const typename Triangulation<dim, spacedim>::cell_iterator &cell, |
| 1776 |
const NonMatching::ImmersedSurfaceQuadrature<dim> &quadrature, |
| 1777 |
const typename Mapping<dim, spacedim>::InternalDataBase &internal_data, |
| 1778 |
internal::FEValuesImplementation::MappingRelatedData<dim, spacedim> |
| 1779 |
&output_data) const |
| 1780 |
{ |
| 1781 |
AssertDimension(dim, spacedim); |
| 1782 |
Assert(dynamic_cast<const InternalData *>(&internal_data) != nullptr, |
| 1783 |
ExcInternalError()); |
| 1784 |
const InternalData &data = static_cast<const InternalData &>(internal_data); |
| 1785 |
|
| 1786 |
const unsigned int n_q_points = quadrature.size(); |
| 1787 |
|
| 1788 |
update_internal_dofs(cell, data); |
| 1789 |
|
| 1790 |
internal::MappingFEFieldImplementation:: |
| 1791 |
maybe_compute_q_points<dim, spacedim, VectorType>( |
| 1792 |
QProjector<dim>::DataSetDescriptor::cell(), |
| 1793 |
data, |
| 1794 |
euler_dof_handler->get_fe(), |
| 1795 |
fe_mask, |
| 1796 |
fe_to_real, |
| 1797 |
output_data.quadrature_points); |
| 1798 |
|
| 1799 |
internal::MappingFEFieldImplementation:: |
| 1800 |
maybe_update_Jacobians<dim, spacedim, VectorType>( |
| 1801 |
QProjector<dim>::DataSetDescriptor::cell(), |
| 1802 |
data, |
| 1803 |
euler_dof_handler->get_fe(), |
| 1804 |
fe_mask, |
| 1805 |
fe_to_real); |
| 1806 |
|
| 1807 |
const UpdateFlags update_flags = data.update_each; |
| 1808 |
const std::vector<double> &weights = quadrature.get_weights(); |
| 1809 |
|
| 1810 |
if (update_flags & (update_normal_vectors | update_JxW_values)) |
| 1811 |
{ |
| 1812 |
AssertDimension(output_data.JxW_values.size(), n_q_points); |
| 1813 |
|
| 1814 |
Assert(!(update_flags & update_normal_vectors) || |
| 1815 |
(output_data.normal_vectors.size() == n_q_points), |
| 1816 |
ExcDimensionMismatch(output_data.normal_vectors.size(), |
| 1817 |
n_q_points)); |
| 1818 |
|
| 1819 |
|
| 1820 |
for (unsigned int point = 0; point < n_q_points; ++point) |
| 1821 |
{ |
| 1822 |
const double det = data.volume_elements[point]; |
| 1823 |
|
| 1824 |
// check for distorted cells. |
| 1825 |
|
| 1826 |
// TODO: this allows for anisotropies of up to 1e6 in 3d and |
| 1827 |
// 1e12 in 2d. might want to find a finer |
| 1828 |
// (dimension-independent) criterion |
| 1829 |
Assert(det > 1e-12 * Utilities::fixed_power<dim>( |
| 1830 |
cell->diameter() / std::sqrt(double(dim))), |
| 1831 |
(typename Mapping<dim, spacedim>::ExcDistortedMappedCell( |
| 1832 |
cell->center(), det, point))); |
| 1833 |
|
| 1834 |
// The normals are n = J^{-T} * \hat{n} before normalizing. |
| 1835 |
Tensor<1, spacedim> normal; |
| 1836 |
for (unsigned int d = 0; d < spacedim; d++) |
| 1837 |
normal[d] = |
| 1838 |
data.covariant[point][d] * quadrature.normal_vector(point); |
| 1839 |
|
| 1840 |
output_data.JxW_values[point] = weights[point] * det * normal.norm(); |
| 1841 |
|
| 1842 |
if ((update_flags & update_normal_vectors) != 0u) |
| 1843 |
{ |
| 1844 |
normal /= normal.norm(); |
| 1845 |
output_data.normal_vectors[point] = normal; |
| 1846 |
} |
| 1847 |
} |
| 1848 |
|
| 1849 |
// copy values from InternalData to vector given by reference |
| 1850 |
if (update_flags & update_jacobians) |
| 1851 |
{ |
| 1852 |
AssertDimension(output_data.jacobians.size(), n_q_points); |
| 1853 |
for (unsigned int point = 0; point < n_q_points; ++point) |
| 1854 |
output_data.jacobians[point] = data.contravariant[point]; |
| 1855 |
} |
| 1856 |
|
| 1857 |
// copy values from InternalData to vector given by reference |
| 1858 |
if (update_flags & update_inverse_jacobians) |
| 1859 |
{ |
| 1860 |
AssertDimension(output_data.inverse_jacobians.size(), n_q_points); |
| 1861 |
for (unsigned int point = 0; point < n_q_points; ++point) |
| 1862 |
output_data.inverse_jacobians[point] = |
| 1863 |
data.covariant[point].transpose(); |
| 1864 |
} |
| 1865 |
|
| 1866 |
// calculate derivatives of the Jacobians |
| 1867 |
internal::MappingFEFieldImplementation:: |
| 1868 |
maybe_update_jacobian_grads<dim, spacedim, VectorType>( |
| 1869 |
QProjector<dim>::DataSetDescriptor::cell(), |
| 1870 |
data, |
| 1871 |
euler_dof_handler->get_fe(), |
| 1872 |
fe_mask, |
| 1873 |
fe_to_real, |
| 1874 |
output_data.jacobian_grads); |
| 1875 |
|
| 1876 |
// calculate derivatives of the Jacobians pushed forward to real cell |
| 1877 |
// coordinates |
| 1878 |
internal::MappingFEFieldImplementation:: |
| 1879 |
maybe_update_jacobian_pushed_forward_grads<dim, spacedim, VectorType>( |
| 1880 |
QProjector<dim>::DataSetDescriptor::cell(), |
| 1881 |
data, |
| 1882 |
euler_dof_handler->get_fe(), |
| 1883 |
fe_mask, |
| 1884 |
fe_to_real, |
| 1885 |
output_data.jacobian_pushed_forward_grads); |
| 1886 |
|
| 1887 |
// calculate hessians of the Jacobians |
| 1888 |
internal::MappingFEFieldImplementation:: |
| 1889 |
maybe_update_jacobian_2nd_derivatives<dim, spacedim, VectorType>( |
| 1890 |
QProjector<dim>::DataSetDescriptor::cell(), |
| 1891 |
data, |
| 1892 |
euler_dof_handler->get_fe(), |
| 1893 |
fe_mask, |
| 1894 |
fe_to_real, |
| 1895 |
output_data.jacobian_2nd_derivatives); |
| 1896 |
|
| 1897 |
// calculate hessians of the Jacobians pushed forward to real cell |
| 1898 |
// coordinates |
| 1899 |
internal::MappingFEFieldImplementation:: |
| 1900 |
maybe_update_jacobian_pushed_forward_2nd_derivatives<dim, |
| 1901 |
spacedim, |
| 1902 |
VectorType>( |
| 1903 |
QProjector<dim>::DataSetDescriptor::cell(), |
| 1904 |
data, |
| 1905 |
euler_dof_handler->get_fe(), |
| 1906 |
fe_mask, |
| 1907 |
fe_to_real, |
| 1908 |
output_data.jacobian_pushed_forward_2nd_derivatives); |
| 1909 |
|
| 1910 |
// calculate gradients of the hessians of the Jacobians |
| 1911 |
internal::MappingFEFieldImplementation:: |
| 1912 |
maybe_update_jacobian_3rd_derivatives<dim, spacedim, VectorType>( |
| 1913 |
QProjector<dim>::DataSetDescriptor::cell(), |
| 1914 |
data, |
| 1915 |
euler_dof_handler->get_fe(), |
| 1916 |
fe_mask, |
| 1917 |
fe_to_real, |
| 1918 |
output_data.jacobian_3rd_derivatives); |
| 1919 |
|
| 1920 |
// calculate gradients of the hessians of the Jacobians pushed forward to |
| 1921 |
// real cell coordinates |
| 1922 |
internal::MappingFEFieldImplementation:: |
| 1923 |
maybe_update_jacobian_pushed_forward_3rd_derivatives<dim, |
| 1924 |
spacedim, |
| 1925 |
VectorType>( |
| 1926 |
QProjector<dim>::DataSetDescriptor::cell(), |
| 1927 |
data, |
| 1928 |
euler_dof_handler->get_fe(), |
| 1929 |
fe_mask, |
| 1930 |
fe_to_real, |
| 1931 |
output_data.jacobian_pushed_forward_3rd_derivatives); |
| 1932 |
} |
| 1933 |
} |
| 1934 |
|
| 1935 |
namespace internal |
| 1936 |
{ |
| 1937 |
namespace MappingFEFieldImplementation |
| 1938 |
{ |
| 1939 |
template <int dim, int spacedim, int rank, typename VectorType> |
| 1940 |
void |
| 1941 |
transform_fields( |
| 1942 |
const ArrayView<const Tensor<rank, dim>> &input, |
| 1943 |
const MappingKind mapping_kind, |
| 1944 |
const typename Mapping<dim, spacedim>::InternalDataBase &mapping_data, |
| 1945 |
const ArrayView<Tensor<rank, spacedim>> &output) |
| 1946 |
{ |
| 1947 |
AssertDimension(input.size(), output.size()); |
| 1948 |
Assert((dynamic_cast< |
| 1949 |
const typename dealii:: |
| 1950 |
MappingFEField<dim, spacedim, VectorType>::InternalData *>( |
| 1951 |
&mapping_data) != nullptr), |
| 1952 |
ExcInternalError()); |
| 1953 |
const typename dealii::MappingFEField<dim, spacedim, VectorType>:: |
| 1954 |
InternalData &data = static_cast< |
| 1955 |
const typename dealii::MappingFEField<dim, spacedim, VectorType>:: |
| 1956 |
InternalData &>(mapping_data); |
| 1957 |
|
| 1958 |
switch (mapping_kind) |
| 1959 |
{ |
| 1960 |
case mapping_contravariant: |
| 1961 |
{ |
| 1962 |
Assert(data.update_each & update_contravariant_transformation, |
| 1963 |
typename FEValuesBase<dim>::ExcAccessToUninitializedField( |
| 1964 |
"update_contravariant_transformation")); |
| 1965 |
|
| 1966 |
for (unsigned int i = 0; i < output.size(); ++i) |
| 1967 |
output[i] = |
| 1968 |
apply_transformation(data.contravariant[i], input[i]); |
| 1969 |
|
| 1970 |
return; |
| 1971 |
} |
| 1972 |
|
| 1973 |
case mapping_piola: |
| 1974 |
{ |
| 1975 |
Assert(data.update_each & update_contravariant_transformation, |
| 1976 |
typename FEValuesBase<dim>::ExcAccessToUninitializedField( |
| 1977 |
"update_contravariant_transformation")); |
| 1978 |
Assert(data.update_each & update_volume_elements, |
| 1979 |
typename FEValuesBase<dim>::ExcAccessToUninitializedField( |
| 1980 |
"update_volume_elements")); |
| 1981 |
Assert(rank == 1, ExcMessage("Only for rank 1")); |
| 1982 |
for (unsigned int i = 0; i < output.size(); ++i) |
| 1983 |
{ |
| 1984 |
output[i] = |
| 1985 |
apply_transformation(data.contravariant[i], input[i]); |
| 1986 |
output[i] /= data.volume_elements[i]; |
| 1987 |
} |
| 1988 |
return; |
| 1989 |
} |
| 1990 |
|
| 1991 |
|
| 1992 |
// We still allow this operation as in the |
| 1993 |
// reference cell Derivatives are Tensor |
| 1994 |
// rather than DerivativeForm |
| 1995 |
case mapping_covariant: |
| 1996 |
{ |
| 1997 |
Assert(data.update_each & update_contravariant_transformation, |
| 1998 |
typename FEValuesBase<dim>::ExcAccessToUninitializedField( |
| 1999 |
"update_contravariant_transformation")); |
| 2000 |
|
| 2001 |
for (unsigned int i = 0; i < output.size(); ++i) |
| 2002 |
output[i] = apply_transformation(data.covariant[i], input[i]); |
| 2003 |
|
| 2004 |
return; |
| 2005 |
} |
| 2006 |
|
| 2007 |
default: |
| 2008 |
DEAL_II_NOT_IMPLEMENTED(); |
| 2009 |
} |
| 2010 |
} |
| 2011 |
|
| 2012 |
|
| 2013 |
template <int dim, int spacedim, int rank, typename VectorType> |
| 2014 |
void |
| 2015 |
transform_differential_forms( |
| 2016 |
const ArrayView<const DerivativeForm<rank, dim, spacedim>> &input, |
| 2017 |
const MappingKind mapping_kind, |
| 2018 |
const typename Mapping<dim, spacedim>::InternalDataBase &mapping_data, |
| 2019 |
const ArrayView<Tensor<rank + 1, spacedim>> &output) |
| 2020 |
{ |
| 2021 |
AssertDimension(input.size(), output.size()); |
| 2022 |
Assert((dynamic_cast< |
| 2023 |
const typename dealii:: |
| 2024 |
MappingFEField<dim, spacedim, VectorType>::InternalData *>( |
| 2025 |
&mapping_data) != nullptr), |
| 2026 |
ExcInternalError()); |
| 2027 |
const typename dealii::MappingFEField<dim, spacedim, VectorType>:: |
| 2028 |
InternalData &data = static_cast< |
| 2029 |
const typename dealii::MappingFEField<dim, spacedim, VectorType>:: |
| 2030 |
InternalData &>(mapping_data); |
| 2031 |
|
| 2032 |
switch (mapping_kind) |
| 2033 |
{ |
| 2034 |
case mapping_covariant: |
| 2035 |
{ |
| 2036 |
Assert(data.update_each & update_contravariant_transformation, |
| 2037 |
typename FEValuesBase<dim>::ExcAccessToUninitializedField( |
| 2038 |
"update_contravariant_transformation")); |
| 2039 |
|
| 2040 |
for (unsigned int i = 0; i < output.size(); ++i) |
| 2041 |
output[i] = apply_transformation(data.covariant[i], input[i]); |
| 2042 |
|
| 2043 |
return; |
| 2044 |
} |
| 2045 |
default: |
| 2046 |
DEAL_II_NOT_IMPLEMENTED(); |
| 2047 |
} |
| 2048 |
} |
| 2049 |
} // namespace MappingFEFieldImplementation |
| 2050 |
} // namespace internal |
| 2051 |
|
| 2052 |
|
| 2053 |
|
| 2054 |
template <int dim, int spacedim, typename VectorType> |
| 2055 |
void |
| 2056 |
MappingFEField<dim, spacedim, VectorType>::transform( |
| 2057 |
const ArrayView<const Tensor<1, dim>> &input, |
| 2058 |
const MappingKind mapping_kind, |
| 2059 |
const typename Mapping<dim, spacedim>::InternalDataBase &mapping_data, |
| 2060 |
const ArrayView<Tensor<1, spacedim>> &output) const |
| 2061 |
{ |
| 2062 |
AssertDimension(input.size(), output.size()); |
| 2063 |
|
| 2064 |
internal::MappingFEFieldImplementation:: |
| 2065 |
transform_fields<dim, spacedim, 1, VectorType>(input, |
| 2066 |
mapping_kind, |
| 2067 |
mapping_data, |
| 2068 |
output); |
| 2069 |
} |
| 2070 |
|
| 2071 |
|
| 2072 |
|
| 2073 |
template <int dim, int spacedim, typename VectorType> |
| 2074 |
void |
| 2075 |
MappingFEField<dim, spacedim, VectorType>::transform( |
| 2076 |
const ArrayView<const DerivativeForm<1, dim, spacedim>> &input, |
| 2077 |
const MappingKind mapping_kind, |
| 2078 |
const typename Mapping<dim, spacedim>::InternalDataBase &mapping_data, |
| 2079 |
const ArrayView<Tensor<2, spacedim>> &output) const |
| 2080 |
{ |
| 2081 |
AssertDimension(input.size(), output.size()); |
| 2082 |
|
| 2083 |
internal::MappingFEFieldImplementation:: |
| 2084 |
transform_differential_forms<dim, spacedim, 1, VectorType>(input, |
| 2085 |
mapping_kind, |
| 2086 |
mapping_data, |
| 2087 |
output); |
| 2088 |
} |
| 2089 |
|
| 2090 |
|
| 2091 |
|
| 2092 |
template <int dim, int spacedim, typename VectorType> |
| 2093 |
void |
| 2094 |
MappingFEField<dim, spacedim, VectorType>::transform( |
| 2095 |
const ArrayView<const Tensor<2, dim>> &input, |
| 2096 |
const MappingKind, |
| 2097 |
const typename Mapping<dim, spacedim>::InternalDataBase &mapping_data, |
| 2098 |
const ArrayView<Tensor<2, spacedim>> &output) const |
| 2099 |
{ |
| 2100 |
(void)input; |
| 2101 |
(void)output; |
| 2102 |
(void)mapping_data; |
| 2103 |
AssertDimension(input.size(), output.size()); |
| 2104 |
|
| 2105 |
AssertThrow(false, ExcNotImplemented()); |
| 2106 |
} |
| 2107 |
|
| 2108 |
|
| 2109 |
|
| 2110 |
template <int dim, int spacedim, typename VectorType> |
| 2111 |
void |
| 2112 |
MappingFEField<dim, spacedim, VectorType>::transform( |
| 2113 |
const ArrayView<const DerivativeForm<2, dim, spacedim>> &input, |
| 2114 |
const MappingKind mapping_kind, |
| 2115 |
const typename Mapping<dim, spacedim>::InternalDataBase &mapping_data, |
| 2116 |
const ArrayView<Tensor<3, spacedim>> &output) const |
| 2117 |
{ |
| 2118 |
AssertDimension(input.size(), output.size()); |
| 2119 |
Assert(dynamic_cast<const InternalData *>(&mapping_data) != nullptr, |
| 2120 |
ExcInternalError()); |
| 2121 |
const InternalData &data = static_cast<const InternalData &>(mapping_data); |
| 2122 |
|
| 2123 |
switch (mapping_kind) |
| 2124 |
{ |
| 2125 |
case mapping_covariant_gradient: |
| 2126 |
{ |
| 2127 |
Assert(data.update_each & update_covariant_transformation, |
| 2128 |
typename FEValuesBase<dim>::ExcAccessToUninitializedField( |
| 2129 |
"update_covariant_transformation")); |
| 2130 |
|
| 2131 |
for (unsigned int q = 0; q < output.size(); ++q) |
| 2132 |
output[q] = |
| 2133 |
internal::apply_covariant_gradient(data.covariant[q], input[q]); |
| 2134 |
|
| 2135 |
return; |
| 2136 |
} |
| 2137 |
|
| 2138 |
default: |
| 2139 |
DEAL_II_NOT_IMPLEMENTED(); |
| 2140 |
} |
| 2141 |
} |
| 2142 |
|
| 2143 |
|
| 2144 |
|
| 2145 |
template <int dim, int spacedim, typename VectorType> |
| 2146 |
void |
| 2147 |
MappingFEField<dim, spacedim, VectorType>::transform( |
| 2148 |
const ArrayView<const Tensor<3, dim>> &input, |
| 2149 |
const MappingKind /*mapping_kind*/, |
| 2150 |
const typename Mapping<dim, spacedim>::InternalDataBase &mapping_data, |
| 2151 |
const ArrayView<Tensor<3, spacedim>> &output) const |
| 2152 |
{ |
| 2153 |
(void)input; |
| 2154 |
(void)output; |
| 2155 |
(void)mapping_data; |
| 2156 |
AssertDimension(input.size(), output.size()); |
| 2157 |
|
| 2158 |
AssertThrow(false, ExcNotImplemented()); |
| 2159 |
} |
| 2160 |
|
| 2161 |
|
| 2162 |
|
| 2163 |
template <int dim, int spacedim, typename VectorType> |
| 2164 |
Point<spacedim> |
| 2165 |
MappingFEField<dim, spacedim, VectorType>::transform_unit_to_real_cell( |
| 2166 |
const typename Triangulation<dim, spacedim>::cell_iterator &cell, |
| 2167 |
const Point<dim> &p) const |
| 2168 |
{ |
| 2169 |
// Use the get_data function to create an InternalData with data vectors of |
| 2170 |
// the right size and transformation shape values already computed at point |
| 2171 |
// p. |
| 2172 |
const Quadrature<dim> point_quadrature(p); |
| 2173 |
std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase> mdata( |
| 2174 |
get_data(update_quadrature_points | update_jacobians, point_quadrature)); |
| 2175 |
Assert(dynamic_cast<InternalData *>(mdata.get()) != nullptr, |
| 2176 |
ExcInternalError()); |
| 2177 |
|
| 2178 |
update_internal_dofs(cell, static_cast<InternalData &>(*mdata)); |
| 2179 |
|
| 2180 |
return do_transform_unit_to_real_cell(static_cast<InternalData &>(*mdata)); |
| 2181 |
} |
| 2182 |
|
| 2183 |
|
| 2184 |
template <int dim, int spacedim, typename VectorType> |
| 2185 |
Point<spacedim> |
| 2186 |
MappingFEField<dim, spacedim, VectorType>::do_transform_unit_to_real_cell( |
| 2187 |
const InternalData &data) const |
| 2188 |
{ |
| 2189 |
Point<spacedim> p_real; |
| 2190 |
|
| 2191 |
for (unsigned int i = 0; i < data.n_shape_functions; ++i) |
| 2192 |
{ |
| 2193 |
unsigned int comp_i = |
| 2194 |
euler_dof_handler->get_fe().system_to_component_index(i).first; |
| 2195 |
if (fe_mask[comp_i]) |
| 2196 |
p_real[fe_to_real[comp_i]] += |
| 2197 |
data.local_dof_values[i] * data.shape(0, i); |
| 2198 |
} |
| 2199 |
|
| 2200 |
return p_real; |
| 2201 |
} |
| 2202 |
|
| 2203 |
|
| 2204 |
|
| 2205 |
template <int dim, int spacedim, typename VectorType> |
| 2206 |
Point<dim> |
| 2207 |
MappingFEField<dim, spacedim, VectorType>::transform_real_to_unit_cell( |
| 2208 |
const typename Triangulation<dim, spacedim>::cell_iterator &cell, |
| 2209 |
const Point<spacedim> &p) const |
| 2210 |
{ |
| 2211 |
// first a Newton iteration based on the real mapping. It uses the center |
| 2212 |
// point of the cell as a starting point |
| 2213 |
Point<dim> initial_p_unit; |
| 2214 |
try |
| 2215 |
{ |
| 2216 |
initial_p_unit = get_default_linear_mapping(cell->get_triangulation()) |
| 2217 |
.transform_real_to_unit_cell(cell, p); |
| 2218 |
} |
| 2219 |
catch (const typename Mapping<dim, spacedim>::ExcTransformationFailed &) |
| 2220 |
{ |
| 2221 |
// mirror the conditions of the code below to determine if we need to |
| 2222 |
// use an arbitrary starting point or if we just need to rethrow the |
| 2223 |
// exception |
| 2224 |
for (unsigned int d = 0; d < dim; ++d) |
| 2225 |
initial_p_unit[d] = 0.5; |
| 2226 |
} |
| 2227 |
|
| 2228 |
initial_p_unit = cell->reference_cell().closest_point(initial_p_unit); |
| 2229 |
|
| 2230 |
UpdateFlags update_flags = update_quadrature_points | update_jacobians; |
| 2231 |
if (spacedim > dim) |
| 2232 |
update_flags |= update_jacobian_grads; |
| 2233 |
std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase> mdata( |
| 2234 |
get_data(update_flags, Quadrature<dim>(initial_p_unit))); |
| 2235 |
Assert(dynamic_cast<InternalData *>(mdata.get()) != nullptr, |
| 2236 |
ExcInternalError()); |
| 2237 |
|
| 2238 |
update_internal_dofs(cell, static_cast<InternalData &>(*mdata)); |
| 2239 |
|
| 2240 |
return do_transform_real_to_unit_cell(cell, |
| 2241 |
p, |
| 2242 |
initial_p_unit, |
| 2243 |
static_cast<InternalData &>(*mdata)); |
| 2244 |
} |
| 2245 |
|
| 2246 |
|
| 2247 |
template <int dim, int spacedim, typename VectorType> |
| 2248 |
Point<dim> |
| 2249 |
MappingFEField<dim, spacedim, VectorType>::do_transform_real_to_unit_cell( |
| 2250 |
const typename Triangulation<dim, spacedim>::cell_iterator &cell, |
| 2251 |
const Point<spacedim> &p, |
| 2252 |
const Point<dim> &starting_guess, |
| 2253 |
InternalData &mdata) const |
| 2254 |
{ |
| 2255 |
const unsigned int n_shapes = mdata.shape_values.size(); |
| 2256 |
(void)n_shapes; |
| 2257 |
Assert(n_shapes != 0, ExcInternalError()); |
| 2258 |
AssertDimension(mdata.shape_derivatives.size(), n_shapes); |
| 2259 |
|
| 2260 |
|
| 2261 |
// Newton iteration to solve |
| 2262 |
// f(x)=p(x)-p=0 |
| 2263 |
// x_{n+1}=x_n-[f'(x)]^{-1}f(x) |
| 2264 |
// The start value was set to be the |
| 2265 |
// linear approximation to the cell |
| 2266 |
// The shape values and derivatives |
| 2267 |
// of the mapping at this point are |
| 2268 |
// previously computed. |
| 2269 |
|
| 2270 |
Point<dim> p_unit = starting_guess; |
| 2271 |
Point<dim> f; |
| 2272 |
mdata.reinit(mdata.update_each, Quadrature<dim>(starting_guess)); |
| 2273 |
|
| 2274 |
Point<spacedim> p_real(do_transform_unit_to_real_cell(mdata)); |
| 2275 |
Tensor<1, spacedim> p_minus_F = p - p_real; |
| 2276 |
const double eps = 1.e-12 * cell->diameter(); |
| 2277 |
const unsigned int newton_iteration_limit = 20; |
| 2278 |
unsigned int newton_iteration = 0; |
| 2279 |
while (p_minus_F.norm_square() > eps * eps) |
| 2280 |
{ |
| 2281 |
// f'(x) |
| 2282 |
Point<spacedim> DF[dim]; |
| 2283 |
Tensor<2, dim> df; |
| 2284 |
for (unsigned int k = 0; k < mdata.n_shape_functions; ++k) |
| 2285 |
{ |
| 2286 |
const Tensor<1, dim> &grad_k = mdata.derivative(0, k); |
| 2287 |
const unsigned int comp_k = |
| 2288 |
euler_dof_handler->get_fe().system_to_component_index(k).first; |
| 2289 |
if (fe_mask[comp_k]) |
| 2290 |
for (unsigned int j = 0; j < dim; ++j) |
| 2291 |
DF[j][fe_to_real[comp_k]] += |
| 2292 |
mdata.local_dof_values[k] * grad_k[j]; |
| 2293 |
} |
| 2294 |
for (unsigned int j = 0; j < dim; ++j) |
| 2295 |
{ |
| 2296 |
f[j] = DF[j] * p_minus_F; |
| 2297 |
for (unsigned int l = 0; l < dim; ++l) |
| 2298 |
df[j][l] = -DF[j] * DF[l]; |
| 2299 |
} |
| 2300 |
// Solve [f'(x)]d=f(x) |
| 2301 |
const Tensor<1, dim> delta = |
| 2302 |
invert(df) * static_cast<const Tensor<1, dim> &>(f); |
| 2303 |
// do a line search |
| 2304 |
double step_length = 1; |
| 2305 |
do |
| 2306 |
{ |
| 2307 |
// update of p_unit. The |
| 2308 |
// spacedimth component of |
| 2309 |
// transformed point is simply |
| 2310 |
// ignored in codimension one |
| 2311 |
// case. When this component is |
| 2312 |
// not zero, then we are |
| 2313 |
// projecting the point to the |
| 2314 |
// surface or curve identified |
| 2315 |
// by the cell. |
| 2316 |
Point<dim> p_unit_trial = p_unit; |
| 2317 |
for (unsigned int i = 0; i < dim; ++i) |
| 2318 |
p_unit_trial[i] -= step_length * delta[i]; |
| 2319 |
// shape values and derivatives |
| 2320 |
// at new p_unit point |
| 2321 |
mdata.reinit(mdata.update_each, Quadrature<dim>(p_unit_trial)); |
| 2322 |
// f(x) |
| 2323 |
const Point<spacedim> p_real_trial = |
| 2324 |
do_transform_unit_to_real_cell(mdata); |
| 2325 |
const Tensor<1, spacedim> f_trial = p - p_real_trial; |
| 2326 |
// see if we are making progress with the current step length |
| 2327 |
// and if not, reduce it by a factor of two and try again |
| 2328 |
if (f_trial.norm() < p_minus_F.norm()) |
| 2329 |
{ |
| 2330 |
p_real = p_real_trial; |
| 2331 |
p_unit = p_unit_trial; |
| 2332 |
p_minus_F = f_trial; |
| 2333 |
break; |
| 2334 |
} |
| 2335 |
else if (step_length > 0.05) |
| 2336 |
step_length /= 2; |
| 2337 |
else |
| 2338 |
goto failure; |
| 2339 |
} |
| 2340 |
while (true); |
| 2341 |
++newton_iteration; |
| 2342 |
if (newton_iteration > newton_iteration_limit) |
| 2343 |
goto failure; |
| 2344 |
} |
| 2345 |
return p_unit; |
| 2346 |
// if we get to the following label, then we have either run out |
| 2347 |
// of Newton iterations, or the line search has not converged. |
| 2348 |
// in either case, we need to give up, so throw an exception that |
| 2349 |
// can then be caught |
| 2350 |
failure: |
| 2351 |
AssertThrow(false, |
| 2352 |
(typename Mapping<dim, spacedim>::ExcTransformationFailed())); |
| 2353 |
// ...the compiler wants us to return something, though we can |
| 2354 |
// of course never get here... |
| 2355 |
return {}; |
| 2356 |
} |
| 2357 |
|
| 2358 |
|
| 2359 |
template <int dim, int spacedim, typename VectorType> |
| 2360 |
unsigned int |
| 2361 |
MappingFEField<dim, spacedim, VectorType>::get_degree() const |
| 2362 |
{ |
| 2363 |
return euler_dof_handler->get_fe().degree; |
| 2364 |
} |
| 2365 |
|
| 2366 |
|
| 2367 |
|
| 2368 |
template <int dim, int spacedim, typename VectorType> |
| 2369 |
ComponentMask |
| 2370 |
MappingFEField<dim, spacedim, VectorType>::get_component_mask() const |
| 2371 |
{ |
| 2372 |
return this->fe_mask; |
| 2373 |
} |
| 2374 |
|
| 2375 |
|
| 2376 |
template <int dim, int spacedim, typename VectorType> |
| 2377 |
std::unique_ptr<Mapping<dim, spacedim>> |
| 2378 |
MappingFEField<dim, spacedim, VectorType>::clone() const |
| 2379 |
{ |
| 2380 |
return std::make_unique<MappingFEField<dim, spacedim, VectorType>>(*this); |
| 2381 |
} |
| 2382 |
|
| 2383 |
|
| 2384 |
template <int dim, int spacedim, typename VectorType> |
| 2385 |
void |
| 2386 |
MappingFEField<dim, spacedim, VectorType>::update_internal_dofs( |
| 2387 |
const typename Triangulation<dim, spacedim>::cell_iterator &cell, |
| 2388 |
const typename MappingFEField<dim, spacedim, VectorType>::InternalData &data) |
| 2389 |
const |
| 2390 |
{ |
| 2391 |
Assert(euler_dof_handler != nullptr, |
| 2392 |
ExcMessage("euler_dof_handler is empty")); |
| 2393 |
|
| 2394 |
typename DoFHandler<dim, spacedim>::cell_iterator dof_cell(*cell, |
| 2395 |
euler_dof_handler); |
| 2396 |
Assert(uses_level_dofs || dof_cell->is_active() == true, ExcInactiveCell()); |
| 2397 |
if (uses_level_dofs) |
| 2398 |
{ |
| 2399 |
AssertIndexRange(cell->level(), euler_vector.size()); |
| 2400 |
AssertDimension(euler_vector[cell->level()]->size(), |
| 2401 |
euler_dof_handler->n_dofs(cell->level())); |
| 2402 |
} |
| 2403 |
else |
| 2404 |
AssertDimension(euler_vector[0]->size(), euler_dof_handler->n_dofs()); |
| 2405 |
|
| 2406 |
if (uses_level_dofs) |
| 2407 |
dof_cell->get_mg_dof_indices(data.local_dof_indices); |
| 2408 |
else |
| 2409 |
dof_cell->get_dof_indices(data.local_dof_indices); |
| 2410 |
|
| 2411 |
const VectorType &vector = |
| 2412 |
uses_level_dofs ? *euler_vector[cell->level()] : *euler_vector[0]; |
| 2413 |
|
| 2414 |
for (unsigned int i = 0; i < data.local_dof_values.size(); ++i) |
| 2415 |
data.local_dof_values[i] = |
| 2416 |
internal::ElementAccess<VectorType>::get(vector, |
| 2417 |
data.local_dof_indices[i]); |
| 2418 |
} |
| 2419 |
|
| 2420 |
DEAL_II_NAMESPACE_CLOSE |
| 2421 |
|
| 2422 |
#endif |