Reference documentation for deal.II version GIT d77e5ebb0a 2023-01-27 22:35: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 {
101  AssertThrow(false, ExcNotImplemented());
102 }
103 
104 
105 
106 template <int dim, int spacedim>
107 void
109  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
110  const ArrayView<const Point<spacedim>> & real_points,
111  const ArrayView<Point<dim>> & unit_points) const
112 {
113  AssertDimension(real_points.size(), unit_points.size());
114  for (unsigned int i = 0; i < real_points.size(); ++i)
115  {
116  try
117  {
118  unit_points[i] = transform_real_to_unit_cell(cell, real_points[i]);
119  }
120  catch (typename Mapping<dim>::ExcTransformationFailed &)
121  {
122  unit_points[i] = Point<dim>();
123  unit_points[i][0] = std::numeric_limits<double>::infinity();
124  }
125  }
126 }
127 
128 
129 
130 template <int dim, int spacedim>
131 Point<dim - 1>
133  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
134  const unsigned int face_no,
135  const Point<spacedim> & p) const
136 {
137  // The function doesn't make physical sense for dim=1
138  Assert(dim > 1, ExcNotImplemented());
139  // Not implemented for higher dimensions
140  Assert(dim <= 3, ExcNotImplemented());
141 
142  Point<dim> unit_cell_pt = transform_real_to_unit_cell(cell, p);
143 
144  const unsigned int unit_normal_direction =
146 
147  if (dim == 2)
148  {
149  if (unit_normal_direction == 0)
150  return Point<dim - 1>{unit_cell_pt(1)};
151  else if (unit_normal_direction == 1)
152  return Point<dim - 1>{unit_cell_pt(0)};
153  }
154  else if (dim == 3)
155  {
156  if (unit_normal_direction == 0)
157  return Point<dim - 1>{unit_cell_pt(1), unit_cell_pt(2)};
158  else if (unit_normal_direction == 1)
159  return Point<dim - 1>{unit_cell_pt(0), unit_cell_pt(2)};
160  else if (unit_normal_direction == 2)
161  return Point<dim - 1>{unit_cell_pt(0), unit_cell_pt(1)};
162  }
163 
164  // We should never get here
165  Assert(false, ExcInternalError());
166  return {};
167 }
168 
169 
170 
171 #ifndef DOXYGEN
172 template <int dim, int spacedim>
173 void
175  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
176  const unsigned int face_no,
177  const hp::QCollection<dim - 1> & quadrature,
178  const typename Mapping<dim, spacedim>::InternalDataBase & internal_data,
180  &output_data) const
181 {
182  // base class version, implement overridden function in derived classes
183  AssertDimension(quadrature.size(), 1);
184  fill_fe_face_values(cell, face_no, quadrature[0], internal_data, output_data);
185 }
186 
187 
188 
189 template <int dim, int spacedim>
190 void
192  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
193  const unsigned int face_no,
194  const Quadrature<dim - 1> & quadrature,
195  const typename Mapping<dim, spacedim>::InternalDataBase & internal_data,
197  &output_data) const
198 {
199  Assert(false,
200  ExcMessage("Use of a deprecated interface, please implement "
201  "fill_fe_face_values taking a hp::QCollection argument"));
202  (void)cell;
203  (void)face_no;
204  (void)quadrature;
205  (void)internal_data;
206  (void)output_data;
207 }
208 
209 
210 
211 template <int dim, int spacedim>
212 std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>
214  const UpdateFlags update_flags,
215  const hp::QCollection<dim - 1> &quadrature) const
216 {
217  // base class version, implement overridden function in derived classes
218  return get_face_data(update_flags, quadrature[0]);
219 }
220 
221 
222 
223 template <int dim, int spacedim>
224 std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>
226  const UpdateFlags update_flags,
227  const Quadrature<dim - 1> &quadrature) const
228 {
229  Assert(false,
230  ExcMessage("Use of a deprecated interface, please implement "
231  "fill_fe_face_values taking a hp::QCollection argument"));
232  (void)update_flags;
233  (void)quadrature;
234 
235  return std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>();
236 }
237 #endif
238 
239 /* ---------------------------- InternalDataBase --------------------------- */
240 
241 
242 template <int dim, int spacedim>
244  : update_each(update_default)
245 {}
246 
247 
248 
249 template <int dim, int spacedim>
250 std::size_t
252 {
253  return sizeof(*this);
254 }
255 
256 
257 /* ------------------------------ Global functions ------------------------- */
258 
259 template <int dim, int spacedim>
262 {
263  const auto &reference_cells = triangulation.get_reference_cells();
264  Assert(reference_cells.size() == 1,
265  ExcMessage(
266  "This function can only work for triangulations that "
267  "use only a single cell type -- for example, only triangles "
268  "or only quadrilaterals. For mixed meshes, there is no "
269  "single linear mapping object that can be used for all "
270  "cells of the triangulation. The triangulation you are "
271  "passing to this function uses multiple cell types."));
272 
273  return reference_cells.front()
274  .template get_default_linear_mapping<dim, spacedim>();
275 }
276 
277 
278 
279 // explicit instantiations
280 #include "mapping.inst"
281 
282 
virtual std::size_t memory_consumption() const
Abstract base class for mapping classes.
Definition: mapping.h:312
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_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 boost::container::small_vector< Point< spacedim >, GeometryInfo< dim >::vertices_per_cell > get_vertices(const typename Triangulation< dim, spacedim >::cell_iterator &cell) 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:461
#define DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
Definition: config.h:475
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:462
#define DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
Definition: config.h:516
Point< 3 > center
Point< 3 > vertices[4]
static ::ExceptionBase & ExcInternalError()
#define Assert(cond, exc)
Definition: exceptions.h:1509
static ::ExceptionBase & ExcNotImplemented()
#define AssertDimension(dim1, dim2)
Definition: exceptions.h:1703
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
Definition: exceptions.h:1619
UpdateFlags
@ update_default
No update.
const Mapping< dim, spacedim > & get_default_linear_mapping(const Triangulation< dim, spacedim > &triangulation)
Definition: mapping.cc:261
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