diff --git a/examples/navier_stokes.cc b/examples/navier_stokes.cc index 4735e5f3fcbb2b495341be394463c56677db9ad6..86fea59d461bd00da837149013b15258a36b794f 100644 --- a/examples/navier_stokes.cc +++ b/examples/navier_stokes.cc @@ -7,17 +7,21 @@ using namespace AMDiS; -using Grid = Dune::YaspGrid<2>; -using Basis = TaylorHoodBasis; +struct NavierStokesBasis +{ + using Grid = Dune::YaspGrid; + using GlobalBasis = typename TaylorHoodBasis::GlobalBasis; + using CoefficientType = double; +}; int main(int argc, char** argv) { AMDiS::init(argc, argv); - ProblemStat prob("stokes"); + ProblemStat prob("stokes"); prob.initialize(INIT_ALL); - ProblemInstat probInstat("stokes", prob); + ProblemInstat probInstat("stokes", prob); probInstat.initialize(INIT_UH_OLD); double viscosity = 1.0; diff --git a/src/amdis/Assembler.hpp b/src/amdis/Assembler.hpp index 59d521695cbce90acacd93b6b22ae2d2dea681ae..dad37e90430b380cdca1867ba025156edec714b9 100644 --- a/src/amdis/Assembler.hpp +++ b/src/amdis/Assembler.hpp @@ -16,19 +16,18 @@ namespace AMDiS { /// Implementation of interface \ref AssemblerBase /** - * \tparam LC LocalContext + * \tparam Traits See \ref DefaultAssemblerTraits **/ - template + template class Assembler - : public AssemblerInterface + : public AssemblerInterface { - using Super = AssemblerInterface; - - private: + using Super = AssemblerInterface; + using LocalContext = typename Traits::LocalContext; using Element = typename Super::Element; using Geometry = typename Super::Geometry; - using ElementMatrixVector = typename Super::ElementMatrixVector; + using ElementContainer = typename Traits::ElementContainer; public: @@ -77,11 +76,11 @@ namespace AMDiS * \ref calculateElementVector or \ref calculateElementMatrix on the * vector or matrix operator, respectively. **/ - void assemble(LC const& localContext, Nodes const&... nodes, - ElementMatrixVector& elementMatrixVector) final + void assemble(LocalContext const& localContext, Nodes const&... nodes, + ElementContainer& ElementContainer) final { - ContextGeometry contextGeo{localContext, element(), geometry()}; - assembleImpl(contextGeo, nodes..., elementMatrixVector); + ContextGeometry contextGeo{localContext, element(), geometry()}; + assembleImpl(contextGeo, nodes..., ElementContainer); } @@ -133,10 +132,10 @@ namespace AMDiS /// Generate a \ref Assembler on a given LocalContext `LC` (element or intersection) - template + template auto makeAssembler(Operator&& op, Nodes const&...) { - return Assembler, Nodes...>{FWD(op)}; + return Assembler, Nodes...>{FWD(op)}; } } // end namespace AMDiS diff --git a/src/amdis/AssemblerInterface.hpp b/src/amdis/AssemblerInterface.hpp index 68e9b5d289c1732cbaeaaceaa3b41fb77fd3eb5d..5cfee9affb986feddc078d5ccc4d84edd221dd4f 100644 --- a/src/amdis/AssemblerInterface.hpp +++ b/src/amdis/AssemblerInterface.hpp @@ -9,10 +9,18 @@ namespace AMDiS { + template + struct DefaultAssemblerTraits + { + using LocalContext = LC; + using ElementContainer = C; + }; + /// Abstract base-class of a \ref Assembler - template + template class AssemblerInterface { + using LocalContext = typename Traits::LocalContext; using ContextType = Impl::ContextTypes; public: @@ -25,14 +33,6 @@ namespace AMDiS static_assert( numNodes == 1 || numNodes == 2, "VectorAssembler gets 1 Node, MatrixAssembler gets 2 Nodes!"); - using ElementMatrix = Dune::DynamicMatrix; // TODO: choose correct value_type - using ElementVector = Dune::DynamicVector; - - /// Either an ElementVector or an ElementMatrix (depending on the number of nodes) - using ElementMatrixVector = std::conditional_t< - (sizeof...(Nodes)==1), ElementVector, std::conditional_t< - (sizeof...(Nodes)==2), ElementMatrix, void>>; - public: /// Virtual destructor virtual ~AssemblerInterface() = default; @@ -44,9 +44,9 @@ namespace AMDiS virtual void unbind() = 0; /// Assemble an element matrix or element vector on the test- (and trial-) function node(s) - virtual void assemble(LocalContext const& localContext, + virtual void assemble(typename Traits::LocalContext const& localContext, Nodes const&... nodes, - ElementMatrixVector& elementMatrixVector) = 0; + typename Traits::ElementContainer& elementMatrixVector) = 0; }; } // end namespace AMDiS diff --git a/src/amdis/DataTransfer.inc.hpp b/src/amdis/DataTransfer.inc.hpp index b6f01e9377ea03d15b7f68806fd13ff409db6e21..bf2efd7834a493243a3665923ff59bc072c814d8 100644 --- a/src/amdis/DataTransfer.inc.hpp +++ b/src/amdis/DataTransfer.inc.hpp @@ -156,7 +156,8 @@ namespace AMDiS // Interpolate from possibly vanishing elements if (mightCoarsen) { auto maxLevel = gv.grid().maxLevel(); - ctype const checkInsideTolerance = std::sqrt(std::numeric_limits::epsilon()); + using std::sqrt; + ctype const checkInsideTolerance = sqrt(std::numeric_limits::epsilon()); for (auto const& e : elements(gv)) { auto father = e; diff --git a/src/amdis/Mesh.hpp b/src/amdis/Mesh.hpp index 1d1d0948b1e7397d733682770188af35741a7bea..be361b7392f7b0e49fce52da89bf93473e1aad39 100644 --- a/src/amdis/Mesh.hpp +++ b/src/amdis/Mesh.hpp @@ -141,7 +141,7 @@ namespace AMDiS static std::unique_ptr create(std::string const& meshName) { - Dune::FieldVector L; L = 1.0; // extension of the domain + Dune::FieldVector L; L = 1.0; // extension of the domain Parameters::get(meshName + "->dimension", L); auto s = Dune::filledArray(1); // number of cells on coarse mesh in each direction @@ -161,8 +161,8 @@ namespace AMDiS static std::unique_ptr create(std::string const& meshName) { - Dune::FieldVector lowerleft; lowerleft = 0.0; // Lower left corner of the domain - Dune::FieldVector upperright; upperright = 1.0; // Upper right corner of the domain + Dune::FieldVector lowerleft; lowerleft = 0.0; // Lower left corner of the domain + Dune::FieldVector upperright; upperright = 1.0; // Upper right corner of the domain Parameters::get(meshName + "->min corner", lowerleft); Parameters::get(meshName + "->max corner", upperright); diff --git a/src/amdis/OperatorList.hpp b/src/amdis/OperatorList.hpp index bf780920a3f2a977174ec7d84725a187fda0d532..929634127dcc9c496d13e7508f5351aae4b187ba 100644 --- a/src/amdis/OperatorList.hpp +++ b/src/amdis/OperatorList.hpp @@ -20,7 +20,7 @@ namespace AMDiS }; } - template + template class OperatorLists { using Element = typename GridView::template Codim<0>::Entity; @@ -102,11 +102,14 @@ namespace AMDiS auto const& onBoundary() const { return boundary_; } private: + using ElementTraits = DefaultAssemblerTraits; + using IntersectionTraits = DefaultAssemblerTraits; + /// The type of local operators associated with grid elements - using ElementAssembler = AssemblerInterface; + using ElementAssembler = AssemblerInterface; /// The type of local operators associated with grid intersections - using IntersectionAssembler = AssemblerInterface; + using IntersectionAssembler = AssemblerInterface; /// List of operators to be assembled on grid elements std::vector> element_; @@ -136,12 +139,12 @@ namespace AMDiS }; - template + template using MatrixOperators - = MatrixData::template MatData>; + = MatrixData::template MatData>; - template + template using VectorOperators - = VectorData::template VecData>; + = VectorData::template VecData>; } // end namespace AMDiS diff --git a/src/amdis/PeriodicBC.inc.hpp b/src/amdis/PeriodicBC.inc.hpp index 94aa74693cb826dc2c1a8f8cedc85d5c64bad8cd..0c92fecd8ba3fbbe67237bb39c7f1bd59de33d1c 100644 --- a/src/amdis/PeriodicBC.inc.hpp +++ b/src/amdis/PeriodicBC.inc.hpp @@ -43,7 +43,8 @@ template void PeriodicBC:: initAssociations(Basis const& basis) { - static const double tol = std::sqrt(std::numeric_limits::epsilon()); + using std::sqrt; + static const auto tol = sqrt(std::numeric_limits::epsilon()); periodicNodes_.clear(); periodicNodes_.resize(basis.dimension(), false); @@ -107,8 +108,9 @@ namespace Impl bool operator()(D const& lhs, D const& rhs) const { + using std::abs; for (int i = 0; i < D::dimension; i++) { - if (std::abs(lhs[i] - rhs[i]) < tol_) + if (abs(lhs[i] - rhs[i]) < tol_) continue; return lhs[i] < rhs[i]; } @@ -127,7 +129,8 @@ template void PeriodicBC:: initAssociations2(Basis const& basis) { - static const double tol = std::sqrt(std::numeric_limits::epsilon()); + using std::sqrt; + static const auto tol = sqrt(std::numeric_limits::epsilon()); periodicNodes_.clear(); periodicNodes_.resize(basis.dimension(), false); diff --git a/src/amdis/ProblemStat.hpp b/src/amdis/ProblemStat.hpp index 97046397ba315ccdddc8a42294718ec9ef0e5c4c..35cea992b5fd4f2ab7f801e3402f835409ee219c 100644 --- a/src/amdis/ProblemStat.hpp +++ b/src/amdis/ProblemStat.hpp @@ -70,8 +70,8 @@ namespace AMDiS /// Dimension of the world static constexpr int dow = Grid::dimensionworld; - using SystemMatrix = DOFMatrix; - using SystemVector = DOFVector; + using SystemMatrix = DOFMatrix; + using SystemVector = DOFVector; using LinearSolverType = LinearSolverInterface; diff --git a/src/amdis/ProblemStatTraits.hpp b/src/amdis/ProblemStatTraits.hpp index 0be129b51b7e447dfcc5b3733ed6860783f60ec4..6bd0c49b0cc0d38d372f1c9471103e055790fd8d 100644 --- a/src/amdis/ProblemStatTraits.hpp +++ b/src/amdis/ProblemStatTraits.hpp @@ -64,7 +64,7 @@ namespace AMDiS }; - template + template struct DefaultBasisCreator { using GridView = typename Grid::LeafGridView; @@ -75,6 +75,7 @@ namespace AMDiS } using GlobalBasis = decltype(create(std::declval())); + using CoefficientType = T; }; /// \brief ProblemStatTraits for a (composite) basis composed of diff --git a/src/amdis/gridfunctions/DiscreteFunction.hpp b/src/amdis/gridfunctions/DiscreteFunction.hpp index 3a367a3a94d95b925a7de0db9c9d721753c43fac..9323112d25ea27f1dc52351974dba3a373d14c1c 100644 --- a/src/amdis/gridfunctions/DiscreteFunction.hpp +++ b/src/amdis/gridfunctions/DiscreteFunction.hpp @@ -32,7 +32,7 @@ namespace AMDiS template class DiscreteFunction { - static_assert(std::is_arithmetic::value, ""); + // static_assert(Dune::IsNumber::value, ""); private: using GlobalBasis = GB; diff --git a/src/amdis/linearalgebra/DOFMatrixBase.hpp b/src/amdis/linearalgebra/DOFMatrixBase.hpp index 213759edfdd00d6a8c02c47a5f7d3dda79e87581..a197930c5cc0b91ca437e4e24bb4cc46f76317c7 100644 --- a/src/amdis/linearalgebra/DOFMatrixBase.hpp +++ b/src/amdis/linearalgebra/DOFMatrixBase.hpp @@ -37,12 +37,13 @@ namespace AMDiS /// The index/size - type using size_type = typename RowBasis::size_type; + using value_type = typename Backend::value_type; /// The type of the data matrix used in the backend using BaseMatrix = typename Backend::BaseMatrix; /// The type of the matrix filled on an element with local contributions - using ElementMatrix = Dune::DynamicMatrix; + using ElementMatrix = Dune::DynamicMatrix; public: /// Constructor. Stores the shared_ptr to the bases. @@ -166,7 +167,7 @@ namespace AMDiS ElementMatrix elementMatrix_; /// List of operators associated to row/col node - MatrixOperators operators_; + MatrixOperators operators_; }; } // end namespace AMDiS diff --git a/src/amdis/linearalgebra/DOFMatrixBase.inc.hpp b/src/amdis/linearalgebra/DOFMatrixBase.inc.hpp index f06bbde64f2d68fc52042ece6d62ebc0fe93e57e..e37a52c2ab05d68aa35c0eaa7df22121c1895e0f 100644 --- a/src/amdis/linearalgebra/DOFMatrixBase.inc.hpp +++ b/src/amdis/linearalgebra/DOFMatrixBase.inc.hpp @@ -32,10 +32,11 @@ void DOFMatrixBase:: insert(RowLocalView const& rowLocalView, ColLocalView const& colLocalView, ElementMatrix const& elementMatrix) { + using std::abs; for (size_type i = 0; i < rowLocalView.size(); ++i) { size_type const row = flatMultiIndex(rowLocalView.index(i)); for (size_type j = 0; j < colLocalView.size(); ++j) { - if (std::abs(elementMatrix[i][j]) > threshold) { + if (abs(elementMatrix[i][j]) > threshold) { size_type const col = flatMultiIndex(colLocalView.index(j)); backend_.insert(row, col, elementMatrix[i][j]); } @@ -59,8 +60,9 @@ addOperator(ContextTag contextTag, Expr const& expr, auto j = child(colBasis_->localView().tree(), makeTreePath(col)); using LocalContext = typename ContextTag::type; + using Traits = DefaultAssemblerTraits; auto op = makeLocalOperator(expr, rowBasis_->gridView()); - auto localAssembler = makeUniquePtr(makeAssembler(std::move(op), i, j)); + auto localAssembler = makeUniquePtr(makeAssembler(std::move(op), i, j)); operators_[i][j].push(contextTag, std::move(localAssembler)); } diff --git a/src/amdis/linearalgebra/DOFVectorBase.hpp b/src/amdis/linearalgebra/DOFVectorBase.hpp index 62603d6617af9fa050ce1ef79d7965c9bd265b45..9f17f9aa9f3462b6183656ced9dd57aa81e23d44 100644 --- a/src/amdis/linearalgebra/DOFVectorBase.hpp +++ b/src/amdis/linearalgebra/DOFVectorBase.hpp @@ -73,7 +73,7 @@ namespace AMDiS using BaseVector = typename Backend::BaseVector; /// The type of the vector filled on an element with local contributions - using ElementVector = Dune::DynamicVector; + using ElementVector = Dune::DynamicVector; /// Defines an interface to transfer the data during grid adaption using DataTransfer = DataTransferInterface; @@ -290,7 +290,7 @@ namespace AMDiS ElementVector elementVector_; /// List of operators associated to nodes, filled in \ref addOperator(). - VectorOperators operators_; + VectorOperators operators_; /// Data interpolation when the grid changes, set by default /// to \ref DataTransferOperation::INTERPOLATE. diff --git a/src/amdis/linearalgebra/DOFVectorBase.inc.hpp b/src/amdis/linearalgebra/DOFVectorBase.inc.hpp index 4795c768f9f58a9579096d41a0dc40514dbcd3eb..783eb8998bced4271c82a18f3414245b6481a838 100644 --- a/src/amdis/linearalgebra/DOFVectorBase.inc.hpp +++ b/src/amdis/linearalgebra/DOFVectorBase.inc.hpp @@ -30,8 +30,9 @@ template void DOFVectorBase:: insert(LocalView const& localView, ElementVector const& elementVector) { + using std::abs; for (size_type i = 0; i < localView.size(); ++i) { - if (std::abs(elementVector[i]) > threshold) { + if (abs(elementVector[i]) > threshold) { size_type const idx = flatMultiIndex(localView.index(i)); backend_[idx] += elementVector[i]; } @@ -50,8 +51,9 @@ addOperator(ContextTag contextTag, Expr const& expr, TreePath path) auto i = child(basis_->localView().tree(), makeTreePath(path)); using LocalContext = typename ContextTag::type; + using Traits = DefaultAssemblerTraits; auto op = makeLocalOperator(expr, basis_->gridView()); - auto localAssembler = makeUniquePtr(makeAssembler(std::move(op), i)); + auto localAssembler = makeUniquePtr(makeAssembler(std::move(op), i)); operators_[i].push(contextTag, std::move(localAssembler)); } diff --git a/src/amdis/linearalgebra/eigen/DirectRunner.hpp b/src/amdis/linearalgebra/eigen/DirectRunner.hpp index afcfa23453e06223bc329d669ff32dc5ed01c6f4..f37208b9bfb65f29c9c0c586fd5e1e555242e680 100644 --- a/src/amdis/linearalgebra/eigen/DirectRunner.hpp +++ b/src/amdis/linearalgebra/eigen/DirectRunner.hpp @@ -10,23 +10,24 @@ namespace AMDiS { /** - * \ingroup Solver - * \class AMDiS::DirectRunner - * \brief \implements RunnerInterface for the (external) direct solvers - */ - template + * \ingroup Solver + * \class AMDiS::DirectRunner + * \brief \implements RunnerInterface for the (external) direct solvers + */ + template