diff --git a/dune/tectonic/ellipticenergy.hh b/dune/tectonic/ellipticenergy.hh index d423025c054b82e33e69974b365d7aae472719fa..ce755278872773f90ba2b6e7aeffba224a1eca12 100644 --- a/dune/tectonic/ellipticenergy.hh +++ b/dune/tectonic/ellipticenergy.hh @@ -16,10 +16,10 @@ template <size_t dim> class EllipticEnergy { using SmallVector = FieldVector<double, dim>; using SmallMatrix = FieldMatrix<double, dim, dim>; - using NonlinearityType = LocalFriction<dim>; + using Nonlinearity = LocalFriction<dim>; EllipticEnergy(SmallMatrix const &A, SmallVector const &b, - shared_ptr<NonlinearityType const> phi, size_t ignore = dim) + shared_ptr<Nonlinearity const> phi, size_t ignore = dim) : A(A), b(b), phi(phi), ignore(ignore) {} double operator()(SmallVector const &v) const { @@ -28,7 +28,7 @@ template <size_t dim> class EllipticEnergy { SmallMatrix const &A; SmallVector const &b; - shared_ptr<NonlinearityType const> const phi; + shared_ptr<Nonlinearity const> const phi; /* Dimension that should be ignored; goes from 0 to dim-1; the special value dim means that no dimension should be ignored */ size_t const ignore; diff --git a/dune/tectonic/globalnonlinearity.hh b/dune/tectonic/globalnonlinearity.hh index 8d23f04833b2d1d60773bdf19389c6844d041c8c..e0a3b8baf23a7ad683e6555ece84027bb4dd5341 100644 --- a/dune/tectonic/globalnonlinearity.hh +++ b/dune/tectonic/globalnonlinearity.hh @@ -12,21 +12,20 @@ #include "localfriction.hh" namespace Dune { -template <class MatrixTypeTEMPLATE, class VectorTypeTEMPLATE> -class GlobalNonlinearity { +template <class Matrix, class Vector> class GlobalNonlinearity { protected: - using SingletonVectorType = BlockVector<FieldVector<double, 1>>; + using SingletonVector = BlockVector<FieldVector<double, 1>>; public: using IndexSet = Dune::MatrixIndexSet; - using MatrixType = MatrixTypeTEMPLATE; - using VectorType = VectorTypeTEMPLATE; - using LocalMatrixType = typename MatrixType::block_type; - using LocalVectorType = typename VectorType::block_type; + using MatrixType = Matrix; + using VectorType = Vector; + using LocalMatrix = typename Matrix::block_type; + using LocalVectorType = typename Vector::block_type; size_t static const block_size = LocalVectorType::dimension; - using FrictionType = LocalFriction<block_size>; + using Friction = LocalFriction<block_size>; - double operator()(VectorType const &x) const { + double operator()(Vector const &x) const { double tmp = 0; for (size_t i = 0; i < x.size(); ++i) { auto const res = restriction(i); @@ -40,20 +39,20 @@ class GlobalNonlinearity { */ virtual shared_ptr<LocalFriction<block_size>> restriction(size_t i) const = 0; - void addHessian(VectorType const &v, MatrixType &hessian) const { + void addHessian(Vector const &v, Matrix &hessian) const { for (size_t i = 0; i < v.size(); ++i) { auto const res = restriction(i); res->addHessian(v[i], hessian[i][i]); } } - void directionalDomain(VectorType const &, VectorType const &, + void directionalDomain(Vector const &, Vector const &, Interval<double> &dom) const { dom[0] = -std::numeric_limits<double>::max(); dom[1] = std::numeric_limits<double>::max(); } - void directionalSubDiff(VectorType const &u, VectorType const &v, + void directionalSubDiff(Vector const &u, Vector const &v, Interval<double> &subdifferential) const { subdifferential[0] = subdifferential[1] = 0; for (size_t i = 0; i < u.size(); ++i) { @@ -70,19 +69,19 @@ class GlobalNonlinearity { indices.add(i, i); } - void addGradient(VectorType const &v, VectorType &gradient) const { + void addGradient(Vector const &v, Vector &gradient) const { for (size_t i = 0; i < v.size(); ++i) { auto const res = restriction(i); res->addGradient(v[i], gradient[i]); } } - double regularity(size_t i, typename VectorType::block_type const &x) const { + double regularity(size_t i, typename Vector::block_type const &x) const { auto const res = restriction(i); return res->regularity(x); } - virtual void updateLogState(SingletonVectorType const &logState) = 0; + virtual void updateLogState(SingletonVector const &logState) = 0; }; } #endif diff --git a/dune/tectonic/globalruinanonlinearity.hh b/dune/tectonic/globalruinanonlinearity.hh index 04d1c5b498fb333cd4045f74fe8845925fc278bd..026a9a6ad1856f25b8ec5f3b2b981506d2a93775 100644 --- a/dune/tectonic/globalruinanonlinearity.hh +++ b/dune/tectonic/globalruinanonlinearity.hh @@ -15,34 +15,32 @@ #include "frictionpotential.hh" namespace Dune { -template <class MatrixType, class VectorType> -class GlobalRuinaNonlinearity - : public GlobalNonlinearity<MatrixType, VectorType> { +template <class Matrix, class Vector> +class GlobalRuinaNonlinearity : public GlobalNonlinearity<Matrix, Vector> { public: - using GlobalNonlinearity<MatrixType, VectorType>::block_size; - using typename GlobalNonlinearity<MatrixType, VectorType>::FrictionType; + using GlobalNonlinearity<Matrix, Vector>::block_size; + using typename GlobalNonlinearity<Matrix, Vector>::Friction; private: - using typename GlobalNonlinearity<MatrixType, - VectorType>::SingletonVectorType; + using typename GlobalNonlinearity<Matrix, Vector>::SingletonVector; public: GlobalRuinaNonlinearity(Dune::BitSetVector<1> const &frictionalNodes, - SingletonVectorType const &nodalIntegrals, + SingletonVector const &nodalIntegrals, FrictionData const &fd) : restrictions(nodalIntegrals.size()) { auto trivialNonlinearity = - make_shared<FrictionType>(make_shared<TrivialFunction>()); + make_shared<Friction>(make_shared<TrivialFunction>()); for (size_t i = 0; i < restrictions.size(); ++i) { restrictions[i] = frictionalNodes[i][0] - ? make_shared<FrictionType>( + ? make_shared<Friction>( make_shared<FrictionPotential>(nodalIntegrals[i], fd)) : trivialNonlinearity; } } - void updateLogState(SingletonVectorType const &logState) override { + void updateLogState(SingletonVector const &logState) override { for (size_t i = 0; i < restrictions.size(); ++i) restrictions[i]->updateLogState(logState[i]); } @@ -50,12 +48,12 @@ class GlobalRuinaNonlinearity /* Return a restriction of the outer function to the i'th node. */ - shared_ptr<FrictionType> restriction(size_t i) const override { + shared_ptr<Friction> restriction(size_t i) const override { return restrictions[i]; } private: - std::vector<shared_ptr<FrictionType>> restrictions; + std::vector<shared_ptr<Friction>> restrictions; }; } #endif diff --git a/dune/tectonic/localfriction.hh b/dune/tectonic/localfriction.hh index 1ca219816609e83c5362cd99179d9491d72d2a5d..ddc0c8a2beaa0709fd7fe9906dfc22d37852d2c2 100644 --- a/dune/tectonic/localfriction.hh +++ b/dune/tectonic/localfriction.hh @@ -14,8 +14,8 @@ #include "frictionpotential.hh" // In order to compute (x * y) / |x|, compute x/|x| first -template <class VectorType> -double dotFirstNormalised(VectorType const &x, VectorType const &y) { +template <class Vector> +double dotFirstNormalised(Vector const &x, Vector const &y) { double const xnorm = x.two_norm(); if (xnorm <= 0.0) return 0.0; diff --git a/dune/tectonic/minimisation.hh b/dune/tectonic/minimisation.hh index 78f291cdd70ce9c48387de4066ca91b9539a8948..f63f0aff011d6110ce0c425b13df473a9fa65b95 100644 --- a/dune/tectonic/minimisation.hh +++ b/dune/tectonic/minimisation.hh @@ -18,9 +18,9 @@ void descentMinimisation(Functional const &J, typename Functional::SmallVector const &v, Bisection const &bisection) { using SmallVector = typename Functional::SmallVector; - using LocalNonlinearityType = typename Functional::NonlinearityType; + using LocalNonlinearity = typename Functional::Nonlinearity; - MyDirectionalConvexFunction<LocalNonlinearityType> const JRest( + MyDirectionalConvexFunction<LocalNonlinearity> const JRest( computeDirectionalA(J.A, v), computeDirectionalb(J.A, J.b, x, v), *J.phi, x, v); // }}} diff --git a/dune/tectonic/myblockproblem.hh b/dune/tectonic/myblockproblem.hh index 07592b2926ce1a21ae725d55951f236fa7dc9216..8d5a112e919c2a2d8e19936c722aae62122b01ab 100644 --- a/dune/tectonic/myblockproblem.hh +++ b/dune/tectonic/myblockproblem.hh @@ -19,23 +19,22 @@ #include "ellipticenergy.hh" /* Just for debugging */ -template <class MatrixType, class VectorType> -double computeEnergy( - MatrixType const &A, VectorType const &x, VectorType const &b, - Dune::GlobalNonlinearity<MatrixType, VectorType> const &phi) { +template <class Matrix, class Vector> +double computeEnergy(Matrix const &A, Vector const &x, Vector const &b, + Dune::GlobalNonlinearity<Matrix, Vector> const &phi) { return computeEnergy(A, x, b) + phi(x); } /** \brief Base class for problems where each block can be solved with a * modified gradient method */ -template <class ConvexProblemTypeTEMPLATE> class MyBlockProblem { +template <class ConvexProblem> class MyBlockProblem { public: - using ConvexProblemType = ConvexProblemTypeTEMPLATE; - using VectorType = typename ConvexProblemType::VectorType; - using MatrixType = typename ConvexProblemType::MatrixType; - using LocalVectorType = typename ConvexProblemType::LocalVectorType; - using LocalMatrixType = typename ConvexProblemType::LocalMatrixType; - size_t static const block_size = ConvexProblemType::block_size; + using ConvexProblemType = ConvexProblem; + using VectorType = typename ConvexProblem::VectorType; + using MatrixType = typename ConvexProblem::MatrixType; + using LocalVector = typename ConvexProblem::LocalVectorType; + using LocalMatrix = typename ConvexProblem::LocalMatrixType; + size_t static const block_size = ConvexProblem::block_size; size_t static const coarse_block_size = block_size; /** \brief Solves one local system using a modified gradient method */ @@ -44,10 +43,8 @@ template <class ConvexProblemTypeTEMPLATE> class MyBlockProblem { struct Linearization { size_t static const block_size = coarse_block_size; - using LocalMatrixType = - typename MyBlockProblem<ConvexProblemType>::LocalMatrixType; - using MatrixType = - Dune::BCRSMatrix<typename Linearization::LocalMatrixType>; + using LocalMatrix = typename MyBlockProblem<ConvexProblem>::LocalMatrix; + using MatrixType = Dune::BCRSMatrix<typename Linearization::LocalMatrix>; using VectorType = Dune::BlockVector<Dune::FieldVector<double, Linearization::block_size>>; using BitVectorType = Dune::BitSetVector<Linearization::block_size>; @@ -60,7 +57,7 @@ template <class ConvexProblemTypeTEMPLATE> class MyBlockProblem { }; MyBlockProblem(Dune::ParameterTree const &parset, - ConvexProblemType const &problem) + ConvexProblem const &problem) : parset(parset), problem(problem) { bisection = Bisection(); } @@ -196,7 +193,7 @@ template <class ConvexProblemTypeTEMPLATE> class MyBlockProblem { Dune::ParameterTree const &parset; // problem data - ConvexProblemType const &problem; + ConvexProblem const &problem; // commonly used minimization stuff Bisection bisection; @@ -205,8 +202,8 @@ template <class ConvexProblemTypeTEMPLATE> class MyBlockProblem { }; /** \brief Solves one local system using a scalar Gauss-Seidel method */ -template <class ConvexProblemTypeTEMPLATE> -class MyBlockProblem<ConvexProblemTypeTEMPLATE>::IterateObject { +template <class ConvexProblem> +class MyBlockProblem<ConvexProblem>::IterateObject { friend class MyBlockProblem; protected: @@ -215,7 +212,7 @@ class MyBlockProblem<ConvexProblemTypeTEMPLATE>::IterateObject { * \param problem The problem including quadratic part and nonlinear part */ IterateObject(Dune::ParameterTree const &parset, Bisection const &bisection, - ConvexProblemType const &problem) + ConvexProblem const &problem) : problem(problem), bisection(bisection), localsteps(parset.get<size_t>("localsolver.steps")) {} @@ -228,7 +225,7 @@ class MyBlockProblem<ConvexProblemTypeTEMPLATE>::IterateObject { } /** \brief Update the i-th block of the current iterate */ - void updateIterate(LocalVectorType const &ui, size_t i) { + void updateIterate(LocalVector const &ui, size_t i) { u[i] = ui; return; } @@ -239,7 +236,7 @@ class MyBlockProblem<ConvexProblemTypeTEMPLATE>::IterateObject { * \param ignore Set of degrees of freedom to leave untouched */ void solveLocalProblem( - LocalVectorType &ui, size_t m, + LocalVector &ui, size_t m, typename Dune::BitSetVector<block_size>::const_reference ignore) { { size_t ic = @@ -258,8 +255,8 @@ class MyBlockProblem<ConvexProblemTypeTEMPLATE>::IterateObject { assert(false); } - LocalMatrixType const *localA = nullptr; - LocalVectorType localb(problem.f[m]); + LocalMatrix const *localA = nullptr; + LocalVector localb(problem.f[m]); auto const end = problem.A[m].end(); for (auto it = problem.A[m].begin(); it != end; ++it) { @@ -279,7 +276,7 @@ class MyBlockProblem<ConvexProblemTypeTEMPLATE>::IterateObject { private: // problem data - ConvexProblemType const &problem; + ConvexProblem const &problem; // commonly used minimization stuff Bisection bisection; diff --git a/dune/tectonic/mydirectionalconvexfunction.hh b/dune/tectonic/mydirectionalconvexfunction.hh index cd05e083de92672480895ea53d9278190da38d7f..9c792a2d92358412256d1aa483b4067890fe184e 100644 --- a/dune/tectonic/mydirectionalconvexfunction.hh +++ b/dune/tectonic/mydirectionalconvexfunction.hh @@ -15,24 +15,24 @@ localb = <b - Au, v> */ -template <class MatrixType, class VectorType> -double computeDirectionalA(MatrixType const &A, VectorType const &v) { +template <class Matrix, class Vector> +double computeDirectionalA(Matrix const &A, Vector const &v) { return Arithmetic::Axy(A, v, v); } -template <class MatrixType, class VectorType> -double computeDirectionalb(MatrixType const &A, VectorType const &b, - VectorType const &u, VectorType const &v) { +template <class Matrix, class Vector> +double computeDirectionalb(Matrix const &A, Vector const &b, Vector const &u, + Vector const &v) { return Arithmetic::bmAxy(A, b, u, v); } -template <class NonlinearityType> class MyDirectionalConvexFunction { +template <class Nonlinearity> class MyDirectionalConvexFunction { public: - using VectorType = typename NonlinearityType::VectorType; - using MatrixType = typename NonlinearityType::MatrixType; + using Vector = typename Nonlinearity::VectorType; + using Matrix = typename Nonlinearity::MatrixType; - MyDirectionalConvexFunction(double A, double b, NonlinearityType const &phi, - VectorType const &u, VectorType const &v) + MyDirectionalConvexFunction(double A, double b, Nonlinearity const &phi, + Vector const &u, Vector const &v) : A(A), b(b), phi(phi), u(u), v(v) { phi.directionalDomain(u, v, dom); } @@ -42,7 +42,7 @@ template <class NonlinearityType> class MyDirectionalConvexFunction { double linearPart() const { return b; } void subDiff(double x, Interval<double> &D) const { - VectorType uxv = u; + Vector uxv = u; Arithmetic::addProduct(uxv, x, v); phi.directionalSubDiff(uxv, v, D); D[0] += A * x - b; @@ -58,9 +58,9 @@ template <class NonlinearityType> class MyDirectionalConvexFunction { double b; private: - NonlinearityType const φ - VectorType const &u; - VectorType const &v; + Nonlinearity const φ + Vector const &u; + Vector const &v; Interval<double> dom; }; diff --git a/src/assemblers.cc b/src/assemblers.cc index 54b7113367ad6fa9ecbde01a2b35ea39be080b17..81b92480811529ea48f6afc48a4337420d561bd3 100644 --- a/src/assemblers.cc +++ b/src/assemblers.cc @@ -11,33 +11,31 @@ #include "assemblers.hh" // Assembles Neumann boundary term in f -template <class GridView, class LocalVectorType, class AssemblerType> -void assembleNeumann(GridView const &gridView, AssemblerType const &assembler, +template <class GridView, class LocalVector, class Assembler> +void assembleNeumann(GridView const &gridView, Assembler const &assembler, Dune::BitSetVector<1> const &neumannNodes, - Dune::BlockVector<LocalVectorType> &f, + Dune::BlockVector<LocalVector> &f, Dune::VirtualFunction<double, double> const &neumann, double relativeTime) { // constant sample function on // neumann boundary BoundaryPatch<GridView> const neumannBoundary(gridView, neumannNodes); - LocalVectorType localNeumann(0); + LocalVector localNeumann(0); neumann.evaluate(relativeTime, localNeumann[0]); - ConstantFunction<LocalVectorType, LocalVectorType> const fNeumann( - localNeumann); - NeumannBoundaryAssembler<typename GridView::Grid, LocalVectorType> + ConstantFunction<LocalVector, LocalVector> const fNeumann(localNeumann); + NeumannBoundaryAssembler<typename GridView::Grid, LocalVector> neumannBoundaryAssembler(fNeumann); assembler.assembleBoundaryFunctional(neumannBoundaryAssembler, f, neumannBoundary); } // Assembles constant 1-function on frictional boundary in nodalIntegrals -template <class GridView, class LocalVectorType, class AssemblerType> +template <class GridView, class LocalVector, class Assembler> Dune::shared_ptr<Dune::BlockVector<Dune::FieldVector<double, 1>>> -assembleFrictionWeightsal(GridView const &gridView, - AssemblerType const &assembler, +assembleFrictionWeightsal(GridView const &gridView, Assembler const &assembler, Dune::BitSetVector<1> const &frictionalNodes) { using Singleton = Dune::FieldVector<double, 1>; BoundaryPatch<GridView> const frictionalBoundary(gridView, frictionalNodes); - ConstantFunction<LocalVectorType, Singleton> const constantOneFunction(1); + ConstantFunction<LocalVector, Singleton> const constantOneFunction(1); NeumannBoundaryAssembler<typename GridView::Grid, Singleton> frictionalBoundaryAssembler(constantOneFunction); @@ -47,14 +45,12 @@ assembleFrictionWeightsal(GridView const &gridView, return nodalIntegrals; } -template <class MatrixType, class VectorType> -Dune::shared_ptr<Dune::GlobalNonlinearity<MatrixType, VectorType>> -assembleNonlinearity( +template <class Matrix, class Vector> +Dune::shared_ptr<Dune::GlobalNonlinearity<Matrix, Vector>> assembleNonlinearity( Dune::BitSetVector<1> const &frictionalNodes, Dune::BlockVector<Dune::FieldVector<double, 1>> const &nodalIntegrals, FrictionData const &fd) { - return Dune::make_shared< - Dune::GlobalRuinaNonlinearity<MatrixType, VectorType>>( + return Dune::make_shared<Dune::GlobalRuinaNonlinearity<Matrix, Vector>>( frictionalNodes, nodalIntegrals, fd); } diff --git a/src/assemblers.hh b/src/assemblers.hh index b728742ec2078c3749294a7c8029e176ec03d2de..75d3dd487b5341aae740cb4e952144df9663bb92 100644 --- a/src/assemblers.hh +++ b/src/assemblers.hh @@ -11,22 +11,20 @@ #include <dune/tectonic/globalnonlinearity.hh> -template <class GridView, class LocalVectorType, class AssemblerType> -void assembleNeumann(GridView const &gridView, AssemblerType const &assembler, +template <class GridView, class LocalVector, class Assembler> +void assembleNeumann(GridView const &gridView, Assembler const &assembler, Dune::BitSetVector<1> const &neumannNodes, - Dune::BlockVector<LocalVectorType> &f, + Dune::BlockVector<LocalVector> &f, Dune::VirtualFunction<double, double> const &neumann, double relativeTime); -template <class GridView, class LocalVectorType, class AssemblerType> +template <class GridView, class LocalVector, class Assembler> Dune::shared_ptr<Dune::BlockVector<Dune::FieldVector<double, 1>>> -assembleFrictionWeightsal(GridView const &gridView, - AssemblerType const &assembler, +assembleFrictionWeightsal(GridView const &gridView, Assembler const &assembler, Dune::BitSetVector<1> const &frictionalNodes); -template <class MatrixType, class VectorType> -Dune::shared_ptr<Dune::GlobalNonlinearity<MatrixType, VectorType>> -assembleNonlinearity( +template <class Matrix, class Vector> +Dune::shared_ptr<Dune::GlobalNonlinearity<Matrix, Vector>> assembleNonlinearity( Dune::BitSetVector<1> const &frictionalNodes, Dune::BlockVector<Dune::FieldVector<double, 1>> const &nodalIntegrals, FrictionData const &fd); diff --git a/src/assemblers_tmpl.cc b/src/assemblers_tmpl.cc index 86b32abdda7f20c1e93e813db4d3f5e5c66d7545..9d0d6d1b1cd70841d6a54b559a20d054b2d2239c 100644 --- a/src/assemblers_tmpl.cc +++ b/src/assemblers_tmpl.cc @@ -15,27 +15,27 @@ using SmallVector = Dune::FieldVector<double, DIM>; using SmallMatrix = Dune::FieldMatrix<double, DIM, DIM>; -using MatrixType = Dune::BCRSMatrix<SmallMatrix>; -using VectorType = Dune::BlockVector<SmallVector>; +using Matrix = Dune::BCRSMatrix<SmallMatrix>; +using Vector = Dune::BlockVector<SmallVector>; -using GridType = Dune::ALUGrid<DIM, DIM, Dune::simplex, Dune::nonconforming>; -using GridView = GridType::LeafGridView; +using Grid = Dune::ALUGrid<DIM, DIM, Dune::simplex, Dune::nonconforming>; +using GridView = Grid::LeafGridView; using P1Basis = P1NodalBasis<GridView, double>; -using AssemblerType = Assembler<P1Basis, P1Basis>; +using MyAssembler = Assembler<P1Basis, P1Basis>; -template void assembleNeumann<GridView, SmallVector, AssemblerType>( - GridView const &gridView, AssemblerType const &assembler, +template void assembleNeumann<GridView, SmallVector, MyAssembler>( + GridView const &gridView, MyAssembler const &assembler, Dune::BitSetVector<1> const &neumannNodes, Dune::BlockVector<SmallVector> &f, Dune::VirtualFunction<double, double> const &neumann, double relativeTime); template Dune::shared_ptr<Dune::BlockVector<Dune::FieldVector<double, 1>>> -assembleFrictionWeightsal<GridView, SmallVector, AssemblerType>( - GridView const &gridView, AssemblerType const &assembler, +assembleFrictionWeightsal<GridView, SmallVector, MyAssembler>( + GridView const &gridView, MyAssembler const &assembler, Dune::BitSetVector<1> const &frictionalNodes); -template Dune::shared_ptr<Dune::GlobalNonlinearity<MatrixType, VectorType>> -assembleNonlinearity<MatrixType, VectorType>( +template Dune::shared_ptr<Dune::GlobalNonlinearity<Matrix, Vector>> +assembleNonlinearity<Matrix, Vector>( Dune::BitSetVector<1> const &frictionalNodes, Dune::BlockVector<Dune::FieldVector<double, 1>> const &nodalIntegrals, FrictionData const &fd); diff --git a/src/enum_parser.cc b/src/enum_parser.cc index d8bcd06c9bde519a458e2f0ee939c6fdf6b6b279..041983c900a2b2e2de20e98c40e84542f3a5a15a 100644 --- a/src/enum_parser.cc +++ b/src/enum_parser.cc @@ -3,18 +3,18 @@ #include <dune/common/exceptions.hh> #include <dune/common/typetraits.hh> -template <class EnumType> struct StringToEnum : public Dune::NotImplemented {}; +template <class Enum> struct StringToEnum : public Dune::NotImplemented {}; -template <class EnumType> +template <class Enum> typename Dune::enable_if< - !Dune::IsBaseOf<Dune::NotImplemented, StringToEnum<EnumType>>::value, + !Dune::IsBaseOf<Dune::NotImplemented, StringToEnum<Enum>>::value, std::istream &>::type -operator>>(std::istream &lhs, EnumType &e) { +operator>>(std::istream &lhs, Enum &e) { std::string s; lhs >> s; try { - e = StringToEnum<EnumType>::convert(s); + e = StringToEnum<Enum>::convert(s); } catch (typename Dune::Exception) { lhs.setstate(std::ios_base::failbit); diff --git a/src/friction_writer.cc b/src/friction_writer.cc index 90417e1cc480a5bcbdaecccb84028774c0081ab2..409ef49fa0b96fceb1353190be0dfa59e2bb358a 100644 --- a/src/friction_writer.cc +++ b/src/friction_writer.cc @@ -10,9 +10,9 @@ double computeCOF(FrictionData const &fd, double V, double logState) { return (mu > 0) ? mu : 0; } -template <class BitVectorType> -FrictionWriter<BitVectorType>::FrictionWriter( - FrictionData const &_fd, BitVectorType const &_boundaryNodes) +template <class BitVector> +FrictionWriter<BitVector>::FrictionWriter(FrictionData const &_fd, + BitVector const &_boundaryNodes) : coefficientWriter("coefficients", std::fstream::out), displacementWriter("displacements", std::fstream::out), stateWriter("states", std::fstream::out), @@ -20,19 +20,17 @@ FrictionWriter<BitVectorType>::FrictionWriter( fd(_fd), boundaryNodes(_boundaryNodes) {} -template <class BitVectorType> -FrictionWriter<BitVectorType>::~FrictionWriter() { +template <class BitVector> FrictionWriter<BitVector>::~FrictionWriter() { stateWriter.close(); displacementWriter.close(); velocityWriter.close(); coefficientWriter.close(); } -template <class BitVectorType> -template <class SingletonVectorType, class VectorType> -void FrictionWriter<BitVectorType>::writeInfo(SingletonVectorType const &alpha, - VectorType const &u, - VectorType const &v) { +template <class BitVector> +template <class SingletonVector, class Vector> +void FrictionWriter<BitVector>::writeInfo(SingletonVector const &alpha, + Vector const &u, Vector const &v) { for (size_t i = 0; i < boundaryNodes.size(); ++i) { if (!boundaryNodes[i][0]) continue; diff --git a/src/friction_writer.hh b/src/friction_writer.hh index 97a7055f3bd7c90c04a67bac2cf20e525c6c24fc..1907f405c73d1c75eca62eeeecbf4bf05b54103b 100644 --- a/src/friction_writer.hh +++ b/src/friction_writer.hh @@ -5,15 +5,15 @@ #include <dune/tectonic/frictiondata.hh> -template <class BitVectorType> class FrictionWriter { +template <class BitVector> class FrictionWriter { public: - FrictionWriter(FrictionData const &_fd, BitVectorType const &_boundaryNodes); + FrictionWriter(FrictionData const &_fd, BitVector const &_boundaryNodes); ~FrictionWriter(); - template <class SingletonVectorType, class VectorType> - void writeInfo(SingletonVectorType const &alpha, VectorType const &u, - VectorType const &v); + template <class SingletonVector, class Vector> + void writeInfo(SingletonVector const &alpha, Vector const &u, + Vector const &v); private: std::fstream coefficientWriter; @@ -21,6 +21,6 @@ template <class BitVectorType> class FrictionWriter { std::fstream stateWriter; std::fstream velocityWriter; FrictionData const &fd; - BitVectorType const &boundaryNodes; + BitVector const &boundaryNodes; }; #endif diff --git a/src/friction_writer_tmpl.cc b/src/friction_writer_tmpl.cc index b37ab8c01e9a7c2698ce5708aab4a5e7a5995df8..38ef0fbbdac90b73b76b47483b003e9ff2a886ec 100644 --- a/src/friction_writer_tmpl.cc +++ b/src/friction_writer_tmpl.cc @@ -1,16 +1,16 @@ #include <dune/common/bitsetvector.hh> #include <dune/istl/bvector.hh> -using BitVectorType = Dune::BitSetVector<1>; -using SingletonVectorType = Dune::BlockVector<Dune::FieldVector<double, 1>>; -using VectorType2 = Dune::BlockVector<Dune::FieldVector<double, 2>>; -using VectorType3 = Dune::BlockVector<Dune::FieldVector<double, 3>>; +using BitVector = Dune::BitSetVector<1>; +using SingletonVector = Dune::BlockVector<Dune::FieldVector<double, 1>>; +using Vector2 = Dune::BlockVector<Dune::FieldVector<double, 2>>; +using Vector3 = Dune::BlockVector<Dune::FieldVector<double, 3>>; -template class FrictionWriter<BitVectorType>; +template class FrictionWriter<BitVector>; -template void FrictionWriter<BitVectorType>::writeInfo( - SingletonVectorType const &alpha, VectorType2 const &u, - VectorType2 const &v); -template void FrictionWriter<BitVectorType>::writeInfo( - SingletonVectorType const &alpha, VectorType3 const &u, - VectorType3 const &v); +template void FrictionWriter<BitVector>::writeInfo(SingletonVector const &alpha, + Vector2 const &u, + Vector2 const &v); +template void FrictionWriter<BitVector>::writeInfo(SingletonVector const &alpha, + Vector3 const &u, + Vector3 const &v); diff --git a/src/one-body-sample.cc b/src/one-body-sample.cc index 60fa76360ae9326ade3d138ae7200f84353c90ae..880d3c19ad9e3d34f0c94404f041a025a3b41f0a 100644 --- a/src/one-body-sample.cc +++ b/src/one-body-sample.cc @@ -100,24 +100,21 @@ size_t const dims = DIM; -template <class VectorType, class MatrixType, class FunctionType, int dimension> -Dune::shared_ptr< - TimeSteppingScheme<VectorType, MatrixType, FunctionType, dimension>> +template <class Vector, class Matrix, class Function, int dimension> +Dune::shared_ptr<TimeSteppingScheme<Vector, Matrix, Function, dimension>> initTimeStepper(Config::scheme scheme, - FunctionType const &velocityDirichletFunction, + Function const &velocityDirichletFunction, Dune::BitSetVector<dimension> const &velocityDirichletNodes, - MatrixType const &massMatrix, MatrixType const &stiffnessMatrix, - MatrixType const &dampingMatrix, VectorType const &u_initial, - VectorType const &v_initial, VectorType const &a_initial) { + Matrix const &massMatrix, Matrix const &stiffnessMatrix, + Matrix const &dampingMatrix, Vector const &u_initial, + Vector const &v_initial, Vector const &a_initial) { switch (scheme) { case Config::Newmark: - return Dune::make_shared< - Newmark<VectorType, MatrixType, FunctionType, dims>>( + return Dune::make_shared<Newmark<Vector, Matrix, Function, dims>>( stiffnessMatrix, massMatrix, dampingMatrix, u_initial, v_initial, a_initial, velocityDirichletNodes, velocityDirichletFunction); case Config::BackwardEuler: - return Dune::make_shared< - BackwardEuler<VectorType, MatrixType, FunctionType, dims>>( + return Dune::make_shared<BackwardEuler<Vector, Matrix, Function, dims>>( stiffnessMatrix, massMatrix, dampingMatrix, u_initial, v_initial, velocityDirichletNodes, velocityDirichletFunction); default: @@ -125,20 +122,16 @@ initTimeStepper(Config::scheme scheme, } } -template <class SingletonVectorType, class VectorType> -Dune::shared_ptr<StateUpdater<SingletonVectorType, VectorType>> -initStateUpdater(Config::stateModel model, - SingletonVectorType const &alpha_initial, - Dune::BitSetVector<1> const &frictionalNodes, - FrictionData const &fd) { +template <class SingletonVector, class Vector> +Dune::shared_ptr<StateUpdater<SingletonVector, Vector>> initStateUpdater( + Config::stateModel model, SingletonVector const &alpha_initial, + Dune::BitSetVector<1> const &frictionalNodes, FrictionData const &fd) { switch (model) { case Config::Dieterich: - return Dune::make_shared< - DieterichStateUpdater<SingletonVectorType, VectorType>>( + return Dune::make_shared<DieterichStateUpdater<SingletonVector, Vector>>( alpha_initial, frictionalNodes, fd.L); case Config::Ruina: - return Dune::make_shared< - RuinaStateUpdater<SingletonVectorType, VectorType>>( + return Dune::make_shared<RuinaStateUpdater<SingletonVector, Vector>>( alpha_initial, frictionalNodes, fd.L); default: assert(false); @@ -162,32 +155,31 @@ int main(int argc, char *argv[]) { using SmallVector = Dune::FieldVector<double, dims>; using SmallMatrix = Dune::FieldMatrix<double, dims, dims>; using SmallSingletonMatrix = Dune::FieldMatrix<double, 1, 1>; - using MatrixType = Dune::BCRSMatrix<SmallMatrix>; - using SingletonMatrixType = Dune::BCRSMatrix<SmallSingletonMatrix>; - using VectorType = Dune::BlockVector<SmallVector>; - using SingletonVectorType = Dune::BlockVector<Dune::FieldVector<double, 1>>; - using NonlinearityType = Dune::GlobalNonlinearity<MatrixType, VectorType>; + using Matrix = Dune::BCRSMatrix<SmallMatrix>; + using SingletonMatrix = Dune::BCRSMatrix<SmallSingletonMatrix>; + using Vector = Dune::BlockVector<SmallVector>; + using SingletonVector = Dune::BlockVector<Dune::FieldVector<double, 1>>; + using Nonlinearity = Dune::GlobalNonlinearity<Matrix, Vector>; auto const E = parset.get<double>("body.E"); auto const nu = parset.get<double>("body.nu"); // {{{ Set up grid - using GridType = - Dune::ALUGrid<dims, dims, Dune::simplex, Dune::nonconforming>; + using Grid = Dune::ALUGrid<dims, dims, Dune::simplex, Dune::nonconforming>; - Dune::FieldVector<typename GridType::ctype, dims> lowerLeft(0); - Dune::FieldVector<typename GridType::ctype, dims> upperRight(1); + Dune::FieldVector<typename Grid::ctype, dims> lowerLeft(0); + Dune::FieldVector<typename Grid::ctype, dims> upperRight(1); upperRight[0] = parset.get<size_t>("body.width"); upperRight[1] = parset.get<size_t>("body.height"); - Dune::shared_ptr<GridType> grid; + Dune::shared_ptr<Grid> grid; { Dune::array<unsigned int, dims> elements; std::fill(elements.begin(), elements.end(), 1); elements[0] = parset.get<size_t>("body.width"); elements[1] = parset.get<size_t>("body.height"); - grid = Dune::StructuredGridFactory<GridType>::createSimplexGrid( + grid = Dune::StructuredGridFactory<Grid>::createSimplexGrid( lowerLeft, upperRight, elements); } @@ -195,7 +187,7 @@ int main(int argc, char *argv[]) { grid->globalRefine(refinements); size_t const fineVertexCount = grid->size(grid->maxLevel(), dims); - using GridView = GridType::LeafGridView; + using GridView = Grid::LeafGridView; GridView const leafView = grid->leafView(); // }}} @@ -215,7 +207,7 @@ int main(int argc, char *argv[]) { Dune::BitSetVector<1> neumannNodes(fineVertexCount, false); Dune::BitSetVector<1> frictionalNodes(fineVertexCount, false); - VectorType vertexCoordinates(fineVertexCount); + Vector vertexCoordinates(fineVertexCount); { Dune::MultipleCodimMultipleGeomTypeMapper< GridView, Dune::MCMGVertexLayout> const vertexMapper(leafView); @@ -247,8 +239,8 @@ int main(int argc, char *argv[]) { BoundaryPatch<GridView> const frictionalBoundary(leafView, frictionalNodes); // Set up functions for time-dependent boundary conditions - using FunctionType = Dune::VirtualFunction<double, double>; - using FunctionMap = SharedPointerMap<std::string, FunctionType>; + using Function = Dune::VirtualFunction<double, double>; + using FunctionMap = SharedPointerMap<std::string, Function>; FunctionMap functions; { initPython(); @@ -262,14 +254,14 @@ int main(int argc, char *argv[]) { // Set up normal stress, mass matrix, and gravity functional double normalStress; - MatrixType M; - EnergyNorm<MatrixType, VectorType> const MNorm(M); - VectorType gravityFunctional; + Matrix M; + EnergyNorm<Matrix, Vector> const MNorm(M); + Vector gravityFunctional; { double const gravity = 9.81; double const density = parset.get<double>("body.density"); { - MassAssembler<GridType, P1Basis::LocalFiniteElement, + MassAssembler<Grid, P1Basis::LocalFiniteElement, P1Basis::LocalFiniteElement, Dune::ScaledIdentityMatrix<double, dims>> const localMass; p1Assembler.assembleOperator(localMass, M); @@ -295,8 +287,7 @@ int main(int argc, char *argv[]) { weightedGravitationalDirection[1] = -density * gravity; ConstantFunction<SmallVector, SmallVector> const gravityFunction( weightedGravitationalDirection); - L2FunctionalAssembler<GridType, P1Basis::LocalFiniteElement, - SmallVector> + L2FunctionalAssembler<Grid, P1Basis::LocalFiniteElement, SmallVector> gravityFunctionalAssembler(gravityFunction); p1Assembler.assembleFunctional(gravityFunctionalAssembler, gravityFunctional); @@ -305,80 +296,80 @@ int main(int argc, char *argv[]) { FrictionData const frictionData(parset.sub("boundary.friction"), normalStress); - MatrixType A; - EnergyNorm<MatrixType, VectorType> const ANorm(A); + Matrix A; + EnergyNorm<Matrix, Vector> const ANorm(A); { - StVenantKirchhoffAssembler<GridType, P1Basis::LocalFiniteElement, + StVenantKirchhoffAssembler<Grid, P1Basis::LocalFiniteElement, P1Basis::LocalFiniteElement> const localStiffness(E, nu); p1Assembler.assembleOperator(localStiffness, A); } - MatrixType C; + Matrix C; { - ViscosityAssembler<GridType, P1Basis::LocalFiniteElement, + ViscosityAssembler<Grid, P1Basis::LocalFiniteElement, P1Basis::LocalFiniteElement> const localViscosity(parset.get<double>("body.shearViscosity"), parset.get<double>("body.bulkViscosity")); p1Assembler.assembleOperator(localViscosity, C); } - SingletonMatrixType frictionalBoundaryMassMatrix; - EnergyNorm<SingletonMatrixType, SingletonVectorType> const stateEnergyNorm( + SingletonMatrix frictionalBoundaryMassMatrix; + EnergyNorm<SingletonMatrix, SingletonVector> const stateEnergyNorm( frictionalBoundaryMassMatrix); { BoundaryMassAssembler< - GridType, BoundaryPatch<GridView>, P1Basis::LocalFiniteElement, + Grid, BoundaryPatch<GridView>, P1Basis::LocalFiniteElement, P1Basis::LocalFiniteElement, SmallSingletonMatrix> const frictionalBoundaryMassAssembler(frictionalBoundary); p1Assembler.assembleOperator(frictionalBoundaryMassAssembler, frictionalBoundaryMassMatrix); } // Q: Does it make sense to weigh them in this manner? - SumNorm<VectorType> const AMNorm(1.0, ANorm, 1.0, MNorm); + SumNorm<Vector> const AMNorm(1.0, ANorm, 1.0, MNorm); auto const nodalIntegrals = assembleFrictionWeightsal<GridView, SmallVector>(leafView, p1Assembler, frictionalNodes); - auto myGlobalNonlinearity = assembleNonlinearity<MatrixType, VectorType>( + auto myGlobalNonlinearity = assembleNonlinearity<Matrix, Vector>( frictionalNodes, *nodalIntegrals, frictionData); // Problem formulation: right-hand side - auto const createRHS = [&](double _relativeTime, VectorType &_ell) { + auto const createRHS = [&](double _relativeTime, Vector &_ell) { assembleNeumann(leafView, p1Assembler, neumannNodes, _ell, neumannFunction, _relativeTime); _ell += gravityFunctional; }; - VectorType ell(fineVertexCount); + Vector ell(fineVertexCount); createRHS(0.0, ell); // {{{ Initial conditions - SingletonVectorType alpha_initial(fineVertexCount); + SingletonVector alpha_initial(fineVertexCount); alpha_initial = std::log(parset.get<double>("boundary.friction.initialState")); - using LinearFactoryType = SolverFactory< + using LinearFactory = SolverFactory< dims, BlockNonlinearTNNMGProblem<ConvexProblem< - ZeroNonlinearity<SmallVector, SmallMatrix>, MatrixType>>, - GridType>; + ZeroNonlinearity<SmallVector, SmallMatrix>, Matrix>>, + Grid>; ZeroNonlinearity<SmallVector, SmallMatrix> zeroNonlinearity; // Solve the stationary problem - VectorType u_initial(fineVertexCount); + Vector u_initial(fineVertexCount); u_initial = 0.0; { - LinearFactoryType displacementFactory(parset.sub("solver.tnnmg"), // FIXME - refinements, *grid, - displacementDirichletNodes); + LinearFactory displacementFactory(parset.sub("solver.tnnmg"), // FIXME + refinements, *grid, + displacementDirichletNodes); auto multigridStep = displacementFactory.getSolver(); - typename LinearFactoryType::ConvexProblemType convexProblem( + typename LinearFactory::ConvexProblem convexProblem( 1.0, A, zeroNonlinearity, ell, u_initial); - typename LinearFactoryType::BlockProblemType initialDisplacementProblem( + typename LinearFactory::BlockProblem initialDisplacementProblem( parset, convexProblem); auto const &localParset = parset.sub("u0.solver"); multigridStep->setProblem(u_initial, initialDisplacementProblem); - LoopSolver<VectorType> initialDisplacementProblemSolver( + LoopSolver<Vector> initialDisplacementProblemSolver( multigridStep, localParset.get<size_t>("maximumIterations"), localParset.get<double>("tolerance"), &ANorm, localParset.get<Solver::VerbosityMode>("verbosity"), @@ -387,7 +378,7 @@ int main(int argc, char *argv[]) { initialDisplacementProblemSolver.preprocess(); initialDisplacementProblemSolver.solve(); } - VectorType v_initial(fineVertexCount); + Vector v_initial(fineVertexCount); v_initial = 0.0; { // Prescribe a homogeneous velocity field in the x-direction @@ -398,13 +389,13 @@ int main(int argc, char *argv[]) { for (auto &x : v_initial) x[0] = v_initial_const; } - VectorType a_initial(fineVertexCount); + Vector a_initial(fineVertexCount); a_initial = 0.0; { /* We solve Au + Cv + Ma + Psi(v) = ell, thus Ma = - (Au + Cv + Psi(v) - ell) */ - VectorType accelerationRHS(fineVertexCount); + Vector accelerationRHS(fineVertexCount); { accelerationRHS = 0.0; Arithmetic::addProduct(accelerationRHS, A, u_initial); @@ -415,19 +406,19 @@ int main(int argc, char *argv[]) { accelerationRHS -= ell; accelerationRHS *= -1.0; } - LinearFactoryType accelerationFactory(parset.sub("solver.tnnmg"), // FIXME - refinements, *grid, - accelerationDirichletNodes); + LinearFactory accelerationFactory(parset.sub("solver.tnnmg"), // FIXME + refinements, *grid, + accelerationDirichletNodes); auto multigridStep = accelerationFactory.getSolver(); - typename LinearFactoryType::ConvexProblemType convexProblem( + typename LinearFactory::ConvexProblem convexProblem( 1.0, M, zeroNonlinearity, accelerationRHS, a_initial); - typename LinearFactoryType::BlockProblemType initialAccelerationProblem( + typename LinearFactory::BlockProblem initialAccelerationProblem( parset, convexProblem); auto const &localParset = parset.sub("a0.solver"); multigridStep->setProblem(a_initial, initialAccelerationProblem); - LoopSolver<VectorType> initialAccelerationProblemSolver( + LoopSolver<Vector> initialAccelerationProblemSolver( multigridStep, localParset.get<size_t>("maximumIterations"), localParset.get<double>("tolerance"), &MNorm, localParset.get<Solver::VerbosityMode>("verbosity"), @@ -441,13 +432,12 @@ int main(int argc, char *argv[]) { writer.writeInfo(alpha_initial, u_initial, v_initial); // Set up TNNMG solver - using NonlinearFactoryType = SolverFactory< - dims, - MyBlockProblem<ConvexProblem< - Dune::GlobalNonlinearity<MatrixType, VectorType>, MatrixType>>, - GridType>; - NonlinearFactoryType factory(parset.sub("solver.tnnmg"), refinements, *grid, - velocityDirichletNodes); + using NonlinearFactory = SolverFactory< + dims, MyBlockProblem<ConvexProblem< + Dune::GlobalNonlinearity<Matrix, Vector>, Matrix>>, + Grid>; + NonlinearFactory factory(parset.sub("solver.tnnmg"), refinements, *grid, + velocityDirichletNodes); auto multigridStep = factory.getSolver(); { @@ -464,12 +454,12 @@ int main(int argc, char *argv[]) { initTimeStepper(parset.get<Config::scheme>("timeSteps.scheme"), velocityDirichletFunction, velocityDirichletNodes, M, A, C, u_initial, v_initial, a_initial); - auto stateUpdater = initStateUpdater<SingletonVectorType, VectorType>( + auto stateUpdater = initStateUpdater<SingletonVector, Vector>( parset.get<Config::stateModel>("boundary.friction.stateModel"), alpha_initial, frictionalNodes, frictionData); - VectorType v = v_initial; - SingletonVectorType alpha(fineVertexCount); + Vector v = v_initial; + SingletonVector alpha(fineVertexCount); auto const timesteps = parset.get<size_t>("timeSteps.number"), maximumStateFPI = parset.get<size_t>("v.fpi.maximumIterations"), @@ -494,29 +484,29 @@ int main(int argc, char *argv[]) { auto const relativeTime = double(run) / double(timesteps); createRHS(relativeTime, ell); - MatrixType velocityMatrix; - VectorType velocityRHS(fineVertexCount); - VectorType velocityIterate(fineVertexCount); + Matrix velocityMatrix; + Vector velocityRHS(fineVertexCount); + Vector velocityIterate(fineVertexCount); stateUpdater->setup(tau); timeSteppingScheme->setup(ell, tau, relativeTime, velocityRHS, velocityIterate, velocityMatrix); - LoopSolver<VectorType> velocityProblemSolver( - multigridStep, maximumIterations, tolerance, &AMNorm, verbosity, - false); // absolute error + LoopSolver<Vector> velocityProblemSolver(multigridStep, maximumIterations, + tolerance, &AMNorm, verbosity, + false); // absolute error size_t iterationCounter; - auto solveVelocityProblem = [&](VectorType &_velocityIterate, - SingletonVectorType const &_alpha) { + auto solveVelocityProblem = [&](Vector &_velocityIterate, + SingletonVector const &_alpha) { myGlobalNonlinearity->updateLogState(_alpha); // NIT: Do we really need to pass u here? - typename NonlinearFactoryType::ConvexProblemType const convexProblem( + typename NonlinearFactory::ConvexProblem const convexProblem( 1.0, velocityMatrix, *myGlobalNonlinearity, velocityRHS, _velocityIterate); - typename NonlinearFactoryType::BlockProblemType velocityProblem( - parset, convexProblem); + typename NonlinearFactory::BlockProblem velocityProblem(parset, + convexProblem); multigridStep->setProblem(_velocityIterate, velocityProblem); velocityProblemSolver.preprocess(); @@ -527,9 +517,9 @@ int main(int argc, char *argv[]) { // Since the velocity explodes in the quasistatic case, use the // displacement as a convergence criterion // Q: is this reasonable? - VectorType u; - VectorType u_saved; - SingletonVectorType alpha_saved; + Vector u; + Vector u_saved; + SingletonVector alpha_saved; double lastStateCorrection; for (size_t stateFPI = 1; stateFPI <= maximumStateFPI; ++stateFPI) { stateUpdater->solve(v); @@ -580,10 +570,10 @@ int main(int argc, char *argv[]) { if (parset.get<bool>("io.writeVTK")) { auto const gridDisplacement = - Dune::make_shared<BasisGridFunction<P1Basis, VectorType> const>( - p1Basis, u); - SingletonVectorType vonMisesStress; - VonMisesStressAssembler<GridType, P0Basis::LocalFiniteElement> + Dune::make_shared<BasisGridFunction<P1Basis, Vector> const>(p1Basis, + u); + SingletonVector vonMisesStress; + VonMisesStressAssembler<Grid, P0Basis::LocalFiniteElement> localStressAssembler(E, nu, gridDisplacement); p0Assembler.assembleFunctional(localStressAssembler, vonMisesStress); diff --git a/src/solverfactory.cc b/src/solverfactory.cc index c428aa057d95a4e5596f44e03d1be224b441ebfa..dc0be6cfee21cfaec20d4f672a306260ae3d89b0 100644 --- a/src/solverfactory.cc +++ b/src/solverfactory.cc @@ -11,9 +11,9 @@ #include "solverfactory.hh" -template <size_t dim, class BlockProblemType, class GridType> -SolverFactory<dim, BlockProblemType, GridType>::SolverFactory( - Dune::ParameterTree const &parset, size_t refinements, GridType const &grid, +template <size_t dim, class BlockProblem, class Grid> +SolverFactory<dim, BlockProblem, Grid>::SolverFactory( + Dune::ParameterTree const &parset, size_t refinements, Grid const &grid, Dune::BitSetVector<dim> const &ignoreNodes) : baseEnergyNorm(linearBaseSolverStep), linearBaseSolver(&linearBaseSolverStep, @@ -21,7 +21,7 @@ SolverFactory<dim, BlockProblemType, GridType>::SolverFactory( parset.get<double>("linear.tolerance"), &baseEnergyNorm, Solver::QUIET), transferOperators(refinements), - multigridStep(new SolverType(linearIterationStep, nonlinearSmoother)) { + multigridStep(new Solver(linearIterationStep, nonlinearSmoother)) { // linear iteration step linearIterationStep.setMGType(parset.get<int>("linear.cycle"), parset.get<int>("linear.pre"), @@ -31,8 +31,8 @@ SolverFactory<dim, BlockProblemType, GridType>::SolverFactory( // transfer operators for (auto &x : transferOperators) - x = new CompressedMultigridTransfer<VectorType>; - TransferOperatorAssembler<GridType>(grid) + x = new CompressedMultigridTransfer<Vector>; + TransferOperatorAssembler<Grid>(grid) .assembleOperatorPointerHierarchy(transferOperators); linearIterationStep.setTransferOperators(transferOperators); @@ -43,17 +43,16 @@ SolverFactory<dim, BlockProblemType, GridType>::SolverFactory( multigridStep->ignoreNodes_ = &ignoreNodes; } -template <size_t dim, class BlockProblemType, class GridType> -SolverFactory<dim, BlockProblemType, GridType>::~SolverFactory() { +template <size_t dim, class BlockProblem, class Grid> +SolverFactory<dim, BlockProblem, Grid>::~SolverFactory() { for (auto &x : transferOperators) delete x; delete multigridStep; } -template <size_t dim, class BlockProblemType, class GridType> -auto SolverFactory<dim, BlockProblemType, GridType>::getSolver() - -> SolverType *{ +template <size_t dim, class BlockProblem, class Grid> +auto SolverFactory<dim, BlockProblem, Grid>::getSolver() -> Solver *{ return multigridStep; } diff --git a/src/solverfactory.hh b/src/solverfactory.hh index 815ec692173f334f089926dbae50f0654424b18d..75cc3954d1e41fee4a18f80898d931b83d264f76 100644 --- a/src/solverfactory.hh +++ b/src/solverfactory.hh @@ -16,38 +16,37 @@ #include <dune/tnnmg/iterationsteps/genericnonlineargs.hh> #include <dune/tnnmg/iterationsteps/tnnmgstep.hh> -template <size_t dim, class BlockProblemTypeTEMPLATE, class GridType> +template <size_t dim, class BlockProblemTEMPLATE, class Grid> class SolverFactory { public: - using BlockProblemType = BlockProblemTypeTEMPLATE; - using ConvexProblemType = typename BlockProblemType::ConvexProblemType; - using VectorType = typename BlockProblemType::VectorType; - using MatrixType = typename BlockProblemType::MatrixType; + using BlockProblem = BlockProblemTEMPLATE; + using ConvexProblem = typename BlockProblem::ConvexProblemType; + using Vector = typename BlockProblem::VectorType; + using Matrix = typename BlockProblem::MatrixType; private: - using NonlinearSmootherType = GenericNonlinearGS<BlockProblemType>; - using SolverType = TruncatedNonsmoothNewtonMultigrid<BlockProblemType, - NonlinearSmootherType>; + using NonlinearSmoother = GenericNonlinearGS<BlockProblem>; + using Solver = + TruncatedNonsmoothNewtonMultigrid<BlockProblem, NonlinearSmoother>; public: SolverFactory(Dune::ParameterTree const &parset, size_t refinements, - GridType const &grid, - Dune::BitSetVector<dim> const &ignoreNodes); + Grid const &grid, Dune::BitSetVector<dim> const &ignoreNodes); ~SolverFactory(); - SolverType *getSolver(); + Solver *getSolver(); private: - TruncatedBlockGSStep<MatrixType, VectorType> linearBaseSolverStep; - EnergyNorm<MatrixType, VectorType> baseEnergyNorm; - LoopSolver<VectorType> linearBaseSolver; - TruncatedBlockGSStep<MatrixType, VectorType> linearPresmoother; - TruncatedBlockGSStep<MatrixType, VectorType> linearPostsmoother; - MultigridStep<MatrixType, VectorType> linearIterationStep; - std::vector<CompressedMultigridTransfer<VectorType> *> transferOperators; - NonlinearSmootherType nonlinearSmoother; - SolverType *multigridStep; + TruncatedBlockGSStep<Matrix, Vector> linearBaseSolverStep; + EnergyNorm<Matrix, Vector> baseEnergyNorm; + LoopSolver<Vector> linearBaseSolver; + TruncatedBlockGSStep<Matrix, Vector> linearPresmoother; + TruncatedBlockGSStep<Matrix, Vector> linearPostsmoother; + MultigridStep<Matrix, Vector> linearIterationStep; + std::vector<CompressedMultigridTransfer<Vector> *> transferOperators; + NonlinearSmoother nonlinearSmoother; + Solver *multigridStep; }; #endif diff --git a/src/solverfactory_tmpl.cc b/src/solverfactory_tmpl.cc index 4b30b8a9126d1e5a511b426bba83e2a4150b8c8d..5d94c6606eb4878c2762df936a0f597639624bc8 100644 --- a/src/solverfactory_tmpl.cc +++ b/src/solverfactory_tmpl.cc @@ -22,16 +22,16 @@ using SmallVector = Dune::FieldVector<double, DIM>; using SmallMatrix = Dune::FieldMatrix<double, DIM, DIM>; -using VectorType = Dune::BlockVector<SmallVector>; -using MatrixType = Dune::BCRSMatrix<SmallMatrix>; +using Vector = Dune::BlockVector<SmallVector>; +using Matrix = Dune::BCRSMatrix<SmallMatrix>; -using GridType = Dune::ALUGrid<DIM, DIM, Dune::simplex, Dune::nonconforming>; +using Grid = Dune::ALUGrid<DIM, DIM, Dune::simplex, Dune::nonconforming>; template class SolverFactory< - DIM, MyBlockProblem<ConvexProblem< - Dune::GlobalNonlinearity<MatrixType, VectorType>, MatrixType>>, - GridType>; + DIM, MyBlockProblem< + ConvexProblem<Dune::GlobalNonlinearity<Matrix, Vector>, Matrix>>, + Grid>; template class SolverFactory< - DIM, BlockNonlinearTNNMGProblem<ConvexProblem< - ZeroNonlinearity<SmallVector, SmallMatrix>, MatrixType>>, - GridType>; + DIM, BlockNonlinearTNNMGProblem< + ConvexProblem<ZeroNonlinearity<SmallVector, SmallMatrix>, Matrix>>, + Grid>; diff --git a/src/state/dieterichstateupdater.hh b/src/state/dieterichstateupdater.hh index 8b11f77e47bf36e7bddfeb9007b4a8f23c152299..a027dec8cfee3f0ada73bf08c9863e96e9f4a56d 100644 --- a/src/state/dieterichstateupdater.hh +++ b/src/state/dieterichstateupdater.hh @@ -4,46 +4,44 @@ #include "compute_state_dieterich_euler.hh" #include "stateupdater.hh" -template <class SingletonVectorType, class VectorType> -class DieterichStateUpdater - : public StateUpdater<SingletonVectorType, VectorType> { +template <class SingletonVector, class Vector> +class DieterichStateUpdater : public StateUpdater<SingletonVector, Vector> { public: - DieterichStateUpdater(SingletonVectorType _logState_initial, + DieterichStateUpdater(SingletonVector _logState_initial, Dune::BitSetVector<1> const &_nodes, double _L); virtual void nextTimeStep(); virtual void setup(double _tau); - virtual void solve(VectorType const &velocity_field); - virtual void extractLogState(SingletonVectorType &); + virtual void solve(Vector const &velocity_field); + virtual void extractLogState(SingletonVector &); private: - SingletonVectorType logState_o; - SingletonVectorType logState; + SingletonVector logState_o; + SingletonVector logState; Dune::BitSetVector<1> const &nodes; double const L; double tau; }; -template <class SingletonVectorType, class VectorType> -DieterichStateUpdater<SingletonVectorType, VectorType>::DieterichStateUpdater( - SingletonVectorType _logState_initial, Dune::BitSetVector<1> const &_nodes, +template <class SingletonVector, class Vector> +DieterichStateUpdater<SingletonVector, Vector>::DieterichStateUpdater( + SingletonVector _logState_initial, Dune::BitSetVector<1> const &_nodes, double _L) : logState(_logState_initial), nodes(_nodes), L(_L) {} -template <class SingletonVectorType, class VectorType> -void DieterichStateUpdater<SingletonVectorType, VectorType>::nextTimeStep() { +template <class SingletonVector, class Vector> +void DieterichStateUpdater<SingletonVector, Vector>::nextTimeStep() { logState_o = logState; } -template <class SingletonVectorType, class VectorType> -void DieterichStateUpdater<SingletonVectorType, VectorType>::setup( - double _tau) { +template <class SingletonVector, class Vector> +void DieterichStateUpdater<SingletonVector, Vector>::setup(double _tau) { tau = _tau; } -template <class SingletonVectorType, class VectorType> -void DieterichStateUpdater<SingletonVectorType, VectorType>::solve( - VectorType const &velocity_field) { +template <class SingletonVector, class Vector> +void DieterichStateUpdater<SingletonVector, Vector>::solve( + Vector const &velocity_field) { for (size_t i = 0; i < nodes.size(); ++i) if (nodes[i][0]) { double const V = velocity_field[i].two_norm(); @@ -51,9 +49,9 @@ void DieterichStateUpdater<SingletonVectorType, VectorType>::solve( } } -template <class SingletonVectorType, class VectorType> -void DieterichStateUpdater<SingletonVectorType, VectorType>::extractLogState( - SingletonVectorType &_logState) { +template <class SingletonVector, class Vector> +void DieterichStateUpdater<SingletonVector, Vector>::extractLogState( + SingletonVector &_logState) { _logState = logState; } diff --git a/src/state/ruinastateupdater.hh b/src/state/ruinastateupdater.hh index ad4798033ed48d31eca9ca2ec3a7f8cbbf16a97d..da0499e35e07dde4022bdee0574808f9834511c2 100644 --- a/src/state/ruinastateupdater.hh +++ b/src/state/ruinastateupdater.hh @@ -4,44 +4,44 @@ #include "compute_state_ruina.hh" #include "stateupdater.hh" -template <class SingletonVectorType, class VectorType> -class RuinaStateUpdater : public StateUpdater<SingletonVectorType, VectorType> { +template <class SingletonVector, class Vector> +class RuinaStateUpdater : public StateUpdater<SingletonVector, Vector> { public: - RuinaStateUpdater(SingletonVectorType _logState_initial, + RuinaStateUpdater(SingletonVector _logState_initial, Dune::BitSetVector<1> const &_nodes, double _L); virtual void nextTimeStep(); virtual void setup(double _tau); - virtual void solve(VectorType const &velocity_field); - virtual void extractLogState(SingletonVectorType &); + virtual void solve(Vector const &velocity_field); + virtual void extractLogState(SingletonVector &); private: - SingletonVectorType logState_o; - SingletonVectorType logState; + SingletonVector logState_o; + SingletonVector logState; Dune::BitSetVector<1> const &nodes; double const L; double tau; }; -template <class SingletonVectorType, class VectorType> -RuinaStateUpdater<SingletonVectorType, VectorType>::RuinaStateUpdater( - SingletonVectorType _logState_initial, Dune::BitSetVector<1> const &_nodes, +template <class SingletonVector, class Vector> +RuinaStateUpdater<SingletonVector, Vector>::RuinaStateUpdater( + SingletonVector _logState_initial, Dune::BitSetVector<1> const &_nodes, double _L) : logState(_logState_initial), nodes(_nodes), L(_L) {} -template <class SingletonVectorType, class VectorType> -void RuinaStateUpdater<SingletonVectorType, VectorType>::nextTimeStep() { +template <class SingletonVector, class Vector> +void RuinaStateUpdater<SingletonVector, Vector>::nextTimeStep() { logState_o = logState; } -template <class SingletonVectorType, class VectorType> -void RuinaStateUpdater<SingletonVectorType, VectorType>::setup(double _tau) { +template <class SingletonVector, class Vector> +void RuinaStateUpdater<SingletonVector, Vector>::setup(double _tau) { tau = _tau; } -template <class SingletonVectorType, class VectorType> -void RuinaStateUpdater<SingletonVectorType, VectorType>::solve( - VectorType const &velocity_field) { +template <class SingletonVector, class Vector> +void RuinaStateUpdater<SingletonVector, Vector>::solve( + Vector const &velocity_field) { for (size_t i = 0; i < nodes.size(); ++i) if (nodes[i][0]) { double const V = velocity_field[i].two_norm(); @@ -49,9 +49,9 @@ void RuinaStateUpdater<SingletonVectorType, VectorType>::solve( } } -template <class SingletonVectorType, class VectorType> -void RuinaStateUpdater<SingletonVectorType, VectorType>::extractLogState( - SingletonVectorType &_logState) { +template <class SingletonVector, class Vector> +void RuinaStateUpdater<SingletonVector, Vector>::extractLogState( + SingletonVector &_logState) { _logState = logState; } diff --git a/src/state/stateupdater.hh b/src/state/stateupdater.hh index 63522be6ae78be6d082c5e3f0ec594de2c723b20..698b91d3200ed327247cad1fbf5b56e33c34f713 100644 --- a/src/state/stateupdater.hh +++ b/src/state/stateupdater.hh @@ -1,12 +1,12 @@ #ifndef STATE_UPDATER_HH #define STATE_UPDATER_HH -template <class SingletonVectorType, class VectorType> class StateUpdater { +template <class SingletonVector, class Vector> class StateUpdater { public: virtual void nextTimeStep() = 0; virtual void setup(double _tau) = 0; - virtual void solve(VectorType const &velocity_field) = 0; - virtual void extractLogState(SingletonVectorType &logState) = 0; + virtual void solve(Vector const &velocity_field) = 0; + virtual void extractLogState(SingletonVector &logState) = 0; }; #endif diff --git a/src/timestepping.hh b/src/timestepping.hh index 5420aa3a37339834aeaaceada3834e70ea6eba94..adb2ac5b5c02437df01261a65413c5c53414f363 100644 --- a/src/timestepping.hh +++ b/src/timestepping.hh @@ -3,16 +3,16 @@ #include <dune/common/bitsetvector.hh> -template <class VectorType, class MatrixType, class FunctionType, size_t dim> +template <class Vector, class Matrix, class Function, size_t dim> class TimeSteppingScheme { public: void virtual nextTimeStep() = 0; - void virtual setup(VectorType const &ell, double _tau, double relativeTime, - VectorType &rhs, VectorType &iterate, MatrixType &AB) = 0; + void virtual setup(Vector const &ell, double _tau, double relativeTime, + Vector &rhs, Vector &iterate, Matrix &AB) = 0; - void virtual postProcess(VectorType const &iterate) = 0; - void virtual extractDisplacement(VectorType &displacement) const = 0; - void virtual extractVelocity(VectorType &velocity) const = 0; + void virtual postProcess(Vector const &iterate) = 0; + void virtual extractDisplacement(Vector &displacement) const = 0; + void virtual extractVelocity(Vector &velocity) const = 0; }; #include "timestepping/newmark.hh" diff --git a/src/timestepping/backward_euler.cc b/src/timestepping/backward_euler.cc index 288ddb6094f658c54752f90fbf6f322511c74ee3..c31714dfba3f1355c656af12aafdacddd4bdaf17 100644 --- a/src/timestepping/backward_euler.cc +++ b/src/timestepping/backward_euler.cc @@ -1,9 +1,9 @@ -template <class VectorType, class MatrixType, class FunctionType, size_t dim> -BackwardEuler<VectorType, MatrixType, FunctionType, dim>::BackwardEuler( - MatrixType const &_A, MatrixType const &_M, MatrixType const &_C, - VectorType const &_u_initial, VectorType const &_v_initial, +template <class Vector, class Matrix, class Function, size_t dim> +BackwardEuler<Vector, Matrix, Function, dim>::BackwardEuler( + Matrix const &_A, Matrix const &_M, Matrix const &_C, + Vector const &_u_initial, Vector const &_v_initial, Dune::BitSetVector<dim> const &_dirichletNodes, - FunctionType const &_dirichletFunction) + Function const &_dirichletFunction) : A(_A), M(_M), C(_C), @@ -12,16 +12,16 @@ BackwardEuler<VectorType, MatrixType, FunctionType, dim>::BackwardEuler( dirichletNodes(_dirichletNodes), dirichletFunction(_dirichletFunction) {} -template <class VectorType, class MatrixType, class FunctionType, size_t dim> -void BackwardEuler<VectorType, MatrixType, FunctionType, dim>::nextTimeStep() { +template <class Vector, class Matrix, class Function, size_t dim> +void BackwardEuler<Vector, Matrix, Function, dim>::nextTimeStep() { v_o = v; u_o = u; } -template <class VectorType, class MatrixType, class FunctionType, size_t dim> -void BackwardEuler<VectorType, MatrixType, FunctionType, dim>::setup( - VectorType const &ell, double _tau, double relativeTime, VectorType &rhs, - VectorType &iterate, MatrixType &AM) { +template <class Vector, class Matrix, class Function, size_t dim> +void BackwardEuler<Vector, Matrix, Function, dim>::setup( + Vector const &ell, double _tau, double relativeTime, Vector &rhs, + Vector &iterate, Matrix &AM) { postProcessCalled = false; tau = _tau; @@ -93,9 +93,9 @@ void BackwardEuler<VectorType, MatrixType, FunctionType, dim>::setup( } } -template <class VectorType, class MatrixType, class FunctionType, size_t dim> -void BackwardEuler<VectorType, MatrixType, FunctionType, dim>::postProcess( - VectorType const &iterate) { +template <class Vector, class Matrix, class Function, size_t dim> +void BackwardEuler<Vector, Matrix, Function, dim>::postProcess( + Vector const &iterate) { postProcessCalled = true; v = iterate; @@ -104,18 +104,18 @@ void BackwardEuler<VectorType, MatrixType, FunctionType, dim>::postProcess( Arithmetic::addProduct(u, tau, v); } -template <class VectorType, class MatrixType, class FunctionType, size_t dim> -void BackwardEuler<VectorType, MatrixType, FunctionType, - dim>::extractDisplacement(VectorType &displacement) const { +template <class Vector, class Matrix, class Function, size_t dim> +void BackwardEuler<Vector, Matrix, Function, dim>::extractDisplacement( + Vector &displacement) const { if (!postProcessCalled) DUNE_THROW(Dune::Exception, "It seems you forgot to call postProcess!"); displacement = u; } -template <class VectorType, class MatrixType, class FunctionType, size_t dim> -void BackwardEuler<VectorType, MatrixType, FunctionType, dim>::extractVelocity( - VectorType &velocity) const { +template <class Vector, class Matrix, class Function, size_t dim> +void BackwardEuler<Vector, Matrix, Function, dim>::extractVelocity( + Vector &velocity) const { if (!postProcessCalled) DUNE_THROW(Dune::Exception, "It seems you forgot to call postProcess!"); diff --git a/src/timestepping/backward_euler.hh b/src/timestepping/backward_euler.hh index 50d73d0a101b419d2856c9f32baba86f8558ba9f..bb86ef128f08764613eec709917ddad31b74b165 100644 --- a/src/timestepping/backward_euler.hh +++ b/src/timestepping/backward_euler.hh @@ -1,34 +1,32 @@ #ifndef DUNE_TECTONIC_TIMESTEPPING_BACKWARD_EULER_HH #define DUNE_TECTONIC_TIMESTEPPING_BACKWARD_EULER_HH -template <class VectorType, class MatrixType, class FunctionType, size_t dim> -class BackwardEuler - : public TimeSteppingScheme<VectorType, MatrixType, FunctionType, dim> { +template <class Vector, class Matrix, class Function, size_t dim> +class BackwardEuler : public TimeSteppingScheme<Vector, Matrix, Function, dim> { public: - BackwardEuler(MatrixType const &_A, MatrixType const &_M, - MatrixType const &_C, VectorType const &_u_initial, - VectorType const &_v_initial, + BackwardEuler(Matrix const &_A, Matrix const &_M, Matrix const &_C, + Vector const &_u_initial, Vector const &_v_initial, Dune::BitSetVector<dim> const &_dirichletNodes, - FunctionType const &_dirichletFunction); + Function const &_dirichletFunction); void virtual nextTimeStep() override; - void virtual setup(VectorType const &, double, double, VectorType &, - VectorType &, MatrixType &) override; - void virtual postProcess(VectorType const &) override; - void virtual extractDisplacement(VectorType &) const override; - void virtual extractVelocity(VectorType &) const override; + void virtual setup(Vector const &, double, double, Vector &, Vector &, + Matrix &) override; + void virtual postProcess(Vector const &) override; + void virtual extractDisplacement(Vector &) const override; + void virtual extractVelocity(Vector &) const override; private: - MatrixType const &A; - MatrixType const &M; - MatrixType const &C; - VectorType u; - VectorType v; + Matrix const &A; + Matrix const &M; + Matrix const &C; + Vector u; + Vector v; Dune::BitSetVector<dim> const &dirichletNodes; - FunctionType const &dirichletFunction; + Function const &dirichletFunction; - VectorType u_o; - VectorType v_o; + Vector u_o; + Vector v_o; double tau; diff --git a/src/timestepping/newmark.cc b/src/timestepping/newmark.cc index d1ce9f3962aeaacb29cfe5532aeea3bac28ab63b..02be5f6df5bbc62acc0e6758ce442ac7f64cd19b 100644 --- a/src/timestepping/newmark.cc +++ b/src/timestepping/newmark.cc @@ -1,10 +1,9 @@ -template <class VectorType, class MatrixType, class FunctionType, size_t dim> -Newmark<VectorType, MatrixType, FunctionType, dim>::Newmark( - MatrixType const &_A, MatrixType const &_M, MatrixType const &_C, - VectorType const &_u_initial, VectorType const &_v_initial, - VectorType const &_a_initial, - Dune::BitSetVector<dim> const &_dirichletNodes, - FunctionType const &_dirichletFunction) +template <class Vector, class Matrix, class Function, size_t dim> +Newmark<Vector, Matrix, Function, dim>::Newmark( + Matrix const &_A, Matrix const &_M, Matrix const &_C, + Vector const &_u_initial, Vector const &_v_initial, + Vector const &_a_initial, Dune::BitSetVector<dim> const &_dirichletNodes, + Function const &_dirichletFunction) : A(_A), M(_M), C(_C), @@ -14,17 +13,19 @@ Newmark<VectorType, MatrixType, FunctionType, dim>::Newmark( dirichletNodes(_dirichletNodes), dirichletFunction(_dirichletFunction) {} -template <class VectorType, class MatrixType, class FunctionType, size_t dim> -void Newmark<VectorType, MatrixType, FunctionType, dim>::nextTimeStep() { +template <class Vector, class Matrix, class Function, size_t dim> +void Newmark<Vector, Matrix, Function, dim>::nextTimeStep() { a_o = a; v_o = v; u_o = u; } -template <class VectorType, class MatrixType, class FunctionType, size_t dim> -void Newmark<VectorType, MatrixType, FunctionType, dim>::setup( - VectorType const &ell, double _tau, double relativeTime, VectorType &rhs, - VectorType &iterate, MatrixType &AM) { +template <class Vector, class Matrix, class Function, size_t dim> +void Newmark<Vector, Matrix, Function, dim>::setup(Vector const &ell, + double _tau, + double relativeTime, + Vector &rhs, Vector &iterate, + Matrix &AM) { postProcessCalled = false; tau = _tau; @@ -99,9 +100,9 @@ void Newmark<VectorType, MatrixType, FunctionType, dim>::setup( } } -template <class VectorType, class MatrixType, class FunctionType, size_t dim> -void Newmark<VectorType, MatrixType, FunctionType, dim>::postProcess( - VectorType const &iterate) { +template <class Vector, class Matrix, class Function, size_t dim> +void Newmark<Vector, Matrix, Function, dim>::postProcess( + Vector const &iterate) { postProcessCalled = true; v = iterate; @@ -118,18 +119,18 @@ void Newmark<VectorType, MatrixType, FunctionType, dim>::postProcess( Arithmetic::subtractProduct(a, 1.0, a_o); } -template <class VectorType, class MatrixType, class FunctionType, size_t dim> -void Newmark<VectorType, MatrixType, FunctionType, dim>::extractDisplacement( - VectorType &displacement) const { +template <class Vector, class Matrix, class Function, size_t dim> +void Newmark<Vector, Matrix, Function, dim>::extractDisplacement( + Vector &displacement) const { if (!postProcessCalled) DUNE_THROW(Dune::Exception, "It seems you forgot to call postProcess!"); displacement = u; } -template <class VectorType, class MatrixType, class FunctionType, size_t dim> -void Newmark<VectorType, MatrixType, FunctionType, dim>::extractVelocity( - VectorType &velocity) const { +template <class Vector, class Matrix, class Function, size_t dim> +void Newmark<Vector, Matrix, Function, dim>::extractVelocity(Vector &velocity) + const { if (!postProcessCalled) DUNE_THROW(Dune::Exception, "It seems you forgot to call postProcess!"); diff --git a/src/timestepping/newmark.hh b/src/timestepping/newmark.hh index ce00de305a579a4fc36256e28e5cb861f9210171..93d888bee72be9aeb859fbeef9c53d9f5c865ff1 100644 --- a/src/timestepping/newmark.hh +++ b/src/timestepping/newmark.hh @@ -1,36 +1,35 @@ #ifndef DUNE_TECTONIC_TIMESTEPPING_NEWMARK_HH #define DUNE_TECTONIC_TIMESTEPPING_NEWMARK_HH -template <class VectorType, class MatrixType, class FunctionType, size_t dim> -class Newmark - : public TimeSteppingScheme<VectorType, MatrixType, FunctionType, dim> { +template <class Vector, class Matrix, class Function, size_t dim> +class Newmark : public TimeSteppingScheme<Vector, Matrix, Function, dim> { public: - Newmark(MatrixType const &_A, MatrixType const &_M, MatrixType const &_C, - VectorType const &_u_initial, VectorType const &_v_initial, - VectorType const &_a_initial, + Newmark(Matrix const &_A, Matrix const &_M, Matrix const &_C, + Vector const &_u_initial, Vector const &_v_initial, + Vector const &_a_initial, Dune::BitSetVector<dim> const &_dirichletNodes, - FunctionType const &_dirichletFunction); + Function const &_dirichletFunction); void virtual nextTimeStep() override; - void virtual setup(VectorType const &, double, double, VectorType &, - VectorType &, MatrixType &) override; - void virtual postProcess(VectorType const &) override; - void virtual extractDisplacement(VectorType &) const override; - void virtual extractVelocity(VectorType &) const override; + void virtual setup(Vector const &, double, double, Vector &, Vector &, + Matrix &) override; + void virtual postProcess(Vector const &) override; + void virtual extractDisplacement(Vector &) const override; + void virtual extractVelocity(Vector &) const override; private: - MatrixType const &A; - MatrixType const &M; - MatrixType const &C; - VectorType u; - VectorType v; - VectorType a; + Matrix const &A; + Matrix const &M; + Matrix const &C; + Vector u; + Vector v; + Vector a; Dune::BitSetVector<dim> const &dirichletNodes; - FunctionType const &dirichletFunction; + Function const &dirichletFunction; - VectorType u_o; - VectorType v_o; - VectorType a_o; + Vector u_o; + Vector v_o; + Vector a_o; double tau; diff --git a/src/timestepping_tmpl.cc b/src/timestepping_tmpl.cc index 9a8a2a3d6215b6984a691c6a410f9367347e5ff5..ce3dad02ae15526639f6ab17c25a47535e76541a 100644 --- a/src/timestepping_tmpl.cc +++ b/src/timestepping_tmpl.cc @@ -10,9 +10,9 @@ using SmallVector = Dune::FieldVector<double, DIM>; using SmallMatrix = Dune::FieldMatrix<double, DIM, DIM>; -using MatrixType = Dune::BCRSMatrix<SmallMatrix>; -using VectorType = Dune::BlockVector<SmallVector>; -using FunctionType = Dune::VirtualFunction<double, double>; +using Matrix = Dune::BCRSMatrix<SmallMatrix>; +using Vector = Dune::BlockVector<SmallVector>; +using Function = Dune::VirtualFunction<double, double>; -template class Newmark<VectorType, MatrixType, FunctionType, DIM>; -template class BackwardEuler<VectorType, MatrixType, FunctionType, DIM>; +template class Newmark<Vector, Matrix, Function, DIM>; +template class BackwardEuler<Vector, Matrix, Function, DIM>; diff --git a/src/vtk.cc b/src/vtk.cc index 2b4a8ab21a2948ae727ec5df7a342b7b8fbd2e65..373144046877c8ebe4f834eae233fca6d5f9e115 100644 --- a/src/vtk.cc +++ b/src/vtk.cc @@ -4,27 +4,27 @@ #include "vtk.hh" -template <class VertexBasis, class CellBasis, class VectorType, - class SingletonVectorType> -void writeVtk(VertexBasis const &vertexBasis, VectorType const &displacement, - SingletonVectorType const &logState, CellBasis const &cellBasis, - SingletonVectorType const &stress, std::string const &filename) { +template <class VertexBasis, class CellBasis, class Vector, + class SingletonVector> +void writeVtk(VertexBasis const &vertexBasis, Vector const &displacement, + SingletonVector const &logState, CellBasis const &cellBasis, + SingletonVector const &stress, std::string const &filename) { Dune::VTKWriter<typename VertexBasis::GridView> writer( vertexBasis.getGridView()); auto const displacementPointer = - Dune::make_shared<VTKBasisGridFunction<VertexBasis, VectorType> const>( + Dune::make_shared<VTKBasisGridFunction<VertexBasis, Vector> const>( vertexBasis, displacement, "displacement"); writer.addVertexData(displacementPointer); auto const logStatePointer = Dune::make_shared< - VTKBasisGridFunction<VertexBasis, SingletonVectorType> const>( + VTKBasisGridFunction<VertexBasis, SingletonVector> const>( vertexBasis, logState, "logState"); writer.addVertexData(logStatePointer); - auto const vonmisesPointer = Dune::make_shared< - VTKBasisGridFunction<CellBasis, SingletonVectorType> const>( - cellBasis, stress, "stress"); + auto const vonmisesPointer = + Dune::make_shared<VTKBasisGridFunction<CellBasis, SingletonVector> const>( + cellBasis, stress, "stress"); writer.addCellData(vonmisesPointer); writer.write(filename.c_str()); diff --git a/src/vtk.hh b/src/vtk.hh index e8ed641f31e8504c7a32617bf02e79877bb8629c..0ce10061815b7d92913151f8cd9ae9b9050fce39 100644 --- a/src/vtk.hh +++ b/src/vtk.hh @@ -6,10 +6,10 @@ #include <dune/fufem/functions/vtkbasisgridfunction.hh> -template <class VertexBasis, class CellBasis, class VectorType, - class SingletonVectorType> -void writeVtk(VertexBasis const &vertexBasis, VectorType const &displacement, - SingletonVectorType const &logState, CellBasis const &cellBasis, - SingletonVectorType const &stress, std::string const &filename); +template <class VertexBasis, class CellBasis, class Vector, + class SingletonVector> +void writeVtk(VertexBasis const &vertexBasis, Vector const &displacement, + SingletonVector const &logState, CellBasis const &cellBasis, + SingletonVector const &stress, std::string const &filename); #endif diff --git a/src/vtk_tmpl.cc b/src/vtk_tmpl.cc index 916c905348fa0cefec3b9b237c4c6780c5a18a7d..1eceed7443fba7b4b357d269334af24bd30a3f48 100644 --- a/src/vtk_tmpl.cc +++ b/src/vtk_tmpl.cc @@ -15,18 +15,18 @@ #include <dune/fufem/functionspacebases/p0basis.hh> #include <dune/fufem/functionspacebases/p1nodalbasis.hh> -using SingletonVectorType = Dune::BlockVector<Dune::FieldVector<double, 1>>; +using SingletonVector = Dune::BlockVector<Dune::FieldVector<double, 1>>; using SmallVector = Dune::FieldVector<double, DIM>; using SmallMatrix = Dune::FieldMatrix<double, DIM, DIM>; -using VectorType = Dune::BlockVector<SmallVector>; +using Vector = Dune::BlockVector<SmallVector>; -using GridType = Dune::ALUGrid<DIM, DIM, Dune::simplex, Dune::nonconforming>; -using GridView = GridType::LeafGridView; +using Grid = Dune::ALUGrid<DIM, DIM, Dune::simplex, Dune::nonconforming>; +using GridView = Grid::LeafGridView; using P1Basis = P1NodalBasis<GridView, double>; using MyP0Basis = P0Basis<GridView, double>; -template void writeVtk<P1Basis, MyP0Basis, VectorType, SingletonVectorType>( - P1Basis const &vertexBasis, VectorType const &displacement, - SingletonVectorType const &logState, MyP0Basis const &cellBasis, - SingletonVectorType const &stress, std::string const &filename); +template void writeVtk<P1Basis, MyP0Basis, Vector, SingletonVector>( + P1Basis const &vertexBasis, Vector const &displacement, + SingletonVector const &logState, MyP0Basis const &cellBasis, + SingletonVector const &stress, std::string const &filename);