Reference documentation for deal.II version 9.0.0
tensor_product_manifold.h
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2016 - 2018 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 at
12 // the top level of the deal.II distribution.
13 //
14 // ---------------------------------------------------------------------
15 
16 #ifndef dealii_tensor_product_manifold_h
17 #define dealii_tensor_product_manifold_h
18 
19 #include <deal.II/base/config.h>
20 #include <deal.II/base/subscriptor.h>
21 #include <deal.II/base/std_cxx14/memory.h>
22 #include <deal.II/base/point.h>
23 #include <deal.II/grid/manifold.h>
24 
25 DEAL_II_NAMESPACE_OPEN
26 
27 
28 
61 template <int dim,
62  int dim_A, int spacedim_A, int chartdim_A,
63  int dim_B, int spacedim_B, int chartdim_B>
65  public ChartManifold<dim,spacedim_A+spacedim_B,chartdim_A+chartdim_B>
66 {
67 public:
72  static const unsigned int chartdim = chartdim_A+chartdim_B;
77  static const unsigned int spacedim = spacedim_A+spacedim_B;
78 
85 
89  virtual std::unique_ptr<Manifold<dim,spacedim_A+spacedim_B> >
90  clone() const override;
91 
95  virtual
97  pull_back(const Point<spacedim> &space_point) const override;
98 
102  virtual
104  push_forward(const Point<chartdim> &chart_point) const override;
105 
109  virtual
111  push_forward_gradient(const Point<chartdim> &chart_point) const override;
112 
113 private:
116 
119 };
120 
121 
122 
123 /*------------------Template Implementations------------------------*/
124 
125 
126 
127 namespace internal
128 {
129  namespace TensorProductManifoldImplementation
130  {
131  template <int dim1, int dim2>
132  Tensor<1,dim1+dim2> concat(const Tensor<1,dim1> &p1, const Tensor<1,dim2> &p2)
133  {
135  for (unsigned int d=0; d<dim1; ++d)
136  r[d] = p1[d];
137  for (unsigned int d=0; d<dim2; ++d)
138  r[dim1+d] = p2[d];
139  return r;
140  }
141 
142  template <int dim1, int dim2>
143  Point<dim1+dim2> concat(const Point<dim1> &p1, const Point<dim2> &p2)
144  {
146  for (unsigned int d=0; d<dim1; ++d)
147  r[d] = p1[d];
148  for (unsigned int d=0; d<dim2; ++d)
149  r[dim1+d] = p2[d];
150  return r;
151  }
152 
153  template <int dim1, int dim2>
154  void split_point(const Point<dim1+dim2> &source, Point<dim1> &p1, Point<dim2> &p2)
155  {
156  for (unsigned int d=0; d<dim1; ++d)
157  p1[d] = source[d];
158  for (unsigned int d=0; d<dim2; ++d)
159  p2[d] = source[dim1+d];
160  }
161 
162  }
163 }
164 
165 template <int dim,
166  int dim_A, int spacedim_A, int chartdim_A,
167  int dim_B, int spacedim_B, int chartdim_B>
172  : ChartManifold<dim,spacedim_A+spacedim_B,chartdim_A+chartdim_B> (
173  internal::TensorProductManifoldImplementation::concat(
174  manifold_A.get_periodicity(),
175  manifold_B.get_periodicity())),
176  manifold_A (&manifold_A),
177  manifold_B (&manifold_B)
178 {}
179 
180 template <int dim,
181  int dim_A, int spacedim_A, int chartdim_A,
182  int dim_B, int spacedim_B, int chartdim_B>
183 std::unique_ptr<Manifold<dim,spacedim_A+spacedim_B> >
185 {
186  return std_cxx14::make_unique<TensorProductManifold<dim, dim_A, spacedim_A, chartdim_A, dim_B, spacedim_B, chartdim_B> >
187  (*manifold_A, *manifold_B);
188 }
189 
190 template <int dim,
191  int dim_A, int spacedim_A, int chartdim_A,
192  int dim_B, int spacedim_B, int chartdim_B>
196 {
197  Point<spacedim_A> space_point_A;
198  Point<spacedim_B> space_point_B;
199  internal::TensorProductManifoldImplementation::split_point(space_point, space_point_A, space_point_B);
200 
201  Point<chartdim_A> result_A = manifold_A->pull_back(space_point_A);
202  Point<chartdim_B> result_B = manifold_B->pull_back(space_point_B);
203 
204  return internal::TensorProductManifoldImplementation::concat(result_A, result_B);
205 }
206 
207 template <int dim,
208  int dim_A, int spacedim_A, int chartdim_A,
209  int dim_B, int spacedim_B, int chartdim_B>
213 {
214  Point<chartdim_A> chart_point_A;
215  Point<chartdim_B> chart_point_B;
216  internal::TensorProductManifoldImplementation::split_point(chart_point, chart_point_A, chart_point_B);
217 
218  Point<spacedim_A> result_A = manifold_A->push_forward(chart_point_A);
219  Point<spacedim_B> result_B = manifold_B->push_forward(chart_point_B);
220 
221  return internal::TensorProductManifoldImplementation::concat(result_A, result_B);
222 }
223 
224 template <int dim,
225  int dim_A, int spacedim_A, int chartdim_A,
226  int dim_B, int spacedim_B, int chartdim_B>
230 
233 {
234  Point<chartdim_A> chart_point_A;
235  Point<chartdim_B> chart_point_B;
236  internal::TensorProductManifoldImplementation::split_point(chart_point, chart_point_A, chart_point_B);
237 
239  = manifold_A->push_forward_gradient(chart_point_A);
241  = manifold_B->push_forward_gradient(chart_point_B);
242 
243 
245  for (unsigned int i = 0; i<chartdim_A; ++i)
246  for (unsigned int j = 0; j<spacedim_A; ++j)
247  result[j][i] = result_A[j][i];
248  for (unsigned int i = 0; i<chartdim_B; ++i)
249  for (unsigned int j = 0; j<spacedim_B; ++j)
250  result[j+spacedim_A][i+chartdim_A] = result_B[j][i];
251 
252  return result;
253 }
254 
255 
256 
257 
258 DEAL_II_NAMESPACE_CLOSE
259 
260 #endif
virtual DerivativeForm< 1, chartdim, spacedim > push_forward_gradient(const Point< chartdim > &chart_point) const override
virtual Point< spacedim > push_forward(const Point< chartdim > &chart_point) const override
static const unsigned int chartdim
virtual Point< chartdim > pull_back(const Point< spacedim > &space_point) const override
Definition: point.h:104
Tensor product manifold of two ChartManifolds.
virtual std::unique_ptr< Manifold< dim, spacedim_A+spacedim_B > > clone() const override
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
static const unsigned int spacedim
Definition: mpi.h:53
TensorProductManifold(const ChartManifold< dim_A, spacedim_A, chartdim_A > &manifold_A, const ChartManifold< dim_B, spacedim_B, chartdim_B > &manifold_B)