From 1c781e660932879182e4d4aff09ca436f5149be9 Mon Sep 17 00:00:00 2001 From: Elias Pipping <elias.pipping@fu-berlin.de> Date: Mon, 14 Nov 2011 08:47:16 +0100 Subject: [PATCH] Use nicefunction, allocate on heap --- dune/tectonic/globallaursennonlinearity.hh | 8 ++++---- dune/tectonic/globalnonlinearity.hh | 6 ++++-- dune/tectonic/globalruinanonlinearity.hh | 13 ++++++------- dune/tectonic/myblockproblem.hh | 3 +-- dune/tectonic/myconvexproblem.hh | 8 +++----- src/one-body-sample.cc | 5 +---- 6 files changed, 19 insertions(+), 24 deletions(-) diff --git a/dune/tectonic/globallaursennonlinearity.hh b/dune/tectonic/globallaursennonlinearity.hh index b1d84544..c6a8ef92 100644 --- a/dune/tectonic/globallaursennonlinearity.hh +++ b/dune/tectonic/globallaursennonlinearity.hh @@ -6,11 +6,11 @@ #include <dune/common/fvector.hh> #include "globalnonlinearity.hh" +#include "nicefunction.hh" namespace Dune { template <int dim, class OuterFunctionType> -class GlobalLaursenNonlinearity - : public Dune::GlobalNonlinearity<dim, OuterFunctionType> { +class GlobalLaursenNonlinearity : public Dune::GlobalNonlinearity<dim> { public: GlobalLaursenNonlinearity( std::vector<double> const &coefficientOfFriction, @@ -34,11 +34,11 @@ class GlobalLaursenNonlinearity sigma_n [id + mu id] = sigma_n (1 + mu) id */ - OuterFunctionType restriction(int i) const { + virtual Dune::NiceFunction *restriction(int i) const { double coefficient = nodalIntegrals[i][0]; coefficient *= normalStress[i]; coefficient *= 1 + coefficientOfFriction[i]; - return OuterFunctionType(coefficient); + return new OuterFunctionType(coefficient); } private: diff --git a/dune/tectonic/globalnonlinearity.hh b/dune/tectonic/globalnonlinearity.hh index 8ed3bb38..7915f9ae 100644 --- a/dune/tectonic/globalnonlinearity.hh +++ b/dune/tectonic/globalnonlinearity.hh @@ -5,13 +5,15 @@ #include <dune/common/fvector.hh> +#include "nicefunction.hh" + namespace Dune { -template <int dim, class OuterFunctionType> class GlobalNonlinearity { +template <int dim> class GlobalNonlinearity { public: /* Return a restriction of the outer function to the i'th node. If */ - virtual OuterFunctionType restriction(int i) const = 0; + virtual NiceFunction* restriction(int i) const = 0; }; } #endif diff --git a/dune/tectonic/globalruinanonlinearity.hh b/dune/tectonic/globalruinanonlinearity.hh index aed66653..8a05c73d 100644 --- a/dune/tectonic/globalruinanonlinearity.hh +++ b/dune/tectonic/globalruinanonlinearity.hh @@ -5,13 +5,12 @@ #include <dune/common/fvector.hh> -#include "localnonlinearity.hh" +#include "nicefunction.hh" #include "globalnonlinearity.hh" namespace Dune { template <int dim> -class GlobalRuinaNonlinearity - : public Dune::GlobalNonlinearity<dim, Dune::RuinaFunction> { +class GlobalRuinaNonlinearity : public Dune::GlobalNonlinearity<dim> { public: GlobalRuinaNonlinearity( std::vector<Dune::FieldVector<double, 1>> const &nodalIntegrals, @@ -27,10 +26,10 @@ class GlobalRuinaNonlinearity /* Return a restriction of the outer function to the i'th node. */ - RuinaFunction virtual restriction(int i) const { - return Dune::RuinaFunction(nodalIntegrals[i][0], a[i], - coefficientOfFriction[i], eta[i], - normalStress[i]); + virtual Dune::NiceFunction *restriction(int i) const { + return new Dune::RuinaFunction(nodalIntegrals[i][0], a[i], + coefficientOfFriction[i], eta[i], + normalStress[i]); } private: diff --git a/dune/tectonic/myblockproblem.hh b/dune/tectonic/myblockproblem.hh index cb285c01..e4ff4a5d 100644 --- a/dune/tectonic/myblockproblem.hh +++ b/dune/tectonic/myblockproblem.hh @@ -17,7 +17,6 @@ template <class MyConvexProblemTypeTEMPLATE> class MyBlockProblem { public: typedef MyConvexProblemTypeTEMPLATE MyConvexProblemType; - typedef typename MyConvexProblemType::FunctionType FunctionType; typedef typename MyConvexProblemType::VectorType VectorType; typedef typename MyConvexProblemType::MatrixType MatrixType; typedef typename MyConvexProblemType::LocalVectorType LocalVectorType; @@ -115,7 +114,7 @@ class MyBlockProblem<MyConvexProblemTypeTEMPLATE>::IterateObject { assert(localA != NULL); auto const f = problem.phi.restriction(m); - Dune::LocalNonlinearity<block_size> const phi(f); + Dune::LocalNonlinearity<block_size> const phi(*f); Dune::SampleFunctional<block_size> localJ(*localA, localb, phi, ignore_component); diff --git a/dune/tectonic/myconvexproblem.hh b/dune/tectonic/myconvexproblem.hh index 588aa381..5d70df27 100644 --- a/dune/tectonic/myconvexproblem.hh +++ b/dune/tectonic/myconvexproblem.hh @@ -10,11 +10,9 @@ \tparam MatrixTypeTEMPLATE The type used for the matrix of the quadratic part */ -template <class MatrixTypeTEMPLATE, class VectorTypeTEMPLATE, - class FunctionTypeTEMPLATE> +template <class MatrixTypeTEMPLATE, class VectorTypeTEMPLATE> class MyConvexProblem { public: - typedef FunctionTypeTEMPLATE FunctionType; typedef VectorTypeTEMPLATE VectorType; typedef MatrixTypeTEMPLATE MatrixType; typedef typename VectorType::block_type LocalVectorType; @@ -29,12 +27,12 @@ class MyConvexProblem { \param u The solution vector */ MyConvexProblem(MatrixType const &A, - Dune::GlobalNonlinearity<block_size, FunctionType> &phi, + Dune::GlobalNonlinearity<block_size> &phi, VectorType const &f, VectorType &u) : A(A), phi(phi), f(f), u(u) {}; MatrixType const &A; - Dune::GlobalNonlinearity<block_size, FunctionType> const φ + Dune::GlobalNonlinearity<block_size> const φ VectorType const &f; diff --git a/src/one-body-sample.cc b/src/one-body-sample.cc index 55d087ca..595341b1 100644 --- a/src/one-body-sample.cc +++ b/src/one-body-sample.cc @@ -185,10 +185,7 @@ int main(int argc, char *argv[]) { setup_boundary(leafView, end_points, ignoreNodes, neumannNodes, frictionalNodes); - typedef MyConvexProblem<OperatorType, VectorType, Dune::LinearFunction> - MyConvexProblemType; - // typedef MyConvexProblem<OperatorType, VectorType, Dune::RuinaFunction> - // MyConvexProblemType; + typedef MyConvexProblem<OperatorType, VectorType> MyConvexProblemType; typedef MyBlockProblem<MyConvexProblemType> MyBlockProblemType; GenericNonlinearGS<MyBlockProblemType> nonlinearGSStep; nonlinearGSStep.ignoreNodes_ = &ignoreNodes; -- GitLab