// ------------------------------------------------------------------------ // // SPDX-License-Identifier: LGPL-2.1-or-later // Copyright (C) 2016 - 2024 by the deal.II authors // // This file is part of the deal.II library. // // Part of the source code is dual licensed under Apache-2.0 WITH // LLVM-exception OR LGPL-2.1-or-later. Detailed license information // governing the source code and code contributions can be found in // LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II. // // ------------------------------------------------------------------------ #ifndef dealii_composition_manifold_h #define dealii_composition_manifold_h /*---------------------------- composition_manifold.h ------------*/ #include #include #include #include #include #include #include #include #include #include DEAL_II_NAMESPACE_OPEN /** * CompositionManifold. Take two ChartManifold objects, and make * their composition. The CompositionManifold object is a * ChartManifold going from the chart of the first ChartManifold to * the embedding space of the second ChartManifold. If the first * ChartManifold is periodic, so is the resulting ChartManifold, with * the same periodicity. Periodicity on the second ChartManifold is not * allowed, and the constructor will throw an exception if the second * Manifold is periodic. * * This class only works for dim <= chartdim <= intermediate_spacedim * <= spacedim. If you try to instantiate anything different, an * Exception will be thrown in one of the ChartManifold classes that * violates this condition. * * Given the ChartManifold F and the ChartManifold G, this class * represents the composition of G after F. * * The template parameters have the following meaning: * * @tparam dim The dimension of the resulting ChartManifold * @tparam spacedim The space dimension of the resulting ChartManifold * @tparam chartdim The chart dimension of the resulting ChartManifold * @tparam intermediate_dim The space dimension of the first ChartManifold * @tparam dim1 The dimension of the first ChartManifold, which coincides also * with the chart dimension of the second ChartManifold * @tparam dim2 The dimension of the second ChartManifold * * @ingroup manifold */ template class CompositionManifold : public ChartManifold { public: /** * Construct the composition of the two given manifolds. */ CompositionManifold(const ChartManifold &F, const ChartManifold &G); /** * Make a clone of this Manifold. */ virtual std::unique_ptr> clone() const override; /** * Pull back the given point in spacedim to the Euclidean chartdim * dimensional space. This function calls the pull_back() function * of G, and then the pull_back() function of F. */ virtual Point pull_back(const Point &space_point) const; /** * Push forward the chartdim dimensional point to a spacedim * Euclidean point. The function calls first the push_forward() of * F, and then the push_forward() of G. */ virtual Point push_forward(const Point &chart_point) const; /** * Return the derivative of the composition of G after F. */ virtual DerivativeForm<1, chartdim, spacedim> push_forward_gradient(const Point &chart_point) const; private: /** * The first ChartManifold. */ ObserverPointer< const ChartManifold, CompositionManifold> F; /** * The second ChartManifold. */ ObserverPointer< const ChartManifold, CompositionManifold> G; }; /*------------------Template Implementations------------------------*/ template CompositionManifold:: CompositionManifold(const ChartManifold &F, const ChartManifold &G) : ChartManifold(F.get_periodicity()) , F(&F) , G(&G) { // We don't know what to do with a periodicity in the second manifold, so // throw an assertion if the second manifold is periodic Assert(G.get_periodicity().norm() == 0.0, ExcMessage("The second manifold cannot be periodic.")); } template std::unique_ptr> CompositionManifold:: clone() const { return std::make_unique< CompositionManifold>( *F, *G); } template Point CompositionManifold:: pull_back(const Point &space_point) const { return F->pull_back(G->pull_back(space_point)); } template Point CompositionManifold:: push_forward(const Point &chart_point) const { return G->push_forward(F->push_forward(chart_point)); } template DerivativeForm<1, chartdim, spacedim> CompositionManifold:: push_forward_gradient(const Point &chart_point) const { DerivativeForm<1, chartdim, intermediate_dim> DF = F->push_forward_gradient(chart_point); DerivativeForm<1, intermediate_dim, spacedim> DG = G->push_forward_gradient(F->push_forward(chart_point)); DerivativeForm<1, chartdim, spacedim> DF_DG; for (unsigned int d = 0; d < spacedim; ++d) for (unsigned int c = 0; c < chartdim; ++c) for (unsigned int s = 0; s < intermediate_dim; ++s) DF_DG[d][c] += DG[d][s] * DF[s][c]; return DF_DG; } DEAL_II_NAMESPACE_CLOSE #endif