From 98b0b7dd50564f1887839c5d9789da46e8be9f69 Mon Sep 17 00:00:00 2001 From: Elias Pipping <elias.pipping@fu-berlin.de> Date: Mon, 9 Jan 2012 17:33:17 +0100 Subject: [PATCH] Be explicit about templates --- dune/tectonic/myblockproblem.hh | 8 +++++--- dune/tectonic/myconvexproblem.hh | 9 +++++---- src/one-body-sample.cc | 23 ++++++++++++++--------- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/dune/tectonic/myblockproblem.hh b/dune/tectonic/myblockproblem.hh index 1f569b48..92937712 100644 --- a/dune/tectonic/myblockproblem.hh +++ b/dune/tectonic/myblockproblem.hh @@ -123,8 +123,9 @@ template <class MyConvexProblemTypeTEMPLATE> class MyBlockProblem { localb = <b - Au, v> */ - MyDirectionalConvexFunction<Dune::GlobalNonlinearity<block_size>> const psi( - localA, localb, problem.phi, u, v); + MyDirectionalConvexFunction< + Dune::GlobalNonlinearity<block_size, VectorType, MatrixType>> const + psi(localA, localb, problem.phi, u, v); Interval<double> D; psi.subDiff(0, D); @@ -197,7 +198,8 @@ template <class MyConvexProblemTypeTEMPLATE> class MyBlockProblem { linearization.A.mv(direction, tmp); // Av double const localb = tmp * direction; // <Av,v> - MyDirectionalConvexFunction<Dune::GlobalNonlinearity<block_size>> const + MyDirectionalConvexFunction< + Dune::GlobalNonlinearity<block_size, VectorType, MatrixType>> const psi(localA, localb, problem.phi, u, direction); Interval<double> D; diff --git a/dune/tectonic/myconvexproblem.hh b/dune/tectonic/myconvexproblem.hh index c2142dac..48b45d72 100644 --- a/dune/tectonic/myconvexproblem.hh +++ b/dune/tectonic/myconvexproblem.hh @@ -21,13 +21,14 @@ class MyConvexProblem { \param f The linear functional \param u The solution vector */ - MyConvexProblem(MatrixType const &A, - Dune::GlobalNonlinearity<block_size> const &phi, - VectorType const &f) + MyConvexProblem( + MatrixType const &A, + Dune::GlobalNonlinearity<block_size, VectorType, MatrixType> const &phi, + VectorType const &f) : A(A), phi(phi), f(f) {}; MatrixType const &A; - Dune::GlobalNonlinearity<block_size> const φ + Dune::GlobalNonlinearity<block_size, VectorType, MatrixType> const φ VectorType const &f; }; diff --git a/src/one-body-sample.cc b/src/one-body-sample.cc index 18705856..e0f44bf8 100644 --- a/src/one-body-sample.cc +++ b/src/one-body-sample.cc @@ -136,9 +136,11 @@ void assemble_frictional( true); // whether to resize the output vector and zero all of its entries } +template <class VectorType, class MatrixType> void assemble_nonlinearity( int size, Dune::ParameterTree const &parset, - Dune::shared_ptr<Dune::GlobalNonlinearity<dim> const> &myGlobalNonlinearity, + Dune::shared_ptr<Dune::GlobalNonlinearity< + dim, VectorType, MatrixType> const> &myGlobalNonlinearity, Dune::shared_ptr<Dune::BlockVector<Dune::FieldVector<double, 1>>> nodalIntegrals) { typedef Dune::BlockVector<Dune::FieldVector<double, 1>> SingletonVectorType; @@ -159,13 +161,14 @@ void assemble_nonlinearity( auto eta = Dune::make_shared<SingletonVectorType>(size); *eta = parset.get<double>("boundary.friction.eta"); - myGlobalNonlinearity = - Dune::make_shared<Dune::GlobalRuinaNonlinearity<dim> const>( - nodalIntegrals, a, mu, eta, normalStress); + myGlobalNonlinearity = Dune::make_shared< + Dune::GlobalRuinaNonlinearity<dim, VectorType, MatrixType> const>( + nodalIntegrals, a, mu, eta, normalStress); } else if (friction_model == std::string("Laursen")) { myGlobalNonlinearity = Dune::make_shared< - Dune::GlobalLaursenNonlinearity<dim, Dune::LinearFunction> const>( - mu, normalStress, nodalIntegrals); + Dune::GlobalLaursenNonlinearity<dim, Dune::LinearFunction, VectorType, + MatrixType> const>(mu, normalStress, + nodalIntegrals); } else { assert(false); } @@ -266,9 +269,11 @@ int main(int argc, char *argv[]) { assemble_frictional<GridType, GridView, SmallVector, P1Basis>( leafView, p1Basis, frictionalNodes, *nodalIntegrals); - Dune::shared_ptr<Dune::GlobalNonlinearity<dim> const> myGlobalNonlinearity; - assemble_nonlinearity(grid.size(grid.maxLevel(), dim), parset, - myGlobalNonlinearity, nodalIntegrals); + Dune::shared_ptr<Dune::GlobalNonlinearity< + dim, VectorType, OperatorType> const> myGlobalNonlinearity; + assemble_nonlinearity<VectorType, OperatorType>( + grid.size(grid.maxLevel(), dim), parset, myGlobalNonlinearity, + nodalIntegrals); // {{{ Set up TNNMG solver // linear iteration step components -- GitLab