deal.II version GIT relicensing-6834-g5b78e6bcdf 2026-10-01 11:20:01+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
mapping_q1_eulerian.cc
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2001 - 2025 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13
16
17#include <deal.II/fe/fe.h>
19
21
29#include <deal.II/lac/vector.h>
30
31#include <boost/container/small_vector.hpp>
32
33#include <array>
34#include <memory>
35
36
38
39
40template <int dim, typename VectorType, int spacedim>
42 const DoFHandler<dim, spacedim> &shiftmap_dof_handler,
43 const VectorType &euler_transform_vectors)
44 : MappingQ<dim, spacedim>(1)
45 , euler_transform_vectors(&euler_transform_vectors)
46 , shiftmap_dof_handler(&shiftmap_dof_handler)
47{}
48
49
50
51template <int dim, typename VectorType, int spacedim>
52boost::container::small_vector<Point<spacedim>,
53#ifndef _MSC_VER
54 ReferenceCells::max_n_vertices<dim>()
55#else
57#endif
58 >
60 const typename Triangulation<dim, spacedim>::cell_iterator &cell) const
61{
62 boost::container::small_vector<Point<spacedim>,
63#ifndef _MSC_VER
64 ReferenceCells::max_n_vertices<dim>()
65#else
67#endif
68 >
69 vertices(cell->n_vertices());
70 // The assertions can not be in the constructor, since this would
71 // require to call dof_handler.distribute_dofs(fe) *before* the mapping
72 // object is constructed, which is not necessarily what we want.
73
74 // TODO: Only one of these two assertions should be relevant
75 AssertDimension(spacedim, shiftmap_dof_handler->get_fe().n_dofs_per_vertex());
76 AssertDimension(shiftmap_dof_handler->get_fe(0).n_components(), spacedim);
77
78 AssertDimension(shiftmap_dof_handler->n_dofs(),
79 euler_transform_vectors->size());
80
81 // cast the Triangulation<dim>::cell_iterator into a
82 // DoFHandler<dim>::cell_iterator which is necessary for access to
83 // DoFCellAccessor::get_dof_values()
85 *cell, shiftmap_dof_handler);
86
87 // We require the cell to be active since we can only then get nodal
88 // values for the shifts
89 Assert(dof_cell->is_active() == true, ExcInactiveCell());
90
91 // now get the values of the shift vectors at the vertices
93 shiftmap_dof_handler->get_fe().n_dofs_per_cell());
94 dof_cell->get_dof_values(*euler_transform_vectors, mapping_values);
95
96 for (const unsigned int i : GeometryInfo<dim>::vertex_indices())
97 {
98 Point<spacedim> shift_vector;
99
100 // pick out the value of the shift vector at the present
101 // vertex. since vertex dofs are always numbered first, we can
102 // access them easily
103 for (unsigned int j = 0; j < spacedim; ++j)
104 shift_vector[j] = mapping_values(i * spacedim + j);
105
106 // compute new support point by old (reference) value and added
107 // shift
108 vertices[i] = cell->vertex(i) + shift_vector;
109 }
110 return vertices;
111}
112
113
114
115template <int dim, typename VectorType, int spacedim>
116void
119 boost::container::small_vector<Point<spacedim>, 200> &points) const
120{
121 const auto vertices = this->get_vertices(cell);
122 points.assign(vertices.begin(), vertices.end());
123}
124
125
126
127template <int dim, typename VectorType, int spacedim>
128std::unique_ptr<Mapping<dim, spacedim>>
130{
131 return std::make_unique<MappingQ1Eulerian<dim, VectorType, spacedim>>(*this);
132}
133
134
135
136template <int dim, typename VectorType, int spacedim>
141 const Quadrature<dim> &quadrature,
142 const typename Mapping<dim, spacedim>::InternalDataBase &internal_data,
144 &output_data) const
145{
146 // call the function of the base class, but ignoring
147 // any potentially detected cell similarity between
148 // the current and the previous cell
151 quadrature,
152 internal_data,
153 output_data);
154 // also return the updated flag since any detected
155 // similarity wasn't based on the mapped field, but
156 // the original vertices which are meaningless
158}
159
160
161
162// explicit instantiations
163#include "fe/mapping_q1_eulerian.inst"
164
165
virtual std::unique_ptr< Mapping< dim, spacedim > > clone() const override
virtual CellSimilarity::Similarity fill_fe_values(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const CellSimilarity::Similarity cell_similarity, const Quadrature< dim > &quadrature, const typename Mapping< dim, spacedim >::InternalDataBase &internal_data, internal::FEValuesImplementation::MappingRelatedData< dim, spacedim > &output_data) const override
MappingQ1Eulerian(const DoFHandler< dim, spacedim > &euler_dof_handler, const VectorType &euler_vector)
virtual void compute_mapping_support_points(const typename Triangulation< dim, spacedim >::cell_iterator &cell, boost::container::small_vector< Point< spacedim >, 200 > &points) const override
virtual boost::container::small_vector< Point< spacedim >, ReferenceCells::max_n_vertices< dim >() > get_vertices(const typename Triangulation< dim, spacedim >::cell_iterator &cell) const override
virtual CellSimilarity::Similarity fill_fe_values(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const CellSimilarity::Similarity cell_similarity, const Quadrature< dim > &quadrature, const typename Mapping< dim, spacedim >::InternalDataBase &internal_data, internal::FEValuesImplementation::MappingRelatedData< dim, spacedim > &output_data) const override
Definition mapping_q.cc:856
Definition point.h:111
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
typename ActiveSelector::cell_iterator cell_iterator
static std_cxx20::ranges::iota_view< unsigned int, unsigned int > vertex_indices()