deal.II version GIT relicensing-2392-g6e04ac39aa 2025-01-19 12:50:00+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: LGPL-2.1-or-later
4// Copyright (C) 2001 - 2023 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
18
19#include <deal.II/fe/fe.h>
21
23
31#include <deal.II/lac/vector.h>
32
33#include <array>
34#include <memory>
35
37
38
39template <int dim, typename VectorType, int spacedim>
41 const DoFHandler<dim, spacedim> &shiftmap_dof_handler,
42 const VectorType &euler_transform_vectors)
43 : MappingQ<dim, spacedim>(1)
44 , euler_transform_vectors(&euler_transform_vectors)
45 , shiftmap_dof_handler(&shiftmap_dof_handler)
46{}
47
48
49
50template <int dim, typename VectorType, int spacedim>
51boost::container::small_vector<Point<spacedim>,
52#ifndef _MSC_VER
53 ReferenceCells::max_n_vertices<dim>()
54#else
56#endif
57 >
59 const typename Triangulation<dim, spacedim>::cell_iterator &cell) const
60{
61 boost::container::small_vector<Point<spacedim>,
62#ifndef _MSC_VER
63 ReferenceCells::max_n_vertices<dim>()
64#else
66#endif
67 >
68 vertices(cell->n_vertices());
69 // The assertions can not be in the constructor, since this would
70 // require to call dof_handler.distribute_dofs(fe) *before* the mapping
71 // object is constructed, which is not necessarily what we want.
72
73 // TODO: Only one of these two assertions should be relevant
74 AssertDimension(spacedim, shiftmap_dof_handler->get_fe().n_dofs_per_vertex());
75 AssertDimension(shiftmap_dof_handler->get_fe(0).n_components(), spacedim);
76
77 AssertDimension(shiftmap_dof_handler->n_dofs(),
78 euler_transform_vectors->size());
79
80 // cast the Triangulation<dim>::cell_iterator into a
81 // DoFHandler<dim>::cell_iterator which is necessary for access to
82 // DoFCellAccessor::get_dof_values()
84 *cell, shiftmap_dof_handler);
85
86 // We require the cell to be active since we can only then get nodal
87 // values for the shifts
88 Assert(dof_cell->is_active() == true, ExcInactiveCell());
89
90 // now get the values of the shift vectors at the vertices
92 shiftmap_dof_handler->get_fe().n_dofs_per_cell());
93 dof_cell->get_dof_values(*euler_transform_vectors, mapping_values);
94
95 for (const unsigned int i : GeometryInfo<dim>::vertex_indices())
96 {
97 Point<spacedim> shift_vector;
98
99 // pick out the value of the shift vector at the present
100 // vertex. since vertex dofs are always numbered first, we can
101 // access them easily
102 for (unsigned int j = 0; j < spacedim; ++j)
103 shift_vector[j] = mapping_values(i * spacedim + j);
104
105 // compute new support point by old (reference) value and added
106 // shift
107 vertices[i] = cell->vertex(i) + shift_vector;
108 }
109 return vertices;
110}
111
112
113
114template <int dim, typename VectorType, int spacedim>
115std::vector<Point<spacedim>>
117 const typename Triangulation<dim, spacedim>::cell_iterator &cell) const
118{
119 const auto vertices = this->get_vertices(cell);
120
121 std::vector<Point<spacedim>> a(GeometryInfo<dim>::vertices_per_cell);
122 for (const unsigned int i : GeometryInfo<dim>::vertex_indices())
123 a[i] = vertices[i];
124
125 return a;
126}
127
128
129
130template <int dim, typename VectorType, int spacedim>
131std::unique_ptr<Mapping<dim, spacedim>>
133{
134 return std::make_unique<MappingQ1Eulerian<dim, VectorType, spacedim>>(*this);
135}
136
137
138
139template <int dim, typename VectorType, int spacedim>
144 const Quadrature<dim> &quadrature,
145 const typename Mapping<dim, spacedim>::InternalDataBase &internal_data,
147 &output_data) const
148{
149 // call the function of the base class, but ignoring
150 // any potentially detected cell similarity between
151 // the current and the previous cell
154 quadrature,
155 internal_data,
156 output_data);
157 // also return the updated flag since any detected
158 // similarity wasn't based on the mapped field, but
159 // the original vertices which are meaningless
161}
162
163
164
165// explicit instantiations
166#include "mapping_q1_eulerian.inst"
167
168
virtual std::vector< Point< spacedim > > compute_mapping_support_points(const typename Triangulation< dim, spacedim >::cell_iterator &cell) const override
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 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:833
Definition point.h:111
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:498
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:499
#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()