Reference documentation for deal.II version GIT 6bdf9a4b6c 2022-08-12 19:20: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 
34 
35 
36 template <int dim, int spacedim>
37 boost::container::small_vector<Point<spacedim>,
40  const typename Triangulation<dim, spacedim>::cell_iterator &cell) const
41 {
42  boost::container::small_vector<Point<spacedim>,
44  vertices;
45  for (const unsigned int i : cell->vertex_indices())
46  vertices.push_back(cell->vertex(i));
47 
48  return vertices;
49 }
50 
51 
52 
53 template <int dim, int spacedim>
57  const bool map_center_of_reference_cell) const
58 {
59  if (map_center_of_reference_cell)
60  {
61  Point<dim> reference_center;
62  for (unsigned int d = 0; d < dim; ++d)
63  reference_center[d] = .5;
64  return transform_unit_to_real_cell(cell, reference_center);
65  }
66  else
67  {
68  const auto vertices = get_vertices(cell);
70  for (const auto &v : vertices)
71  center += v;
73  }
74 }
75 
76 
77 
78 template <int dim, int spacedim>
81  const typename Triangulation<dim, spacedim>::cell_iterator &cell) const
82 {
84  return cell->bounding_box();
85  else
86  return BoundingBox<spacedim>(get_vertices(cell));
87 }
88 
89 
90 
91 template <int dim, int spacedim>
92 void
98  const
99 {
100  AssertThrow(false, ExcNotImplemented());
101 }
102 
103 
104 
105 template <int dim, int spacedim>
106 void
108  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
109  const ArrayView<const Point<spacedim>> & real_points,
110  const ArrayView<Point<dim>> & unit_points) const
111 {
112  AssertDimension(real_points.size(), unit_points.size());
113  for (unsigned int i = 0; i < real_points.size(); ++i)
114  {
115  try
116  {
117  unit_points[i] = transform_real_to_unit_cell(cell, real_points[i]);
118  }
119  catch (typename Mapping<dim>::ExcTransformationFailed &)
120  {
121  unit_points[i] = Point<dim>();
122  unit_points[i][0] = std::numeric_limits<double>::infinity();
123  }
124  }
125 }
126 
127 
128 
129 template <int dim, int spacedim>
130 Point<dim - 1>
132  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
133  const unsigned int face_no,
134  const Point<spacedim> & p) const
135 {
136  // The function doesn't make physical sense for dim=1
137  Assert(dim > 1, ExcNotImplemented());
138  // Not implemented for higher dimensions
139  Assert(dim <= 3, ExcNotImplemented());
140 
141  Point<dim> unit_cell_pt = transform_real_to_unit_cell(cell, p);
142 
143  const unsigned int unit_normal_direction =
145 
146  if (dim == 2)
147  {
148  if (unit_normal_direction == 0)
149  return Point<dim - 1>{unit_cell_pt(1)};
150  else if (unit_normal_direction == 1)
151  return Point<dim - 1>{unit_cell_pt(0)};
152  }
153  else if (dim == 3)
154  {
155  if (unit_normal_direction == 0)
156  return Point<dim - 1>{unit_cell_pt(1), unit_cell_pt(2)};
157  else if (unit_normal_direction == 1)
158  return Point<dim - 1>{unit_cell_pt(0), unit_cell_pt(2)};
159  else if (unit_normal_direction == 2)
160  return Point<dim - 1>{unit_cell_pt(0), unit_cell_pt(1)};
161  }
162 
163  // We should never get here
164  Assert(false, ExcInternalError());
165  return {};
166 }
167 
168 
169 
170 #ifndef DOXYGEN
171 template <int dim, int spacedim>
172 void
174  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
175  const unsigned int face_no,
176  const hp::QCollection<dim - 1> & quadrature,
177  const typename Mapping<dim, spacedim>::InternalDataBase & internal_data,
179  &output_data) const
180 {
181  // base class version, implement overridden function in derived classes
182  AssertDimension(quadrature.size(), 1);
183  fill_fe_face_values(cell, face_no, quadrature[0], internal_data, output_data);
184 }
185 
186 
187 
188 template <int dim, int spacedim>
189 void
191  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
192  const unsigned int face_no,
193  const Quadrature<dim - 1> & quadrature,
194  const typename Mapping<dim, spacedim>::InternalDataBase & internal_data,
196  &output_data) const
197 {
198  Assert(false,
199  ExcMessage("Use of a deprecated interface, please implement "
200  "fill_fe_face_values taking a hp::QCollection argument"));
201  (void)cell;
202  (void)face_no;
203  (void)quadrature;
204  (void)internal_data;
205  (void)output_data;
206 }
207 
208 
209 
210 template <int dim, int spacedim>
211 std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>
213  const UpdateFlags update_flags,
214  const hp::QCollection<dim - 1> &quadrature) const
215 {
216  // base class version, implement overridden function in derived classes
217  return get_face_data(update_flags, quadrature[0]);
218 }
219 
220 
221 
222 template <int dim, int spacedim>
223 std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>
225  const UpdateFlags update_flags,
226  const Quadrature<dim - 1> &quadrature) const
227 {
228  Assert(false,
229  ExcMessage("Use of a deprecated interface, please implement "
230  "fill_fe_face_values taking a hp::QCollection argument"));
231  (void)update_flags;
232  (void)quadrature;
233 
234  return std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>();
235 }
236 #endif
237 
238 /* ---------------------------- InternalDataBase --------------------------- */
239 
240 
241 template <int dim, int spacedim>
243  : update_each(update_default)
244 {}
245 
246 
247 
248 template <int dim, int spacedim>
249 std::size_t
251 {
252  return sizeof(*this);
253 }
254 
255 
256 /* ------------------------------ Global functions ------------------------- */
257 
258 template <int dim, int spacedim>
261 {
262  const auto &reference_cells = triangulation.get_reference_cells();
263  Assert(reference_cells.size() == 1,
264  ExcMessage(
265  "This function can only work for triangulations that "
266  "use only a single cell type -- for example, only triangles "
267  "or only quadrilaterals. For mixed meshes, there is no "
268  "single linear mapping object that can be used for all "
269  "cells of the triangulation. The triangulation you are "
270  "passing to this function uses multiple cell types."));
271 
272  return reference_cells.front()
273  .template get_default_linear_mapping<dim, spacedim>();
274 }
275 
276 
277 
278 // explicit instantiations
279 #include "mapping.inst"
280 
281 
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:442
#define DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
Definition: config.h:456
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:443
#define DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
Definition: config.h:495
Point< 3 > center
Point< 3 > vertices[4]
static ::ExceptionBase & ExcInternalError()
#define Assert(cond, exc)
Definition: exceptions.h:1473
static ::ExceptionBase & ExcNotImplemented()
#define AssertDimension(dim1, dim2)
Definition: exceptions.h:1667
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
Definition: exceptions.h:1583
UpdateFlags
@ update_default
No update.
const Mapping< dim, spacedim > & get_default_linear_mapping(const Triangulation< dim, spacedim > &triangulation)
Definition: mapping.cc:260
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