From 91f852f2a9d5c445f16a2f3839327c57fc74d3de Mon Sep 17 00:00:00 2001 From: Oliver Sander <oliver.sander@tu-dresden.de> Date: Wed, 1 May 2024 08:13:40 +0200 Subject: [PATCH] Remove 2 template parameters from GeodesicFEAssemblerWrapper They were expected to be the factors of a ProductManifold which is also a template parameter. Expecting the product and the factors is redundant. We simply extract the factors from the product now. --- .../assemblers/geodesicfeassemblerwrapper.hh | 26 +++++++++---------- src/cosserat-continuum.cc | 4 +-- src/film-on-substrate.cc | 2 +- src/simofoxshell.cc | 2 +- test/filmonsubstratetest.cc | 2 +- test/geodesicfeassemblerwrappertest.cc | 2 +- test/mixedriemannianpnsolvertest.cc | 2 +- 7 files changed, 20 insertions(+), 20 deletions(-) diff --git a/dune/gfe/assemblers/geodesicfeassemblerwrapper.hh b/dune/gfe/assemblers/geodesicfeassemblerwrapper.hh index d7129ef5..ceea08ee 100644 --- a/dune/gfe/assemblers/geodesicfeassemblerwrapper.hh +++ b/dune/gfe/assemblers/geodesicfeassemblerwrapper.hh @@ -12,10 +12,13 @@ namespace Dune::GFE { It reimplements the same methods as these two and transfers the structure of the gradient and the Hessian */ - template <class Basis, class ScalarBasis, class TargetSpace, class MixedSpace0, class MixedSpace1> + template <class Basis, class ScalarBasis, class TargetSpace> class GeodesicFEAssemblerWrapper { + using MixedSpace0 = std::tuple_element_t<0,TargetSpace>; + using MixedSpace1 = std::tuple_element_t<1,TargetSpace>; + typedef typename Basis::GridView GridView; //! Dimension of the grid. @@ -42,9 +45,6 @@ namespace Dune::GFE { basis_(basis) { hessianMixed_ = std::make_unique<MatrixType>(); - // The two spaces from the mixed version need to have the same embeddedDim as the Target Space - assert(MixedSpace0::embeddedDim + MixedSpace1::embeddedDim == TargetSpace::embeddedDim); - assert(blocksize0 + blocksize1 == blocksize); } /** \brief Assemble the tangent stiffness matrix and the functional gradient together @@ -69,14 +69,14 @@ namespace Dune::GFE { } private: - Dune::TupleVector<std::vector<MixedSpace0>,std::vector<MixedSpace1> > splitVector(const std::vector<TargetSpace>& sol) const; + auto splitVector(const std::vector<TargetSpace>& sol) const; std::unique_ptr<MatrixType> hessianMixed_; }; // end class } //end namespace -template <class Basis, class ScalarBasis, class TargetSpace, class MixedSpace0, class MixedSpace1> -Dune::TupleVector<std::vector<MixedSpace0>,std::vector<MixedSpace1> > Dune::GFE::GeodesicFEAssemblerWrapper<Basis, ScalarBasis, TargetSpace,MixedSpace0,MixedSpace1>:: +template <class Basis, class ScalarBasis, class TargetSpace> +auto Dune::GFE::GeodesicFEAssemblerWrapper<Basis, ScalarBasis, TargetSpace>:: splitVector(const std::vector<TargetSpace>& sol) const { using namespace Indices; // Split the solution into the Deformation and the Rotational part @@ -92,8 +92,8 @@ splitVector(const std::vector<TargetSpace>& sol) const { return solutionSplit; } -template <class Basis, class ScalarBasis, class TargetSpace, class MixedSpace0, class MixedSpace1> -void Dune::GFE::GeodesicFEAssemblerWrapper<Basis, ScalarBasis, TargetSpace,MixedSpace0,MixedSpace1>:: +template <class Basis, class ScalarBasis, class TargetSpace> +void Dune::GFE::GeodesicFEAssemblerWrapper<Basis, ScalarBasis, TargetSpace>:: getNeighborsPerVertex(Dune::MatrixIndexSet& nb) const { auto n = basis_.size(); @@ -112,8 +112,8 @@ getNeighborsPerVertex(Dune::MatrixIndexSet& nb) const nb = nb00; } -template <class Basis, class ScalarBasis, class TargetSpace, class MixedSpace0, class MixedSpace1> -void Dune::GFE::GeodesicFEAssemblerWrapper<Basis, ScalarBasis, TargetSpace,MixedSpace0,MixedSpace1>:: +template <class Basis, class ScalarBasis, class TargetSpace> +void Dune::GFE::GeodesicFEAssemblerWrapper<Basis, ScalarBasis, TargetSpace>:: assembleGradientAndHessian(const std::vector<TargetSpace>& sol, Dune::BlockVector<Dune::FieldVector<double, blocksize> >& gradient, Dune::BCRSMatrix<MatrixBlock>& hessian, @@ -184,8 +184,8 @@ assembleGradientAndHessian(const std::vector<TargetSpace>& sol, } } -template <class Basis, class ScalarBasis, class TargetSpace, class MixedSpace0, class MixedSpace1> -double Dune::GFE::GeodesicFEAssemblerWrapper<Basis, ScalarBasis, TargetSpace,MixedSpace0,MixedSpace1>:: +template <class Basis, class ScalarBasis, class TargetSpace> +double Dune::GFE::GeodesicFEAssemblerWrapper<Basis, ScalarBasis, TargetSpace>:: computeEnergy(const std::vector<TargetSpace>& sol) const { using namespace Dune::TypeTree::Indices; diff --git a/src/cosserat-continuum.cc b/src/cosserat-continuum.cc index 09da4039..be69022f 100644 --- a/src/cosserat-continuum.cc +++ b/src/cosserat-continuum.cc @@ -580,7 +580,7 @@ int main (int argc, char *argv[]) try dirichletDofsTargetSpace[i][j] = orientationDirichletDofs[i][j-3]; } - using GFEAssemblerWrapper = Dune::GFE::GeodesicFEAssemblerWrapper<CompositeBasis, DeformationFEBasis, TargetSpace, RealTuple<double, 3>, Rotation<double,3> >; + using GFEAssemblerWrapper = Dune::GFE::GeodesicFEAssemblerWrapper<CompositeBasis, DeformationFEBasis, TargetSpace>; GFEAssemblerWrapper assembler(&mixedAssembler, deformationFEBasis); if (parameterSet.get<std::string>("solvertype", "trustRegion") == "trustRegion") { RiemannianTrustRegionSolver<DeformationFEBasis, TargetSpace, GFEAssemblerWrapper> solver; @@ -678,7 +678,7 @@ int main (int argc, char *argv[]) try dirichletDofsTargetSpace[i][j] = orientationDirichletDofs[i][j-3]; } - using GFEAssemblerWrapper = Dune::GFE::GeodesicFEAssemblerWrapper<CompositeBasis, DeformationFEBasis, TargetSpace, RealTuple<double, 3>, Rotation<double,3> >; + using GFEAssemblerWrapper = Dune::GFE::GeodesicFEAssemblerWrapper<CompositeBasis, DeformationFEBasis, TargetSpace>; GFEAssemblerWrapper assembler(&mixedAssembler, deformationFEBasis); if (parameterSet.get<std::string>("solvertype", "trustRegion") == "trustRegion") { RiemannianTrustRegionSolver<DeformationFEBasis, TargetSpace, GFEAssemblerWrapper> solver; diff --git a/src/film-on-substrate.cc b/src/film-on-substrate.cc index efd0f302..1e6cc7b1 100644 --- a/src/film-on-substrate.cc +++ b/src/film-on-substrate.cc @@ -594,7 +594,7 @@ int main (int argc, char *argv[]) try for (int j = dim; j < RBM::TangentVector::dimension; j ++) dirichletDofsRBM[i][j] = dirichletDofs[_1][i][j-dim]; } - typedef Dune::GFE::GeodesicFEAssemblerWrapper<CompositeBasis, DeformationFEBasis, RBM, RealTuple<double, dim>, Rotation<double,dim> > GFEAssemblerWrapper; + typedef Dune::GFE::GeodesicFEAssemblerWrapper<CompositeBasis, DeformationFEBasis, RBM> GFEAssemblerWrapper; GFEAssemblerWrapper assembler(&mixedAssembler, deformationFEBasis); #endif diff --git a/src/simofoxshell.cc b/src/simofoxshell.cc index f67062dd..389a0c16 100644 --- a/src/simofoxshell.cc +++ b/src/simofoxshell.cc @@ -398,7 +398,7 @@ int main(int argc, char *argv[]) try for (int j = 3; j < TargetSpace::TangentVector::dimension; j ++) dirichletDofsTargetSpace[i][j] = orientationDirichletDofs[i][j-3]; } - using GFEAssemblerWrapper = Dune::GFE::GeodesicFEAssemblerWrapper<decltype(compositeBasis), MidsurfaceFEBasis, TargetSpace, RealTuple<double, 3>, UnitVector<double,3> >; + using GFEAssemblerWrapper = Dune::GFE::GeodesicFEAssemblerWrapper<decltype(compositeBasis), MidsurfaceFEBasis, TargetSpace>; GFEAssemblerWrapper assemblerNotMixed(&assembler, midsurfaceFEBasis); RiemannianProximalNewtonSolver<MidsurfaceFEBasis, TargetSpace, GFEAssemblerWrapper> solver; solver.setup(*grid, diff --git a/test/filmonsubstratetest.cc b/test/filmonsubstratetest.cc index 9b543291..8255ca56 100644 --- a/test/filmonsubstratetest.cc +++ b/test/filmonsubstratetest.cc @@ -392,7 +392,7 @@ int main (int argc, char *argv[]) for (int j = dim; j < RBM::TangentVector::dimension; j ++) dirichletDofsRBM[i][j] = dirichletDofs[_1][i][j-dim]; } - typedef GFE::GeodesicFEAssemblerWrapper<CompositeBasis, DeformationFEBasis, RBM, RealTuple<double, dim>, Rotation<double,dim> > GFEAssemblerWrapper; + typedef GFE::GeodesicFEAssemblerWrapper<CompositeBasis, DeformationFEBasis, RBM> GFEAssemblerWrapper; GFEAssemblerWrapper assembler(&mixedAssembler, deformationFEBasis); #endif diff --git a/test/geodesicfeassemblerwrappertest.cc b/test/geodesicfeassemblerwrappertest.cc index 9b6cf7a7..94f8a7ae 100644 --- a/test/geodesicfeassemblerwrappertest.cc +++ b/test/geodesicfeassemblerwrappertest.cc @@ -145,7 +145,7 @@ int main (int argc, char *argv[]) using DeformationFEBasis = Functions::LagrangeBasis<GridView,displacementOrder>; DeformationFEBasis deformationFEBasis(gridView); - using GFEAssemblerWrapper = GFE::GeodesicFEAssemblerWrapper<CompositeBasis, DeformationFEBasis, RBM, RealTuple<double, dim>, Rotation<double,dim> >; + using GFEAssemblerWrapper = GFE::GeodesicFEAssemblerWrapper<CompositeBasis, DeformationFEBasis, RBM>; GFEAssemblerWrapper assembler(&mixedAssembler, deformationFEBasis); ///////////////////////////////////////////////////////////////////////// diff --git a/test/mixedriemannianpnsolvertest.cc b/test/mixedriemannianpnsolvertest.cc index 89ddeb07..201bed5a 100644 --- a/test/mixedriemannianpnsolvertest.cc +++ b/test/mixedriemannianpnsolvertest.cc @@ -174,7 +174,7 @@ int main (int argc, char *argv[]) MixedGFEAssembler<CompositeBasis, RBM> mixedAssembler(compositeBasis, mixedLocalGFEADOLCStiffness); - using GFEAssemblerWrapper = GFE::GeodesicFEAssemblerWrapper<CompositeBasis, DeformationFEBasis, RBM, RealTuple<double, dim>, Rotation<double,dim> >; + using GFEAssemblerWrapper = GFE::GeodesicFEAssemblerWrapper<CompositeBasis, DeformationFEBasis, RBM>; GFEAssemblerWrapper assembler(&mixedAssembler, deformationFEBasis); ///////////////////////////////////////////////////////////////////////// -- GitLab