diff --git a/CMakeLists.txt b/CMakeLists.txt index 2b82162ef1e05e879e09dd312d9e740f5932c174..3d7c107c76da5291b36e01efe51d78da57de464d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,5 +23,10 @@ add_subdirectory("externals") target_link_libraries(amdis fmt) +option(ENABLE_ALL_WARNINGS "enable all meaningful warnings" OFF) +if (ENABLE_ALL_WARNINGS) + target_compile_options(amdis PUBLIC "-Wall" "-Wextra" "-pedantic" "-Wnon-virtual-dtor" "-Wold-style-cast" "-Wcast-align" "-Woverloaded-virtual" "-Wpedantic" "-Wconversion") +endif (ENABLE_ALL_WARNINGS) + # finalize the dune project, e.g. generating config.h etc. finalize_dune_project(GENERATE_CONFIG_H_CMAKE) diff --git a/ProblemIterationInterface.hpp b/ProblemIterationInterface.hpp new file mode 100644 index 0000000000000000000000000000000000000000..b5ebd4b1d5c26527695f2f4badaa0c3a1c665678 --- /dev/null +++ b/ProblemIterationInterface.hpp @@ -0,0 +1,63 @@ +#pragma once + +#include <string> + +#include "Flag.hpp" + +namespace AMDiS +{ + class AdaptInfo; + class ProblemStatBase; + + const Flag BUILD = 1; // Assemble vectors and matrices + const Flag BUILD_RHS = 2; // Assemble rhs vectors only + const Flag ADAPT = 4; // Run adaption procedure + const Flag SOLVE = 8; // Solve system + const Flag SOLVE_RHS = 16; // Solve system, where only rhs vectors have changed + const Flag ESTIMATE = 32; // Estimate error + const Flag MARK = 64; // Mark elements + + const Flag FULL_ITERATION = BUILD | ADAPT | SOLVE | ESTIMATE | MARK; + const Flag NO_ADAPTION = BUILD | SOLVE | ESTIMATE; + + /** \brief + * Interface for master problems needed by the adaption loop. A master problem + * can handle one single or multiple coupled problems. In the latter case, + * the master problem can determine the execution order of the build, solve, + * estimate, and adapt steps of the single problems in \ref oneIteration(). + */ + class ProblemIterationInterface + { + public: + virtual ~ProblemIterationInterface() = default; + + /// Called before each adaption loop iteration. + virtual void beginIteration(AdaptInfo&) { /* by default, do nothing */ } + + /** \brief + * Determines the execution order of the single adaption steps. If adapt is + * true, mesh adaption will be performed. This allows to avoid mesh adaption, + * e.g. in timestep adaption loops of timestep adaptive strategies. + */ + virtual Flag oneIteration(AdaptInfo& adaptInfo, Flag toDo = FULL_ITERATION) = 0; + + /// Called after each adaption loop iteration. + virtual void endIteration(AdaptInfo&) { /* by default, do nothing */ } + + /// Returns number of managed problems + virtual int numProblems() const = 0; + + /** \brief + * Returns the problem with the given number. If only one problem + * is managed by this master problem, the number hasn't to be given. + */ + virtual ProblemStatBase& problem(int number = 0) = 0; + + /// Returns the problem with the given name. + virtual ProblemStatBase& problem(std::string const& name) = 0; + + /// Returns the name of the problem. + virtual std::string const& name() const = 0; + }; + +} // end namespace AMDiS diff --git a/doc/doxygen/Doxylocal b/doc/doxygen/Doxylocal index a96b4da812fa41f9c1f3fc9fd9e31f7397db2eed..73390058f864451c712764aea70c63b025c07ad3 100644 --- a/doc/doxygen/Doxylocal +++ b/doc/doxygen/Doxylocal @@ -32,8 +32,8 @@ INPUT += @top_srcdir@/src/amdis \ @top_srcdir@/src/amdis/common \ @top_srcdir@/src/amdis/gridfunctions \ @top_srcdir@/src/amdis/io \ - @top_srcdir@/src/amdis/linear_algebra \ - @top_srcdir@/src/amdis/linear_algebra/mtl \ + @top_srcdir@/src/amdis/linearalgebra \ + @top_srcdir@/src/amdis/linearalgebra/mtl \ @top_srcdir@/src/amdis/operations \ @top_srcdir@/src/amdis/utility \ @top_srcdir@/doc @@ -45,8 +45,8 @@ INPUT += @top_srcdir@/src/amdis \ # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. -EXCLUDE += @top_srcdir@/src/amdis/linear_algebra/eigen \ - @top_srcdir@/src/amdis/linear_algebra/istl +EXCLUDE += @top_srcdir@/src/amdis/linearalgebra/eigen \ + @top_srcdir@/src/amdis/linearalgebra/istl # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see diff --git a/examples/boundary.cc b/examples/boundary.cc index c6f31b4b990a2e58321357bed1ebafedfb8e90f2..c2fb95ec19ed6617164bc618330ed9f409025140 100644 --- a/examples/boundary.cc +++ b/examples/boundary.cc @@ -10,7 +10,7 @@ #include <amdis/AMDiS.hpp> #include <amdis/Integrate.hpp> #include <amdis/ProblemStat.hpp> -#include <amdis/Operators.hpp> +#include <amdis/LocalOperators.hpp> #include <amdis/common/Literals.hpp> using namespace AMDiS; diff --git a/examples/convection_diffusion.cc b/examples/convection_diffusion.cc index d5e229c380ac77225b2ea34e66ed9c3422eb3ac0..16c2d9395243697352eefced4bf439d0c47b488e 100644 --- a/examples/convection_diffusion.cc +++ b/examples/convection_diffusion.cc @@ -5,7 +5,7 @@ #include <amdis/AMDiS.hpp> #include <amdis/ProblemStat.hpp> -#include <amdis/assembler/ConvectionDiffusionOperator.hpp> +#include <amdis/localoperators/ConvectionDiffusionOperator.hpp> #include <amdis/common/Literals.hpp> using namespace AMDiS; diff --git a/examples/ellipt.cc b/examples/ellipt.cc index 3a19575a81544a55a9df0bf0a81d7baa6ea1a43b..df4cde8153e28285b028b85e7f7b620804574c39 100644 --- a/examples/ellipt.cc +++ b/examples/ellipt.cc @@ -5,8 +5,8 @@ #include <amdis/AMDiS.hpp> #include <amdis/Integrate.hpp> +#include <amdis/LocalOperators.hpp> #include <amdis/ProblemStat.hpp> -#include <amdis/Operators.hpp> #include <amdis/common/Literals.hpp> using namespace AMDiS; diff --git a/examples/heat.cc b/examples/heat.cc index 3f75d4a4aef060e93362662e66bc00d6040c3445..1ab60048517dbe4d3cf49d01450a679cd72a4cef 100644 --- a/examples/heat.cc +++ b/examples/heat.cc @@ -5,9 +5,9 @@ #include <amdis/AMDiS.hpp> #include <amdis/AdaptInstationary.hpp> +#include <amdis/LocalOperators.hpp> #include <amdis/ProblemInstat.hpp> #include <amdis/ProblemStat.hpp> -#include <amdis/Operators.hpp> #include <amdis/GridFunctions.hpp> #include <amdis/common/Literals.hpp> diff --git a/examples/navier_stokes.cc b/examples/navier_stokes.cc index c82e313dcae1a52e3b6bf2502570117695ace2be..5e28b93f263d8f4c60d48a86d886fbfd9d94aef7 100644 --- a/examples/navier_stokes.cc +++ b/examples/navier_stokes.cc @@ -9,10 +9,10 @@ #include <amdis/AMDiS.hpp> #include <amdis/common/FieldMatVec.hpp> #include <amdis/AdaptInstationary.hpp> +#include <amdis/LocalOperators.hpp> #include <amdis/ProblemStat.hpp> #include <amdis/ProblemInstat.hpp> -#include <amdis/Operators.hpp> -#include <amdis/assembler/StokesOperator.hpp> +#include <amdis/localoperators/StokesOperator.hpp> using namespace AMDiS; diff --git a/examples/neumann.cc b/examples/neumann.cc index 65ab4016564cf489f33d0cdedc269b6049737c6f..c94947b8473e2ce3b017220373d3d270bd62db91 100644 --- a/examples/neumann.cc +++ b/examples/neumann.cc @@ -14,7 +14,7 @@ #include <amdis/AMDiS.hpp> #include <amdis/Integrate.hpp> #include <amdis/ProblemStat.hpp> -#include <amdis/Operators.hpp> +#include <amdis/LocalOperators.hpp> #include <amdis/common/Literals.hpp> using namespace AMDiS; diff --git a/examples/periodic.cc b/examples/periodic.cc index f03e0a07637f8910c289b4c9f5f09883d6ff04cd..d1293153a128418645064745f463a03f3eb7dc72 100644 --- a/examples/periodic.cc +++ b/examples/periodic.cc @@ -10,7 +10,7 @@ #include <amdis/AMDiS.hpp> #include <amdis/Integrate.hpp> #include <amdis/ProblemStat.hpp> -#include <amdis/Operators.hpp> +#include <amdis/LocalOperators.hpp> #include <amdis/common/Literals.hpp> using namespace AMDiS; diff --git a/examples/stokes0.cc b/examples/stokes0.cc index 11fe7d2c8cd59208926d1b7fbaa64201d42de9e6..5a5939981ce8559ac617bb14522f33435d91a67f 100644 --- a/examples/stokes0.cc +++ b/examples/stokes0.cc @@ -7,8 +7,8 @@ #include <cmath> #include <amdis/AMDiS.hpp> +#include <amdis/LocalOperators.hpp> #include <amdis/ProblemStat.hpp> -#include <amdis/Operators.hpp> #ifdef DOW #undef DOW diff --git a/examples/stokes1.cc b/examples/stokes1.cc index b07ef3614f0c364c2f5ccb41c579e7a7ae71b40d..af6eac97fa3c5edff423c818b7394bb4659b0ef5 100644 --- a/examples/stokes1.cc +++ b/examples/stokes1.cc @@ -7,8 +7,8 @@ #include <cmath> #include <amdis/AMDiS.hpp> +#include <amdis/LocalOperators.hpp> #include <amdis/ProblemStat.hpp> -#include <amdis/Operators.hpp> #ifdef DOW #undef DOW diff --git a/examples/stokes3.cc b/examples/stokes3.cc index ce338c56c2cc98ee5d39a8755ba7c5ab593a4571..0fe98d45314c1ab84ccb26831a36946e48a8a5f5 100644 --- a/examples/stokes3.cc +++ b/examples/stokes3.cc @@ -7,9 +7,9 @@ #include <cmath> #include <amdis/AMDiS.hpp> +#include <amdis/LocalOperators.hpp> #include <amdis/ProblemStat.hpp> -#include <amdis/Operators.hpp> -#include <amdis/assembler/StokesOperator.hpp> +#include <amdis/localoperators/StokesOperator.hpp> using namespace AMDiS; diff --git a/examples/vecellipt.cc b/examples/vecellipt.cc index 5528712cd3e82c4c8a968912d75d2e334ad8692a..6b81c7f61d6e96ba4d41eb931c8d207b3067e0b2 100644 --- a/examples/vecellipt.cc +++ b/examples/vecellipt.cc @@ -5,8 +5,8 @@ #include <iostream> #include <amdis/AMDiS.hpp> +#include <amdis/LocalOperators.hpp> #include <amdis/ProblemStat.hpp> -#include <amdis/Operators.hpp> using namespace AMDiS; diff --git a/src/amdis/AdaptInfo.hpp b/src/amdis/AdaptInfo.hpp index 72e19008774e0712346faf379e65dd9c5b7ce09d..d233e0b3838a81eddc5eaa6ef685e120a7009e01 100644 --- a/src/amdis/AdaptInfo.hpp +++ b/src/amdis/AdaptInfo.hpp @@ -11,8 +11,7 @@ // AMDiS includes #include <amdis/Output.hpp> #include <amdis/common/ConceptsBase.hpp> -#include <amdis/common/Math.hpp> -#include <amdis/utility/TreePath.hpp> +#include <amdis/typetree/TreePath.hpp> namespace AMDiS { diff --git a/src/amdis/Assembler.hpp b/src/amdis/Assembler.hpp index 9da5ea595c4bade6807d37b712def39adc0c0836..cd1aaa75031e41466960b65e259506b396d73bbf 100644 --- a/src/amdis/Assembler.hpp +++ b/src/amdis/Assembler.hpp @@ -1,85 +1,144 @@ #pragma once +#include <functional> +#include <memory> +#include <type_traits> + +#include <dune/common/shared_ptr.hh> +#include <dune/geometry/quadraturerules.hh> + +#include <amdis/ContextGeometry.hpp> +#include <amdis/AssemblerInterface.hpp> +#include <amdis/common/Concepts.hpp> +#include <amdis/typetree/FiniteElementType.hpp> + namespace AMDiS { - template <class ElementAssembler, class IntersectionAssembler, class BoundaryAssembler> - struct AssemblerTriple + /// Implementation of interface \ref AssemblerBase + template <class LocalContext, class Operator, class... Nodes> + class Assembler + : public AssemblerInterface<LocalContext, Nodes...> { - ElementAssembler elementAssembler; - IntersectionAssembler intersectionAssembler; - BoundaryAssembler boundaryAssembler; - }; + using Super = AssemblerInterface<LocalContext, Nodes...>; - template <class EA, class IA, class BA> - AssemblerTriple<EA, IA, BA> makeAssemblerTriple(EA const& ea, IA const& ia, BA const& ba) - { - return {ea, ia, ba}; - } + private: + using Element = typename Super::Element; + using Geometry = typename Super::Geometry; + using ElementMatrixVector = typename Super::ElementMatrixVector; - template <class GridView, class Element, class Operators, class EA, class IA, class BA> - void assembleOperators( - GridView const& gridView, - Element const& element, - Operators& operators, - AssemblerTriple<EA,IA,BA> const& assemblerTriple) - { - // assemble element operators - assemblerTriple.elementAssembler(element, operators.onElement()); + public: + + /// Constructor. Stores a copy of operator `op`. + explicit Assembler(Operator const& op) + : op_(Dune::wrap_or_move(op)) + {} + + /// Constructor. Stores a copy of operator `op`. + explicit Assembler(Operator&& op) + : op_(Dune::wrap_or_move(std::move(op))) + {} + + /// Constructor. Stores the reference to the operator. + explicit Assembler(std::reference_wrapper<Operator> op) + : op_(Dune::wrap_or_move(op.get())) + {} - // assemble intersection operators - if (!operators.onIntersection().empty() - || (!operators.onBoundary().empty() && element.hasBoundaryIntersections())) + /// \brief Implementation of \ref AssemblerInterface::bind. + /** + * Binds the operator `op_` to the `element` and `geometry` and + * stores point to the `element` and `geometry`. + **/ + void bind(Element const& element, Geometry const& geometry) final { - for (auto const& intersection : intersections(gridView, element)) { - if (intersection.boundary()) - assemblerTriple.boundaryAssembler(intersection, operators.onBoundary()); - else - assemblerTriple.intersectionAssembler(intersection, operators.onIntersection()); - } + element_ = &element; + geometry_ = &geometry; + op_->bind(element, geometry); } - } + /// \brief Implementation of \ref AssemblerBase::unbind + /** + * Unbinds the operator `op_` and sets \ref element_ and \ref geometry_ + * to nullptr. + **/ + void unbind() final + { + op_->unbind(); + geometry_ = nullptr; + element_ = nullptr; + } - template <class Node, class ElementVector> - auto makeVectorAssembler(Node const& node, ElementVector& elementVector) - { - return makeAssemblerTriple( - [&](auto const& element, auto& operators) { - for (auto op : operators) - op->assemble(element, node, elementVector); - }, - [&](auto const& is, auto& operators) { - for (auto op : operators) - op->assemble(is, node, elementVector); - }, - [&](auto const& bis, auto& operators) { - for (auto data : operators) { - if (data.bc.onBoundary(bis)) - data.op->assemble(bis, node, elementVector); - } - }); - } + /// Implementation of \ref AssemblerBase::assemble + /** + * Stores geometry and localGeometry and calls + * \ref calculateElementVector or \ref calculateElementMatrix on the + * vector or matrix operator, respectively. + **/ + void assemble(LocalContext const& localContext, + Nodes const&... nodes, + ElementMatrixVector& elementMatrixVector) final + { + ContextGeometry<LocalContext> context{localContext, element(), geometry()}; + assembleImpl(context, nodes..., elementMatrixVector); + } + + +#ifndef DOXYGEN + + protected: // implementation detail + + // matrix assembling + template <class Context, class RowNode, class ColNode, class ElementMatrix> + void assembleImpl(Context const& context, + RowNode const& rowNode, ColNode const& colNode, + ElementMatrix& elementMatrix) + { + op_->calculateElementMatrix(context, rowNode, colNode, elementMatrix); + } + + // vector assembling + template <class Context, class Node, class ElementVector> + void assembleImpl(Context const& context, + Node const& node, + ElementVector& elementVector) + { + op_->calculateElementVector(context, node, elementVector); + } + +#endif // DOXYGEN + + public: + + /// return the bound entity (of codim 0) + Element const& element() const + { + assert( element_ ); + return *element_; + } + + /// return the geometry of the bound element + Geometry const& geometry() const + { + assert( geometry_ ); + return *geometry_; + } + + + private: + + /// the stored operator, implementing \ref GridFunctionOperatorBase + std::shared_ptr<Operator> op_; + + Element const* element_ = nullptr; + Geometry const* geometry_ = nullptr; + }; - template <class RowNode, class ColNode, class ElementMatrix> - auto makeMatrixAssembler(RowNode const& rowNode, ColNode const& colNode, ElementMatrix& elementMatrix) + /// Generate a \ref Assembler on a given `LocalContext` (element or intersection) + template <class LocalContext, class Operator, class... Nodes> + auto makeAssembler(Operator&& op, Nodes const&...) { - return makeAssemblerTriple( - [&](auto const& element, auto& operators) { - for (auto op : operators) - op->assemble(element, rowNode, colNode, elementMatrix); - }, - [&](auto const& is, auto& operators) { - for (auto op : operators) - op->assemble(is, rowNode, colNode, elementMatrix); - }, - [&](auto const& bis, auto& operators) { - for (auto data : operators) { - if (data.bc.onBoundary(bis)) - data.op->assemble(bis, rowNode, colNode, elementMatrix); - } - }); + return Assembler<LocalContext, Underlying_t<Operator>, Nodes...>{std::forward<Operator>(op)}; } } // end namespace AMDiS diff --git a/src/amdis/LocalAssemblerBase.hpp b/src/amdis/AssemblerInterface.hpp similarity index 86% rename from src/amdis/LocalAssemblerBase.hpp rename to src/amdis/AssemblerInterface.hpp index daec80ac20c3a0bb5d577e1836a6c946c6d76a11..68e9b5d289c1732cbaeaaceaa3b41fb77fd3eb5d 100644 --- a/src/amdis/LocalAssemblerBase.hpp +++ b/src/amdis/AssemblerInterface.hpp @@ -9,13 +9,15 @@ namespace AMDiS { - /// Abstract base-class of a \ref LocalAssembler + /// Abstract base-class of a \ref Assembler template <class LocalContext, class... Nodes> - class LocalAssemblerBase + class AssemblerInterface { + using ContextType = Impl::ContextTypes<LocalContext>; + public: /// The codim=0 grid entity - using Element = typename Impl::ContextTypes<LocalContext>::Entity; + using Element = typename ContextType::Entity; /// The geometry of the \ref Element using Geometry = typename Element::Geometry; @@ -33,7 +35,7 @@ namespace AMDiS public: /// Virtual destructor - virtual ~LocalAssemblerBase() = default; + virtual ~AssemblerInterface() = default; /// Bind the local-assembler to the grid-element with its corresponding geometry virtual void bind(Element const& element, Geometry const& geometry) = 0; diff --git a/src/amdis/CMakeLists.txt b/src/amdis/CMakeLists.txt index e99d8316c9ea9717a93512c200873adfb43ae94f..cde9be08724e21a1ceb68249b8df7a5863d31b1b 100644 --- a/src/amdis/CMakeLists.txt +++ b/src/amdis/CMakeLists.txt @@ -20,13 +20,18 @@ install(FILES AdaptStationary.hpp AMDiS.hpp Assembler.hpp + AssemblerInterface.hpp Boundary.hpp + BoundaryCondition.hpp + BoundaryManager.hpp ContextGeometry.hpp CreatorInterface.hpp CreatorMap.hpp DataTransfer.hpp + DataTransfer.inc.hpp DirichletBC.hpp FileWriter.hpp + FileWriterInterface.hpp Flag.hpp GridFunctionOperator.hpp GridFunctions.hpp @@ -34,18 +39,18 @@ install(FILES GridTransferManager.hpp Initfile.hpp InitfileParser.hpp + Integrate.hpp LinearAlgebra.hpp - LinearSolvers.hpp - LocalAssembler.hpp - LocalAssemblerBase.hpp - LocalAssemblerList.hpp LocalOperator.hpp + LocalOperators.hpp Marker.hpp Marker.inc.hpp Mesh.hpp Operations.hpp - Operators.hpp + OperatorList.hpp Output.hpp + PeriodicBC.hpp + PeriodicBC.inc.hpp ProblemInstat.hpp ProblemInstat.inc.hpp ProblemInstatBase.hpp @@ -55,14 +60,13 @@ install(FILES ProblemStatBase.hpp ProblemStatTraits.hpp ProblemTimeInterface.hpp - QuadratureFactory.hpp StandardProblemIteration.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/amdis) -add_subdirectory("assembler") add_subdirectory("common") add_subdirectory("gridfunctions") -add_subdirectory("io") -add_subdirectory("linear_algebra") +add_subdirectory("linearalgebra") +add_subdirectory("localoperators") add_subdirectory("operations") +add_subdirectory("typetree") add_subdirectory("utility") diff --git a/src/amdis/ContextGeometry.hpp b/src/amdis/ContextGeometry.hpp index 6307603e484c7d19668e360b1a659a6e3809cab0..acc8c0b4bf46ae6cc4a1df6b599f3e9ae2184845 100644 --- a/src/amdis/ContextGeometry.hpp +++ b/src/amdis/ContextGeometry.hpp @@ -37,15 +37,16 @@ namespace AMDiS * geometry (and localGeometry) of the entity it belongs to, these objects * are provided as well. **/ - template <class LocalContextType> + template <class LC> struct ContextGeometry { - public: + using ContextType = Impl::ContextTypes<LC>; - using LocalContext = LocalContextType; - using Element = typename Impl::ContextTypes<LocalContext>::Entity; + public: + using LocalContext = LC; + using Element = typename ContextType::Entity; using Geometry = typename Element::Geometry; - using LocalGeometry = typename Impl::ContextTypes<LocalContext>::LocalGeometry; + using LocalGeometry = typename ContextType::LocalGeometry; using IsEntity = std::is_same<Element, LocalContext>; @@ -80,7 +81,7 @@ namespace AMDiS LocalGeometry const& localGeometry() const { - return localGeometryImpl(IsEntity{}); + return localGeometry_impl(IsEntity{}); } @@ -90,7 +91,7 @@ namespace AMDiS template <class Coordinate> decltype(auto) local(Coordinate const& p) const { - return localImpl(p, IsEntity{}); + return local_impl(p, IsEntity{}); } /// Transformation of coordinate `p` given in `localGeometry` to world space coordinates. @@ -118,26 +119,26 @@ namespace AMDiS // position for elements template <class Coordinate> - Coordinate const& localImpl(Coordinate const& p, std::true_type) const + Coordinate const& local_impl(Coordinate const& p, std::true_type) const { return p; } // position for intersection template <class Coordinate> - auto localImpl(Coordinate const& p, std::false_type) const + auto local_impl(Coordinate const& p, std::false_type) const { return localGeometry().global(p); } // local-geometry is the same as geometry - Geometry const& localGeometryImpl(std::true_type) const + Geometry const& localGeometry_impl(std::true_type) const { return *geometry_; } // local-geometry of intersection in inside element - LocalGeometry const& localGeometryImpl(std::false_type) const + LocalGeometry const& localGeometry_impl(std::false_type) const { if (!localGeometry_) localGeometry_.emplace(localContext_->geometryInInside()); diff --git a/src/amdis/CreatorInterface.hpp b/src/amdis/CreatorInterface.hpp index fa4a7eadd70180cd711211e0cc924cee0fa71292..01a83a89a88133ad3a5d23dcc7b30e2b1a0fb6b2 100644 --- a/src/amdis/CreatorInterface.hpp +++ b/src/amdis/CreatorInterface.hpp @@ -3,7 +3,6 @@ #include <memory> #include <string> -#include <amdis/common/Utility.hpp> #include <amdis/Output.hpp> namespace AMDiS @@ -56,7 +55,7 @@ namespace AMDiS * Creates a new instance of the sub class of BaseClass by passing a * string to the constructor. */ - virtual std::unique_ptr<BaseClass> create(std::string) = 0; + virtual std::unique_ptr<BaseClass> createWithString(std::string) = 0; }; diff --git a/src/amdis/DataTransfer.inc.hpp b/src/amdis/DataTransfer.inc.hpp index 9040221aad2fa15da2ee23cf2dcbee74502497e9..799009cd77f4bedfad5b7e8fda0c164c8808104c 100644 --- a/src/amdis/DataTransfer.inc.hpp +++ b/src/amdis/DataTransfer.inc.hpp @@ -21,14 +21,14 @@ #include <dune/functions/functionspacebases/lagrangebasis.hh> #include <amdis/Output.hpp> -#include <amdis/utility/ConcurrentCache.hpp> -#include <amdis/utility/TreeContainer.hpp> -#include <amdis/utility/Visitor.hpp> +#include <amdis/common/ConcurrentCache.hpp> +#include <amdis/typetree/TreeContainer.hpp> +#include <amdis/typetree/Visitor.hpp> namespace AMDiS { template <class Node, class Container, class Basis> - class NodeDataTransfer {}; + class NodeDataTransfer; /** Data Transfer implementation for a single grid @@ -292,14 +292,13 @@ namespace AMDiS /** Element-local data transfer on a single leaf node of the basis tree * Handles computations related to the finite element basis node */ - template <class GV, int k, class TP, class Container, class Basis> - class NodeDataTransfer<Dune::Functions::LagrangeNode<GV,k,TP>, Container, Basis> + template <class Node, class Container, class Basis> + class NodeDataTransfer { using T = typename Container::value_type; using LocalView = typename Basis::LocalView; - using Element = typename GV::template Codim<0>::Entity; + using Element = typename Node::Element; - using Node = typename Dune::Functions::LagrangeNode<GV,k,TP>; using LocalBasis = typename Node::FiniteElement::Traits::LocalBasisType; using LBRangeType = typename LocalBasis::Traits::RangeType; using LocalInterpolation = typename Node::FiniteElement::Traits::LocalBasisType; @@ -373,9 +372,9 @@ namespace AMDiS NodeElementData fatherDOFsTemp_; }; - template <class GV, int k, class TP, class Container, class Basis> + template <class Node, class Container, class Basis> template <class Trafo> - bool NodeDataTransfer<Dune::Functions::LagrangeNode<GV,k,TP>, Container, Basis>:: + bool NodeDataTransfer<Node, Container, Basis>:: restrictLocal(Element const& father, NodeElementData& fatherDOFs, Trafo const& trafo, NodeElementData const& childDOFs, bool init) { @@ -429,9 +428,9 @@ namespace AMDiS std::logical_and<bool>()); } - template <class GV, int k, class TP, class Container, class Basis> + template <class Node, class Container, class Basis> template <class Trafo> - void NodeDataTransfer<Dune::Functions::LagrangeNode<GV,k,TP>, Container, Basis>:: + void NodeDataTransfer<Node, Container, Basis>:: prolongLocal(Element const& father, NodeElementData const& fatherDOFs, Trafo const& trafo, bool init) { diff --git a/src/amdis/DirichletBC.hpp b/src/amdis/DirichletBC.hpp index 0d570e28f4852d9b6cba5b8e710223b10b86937f..344d10763c34c1b3c5811195a127aafe28f278a8 100644 --- a/src/amdis/DirichletBC.hpp +++ b/src/amdis/DirichletBC.hpp @@ -10,9 +10,9 @@ #include <amdis/Boundary.hpp> #include <amdis/BoundaryCondition.hpp> #include <amdis/common/Concepts.hpp> -#include <amdis/utility/RangeType.hpp> -#include <amdis/utility/TreeData.hpp> -#include <amdis/utility/Visitor.hpp> +#include <amdis/typetree/RangeType.hpp> +#include <amdis/typetree/TreeData.hpp> +#include <amdis/typetree/Visitor.hpp> namespace AMDiS { diff --git a/src/amdis/DirichletBC.inc.hpp b/src/amdis/DirichletBC.inc.hpp index d3ab7385eacf67fa0676d8607cd02c5c0fad0efe..cdbed4cccfe0a5343593dab7125c039667f94269 100644 --- a/src/amdis/DirichletBC.inc.hpp +++ b/src/amdis/DirichletBC.inc.hpp @@ -8,7 +8,7 @@ #include <dune/functions/functionspacebases/subspacebasis.hh> #include <amdis/Output.hpp> -#include <amdis/linear_algebra/Constraints.hpp> +#include <amdis/linearalgebra/Constraints.hpp> namespace AMDiS { diff --git a/src/amdis/FileWriter.hpp b/src/amdis/FileWriter.hpp index 086dc86b905c360c6b4c0a04be15be52aa6b51ce..9576f4c71180f503a406e98f1214715e7e3d9108 100644 --- a/src/amdis/FileWriter.hpp +++ b/src/amdis/FileWriter.hpp @@ -9,12 +9,12 @@ //#include <dune/geometry/referenceelements.hh> #include <dune/typetree/childextraction.hh> +#include <amdis/FileWriterInterface.hpp> #include <amdis/Initfile.hpp> -#include <amdis/common/Size.hpp> +#include <amdis/common/Filesystem.hpp> +#include <amdis/common/StaticSize.hpp> #include <amdis/common/ValueCategory.hpp> #include <amdis/gridfunctions/DiscreteFunction.hpp> -#include <amdis/io/FileWriterInterface.hpp> -#include <amdis/utility/Filesystem.hpp> namespace AMDiS { diff --git a/src/amdis/io/FileWriterInterface.hpp b/src/amdis/FileWriterInterface.hpp similarity index 96% rename from src/amdis/io/FileWriterInterface.hpp rename to src/amdis/FileWriterInterface.hpp index eb2591cc906988e778592db19ecf2ddb61066708..cfb643b5eb467b6478e04a220171d1946d3bc63e 100644 --- a/src/amdis/io/FileWriterInterface.hpp +++ b/src/amdis/FileWriterInterface.hpp @@ -4,7 +4,7 @@ #include <amdis/Initfile.hpp> #include <amdis/Output.hpp> -#include <amdis/utility/Filesystem.hpp> +#include <amdis/common/Filesystem.hpp> namespace AMDiS { diff --git a/src/amdis/GridFunctionOperator.hpp b/src/amdis/GridFunctionOperator.hpp index 733befae6c2f17175f2480e626f9be4a9ca860bb..b33394536a1ad8db018247b52fa6fee7c3a62a35 100644 --- a/src/amdis/GridFunctionOperator.hpp +++ b/src/amdis/GridFunctionOperator.hpp @@ -5,10 +5,10 @@ #include <amdis/GridFunctions.hpp> #include <amdis/LocalOperator.hpp> -#include <amdis/QuadratureFactory.hpp> #include <amdis/common/Transposed.hpp> -#include <amdis/common/Utility.hpp> -#include <amdis/utility/FiniteElementType.hpp> +#include <amdis/common/TypeTraits.hpp> +#include <amdis/typetree/FiniteElementType.hpp> +#include <amdis/utility/QuadratureFactory.hpp> namespace AMDiS { @@ -18,7 +18,7 @@ namespace AMDiS **/ /// \brief The main implementation of an CRTP-base class for operators using a grid-function - /// coefficient to be used in a \ref LocalAssembler. + /// coefficient to be used in an \ref Assembler. /** * An Operator that takes a GridFunction as coefficient. * Provides quadrature rules and handles the evaluation of the GridFunction at @@ -39,11 +39,19 @@ namespace AMDiS class GridFunctionOperatorBase : public LocalOperator<Derived, LocalContext> { + template <class D, class LC> + friend class LocalOperator; + + using ContextType = Impl::ContextTypes<LocalContext>; + using Super = LocalOperator<Derived, LocalContext>; + + private: /// The type of the localFunction associated with the GridFunction using LocalFunction = decltype(localFunction(std::declval<GridFunction>())); /// The Codim=0 entity of the grid, the localFunction can be bound to - using Element = typename Impl::ContextTypes<LocalContext>::Entity; + using Element = typename ContextType::Entity; + /// The geometry-type of the grid element using Geometry = typename Element::Geometry; @@ -66,30 +74,6 @@ namespace AMDiS , termOrder_(termOrder) {} - /// \brief Binds operator to `element` and `geometry`. - /** - * Binding an operator to the currently visited element in grid traversal. - * Since all operators need geometry information, the `Element::Geometry` - * object `geometry` is created once, during grid traversal, and passed in. - * - * By default, it binds the \ref localFct_ to the `element` and the Quadrature - * factory to the localFunction. - **/ - void bind_impl(Element const& element, Geometry const& geometry) - { - assert( bool(quadFactory_) ); - localFct_.emplace(localFunction(gridFct_)); - localFct_->bind(element); - quadFactory_->bind(localFct_.value()); - } - - /// Unbinds operator from element. - void unbind_impl() - { - localFct_->unbind(); - localFct_.reset(); - } - /// Create a quadrature factory from a PreQuadratureFactory, e.g. class derived from \ref QuadratureFactory template <class PreQuadFactory> void setQuadFactory(PreQuadFactory&& pre) @@ -117,6 +101,31 @@ namespace AMDiS return quadFactory_->rule(type, quadDegree); } + private: + /// \brief Binds operator to `element` and `geometry`. + /** + * Binding an operator to the currently visited element in grid traversal. + * Since all operators need geometry information, the `Element::Geometry` + * object `geometry` is created once, during grid traversal, and passed in. + * + * By default, it binds the \ref localFct_ to the `element` and the Quadrature + * factory to the localFunction. + **/ + void bind_impl(Element const& element, Geometry const& geometry) + { + assert( bool(quadFactory_) ); + localFct_.emplace(localFunction(gridFct_)); + localFct_->bind(element); + quadFactory_->bind(localFct_.value()); + } + + /// Unbinds operator from element. + void unbind_impl() + { + localFct_->unbind(); + localFct_.reset(); + } + private: /// The gridFunction to be used within the operator GridFunction gridFct_; @@ -138,6 +147,9 @@ namespace AMDiS class GridFunctionOperatorTransposed : public LocalOperator<Derived, typename Transposed::LocalContext> { + template <class D, class LC> + friend class LocalOperator; + template <class T, class... Args> using Constructable = decltype( new T(std::declval<Args>()...) ); @@ -148,24 +160,25 @@ namespace AMDiS : transposedOp_(std::forward<Args>(args)...) {} + /// Redirects the setQuadFactory call top the transposed operator + template <class PreQuadFactory> + void setQuadFactory(PreQuadFactory&& pre) + { + transposedOp_.setQuadFactory(std::forward<PreQuadFactory>(pre)); + } + + private: /// Redirects the bind call top the transposed operator template <class Element, class Geometry> void bind_impl(Element const& element, Geometry const& geometry) { - transposedOp_.bind_impl(element, geometry); + transposedOp_.bind(element, geometry); } /// Redirects the unbind call top the transposed operator void unbind_impl() { - transposedOp_.unbind_impl(); - } - - /// Redirects the setQuadFactory call top the transposed operator - template <class PreQuadFactory> - void setQuadFactory(PreQuadFactory&& pre) - { - transposedOp_.setQuadFactory(std::forward<PreQuadFactory>(pre)); + transposedOp_.unbind(); } /// Apply the assembling to the transposed elementMatrix with interchanged row-/colNode diff --git a/src/amdis/GridTransfer.hpp b/src/amdis/GridTransfer.hpp index 9c77d58f5d953328a4a094bb7c275d6c17dc8a54..3cd13923dbd29734bed80400d35fdb6ee9180998 100644 --- a/src/amdis/GridTransfer.hpp +++ b/src/amdis/GridTransfer.hpp @@ -2,9 +2,8 @@ #include <list> -#include <amdis/linear_algebra/DOFVectorInterface.hpp> - #include <amdis/Output.hpp> +#include <amdis/linearalgebra/DOFVectorInterface.hpp> namespace AMDiS { diff --git a/src/amdis/GridTransferManager.hpp b/src/amdis/GridTransferManager.hpp index 554d9e778f18dddbf4dc56ab25a99e1d9011a5a6..1563a16b52fd69bf9bc27850dcc27c0f4c6b4578 100644 --- a/src/amdis/GridTransferManager.hpp +++ b/src/amdis/GridTransferManager.hpp @@ -5,7 +5,7 @@ #include <memory> #include <amdis/GridTransfer.hpp> -#include <amdis/utility/ConcurrentCache.hpp> +#include <amdis/common/ConcurrentCache.hpp> namespace AMDiS { diff --git a/src/amdis/InitfileParser.cpp b/src/amdis/InitfileParser.cpp index 86c150627a2d97db75e07b62250788f1f6c94a79..53d91095034f444383aaa77fe20ea623481dede8 100644 --- a/src/amdis/InitfileParser.cpp +++ b/src/amdis/InitfileParser.cpp @@ -1,8 +1,8 @@ #include <amdis/InitfileParser.hpp> #include <amdis/Output.hpp> -#include <amdis/utility/Filesystem.hpp> -#include <amdis/utility/String.hpp> +#include <amdis/common/Filesystem.hpp> +#include <amdis/common/String.hpp> namespace AMDiS { @@ -66,6 +66,7 @@ void InitfileParser::readInitfile(std::istream& in, Dune::ParameterTree& pt, boo switch (char c = swap[pos++]) { case '<': c= '>'; + // [[fallthrough]]; case '\"': delimiter += c; epos = sw.find_first_of(delimiter, pos); diff --git a/src/amdis/Integrate.hpp b/src/amdis/Integrate.hpp index bedd76502a389f7e4b6c273c96a62f1c86d988ec..08d527a11f78e2228be58de6e3f4ad63dac08020 100644 --- a/src/amdis/Integrate.hpp +++ b/src/amdis/Integrate.hpp @@ -3,7 +3,6 @@ #include <type_traits> #include <dune/geometry/quadraturerules.hh> #include <amdis/GridFunctions.hpp> -#include <amdis/common/Mpl.hpp> namespace AMDiS { @@ -68,7 +67,7 @@ namespace AMDiS auto makeQuad = [](auto&& t, auto&& lf) { return Rules::rule(t, order(lf)); }; return Impl::integrateImpl(std::forward<decltype(gridFct)>(gridFct), gridView, makeQuad, - bool_<expr_has_order>); + std::integral_constant<bool,expr_has_order>{}); } diff --git a/src/amdis/LinearAlgebra.hpp b/src/amdis/LinearAlgebra.hpp index aa920278aeb6156d4224030cfc4f745352e4cea3..9a32bd9a09865918d3e0f4b569ea598500eb183c 100644 --- a/src/amdis/LinearAlgebra.hpp +++ b/src/amdis/LinearAlgebra.hpp @@ -1,21 +1,29 @@ #pragma once +#include <amdis/linearalgebra/LinearSolver.hpp> +#include <amdis/linearalgebra/SolverInfo.hpp> + #if HAVE_MTL -#include <amdis/linear_algebra/mtl/Constraints.hpp> -#include <amdis/linear_algebra/mtl/DOFMatrix.hpp> -#include <amdis/linear_algebra/mtl/DOFVector.hpp> +#include <amdis/linearalgebra/mtl/Constraints.hpp> +#include <amdis/linearalgebra/mtl/DOFMatrix.hpp> +#include <amdis/linearalgebra/mtl/DOFVector.hpp> +#include <amdis/linearalgebra/mtl/ITL_Solver.hpp> +#include <amdis/linearalgebra/mtl/ITL_Preconditioner.hpp> #elif HAVE_EIGEN -#include <amdis/linear_algebra/eigen/Constraints.hpp> -#include <amdis/linear_algebra/eigen/DOFMatrix.hpp> -#include <amdis/linear_algebra/eigen/DOFVector.hpp> +#include <amdis/linearalgebra/eigen/Constraints.hpp> +#include <amdis/linearalgebra/eigen/DOFMatrix.hpp> +#include <amdis/linearalgebra/eigen/DOFVector.hpp> +#include <amdis/linearalgebra/eigen/SolverCreator.hpp> #else // ISTL -#include <amdis/linear_algebra/istl/Constraints.hpp> -#include <amdis/linear_algebra/istl/DOFMatrix.hpp> -#include <amdis/linear_algebra/istl/DOFVector.hpp> +#include <amdis/linearalgebra/istl/Constraints.hpp> +#include <amdis/linearalgebra/istl/DOFMatrix.hpp> +#include <amdis/linearalgebra/istl/DOFVector.hpp> +#include <amdis/linearalgebra/istl/ISTL_Solver.hpp> +#include <amdis/linearalgebra/istl/ISTL_Preconditioner.hpp> #endif \ No newline at end of file diff --git a/src/amdis/LinearSolvers.hpp b/src/amdis/LinearSolvers.hpp deleted file mode 100644 index 89951d561731aed8232cf7318348aa96751f4094..0000000000000000000000000000000000000000 --- a/src/amdis/LinearSolvers.hpp +++ /dev/null @@ -1,20 +0,0 @@ -#pragma once - -#include <amdis/linear_algebra/LinearSolver.hpp> -#include <amdis/linear_algebra/SolverInfo.hpp> - -#if HAVE_MTL - -#include <amdis/linear_algebra/mtl/ITL_Solver.hpp> -#include <amdis/linear_algebra/mtl/ITL_Preconditioner.hpp> - -#elif HAVE_EIGEN - -#include <amdis/linear_algebra/eigen/SolverCreator.hpp> - -#else // ISTL - -#include <amdis/linear_algebra/istl/ISTL_Solver.hpp> -#include <amdis/linear_algebra/istl/ISTL_Preconditioner.hpp> - -#endif \ No newline at end of file diff --git a/src/amdis/LocalAssembler.hpp b/src/amdis/LocalAssembler.hpp deleted file mode 100644 index db3c56c486cbb627e5c541b3eaed65dee3e961b8..0000000000000000000000000000000000000000 --- a/src/amdis/LocalAssembler.hpp +++ /dev/null @@ -1,144 +0,0 @@ -#pragma once - -#include <functional> -#include <memory> -#include <type_traits> - -#include <dune/common/shared_ptr.hh> -#include <dune/geometry/quadraturerules.hh> - -#include <amdis/ContextGeometry.hpp> -#include <amdis/LocalAssemblerBase.hpp> -#include <amdis/common/Concepts.hpp> -#include <amdis/utility/FiniteElementType.hpp> - -namespace AMDiS -{ - /// Implementation of interface \ref LocalAssemblerBase - template <class LocalContext, class Operator, class... Nodes> - class LocalAssembler - : public LocalAssemblerBase<LocalContext, Nodes...> - { - using Super = LocalAssemblerBase<LocalContext, Nodes...>; - - private: - - using Element = typename Super::Element; - using Geometry = typename Super::Geometry; - using ElementMatrixVector = typename Super::ElementMatrixVector; - - public: - - /// Constructor. Stores a copy of operator `op`. - explicit LocalAssembler(Operator const& op) - : op_(Dune::wrap_or_move(op)) - {} - - /// Constructor. Stores a copy of operator `op`. - explicit LocalAssembler(Operator&& op) - : op_(Dune::wrap_or_move(std::move(op))) - {} - - /// Constructor. Stores the reference to the operator. - explicit LocalAssembler(std::reference_wrapper<Operator> op) - : op_(Dune::wrap_or_move(op.get())) - {} - - /// \brief Implementation of \ref LocalAssemblerBase::bind. - /** - * Binds the operator `op_` to the `element` and `geometry` and - * stores point to the `element` and `geometry`. - **/ - virtual void bind(Element const& element, Geometry const& geometry) final - { - element_ = &element; - geometry_ = &geometry; - op_->bind(element, geometry); - } - - /// \brief Implementation of \ref LocalAssemblerBase::unbind - /** - * Unbinds the operator `op_` and sets \ref element_ and \ref geometry_ - * to nullptr. - **/ - virtual void unbind() final - { - op_->unbind(); - geometry_ = nullptr; - element_ = nullptr; - } - - /// Implementation of \ref LocalAssemblerBase::assemble - /** - * Stores geometry and localGeometry and calls - * \ref calculateElementVector or \ref calculateElementMatrix on the - * vector or matrix operator, respectively. - **/ - virtual void assemble(LocalContext const& localContext, - Nodes const&... nodes, - ElementMatrixVector& elementMatrixVector) final - { - ContextGeometry<LocalContext> context{localContext, element(), geometry()}; - assembleImpl(context, nodes..., elementMatrixVector); - } - - -#ifndef DOXYGEN - - protected: // implementation detail - - // matrix assembling - template <class Context, class RowNode, class ColNode, class ElementMatrix> - void assembleImpl(Context const& context, - RowNode const& rowNode, ColNode const& colNode, - ElementMatrix& elementMatrix) - { - op_->calculateElementMatrix(context, rowNode, colNode, elementMatrix); - } - - // vector assembling - template <class Context, class Node, class ElementVector> - void assembleImpl(Context const& context, - Node const& node, - ElementVector& elementVector) - { - op_->calculateElementVector(context, node, elementVector); - } - -#endif // DOXYGEN - - public: - - /// return the bound entity (of codim 0) - Element const& element() const - { - assert( element_ ); - return *element_; - } - - /// return the geometry of the bound element - Geometry const& geometry() const - { - assert( geometry_ ); - return *geometry_; - } - - - private: - - /// the stored operator, implementing \ref GridFunctionOperatorBase - std::shared_ptr<Operator> op_; - - Element const* element_ = nullptr; - Geometry const* geometry_ = nullptr; - }; - - - /// Generate a \ref LocalAssembler on a given `LocalContext` (element or intersection) - template <class LocalContext, class Operator, class... Nodes> - auto makeLocalAssembler(Operator&& op, Nodes const&...) - { - return LocalAssembler<LocalContext, Underlying_t<Operator>, Nodes...>{std::forward<Operator>(op)}; - } - -} // end namespace AMDiS diff --git a/src/amdis/LocalOperator.hpp b/src/amdis/LocalOperator.hpp index ef6bfcf46b8b1b1d7d02e11b403ba7714d94bbd4..ad3772674336649ca838b51961db931a69d26d9e 100644 --- a/src/amdis/LocalOperator.hpp +++ b/src/amdis/LocalOperator.hpp @@ -3,10 +3,11 @@ #include <cassert> #include <type_traits> -#include <amdis/GridFunctions.hpp> +// #include <amdis/GridFunctions.hpp> +#include <amdis/ContextGeometry.hpp> #include <amdis/Output.hpp> -#include <amdis/common/Utility.hpp> -#include <amdis/utility/FiniteElementType.hpp> +#include <amdis/common/TypeTraits.hpp> +#include <amdis/typetree/FiniteElementType.hpp> namespace AMDiS { @@ -15,21 +16,25 @@ namespace AMDiS * @{ **/ - /// \brief The main implementation of an operator to be used in a \ref LocalAssembler. + /// \brief The main implementation of an operator to be used in a \ref Assembler. /** * The CRTP Base class for local operators. * - * \tparam Derived The class that derives from this base class - * \tparam LocalContextType The type of the element or intersection the operator is evaluated on + * \tparam Derived The class that derives from this base class + * \tparam LC The type of the element or intersection the operator is evaluated on **/ - template <class Derived, class LocalContextType> + template <class Derived, class LC> class LocalOperator { + using ContextType = Impl::ContextTypes<LC>; + public: /// The element or intersection the operator is assembled on - using LocalContext = LocalContextType; + using LocalContext = LC; + /// The codim=0 grid entity - using Element = typename Impl::ContextTypes<LocalContext>::Entity; + using Element = typename ContextType::Entity; + /// The geometry of the \ref Element using Geometry = typename Element::Geometry; @@ -79,6 +84,7 @@ namespace AMDiS ColNode const& colNode, ElementMatrix& elementMatrix) { + assert( bound_ ); derived().getElementMatrix(context, rowNode, colNode, elementMatrix); } @@ -93,6 +99,7 @@ namespace AMDiS Node const& node, ElementVector& elementVector) { + assert( bound_ ); derived().getElementVector(context, node, elementVector); } diff --git a/src/amdis/LocalOperators.hpp b/src/amdis/LocalOperators.hpp new file mode 100644 index 0000000000000000000000000000000000000000..8abe8d6d1beb8763e2a88e07d13e4d5af3e3a47b --- /dev/null +++ b/src/amdis/LocalOperators.hpp @@ -0,0 +1,66 @@ +#pragma once + +#include <amdis/Assembler.hpp> +#include <amdis/GridFunctionOperator.hpp> + +/* + * In the following comments we use the notation + * psi ... scalar testfunction + * Psi ... vector testfunction + * phi ... scalar trialfunction + * Phi ... vector trialfunction + * A ..... matrix coefficient + * b ..... vector coefficient + * c ..... scalar coefficient + */ + + +/** + * \defgroup operators Operator module + * \brief Defines operators to be assembled in the matrix/vector + * + * An `Operator` is a class providing methods necessary for assembling: + * - `bind(Element, Geometry)` and `unbind()` for binding an unbinding the + * element to (from) an GridView entity of codim 0. Additionally the Geometry + * object of the element is provided. + * - `getQuadratureRule(Nodes...)` factory for the + * quadrature rules used in assembling the operator on the element. `Nodes...` + * is either `{RowNode, ColNode}` for Matrix-Operators or `{Node}` for a + * Vector-Operator. + * - `calculateElementVector(ContextGeometry, QuadratureRule, ElementVector, Node)` + * where the `ContextGeometry` provides a reference to the ElementGeometry and + * geometry of the LocalContext (that can be different), *or* + * - `calculateElementMatrix(ContextGeometry, QuadratureRule, ElementMatrix, RowNode, ColNode, Flags...)` + * Same as for `calculateElementVector` but additionally two optimization flags + * are provided as `bool_t<...>` type: + * + `sameFE`: the FiniteElementSpace of `RowNode` and `ColNode` are the same. + * + `sameNode`: the nodes are the same in the GlobalBasis-tree. + **/ + +// zero-order operators +#include <amdis/localoperators/ZeroOrderTest.hpp> // <psi * c> +#include <amdis/localoperators/ZeroOrderTestTrial.hpp> // <psi, c * phi> +#include <amdis/localoperators/ZeroOrderTestTrialvec.hpp> // <psi, b * Phi> +#include <amdis/localoperators/ZeroOrderTestvec.hpp> // <Psi * b> +#include <amdis/localoperators/ZeroOrderTestvecTrial.hpp> // <Psi, b * phi> +#include <amdis/localoperators/ZeroOrderTestvecTrialvec.hpp> // <Psi, A * Phi>, <Psi, c * Phi> + +// first-order operators +#include <amdis/localoperators/FirstOrderPartialTest.hpp> // <d_i(psi), c> +#include <amdis/localoperators/FirstOrderGradTest.hpp> // <grad(psi), b> +#include <amdis/localoperators/FirstOrderDivTestvec.hpp> // <div(Psi), c> + +#include <amdis/localoperators/FirstOrderDivTestvecTrial.hpp> // <div(Psi), c * phi> +#include <amdis/localoperators/FirstOrderGradTestTrial.hpp> // <grad(psi), b * phi> +#include <amdis/localoperators/FirstOrderGradTestTrialvec.hpp> // <grad(psi), c * Phi> +#include <amdis/localoperators/FirstOrderPartialTestTrial.hpp> // <d_i(psi), c * psi> +#include <amdis/localoperators/FirstOrderTestDivTrialvec.hpp> // <psi, c * div(Phi)> +#include <amdis/localoperators/FirstOrderTestGradTrial.hpp> // <psi, b * grad(phi)> +#include <amdis/localoperators/FirstOrderTestPartialTrial.hpp> // <psi, c * d_i(phi)> +#include <amdis/localoperators/FirstOrderTestvecGradTrial.hpp> // <Psi, c * grad(phi)> + +// second-order operators +#include <amdis/localoperators/SecondOrderDivTestvecDivTrialvec.hpp> // <div(Psi), c * div(Phi)> +#include <amdis/localoperators/SecondOrderGradTestGradTrial.hpp> // <grad(psi), A * grad(phi)> +#include <amdis/localoperators/SecondOrderPartialTestPartialTrial.hpp> // <d_i(psi), c * d_j(phi)> + diff --git a/src/amdis/Marker.inc.hpp b/src/amdis/Marker.inc.hpp index cc4687a848be2c4a204a64d1753ed5cd7627f305..518efa1d91da042c3e7164423f168f06eaf5f059 100644 --- a/src/amdis/Marker.inc.hpp +++ b/src/amdis/Marker.inc.hpp @@ -288,7 +288,7 @@ Flag GridFunctionMarker<Grid, PreGridFct>::markGrid(AdaptInfo& adaptInfo) int codim = ref.dimension; for (int i = 0; i < ref.size(codim); i++) - targetLevel = std::max(targetLevel, (int)std::round(localFct(ref.position(i, codim)))); + targetLevel = std::max(targetLevel, int(std::round(localFct(ref.position(i, codim))))); int m = ((((targetLevel > currentLevel) && (currentLevel < this->maxRefineLevel_)) || (currentLevel < this->minRefineLevel_)) diff --git a/src/amdis/Mesh.hpp b/src/amdis/Mesh.hpp index bf7e204b063db5c3682d259c0f9b0aceaab5ccea..1d1d0948b1e7397d733682770188af35741a7bea 100644 --- a/src/amdis/Mesh.hpp +++ b/src/amdis/Mesh.hpp @@ -16,7 +16,7 @@ #include <amdis/Initfile.hpp> #include <amdis/Output.hpp> -#include <amdis/utility/Filesystem.hpp> +#include <amdis/common/Filesystem.hpp> namespace AMDiS { diff --git a/src/amdis/LocalAssemblerList.hpp b/src/amdis/OperatorList.hpp similarity index 85% rename from src/amdis/LocalAssemblerList.hpp rename to src/amdis/OperatorList.hpp index a5e993d63d6f5e384b1f732555345c96909ae7b0..b0807c857922ef0c4ecae214e160b6c7a038ef13 100644 --- a/src/amdis/LocalAssemblerList.hpp +++ b/src/amdis/OperatorList.hpp @@ -4,8 +4,8 @@ #include <memory> #include <amdis/BoundaryCondition.hpp> -#include <amdis/LocalAssemblerBase.hpp> -#include <amdis/utility/TreeData.hpp> +#include <amdis/AssemblerInterface.hpp> +#include <amdis/typetree/TreeData.hpp> namespace AMDiS { @@ -58,16 +58,16 @@ namespace AMDiS template <class Geo> void bind(Element const& elem, Geo const& geo) { - for (auto op : element_) op->bind(elem,geo); - for (auto op : intersection_) op->bind(elem,geo); + for (auto& op : element_) op->bind(elem,geo); + for (auto& op : intersection_) op->bind(elem,geo); for (auto& data : boundary_) data.op->bind(elem,geo); } /// Unbind all operators from the element void unbind() { - for (auto op : element_) op->unbind(); - for (auto op : intersection_) op->unbind(); + for (auto& op : element_) op->unbind(); + for (auto& op : intersection_) op->unbind(); for (auto& data : boundary_) data.op->unbind(); assembled_ = true; } @@ -103,19 +103,19 @@ namespace AMDiS private: /// The type of local operators associated with grid elements - using ElementOperator = LocalAssemblerBase<Element, Nodes...>; + using ElementAssembler = AssemblerInterface<Element, Nodes...>; /// The type of local operators associated with grid intersections - using IntersectionOperator = LocalAssemblerBase<Intersection, Nodes...>; + using IntersectionAssembler = AssemblerInterface<Intersection, Nodes...>; /// List of operators to be assembled on grid elements - std::vector<std::shared_ptr<ElementOperator>> element_; + std::vector<std::shared_ptr<ElementAssembler>> element_; /// List of operators to be assembled on interior intersections - std::vector<std::shared_ptr<IntersectionOperator>> intersection_; + std::vector<std::shared_ptr<IntersectionAssembler>> intersection_; /// List of operators to be assembled on boundary intersections - std::vector<DataElement<IntersectionOperator>> boundary_; + std::vector<DataElement<IntersectionAssembler>> boundary_; /// if false, do reassemble of all operators bool assembled_ = false; diff --git a/src/amdis/Operators.hpp b/src/amdis/Operators.hpp deleted file mode 100644 index 5fba1925cbfaa813aad9e9d7e395ecb8618bd7e9..0000000000000000000000000000000000000000 --- a/src/amdis/Operators.hpp +++ /dev/null @@ -1,66 +0,0 @@ -#pragma once - -#include <amdis/LocalAssembler.hpp> -#include <amdis/GridFunctionOperator.hpp> - -/* - * In the following comments we use the notation - * psi ... scalar testfunction - * Psi ... vector testfunction - * phi ... scalar trialfunction - * Phi ... vector trialfunction - * A ..... matrix coefficient - * b ..... vector coefficient - * c ..... scalar coefficient - */ - - -/** - * \defgroup operators Operator module - * \brief Defines operators to be assembled in the matrix/vector - * - * An `Operator` is a class providing methods necessary for assembling: - * - `bind(Element, Geometry)` and `unbind()` for binding an unbinding the - * element to (from) an GridView entity of codim 0. Additionally the Geometry - * object of the element is provided. - * - `getQuadratureRule(Nodes...)` factory for the - * quadrature rules used in assembling the operator on the element. `Nodes...` - * is either `{RowNode, ColNode}` for Matrix-Operators or `{Node}` for a - * Vector-Operator. - * - `calculateElementVector(ContextGeometry, QuadratureRule, ElementVector, Node)` - * where the `ContextGeometry` provides a reference to the ElementGeometry and - * geometry of the LocalContext (that can be different), *or* - * - `calculateElementMatrix(ContextGeometry, QuadratureRule, ElementMatrix, RowNode, ColNode, Flags...)` - * Same as for `calculateElementVector` but additionally two optimization flags - * are provided as `bool_t<...>` type: - * + `sameFE`: the FiniteElementSpace of `RowNode` and `ColNode` are the same. - * + `sameNode`: the nodes are the same in the GlobalBasis-tree. - **/ - -// zero-order operators -#include <amdis/assembler/ZeroOrderTest.hpp> // <psi * c> -#include <amdis/assembler/ZeroOrderTestTrial.hpp> // <psi, c * phi> -#include <amdis/assembler/ZeroOrderTestTrialvec.hpp> // <psi, b * Phi> -#include <amdis/assembler/ZeroOrderTestvec.hpp> // <Psi * b> -#include <amdis/assembler/ZeroOrderTestvecTrial.hpp> // <Psi, b * phi> -#include <amdis/assembler/ZeroOrderTestvecTrialvec.hpp> // <Psi, A * Phi>, <Psi, c * Phi> - -// first-order operators -#include <amdis/assembler/FirstOrderPartialTest.hpp> // <d_i(psi), c> -#include <amdis/assembler/FirstOrderGradTest.hpp> // <grad(psi), b> -#include <amdis/assembler/FirstOrderDivTestvec.hpp> // <div(Psi), c> - -#include <amdis/assembler/FirstOrderDivTestvecTrial.hpp> // <div(Psi), c * phi> -#include <amdis/assembler/FirstOrderGradTestTrial.hpp> // <grad(psi), b * phi> -#include <amdis/assembler/FirstOrderGradTestTrialvec.hpp> // <grad(psi), c * Phi> -#include <amdis/assembler/FirstOrderPartialTestTrial.hpp> // <d_i(psi), c * psi> -#include <amdis/assembler/FirstOrderTestDivTrialvec.hpp> // <psi, c * div(Phi)> -#include <amdis/assembler/FirstOrderTestGradTrial.hpp> // <psi, b * grad(phi)> -#include <amdis/assembler/FirstOrderTestPartialTrial.hpp> // <psi, c * d_i(phi)> -#include <amdis/assembler/FirstOrderTestvecGradTrial.hpp> // <Psi, c * grad(phi)> - -// second-order operators -#include <amdis/assembler/SecondOrderDivTestvecDivTrialvec.hpp> // <div(Psi), c * div(Phi)> -#include <amdis/assembler/SecondOrderGradTestGradTrial.hpp> // <grad(psi), A * grad(phi)> -#include <amdis/assembler/SecondOrderPartialTestPartialTrial.hpp> // <d_i(psi), c * d_j(phi)> - diff --git a/src/amdis/PeriodicBC.hpp b/src/amdis/PeriodicBC.hpp index 5d10800a83c5343c4201ff1c1e6f672f9925ad98..23f4fb374ebb28fd35479d2224ab0ad17da3f2ef 100644 --- a/src/amdis/PeriodicBC.hpp +++ b/src/amdis/PeriodicBC.hpp @@ -6,9 +6,10 @@ #include <type_traits> #include <vector> +#include <amdis/Output.hpp> #include <amdis/common/ConceptsBase.hpp> +#include <amdis/common/FieldMatVec.hpp> -#include <amdis/Output.hpp> namespace AMDiS { diff --git a/src/amdis/ProblemInstat.hpp b/src/amdis/ProblemInstat.hpp index 56a3555f391784e94cef478a93918f61d211625e..d2f9704d06235b7beffbcc04a95ccc677ed26221 100644 --- a/src/amdis/ProblemInstat.hpp +++ b/src/amdis/ProblemInstat.hpp @@ -4,7 +4,7 @@ #include <amdis/ProblemInstatBase.hpp> #include <amdis/ProblemStat.hpp> -#include <amdis/common/Utility.hpp> +#include <amdis/common/TypeTraits.hpp> namespace AMDiS { diff --git a/src/amdis/ProblemStat.hpp b/src/amdis/ProblemStat.hpp index b1fa1d754f0954ef125b53aaf62ec84afa422219..75711f2304fa0cc43ce1a73ddb5ee25b4985dccb 100644 --- a/src/amdis/ProblemStat.hpp +++ b/src/amdis/ProblemStat.hpp @@ -20,8 +20,7 @@ #include <amdis/Flag.hpp> #include <amdis/Initfile.hpp> #include <amdis/LinearAlgebra.hpp> -#include <amdis/LinearSolvers.hpp> -#include <amdis/LocalAssemblerList.hpp> +#include <amdis/OperatorList.hpp> #include <amdis/Marker.hpp> #include <amdis/Mesh.hpp> #include <amdis/PeriodicBC.hpp> @@ -30,16 +29,16 @@ #include <amdis/StandardProblemIteration.hpp> #include <amdis/common/TupleUtility.hpp> -#include <amdis/common/Utility.hpp> +#include <amdis/common/TypeTraits.hpp> #include <amdis/GridFunctions.hpp> #include <amdis/gridfunctions/DiscreteFunction.hpp> #include <amdis/gridfunctions/DOFVectorView.hpp> -#include <amdis/io/FileWriterInterface.hpp> +#include <amdis/FileWriterInterface.hpp> -#include <amdis/utility/TreeData.hpp> -#include <amdis/utility/TreePath.hpp> +#include <amdis/typetree/TreeData.hpp> +#include <amdis/typetree/TreePath.hpp> namespace AMDiS { @@ -320,6 +319,7 @@ namespace AMDiS template <class TreePath = RootTreePath> auto solution(TreePath path = {}) { + assert(bool(solution_) && "You have to call initialize() before."); auto&& tp = makeTreePath(path); return makeDOFVectorView(*solution_, tp); } @@ -328,6 +328,7 @@ namespace AMDiS template <class TreePath = RootTreePath> auto solution(TreePath path = {}) const { + assert(bool(solution_) && "You have to call initialize() before."); auto&& tp = makeTreePath(path); return makeDiscreteFunction(*solution_, tp); } diff --git a/src/amdis/ProblemStat.inc.hpp b/src/amdis/ProblemStat.inc.hpp index 50058ccfaf357d662aee26391e6c204ee6643809..a086f54aa1a410d497e72a6dcd289094c19dbdbd 100644 --- a/src/amdis/ProblemStat.inc.hpp +++ b/src/amdis/ProblemStat.inc.hpp @@ -9,9 +9,9 @@ #include <amdis/AdaptInfo.hpp> #include <amdis/FileWriter.hpp> +#include <amdis/Assembler.hpp> #include <amdis/GridFunctionOperator.hpp> #include <amdis/GridTransferManager.hpp> -#include <amdis/LocalAssembler.hpp> #include <amdis/common/Loops.hpp> namespace AMDiS { @@ -196,7 +196,7 @@ void ProblemStat<Traits>::createSolver() auto solverCreator = named(CreatorMap<LinearSolverType>::getCreator(solverName, name_ + "->solver->name")); - linearSolver_ = solverCreator->create(name_ + "->solver"); + linearSolver_ = solverCreator->createWithString(name_ + "->solver"); } diff --git a/src/amdis/common/Algorithm.hpp b/src/amdis/common/Algorithm.hpp new file mode 100644 index 0000000000000000000000000000000000000000..dabbe0331cc384a9584e1e306d06faae8147871b --- /dev/null +++ b/src/amdis/common/Algorithm.hpp @@ -0,0 +1,36 @@ +#pragma once + +#include <algorithm> + +namespace AMDiS +{ + template <class InputIter, class T, class Func> + void split(InputIter first, InputIter end, T const& t, Func f) + { + if (first == end) + return; + + while (true) { + InputIter found = std::find(first, end, t); + f(first, found); + if (found == end) + break; + first = ++found; + } + } + + template <class InputIter, class SeparaterIter, class Func> + void split(InputIter first, InputIter end, SeparaterIter s_first, SeparaterIter s_end, Func f) + { + if (first == end) + return; + + while (true) { + InputIter found = std::find_first_of(first, end, s_first, s_end); + f(first, found); + if (found == end) + break; + first = ++found; + } + } +} \ No newline at end of file diff --git a/src/amdis/common/CMakeLists.txt b/src/amdis/common/CMakeLists.txt index 7b4b4ac25b8cc8d50d016821c0f0c2bfb9565e00..c3b5a867cf54695effa45dc949904984920d9c89 100644 --- a/src/amdis/common/CMakeLists.txt +++ b/src/amdis/common/CMakeLists.txt @@ -1,25 +1,28 @@ -#install headers +dune_library_add_sources(amdis SOURCES + Filesystem.cpp + String.cpp +) install(FILES - Assigner.hpp - ClonablePtr.hpp + Algorithm.hpp + Apply.hpp Concepts.hpp ConceptsBase.hpp + ConcurrentCache.hpp FieldMatVec.hpp FieldMatVec.inc.hpp - FieldTraits.hpp - IndexSeq.hpp + Filesystem.hpp Literals.hpp Loops.hpp Math.hpp Mpl.hpp MultiTypeMatrix.hpp MultiTypeVector.hpp - ScalarTypes.hpp - Size.hpp + StaticSize.hpp + String.hpp Tags.hpp Transposed.hpp TupleUtility.hpp - Utility.hpp + TypeTraits.hpp ValueCategory.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/amdis/common) diff --git a/src/amdis/common/ClonablePtr.hpp b/src/amdis/common/ClonablePtr.hpp deleted file mode 100644 index 2dcd9c35daf3f95ee9e49dc3caaba49c46b97f14..0000000000000000000000000000000000000000 --- a/src/amdis/common/ClonablePtr.hpp +++ /dev/null @@ -1,127 +0,0 @@ -#pragma once - -#include <memory> -#include <utility> - -#include <amdis/common/Utility.hpp> - -namespace AMDiS -{ - // A pointer class that deletes only when owning the pointer - template <class T> - class ClonablePtr - { - private: - struct alloc_tag {}; ///< hidden helper struct, used by \ref make - - public: - using Self = ClonablePtr; - using element_type = T; - - /// Default constructor, creates a non-owned nullptr - ClonablePtr() = default; - - /// Constructor from pointer. Can only be used via make method, - /// Transfers ownership. - ClonablePtr(owner<T>* p, alloc_tag) noexcept - : p(p) - , is_owner(true) - {} - - /// Constructor from reference - explicit ClonablePtr(T& ref) noexcept - : p(&ref) - , is_owner(false) - {} - - /// Constructor from std::unique_ptr - explicit ClonablePtr(std::unique_ptr<T>& ptr) - : p(ptr.release()) - , is_owner(true) - {} - - explicit ClonablePtr(std::unique_ptr<T>&& ptr) - : p(ptr.release()) - , is_owner(true) - {} - - /// Destructor, deletes in case of owner only - ~ClonablePtr() noexcept - { - if (is_owner) - delete p; - } - - /// Copy constructor, creates a clone of the pointed to object - ClonablePtr(Self const& that) noexcept( std::is_nothrow_copy_constructible<T>::value ) - : p(new T(*that.p)) - , is_owner(true) - {} - - /// Move constructor, copies the pointer only. - ClonablePtr(Self&& that) noexcept - : p(that.p) - , is_owner(that.is_owner) - { - that.p = nullptr; - that.is_owner = false; - } - - /// Copy and move assignment operator, using the copy-and-swap idiom - Self& operator=(Self that) noexcept - { - swap(that); - return *this; - } - - /// Factory method. creates a new Object of type T and stores the pointer. - template <class... Args> - static Self make(Args&&... args) - noexcept( std::is_nothrow_constructible<T, std::decay_t<Args>...>::value ) - { - return {new T(std::forward<Args>(args)...), Self::alloc_tag()}; - } - - /// Access-method by dereferencing - T& operator*() const noexcept - { - return *p; - } - - /// Access-method by pointer access - T* operator->() const noexcept - { - return p; - } - - /// retrieve the underlying pointer - T* get() const noexcept - { - return p; - } - - /// Test whether pointer is NULL - operator bool() const noexcept - { - return !(p == NULL); - } - - void swap(Self& that) noexcept - { - using std::swap; - swap(p, that.p); - swap(is_owner, that.is_owner); - } - - private: - T* p = nullptr; ///< managed pointer - bool is_owner = false; ///< true, if class is owner of pointer, false otherwise - }; - - template <class T> - void swap(ClonablePtr<T>& a, ClonablePtr<T>& b) noexcept - { - a.swap(b); - } - -} // end namespace AMDiS diff --git a/src/amdis/common/Concepts.hpp b/src/amdis/common/Concepts.hpp index c548cc02c6b147ecc1fd57a3e3fdfaab362e69c3..ed851525ac7b16cdb7201a2354d5333dd0cb8d12 100644 --- a/src/amdis/common/Concepts.hpp +++ b/src/amdis/common/Concepts.hpp @@ -6,7 +6,7 @@ #include <amdis/common/ConceptsBase.hpp> #include <amdis/common/Mpl.hpp> -#include <amdis/common/Utility.hpp> +#include <amdis/common/TypeTraits.hpp> namespace AMDiS { @@ -48,49 +48,6 @@ namespace AMDiS #ifndef DOXYGEN namespace Definition { - // a < b - struct LessThanComparable - { - template <class A, class B> - auto requires_(A&& a, B&& b) -> decltype( a < b ); - }; - - // a + b - struct Addable - { - template <class A, class B> - auto requires_(A&& a, B&& b) -> decltype( - Concepts::valid_expr( - a + b, - b + a - )); - }; - - // a - b - struct Subtractable - { - template <class A, class B> - auto requires_(A&& a, B&& b) -> decltype( a - b ); - }; - - // a * b - struct Multiplicable - { - template <class A, class B> - auto requires_(A&& a, B&& b) -> decltype( - Concepts::valid_expr( - a * b, - b * a - )); - }; - - // a / b - struct Divisible - { - template <class A, class B> - auto requires_(A&& a, B&& b) -> decltype( a / b ); - }; - // f(args...) struct Callable { @@ -98,16 +55,6 @@ namespace AMDiS auto requires_(F&& f, Args&&... args) -> decltype( f(std::forward<Args>(args)...)); }; - // f(args...) - struct Evaluable - { - template <class F, class... Args> - auto requires_(F&& f, Args&&... args) -> void_t< - decltype( f(std::forward<Args>(args)...)), - std::result_of_t<std::decay_t<F>(std::decay_t<Args>...)> - >; - }; - // idx[0] struct MultiIndex { @@ -125,34 +72,10 @@ namespace AMDiS #endif // DOXYGEN - /// \brief Argument `A` is (implicitly) convertible to arguemnt `B` and vice versa. - template <class A, class B > - constexpr bool Convertible = std::is_convertible<A,B>::value && std::is_convertible<B,A>::value; - /// Types are the same, up to decay of qualifiers template <class A, class B> constexpr bool Similar = Traits::IsSimilar<A, B>::value; - /// \brief Argument A is less-than comparable to type B, i.e. A < B is valid - template <class A, class B = A> - constexpr bool LessThanComparable = models<Definition::LessThanComparable(A, B)>; - - /// \brief Argument A is addable to type B, i.e. A + B is valid - template <class A, class B> - constexpr bool Addable = models<Definition::Addable(A, B)>; - - /// \brief Argument A is subtractable by type B, i.e. A - B is valid - template <class A, class B> - constexpr bool Subtractable = models<Definition::Subtractable(A, B)>; - - /// \brief Argument A is multiplicable by type B, i.e. A * B is valid - template <class A, class B> - constexpr bool Multiplicable = models<Definition::Multiplicable(A, B)>; - - /// \brief Argument A is divisible by type B, i.e. A / B is valid - template <class A, class B> - constexpr bool Divisible = models<Definition::Divisible(A, B)>; - /// \brief A Collable is a function `F` that can be called with arguments of type `Args...`. /** * To be used as follows: `Concepts::Collable<F, Args...>`. Returns true, if @@ -162,9 +85,6 @@ namespace AMDiS template <class F, class... Args> constexpr bool Callable = models<Definition::Callable(F, Args...)>; - template <class F, class... Args> - constexpr bool Evaluable = models<Definition::Evaluable(F, Args...)>; - /// \brief A Functor is a function `F` with signature `Signature`. /** diff --git a/src/amdis/utility/ConcurrentCache.hpp b/src/amdis/common/ConcurrentCache.hpp similarity index 100% rename from src/amdis/utility/ConcurrentCache.hpp rename to src/amdis/common/ConcurrentCache.hpp diff --git a/src/amdis/common/FieldMatVec.hpp b/src/amdis/common/FieldMatVec.hpp index a7d61c19836310ef5d7b737a9215b1ce545b81ad..165e98d6eb97e2871c6f993b3837609262eb0e64 100644 --- a/src/amdis/common/FieldMatVec.hpp +++ b/src/amdis/common/FieldMatVec.hpp @@ -5,6 +5,7 @@ #include <dune/common/diagonalmatrix.hh> #include <dune/common/fmatrix.hh> #include <dune/common/fvector.hh> +#include <dune/common/typetraits.hh> namespace std { diff --git a/src/amdis/common/FieldTraits.hpp b/src/amdis/common/FieldTraits.hpp deleted file mode 100644 index 226fd9b945c120edcd1f46981460204b234a5a82..0000000000000000000000000000000000000000 --- a/src/amdis/common/FieldTraits.hpp +++ /dev/null @@ -1,16 +0,0 @@ -#pragma once - -#include <dune/common/ftraits.hh> - -#include <amdis/common/Utility.hpp> - -namespace AMDiS -{ - template <class... T> - struct CommonFieldTraits - { - using field_type = CommonType_t<typename Dune::FieldTraits<T>::field_type...>; - using real_type = CommonType_t<typename Dune::FieldTraits<T>::real_type...>; - }; - -} // end namespace AMDiS diff --git a/src/amdis/utility/Filesystem.cpp b/src/amdis/common/Filesystem.cpp similarity index 92% rename from src/amdis/utility/Filesystem.cpp rename to src/amdis/common/Filesystem.cpp index 233ea4574edd04926abfd9900e96e6854501a0a0..77fddde1ff17a698900c76b3ea2a08cae41aa3b4 100644 --- a/src/amdis/utility/Filesystem.cpp +++ b/src/amdis/common/Filesystem.cpp @@ -17,10 +17,14 @@ #include <fstream> #include <string> -#include <amdis/Output.hpp> +#include <amdis/common/Algorithm.hpp> +#include <amdis/common/String.hpp> -template <class... Args> -void inline _ignore_(Args&&...) {} + +namespace { + template <class... Args> + void inline _ignore_(Args&&...) {} +} namespace AMDiS { namespace filesystem { @@ -158,7 +162,7 @@ bool create_directories(path const& p) switch (errno) { case ENOENT: - error_exit("parent didn't exist. Should not happen, since parent directory created before!"); + throw std::runtime_error("parent didn't exist. Should not happen, since parent directory created before!"); return false; break; case EEXIST: diff --git a/src/amdis/utility/Filesystem.hpp b/src/amdis/common/Filesystem.hpp similarity index 98% rename from src/amdis/utility/Filesystem.hpp rename to src/amdis/common/Filesystem.hpp index ecae9493ae8af99f8c698d2a49e80a5c6278a2c3..384aedd031356befc7c37a7c7aa22adabcb2675d 100644 --- a/src/amdis/utility/Filesystem.hpp +++ b/src/amdis/common/Filesystem.hpp @@ -3,8 +3,6 @@ #include <string> #include <vector> -#include <amdis/utility/String.hpp> - namespace AMDiS { namespace filesystem diff --git a/src/amdis/common/IndexSeq.hpp b/src/amdis/common/IndexSeq.hpp deleted file mode 100644 index 1d01b2d435b85af2cc97458e36bbaaf93c4e386c..0000000000000000000000000000000000000000 --- a/src/amdis/common/IndexSeq.hpp +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once - -#include <utility> - -namespace AMDiS -{ - /// Alias template to create a sequence of indices - template <std::size_t N> - using MakeSeq_t = std::make_index_sequence<N>; - -} // end namespace AMDiS diff --git a/src/amdis/common/Literals.hpp b/src/amdis/common/Literals.hpp index 7ea68ad4a27b73522397686536ff87ae0424183d..6e6906dcb5f199b8c06dd2efaa10f91ff9b9fbe6 100644 --- a/src/amdis/common/Literals.hpp +++ b/src/amdis/common/Literals.hpp @@ -1,8 +1,7 @@ #pragma once #include <cassert> - -#include <amdis/common/Mpl.hpp> +#include <type_traits> namespace AMDiS { @@ -27,7 +26,7 @@ namespace AMDiS std::size_t power = 1; const int N = sizeof...(digits); - for (std::size_t i = 0; i < N; ++i) { + for (int i = 0; i < N; ++i) { char c = arr[N - 1 - i]; result+= char2digit(c) * power; power *= 10u; @@ -42,7 +41,7 @@ namespace AMDiS template <char... digits> constexpr auto operator"" _c() { - return index_<Impl::string2num<digits...>()>; + return std::integral_constant<std::size_t,Impl::string2num<digits...>()>{}; } } // end namespace AMDiS diff --git a/src/amdis/common/Math.hpp b/src/amdis/common/Math.hpp index 8ff382dce17387dc7b65ddf0c65f63060f2ffc24..c01d0d9705ca6a3e5d2b1353fb3b5bd256549a70 100644 --- a/src/amdis/common/Math.hpp +++ b/src/amdis/common/Math.hpp @@ -4,7 +4,6 @@ #include <cmath> #include <cstdint> #include <limits> -#include <string> #include <type_traits> #include <dune/common/power.hh> @@ -17,7 +16,7 @@ namespace AMDiS template <class T> constexpr T abs(T const& a) { - return a >= 0 ? a : -a; + return a < 0 ? -a : a; } @@ -37,7 +36,7 @@ namespace AMDiS } - /// Implementation of the minimum of two values \f$ min(a,b)\f$ of any type + /// Implementation of the minimum of values \f$ min(a,b)\f$ of any type /// supporting the `<` relation. /// @{ @@ -62,7 +61,7 @@ namespace AMDiS /// @} - /// Implementation of the maximum of two values \f$ max(a,b)\f$ of any type + /// Implementation of the maximum of values \f$ max(a,b)\f$ of any type /// supporting the `>` relation. /// @{ template <class T0, class T1> @@ -85,34 +84,41 @@ namespace AMDiS /// @} - } // end namespace Math + // sum over empty set is zero + constexpr double sum() + { + return 0.0; + } +#ifndef AMDIS_HAS_CXX_FOLD_EXPRESSIONS + template <class T> + constexpr auto const& sum(T const& t) + { + return t; + } - template <class T> - inline void nullify(T& a) - { - a = 0; - } + template <class T0, class T1> + constexpr auto sum(T0 const& t0, T1 const& t1) + { + return t0 + t1; + } - inline void nullify(std::string& s) - { - s = ""; - } + template <class T0, class... Ts> + constexpr auto sum(T0 const& t0, Ts const&... ts) + { + return t0 + sum(ts...); + } +#else + template <class... Ts> + constexpr auto sum(Ts const&... ts) + { + return (ts + ...); + } +#endif + + } // end namespace Math template <class T> constexpr T threshold = std::numeric_limits<T>::epsilon(); - - /// Calculates factorial of i - constexpr std::uint64_t factorial(std::uint64_t i) - { - return i <= 1 ? 1 : i * factorial(i - 1); - } - - /// check for inf and nan values - inline bool isNumber(double val) - { - return !std::isnan(val) && !std::isinf(val); - } - } // end namespace AMDiS diff --git a/src/amdis/common/MultiTypeMatrix.hpp b/src/amdis/common/MultiTypeMatrix.hpp index 805150a2dd50fe5fe08b6a83bd03f93bdd939463..2a512bda65ae25d5069e285e46511cca2c8fbfbe 100644 --- a/src/amdis/common/MultiTypeMatrix.hpp +++ b/src/amdis/common/MultiTypeMatrix.hpp @@ -1,15 +1,18 @@ #pragma once #include <tuple> +#include <type_traits> + +#include <dune/common/ftraits.hh> #include <amdis/common/Concepts.hpp> -#include <amdis/common/FieldTraits.hpp> #include <amdis/common/Loops.hpp> #include <amdis/common/Math.hpp> #include <amdis/common/Mpl.hpp> #include <amdis/common/MultiTypeVector.hpp> -#include <amdis/common/Size.hpp> -#include <amdis/utility/MultiIndex.hpp> +#include <amdis/common/StaticSize.hpp> +#include <amdis/common/TypeTraits.hpp> +#include <amdis/typetree/MultiIndex.hpp> namespace AMDiS { @@ -23,8 +26,8 @@ namespace Dune template <class... Rows> struct FieldTraits<AMDiS::MultiTypeMatrix<Rows...>> { - using field_type = typename AMDiS::CommonFieldTraits<Rows...>::field_type; - using real_type = typename AMDiS::CommonFieldTraits<Rows...>::real_type; + using field_type = std::common_type_t<typename Dune::FieldTraits<Rows>::field_type...>; + using real_type = std::common_type_t<typename Dune::FieldTraits<Rows>::real_type...>; }; } diff --git a/src/amdis/common/MultiTypeVector.hpp b/src/amdis/common/MultiTypeVector.hpp index d2f89d548638acb04031815dd935abb9318d1bad..bfe4a24f058e61e6eaa958aad289e4bb08e4142f 100644 --- a/src/amdis/common/MultiTypeVector.hpp +++ b/src/amdis/common/MultiTypeVector.hpp @@ -1,14 +1,16 @@ #pragma once #include <tuple> +#include <type_traits> +#include <dune/common/ftraits.hh> #include <dune/functions/common/indexaccess.hh> #include <amdis/common/Concepts.hpp> -#include <amdis/common/FieldTraits.hpp> #include <amdis/common/Loops.hpp> #include <amdis/common/Mpl.hpp> -#include <amdis/common/Size.hpp> +#include <amdis/common/StaticSize.hpp> +#include <amdis/common/TypeTraits.hpp> namespace AMDiS { @@ -22,8 +24,8 @@ namespace Dune template <class... FV> struct FieldTraits<AMDiS::MultiTypeVector<FV...>> { - using field_type = typename AMDiS::CommonFieldTraits<FV...>::field_type; - using real_type = typename AMDiS::CommonFieldTraits<FV...>::real_type; + using field_type = std::common_type_t<typename Dune::FieldTraits<FV>::field_type...>; + using real_type = std::common_type_t<typename Dune::FieldTraits<FV>::real_type...>; }; } diff --git a/src/amdis/common/ScalarTypes.hpp b/src/amdis/common/ScalarTypes.hpp deleted file mode 100644 index 3f60c4cb1dd683b4f26d78e7fdf2089ea8139cbb..0000000000000000000000000000000000000000 --- a/src/amdis/common/ScalarTypes.hpp +++ /dev/null @@ -1,40 +0,0 @@ -#pragma once - -// std c++ headers -#include <type_traits> - -namespace AMDiS -{ - namespace Traits - { - template <class T> - struct IsIntegral - : public std::is_integral<std::decay_t<T>> {}; - - template <class T> - struct IsArithmetic - : public std::is_arithmetic<std::decay_t<T>> {}; - - } // end namespace traits - - namespace Concepts - { - /** \addtogroup Concepts - * @{ - **/ - - /// \brief The types following the std type-trait \ref std::is_integral are - /// categorized as *integral types*. - template <class T> - constexpr bool Integral = Traits::IsIntegral<T>::value; - - /// \brief The types following the std type-trait \ref std::is_arithmetic are - /// categorized as *arithmetic types*. - template <class T> - constexpr bool Arithmetic = Traits::IsArithmetic<T>::value; - - /** @} **/ - - } // end namespace Concepts - -} // end namespace AMDiS diff --git a/src/amdis/common/Size.hpp b/src/amdis/common/StaticSize.hpp similarity index 100% rename from src/amdis/common/Size.hpp rename to src/amdis/common/StaticSize.hpp diff --git a/src/amdis/common/String.cpp b/src/amdis/common/String.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6a5b28f959390cdc482b3a60f580cee6701a27a1 --- /dev/null +++ b/src/amdis/common/String.cpp @@ -0,0 +1,70 @@ +#include "String.hpp" + +namespace AMDiS +{ + /// convert all characters in a string to upper case + std::string to_upper(std::string input) + { + for (auto& c : input) + c = static_cast<char>(std::toupper(static_cast<unsigned char>(c))); + return input; + } + + /// convert all characters in a string to upper case + std::string to_lower(std::string input) + { + for (auto& c : input) + c = static_cast<char>(std::tolower(static_cast<unsigned char>(c))); + return input; + } + + /// trim a string from the left + std::string& ltrim(std::string& str) + { + auto it = std::find_if(str.begin(), str.end(), [](char ch) + { + return !std::isspace<char>(ch, std::locale::classic()); + }); + str.erase(str.begin() , it); + return str; + } + + /// trim a string from the right + std::string& rtrim(std::string& str) + { + auto it = std::find_if(str.rbegin(), str.rend(), [](char ch) + { + return !std::isspace<char>(ch, std::locale::classic()); + }); + str.erase(it.base(), str.end()); + return str; + } + + /// trim a string from both sides + std::string& trim(std::string& str) + { + return ltrim(rtrim(str)); + } + + /// trim a (copy of the) string from both sides + std::string trim_copy(std::string const& str) + { + auto s = str; + return trim(s); + } + + /// Replace all occurences of substring `from` with `to` in source `str`. + void replaceAll(std::string& str, std::string const& from, std::string const& to) + { + if (from.empty()) + return; + + typename std::string::size_type start_pos = 0; + while ((start_pos = str.find(from, start_pos)) != std::string::npos) + { + str.replace(start_pos, from.length(), to); + start_pos += to.length(); + } + } + +} // end namspace AMDiS diff --git a/src/amdis/common/String.hpp b/src/amdis/common/String.hpp new file mode 100644 index 0000000000000000000000000000000000000000..01c3f104accafb108e3216db9b6c55a50e78c3e0 --- /dev/null +++ b/src/amdis/common/String.hpp @@ -0,0 +1,31 @@ +#pragma once + +#include <algorithm> +#include <cctype> +#include <locale> +#include <string> + +namespace AMDiS +{ + /// convert all characters in a string to upper case + std::string to_upper(std::string input); + + /// convert all characters in a string to upper case + std::string to_lower(std::string input); + + /// trim a string from the left + std::string& ltrim(std::string& str); + + /// trim a string from the right + std::string& rtrim(std::string& str); + + /// trim a string from both sides + std::string& trim(std::string& str); + + /// trim a (copy of the) string from both sides + std::string trim_copy(std::string const& str); + + /// Replace all occurences of substring `from` with `to` in source `str`. + void replaceAll(std::string& str, std::string const& from, std::string const& to); + +} // end namspace AMDiS diff --git a/src/amdis/common/TupleUtility.hpp b/src/amdis/common/TupleUtility.hpp index 8b10ec3fc8720e94760cc1d409dcaa536c52b9f5..2f6aaead244295067097262ac55f60dcae9372ff 100644 --- a/src/amdis/common/TupleUtility.hpp +++ b/src/amdis/common/TupleUtility.hpp @@ -2,13 +2,10 @@ #include <tuple> #include <type_traits> +#include <utility> #include <dune/common/hash.hh> -#include <amdis/common/IndexSeq.hpp> -#include <amdis/common/Mpl.hpp> -#include <amdis/common/Utility.hpp> - namespace AMDiS { namespace Impl @@ -35,207 +32,4 @@ namespace AMDiS } // end namespace Impl - namespace Impl - { - template <class Tuple, std::size_t N> - struct ConstructTuple - { - // add arg to repeated constructor argument list - template <class Arg, class... Args> - static Tuple make(Arg&& arg, Args&&... args) - { - return ConstructTuple<Tuple, N-1>::make( - std::forward<Arg>(arg), std::forward<Arg>(arg), std::forward<Args>(args)...); - } - }; - - template <class Tuple> - struct ConstructTuple<Tuple, 1> - { - template <class... Args> - static Tuple make(Args&&... args) - { - static_assert(std::tuple_size<Tuple>::value == sizeof...(args), - "Nr. of argument != tuple-size"); - return Tuple{std::forward<Args>(args)...}; - } - }; - - template <class Tuple> - struct ConstructTuple<Tuple, 0> - { - template <class... Args> - static Tuple make(Args&&... args) - { - static_assert(std::tuple_size<Tuple>::value == 0, - "Construction of empty tuples with empty argument list only!"); - return Tuple{}; - } - }; - - - template <class Tuple> - struct FoldTuples - { - // add arg to repeated constructor argument list - template <std::size_t... Is, class... Tuples> - static Tuple make(Indices<Is...>, Tuples&&... tuples) - { - return Tuple{make_element(index_<Is>, std::forward<Tuples>(tuples)...)...}; - } - - template <std::size_t I, class... Tuples> - static std::tuple_element_t<I, Tuple> make_element(index_t<I>, Tuples&&... tuples) - { - using ::AMDiS::get; - return std::tuple_element_t<I, Tuple>{get<I>(std::forward<Tuples>(tuples))...}; - } - }; - - } // end namespace Impl - - - /// Construct a tuple with each element constructed by the same argument arg. - /// Returns tuple { tuple_element_t<0>(arg), tuple_element_t<1>(arg), ... } - template <class Tuple, class Arg> - Tuple constructTuple(Arg&& arg) - { - return Impl::ConstructTuple<Tuple, std::tuple_size<Tuple>::value>::make( - std::forward<Arg>(arg)); - } - - /// Construct a tuple of tuples, by folding a list of tuples of the same size. - /// Return tuple { {arg0[0], arg1[0], arg2[0], ...}, {arg0[1], arg1[1], arg2[1], ...}, ...} - template <class Tuple, class... Args> - Tuple foldTuples(Args&&... args) - { - return Impl::FoldTuples<Tuple>::make(MakeSeq_t<std::tuple_size<Tuple>::value>(), - std::forward<Args>(args)...); - } - - - namespace Impl - { - template <template<class> class Base, class Tuple, class Indices> struct MakeTuple; - - template <template<class> class Base, class Tuple, std::size_t... I> - struct MakeTuple<Base, Tuple, Indices<I...>> - { - using type = std::tuple<Base<std::tuple_element_t<I, Tuple>>...>; - }; - - } // end namespace Impl - - - /// Constructs tuple type, by wrapping Base around the tuple elements. - /// Returns tuple type tuple<Base<tuple_element_t<0>>, Base<tuple_element_t<1>>, ...> - template <template<class> class Base, class Tuple> - using MakeTuple_t = - typename Impl::MakeTuple<Base, Tuple, MakeSeq_t<std::tuple_size<Tuple>::value>>::type; - - - namespace Impl - { - template <template<class,class> class Base, class Tuple1, class Tuple2, class Indices> struct MakeTuple2; - - template <template<class,class> class Base, class Tuple1, class Tuple2, std::size_t... I> - struct MakeTuple2<Base, Tuple1, Tuple2, Indices<I...>> - { - using type = std::tuple<Base<std::tuple_element_t<I, Tuple1>, std::tuple_element_t<I, Tuple2>>...>; - }; - - } // end namespace Impl - - - /// Constructs tuple type, by wrapping Base around the tuple elements. - /// Returns tuple type tuple<Base<tuple_element_t<0,T1>,tuple_element_t<0,T2>>, Base<tuple_element_t<1,T1>,tuple_element_t<1,T2>>, ...> - template <template<class,class> class Base, class Tuple1, class Tuple2> - using MakeTuple2_t = - typename Impl::MakeTuple2<Base, Tuple1, Tuple2, MakeSeq_t<std::tuple_size<Tuple1>::value>>::type; - - - namespace Impl - { - template <template<class...> class Base, class Tuple, class Indices> struct ExpandTuple; - - template <template<class...> class Base, class Tuple, std::size_t... I> - struct ExpandTuple<Base, Tuple, Indices<I...>> - { - using type = Base<std::tuple_element_t<I, Tuple>...>; - }; - - } // end namespace Impl - - - /// Expands tuple element types into template list of Base class. - /// Returns Base<tuple_element<0>, tuple_element<1>, ...> - template <template<class...> class Base, class Tuple> - using ExpandTuple_t = - typename Impl::ExpandTuple<Base, Tuple, MakeSeq_t<std::tuple_size<Tuple>::value>>::type; - - - namespace Impl - { - template <class T, class Indices> struct RepeatedTuple; - - template <class T, std::size_t... I> - struct RepeatedTuple<T, Indices<I...>> - { - template <std::size_t, class U> using Id = U; - using type = std::tuple<Id<I, T>...>; - }; - - } // end namespace Impl - - /// Construct tuple of N times type T. - /// Returns tuple<T, T, T, ...> - template <std::size_t N, class T> - using Repeat_t = - typename Impl::RepeatedTuple<T, MakeSeq_t<N>>::type; - - - - - namespace Impl - { - template <template<class> class Base, class Tuple, class Indices> struct MapTuple; - - template <template<class> class Base, class Tuple, std::size_t... I> - struct MapTuple<Base, Tuple, Indices<I...>> - { - using type = std::tuple<typename Base<std::tuple_element_t<I, Tuple>>::type...>; - }; - - } // end namespace Impl - - /// Constructs tuple type, by wrapping Base around the tuple elements. - /// Returns tuple type tuple<Base<tuple_element_t<0>>::type, Base<tuple_element_t<1>>::type, ...> - template <template<class> class Base, class Tuple> - using MapTuple_t = - typename Impl::MapTuple<Base, Tuple, MakeSeq_t<std::tuple_size<Tuple>::value>>::type; - - - template <class Functor, class Tuples, std::size_t I, std::size_t... J> - auto mapTuple(Functor f, Tuples&& tuples, index_t<I>, Indices<J...>) - { - return f(std::get<I>(std::get<J>(std::forward<Tuples>(tuples)))...); - } - - template <class Functor, class Tuples, std::size_t... I> - auto mapTuple(Functor f, Tuples&& tuples, Indices<I...>) - { - return std::make_tuple(mapTuple(f, std::forward<Tuples>(tuples), index_<I>, - MakeSeq_t<std::tuple_size<std::decay_t<Tuples>>::value>{})...); - } - - // construction method to construct a new tuple by applying a functor to the elements - // of a given tuple - template <class Functor, class Tuple0, class... Tuples> - auto mapTuple(Functor f, Tuple0&& tuple0, Tuples&&... tuples) - { - return mapTuple(f, std::make_tuple(std::forward<Tuple0>(tuple0), std::forward<Tuples>(tuples)...), - MakeSeq_t<std::tuple_size<std::decay_t<Tuple0>>::value>{}); - } - - } // end namespace AMDiS diff --git a/src/amdis/common/TypeTraits.hpp b/src/amdis/common/TypeTraits.hpp new file mode 100644 index 0000000000000000000000000000000000000000..4739771297b15867f290f8bc2993973925899c23 --- /dev/null +++ b/src/amdis/common/TypeTraits.hpp @@ -0,0 +1,55 @@ +#pragma once + +#include <memory> +#include <type_traits> +#include <vector> + +#if AMDIS_HAS_CXX_CONSTEXPR_IF +#define IF_CONSTEXPR if constexpr +#else +#define IF_CONSTEXPR if +#endif + +namespace AMDiS +{ + namespace Impl + { + template <class T> + struct UnderlyingType + { + using type = T; + }; + + template <class T> + struct UnderlyingType<std::reference_wrapper<T>> + { + using type = T; + }; + } + + template <class T> + using Underlying_t = typename Impl::UnderlyingType<T>::type; + + // --------------------------------------------------------------------------- + + /// A variadic type list + template <class... Ts> + struct Types {}; + + template <class... Ts> + using Types_t = Types<std::decay_t<Ts>...>; + + + /// Alias that indicates ownership of resources + template <class T> + using owner = T; + + + /// Create a unique_ptr by copy/move construction + template <class Obj> + auto makeUniquePtr(Obj&& obj) + { + return std::make_unique<std::decay_t<Obj>>(std::forward<Obj>(obj)); + } + +} // end namespace AMDiS diff --git a/src/amdis/common/Utility.hpp b/src/amdis/common/Utility.hpp deleted file mode 100644 index ebcc6ebc0eea088b677e42118d8603c24d9df490..0000000000000000000000000000000000000000 --- a/src/amdis/common/Utility.hpp +++ /dev/null @@ -1,120 +0,0 @@ -#pragma once - -#include <memory> -#include <type_traits> -#include <vector> - -#if AMDIS_HAS_CXX_CONSTEXPR_IF -#define IF_CONSTEXPR if constexpr -#else -#define IF_CONSTEXPR if -#endif - -namespace AMDiS -{ - namespace Impl - { - template <class T> - struct UnderlyingType - { - using type = std::decay_t<T>; - }; - - template <class T> - struct UnderlyingType<std::reference_wrapper<T>> - { - using type = std::decay_t<T>; - }; - } - - template <class T> - using Underlying_t = typename Impl::UnderlyingType<T>::type; - - - namespace Impl - { - template <class T0, class... Ts> - struct CommonType - { - using type = std::common_type_t<T0, typename CommonType<Ts...>::type>; - }; - - template <class T0> - struct CommonType<T0> - { - using type = T0; - }; - } - - template <class... T> - using CommonType_t = typename Impl::CommonType<T...>::type; - - - /// Create a unique_ptr by copy/move construction - template <class Obj> - auto makeUniquePtr(Obj&& obj) - { - return std::make_unique<std::decay_t<Obj>>(std::forward<Obj>(obj)); - } - - // --------------------------------------------------------------------------- - - // base template for tuple size, must implement a static value member - template <class TupleType> - struct TupleSize; - - // utility constant returning the value of the tuple size - template <class TupleType> - constexpr std::size_t TupleSize_v = TupleSize<TupleType>::value; - - - // base template for retrieving the tuple element type, must implement the type member `type` - template <size_t I, class TupleType> - struct TupleElement; - - // base template for retrieving the tuple element type - template <size_t I, class TupleType> - using TupleElement_t = typename TupleElement<I, TupleType>::type; - - - /// A variadic type list - template <class... Ts> - struct Types {}; - - template <class... Ts> - using Types_t = Types<std::decay_t<Ts>...>; - - - template <class... T> - struct TupleSize<Types<T...>> - : std::integral_constant<std::size_t, sizeof...(T)> {}; - - template <size_t I, class Head, class... Tail> - struct TupleElement<I, Types<Head, Tail...>> - { - using type = typename TupleElement<I-1, Types<Tail...>>::type; - }; - - template <class Head, class... Tail> - struct TupleElement<0, Types<Head, Tail...>> - { - using type = Head; - }; - - - /// Alias that indicates ownership of resources - template <class T> - using owner = T; - - - // --------------------------------------------------------------------------- - - - /// generalization of get<tuple>, get<array> for vectors - template <std::size_t I, class T, class A> - T const& get(std::vector<T,A> const& vec) - { - return vec[I]; - } - -} // end namespace AMDiS diff --git a/src/amdis/gridfunctions/CMakeLists.txt b/src/amdis/gridfunctions/CMakeLists.txt index 328773dbb331542870e5923ecb608e05839620d7..e1a017f5b713a6bdd5bf8a0755a25fe2572a29ac 100644 --- a/src/amdis/gridfunctions/CMakeLists.txt +++ b/src/amdis/gridfunctions/CMakeLists.txt @@ -10,6 +10,5 @@ install(FILES DOFVectorView.hpp FunctorGridFunction.hpp GridFunctionConcepts.hpp - Integrate.hpp OperationsGridFunction.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/amdis/gridfunctions) diff --git a/src/amdis/gridfunctions/ConstantGridFunction.hpp b/src/amdis/gridfunctions/ConstantGridFunction.hpp index cbecac1295bfb8a4b091b7bda2bd6ef941a52b60..936f02edc6109a3157d09c3c67259b3990db8353 100644 --- a/src/amdis/gridfunctions/ConstantGridFunction.hpp +++ b/src/amdis/gridfunctions/ConstantGridFunction.hpp @@ -8,7 +8,7 @@ #include <dune/common/fvector.hh> #include <dune/functions/common/defaultderivativetraits.hh> -#include <amdis/common/Utility.hpp> +#include <amdis/common/TypeTraits.hpp> #include <amdis/gridfunctions/AnalyticGridFunction.hpp> #include <amdis/gridfunctions/GridFunctionConcepts.hpp> diff --git a/src/amdis/gridfunctions/DiscreteFunction.hpp b/src/amdis/gridfunctions/DiscreteFunction.hpp index 4e853eac9ec3839ca6bc8b62f27e1eaae9f5adfa..47d9d07eef9265e458a3193faa709504fe7fe848 100644 --- a/src/amdis/gridfunctions/DiscreteFunction.hpp +++ b/src/amdis/gridfunctions/DiscreteFunction.hpp @@ -10,8 +10,8 @@ #include <dune/typetree/childextraction.hh> #include <amdis/GridFunctions.hpp> -#include <amdis/utility/FiniteElementType.hpp> -#include <amdis/utility/TreePath.hpp> +#include <amdis/typetree/FiniteElementType.hpp> +#include <amdis/typetree/TreePath.hpp> namespace AMDiS { diff --git a/src/amdis/gridfunctions/DiscreteFunction.inc.hpp b/src/amdis/gridfunctions/DiscreteFunction.inc.hpp index fa93de99d339c09e0069b6e1a49b6ad67393eef1..069e67c610ca5e9fea508daad154b62e5542fd1d 100644 --- a/src/amdis/gridfunctions/DiscreteFunction.inc.hpp +++ b/src/amdis/gridfunctions/DiscreteFunction.inc.hpp @@ -1,7 +1,7 @@ #pragma once #include <amdis/common/FieldMatVec.hpp> -#include <amdis/LocalBasisCache.hpp> +#include <amdis/utility/LocalBasisCache.hpp> #include <dune/grid/utility/hierarchicsearch.hh> diff --git a/src/amdis/gridfunctions/FunctorGridFunction.hpp b/src/amdis/gridfunctions/FunctorGridFunction.hpp index 88a6b27d689d807eb1f677fd2f4f193eeaafa17f..99688cf23908e5e092400f35a3c38d89ae64d3c2 100644 --- a/src/amdis/gridfunctions/FunctorGridFunction.hpp +++ b/src/amdis/gridfunctions/FunctorGridFunction.hpp @@ -6,7 +6,6 @@ #include <dune/common/std/apply.hh> #include <amdis/Operations.hpp> -#include <amdis/common/IndexSeq.hpp> #include <amdis/common/Loops.hpp> #include <amdis/common/Mpl.hpp> #include <amdis/gridfunctions/GridFunctionConcepts.hpp> diff --git a/src/amdis/gridfunctions/GridFunctionConcepts.hpp b/src/amdis/gridfunctions/GridFunctionConcepts.hpp index bd67e4b35769380ec8feb19675423d251fda1d84..ac073736646f08d9a57b264f4693e6c58cded617 100644 --- a/src/amdis/gridfunctions/GridFunctionConcepts.hpp +++ b/src/amdis/gridfunctions/GridFunctionConcepts.hpp @@ -3,7 +3,6 @@ #include <dune/common/typeutilities.hh> #include <amdis/common/Concepts.hpp> -#include <amdis/common/IndexSeq.hpp> #include <amdis/common/Mpl.hpp> namespace AMDiS diff --git a/src/amdis/io/CMakeLists.txt b/src/amdis/io/CMakeLists.txt deleted file mode 100644 index be7489416ec538ca476e00c69d360559f54d24e2..0000000000000000000000000000000000000000 --- a/src/amdis/io/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -#install headers - -install(FILES - FileWriterInterface.hpp -DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/amdis/io) diff --git a/src/amdis/linear_algebra/HierarchicWrapper.hpp b/src/amdis/linear_algebra/HierarchicWrapper.hpp deleted file mode 100644 index 79f1f4c1b576b65bcffe2787fd35cf0deb536a6e..0000000000000000000000000000000000000000 --- a/src/amdis/linear_algebra/HierarchicWrapper.hpp +++ /dev/null @@ -1,120 +0,0 @@ -#pragma once - -#if HAVE_MTL -#include <boost/numeric/mtl/mtl_fwd.hpp> -#endif - -#include <dune/functions/functionspacebases/sizeinfo.hh> - -#include <amdis/utility/MultiIndex.hpp> - -namespace AMDiS -{ - template <class Matrix> - class HierarchicMatrixWrapper - { - public: - explicit HierarchicMatrixWrapper(Matrix& matrix) - : matrix_(matrix) - {} - - template <class RowIndex, class ColIndex> - auto& operator()(RowIndex const& row, ColIndex const& col) - { - return matrix_(flatMultiIndex(row), flatMultiIndex(col)); - } - - template <class RowIndex, class ColIndex> - auto const& operator()(RowIndex const& row, ColIndex const& col) const - { - return matrix_(flatMultiIndex(row), flatMultiIndex(col)); - } - - - private: - Matrix& matrix_; - }; - - template <class Matrix> - HierarchicMatrixWrapper<Matrix> hierarchicMatrixWrapper(Matrix& matrix) - { - return {matrix}; - } - - - template <class Vector> - class HierarchicVectorWrapper - { - public: - explicit HierarchicVectorWrapper(Vector& vector) - : vector_(vector) - {} - - template <class Index> - auto& operator[](Index const& idx) - { - return vector_[flatMultiIndex(idx)]; - } - - template <class Index> - auto const& operator[](Index const& idx) const - { - return vector_[flatMultiIndex(idx)]; - } - - template <class Basis> - void resize(Dune::Functions::SizeInfo<Basis> const& s) - { - resizeImpl(vector_, s); - } - - std::size_t size() const - { - return sizeImpl(vector_); - } - - protected: - - template <class Vec, class Basis> - void_t<decltype( std::declval<Vec>().resize(std::size_t(0)) )> - resizeImpl(Vec& vec, Dune::Functions::SizeInfo<Basis> const& s) - { - vec.resize(std::size_t(s)); - } - - template <class Vec, class Basis> - void_t<decltype( std::declval<Vec>().change_dim(std::size_t(0)) )> - resizeImpl(Vec& vec, Dune::Functions::SizeInfo<Basis> const& s) - { - vec.change_dim(std::size_t(s)); - } - -#if HAVE_MTL - template <class... Params> - std::size_t sizeImpl(mtl::vec::dense_vector<Params...> const& v) const - { - return mtl::size(v); - } -#endif - - template <class V> - using HasSizeMember = decltype(std::declval<V>().size()); - - template <class V, - std::enable_if_t<Dune::Std::is_detected<HasSizeMember, V>::value, int> = 0> - std::size_t sizeImpl(V const& v) const - { - return v.size(); - } - - private: - Vector& vector_; - }; - - template <class Vector> - auto hierarchicVectorWrapper(Vector& vector) - { - return HierarchicVectorWrapper<Vector>{vector}; - } - -} // end namespace AMDiS diff --git a/src/amdis/linear_algebra/CMakeLists.txt b/src/amdis/linearalgebra/CMakeLists.txt similarity index 80% rename from src/amdis/linear_algebra/CMakeLists.txt rename to src/amdis/linearalgebra/CMakeLists.txt index 7027481fbf5e2d205a98cf50c6df0b359fb1f492..29239f9e4e449e54bcc614ab219dfb12e52ea922 100644 --- a/src/amdis/linear_algebra/CMakeLists.txt +++ b/src/amdis/linearalgebra/CMakeLists.txt @@ -6,13 +6,12 @@ install(FILES DOFVectorBase.hpp DOFVectorBase.inc.hpp DOFVectorInterface.hpp - HierarchicWrapper.hpp LinearSolver.hpp LinearSolverInterface.hpp PreconditionerInterface.hpp RunnerInterface.hpp SolverInfo.hpp -DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/amdis/linear_algebra) +DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/amdis/linearalgebra) add_subdirectory("eigen") add_subdirectory("istl") diff --git a/src/amdis/linear_algebra/Common.hpp b/src/amdis/linearalgebra/Common.hpp similarity index 100% rename from src/amdis/linear_algebra/Common.hpp rename to src/amdis/linearalgebra/Common.hpp diff --git a/src/amdis/linear_algebra/Constraints.hpp b/src/amdis/linearalgebra/Constraints.hpp similarity index 93% rename from src/amdis/linear_algebra/Constraints.hpp rename to src/amdis/linearalgebra/Constraints.hpp index c774ff771eab520813a45402b5169d221dfc28eb..f539113b9b32a3aaa4ede4e788351bfdfec5857d 100644 --- a/src/amdis/linear_algebra/Constraints.hpp +++ b/src/amdis/linearalgebra/Constraints.hpp @@ -1,6 +1,6 @@ #pragma once -#include <amdis/linear_algebra/DOFMatrixBase.hpp> +#include <amdis/linearalgebra/DOFMatrixBase.hpp> namespace AMDiS { diff --git a/src/amdis/linear_algebra/DOFMatrixBase.hpp b/src/amdis/linearalgebra/DOFMatrixBase.hpp similarity index 94% rename from src/amdis/linear_algebra/DOFMatrixBase.hpp rename to src/amdis/linearalgebra/DOFMatrixBase.hpp index 2c55312bbf4238f4c81505ee8ccddad028988319..906deface3c0a599e3539332d8f7ddd2c58f7ea8 100644 --- a/src/amdis/linear_algebra/DOFMatrixBase.hpp +++ b/src/amdis/linearalgebra/DOFMatrixBase.hpp @@ -4,10 +4,10 @@ #include <dune/common/timer.hh> -#include <amdis/LocalAssemblerList.hpp> +#include <amdis/OperatorList.hpp> #include <amdis/common/Math.hpp> -#include <amdis/utility/MultiIndex.hpp> -#include <amdis/utility/TreePath.hpp> +#include <amdis/typetree/MultiIndex.hpp> +#include <amdis/typetree/TreePath.hpp> namespace AMDiS { @@ -41,6 +41,9 @@ namespace AMDiS operators_.init(rowBasis, colBasis); } + DOFMatrixBase(DOFMatrixBase const&) = delete; + DOFMatrixBase(DOFMatrixBase&&) = delete; + /// Return the row-basis \ref rowBasis of the matrix RowBasis const& rowBasis() const { diff --git a/src/amdis/linear_algebra/DOFMatrixBase.inc.hpp b/src/amdis/linearalgebra/DOFMatrixBase.inc.hpp similarity index 94% rename from src/amdis/linear_algebra/DOFMatrixBase.inc.hpp rename to src/amdis/linearalgebra/DOFMatrixBase.inc.hpp index adde13479ec5b705a466c4ef69fd1fccd20ee5f0..647d2d7ff3ef67eeccd8203112151cc8c42025cb 100644 --- a/src/amdis/linear_algebra/DOFMatrixBase.inc.hpp +++ b/src/amdis/linearalgebra/DOFMatrixBase.inc.hpp @@ -1,10 +1,9 @@ #pragma once #include <amdis/Assembler.hpp> -#include <amdis/LocalAssembler.hpp> #include <amdis/LocalOperator.hpp> -#include <amdis/common/Utility.hpp> -#include <amdis/utility/Visitor.hpp> +#include <amdis/typetree/Visitor.hpp> +#include <amdis/utility/AssembleOperators.hpp> namespace AMDiS { @@ -61,7 +60,7 @@ addOperator(ContextTag contextTag, PreOperator const& preOp, using Context = typename ContextTag::type; auto op = makeLocalOperator<Context>(preOp, rowBasis_->gridView()); - auto localAssembler = makeUniquePtr(makeLocalAssembler<Context>(std::move(op), i, j)); + auto localAssembler = makeUniquePtr(makeAssembler<Context>(std::move(op), i, j)); operators_[i][j].push(contextTag, std::move(localAssembler)); } diff --git a/src/amdis/linear_algebra/DOFVectorBase.hpp b/src/amdis/linearalgebra/DOFVectorBase.hpp similarity index 94% rename from src/amdis/linear_algebra/DOFVectorBase.hpp rename to src/amdis/linearalgebra/DOFVectorBase.hpp index 7f8049957bd21e0bdd4374d2e45cd2e2daae56be..3c8c32e76fd8ca09f1af2c4f83a23bb9a1431470 100644 --- a/src/amdis/linear_algebra/DOFVectorBase.hpp +++ b/src/amdis/linearalgebra/DOFVectorBase.hpp @@ -3,16 +3,16 @@ #include <cmath> #include <utility> +#include <dune/common/typetraits.hh> #include <dune/functions/functionspacebases/sizeinfo.hh> #include <amdis/DataTransfer.hpp> #include <amdis/GridTransferManager.hpp> -#include <amdis/LocalAssemblerList.hpp> +#include <amdis/OperatorList.hpp> #include <amdis/common/Math.hpp> -#include <amdis/common/ScalarTypes.hpp> -#include <amdis/linear_algebra/DOFVectorInterface.hpp> -#include <amdis/utility/MultiIndex.hpp> -#include <amdis/utility/TreePath.hpp> +#include <amdis/linearalgebra/DOFVectorInterface.hpp> +#include <amdis/typetree/MultiIndex.hpp> +#include <amdis/typetree/TreePath.hpp> namespace AMDiS { @@ -102,9 +102,9 @@ namespace AMDiS Self& operator=(Self&& that) = default; /// Sets each DOFVector to the scalar \p value. - template <class Scalar, - std::enable_if_t<Concepts::Arithmetic<Scalar>, int> = 0> - Self& operator=(Scalar value) + template <class Number, + std::enable_if_t<Dune::IsNumber<Number>::value, int> = 0> + Self& operator=(Number value) { backend_.set(value); return *this; diff --git a/src/amdis/linear_algebra/DOFVectorBase.inc.hpp b/src/amdis/linearalgebra/DOFVectorBase.inc.hpp similarity index 91% rename from src/amdis/linear_algebra/DOFVectorBase.inc.hpp rename to src/amdis/linearalgebra/DOFVectorBase.inc.hpp index 7de4dcde61482e36d7991b920014dad31e3b3161..47264d540934cc02500dd37fb3b170396e20c836 100644 --- a/src/amdis/linear_algebra/DOFVectorBase.inc.hpp +++ b/src/amdis/linearalgebra/DOFVectorBase.inc.hpp @@ -1,10 +1,9 @@ #pragma once #include <amdis/Assembler.hpp> -#include <amdis/LocalAssembler.hpp> #include <amdis/LocalOperator.hpp> -#include <amdis/common/Utility.hpp> -#include <amdis/utility/Visitor.hpp> +#include <amdis/typetree/Visitor.hpp> +#include <amdis/utility/AssembleOperators.hpp> namespace AMDiS { @@ -52,7 +51,7 @@ addOperator(ContextTag contextTag, PreOperator const& preOp, TreePath path) using Context = typename ContextTag::type; auto op = makeLocalOperator<Context>(preOp, basis_->gridView()); - auto localAssembler = makeUniquePtr(makeLocalAssembler<Context>(std::move(op), i)); + auto localAssembler = makeUniquePtr(makeAssembler<Context>(std::move(op), i)); operators_[i].push(contextTag, std::move(localAssembler)); } diff --git a/src/amdis/linear_algebra/DOFVectorInterface.hpp b/src/amdis/linearalgebra/DOFVectorInterface.hpp similarity index 100% rename from src/amdis/linear_algebra/DOFVectorInterface.hpp rename to src/amdis/linearalgebra/DOFVectorInterface.hpp diff --git a/src/amdis/linear_algebra/LinearSolver.hpp b/src/amdis/linearalgebra/LinearSolver.hpp similarity index 93% rename from src/amdis/linear_algebra/LinearSolver.hpp rename to src/amdis/linearalgebra/LinearSolver.hpp index c1f5661065514eac5b7a0156b3c06f966b9e6cf6..b7a5e3338bb2f571f71eb72b11d56beceebd4af3 100644 --- a/src/amdis/linear_algebra/LinearSolver.hpp +++ b/src/amdis/linearalgebra/LinearSolver.hpp @@ -7,7 +7,7 @@ // AMDiS includes #include <amdis/CreatorInterface.hpp> #include <amdis/Output.hpp> -#include <amdis/linear_algebra/LinearSolverInterface.hpp> +#include <amdis/linearalgebra/LinearSolverInterface.hpp> namespace AMDiS { @@ -32,7 +32,7 @@ namespace AMDiS /// A creator to be used instead of the constructor. struct Creator : CreatorInterfaceName<Super> { - virtual std::unique_ptr<Super> create(std::string prefix) override + virtual std::unique_ptr<Super> createWithString(std::string prefix) override { return std::make_unique<Self>(prefix); } diff --git a/src/amdis/linear_algebra/LinearSolverInterface.hpp b/src/amdis/linearalgebra/LinearSolverInterface.hpp similarity index 89% rename from src/amdis/linear_algebra/LinearSolverInterface.hpp rename to src/amdis/linearalgebra/LinearSolverInterface.hpp index 54228ef66b9004fd42e0c2c9d1b8907f24cf0d4f..285d7dfa8f6f87273d8bcef3cfa0fad994e77874 100644 --- a/src/amdis/linear_algebra/LinearSolverInterface.hpp +++ b/src/amdis/linearalgebra/LinearSolverInterface.hpp @@ -11,11 +11,11 @@ * systems. */ -#include <amdis/common/Utility.hpp> +#include <amdis/common/TypeTraits.hpp> -#include <amdis/linear_algebra/PreconditionerInterface.hpp> -#include <amdis/linear_algebra/RunnerInterface.hpp> -#include <amdis/linear_algebra/SolverInfo.hpp> +#include <amdis/linearalgebra/PreconditionerInterface.hpp> +#include <amdis/linearalgebra/RunnerInterface.hpp> +#include <amdis/linearalgebra/SolverInfo.hpp> namespace AMDiS { diff --git a/src/amdis/linear_algebra/PreconditionerInterface.hpp b/src/amdis/linearalgebra/PreconditionerInterface.hpp similarity index 100% rename from src/amdis/linear_algebra/PreconditionerInterface.hpp rename to src/amdis/linearalgebra/PreconditionerInterface.hpp diff --git a/src/amdis/linear_algebra/RunnerInterface.hpp b/src/amdis/linearalgebra/RunnerInterface.hpp similarity index 92% rename from src/amdis/linear_algebra/RunnerInterface.hpp rename to src/amdis/linearalgebra/RunnerInterface.hpp index 68056e9da97f53b5e1f26a9b60cc1b076ab61bfb..a9e733d4da61d0c1d44ef603675e5ad539fe5253 100644 --- a/src/amdis/linear_algebra/RunnerInterface.hpp +++ b/src/amdis/linearalgebra/RunnerInterface.hpp @@ -1,7 +1,7 @@ #pragma once -#include <amdis/common/Utility.hpp> -#include <amdis/linear_algebra/PreconditionerInterface.hpp> +#include <amdis/common/TypeTraits.hpp> +#include <amdis/linearalgebra/PreconditionerInterface.hpp> namespace AMDiS { diff --git a/src/amdis/linear_algebra/SolverInfo.hpp b/src/amdis/linearalgebra/SolverInfo.hpp similarity index 100% rename from src/amdis/linear_algebra/SolverInfo.hpp rename to src/amdis/linearalgebra/SolverInfo.hpp diff --git a/src/amdis/linear_algebra/eigen/CMakeLists.txt b/src/amdis/linearalgebra/eigen/CMakeLists.txt similarity index 72% rename from src/amdis/linear_algebra/eigen/CMakeLists.txt rename to src/amdis/linearalgebra/eigen/CMakeLists.txt index 8fbcf5e3f3627776a82ccb1800e3da71a85c1843..2cc5df2eca8fc78d22832aa77a8ff27da1d59f20 100644 --- a/src/amdis/linear_algebra/eigen/CMakeLists.txt +++ b/src/amdis/linearalgebra/eigen/CMakeLists.txt @@ -7,4 +7,4 @@ install(FILES PreconConfig.hpp SolverConfig.hpp SolverCreator.hpp -DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/amdis/linear_algebra/eigen) +DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/amdis/linearalgebra/eigen) diff --git a/src/amdis/linear_algebra/eigen/Constraints.hpp b/src/amdis/linearalgebra/eigen/Constraints.hpp similarity index 94% rename from src/amdis/linear_algebra/eigen/Constraints.hpp rename to src/amdis/linearalgebra/eigen/Constraints.hpp index fec59492f940bbbdb5d3c0d08b482bd089ba64c8..f183586f9edf3ecf758fe7979e3d6403fea02102 100644 --- a/src/amdis/linear_algebra/eigen/Constraints.hpp +++ b/src/amdis/linearalgebra/eigen/Constraints.hpp @@ -5,8 +5,8 @@ #include <Eigen/SparseCore> #include <amdis/common/Mpl.hpp> -#include <amdis/linear_algebra/Common.hpp> -#include <amdis/linear_algebra/Constraints.hpp> +#include <amdis/linearalgebra/Common.hpp> +#include <amdis/linearalgebra/Constraints.hpp> namespace AMDiS { diff --git a/src/amdis/linear_algebra/eigen/DOFMatrix.hpp b/src/amdis/linearalgebra/eigen/DOFMatrix.hpp similarity index 96% rename from src/amdis/linear_algebra/eigen/DOFMatrix.hpp rename to src/amdis/linearalgebra/eigen/DOFMatrix.hpp index 46920b20442500d9e650399ed402f8f47b0575a9..7e5fc0ccb1c00c27e53e5ab183399eb785c77b1c 100644 --- a/src/amdis/linear_algebra/eigen/DOFMatrix.hpp +++ b/src/amdis/linearalgebra/eigen/DOFMatrix.hpp @@ -10,8 +10,8 @@ #include <dune/common/timer.hh> #include <amdis/Output.hpp> -#include <amdis/linear_algebra/Common.hpp> -#include <amdis/linear_algebra/DOFMatrixBase.hpp> +#include <amdis/linearalgebra/Common.hpp> +#include <amdis/linearalgebra/DOFMatrixBase.hpp> namespace AMDiS { diff --git a/src/amdis/linear_algebra/eigen/DOFVector.hpp b/src/amdis/linearalgebra/eigen/DOFVector.hpp similarity index 98% rename from src/amdis/linear_algebra/eigen/DOFVector.hpp rename to src/amdis/linearalgebra/eigen/DOFVector.hpp index d70ae9b0703c732360d9a310e4a6322b5df5f724..9e857c5b3e07da331f9163d7ceb910dee153781b 100644 --- a/src/amdis/linear_algebra/eigen/DOFVector.hpp +++ b/src/amdis/linearalgebra/eigen/DOFVector.hpp @@ -5,7 +5,7 @@ #include <dune/common/ftraits.hh> #include <amdis/Output.hpp> -#include <amdis/linear_algebra/DOFVectorBase.hpp> +#include <amdis/linearalgebra/DOFVectorBase.hpp> namespace AMDiS { diff --git a/src/amdis/linear_algebra/eigen/DirectRunner.hpp b/src/amdis/linearalgebra/eigen/DirectRunner.hpp similarity index 91% rename from src/amdis/linear_algebra/eigen/DirectRunner.hpp rename to src/amdis/linearalgebra/eigen/DirectRunner.hpp index 90a350e571543ac304485d49a457ab6357767ae7..5e2aeb3164fe62bec4f95fb162bc303aeabefebc 100644 --- a/src/amdis/linear_algebra/eigen/DirectRunner.hpp +++ b/src/amdis/linearalgebra/eigen/DirectRunner.hpp @@ -3,9 +3,9 @@ #include <algorithm> #include <string> -#include <amdis/linear_algebra/RunnerInterface.hpp> -#include <amdis/linear_algebra/SolverInfo.hpp> -#include <amdis/linear_algebra/eigen/SolverConfig.hpp> +#include <amdis/linearalgebra/RunnerInterface.hpp> +#include <amdis/linearalgebra/SolverInfo.hpp> +#include <amdis/linearalgebra/eigen/SolverConfig.hpp> namespace AMDiS { diff --git a/src/amdis/linear_algebra/eigen/IterativeRunner.hpp b/src/amdis/linearalgebra/eigen/IterativeRunner.hpp similarity index 89% rename from src/amdis/linear_algebra/eigen/IterativeRunner.hpp rename to src/amdis/linearalgebra/eigen/IterativeRunner.hpp index ba02feabc81aa442a27bae2c6709aa77b6e17edb..3e4fe65b2d8b0683fb6fa63f7b701d2bafc4bdd3 100644 --- a/src/amdis/linear_algebra/eigen/IterativeRunner.hpp +++ b/src/amdis/linearalgebra/eigen/IterativeRunner.hpp @@ -2,10 +2,10 @@ #include <dune/istl/preconditioner.hh> -#include <amdis/linear_algebra/RunnerInterface.hpp> -#include <amdis/linear_algebra/SolverInfo.hpp> -#include <amdis/linear_algebra/eigen/PreconConfig.hpp> -#include <amdis/linear_algebra/eigen/SolverConfig.hpp> +#include <amdis/linearalgebra/RunnerInterface.hpp> +#include <amdis/linearalgebra/SolverInfo.hpp> +#include <amdis/linearalgebra/eigen/PreconConfig.hpp> +#include <amdis/linearalgebra/eigen/SolverConfig.hpp> namespace AMDiS { diff --git a/src/amdis/linear_algebra/eigen/PreconConfig.hpp b/src/amdis/linearalgebra/eigen/PreconConfig.hpp similarity index 100% rename from src/amdis/linear_algebra/eigen/PreconConfig.hpp rename to src/amdis/linearalgebra/eigen/PreconConfig.hpp diff --git a/src/amdis/linear_algebra/eigen/SolverConfig.hpp b/src/amdis/linearalgebra/eigen/SolverConfig.hpp similarity index 100% rename from src/amdis/linear_algebra/eigen/SolverConfig.hpp rename to src/amdis/linearalgebra/eigen/SolverConfig.hpp diff --git a/src/amdis/linear_algebra/eigen/SolverCreator.hpp b/src/amdis/linearalgebra/eigen/SolverCreator.hpp similarity index 95% rename from src/amdis/linear_algebra/eigen/SolverCreator.hpp rename to src/amdis/linearalgebra/eigen/SolverCreator.hpp index ef9d7ba53b2d6274ed32a5f03712d9bd3432dc8b..dea331ea0cf810d29db548390ef19159873e089f 100644 --- a/src/amdis/linear_algebra/eigen/SolverCreator.hpp +++ b/src/amdis/linearalgebra/eigen/SolverCreator.hpp @@ -12,9 +12,9 @@ #include <amdis/CreatorMap.hpp> #include <amdis/Initfile.hpp> -#include <amdis/linear_algebra/LinearSolver.hpp> -#include <amdis/linear_algebra/eigen/DirectRunner.hpp> -#include <amdis/linear_algebra/eigen/IterativeRunner.hpp> +#include <amdis/linearalgebra/LinearSolver.hpp> +#include <amdis/linearalgebra/eigen/DirectRunner.hpp> +#include <amdis/linearalgebra/eigen/IterativeRunner.hpp> namespace AMDiS { @@ -30,7 +30,7 @@ namespace AMDiS using SolverBase = LinearSolverInterface<Matrix, VectorX, VectorB>; using Scalar = typename Matrix::Scalar; - virtual std::unique_ptr<SolverBase> create(std::string prefix) override + virtual std::unique_ptr<SolverBase> createWithString(std::string const& prefix) override { // get creator string for preconditioner std::string precon = "no"; diff --git a/src/amdis/linear_algebra/istl/CMakeLists.txt b/src/amdis/linearalgebra/istl/CMakeLists.txt similarity index 71% rename from src/amdis/linear_algebra/istl/CMakeLists.txt rename to src/amdis/linearalgebra/istl/CMakeLists.txt index f342ea029c11494a5c06cf177fe6262b51e7cd26..f11fd2dbcdf17c696d9194254eeefdebbe495355 100644 --- a/src/amdis/linear_algebra/istl/CMakeLists.txt +++ b/src/amdis/linearalgebra/istl/CMakeLists.txt @@ -7,4 +7,4 @@ install(FILES ISTL_Preconditioner.hpp ISTL_Solver.hpp ISTLRunner.hpp -DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/amdis/linear_algebra/istl) +DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/amdis/linearalgebra/istl) diff --git a/src/amdis/linear_algebra/istl/Constraints.hpp b/src/amdis/linearalgebra/istl/Constraints.hpp similarity index 91% rename from src/amdis/linear_algebra/istl/Constraints.hpp rename to src/amdis/linearalgebra/istl/Constraints.hpp index 5a11d6ff7d1e47cccdb79063e6bd446ca23a08a1..e56547d94239d6b28cfe32c0b03e35796a6b23de 100644 --- a/src/amdis/linear_algebra/istl/Constraints.hpp +++ b/src/amdis/linearalgebra/istl/Constraints.hpp @@ -4,8 +4,8 @@ #include <dune/istl/bcrsmatrix.hh> -#include <amdis/linear_algebra/Common.hpp> -#include <amdis/linear_algebra/Constraints.hpp> +#include <amdis/linearalgebra/Common.hpp> +#include <amdis/linearalgebra/Constraints.hpp> namespace AMDiS { diff --git a/src/amdis/linear_algebra/istl/DOFMatrix.hpp b/src/amdis/linearalgebra/istl/DOFMatrix.hpp similarity index 96% rename from src/amdis/linear_algebra/istl/DOFMatrix.hpp rename to src/amdis/linearalgebra/istl/DOFMatrix.hpp index 572d2bd9bd01a262cc85ec143bf5c96541834700..eb3ab6cf8eca2c078542ff0bf0cf18b03a4682f6 100644 --- a/src/amdis/linear_algebra/istl/DOFMatrix.hpp +++ b/src/amdis/linearalgebra/istl/DOFMatrix.hpp @@ -8,8 +8,8 @@ #include <dune/istl/matrixindexset.hh> #include <amdis/Output.hpp> -#include <amdis/linear_algebra/Common.hpp> -#include <amdis/linear_algebra/DOFMatrixBase.hpp> +#include <amdis/linearalgebra/Common.hpp> +#include <amdis/linearalgebra/DOFMatrixBase.hpp> namespace AMDiS { diff --git a/src/amdis/linear_algebra/istl/DOFVector.hpp b/src/amdis/linearalgebra/istl/DOFVector.hpp similarity index 98% rename from src/amdis/linear_algebra/istl/DOFVector.hpp rename to src/amdis/linearalgebra/istl/DOFVector.hpp index ae950445fec43ad19c22a7b21e890b325c75196d..87349079bccfaa7b2414cc0e5dde16938d955fff 100644 --- a/src/amdis/linear_algebra/istl/DOFVector.hpp +++ b/src/amdis/linearalgebra/istl/DOFVector.hpp @@ -3,7 +3,7 @@ #include <dune/istl/bvector.hh> #include <amdis/Output.hpp> -#include <amdis/linear_algebra/DOFVectorBase.hpp> +#include <amdis/linearalgebra/DOFVectorBase.hpp> namespace AMDiS { diff --git a/src/amdis/linear_algebra/istl/DirectRunner.hpp b/src/amdis/linearalgebra/istl/DirectRunner.hpp similarity index 93% rename from src/amdis/linear_algebra/istl/DirectRunner.hpp rename to src/amdis/linearalgebra/istl/DirectRunner.hpp index 7f71fa864f2fd39b338de182ac725aaae0c68f5e..f4cd263302bdaa59ee86db1ed9e277440dc5cc8f 100644 --- a/src/amdis/linear_algebra/istl/DirectRunner.hpp +++ b/src/amdis/linearalgebra/istl/DirectRunner.hpp @@ -4,8 +4,8 @@ #include <string> #include <amdis/Output.hpp> -#include <amdis/linear_algebra/RunnerInterface.hpp> -#include <amdis/linear_algebra/SolverInfo.hpp> +#include <amdis/linearalgebra/RunnerInterface.hpp> +#include <amdis/linearalgebra/SolverInfo.hpp> namespace AMDiS { diff --git a/src/amdis/linear_algebra/istl/Fwd.hpp b/src/amdis/linearalgebra/istl/Fwd.hpp similarity index 100% rename from src/amdis/linear_algebra/istl/Fwd.hpp rename to src/amdis/linearalgebra/istl/Fwd.hpp diff --git a/src/amdis/linear_algebra/istl/ISTLRunner.hpp b/src/amdis/linearalgebra/istl/ISTLRunner.hpp similarity index 90% rename from src/amdis/linear_algebra/istl/ISTLRunner.hpp rename to src/amdis/linearalgebra/istl/ISTLRunner.hpp index 61b71e2c15dcc2a8a74ecbe84b5340bf7dd0d581..12c80cfd4e085c67fbe857930bd8b902c5b99e31 100644 --- a/src/amdis/linear_algebra/istl/ISTLRunner.hpp +++ b/src/amdis/linearalgebra/istl/ISTLRunner.hpp @@ -2,10 +2,10 @@ #include <dune/istl/preconditioner.hh> -#include <amdis/linear_algebra/RunnerInterface.hpp> -#include <amdis/linear_algebra/SolverInfo.hpp> -#include <amdis/linear_algebra/istl/Fwd.hpp> -#include <amdis/linear_algebra/istl/ISTL_Preconditioner.hpp> +#include <amdis/linearalgebra/RunnerInterface.hpp> +#include <amdis/linearalgebra/SolverInfo.hpp> +#include <amdis/linearalgebra/istl/Fwd.hpp> +#include <amdis/linearalgebra/istl/ISTL_Preconditioner.hpp> namespace AMDiS { @@ -76,7 +76,7 @@ namespace AMDiS preconName = "default"; auto* creator = named(CreatorMap<ISTLPrecon>::getCreator(preconName, initFileStr)); - preconCreator_ = creator->create(initFileStr); + preconCreator_ = creator->createWithString(initFileStr); assert(preconCreator_); } diff --git a/src/amdis/linear_algebra/istl/ISTL_Preconditioner.hpp b/src/amdis/linearalgebra/istl/ISTL_Preconditioner.hpp similarity index 97% rename from src/amdis/linear_algebra/istl/ISTL_Preconditioner.hpp rename to src/amdis/linearalgebra/istl/ISTL_Preconditioner.hpp index f6ec6a1b55513d28408044ae0ace398b88671299..4326124ceef6d60920efdfd95fc14bb1d2af81e3 100644 --- a/src/amdis/linear_algebra/istl/ISTL_Preconditioner.hpp +++ b/src/amdis/linearalgebra/istl/ISTL_Preconditioner.hpp @@ -30,7 +30,7 @@ namespace AMDiS struct Creator : CreatorInterfaceName<Super> { - virtual std::unique_ptr<Super> create(std::string prefix) override + virtual std::unique_ptr<Super> createWithString(std::string prefix) override { return std::make_unique<Self>(prefix); } diff --git a/src/amdis/linear_algebra/istl/ISTL_Solver.hpp b/src/amdis/linearalgebra/istl/ISTL_Solver.hpp similarity index 97% rename from src/amdis/linear_algebra/istl/ISTL_Solver.hpp rename to src/amdis/linearalgebra/istl/ISTL_Solver.hpp index fa10d194ee30410f6bcf0ae3217b7340d19187d1..35bcd6bf8986461e3dee1213deeb0c4f053d9334 100644 --- a/src/amdis/linear_algebra/istl/ISTL_Solver.hpp +++ b/src/amdis/linearalgebra/istl/ISTL_Solver.hpp @@ -9,9 +9,9 @@ #include <amdis/CreatorMap.hpp> #include <amdis/Initfile.hpp> -#include <amdis/linear_algebra/istl/Fwd.hpp> -#include <amdis/linear_algebra/istl/DirectRunner.hpp> -#include <amdis/linear_algebra/istl/ISTLRunner.hpp> +#include <amdis/linearalgebra/istl/Fwd.hpp> +#include <amdis/linearalgebra/istl/DirectRunner.hpp> +#include <amdis/linearalgebra/istl/ISTLRunner.hpp> namespace AMDiS { diff --git a/src/amdis/linear_algebra/mtl/CMakeLists.txt b/src/amdis/linearalgebra/mtl/CMakeLists.txt similarity index 75% rename from src/amdis/linear_algebra/mtl/CMakeLists.txt rename to src/amdis/linearalgebra/mtl/CMakeLists.txt index adcf1b591b2a56d86c1c884b5c1d03bc1e5af7a0..20fb45a12878b30f74862c6e159dc5c6c6addaf2 100644 --- a/src/amdis/linear_algebra/mtl/CMakeLists.txt +++ b/src/amdis/linearalgebra/mtl/CMakeLists.txt @@ -7,6 +7,6 @@ install(FILES KrylovRunner.hpp Preconditioner.hpp UmfpackRunner.hpp -DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/amdis/linear_algebra/mtl) +DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/amdis/linearalgebra/mtl) add_subdirectory("itl") diff --git a/src/amdis/linear_algebra/mtl/Constraints.hpp b/src/amdis/linearalgebra/mtl/Constraints.hpp similarity index 97% rename from src/amdis/linear_algebra/mtl/Constraints.hpp rename to src/amdis/linearalgebra/mtl/Constraints.hpp index bd20520609e12d897ee2b149ed48cdb3c4e3b53c..dbdd6e066ec8e5499f661fb4c094b0eaa933978c 100644 --- a/src/amdis/linear_algebra/mtl/Constraints.hpp +++ b/src/amdis/linearalgebra/mtl/Constraints.hpp @@ -7,8 +7,8 @@ #include <boost/numeric/mtl/utility/property_map.hpp> #include <boost/numeric/mtl/utility/range_wrapper.hpp> -#include <amdis/linear_algebra/Common.hpp> -#include <amdis/linear_algebra/Constraints.hpp> +#include <amdis/linearalgebra/Common.hpp> +#include <amdis/linearalgebra/Constraints.hpp> namespace AMDiS { diff --git a/src/amdis/linear_algebra/mtl/DOFMatrix.hpp b/src/amdis/linearalgebra/mtl/DOFMatrix.hpp similarity index 97% rename from src/amdis/linear_algebra/mtl/DOFMatrix.hpp rename to src/amdis/linearalgebra/mtl/DOFMatrix.hpp index 26ecdf75afe01b658465bc5086a0932ae78924c4..3142e940ef1859902f0e788ef74d58654a0e9eaa 100644 --- a/src/amdis/linear_algebra/mtl/DOFMatrix.hpp +++ b/src/amdis/linearalgebra/mtl/DOFMatrix.hpp @@ -11,8 +11,8 @@ #include <boost/numeric/mtl/utility/range_wrapper.hpp> #include <amdis/Output.hpp> -#include <amdis/linear_algebra/Common.hpp> -#include <amdis/linear_algebra/DOFMatrixBase.hpp> +#include <amdis/linearalgebra/Common.hpp> +#include <amdis/linearalgebra/DOFMatrixBase.hpp> namespace AMDiS { diff --git a/src/amdis/linear_algebra/mtl/DOFVector.hpp b/src/amdis/linearalgebra/mtl/DOFVector.hpp similarity index 98% rename from src/amdis/linear_algebra/mtl/DOFVector.hpp rename to src/amdis/linearalgebra/mtl/DOFVector.hpp index be9f61d7386cccd1b3c029be48c3c65a880b5936..49057cdaa3f12fcccefd93e1c98072302a7e30c0 100644 --- a/src/amdis/linear_algebra/mtl/DOFVector.hpp +++ b/src/amdis/linearalgebra/mtl/DOFVector.hpp @@ -5,7 +5,7 @@ #include <dune/common/ftraits.hh> #include <amdis/Output.hpp> -#include <amdis/linear_algebra/DOFVectorBase.hpp> +#include <amdis/linearalgebra/DOFVectorBase.hpp> namespace AMDiS { diff --git a/src/amdis/linear_algebra/mtl/ITL_Preconditioner.hpp b/src/amdis/linearalgebra/mtl/ITL_Preconditioner.hpp similarity index 97% rename from src/amdis/linear_algebra/mtl/ITL_Preconditioner.hpp rename to src/amdis/linearalgebra/mtl/ITL_Preconditioner.hpp index 42e25d04fb451bbd41363d9d318ed7b2aed2b4c9..a24349ef4d728139e3c3958b6bda40a2a6c89a35 100644 --- a/src/amdis/linear_algebra/mtl/ITL_Preconditioner.hpp +++ b/src/amdis/linearalgebra/mtl/ITL_Preconditioner.hpp @@ -6,10 +6,10 @@ #include <boost/numeric/itl/pc/ic_0.hpp> #include <boost/numeric/mtl/vector/assigner.hpp> -#include <amdis/linear_algebra/mtl/itl/masslumping.hpp> +#include <amdis/linearalgebra/mtl/itl/masslumping.hpp> #include <amdis/CreatorMap.hpp> -#include <amdis/linear_algebra/mtl/Preconditioner.hpp> +#include <amdis/linearalgebra/mtl/Preconditioner.hpp> namespace AMDiS { diff --git a/src/amdis/linear_algebra/mtl/ITL_Solver.hpp b/src/amdis/linearalgebra/mtl/ITL_Solver.hpp similarity index 96% rename from src/amdis/linear_algebra/mtl/ITL_Solver.hpp rename to src/amdis/linearalgebra/mtl/ITL_Solver.hpp index 9356f9c1d0acadb76f6bb360c78529ac532b06ec..2cd2df2b53c1fc6bbc6b51b7affa0f7233786c9a 100644 --- a/src/amdis/linear_algebra/mtl/ITL_Solver.hpp +++ b/src/amdis/linearalgebra/mtl/ITL_Solver.hpp @@ -6,19 +6,19 @@ #include <boost/numeric/itl/itl.hpp> // more solvers defined in AMDiS -#include <amdis/linear_algebra/mtl/itl/minres.hpp> -#include <amdis/linear_algebra/mtl/itl/gcr.hpp> -#include <amdis/linear_algebra/mtl/itl/fgmres.hpp> -#include <amdis/linear_algebra/mtl/itl/fgmres_householder.hpp> -#include <amdis/linear_algebra/mtl/itl/gmres2.hpp> -#include <amdis/linear_algebra/mtl/itl/gmres_householder.hpp> -#include <amdis/linear_algebra/mtl/itl/preonly.hpp> +#include <amdis/linearalgebra/mtl/itl/minres.hpp> +#include <amdis/linearalgebra/mtl/itl/gcr.hpp> +#include <amdis/linearalgebra/mtl/itl/fgmres.hpp> +#include <amdis/linearalgebra/mtl/itl/fgmres_householder.hpp> +#include <amdis/linearalgebra/mtl/itl/gmres2.hpp> +#include <amdis/linearalgebra/mtl/itl/gmres_householder.hpp> +#include <amdis/linearalgebra/mtl/itl/preonly.hpp> #include <amdis/CreatorMap.hpp> #include <amdis/Initfile.hpp> -#include <amdis/linear_algebra/LinearSolver.hpp> -#include <amdis/linear_algebra/mtl/KrylovRunner.hpp> -#include <amdis/linear_algebra/mtl/UmfpackRunner.hpp> +#include <amdis/linearalgebra/LinearSolver.hpp> +#include <amdis/linearalgebra/mtl/KrylovRunner.hpp> +#include <amdis/linearalgebra/mtl/UmfpackRunner.hpp> namespace AMDiS { diff --git a/src/amdis/linear_algebra/mtl/KrylovRunner.hpp b/src/amdis/linearalgebra/mtl/KrylovRunner.hpp similarity index 94% rename from src/amdis/linear_algebra/mtl/KrylovRunner.hpp rename to src/amdis/linearalgebra/mtl/KrylovRunner.hpp index 6467e14739ee8de805e01585f1821bb28cf7e2a2..037de430b415e966d8f985de09af88a83e7c86af 100644 --- a/src/amdis/linear_algebra/mtl/KrylovRunner.hpp +++ b/src/amdis/linearalgebra/mtl/KrylovRunner.hpp @@ -7,11 +7,11 @@ #include <boost/numeric/mtl/mtl.hpp> // AMDiS headers -#include <amdis/linear_algebra/PreconditionerInterface.hpp> -#include <amdis/linear_algebra/RunnerInterface.hpp> -#include <amdis/linear_algebra/SolverInfo.hpp> +#include <amdis/linearalgebra/PreconditionerInterface.hpp> +#include <amdis/linearalgebra/RunnerInterface.hpp> +#include <amdis/linearalgebra/SolverInfo.hpp> -#include <amdis/linear_algebra/mtl/ITL_Preconditioner.hpp> +#include <amdis/linearalgebra/mtl/ITL_Preconditioner.hpp> namespace AMDiS { diff --git a/src/amdis/linear_algebra/mtl/Preconditioner.hpp b/src/amdis/linearalgebra/mtl/Preconditioner.hpp similarity index 96% rename from src/amdis/linear_algebra/mtl/Preconditioner.hpp rename to src/amdis/linearalgebra/mtl/Preconditioner.hpp index d317ad8e18611e8917239f77e714723abe65e51a..23dddbd9c2d49da25c57bfe87fab4d52cc749727 100644 --- a/src/amdis/linear_algebra/mtl/Preconditioner.hpp +++ b/src/amdis/linearalgebra/mtl/Preconditioner.hpp @@ -1,6 +1,6 @@ #pragma once -#include <amdis/linear_algebra/PreconditionerInterface.hpp> +#include <amdis/linearalgebra/PreconditionerInterface.hpp> namespace AMDiS { diff --git a/src/amdis/linear_algebra/mtl/UmfpackRunner.hpp b/src/amdis/linearalgebra/mtl/UmfpackRunner.hpp similarity index 96% rename from src/amdis/linear_algebra/mtl/UmfpackRunner.hpp rename to src/amdis/linearalgebra/mtl/UmfpackRunner.hpp index cb97ff50a83a85eb168fec956f114a438a67e019..35659d76f7aee8a6b28f816935a9cd5bfa66bc89 100644 --- a/src/amdis/linear_algebra/mtl/UmfpackRunner.hpp +++ b/src/amdis/linearalgebra/mtl/UmfpackRunner.hpp @@ -9,8 +9,8 @@ #include <boost/numeric/mtl/interface/umfpack_solve.hpp> #include <amdis/Output.hpp> -#include <amdis/linear_algebra/RunnerInterface.hpp> -#include <amdis/linear_algebra/SolverInfo.hpp> +#include <amdis/linearalgebra/RunnerInterface.hpp> +#include <amdis/linearalgebra/SolverInfo.hpp> namespace AMDiS { diff --git a/src/amdis/linear_algebra/mtl/itl/CMakeLists.txt b/src/amdis/linearalgebra/mtl/itl/CMakeLists.txt similarity index 75% rename from src/amdis/linear_algebra/mtl/itl/CMakeLists.txt rename to src/amdis/linearalgebra/mtl/itl/CMakeLists.txt index 58ff9722a11ca7c1aafe94582d017ae19a8e5581..ffe212d96d8944dd67b60cd142df139215a5cdac 100644 --- a/src/amdis/linear_algebra/mtl/itl/CMakeLists.txt +++ b/src/amdis/linearalgebra/mtl/itl/CMakeLists.txt @@ -11,4 +11,4 @@ install(FILES minres.hpp preonly.hpp umfpack2_solve.hpp -DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/amdis/linear_algebra/mtl/itl) +DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/amdis/linearalgebra/mtl/itl) diff --git a/src/amdis/linear_algebra/mtl/itl/block_diagonal.hpp b/src/amdis/linearalgebra/mtl/itl/block_diagonal.hpp similarity index 97% rename from src/amdis/linear_algebra/mtl/itl/block_diagonal.hpp rename to src/amdis/linearalgebra/mtl/itl/block_diagonal.hpp index 3e9f147cebe4c07739640d8bde513ae2bdbc7ee8..b295a389e6e8a5dc83ecc3ea125a6675efd64613 100644 --- a/src/amdis/linear_algebra/mtl/itl/block_diagonal.hpp +++ b/src/amdis/linearalgebra/mtl/itl/block_diagonal.hpp @@ -2,7 +2,7 @@ #include <boost/numeric/itl/pc/diagonal.hpp> -#include <amdis/linear_algebra/mtl/BlockMTLMatrix.hpp> +#include <amdis/linearalgebra/mtl/BlockMTLMatrix.hpp> namespace itl { diff --git a/src/amdis/linear_algebra/mtl/itl/details.hpp b/src/amdis/linearalgebra/mtl/itl/details.hpp similarity index 100% rename from src/amdis/linear_algebra/mtl/itl/details.hpp rename to src/amdis/linearalgebra/mtl/itl/details.hpp diff --git a/src/amdis/linear_algebra/mtl/itl/fgmres.hpp b/src/amdis/linearalgebra/mtl/itl/fgmres.hpp similarity index 100% rename from src/amdis/linear_algebra/mtl/itl/fgmres.hpp rename to src/amdis/linearalgebra/mtl/itl/fgmres.hpp diff --git a/src/amdis/linear_algebra/mtl/itl/fgmres_householder.hpp b/src/amdis/linearalgebra/mtl/itl/fgmres_householder.hpp similarity index 100% rename from src/amdis/linear_algebra/mtl/itl/fgmres_householder.hpp rename to src/amdis/linearalgebra/mtl/itl/fgmres_householder.hpp diff --git a/src/amdis/linear_algebra/mtl/itl/gcr.hpp b/src/amdis/linearalgebra/mtl/itl/gcr.hpp similarity index 100% rename from src/amdis/linear_algebra/mtl/itl/gcr.hpp rename to src/amdis/linearalgebra/mtl/itl/gcr.hpp diff --git a/src/amdis/linear_algebra/mtl/itl/gmres2.hpp b/src/amdis/linearalgebra/mtl/itl/gmres2.hpp similarity index 100% rename from src/amdis/linear_algebra/mtl/itl/gmres2.hpp rename to src/amdis/linearalgebra/mtl/itl/gmres2.hpp diff --git a/src/amdis/linear_algebra/mtl/itl/gmres_householder.hpp b/src/amdis/linearalgebra/mtl/itl/gmres_householder.hpp similarity index 100% rename from src/amdis/linear_algebra/mtl/itl/gmres_householder.hpp rename to src/amdis/linearalgebra/mtl/itl/gmres_householder.hpp diff --git a/src/amdis/linear_algebra/mtl/itl/hypre.hpp b/src/amdis/linearalgebra/mtl/itl/hypre.hpp similarity index 100% rename from src/amdis/linear_algebra/mtl/itl/hypre.hpp rename to src/amdis/linearalgebra/mtl/itl/hypre.hpp diff --git a/src/amdis/linear_algebra/mtl/itl/masslumping.hpp b/src/amdis/linearalgebra/mtl/itl/masslumping.hpp similarity index 98% rename from src/amdis/linear_algebra/mtl/itl/masslumping.hpp rename to src/amdis/linearalgebra/mtl/itl/masslumping.hpp index 26d6b684adfbc2013db1bae540108b9c360ad7d5..d4d0fe1a64f49f67b866188bf2bd94f05179da22 100644 --- a/src/amdis/linear_algebra/mtl/itl/masslumping.hpp +++ b/src/amdis/linearalgebra/mtl/itl/masslumping.hpp @@ -13,7 +13,7 @@ #ifndef ITL_PC_MASSLUMPING_INCLUDE #define ITL_PC_MASSLUMPING_INCLUDE -#include <boost/numeric/linear_algebra/inverse.hpp> +#include <boost/numeric/linearalgebra/inverse.hpp> #include <boost/numeric/mtl/vector/dense_vector.hpp> #include <boost/numeric/mtl/utility/exception.hpp> diff --git a/src/amdis/linear_algebra/mtl/itl/minres.hpp b/src/amdis/linearalgebra/mtl/itl/minres.hpp similarity index 100% rename from src/amdis/linear_algebra/mtl/itl/minres.hpp rename to src/amdis/linearalgebra/mtl/itl/minres.hpp diff --git a/src/amdis/linear_algebra/mtl/itl/preonly.hpp b/src/amdis/linearalgebra/mtl/itl/preonly.hpp similarity index 100% rename from src/amdis/linear_algebra/mtl/itl/preonly.hpp rename to src/amdis/linearalgebra/mtl/itl/preonly.hpp diff --git a/src/amdis/linear_algebra/mtl/itl/umfpack2_solve.hpp b/src/amdis/linearalgebra/mtl/itl/umfpack2_solve.hpp similarity index 100% rename from src/amdis/linear_algebra/mtl/itl/umfpack2_solve.hpp rename to src/amdis/linearalgebra/mtl/itl/umfpack2_solve.hpp diff --git a/src/amdis/assembler/CMakeLists.txt b/src/amdis/localoperators/CMakeLists.txt similarity index 74% rename from src/amdis/assembler/CMakeLists.txt rename to src/amdis/localoperators/CMakeLists.txt index f325175d965601899d7869df9a781bcd78537319..a07432563a66cf32f4728aaeda9dca42f1f06545 100644 --- a/src/amdis/assembler/CMakeLists.txt +++ b/src/amdis/localoperators/CMakeLists.txt @@ -1,9 +1,13 @@ #install headers install(FILES + ConvectionDiffusionOperator.hpp + FirstOrderDivTestvec.hpp FirstOrderDivTestvecTrial.hpp + FirstOrderGradTest.hpp FirstOrderGradTestTrial.hpp FirstOrderGradTestTrialvec.hpp + FirstOrderPartialTest.hpp FirstOrderPartialTestTrial.hpp FirstOrderTestDivTrialvec.hpp FirstOrderTestGradTrial.hpp @@ -12,10 +16,11 @@ install(FILES SecondOrderDivTestvecDivTrialvec.hpp SecondOrderGradTestGradTrial.hpp SecondOrderPartialTestPartialTrial.hpp + StokesOperator.hpp ZeroOrderTest.hpp ZeroOrderTestTrial.hpp ZeroOrderTestTrialvec.hpp ZeroOrderTestvec.hpp ZeroOrderTestvecTrial.hpp ZeroOrderTestvecTrialvec.hpp -DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/amdis/assembler) +DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/amdis/localoperators) diff --git a/src/amdis/assembler/ConvectionDiffusionOperator.hpp b/src/amdis/localoperators/ConvectionDiffusionOperator.hpp similarity index 96% rename from src/amdis/assembler/ConvectionDiffusionOperator.hpp rename to src/amdis/localoperators/ConvectionDiffusionOperator.hpp index caa98f9939749bd2651102bb583daf80a8ca376d..4fc8743ed5bf8e2b462cbcfed892454c6860a14a 100644 --- a/src/amdis/assembler/ConvectionDiffusionOperator.hpp +++ b/src/amdis/localoperators/ConvectionDiffusionOperator.hpp @@ -2,11 +2,11 @@ #include <type_traits> -#include <amdis/LocalBasisCache.hpp> +#include <amdis/utility/LocalBasisCache.hpp> #include <amdis/LocalOperator.hpp> #include <amdis/Output.hpp> -#include <amdis/common/Utility.hpp> -#include <amdis/common/Size.hpp> +#include <amdis/common/TypeTraits.hpp> +#include <amdis/common/StaticSize.hpp> namespace AMDiS { @@ -109,22 +109,22 @@ namespace AMDiS IF_CONSTEXPR(conserving) { WorldVector gradAi; for (std::size_t i = 0; i < numLocalFe; ++i) { - const int local_i = rowNode.localIndex(i); + const auto local_i = rowNode.localIndex(i); gradAi = A * gradients[i]; auto gradBi = b * gradients[i]; for (std::size_t j = 0; j < numLocalFe; ++j) { - const int local_j = colNode.localIndex(j); + const auto local_j = colNode.localIndex(j); elementMatrix[local_i][local_j] += (dot(gradAi, gradients[j]) + (c * shapeValues[i] - gradBi) * shapeValues[j]) * factor; } } } else { WorldVector grad_i; for (std::size_t i = 0; i < numLocalFe; ++i) { - const int local_i = rowNode.localIndex(i); + const auto local_i = rowNode.localIndex(i); grad_i = A * gradients[i]; grad_i+= b * shapeValues[i]; for (std::size_t j = 0; j < numLocalFe; ++j) { - const int local_j = colNode.localIndex(j); + const auto local_j = colNode.localIndex(j); elementMatrix[local_i][local_j] += (dot(grad_i, gradients[j]) + c * shapeValues[i] * shapeValues[j]) * factor; } } @@ -169,7 +169,7 @@ namespace AMDiS const auto factor = localFctF(local) * context.integrationElement(quad[iq].position()) * quad[iq].weight(); for (std::size_t i = 0; i < numLocalFe; ++i) { - const int local_i = node.localIndex(i); + const auto local_i = node.localIndex(i); elementVector[local_i] += shapeValues[i] * factor; } } diff --git a/src/amdis/assembler/FirstOrderDivTestvec.hpp b/src/amdis/localoperators/FirstOrderDivTestvec.hpp similarity index 97% rename from src/amdis/assembler/FirstOrderDivTestvec.hpp rename to src/amdis/localoperators/FirstOrderDivTestvec.hpp index 615e76d67079e366d921252e76bc12cc5c0b90ae..d48f3c4f0563fbd1787da6fb180732d792fea713 100644 --- a/src/amdis/assembler/FirstOrderDivTestvec.hpp +++ b/src/amdis/localoperators/FirstOrderDivTestvec.hpp @@ -3,9 +3,9 @@ #include <type_traits> #include <amdis/GridFunctionOperator.hpp> -#include <amdis/LocalBasisCache.hpp> #include <amdis/Output.hpp> -#include <amdis/common/Size.hpp> +#include <amdis/common/StaticSize.hpp> +#include <amdis/utility/LocalBasisCache.hpp> namespace AMDiS { diff --git a/src/amdis/assembler/FirstOrderDivTestvecTrial.hpp b/src/amdis/localoperators/FirstOrderDivTestvecTrial.hpp similarity index 93% rename from src/amdis/assembler/FirstOrderDivTestvecTrial.hpp rename to src/amdis/localoperators/FirstOrderDivTestvecTrial.hpp index dc49905dec8c8242c1a80952be2bb022275675b4..655be6c0f6388f48a128be94802fb00e6bf55229 100644 --- a/src/amdis/assembler/FirstOrderDivTestvecTrial.hpp +++ b/src/amdis/localoperators/FirstOrderDivTestvecTrial.hpp @@ -2,7 +2,7 @@ #include <type_traits> -#include <amdis/assembler/FirstOrderTestDivTrialvec.hpp> +#include <amdis/localoperators/FirstOrderTestDivTrialvec.hpp> namespace AMDiS { diff --git a/src/amdis/assembler/FirstOrderGradTest.hpp b/src/amdis/localoperators/FirstOrderGradTest.hpp similarity index 97% rename from src/amdis/assembler/FirstOrderGradTest.hpp rename to src/amdis/localoperators/FirstOrderGradTest.hpp index c0fa40242f41eb1634834efb2c5685d0f87f3aaa..c7060f5109b76040ee7dbb04c542357538700861 100644 --- a/src/amdis/assembler/FirstOrderGradTest.hpp +++ b/src/amdis/localoperators/FirstOrderGradTest.hpp @@ -3,9 +3,9 @@ #include <type_traits> #include <amdis/GridFunctionOperator.hpp> -#include <amdis/LocalBasisCache.hpp> #include <amdis/Output.hpp> -#include <amdis/common/Size.hpp> +#include <amdis/common/StaticSize.hpp> +#include <amdis/utility/LocalBasisCache.hpp> namespace AMDiS { diff --git a/src/amdis/assembler/FirstOrderGradTestTrial.hpp b/src/amdis/localoperators/FirstOrderGradTestTrial.hpp similarity index 94% rename from src/amdis/assembler/FirstOrderGradTestTrial.hpp rename to src/amdis/localoperators/FirstOrderGradTestTrial.hpp index 6808103e4b6013135f7c278caed611dea2776dcc..6f1067e2de5e254cf7cc6a64c03ae1c155abb30d 100644 --- a/src/amdis/assembler/FirstOrderGradTestTrial.hpp +++ b/src/amdis/localoperators/FirstOrderGradTestTrial.hpp @@ -2,7 +2,7 @@ #include <type_traits> -#include <amdis/assembler/FirstOrderTestGradTrial.hpp> +#include <amdis/localoperators/FirstOrderTestGradTrial.hpp> namespace AMDiS { diff --git a/src/amdis/assembler/FirstOrderGradTestTrialvec.hpp b/src/amdis/localoperators/FirstOrderGradTestTrialvec.hpp similarity index 93% rename from src/amdis/assembler/FirstOrderGradTestTrialvec.hpp rename to src/amdis/localoperators/FirstOrderGradTestTrialvec.hpp index 83c6c9e86c8eb9dceef7638ca56d3f612eae309e..4649db6fb51a5fe37a0b73b92b5157151d682d78 100644 --- a/src/amdis/assembler/FirstOrderGradTestTrialvec.hpp +++ b/src/amdis/localoperators/FirstOrderGradTestTrialvec.hpp @@ -2,7 +2,7 @@ #include <type_traits> -#include <amdis/assembler/FirstOrderTestvecGradTrial.hpp> +#include <amdis/localoperators/FirstOrderTestvecGradTrial.hpp> namespace AMDiS { diff --git a/src/amdis/assembler/FirstOrderPartialTest.hpp b/src/amdis/localoperators/FirstOrderPartialTest.hpp similarity index 97% rename from src/amdis/assembler/FirstOrderPartialTest.hpp rename to src/amdis/localoperators/FirstOrderPartialTest.hpp index 3f7d7d526d8615e9235e0ba92da953c1bfe0fb25..ca72328b17c73b4baf8c80d5846d2b4b0d08decd 100644 --- a/src/amdis/assembler/FirstOrderPartialTest.hpp +++ b/src/amdis/localoperators/FirstOrderPartialTest.hpp @@ -2,7 +2,7 @@ #include <type_traits> -#include <amdis/assembler/FirstOrderTestPartialTrial.hpp> +#include <amdis/localoperators/FirstOrderTestPartialTrial.hpp> namespace AMDiS { diff --git a/src/amdis/assembler/FirstOrderPartialTestTrial.hpp b/src/amdis/localoperators/FirstOrderPartialTestTrial.hpp similarity index 94% rename from src/amdis/assembler/FirstOrderPartialTestTrial.hpp rename to src/amdis/localoperators/FirstOrderPartialTestTrial.hpp index 0c9435f8e40c0d80328ab42a914fd1fe6f84273b..d094d03f43fca3cfe2e024dacbd59e245786fff5 100644 --- a/src/amdis/assembler/FirstOrderPartialTestTrial.hpp +++ b/src/amdis/localoperators/FirstOrderPartialTestTrial.hpp @@ -2,7 +2,7 @@ #include <type_traits> -#include <amdis/assembler/FirstOrderTestPartialTrial.hpp> +#include <amdis/localoperators/FirstOrderTestPartialTrial.hpp> namespace AMDiS { diff --git a/src/amdis/assembler/FirstOrderTestDivTrialvec.hpp b/src/amdis/localoperators/FirstOrderTestDivTrialvec.hpp similarity index 97% rename from src/amdis/assembler/FirstOrderTestDivTrialvec.hpp rename to src/amdis/localoperators/FirstOrderTestDivTrialvec.hpp index 4eb44a5484f9e417b7c3c22c4b55b05bfb86fcb3..07e31f1d40948abab4fb6d65154b35c856d19042 100644 --- a/src/amdis/assembler/FirstOrderTestDivTrialvec.hpp +++ b/src/amdis/localoperators/FirstOrderTestDivTrialvec.hpp @@ -3,9 +3,9 @@ #include <type_traits> #include <amdis/GridFunctionOperator.hpp> -#include <amdis/LocalBasisCache.hpp> +#include <amdis/utility/LocalBasisCache.hpp> #include <amdis/Output.hpp> -#include <amdis/common/Size.hpp> +#include <amdis/common/StaticSize.hpp> namespace AMDiS { diff --git a/src/amdis/assembler/FirstOrderTestGradTrial.hpp b/src/amdis/localoperators/FirstOrderTestGradTrial.hpp similarity index 97% rename from src/amdis/assembler/FirstOrderTestGradTrial.hpp rename to src/amdis/localoperators/FirstOrderTestGradTrial.hpp index dc19a87b81bb4d1c8b0b5d6a015034598e268e03..667fc203786c135c859438c982e2c023c815349d 100644 --- a/src/amdis/assembler/FirstOrderTestGradTrial.hpp +++ b/src/amdis/localoperators/FirstOrderTestGradTrial.hpp @@ -3,9 +3,9 @@ #include <type_traits> #include <amdis/GridFunctionOperator.hpp> -#include <amdis/LocalBasisCache.hpp> +#include <amdis/utility/LocalBasisCache.hpp> #include <amdis/Output.hpp> -#include <amdis/common/Size.hpp> +#include <amdis/common/StaticSize.hpp> namespace AMDiS { diff --git a/src/amdis/assembler/FirstOrderTestPartialTrial.hpp b/src/amdis/localoperators/FirstOrderTestPartialTrial.hpp similarity index 97% rename from src/amdis/assembler/FirstOrderTestPartialTrial.hpp rename to src/amdis/localoperators/FirstOrderTestPartialTrial.hpp index de5600a8a604b65188ea2bd295ff4a497e4ec04d..2e40ac54042fa7e9852a8b40f8e30554585c6989 100644 --- a/src/amdis/assembler/FirstOrderTestPartialTrial.hpp +++ b/src/amdis/localoperators/FirstOrderTestPartialTrial.hpp @@ -3,9 +3,9 @@ #include <type_traits> #include <amdis/GridFunctionOperator.hpp> -#include <amdis/LocalBasisCache.hpp> +#include <amdis/utility/LocalBasisCache.hpp> #include <amdis/Output.hpp> -#include <amdis/common/Size.hpp> +#include <amdis/common/StaticSize.hpp> namespace AMDiS { diff --git a/src/amdis/assembler/FirstOrderTestvecGradTrial.hpp b/src/amdis/localoperators/FirstOrderTestvecGradTrial.hpp similarity index 97% rename from src/amdis/assembler/FirstOrderTestvecGradTrial.hpp rename to src/amdis/localoperators/FirstOrderTestvecGradTrial.hpp index 2c18a817fdc177b3bb2bf00507cce3a71ef78dd6..35949d1aca82f5458ad4bbd6f83aef4ce27ea277 100644 --- a/src/amdis/assembler/FirstOrderTestvecGradTrial.hpp +++ b/src/amdis/localoperators/FirstOrderTestvecGradTrial.hpp @@ -3,9 +3,9 @@ #include <type_traits> #include <amdis/GridFunctionOperator.hpp> -#include <amdis/LocalBasisCache.hpp> +#include <amdis/utility/LocalBasisCache.hpp> #include <amdis/Output.hpp> -#include <amdis/common/Size.hpp> +#include <amdis/common/StaticSize.hpp> namespace AMDiS { diff --git a/src/amdis/assembler/SecondOrderDivTestvecDivTrialvec.hpp b/src/amdis/localoperators/SecondOrderDivTestvecDivTrialvec.hpp similarity index 98% rename from src/amdis/assembler/SecondOrderDivTestvecDivTrialvec.hpp rename to src/amdis/localoperators/SecondOrderDivTestvecDivTrialvec.hpp index 5657676f3a2bac04d74327607eb52748012c8219..f0cfa6cf90197f83bd79d417a0622a2d1ede4a8d 100644 --- a/src/amdis/assembler/SecondOrderDivTestvecDivTrialvec.hpp +++ b/src/amdis/localoperators/SecondOrderDivTestvecDivTrialvec.hpp @@ -3,9 +3,9 @@ #include <type_traits> #include <amdis/GridFunctionOperator.hpp> -#include <amdis/LocalBasisCache.hpp> +#include <amdis/utility/LocalBasisCache.hpp> #include <amdis/Output.hpp> -#include <amdis/common/Size.hpp> +#include <amdis/common/StaticSize.hpp> namespace AMDiS { diff --git a/src/amdis/assembler/SecondOrderGradTestGradTrial.hpp b/src/amdis/localoperators/SecondOrderGradTestGradTrial.hpp similarity index 99% rename from src/amdis/assembler/SecondOrderGradTestGradTrial.hpp rename to src/amdis/localoperators/SecondOrderGradTestGradTrial.hpp index 23605c668ce19069b8adfc8cbca2597f3507a5d2..274f6352a203516ee5792322ae8e47daadff5b48 100644 --- a/src/amdis/assembler/SecondOrderGradTestGradTrial.hpp +++ b/src/amdis/localoperators/SecondOrderGradTestGradTrial.hpp @@ -3,9 +3,9 @@ #include <type_traits> #include <amdis/GridFunctionOperator.hpp> -#include <amdis/LocalBasisCache.hpp> +#include <amdis/utility/LocalBasisCache.hpp> #include <amdis/Output.hpp> -#include <amdis/common/Size.hpp> +#include <amdis/common/StaticSize.hpp> #include <amdis/common/ValueCategory.hpp> namespace AMDiS diff --git a/src/amdis/assembler/SecondOrderPartialTestPartialTrial.hpp b/src/amdis/localoperators/SecondOrderPartialTestPartialTrial.hpp similarity index 98% rename from src/amdis/assembler/SecondOrderPartialTestPartialTrial.hpp rename to src/amdis/localoperators/SecondOrderPartialTestPartialTrial.hpp index bc3301b43be75b3a0e9ff4fb0b3a100c667cdaa9..9a4e0234a7c1e3c18caa9b297636079ad2dede65 100644 --- a/src/amdis/assembler/SecondOrderPartialTestPartialTrial.hpp +++ b/src/amdis/localoperators/SecondOrderPartialTestPartialTrial.hpp @@ -3,9 +3,9 @@ #include <type_traits> #include <amdis/GridFunctionOperator.hpp> -#include <amdis/LocalBasisCache.hpp> +#include <amdis/utility/LocalBasisCache.hpp> #include <amdis/Output.hpp> -#include <amdis/common/Size.hpp> +#include <amdis/common/StaticSize.hpp> namespace AMDiS { diff --git a/src/amdis/assembler/StokesOperator.hpp b/src/amdis/localoperators/StokesOperator.hpp similarity index 98% rename from src/amdis/assembler/StokesOperator.hpp rename to src/amdis/localoperators/StokesOperator.hpp index 5dd8218a810ac6b7d327dcda6df33a79afe28de2..d4a8e94a72e0f17a114e2475254d616a6583f173 100644 --- a/src/amdis/assembler/StokesOperator.hpp +++ b/src/amdis/localoperators/StokesOperator.hpp @@ -4,8 +4,8 @@ #include <vector> #include <amdis/GridFunctionOperator.hpp> -#include <amdis/LocalBasisCache.hpp> -#include <amdis/common/Size.hpp> +#include <amdis/utility/LocalBasisCache.hpp> +#include <amdis/common/StaticSize.hpp> namespace AMDiS { diff --git a/src/amdis/assembler/ZeroOrderTest.hpp b/src/amdis/localoperators/ZeroOrderTest.hpp similarity index 96% rename from src/amdis/assembler/ZeroOrderTest.hpp rename to src/amdis/localoperators/ZeroOrderTest.hpp index 40c3397e512534adce6a9c5d4f74ae55add6a1c3..9aad9f277def095d13420f9f186c864c5d24e988 100644 --- a/src/amdis/assembler/ZeroOrderTest.hpp +++ b/src/amdis/localoperators/ZeroOrderTest.hpp @@ -3,8 +3,8 @@ #include <type_traits> #include <amdis/GridFunctionOperator.hpp> -#include <amdis/LocalBasisCache.hpp> -#include <amdis/common/Size.hpp> +#include <amdis/utility/LocalBasisCache.hpp> +#include <amdis/common/StaticSize.hpp> namespace AMDiS { diff --git a/src/amdis/assembler/ZeroOrderTestTrial.hpp b/src/amdis/localoperators/ZeroOrderTestTrial.hpp similarity index 98% rename from src/amdis/assembler/ZeroOrderTestTrial.hpp rename to src/amdis/localoperators/ZeroOrderTestTrial.hpp index 9c8980a821d08be6735adeeddfe6fa181680cc02..59c88e928c4586cb69caa725249efd741785d8d7 100644 --- a/src/amdis/assembler/ZeroOrderTestTrial.hpp +++ b/src/amdis/localoperators/ZeroOrderTestTrial.hpp @@ -3,8 +3,8 @@ #include <type_traits> #include <amdis/GridFunctionOperator.hpp> -#include <amdis/LocalBasisCache.hpp> -#include <amdis/common/Size.hpp> +#include <amdis/utility/LocalBasisCache.hpp> +#include <amdis/common/StaticSize.hpp> namespace AMDiS { diff --git a/src/amdis/assembler/ZeroOrderTestTrialvec.hpp b/src/amdis/localoperators/ZeroOrderTestTrialvec.hpp similarity index 95% rename from src/amdis/assembler/ZeroOrderTestTrialvec.hpp rename to src/amdis/localoperators/ZeroOrderTestTrialvec.hpp index 369ddab6c9172cfcaf2ca166febaaccfec889452..670b6d95a4c0e17bf34bad3b3279e9137e1aed39 100644 --- a/src/amdis/assembler/ZeroOrderTestTrialvec.hpp +++ b/src/amdis/localoperators/ZeroOrderTestTrialvec.hpp @@ -3,8 +3,8 @@ #include <type_traits> #include <amdis/GridFunctionOperator.hpp> -#include <amdis/LocalBasisCache.hpp> -#include <amdis/common/Size.hpp> +#include <amdis/utility/LocalBasisCache.hpp> +#include <amdis/common/StaticSize.hpp> namespace AMDiS { @@ -46,7 +46,7 @@ namespace AMDiS "RowNode must be Leaf-Node and ColNode must be a Power-Node."); static const std::size_t CHILDREN = ColNode::CHILDREN; - static_assert( std::is_same<typename GridFct::Range, Dune::FieldVector<double, CHILDREN>>::value, "" ); + static_assert( std::is_same<typename GridFct::Range, Dune::FieldVector<double, int(CHILDREN)>>::value, "" ); auto const& quad = this->getQuadratureRule(context.type(), rowNode, colNode); auto const& rowLocalFE = rowNode.finiteElement(); diff --git a/src/amdis/assembler/ZeroOrderTestvec.hpp b/src/amdis/localoperators/ZeroOrderTestvec.hpp similarity index 96% rename from src/amdis/assembler/ZeroOrderTestvec.hpp rename to src/amdis/localoperators/ZeroOrderTestvec.hpp index 498e98e78943bb4614ab0214937eb6843a2a72a8..e5ff5403d2efd4719068abfd25d71beb7da164bd 100644 --- a/src/amdis/assembler/ZeroOrderTestvec.hpp +++ b/src/amdis/localoperators/ZeroOrderTestvec.hpp @@ -3,8 +3,8 @@ #include <type_traits> #include <amdis/GridFunctionOperator.hpp> -#include <amdis/LocalBasisCache.hpp> -#include <amdis/common/Size.hpp> +#include <amdis/utility/LocalBasisCache.hpp> +#include <amdis/common/StaticSize.hpp> namespace AMDiS { diff --git a/src/amdis/assembler/ZeroOrderTestvecTrial.hpp b/src/amdis/localoperators/ZeroOrderTestvecTrial.hpp similarity index 94% rename from src/amdis/assembler/ZeroOrderTestvecTrial.hpp rename to src/amdis/localoperators/ZeroOrderTestvecTrial.hpp index f37c6aa46cc7bd46e7de3e1983c46b0c22c0b1b4..4b3a6da4a1352e8e705f15734300e3f4373c4083 100644 --- a/src/amdis/assembler/ZeroOrderTestvecTrial.hpp +++ b/src/amdis/localoperators/ZeroOrderTestvecTrial.hpp @@ -2,7 +2,7 @@ #include <type_traits> -#include <amdis/assembler/ZeroOrderTestTrialvec.hpp> +#include <amdis/localoperators/ZeroOrderTestTrialvec.hpp> namespace AMDiS { diff --git a/src/amdis/assembler/ZeroOrderTestvecTrialvec.hpp b/src/amdis/localoperators/ZeroOrderTestvecTrialvec.hpp similarity index 97% rename from src/amdis/assembler/ZeroOrderTestvecTrialvec.hpp rename to src/amdis/localoperators/ZeroOrderTestvecTrialvec.hpp index e9504eda23028366b8e0355237b1b3220be632ce..1a34286c232164f791d158e262c76bc64655de07 100644 --- a/src/amdis/assembler/ZeroOrderTestvecTrialvec.hpp +++ b/src/amdis/localoperators/ZeroOrderTestvecTrialvec.hpp @@ -3,8 +3,8 @@ #include <type_traits> #include <amdis/GridFunctionOperator.hpp> -#include <amdis/LocalBasisCache.hpp> -#include <amdis/common/Size.hpp> +#include <amdis/utility/LocalBasisCache.hpp> +#include <amdis/common/StaticSize.hpp> #include <amdis/common/ValueCategory.hpp> namespace AMDiS @@ -167,7 +167,7 @@ namespace AMDiS tag::matrix) { static const std::size_t CHILDREN = RowNode::CHILDREN; - static_assert( std::is_same<expr_value_type, Dune::FieldMatrix<double, CHILDREN, CHILDREN>>::value, "" ); + static_assert( std::is_same<expr_value_type, Dune::FieldMatrix<double, int(CHILDREN), int(CHILDREN)>>::value, "" ); auto const& rowLocalFE = rowNode.child(0).finiteElement(); auto const& colLocalFE = colNode.child(0).finiteElement(); @@ -183,7 +183,7 @@ namespace AMDiS // The multiplicative factor in the integral transformation formula const auto factor = context.integrationElement(quad[iq].position()) * quad[iq].weight(); - const Dune::FieldMatrix<double, CHILDREN, CHILDREN> exprValue = Super::coefficient(local); + const Dune::FieldMatrix<double, int(CHILDREN), int(CHILDREN)> exprValue = Super::coefficient(local); auto const& rowShapeValues = rowShapeValuesCache[iq]; auto const& colShapeValues = colShapeValuesCache[iq]; diff --git a/src/amdis/operations/Arithmetic.hpp b/src/amdis/operations/Arithmetic.hpp index 2d40051437ffd84f4439ecf9c8adf2372fd0e814..31d7c7a861361a253ac66039d78fd5377f856f8c 100644 --- a/src/amdis/operations/Arithmetic.hpp +++ b/src/amdis/operations/Arithmetic.hpp @@ -18,37 +18,23 @@ namespace AMDiS /// Functor that represents A+B struct Plus { -#ifdef AMDIS_HAS_CXX_FOLD_EXPRESSIONS template <class... Ts> constexpr auto operator()(Ts const&... ts) const { - return (ts + ...); - } -#else - template <class T0, class T1> - constexpr auto operator()(T0 const& t0, T1 const& t1) const - { - return t0 + t1; + return Math::sum(ts...); } - - template <class T0, class... Ts> - constexpr auto operator()(T0 const& t0, Ts const&... ts) const - { - return t0 + operator()(ts...); - } -#endif }; #ifndef DOXYGEN // [0] + g => g template <class G> struct ComposerBuilder<Plus, Zero, G> - : ComposerBuilder<Plus, G> {}; + : ComposerBuilder<Id, G> {}; // g + [0] => g template <class G> struct ComposerBuilder<Plus, G, Zero> - : ComposerBuilder<Plus, G> {}; + : ComposerBuilder<Id, G> {}; // [0] + [0] => [0] template <> @@ -97,15 +83,10 @@ namespace AMDiS }; #ifndef DOXYGEN - // [0] - g => -g - // template <class G> - // struct ComposerBuilder<Minus, Zero, G> - // : ComposerBuilder<Id, Negate> {}; - // g - [0] => g template <class G> struct ComposerBuilder<Minus, G, Zero> - : ComposerBuilder<Minus, G> {}; + : ComposerBuilder<Id, G> {}; // [0] - [0] => [0] template <> @@ -169,14 +150,74 @@ namespace AMDiS // ------------------------------------------------------------------------- + /// Functor that represents A/B + struct Divides + { + template <class T, class S> + constexpr auto operator()(T const& lhs, S const& rhs) const + { + return lhs / rhs; + } + + // d_0 f(x,y) = 1 / y + friend auto partial(Divides, index_t<0>) + { + return compose(Divides{}, One{}, Arg<1>{}); + } + + // d_1 f(x,y) = (y - x)/y^2 + friend auto partial(Divides, index_t<1>); + }; + + // ------------------------------------------------------------------------- + + /// Functor that represents A-B + struct Negate + { + template <class T> + constexpr auto operator()(T const& x) const + { + return -x; + } + + friend int order(Negate, int d) + { + return d; + } + + friend auto partial(Negate, index_t<0>) + { + return StaticConstant<int,-1>{}; + } + }; + +#ifndef DOXYGEN + // g + -h => g - h + template <class G> + struct ComposerBuilder<Plus, G, Negate> + : ComposerBuilder<Minus, G, Id> {}; + + // [0] - g => -g + template <class G> + struct ComposerBuilder<Minus, Zero, G> + : ComposerBuilder<Id, Negate> {}; + + // -(g - h) => (h - g) + template <> + struct ComposerBuilder<Negate, Minus> + : ComposerBuilder<Minus, Arg<1>, Arg<0>> {}; +#endif + + // ------------------------------------------------------------------------- + // forward declaration - template <int p> + template <int p, bool positive> struct PowImpl; template <int p> struct PowType { - using type = PowImpl<p>; + using type = PowImpl<p, (p>0)>; }; template <> struct PowType<1> { using type = Id; }; @@ -189,10 +230,8 @@ namespace AMDiS /// Functor that represents x^p template <int p> - struct PowImpl + struct PowImpl<p, true> { - static_assert(p > 1, "Exponent in power must be non-negative!"); - template <class T> constexpr auto operator()(T const& x) const { @@ -210,14 +249,47 @@ namespace AMDiS } }; + template <int p> + struct PowImpl<p, false> + : public Composer<Divides, One, Pow<-p>> + { + constexpr PowImpl() + : Composer<Divides, One, Pow<-p>>{} + {} + + template <class T> + constexpr auto operator()(T const& x) const + { + return T(1) / Math::pow<-p>(x); + } + }; + + +#ifndef DOXYGEN + // (x^p1)^p2 => x^(p1*p2) + template <int p1, bool pos1, int p2, bool pos2> + struct ComposerBuilder<PowImpl<p1,pos1>, PowImpl<p2,pos2>> + : ComposerBuilder<Id, Pow<p1*p2>> {}; + + // x^p * y^p => (x*y)^p + template <int p, bool pos> + struct ComposerBuilder<Multiplies, PowImpl<p,pos>, PowImpl<p,pos>> + : ComposerBuilder<Pow<p>, Multiplies> {}; +#endif + + // d_1 f(x,y) = (y - x)/y^2 + auto partial(Divides, index_t<1>) + { + return compose(Divides{}, compose(Minus{}, Arg<1>{}, Arg<0>{}), + compose(Pow<2>{}, Arg<1>{})); + } + /// Functor that represents x^p, \see \ref Pow struct Pow_ { Pow_(int p) : p_(p) - { - assert( p_ >= 0 ); - } + {} template <class T> auto operator()(T const& x) const @@ -238,53 +310,6 @@ namespace AMDiS int p_; }; - // ------------------------------------------------------------------------- - - /// Functor that represents A/B - struct Divides - { - template <class T, class S> - constexpr auto operator()(T const& lhs, S const& rhs) const - { - return lhs / rhs; - } - - // d_0 f(x,y) = 1 / y - friend auto partial(Divides, index_t<0>) - { - return compose(Divides{}, One{}, Arg<1>{}); - } - - // d_1 f(x,y) = (y - x)/y^2 - friend auto partial(Divides, index_t<1>) - { - return compose(Divides{}, compose(Minus{}, Arg<1>{}, Arg<0>{}), - compose(Pow<2>{}, Arg<1>{})); - } - }; - - // ------------------------------------------------------------------------- - - /// Functor that represents A-B - struct Negate - { - template <class T> - constexpr auto operator()(T const& x) const - { - return -x; - } - - friend int order(Negate, int d) - { - return d; - } - - friend auto partial(Negate, index_t<0>) - { - return StaticConstant<int,-1>{}; - } - }; - /** @} **/ } // end namespace Operation diff --git a/src/amdis/common/Assigner.hpp b/src/amdis/operations/Assigner.hpp similarity index 100% rename from src/amdis/common/Assigner.hpp rename to src/amdis/operations/Assigner.hpp diff --git a/src/amdis/operations/Basic.hpp b/src/amdis/operations/Basic.hpp index dcbe11d7fa6e7e9abb15ffe8c6d5d669a25292df..ed95863a2a5dda2c85ca16824ae7b407cd1b0dae 100644 --- a/src/amdis/operations/Basic.hpp +++ b/src/amdis/operations/Basic.hpp @@ -1,12 +1,10 @@ #pragma once #include <algorithm> +#include <utility> -#include <amdis/common/IndexSeq.hpp> -#include <amdis/common/Math.hpp> #include <amdis/common/Mpl.hpp> -#include <amdis/common/Concepts.hpp> -#include <amdis/common/ScalarTypes.hpp> +#include <amdis/common/ConceptsBase.hpp> namespace AMDiS { @@ -16,13 +14,13 @@ namespace AMDiS { struct HasFunctorOrder { - template <class F, std::size_t... I> - auto requires_(F&& f, Indices<I...>) -> decltype( order(f, int(I)...) ); + template <class F, int... I> + auto requires_(F&& f, std::integer_sequence<int,I...>) -> decltype( order(f, I...) ); }; } - template <class F, std::size_t N> - constexpr bool HasFunctorOrder = models<Definition::HasFunctorOrder(F, MakeSeq_t<N>)>; + template <class F, int N> + constexpr bool HasFunctorOrder = models<Definition::HasFunctorOrder(F, std::make_integer_sequence<int,N>)>; } namespace Operation diff --git a/src/amdis/operations/CMakeLists.txt b/src/amdis/operations/CMakeLists.txt index 23e3876ae079ed1ab3d0eec5aca772eab01d4717..9aae27686d5d3aada0205d2646c1c3540395a85e 100644 --- a/src/amdis/operations/CMakeLists.txt +++ b/src/amdis/operations/CMakeLists.txt @@ -2,6 +2,7 @@ install(FILES Arithmetic.hpp + Assigner.hpp Basic.hpp CMath.hpp Composer.hpp diff --git a/src/amdis/operations/CMath.hpp b/src/amdis/operations/CMath.hpp index fe069ec9f1a3f25a81ccb842d96277f39f5a35e0..c90d54168337bb87fc2fddf5c94d30c5b63ae287 100644 --- a/src/amdis/operations/CMath.hpp +++ b/src/amdis/operations/CMath.hpp @@ -90,30 +90,18 @@ namespace AMDiS return std::atan2(x, y); } - struct D0 { - template <class T1, class T2> - constexpr auto operator() (T1 const& x, T2 const& y) const - { - return -y/(Math::sqr(x) + Math::sqr(y)); - } - }; - + // -y/(Math::sqr(x) + Math::sqr(y)) constexpr friend auto partial(Atan2, index_t<0>) { - return D0{}; + return compose(Divides{}, compose(Negate{}, Arg<1>{}), + compose(Plus{}, compose(Pow<2>{}, Arg<0>{}), compose(Pow<2>{}, Arg<1>{}))); } - struct D1 { - template <class T1, class T2> - constexpr auto operator() (T1 const& x, T2 const& y) const - { - return x/(Math::sqr(x) + Math::sqr(y)); - } - }; - + // x/(Math::sqr(x) + Math::sqr(y)); constexpr friend auto partial(Atan2, index_t<1>) { - return D1{}; + return compose(Divides{}, Arg<0>{}, + compose(Plus{}, compose(Pow<2>{}, Arg<0>{}), compose(Pow<2>{}, Arg<1>{}))); } }; @@ -121,11 +109,11 @@ namespace AMDiS template <class T> struct Clamp { - Clamp(T const& lo, T const& hi) + constexpr Clamp(T const& lo, T const& hi) : lo_(lo) , hi_(hi) { - assert(lo < hi); + // assert(lo < hi); } constexpr auto operator() (T const& v) const diff --git a/src/amdis/operations/Composer.hpp b/src/amdis/operations/Composer.hpp index c10be583a253594c1f35238ce79d2c7bfd9ee024..891be0af1ed670899ab89a75c9ff2c6b1ca449e8 100644 --- a/src/amdis/operations/Composer.hpp +++ b/src/amdis/operations/Composer.hpp @@ -6,7 +6,6 @@ #include <dune/common/std/apply.hh> #include <amdis/common/Concepts.hpp> -#include <amdis/common/IndexSeq.hpp> #include <amdis/common/Mpl.hpp> #include <amdis/operations/Basic.hpp> @@ -51,7 +50,7 @@ namespace AMDiS /// Generator function for \ref composer template <class F, class... Gs> - auto compose(F&& f, Gs&&... gs) + constexpr auto compose(F&& f, Gs&&... gs) { return ComposerBuilder<std::decay_t<F>, std::decay_t<Gs>...>::build( std::forward<F>(f), std::forward<Gs>(gs)...); diff --git a/src/amdis/operations/Composer.impl.hpp b/src/amdis/operations/Composer.impl.hpp index 5a53683448fdc54076dcac02237d73a7de06e8a1..7a73b0e202d2943b4d14301d4464561175366185 100644 --- a/src/amdis/operations/Composer.impl.hpp +++ b/src/amdis/operations/Composer.impl.hpp @@ -1,5 +1,6 @@ #pragma once +#include <utility> #include <amdis/operations/Composer.hpp> #include <amdis/operations/Arithmetic.hpp> @@ -11,7 +12,7 @@ namespace AMDiS { namespace Operation { template <int J, class F, class... Gs> auto partial(Composer<F,Gs...> const& c, index_t<J> _j) { - auto index_seq = MakeSeq_t<sizeof...(Gs)>{}; + auto index_seq = std::make_index_sequence<sizeof...(Gs)>{}; // d_i(f)[g...] * d_j(g_i) auto term_i = [&](auto const _i) diff --git a/src/amdis/operations/FieldMatVec.hpp b/src/amdis/operations/FieldMatVec.hpp index 5b04cb4ae9a6de2eca80b0d39913bc219272ade7..ffe4d4b905fa410de8fb7fc4091fe68d530c89e5 100644 --- a/src/amdis/operations/FieldMatVec.hpp +++ b/src/amdis/operations/FieldMatVec.hpp @@ -20,7 +20,7 @@ namespace AMDiS template <class T0, class T1, int N> constexpr auto operator()(Dune::FieldVector<T0,N> const& lhs, Dune::FieldVector<T1,N> const& rhs) const { - return dot(lhs, rhs); + return lhs.dot(rhs); } friend constexpr int order(Dot, int d1, int d2) @@ -67,7 +67,7 @@ namespace AMDiS struct TwoNorm : public Composer<Sqrt, UnaryDot> { - TwoNorm() + constexpr TwoNorm() : Composer<Sqrt, UnaryDot>(Sqrt{}, UnaryDot{}) {} diff --git a/src/amdis/operations/MaxMin.hpp b/src/amdis/operations/MaxMin.hpp index fec9047d02fb94252ccc98b3971b42bfde9463cb..c19e526c3c037a261a62eb62a382d4f7ace54b34 100644 --- a/src/amdis/operations/MaxMin.hpp +++ b/src/amdis/operations/MaxMin.hpp @@ -10,7 +10,6 @@ namespace AMDiS template <class T, class S> constexpr auto operator()(T const& lhs, S const& rhs) const { - static_assert(Concepts::LessThanComparable<T,S>, "Argument types are not comparable by <."); return Math::max(lhs, rhs); } }; @@ -23,7 +22,6 @@ namespace AMDiS template <class T, class S> constexpr auto operator()(T const& lhs, S const& rhs) const { - static_assert(Concepts::LessThanComparable<T,S>, "Argument types are not comparable by <."); return Math::min(lhs, rhs); } }; diff --git a/src/amdis/typetree/CMakeLists.txt b/src/amdis/typetree/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..60c45aeb846993efd054f3a00ac46c55b693433a --- /dev/null +++ b/src/amdis/typetree/CMakeLists.txt @@ -0,0 +1,11 @@ + +install(FILES + FiniteElementType.hpp + MultiIndex.hpp + RangeType.hpp + Traversal.hpp + TreeContainer.hpp + TreeData.hpp + TreePath.hpp + Visitor.hpp +DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/amdis/typetree) diff --git a/src/amdis/utility/FiniteElementType.hpp b/src/amdis/typetree/FiniteElementType.hpp similarity index 76% rename from src/amdis/utility/FiniteElementType.hpp rename to src/amdis/typetree/FiniteElementType.hpp index 286034bcbbead899025d0bf79f1c43c76ebdf139..a2a79defb90052b085c082a96f06d4d848456dae 100644 --- a/src/amdis/utility/FiniteElementType.hpp +++ b/src/amdis/typetree/FiniteElementType.hpp @@ -2,6 +2,9 @@ #include <cmath> +#include <dune/common/typetraits.hh> +#include <dune/typetree/nodetags.hh> + #include <amdis/common/Loops.hpp> #include <amdis/common/Mpl.hpp> #include <amdis/common/Tags.hpp> @@ -10,10 +13,10 @@ namespace AMDiS { namespace Impl { - template <class Node, bool isLeaf, bool isPower, bool isComposite> + template <class Node, class NodeTag> struct FiniteElementTypeImpl { - static_assert( isLeaf || isPower || isComposite, "Unknown node-type for range definition" ); + static_assert( Dune::AlwaysFalse<NodeTag>::value, "Unknown node-type for range definition" ); // polynomial degree of finite-element basis functions static int order(Node const&) { return 0; } @@ -22,7 +25,7 @@ namespace AMDiS template <class Node> using FiniteElementType = - Impl::FiniteElementTypeImpl<Node, Node::isLeaf, Node::isPower, Node::isComposite>; + Impl::FiniteElementTypeImpl<Node, typename Node::NodeTag>; template <class Node> using FiniteElementType_t = typename FiniteElementType<Node>::type; @@ -38,7 +41,7 @@ namespace AMDiS { // Leaf node template <class Node> - struct FiniteElementTypeImpl<Node, true, false, false> + struct FiniteElementTypeImpl<Node, Dune::TypeTree::LeafNodeTag> { using type = typename Node::FiniteElement; @@ -50,7 +53,7 @@ namespace AMDiS // Power node template <class Node> - struct FiniteElementTypeImpl<Node, false, true, false> + struct FiniteElementTypeImpl<Node, Dune::TypeTree::PowerNodeTag> { using ChildNode = typename Node::template Child<0>::type; using type = FiniteElementType_t<ChildNode>; @@ -63,7 +66,7 @@ namespace AMDiS // Composite node template <class Node> - struct FiniteElementTypeImpl<Node, false, false, true> + struct FiniteElementTypeImpl<Node, Dune::TypeTree::CompositeNodeTag> { using type = tag::unknown; // no common FiniteElement type diff --git a/src/amdis/utility/MultiIndex.hpp b/src/amdis/typetree/MultiIndex.hpp similarity index 100% rename from src/amdis/utility/MultiIndex.hpp rename to src/amdis/typetree/MultiIndex.hpp diff --git a/src/amdis/utility/RangeType.hpp b/src/amdis/typetree/RangeType.hpp similarity index 89% rename from src/amdis/utility/RangeType.hpp rename to src/amdis/typetree/RangeType.hpp index 0c3fc3705c484a69455535505f0fc96346cbe8fc..0e36925ec9476e92d8b28445c44705e4c466698a 100644 --- a/src/amdis/utility/RangeType.hpp +++ b/src/amdis/typetree/RangeType.hpp @@ -1,22 +1,21 @@ #pragma once #include <type_traits> +#include <utility> #include <dune/common/fvector.hh> +#include <dune/common/typetraits.hh> -#include <amdis/common/IndexSeq.hpp> #include <amdis/common/MultiTypeVector.hpp> namespace AMDiS { namespace Impl { - template <class> struct always_false : std::false_type {}; - template <class Node, class R, class NodeTag> struct RangeTypeImpl { - static_assert( always_false<NodeTag>::value, "Unknown node-type for range definition" ); + static_assert( Dune::AlwaysFalse<NodeTag>::value, "Unknown node-type for range definition" ); }; } @@ -79,7 +78,7 @@ namespace AMDiS using type = MultiTypeVector<RangeType_t<ChildNode<I>,R>...>; }; - using type = typename RangeTypeGenerator<MakeSeq_t<Node::CHILDREN>>::type; + using type = typename RangeTypeGenerator<std::make_index_sequence<Node::CHILDREN>>::type; }; } // end namespace Impl diff --git a/src/amdis/utility/Traversal.hpp b/src/amdis/typetree/Traversal.hpp similarity index 100% rename from src/amdis/utility/Traversal.hpp rename to src/amdis/typetree/Traversal.hpp diff --git a/src/amdis/utility/TreeContainer.hpp b/src/amdis/typetree/TreeContainer.hpp similarity index 100% rename from src/amdis/utility/TreeContainer.hpp rename to src/amdis/typetree/TreeContainer.hpp diff --git a/src/amdis/utility/TreeData.hpp b/src/amdis/typetree/TreeData.hpp similarity index 95% rename from src/amdis/utility/TreeData.hpp rename to src/amdis/typetree/TreeData.hpp index d3842885d812cb28309fc7a897ad34819ec96411..2e558ace277c21b374b870fdf0187408ae5b0cb4 100644 --- a/src/amdis/utility/TreeData.hpp +++ b/src/amdis/typetree/TreeData.hpp @@ -6,7 +6,7 @@ #include <vector> #include <dune/typetree/typetree.hh> -#include <amdis/utility/Visitor.hpp> +#include <amdis/typetree/Visitor.hpp> namespace AMDiS { @@ -119,7 +119,8 @@ namespace AMDiS { assert(initialized_); assert(data_.size() > node.treeIndex()); - return *(NodeData<Node>*)(data_[node.treeIndex()]); + using NodePtr = NodeData<Node>*; + return *NodePtr(data_[node.treeIndex()]); } //! Get reference to data associated to given node @@ -128,7 +129,8 @@ namespace AMDiS { assert(initialized_); assert(data_.size() > node.treeIndex()); - return *(NodeData<Node>*)(data_[node.treeIndex()]); + using NodePtr = NodeData<Node>*; + return *NodePtr(data_[node.treeIndex()]); } //! Swap tree and data container with `other` @@ -175,7 +177,8 @@ namespace AMDiS { apply([this](const auto& node, auto) { using Node = std::remove_reference_t<decltype(node)>; - auto* p = (NodeData<Node>*)(data_[node.treeIndex()]); + using NodePtr = NodeData<Node>*; + auto* p = NodePtr(data_[node.treeIndex()]); delete p; }); basis_ = nullptr; diff --git a/src/amdis/utility/TreePath.hpp b/src/amdis/typetree/TreePath.hpp similarity index 100% rename from src/amdis/utility/TreePath.hpp rename to src/amdis/typetree/TreePath.hpp diff --git a/src/amdis/utility/Visitor.hpp b/src/amdis/typetree/Visitor.hpp similarity index 98% rename from src/amdis/utility/Visitor.hpp rename to src/amdis/typetree/Visitor.hpp index 0df1a74a9dfef2357aa4a2767f321aded82cd4b0..153e0e1ea938ec51742e28d8901ccbf15c53c543 100644 --- a/src/amdis/utility/Visitor.hpp +++ b/src/amdis/typetree/Visitor.hpp @@ -1,8 +1,7 @@ #pragma once #include <dune/typetree/visitor.hh> -#include <amdis/common/Mpl.hpp> -#include <amdis/utility/Traversal.hpp> +#include <amdis/typetree/Traversal.hpp> namespace AMDiS { diff --git a/src/amdis/utility/AssembleOperators.hpp b/src/amdis/utility/AssembleOperators.hpp new file mode 100644 index 0000000000000000000000000000000000000000..955b85d489029bb995abdd8ee49d5c7241623e90 --- /dev/null +++ b/src/amdis/utility/AssembleOperators.hpp @@ -0,0 +1,85 @@ +#pragma once + +namespace AMDiS +{ + template <class ElementAssembler, class IntersectionAssembler, class BoundaryAssembler> + struct AssemblerTriple + { + ElementAssembler elementAssembler; + IntersectionAssembler intersectionAssembler; + BoundaryAssembler boundaryAssembler; + }; + + template <class EA, class IA, class BA> + AssemblerTriple<EA, IA, BA> makeAssemblerTriple(EA const& ea, IA const& ia, BA const& ba) + { + return {ea, ia, ba}; + } + + + template <class GridView, class Element, class Operators, class EA, class IA, class BA> + void assembleOperators( + GridView const& gridView, + Element const& element, + Operators& operators, + AssemblerTriple<EA,IA,BA> const& assemblerTriple) + { + // assemble element operators + assemblerTriple.elementAssembler(element, operators.onElement()); + + // assemble intersection operators + if (!operators.onIntersection().empty() + || (!operators.onBoundary().empty() && element.hasBoundaryIntersections())) + { + for (auto const& intersection : intersections(gridView, element)) { + if (intersection.boundary()) + assemblerTriple.boundaryAssembler(intersection, operators.onBoundary()); + else + assemblerTriple.intersectionAssembler(intersection, operators.onIntersection()); + } + } + } + + + template <class Node, class ElementVector> + auto makeVectorAssembler(Node const& node, ElementVector& elementVector) + { + return makeAssemblerTriple( + [&](auto const& element, auto& operators) { + for (auto& op : operators) + op->assemble(element, node, elementVector); + }, + [&](auto const& is, auto& operators) { + for (auto& op : operators) + op->assemble(is, node, elementVector); + }, + [&](auto const& bis, auto& operators) { + for (auto& data : operators) { + if (data.bc.onBoundary(bis)) + data.op->assemble(bis, node, elementVector); + } + }); + } + + + template <class RowNode, class ColNode, class ElementMatrix> + auto makeMatrixAssembler(RowNode const& rowNode, ColNode const& colNode, ElementMatrix& elementMatrix) + { + return makeAssemblerTriple( + [&](auto const& element, auto& operators) { + for (auto& op : operators) + op->assemble(element, rowNode, colNode, elementMatrix); + }, + [&](auto const& is, auto& operators) { + for (auto& op : operators) + op->assemble(is, rowNode, colNode, elementMatrix); + }, + [&](auto const& bis, auto& operators) { + for (auto& data : operators) { + if (data.bc.onBoundary(bis)) + data.op->assemble(bis, rowNode, colNode, elementMatrix); + } + }); + } + +} // end namespace AMDiS \ No newline at end of file diff --git a/src/amdis/utility/CMakeLists.txt b/src/amdis/utility/CMakeLists.txt index 31b476997d6e1c53929c718b2350f2c02eeb8206..e5d246e1035f46cf59b87656407a7186c2201d30 100644 --- a/src/amdis/utility/CMakeLists.txt +++ b/src/amdis/utility/CMakeLists.txt @@ -1,18 +1,5 @@ -#install headers - -dune_library_add_sources(amdis SOURCES - Filesystem.cpp -) - install(FILES - ConcurrentCache.hpp - Filesystem.hpp - FiniteElementType.hpp - MultiIndex.hpp - RangeType.hpp - String.hpp - Traversal.hpp - TreeData.hpp - TreePath.hpp - Visitor.hpp + AssembleOperators.hpp + LocalBasisCache.hpp + QuadratureFactory.hpp DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/amdis/utility) diff --git a/src/amdis/LocalBasisCache.hpp b/src/amdis/utility/LocalBasisCache.hpp similarity index 98% rename from src/amdis/LocalBasisCache.hpp rename to src/amdis/utility/LocalBasisCache.hpp index cf4b1c45fb37cc55c476d31c09d9a5b309541028..98ae9313ae24b38fe3daa50d364246f6dcb9a177 100644 --- a/src/amdis/LocalBasisCache.hpp +++ b/src/amdis/utility/LocalBasisCache.hpp @@ -7,8 +7,8 @@ #include <dune/geometry/quadraturerules.hh> #include <dune/geometry/type.hh> -#include <amdis/utility/ConcurrentCache.hpp> -#include <amdis/utility/FiniteElementType.hpp> +#include <amdis/common/ConcurrentCache.hpp> +#include <amdis/typetree/FiniteElementType.hpp> namespace AMDiS { diff --git a/src/amdis/QuadratureFactory.hpp b/src/amdis/utility/QuadratureFactory.hpp similarity index 100% rename from src/amdis/QuadratureFactory.hpp rename to src/amdis/utility/QuadratureFactory.hpp diff --git a/src/amdis/utility/String.hpp b/src/amdis/utility/String.hpp deleted file mode 100644 index f038e7cb646dfe7a5b33121b1efe7f7fc9e8077b..0000000000000000000000000000000000000000 --- a/src/amdis/utility/String.hpp +++ /dev/null @@ -1,105 +0,0 @@ -#pragma once - -#include <algorithm> -#include <cctype> -#include <locale> -#include <string> - -namespace AMDiS -{ - /// convert all characters in a string to upper case - inline std::string to_upper(std::string input) - { - for (auto& c : input) - c = toupper(c); - return input; - } - - /// convert all characters in a string to upper case - inline std::string to_lower(std::string input) - { - for (auto& c : input) - c = tolower(c); - return input; - } - - /// trim a string from the left - inline std::string& ltrim(std::string& str) - { - auto it = std::find_if(str.begin(), str.end(), [](char ch) - { - return !std::isspace<char>(ch, std::locale::classic()); - }); - str.erase(str.begin() , it); - return str; - } - - /// trim a string from the right - inline std::string& rtrim(std::string& str) - { - auto it = std::find_if(str.rbegin(), str.rend(), [](char ch) - { - return !std::isspace<char>(ch, std::locale::classic()); - }); - str.erase(it.base(), str.end()); - return str; - } - - /// trim a string from both sides - inline std::string& trim(std::string& str) - { - return ltrim(rtrim(str)); - } - - /// trim a (copy of the) string from both sides - inline std::string trim_copy(std::string const& str) - { - auto s = str; - return trim(s); - } - - - template <class InputIter, class T, class Func> - void split(InputIter first, InputIter end, T const& t, Func f) - { - if (first == end) - return; - - while (true) { - InputIter found = std::find(first, end, t); - f(first, found); - if (found == end) - break; - first = ++found; - } - } - - template <class InputIter, class SeparaterIter, class Func> - void split(InputIter first, InputIter end, SeparaterIter s_first, SeparaterIter s_end, Func f) - { - if (first == end) - return; - - while (true) { - InputIter found = std::find_first_of(first, end, s_first, s_end); - f(first, found); - if (found == end) - break; - first = ++found; - } - } - - /// Replace all occurences of substring `from` with `to` in source `str`. - inline void replaceAll(std::string& str, std::string const& from, std::string const& to) - { - if (from.empty()) - return; - std::size_t start_pos = 0; - while ((start_pos = str.find(from, start_pos)) != std::string::npos) - { - str.replace(start_pos, from.length(), to); - start_pos += to.length(); - } - } - -} // end namspace AMDiS diff --git a/test/AdaptInfoTest.cpp b/test/AdaptInfoTest.cpp index 0b861c7144d0230aac9fbff0aec8d9ee4505a8b4..7264e3074a01fec8a12a76bda62ce809269b2d07 100644 --- a/test/AdaptInfoTest.cpp +++ b/test/AdaptInfoTest.cpp @@ -3,7 +3,7 @@ #include <amdis/common/Literals.hpp> -#include <amdis/utility/TreePath.hpp> +#include <amdis/typetree/TreePath.hpp> #include "Tests.hpp" diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index bb4e86298bb60fb70e9d89fff6c5d804e2706a93..ead7e40c7d76f7a36dae9fc4c700ee9340c7d2c3 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -2,9 +2,6 @@ dune_add_test(SOURCES AdaptInfoTest.cpp LINK_LIBRARIES amdis) -dune_add_test(SOURCES ClonablePtrTest.cpp - LINK_LIBRARIES amdis) - dune_add_test(SOURCES ConceptsTest.cpp LINK_LIBRARIES amdis) @@ -57,6 +54,3 @@ dune_add_test(SOURCES StringTest.cpp dune_add_test(SOURCES TreeDataTest.cpp LINK_LIBRARIES amdis) - -dune_add_test(SOURCES TupleUtilityTest.cpp - LINK_LIBRARIES amdis) diff --git a/test/ClonablePtrTest.cpp b/test/ClonablePtrTest.cpp deleted file mode 100644 index 285ad332e7e0156d1b1451b3a9797df3d74309e6..0000000000000000000000000000000000000000 --- a/test/ClonablePtrTest.cpp +++ /dev/null @@ -1,66 +0,0 @@ -// #include <iostream> - -#include <amdis/common/ClonablePtr.hpp> - -#include "Tests.hpp" - -using namespace AMDiS; - -int main() -{ - using C = ClonablePtr<int>; - - // constructors - C p1; // default constructor - AMDIS_TEST( !(p1) ); - AMDIS_TEST( (p1.get() == nullptr) ); // same as above - - int i = 10; - C p2(i); // constructor from reference - AMDIS_TEST( (p2.get() != nullptr) ); - AMDIS_TEST_EQ( *p2 , i ); - - p1 = p2; // copy and move assignment - AMDIS_TEST( (p1.get() != nullptr) ); - AMDIS_TEST_EQ( *p1 , i ); - AMDIS_TEST_EQ( *p1 , *p2 ); - - int j = 20; - auto u = std::make_unique<int>(j); - AMDIS_TEST( (u.get() != nullptr) ); - - C p3(u); // constructor from std::unique_ptr - AMDIS_TEST( (u.get() == nullptr) ); // unique_ptr is reset to NULL - AMDIS_TEST( (p3.get() != nullptr) ); - AMDIS_TEST_EQ( *p3 , j ); - - C p4(p3); // copy constructor - AMDIS_TEST( (p3.get() != nullptr) ); // ClonablePtr is not reset - AMDIS_TEST( (p4.get() != nullptr) ); - AMDIS_TEST_EQ( *p4 , j ); - AMDIS_TEST_EQ( *p3 , *p4 ); - - int k = 30; - C p5 = C::make(k); // factory method - AMDIS_TEST( (p5.get() != nullptr) ); - AMDIS_TEST_EQ( *p5 , k ); - - C p6(*p5); // move constructor - AMDIS_TEST( (p6.get() != nullptr) ); - AMDIS_TEST_EQ( *p6 , k ); - AMDIS_TEST_EQ( *p5 , *p6 ); - -/* // Test output - std::cout << "*p1:" << *p1 << ", " << p1.get() << "\n" - << "*p2:" << *p2 << ", " << p2.get() << "\n" - << "*p3:" << *p3 << ", " << p3.get() << "\n" - << "*p4:" << *p4 << ", " << p4.get() << "\n" - << "*p5:" << *p5 << ", " << p5.get() << "\n" - << "*p6:" << *p6 << ", " << p6.get() << "\n" - << " u : " << u.get() << "\n" - << " i :" << i << "\n" - << " j :" << j << "\n" - << " k :" << k << "\n" - << "End of Test" << "\n"; -*/ -} \ No newline at end of file diff --git a/test/ConceptsTest.cpp b/test/ConceptsTest.cpp index 40d14bc335ac9eeda076ead3bf960efa7d5ac0e3..ced9c2dced370aaa8d5bb71d77307f54dea91438 100644 --- a/test/ConceptsTest.cpp +++ b/test/ConceptsTest.cpp @@ -12,36 +12,12 @@ using namespace AMDiS; int main() { using V = Dune::FieldVector<double,2>; - using M = Dune::FieldMatrix<double,2,2>; - - // arithmetic concepts - static_assert( Concepts::Addable<double,double>, "" ); - static_assert( Concepts::Addable<V,V>, "" ); - static_assert( Concepts::Addable<M,M>, "" ); - - static_assert( Concepts::Subtractable<double,double>, "" ); - static_assert( Concepts::Subtractable<V,V>, "" ); - static_assert( Concepts::Subtractable<M,M>, "" ); - - static_assert( Concepts::Multiplicable<double,double>, "" ); - static_assert( Concepts::Multiplicable<V,double>, "" ); - static_assert( Concepts::Multiplicable<V,V>, "" ); - static_assert( Concepts::Multiplicable<M,double>, "" ); -// static_assert( Concepts::Multiplicable<M,V>, "" ); // A*x defined but x*A is not - - static_assert( Concepts::Divisible<double,double>, "" ); - static_assert( Concepts::Divisible<V,double>, "" ); - static_assert( Concepts::Divisible<M,double>, "" ); - - static_assert( Concepts::LessThanComparable<double,double>, "" ); - static_assert( Concepts::LessThanComparable<char,char>, "" ); // Concepts::Callable auto f = [](V const&) { return 0.0; }; auto b = [](V const&) { return true; }; static_assert( Concepts::Callable<decltype(f),V>, "" ); - static_assert( Concepts::Evaluable<decltype(f),V>, "" ); static_assert( Concepts::Functor<decltype(f),double(V)>, "" ); static_assert( Concepts::Functor<decltype(b),bool(V)>, "" ); static_assert( Concepts::Predicate<decltype(b),V>, "" ); diff --git a/test/DiscreteFunctionTest.cpp b/test/DiscreteFunctionTest.cpp index 14419ce8a50a1991aaa93cd52f6829a65c16b104..ae1ba4a64b945425b20551a77dadf470e4e505f9 100644 --- a/test/DiscreteFunctionTest.cpp +++ b/test/DiscreteFunctionTest.cpp @@ -8,7 +8,7 @@ #include <amdis/ProblemStat.hpp> #include <amdis/gridfunctions/DiscreteFunction.hpp> #include <amdis/gridfunctions/DOFVectorView.hpp> -#include <amdis/utility/TreePath.hpp> +#include <amdis/typetree/TreePath.hpp> #include "Tests.hpp" diff --git a/test/ExpressionsTest.cpp b/test/ExpressionsTest.cpp index 837ba91945020464d79e5707a9dc2d6010493098..7c2924ab7bb63ecfedfe09522dd585b0a3a66ae4 100644 --- a/test/ExpressionsTest.cpp +++ b/test/ExpressionsTest.cpp @@ -5,8 +5,8 @@ #include <amdis/AMDiS.hpp> #include <amdis/Integrate.hpp> +#include <amdis/LocalOperators.hpp> #include <amdis/ProblemStat.hpp> -#include <amdis/Operators.hpp> #include <amdis/common/Literals.hpp> #include <amdis/common/FieldMatVec.hpp> diff --git a/test/FilesystemTest.cpp b/test/FilesystemTest.cpp index d4a7fa8bd3707958335dc9e889a8c962e3d1c97a..2a9e7f53341350c557fb2f31e2c3c3b735d7ea82 100644 --- a/test/FilesystemTest.cpp +++ b/test/FilesystemTest.cpp @@ -1,4 +1,4 @@ -#include <amdis/utility/Filesystem.hpp> +#include <amdis/common/Filesystem.hpp> #include "Tests.hpp" diff --git a/test/FiniteElementTypeTest.cpp b/test/FiniteElementTypeTest.cpp index 4bcc83877816ad46cbc5233d2e3226f96ff6335f..dac256bd243a2f51404c885b5c293b7c6f2f489d 100644 --- a/test/FiniteElementTypeTest.cpp +++ b/test/FiniteElementTypeTest.cpp @@ -4,7 +4,7 @@ #include <dune/functions/functionspacebases/powerbasis.hh> #include <dune/functions/functionspacebases/lagrangebasis.hh> -#include <amdis/utility/FiniteElementType.hpp> +#include <amdis/typetree/FiniteElementType.hpp> #include "Tests.hpp" int main() diff --git a/test/OperatorsTest.cpp b/test/OperatorsTest.cpp index 259eaddd1870b2a470c14d61aa1ea6986f695867..1568cec3b7cde8149755595f7d8644b79e38b0b5 100644 --- a/test/OperatorsTest.cpp +++ b/test/OperatorsTest.cpp @@ -3,14 +3,12 @@ #include "config.h" #include <amdis/AMDiS.hpp> #include <amdis/ProblemStat.hpp> -#include <amdis/Operators.hpp> -#include <amdis/assembler/ConvectionDiffusionOperator.hpp> -#include <amdis/assembler/StokesOperator.hpp> - +#include <amdis/LocalOperators.hpp> +#include <amdis/localoperators/ConvectionDiffusionOperator.hpp> +#include <amdis/localoperators/StokesOperator.hpp> using namespace AMDiS; - using Grid = Dune::YaspGrid<2>; using Param = TaylorHoodBasis<typename Grid::LeafGridView>; using Problem = ProblemStat<Param>; diff --git a/test/RangeTypeTest.cpp b/test/RangeTypeTest.cpp index 0ae30121be3166143c11f89955dcc9b4c4dad96d..2ba3071f16da95146eb10b10618c740f372fd835 100644 --- a/test/RangeTypeTest.cpp +++ b/test/RangeTypeTest.cpp @@ -4,7 +4,7 @@ #include <dune/functions/functionspacebases/powerbasis.hh> #include <dune/functions/functionspacebases/lagrangebasis.hh> -#include <amdis/utility/RangeType.hpp> +#include <amdis/typetree/RangeType.hpp> #include "Tests.hpp" int main() diff --git a/test/StringTest.cpp b/test/StringTest.cpp index d10c87423e57b26b62fce60eb1c6eb90f9d42c25..8390dde586217c41126e1c09201d2f20ac0b0459 100644 --- a/test/StringTest.cpp +++ b/test/StringTest.cpp @@ -1,7 +1,8 @@ #include <string> #include <vector> -#include <amdis/utility/String.hpp> +#include <amdis/common/Algorithm.hpp> +#include <amdis/common/String.hpp> #include "Tests.hpp" using namespace AMDiS; @@ -52,7 +53,7 @@ void test2() std::string text = "Hallo Welt!"; replaceAll(text, "Welt", "du"); AMDIS_TEST_EQ(text,"Hallo du!" ); - + replaceAll(text, "", "Guten Tag"); AMDIS_TEST_EQ(text,"Hallo du!" ); } diff --git a/test/TreeDataTest.cpp b/test/TreeDataTest.cpp index 8c65636cf777de1ad0cf340bf446302d8b8eb0c3..d0320281dc436ff7a49d135a31a4c41d43466cc8 100644 --- a/test/TreeDataTest.cpp +++ b/test/TreeDataTest.cpp @@ -9,7 +9,7 @@ #include <dune/functions/functionspacebases/lagrangebasis.hh> #include <dune/functions/functionspacebases/powerbasis.hh> -#include <amdis/utility/TreeData.hpp> +#include <amdis/typetree/TreeData.hpp> #include "Tests.hpp" diff --git a/test/TupleUtilityTest.cpp b/test/TupleUtilityTest.cpp deleted file mode 100644 index 9d99c3baf104c2e3e7e2025c1c505677dd2d6eeb..0000000000000000000000000000000000000000 --- a/test/TupleUtilityTest.cpp +++ /dev/null @@ -1,26 +0,0 @@ -#include <tuple> -#include <iostream> - -#include <amdis/common/TupleUtility.hpp> - -#include "Tests.hpp" - -using namespace AMDiS; - -int main() -{ - using Tuple1 = std::tuple<double,int>; - using TupleDouble = std::tuple<double,double>; - using TupleInt = std::tuple<int,int>; - using Tuple2 = std::tuple<TupleDouble,TupleInt>; - - Tuple1 u{1.3, 2}; - auto v = constructTuple<Tuple1>(1.5); - auto w = foldTuples<Tuple2>(u,v); - - AMDIS_TEST((u == Tuple1{1.3, 2})); - AMDIS_TEST((v == Tuple1{1.5, 1})); - AMDIS_TEST((w == Tuple2{TupleDouble{1.3, 1.5}, TupleDouble{2, 1}} )); - - return report_errors(); -} \ No newline at end of file