Reference documentation for deal.II version GIT 44af803bb8 2022-12-03 23:15:02+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\}}\)
mapping.cc
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2001 - 2021 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 
18 
19 #include <deal.II/fe/mapping.h>
20 
21 #include <deal.II/grid/tria.h>
22 
24 #ifdef DEAL_II_BOOST_HAS_BROKEN_HEADER_DEPRECATIONS
25 # define BOOST_ALLOW_DEPRECATED_HEADERS
26 #endif
27 #include <boost/geometry.hpp>
28 #ifdef DEAL_II_BOOST_HAS_BROKEN_HEADER_DEPRECATIONS
29 # undef BOOST_ALLOW_DEPRECATED_HEADERS
30 #endif
32 
33 #include <limits>
34 
36 
37 
38 template <int dim, int spacedim>
39 boost::container::small_vector<Point<spacedim>,
42  const typename Triangulation<dim, spacedim>::cell_iterator &cell) const
43 {
44  boost::container::small_vector<Point<spacedim>,
46  vertices;
47  for (const unsigned int i : cell->vertex_indices())
48  vertices.push_back(cell->vertex(i));
49 
50  return vertices;
51 }
52 
53 
54 
55 template <int dim, int spacedim>
59  const bool map_center_of_reference_cell) const
60 {
61  if (map_center_of_reference_cell)
62  {
63  Point<dim> reference_center;
64  for (unsigned int d = 0; d < dim; ++d)
65  reference_center[d] = .5;
66  return transform_unit_to_real_cell(cell, reference_center);
67  }
68  else
69  {
70  const auto vertices = get_vertices(cell);
72  for (const auto &v : vertices)
73  center += v;
75  }
76 }
77 
78 
79 
80 template <int dim, int spacedim>
83  const typename Triangulation<dim, spacedim>::cell_iterator &cell) const
84 {
86  return cell->bounding_box();
87  else
88  return BoundingBox<spacedim>(get_vertices(cell));
89 }
90 
91 
92 
93 template <int dim, int spacedim>
94 void
100  const
101 {
102  AssertThrow(false, ExcNotImplemented());
103 }
104 
105 
106 
107 template <int dim, int spacedim>
108 void
110  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
111  const ArrayView<const Point<spacedim>> & real_points,
112  const ArrayView<Point<dim>> & unit_points) const
113 {
114  AssertDimension(real_points.size(), unit_points.size());
115  for (unsigned int i = 0; i < real_points.size(); ++i)
116  {
117  try
118  {
119  unit_points[i] = transform_real_to_unit_cell(cell, real_points[i]);
120  }
121  catch (typename Mapping<dim>::ExcTransformationFailed &)
122  {
123  unit_points[i] = Point<dim>();
124  unit_points[i][0] = std::numeric_limits<double>::infinity();
125  }
126  }
127 }
128 
129 
130 
131 template <int dim, int spacedim>
132 Point<dim - 1>
134  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
135  const unsigned int face_no,
136  const Point<spacedim> & p) const
137 {
138  // The function doesn't make physical sense for dim=1
139  Assert(dim > 1, ExcNotImplemented());
140  // Not implemented for higher dimensions
141  Assert(dim <= 3, ExcNotImplemented());
142 
143  Point<dim> unit_cell_pt = transform_real_to_unit_cell(cell, p);
144 
145  const unsigned int unit_normal_direction =
147 
148  if (dim == 2)
149  {
150  if (unit_normal_direction == 0)
151  return Point<dim - 1>{unit_cell_pt(1)};
152  else if (unit_normal_direction == 1)
153  return Point<dim - 1>{unit_cell_pt(0)};
154  }
155  else if (dim == 3)
156  {
157  if (unit_normal_direction == 0)
158  return Point<dim - 1>{unit_cell_pt(1), unit_cell_pt(2)};
159  else if (unit_normal_direction == 1)
160  return Point<dim - 1>{unit_cell_pt(0), unit_cell_pt(2)};
161  else if (unit_normal_direction == 2)
162  return Point<dim - 1>{unit_cell_pt(0), unit_cell_pt(1)};
163  }
164 
165  // We should never get here
166  Assert(false, ExcInternalError());
167  return {};
168 }
169 
170 
171 
172 #ifndef DOXYGEN
173 template <int dim, int spacedim>
174 void
176  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
177  const unsigned int face_no,
178  const hp::QCollection<dim - 1> & quadrature,
179  const typename Mapping<dim, spacedim>::InternalDataBase & internal_data,
181  &output_data) const
182 {
183  // base class version, implement overridden function in derived classes
184  AssertDimension(quadrature.size(), 1);
185  fill_fe_face_values(cell, face_no, quadrature[0], internal_data, output_data);
186 }
187 
188 
189 
190 template <int dim, int spacedim>
191 void
193  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
194  const unsigned int face_no,
195  const Quadrature<dim - 1> & quadrature,
196  const typename Mapping<dim, spacedim>::InternalDataBase & internal_data,
198  &output_data) const
199 {
200  Assert(false,
201  ExcMessage("Use of a deprecated interface, please implement "
202  "fill_fe_face_values taking a hp::QCollection argument"));
203  (void)cell;
204  (void)face_no;
205  (void)quadrature;
206  (void)internal_data;
207  (void)output_data;
208 }
209 
210 
211 
212 template <int dim, int spacedim>
213 std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>
215  const UpdateFlags update_flags,
216  const hp::QCollection<dim - 1> &quadrature) const
217 {
218  // base class version, implement overridden function in derived classes
219  return get_face_data(update_flags, quadrature[0]);
220 }
221 
222 
223 
224 template <int dim, int spacedim>
225 std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>
227  const UpdateFlags update_flags,
228  const Quadrature<dim - 1> &quadrature) const
229 {
230  Assert(false,
231  ExcMessage("Use of a deprecated interface, please implement "
232  "fill_fe_face_values taking a hp::QCollection argument"));
233  (void)update_flags;
234  (void)quadrature;
235 
236  return std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>();
237 }
238 #endif
239 
240 /* ---------------------------- InternalDataBase --------------------------- */
241 
242 
243 template <int dim, int spacedim>
245  : update_each(update_default)
246 {}
247 
248 
249 
250 template <int dim, int spacedim>
251 std::size_t
253 {
254  return sizeof(*this);
255 }
256 
257 
258 /* ------------------------------ Global functions ------------------------- */
259 
260 template <int dim, int spacedim>
263 {
264  const auto &reference_cells = triangulation.get_reference_cells();
265  Assert(reference_cells.size() == 1,
266  ExcMessage(
267  "This function can only work for triangulations that "
268  "use only a single cell type -- for example, only triangles "
269  "or only quadrilaterals. For mixed meshes, there is no "
270  "single linear mapping object that can be used for all "
271  "cells of the triangulation. The triangulation you are "
272  "passing to this function uses multiple cell types."));
273 
274  return reference_cells.front()
275  .template get_default_linear_mapping<dim, spacedim>();
276 }
277 
278 
279 
280 // explicit instantiations
281 #include "mapping.inst"
282 
283 
virtual std::size_t memory_consumption() const
Abstract base class for mapping classes.
Definition: mapping.h:311
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 Point< dim > transform_real_to_unit_cell(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const Point< spacedim > &p) const =0
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 boost::container::small_vector< Point< spacedim >, GeometryInfo< dim >::vertices_per_cell > get_vertices(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
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 bool preserves_vertex_locations() const =0
virtual BoundingBox< spacedim > get_bounding_box(const typename Triangulation< dim, spacedim >::cell_iterator &cell) const
virtual Point< spacedim > transform_unit_to_real_cell(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const Point< dim > &p) const =0
virtual std::unique_ptr< InternalDataBase > get_face_data(const UpdateFlags update_flags, const hp::QCollection< dim - 1 > &quadrature) const
virtual Point< spacedim > get_center(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const bool map_center_of_reference_cell=true) const
unsigned int size() const
Definition: collection.h:264
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:458
#define DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
Definition: config.h:472
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:459
#define DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
Definition: config.h:512
Point< 3 > center
Point< 3 > vertices[4]
static ::ExceptionBase & ExcInternalError()
#define Assert(cond, exc)
Definition: exceptions.h:1501
static ::ExceptionBase & ExcNotImplemented()
#define AssertDimension(dim1, dim2)
Definition: exceptions.h:1695
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
Definition: exceptions.h:1611
UpdateFlags
@ update_default
No update.
const Mapping< dim, spacedim > & get_default_linear_mapping(const Triangulation< dim, spacedim > &triangulation)
Definition: mapping.cc:262
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
const ::parallel::distributed::Triangulation< dim, spacedim > * triangulation