Reference documentation for deal.II version Git ede8f93e86 2020-12-03 14:59:20 -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 - 2020 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 
25 
26 template <int dim, int spacedim>
27 boost::container::small_vector<Point<spacedim>,
30  const typename Triangulation<dim, spacedim>::cell_iterator &cell) const
31 {
32  boost::container::small_vector<Point<spacedim>,
34  vertices;
35  for (const unsigned int i : cell->vertex_indices())
36  vertices.push_back(cell->vertex(i));
37 
38  return vertices;
39 }
40 
41 
42 
43 template <int dim, int spacedim>
47  const bool map_center_of_reference_cell) const
48 {
49  if (map_center_of_reference_cell)
50  {
51  Point<dim> reference_center;
52  for (unsigned int d = 0; d < dim; ++d)
53  reference_center[d] = .5;
54  return transform_unit_to_real_cell(cell, reference_center);
55  }
56  else
57  {
58  const auto vertices = get_vertices(cell);
60  for (const auto &v : vertices)
61  center += v;
63  }
64 }
65 
66 
67 
68 template <int dim, int spacedim>
71  const typename Triangulation<dim, spacedim>::cell_iterator &cell) const
72 {
73  if (preserves_vertex_locations())
74  return cell->bounding_box();
75  else
76  return BoundingBox<spacedim>(get_vertices(cell));
77 }
78 
79 
80 
81 template <int dim, int spacedim>
82 void
85  const ArrayView<const Point<spacedim>> & real_points,
86  const ArrayView<Point<dim>> & unit_points) const
87 {
88  AssertDimension(real_points.size(), unit_points.size());
89  for (unsigned int i = 0; i < real_points.size(); ++i)
90  {
91  try
92  {
93  unit_points[i] = transform_real_to_unit_cell(cell, real_points[i]);
94  }
95  catch (typename Mapping<dim>::ExcTransformationFailed &)
96  {
97  unit_points[i] = Point<dim>();
98  unit_points[i][0] = std::numeric_limits<double>::infinity();
99  }
100  }
101 }
102 
103 
104 
105 template <int dim, int spacedim>
106 Point<dim - 1>
108  const typename Triangulation<dim, spacedim>::cell_iterator &cell,
109  const unsigned int face_no,
110  const Point<spacedim> & p) const
111 {
112  // The function doesn't make physical sense for dim=1
113  Assert(dim > 1, ExcNotImplemented());
114  // Not implemented for higher dimensions
115  Assert(dim <= 3, ExcNotImplemented());
116 
117  Point<dim> unit_cell_pt = transform_real_to_unit_cell(cell, p);
118 
119  const unsigned int unit_normal_direction =
121 
122  if (dim == 2)
123  {
124  if (unit_normal_direction == 0)
125  return Point<dim - 1>{unit_cell_pt(1)};
126  else if (unit_normal_direction == 1)
127  return Point<dim - 1>{unit_cell_pt(0)};
128  }
129  else if (dim == 3)
130  {
131  if (unit_normal_direction == 0)
132  return Point<dim - 1>{unit_cell_pt(1), unit_cell_pt(2)};
133  else if (unit_normal_direction == 1)
134  return Point<dim - 1>{unit_cell_pt(0), unit_cell_pt(2)};
135  else if (unit_normal_direction == 2)
136  return Point<dim - 1>{unit_cell_pt(0), unit_cell_pt(1)};
137  }
138 
139  // We should never get here
140  Assert(false, ExcInternalError());
141  return {};
142 }
143 
144 /* ---------------------------- InternalDataBase --------------------------- */
145 
146 
147 template <int dim, int spacedim>
149  : update_each(update_default)
150 {}
151 
152 
153 
154 template <int dim, int spacedim>
155 std::size_t
157 {
158  return sizeof(*this);
159 }
160 
161 
162 /*------------------------------ InternalData ------------------------------*/
163 
164 
165 
166 // explicit instantiations
167 #include "mapping.inst"
168 
169 
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:107
Point< 1 > transform_real_to_unit_cell(const std::array< Point< spacedim >, GeometryInfo< 1 >::vertices_per_cell > &vertices, const Point< spacedim > &p)
#define AssertDimension(dim1, dim2)
Definition: exceptions.h:1623
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:45
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:83
virtual std::size_t memory_consumption() const
Definition: mapping.cc:156
No update.
#define Assert(cond, exc)
Definition: exceptions.h:1466
Abstract base class for mapping classes.
Definition: mapping.h:301
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:372
Point< 3 > vertices[4]
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
virtual BoundingBox< spacedim > get_bounding_box(const typename Triangulation< dim, spacedim >::cell_iterator &cell) const
Definition: mapping.cc:70
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:371
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:29
static ::ExceptionBase & ExcNotImplemented()
static ::ExceptionBase & ExcInternalError()