Reference documentation for deal.II version Git 24041777c5 2021-12-02 20:43:25 -0700
\(\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 #include <boost/geometry.hpp>
26 
28 
29 
30 template <int dim, int spacedim>
31 boost::container::small_vector<Point<spacedim>,
34  const typename Triangulation<dim, spacedim>::cell_iterator &cell) const
35 {
36  boost::container::small_vector<Point<spacedim>,
38  vertices;
39  for (const unsigned int i : cell->vertex_indices())
40  vertices.push_back(cell->vertex(i));
41 
42  return vertices;
43 }
44 
45 
46 
47 template <int dim, int spacedim>
51  const bool map_center_of_reference_cell) const
52 {
53  if (map_center_of_reference_cell)
54  {
55  Point<dim> reference_center;
56  for (unsigned int d = 0; d < dim; ++d)
57  reference_center[d] = .5;
58  return transform_unit_to_real_cell(cell, reference_center);
59  }
60  else
61  {
62  const auto vertices = get_vertices(cell);
64  for (const auto &v : vertices)
65  center += v;
67  }
68 }
69 
70 
71 
72 template <int dim, int spacedim>
75  const typename Triangulation<dim, spacedim>::cell_iterator &cell) const
76 {
77  if (preserves_vertex_locations())
78  return cell->bounding_box();
79  else
80  return BoundingBox<spacedim>(get_vertices(cell));
81 }
82 
83 
84 
85 template <int dim, int spacedim>
86 void
92  const
93 {
95 }
96 
97 
98 
99 template <int dim, int spacedim>
100 void
102  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
103  const ArrayView<const Point<spacedim>> & real_points,
104  const ArrayView<Point<dim>> & unit_points) const
105 {
106  AssertDimension(real_points.size(), unit_points.size());
107  for (unsigned int i = 0; i < real_points.size(); ++i)
108  {
109  try
110  {
111  unit_points[i] = transform_real_to_unit_cell(cell, real_points[i]);
112  }
113  catch (typename Mapping<dim>::ExcTransformationFailed &)
114  {
115  unit_points[i] = Point<dim>();
116  unit_points[i][0] = std::numeric_limits<double>::infinity();
117  }
118  }
119 }
120 
121 
122 
123 template <int dim, int spacedim>
124 Point<dim - 1>
126  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
127  const unsigned int face_no,
128  const Point<spacedim> & p) const
129 {
130  // The function doesn't make physical sense for dim=1
131  Assert(dim > 1, ExcNotImplemented());
132  // Not implemented for higher dimensions
133  Assert(dim <= 3, ExcNotImplemented());
134 
135  Point<dim> unit_cell_pt = transform_real_to_unit_cell(cell, p);
136 
137  const unsigned int unit_normal_direction =
139 
140  if (dim == 2)
141  {
142  if (unit_normal_direction == 0)
143  return Point<dim - 1>{unit_cell_pt(1)};
144  else if (unit_normal_direction == 1)
145  return Point<dim - 1>{unit_cell_pt(0)};
146  }
147  else if (dim == 3)
148  {
149  if (unit_normal_direction == 0)
150  return Point<dim - 1>{unit_cell_pt(1), unit_cell_pt(2)};
151  else if (unit_normal_direction == 1)
152  return Point<dim - 1>{unit_cell_pt(0), unit_cell_pt(2)};
153  else if (unit_normal_direction == 2)
154  return Point<dim - 1>{unit_cell_pt(0), unit_cell_pt(1)};
155  }
156 
157  // We should never get here
158  Assert(false, ExcInternalError());
159  return {};
160 }
161 
162 
163 
164 #ifndef DOXYGEN
165 template <int dim, int spacedim>
166 void
168  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
169  const unsigned int face_no,
170  const hp::QCollection<dim - 1> & quadrature,
171  const typename Mapping<dim, spacedim>::InternalDataBase & internal_data,
173  &output_data) const
174 {
175  // base class version, implement overridden function in derived classes
176  AssertDimension(quadrature.size(), 1);
177  fill_fe_face_values(cell, face_no, quadrature[0], internal_data, output_data);
178 }
179 
180 
181 
182 template <int dim, int spacedim>
183 void
185  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
186  const unsigned int face_no,
187  const Quadrature<dim - 1> & quadrature,
188  const typename Mapping<dim, spacedim>::InternalDataBase & internal_data,
190  &output_data) const
191 {
192  Assert(false,
193  ExcMessage("Use of a deprecated interface, please implement "
194  "fill_fe_face_values taking a hp::QCollection argument"));
195  (void)cell;
196  (void)face_no;
197  (void)quadrature;
198  (void)internal_data;
199  (void)output_data;
200 }
201 
202 
203 
204 template <int dim, int spacedim>
205 std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>
207  const UpdateFlags update_flags,
208  const hp::QCollection<dim - 1> &quadrature) const
209 {
210  // base class version, implement overridden function in derived classes
211  return get_face_data(update_flags, quadrature[0]);
212 }
213 
214 
215 
216 template <int dim, int spacedim>
217 std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>
219  const UpdateFlags update_flags,
220  const Quadrature<dim - 1> &quadrature) const
221 {
222  Assert(false,
223  ExcMessage("Use of a deprecated interface, please implement "
224  "fill_fe_face_values taking a hp::QCollection argument"));
225  (void)update_flags;
226  (void)quadrature;
227 
228  return std::unique_ptr<typename Mapping<dim, spacedim>::InternalDataBase>();
229 }
230 #endif
231 
232 /* ---------------------------- InternalDataBase --------------------------- */
233 
234 
235 template <int dim, int spacedim>
237  : update_each(update_default)
238 {}
239 
240 
241 
242 template <int dim, int spacedim>
243 std::size_t
245 {
246  return sizeof(*this);
247 }
248 
249 
250 /* ------------------------------ Global functions ------------------------- */
251 
252 template <int dim, int spacedim>
255 {
256  const auto &reference_cells = triangulation.get_reference_cells();
257  Assert(reference_cells.size() == 1,
258  ExcMessage(
259  "This function can only work for triangulations that "
260  "use only a single cell type -- for example, only triangles "
261  "or only quadrilaterals. For mixed meshes, there is no "
262  "single linear mapping object that can be used for all "
263  "cells of the triangulation. The triangulation you are "
264  "passing to this function uses multiple cell types."));
265 
266  return reference_cells.front()
267  .template get_default_linear_mapping<dim, spacedim>();
268 }
269 
270 
271 
272 // explicit instantiations
273 #include "mapping.inst"
274 
275 
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
Definition: mapping.cc:125
Point< 1 > transform_real_to_unit_cell(const std::array< Point< spacedim >, GeometryInfo< 1 >::vertices_per_cell > &vertices, const Point< spacedim > &p)
const std::vector< ReferenceCell > & get_reference_cells() const
Definition: tria.cc:14642
#define AssertDimension(dim1, dim2)
Definition: exceptions.h:1655
unsigned int size() const
Definition: collection.h:263
virtual Point< spacedim > get_center(const typename Triangulation< dim, spacedim >::cell_iterator &cell, const bool map_center_of_reference_cell=true) const
Definition: mapping.cc:49
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
Definition: mapping.cc:101
const Mapping< dim, spacedim > & get_default_linear_mapping(const Triangulation< dim, spacedim > &triangulation)
Definition: mapping.cc:254
virtual std::size_t memory_consumption() const
Definition: mapping.cc:244
virtual std::unique_ptr< InternalDataBase > get_face_data(const UpdateFlags update_flags, const hp::QCollection< dim - 1 > &quadrature) const
#define AssertThrow(cond, exc)
Definition: exceptions.h:1571
#define DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
Definition: config.h:417
static ::ExceptionBase & ExcMessage(std::string arg1)
No update.
#define Assert(cond, exc)
Definition: exceptions.h:1461
UpdateFlags
Abstract base class for mapping classes.
Definition: mapping.h:310
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:404
Point< 3 > vertices[4]
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
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 BoundingBox< spacedim > get_bounding_box(const typename Triangulation< dim, spacedim >::cell_iterator &cell) const
Definition: mapping.cc:74
#define DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
Definition: config.h:455
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:403
Point< 3 > center
virtual boost::container::small_vector< Point< spacedim >, GeometryInfo< dim >::vertices_per_cell > get_vertices(const typename Triangulation< dim, spacedim >::cell_iterator &cell) const
Definition: mapping.cc:33
static ::ExceptionBase & ExcNotImplemented()
const ::parallel::distributed::Triangulation< dim, spacedim > * triangulation
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
Definition: mapping.cc:87
static ::ExceptionBase & ExcInternalError()