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.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 - 2026 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
15
16#include <deal.II/fe/mapping.h>
17
18#include <deal.II/grid/tria.h>
19
20#ifdef DEAL_II_BOOST_HAS_BROKEN_HEADER_DEPRECATIONS
21# define BOOST_ALLOW_DEPRECATED_HEADERS
22#endif
23#include <boost/geometry.hpp>
24#ifdef DEAL_II_BOOST_HAS_BROKEN_HEADER_DEPRECATIONS
25# undef BOOST_ALLOW_DEPRECATED_HEADERS
26#endif
27
28#include <limits>
29
31#ifndef DOXYGEN
32
33template <int dim, int spacedim>
34boost::container::small_vector<Point<spacedim>,
35# ifndef _MSC_VER
36 ReferenceCells::max_n_vertices<dim>()
37# else
39# endif
40 >
42 const typename Triangulation<dim, spacedim>::cell_iterator &cell) const
43{
44 boost::container::small_vector<Point<spacedim>,
45# ifndef _MSC_VER
46 ReferenceCells::max_n_vertices<dim>()
47# else
49# endif
50 >
51 vertices;
52 for (const unsigned int i : cell->vertex_indices())
53 vertices.push_back(cell->vertex(i));
54
55 return vertices;
56}
57
58
59
60template <int dim, int spacedim>
61boost::container::small_vector<Point<spacedim>,
62# ifndef _MSC_VER
64# else
66# endif
67 >
70 const unsigned int face_no) const
71{
72 boost::container::small_vector<Point<spacedim>,
73# ifndef _MSC_VER
75# else
77# endif
78 >
79 face_vertices;
80
81 const auto &cell_vertices = get_vertices(cell);
82 const auto &reference_cell = cell->reference_cell();
83 const auto face_orientation = cell->combined_face_orientation(face_no);
84
85 for (const unsigned int v :
86 reference_cell.face_reference_cell(face_no).vertex_indices())
87 {
88 face_vertices.push_back(
89 cell_vertices[reference_cell.face_to_cell_vertices(
90 face_no, v, face_orientation)]);
91 }
92
93 return face_vertices;
94}
95
96
97
98template <int dim, int spacedim>
102 const bool map_barycenter_of_reference_cell) const
103{
104 if (map_barycenter_of_reference_cell)
105 {
106 return transform_unit_to_real_cell(cell,
107 cell->reference_cell().barycenter());
108 }
109 else
110 {
111 const auto vertices = get_vertices(cell);
112 Point<spacedim> center;
113 for (const auto &v : vertices)
114 center += v;
115 return center / cell->n_vertices();
116 }
117}
118
119
120
121template <int dim, int spacedim>
124 const typename Triangulation<dim, spacedim>::cell_iterator &cell) const
125{
126 if (preserves_vertex_locations())
127 return cell->bounding_box();
128 else
129 return BoundingBox<spacedim>(get_vertices(cell));
130}
131
132
133
134template <int dim, int spacedim>
135void
141{
143}
144
145
146
147template <int dim, int spacedim>
148void
151 const ArrayView<const Point<spacedim>> &real_points,
152 const ArrayView<Point<dim>> &unit_points) const
153{
154 AssertDimension(real_points.size(), unit_points.size());
155 for (unsigned int i = 0; i < real_points.size(); ++i)
156 {
157 try
158 {
159 unit_points[i] = transform_real_to_unit_cell(cell, real_points[i]);
160 }
162 {
163 // If the transformation for this one point failed, mark it
164 // as invalid as described in the documentation.
165 unit_points[i] = Point<dim>();
166 unit_points[i][0] = std::numeric_limits<double>::lowest();
167 }
168 }
169}
170
171
172
173template <int dim, int spacedim>
174Point<dim - 1>
177 const unsigned int face_no,
178 const Point<spacedim> &p) const
179{
180 // The function doesn't make physical sense for dim=1
181 Assert(dim > 1, ExcNotImplemented());
182 // Not implemented for higher dimensions
183 Assert(dim <= 3, ExcNotImplemented());
184
185 Point<dim> unit_cell_pt = transform_real_to_unit_cell(cell, p);
186
187 const unsigned int unit_normal_direction =
189
190 if (dim == 2)
191 {
192 if (unit_normal_direction == 0)
193 return Point<dim - 1>{unit_cell_pt[1]};
194 else if (unit_normal_direction == 1)
195 return Point<dim - 1>{unit_cell_pt[0]};
196 }
197 else if (dim == 3)
198 {
199 if (unit_normal_direction == 0)
200 return Point<dim - 1>{unit_cell_pt[1], unit_cell_pt[2]};
201 else if (unit_normal_direction == 1)
202 return Point<dim - 1>{unit_cell_pt[0], unit_cell_pt[2]};
203 else if (unit_normal_direction == 2)
204 return Point<dim - 1>{unit_cell_pt[0], unit_cell_pt[1]};
205 }
206
207 // We should never get here
209 return {};
210}
211
212
213
214# ifndef DOXYGEN
215template <int dim, int spacedim>
216void
219 const unsigned int face_no,
220 const hp::QCollection<dim - 1> &quadrature,
221 const typename Mapping<dim, spacedim>::InternalDataBase &internal_data,
223 &output_data) const
224{
225 // base class version, implement overridden function in derived classes
226 AssertDimension(quadrature.size(), 1);
227 fill_fe_face_values(cell, face_no, quadrature[0], internal_data, output_data);
228}
229
230
231
232template <int dim, int spacedim>
233void
236 const unsigned int face_no,
237 const Quadrature<dim - 1> &quadrature,
238 const typename Mapping<dim, spacedim>::InternalDataBase &internal_data,
240 &output_data) const
241{
242 Assert(false,
243 ExcMessage("Use of a deprecated interface, please implement "
244 "fill_fe_face_values taking a hp::QCollection argument"));
245 (void)cell;
246 (void)face_no;
247 (void)quadrature;
248 (void)internal_data;
249 (void)output_data;
250}
251
252
253
254template <int dim, int spacedim>
255std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>
257 const UpdateFlags update_flags,
258 const hp::QCollection<dim - 1> &quadrature) const
259{
260 // base class version, implement overridden function in derived classes
261 return get_face_data(update_flags, quadrature[0]);
262}
263
264
265
266template <int dim, int spacedim>
267std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>
269 const UpdateFlags update_flags,
270 const Quadrature<dim - 1> &quadrature) const
271{
272 Assert(false,
273 ExcMessage("Use of a deprecated interface, please implement "
274 "fill_fe_face_values taking a hp::QCollection argument"));
275 (void)update_flags;
276 (void)quadrature;
277
278 return std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>();
279}
280# endif
281
282/* ---------------------------- InternalDataBase --------------------------- */
283
284
285template <int dim, int spacedim>
287 : update_each(update_default)
288{}
289
290
291
292template <int dim, int spacedim>
293void
295 const Quadrature<dim> &)
296{
298}
299
300
301
302template <int dim, int spacedim>
303std::size_t
305{
306 return sizeof(*this);
307}
308#endif
309
310/* ------------------------------ Global functions ------------------------- */
311
312template <int dim, int spacedim>
315{
316 const auto &reference_cells = triangulation.get_reference_cells();
317 Assert(reference_cells.size() == 1,
319 "This function can only work for triangulations that "
320 "use only a single cell type -- for example, only triangles "
321 "or only quadrilaterals. For mixed meshes, there is no "
322 "single linear mapping object that can be used for all "
323 "cells of the triangulation. The triangulation you are "
324 "passing to this function uses multiple cell types."));
325
326 return reference_cells.front()
327 .template get_default_linear_mapping<spacedim>();
328}
329
330
331
332// explicit instantiations
333#include "fe/mapping.inst"
334
335
***mech_lbc_system increment_interpolation_handlers push_back(scale_z_handler)
virtual std::size_t memory_consumption() const
virtual void reinit(const UpdateFlags update_flags, const Quadrature< dim > &quadrature)
Abstract base class for mapping classes.
Definition mapping.h:318
Point< dim - 1 > project_real_point_to_unit_point_on_face(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const unsigned int face_no, const Point< spacedim > &p) const
virtual BoundingBox< spacedim > get_bounding_box(const typename Triangulation< dim, spacedim >::cell_iterator &cell) const
virtual void fill_fe_immersed_surface_values(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const NonMatching::ImmersedSurfaceQuadrature< dim > &quadrature, const typename Mapping< dim, spacedim >::InternalDataBase &internal_data, internal::FEValuesImplementation::MappingRelatedData< dim, spacedim > &output_data) const
virtual void fill_fe_face_values(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const unsigned int face_no, const hp::QCollection< dim - 1 > &quadrature, const typename Mapping< dim, spacedim >::InternalDataBase &internal_data, internal::FEValuesImplementation::MappingRelatedData< dim, spacedim > &output_data) const
virtual void transform_points_real_to_unit_cell(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const ArrayView< const Point< spacedim > > &real_points, const ArrayView< Point< dim > > &unit_points) const
virtual boost::container::small_vector< Point< spacedim >, ReferenceCells::max_n_vertices< dim >() > get_vertices(const typename Triangulation< dim, spacedim >::cell_iterator &cell) const
virtual Point< spacedim > get_center(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const bool map_barycenter_of_reference_cell=true) const
virtual std::unique_ptr< InternalDataBase > get_face_data(const UpdateFlags update_flags, const hp::QCollection< dim - 1 > &quadrature) const
Definition point.h:111
const std::vector< ReferenceCell< dim > > & get_reference_cells() const
unsigned int size() const
Definition collection.h:314
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
#define DEAL_II_ASSERT_UNREACHABLE()
unsigned int vertex_indices[2]
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
#define AssertDimension(dim1, dim2)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
UpdateFlags
@ update_default
No update.
const Mapping< dim, spacedim > & get_default_linear_mapping(const Triangulation< dim, spacedim > &triangulation)
Definition mapping.cc:314
void reference_cell(Triangulation< dim, spacedim > &tria, const ReferenceCell< dim > &reference_cell)
constexpr unsigned int max_n_vertices()
Point< 1 > transform_real_to_unit_cell(const std::array< Point< spacedim >, GeometryInfo< 1 >::vertices_per_cell > &vertices, const Point< spacedim > &p)