deal.II version GIT relicensing-2167-g9622207b8f 2024-11-21 12:40:00+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\}}\)
Loading...
Searching...
No Matches
tensor_product_manifold.h
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2016 - 2023 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15#ifndef dealii_tensor_product_manifold_h
16#define dealii_tensor_product_manifold_h
17
18#include <deal.II/base/config.h>
19
21#include <deal.II/base/point.h>
23
25
26#include <memory>
27
29
30
31
62template <int dim,
63 int dim_A,
64 int spacedim_A,
65 int chartdim_A,
66 int dim_B,
67 int spacedim_B,
68 int chartdim_B>
70 : public ChartManifold<dim, spacedim_A + spacedim_B, chartdim_A + chartdim_B>
71{
72public:
77 static const unsigned int chartdim = chartdim_A + chartdim_B;
82 static const unsigned int spacedim = spacedim_A + spacedim_B;
83
90
94 virtual std::unique_ptr<Manifold<dim, spacedim_A + spacedim_B>>
95 clone() const override;
96
100 virtual Point<chartdim>
101 pull_back(const Point<spacedim> &space_point) const override;
102
106 virtual Point<spacedim>
107 push_forward(const Point<chartdim> &chart_point) const override;
108
113 push_forward_gradient(const Point<chartdim> &chart_point) const override;
114
115private:
116 std::unique_ptr<const ChartManifold<dim_A, spacedim_A, chartdim_A>>
118
119 std::unique_ptr<const ChartManifold<dim_B, spacedim_B, chartdim_B>>
121};
122
123
124
125/*------------------Template Implementations------------------------*/
126
127
128
129namespace internal
130{
131 namespace TensorProductManifoldImplementation
132 {
133 template <int dim1, int dim2>
136 {
138 for (unsigned int d = 0; d < dim1; ++d)
139 r[d] = p1[d];
140 for (unsigned int d = 0; d < dim2; ++d)
141 r[dim1 + d] = p2[d];
142 return r;
143 }
144
145 template <int dim1, int dim2>
147 concat(const Point<dim1> &p1, const Point<dim2> &p2)
148 {
150 for (unsigned int d = 0; d < dim1; ++d)
151 r[d] = p1[d];
152 for (unsigned int d = 0; d < dim2; ++d)
153 r[dim1 + d] = p2[d];
154 return r;
155 }
156
157 template <int dim1, int dim2>
158 void
160 Point<dim1> &p1,
161 Point<dim2> &p2)
162 {
163 for (unsigned int d = 0; d < dim1; ++d)
164 p1[d] = source[d];
165 for (unsigned int d = 0; d < dim2; ++d)
166 p2[d] = source[dim1 + d];
167 }
168
169 } // namespace TensorProductManifoldImplementation
170} // namespace internal
171
172template <int dim,
173 int dim_A,
174 int spacedim_A,
175 int chartdim_A,
176 int dim_B,
177 int spacedim_B,
178 int chartdim_B>
180 dim_A,
181 spacedim_A,
182 chartdim_A,
183 dim_B,
184 spacedim_B,
185 chartdim_B>::
186 TensorProductManifold(
189 : ChartManifold<dim, spacedim_A + spacedim_B, chartdim_A + chartdim_B>(
190 internal::TensorProductManifoldImplementation::concat(
191 manifold_A.get_periodicity(),
192 manifold_B.get_periodicity()))
193 , manifold_A(Utilities::dynamic_unique_cast<
194 ChartManifold<dim_A, spacedim_A, chartdim_A>,
195 Manifold<dim_A, spacedim_A>>(manifold_A.clone()))
196 , manifold_B(Utilities::dynamic_unique_cast<
197 ChartManifold<dim_B, spacedim_B, chartdim_B>,
198 Manifold<dim_B, spacedim_B>>(manifold_B.clone()))
199{}
200
201template <int dim,
202 int dim_A,
203 int spacedim_A,
204 int chartdim_A,
205 int dim_B,
206 int spacedim_B,
207 int chartdim_B>
208std::unique_ptr<Manifold<dim, spacedim_A + spacedim_B>>
210 dim_A,
211 spacedim_A,
212 chartdim_A,
213 dim_B,
214 spacedim_B,
215 chartdim_B>::clone() const
216{
217 return std::make_unique<TensorProductManifold<dim,
218 dim_A,
219 spacedim_A,
220 chartdim_A,
221 dim_B,
222 spacedim_B,
223 chartdim_B>>(*manifold_A,
224 *manifold_B);
225}
226
227template <int dim,
228 int dim_A,
229 int spacedim_A,
230 int chartdim_A,
231 int dim_B,
232 int spacedim_B,
233 int chartdim_B>
235 dim_A,
236 spacedim_A,
237 chartdim_A,
238 dim_B,
239 spacedim_B,
240 chartdim_B>::chartdim>
242 dim_A,
243 spacedim_A,
244 chartdim_A,
245 dim_B,
246 spacedim_B,
247 chartdim_B>::
248 pull_back(
250 dim_A,
251 spacedim_A,
252 chartdim_A,
253 dim_B,
254 spacedim_B,
255 chartdim_B>::spacedim> &space_point) const
256{
257 Point<spacedim_A> space_point_A;
258 Point<spacedim_B> space_point_B;
260 space_point_A,
261 space_point_B);
262
263 Point<chartdim_A> result_A = manifold_A->pull_back(space_point_A);
264 Point<chartdim_B> result_B = manifold_B->pull_back(space_point_B);
265
267 result_B);
268}
269
270template <int dim,
271 int dim_A,
272 int spacedim_A,
273 int chartdim_A,
274 int dim_B,
275 int spacedim_B,
276 int chartdim_B>
278 dim_A,
279 spacedim_A,
280 chartdim_A,
281 dim_B,
282 spacedim_B,
283 chartdim_B>::spacedim>
285 dim_A,
286 spacedim_A,
287 chartdim_A,
288 dim_B,
289 spacedim_B,
290 chartdim_B>::
291 push_forward(
293 dim_A,
294 spacedim_A,
295 chartdim_A,
296 dim_B,
297 spacedim_B,
298 chartdim_B>::chartdim> &chart_point) const
299{
300 Point<chartdim_A> chart_point_A;
301 Point<chartdim_B> chart_point_B;
303 chart_point_A,
304 chart_point_B);
305
306 Point<spacedim_A> result_A = manifold_A->push_forward(chart_point_A);
307 Point<spacedim_B> result_B = manifold_B->push_forward(chart_point_B);
308
310 result_B);
311}
312
313template <int dim,
314 int dim_A,
315 int spacedim_A,
316 int chartdim_A,
317 int dim_B,
318 int spacedim_B,
319 int chartdim_B>
322 dim_A,
323 spacedim_A,
324 chartdim_A,
325 dim_B,
326 spacedim_B,
327 chartdim_B>::chartdim,
329 dim_A,
330 spacedim_A,
331 chartdim_A,
332 dim_B,
333 spacedim_B,
334 chartdim_B>::spacedim>
335
337 dim_A,
338 spacedim_A,
339 chartdim_A,
340 dim_B,
341 spacedim_B,
342 chartdim_B>::
343 push_forward_gradient(
345 dim_A,
346 spacedim_A,
347 chartdim_A,
348 dim_B,
349 spacedim_B,
350 chartdim_B>::chartdim> &chart_point) const
351{
352 Point<chartdim_A> chart_point_A;
353 Point<chartdim_B> chart_point_B;
355 chart_point_A,
356 chart_point_B);
357
359 manifold_A->push_forward_gradient(chart_point_A);
361 manifold_B->push_forward_gradient(chart_point_B);
362
363
365 for (unsigned int i = 0; i < chartdim_A; ++i)
366 for (unsigned int j = 0; j < spacedim_A; ++j)
367 result[j][i] = result_A[j][i];
368 for (unsigned int i = 0; i < chartdim_B; ++i)
369 for (unsigned int j = 0; j < spacedim_B; ++j)
370 result[j + spacedim_A][i + chartdim_A] = result_B[j][i];
371
372 return result;
373}
374
375
376
378
379#endif
Definition point.h:111
Tensor product manifold of two ChartManifolds.
static const unsigned int chartdim
virtual Point< spacedim > push_forward(const Point< chartdim > &chart_point) const override
virtual DerivativeForm< 1, chartdim, spacedim > push_forward_gradient(const Point< chartdim > &chart_point) const override
static const unsigned int spacedim
virtual Point< chartdim > pull_back(const Point< spacedim > &space_point) const override
virtual std::unique_ptr< Manifold< dim, spacedim_A+spacedim_B > > clone() const override
std::unique_ptr< const ChartManifold< dim_B, spacedim_B, chartdim_B > > manifold_B
std::unique_ptr< const ChartManifold< dim_A, spacedim_A, chartdim_A > > manifold_A
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:498
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:499
Tensor< 1, dim1+dim2 > concat(const Tensor< 1, dim1 > &p1, const Tensor< 1, dim2 > &p2)
void split_point(const Point< dim1+dim2 > &source, Point< dim1 > &p1, Point< dim2 > &p2)