deal.II version GIT relicensing-6834-g5b78e6bcdf 2026-10-01 11:20:01+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: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2016 - 2024 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13#ifndef dealii_tensor_product_manifold_h
14#define dealii_tensor_product_manifold_h
15
16#include <deal.II/base/config.h>
17
19#include <deal.II/base/point.h>
21
23
24#include <memory>
25
27
28
29
60template <int dim,
61 int dim_A,
62 int spacedim_A,
63 int chartdim_A,
64 int dim_B,
65 int spacedim_B,
66 int chartdim_B>
68 : public ChartManifold<dim, spacedim_A + spacedim_B, chartdim_A + chartdim_B>
69{
70public:
75 static const unsigned int chartdim = chartdim_A + chartdim_B;
80 static const unsigned int spacedim = spacedim_A + spacedim_B;
81
88
92 virtual std::unique_ptr<Manifold<dim, spacedim_A + spacedim_B>>
93 clone() const override;
94
98 virtual Point<chartdim>
99 pull_back(const Point<spacedim> &space_point) const override;
100
104 virtual Point<spacedim>
105 push_forward(const Point<chartdim> &chart_point) const override;
106
111 push_forward_gradient(const Point<chartdim> &chart_point) const override;
112
113private:
114 std::unique_ptr<const ChartManifold<dim_A, spacedim_A, chartdim_A>>
116
117 std::unique_ptr<const ChartManifold<dim_B, spacedim_B, chartdim_B>>
119};
120
121
122
123/*------------------Template Implementations------------------------*/
124
125
126
127namespace internal
128{
129 namespace TensorProductManifoldImplementation
130 {
131 template <int dim1, int dim2>
134 {
136 for (unsigned int d = 0; d < dim1; ++d)
137 r[d] = p1[d];
138 for (unsigned int d = 0; d < dim2; ++d)
139 r[dim1 + d] = p2[d];
140 return r;
141 }
142
143 template <int dim1, int dim2>
145 concat(const Point<dim1> &p1, const Point<dim2> &p2)
146 {
148 for (unsigned int d = 0; d < dim1; ++d)
149 r[d] = p1[d];
150 for (unsigned int d = 0; d < dim2; ++d)
151 r[dim1 + d] = p2[d];
152 return r;
153 }
154
155 template <int dim1, int dim2>
156 void
158 Point<dim1> &p1,
159 Point<dim2> &p2)
160 {
161 for (unsigned int d = 0; d < dim1; ++d)
162 p1[d] = source[d];
163 for (unsigned int d = 0; d < dim2; ++d)
164 p2[d] = source[dim1 + d];
165 }
166
167 } // namespace TensorProductManifoldImplementation
168} // namespace internal
169
170template <int dim,
171 int dim_A,
172 int spacedim_A,
173 int chartdim_A,
174 int dim_B,
175 int spacedim_B,
176 int chartdim_B>
178 dim_A,
179 spacedim_A,
180 chartdim_A,
181 dim_B,
182 spacedim_B,
183 chartdim_B>::
184 TensorProductManifold(
187 : ChartManifold<dim, spacedim_A + spacedim_B, chartdim_A + chartdim_B>(
188 internal::TensorProductManifoldImplementation::concat(
189 manifold_A.get_periodicity(),
190 manifold_B.get_periodicity()))
191 , manifold_A(Utilities::dynamic_unique_cast<
192 ChartManifold<dim_A, spacedim_A, chartdim_A>,
193 Manifold<dim_A, spacedim_A>>(manifold_A.clone()))
194 , manifold_B(Utilities::dynamic_unique_cast<
195 ChartManifold<dim_B, spacedim_B, chartdim_B>,
196 Manifold<dim_B, spacedim_B>>(manifold_B.clone()))
197{}
198
199template <int dim,
200 int dim_A,
201 int spacedim_A,
202 int chartdim_A,
203 int dim_B,
204 int spacedim_B,
205 int chartdim_B>
206std::unique_ptr<Manifold<dim, spacedim_A + spacedim_B>>
208 dim_A,
209 spacedim_A,
210 chartdim_A,
211 dim_B,
212 spacedim_B,
213 chartdim_B>::clone() const
214{
215 return std::make_unique<TensorProductManifold<dim,
216 dim_A,
217 spacedim_A,
218 chartdim_A,
219 dim_B,
220 spacedim_B,
221 chartdim_B>>(*manifold_A,
222 *manifold_B);
223}
224
225template <int dim,
226 int dim_A,
227 int spacedim_A,
228 int chartdim_A,
229 int dim_B,
230 int spacedim_B,
231 int chartdim_B>
233 dim_A,
234 spacedim_A,
235 chartdim_A,
236 dim_B,
237 spacedim_B,
238 chartdim_B>::chartdim>
240 dim_A,
241 spacedim_A,
242 chartdim_A,
243 dim_B,
244 spacedim_B,
245 chartdim_B>::
246 pull_back(
248 dim_A,
249 spacedim_A,
250 chartdim_A,
251 dim_B,
252 spacedim_B,
253 chartdim_B>::spacedim> &space_point) const
254{
255 Point<spacedim_A> space_point_A;
256 Point<spacedim_B> space_point_B;
258 space_point_A,
259 space_point_B);
260
261 Point<chartdim_A> result_A = manifold_A->pull_back(space_point_A);
262 Point<chartdim_B> result_B = manifold_B->pull_back(space_point_B);
263
265 result_B);
266}
267
268template <int dim,
269 int dim_A,
270 int spacedim_A,
271 int chartdim_A,
272 int dim_B,
273 int spacedim_B,
274 int chartdim_B>
276 dim_A,
277 spacedim_A,
278 chartdim_A,
279 dim_B,
280 spacedim_B,
281 chartdim_B>::spacedim>
283 dim_A,
284 spacedim_A,
285 chartdim_A,
286 dim_B,
287 spacedim_B,
288 chartdim_B>::
289 push_forward(
291 dim_A,
292 spacedim_A,
293 chartdim_A,
294 dim_B,
295 spacedim_B,
296 chartdim_B>::chartdim> &chart_point) const
297{
298 Point<chartdim_A> chart_point_A;
299 Point<chartdim_B> chart_point_B;
301 chart_point_A,
302 chart_point_B);
303
304 Point<spacedim_A> result_A = manifold_A->push_forward(chart_point_A);
305 Point<spacedim_B> result_B = manifold_B->push_forward(chart_point_B);
306
308 result_B);
309}
310
311template <int dim,
312 int dim_A,
313 int spacedim_A,
314 int chartdim_A,
315 int dim_B,
316 int spacedim_B,
317 int chartdim_B>
320 dim_A,
321 spacedim_A,
322 chartdim_A,
323 dim_B,
324 spacedim_B,
325 chartdim_B>::chartdim,
327 dim_A,
328 spacedim_A,
329 chartdim_A,
330 dim_B,
331 spacedim_B,
332 chartdim_B>::spacedim>
333
335 dim_A,
336 spacedim_A,
337 chartdim_A,
338 dim_B,
339 spacedim_B,
340 chartdim_B>::
341 push_forward_gradient(
343 dim_A,
344 spacedim_A,
345 chartdim_A,
346 dim_B,
347 spacedim_B,
348 chartdim_B>::chartdim> &chart_point) const
349{
350 Point<chartdim_A> chart_point_A;
351 Point<chartdim_B> chart_point_B;
353 chart_point_A,
354 chart_point_B);
355
357 manifold_A->push_forward_gradient(chart_point_A);
359 manifold_B->push_forward_gradient(chart_point_B);
360
361
363 for (unsigned int i = 0; i < chartdim_A; ++i)
364 for (unsigned int j = 0; j < spacedim_A; ++j)
365 result[j][i] = result_A[j][i];
366 for (unsigned int i = 0; i < chartdim_B; ++i)
367 for (unsigned int j = 0; j < spacedim_B; ++j)
368 result[j + spacedim_A][i + chartdim_A] = result_B[j][i];
369
370 return result;
371}
372
373
374
376
377#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:38
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
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)