Commit f688bc11 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

Cleanup of directory structure and removed obsolete files and functions

parent 0ef5f46a
......@@ -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);
}
......
......@@ -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");
}
......
#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
#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)
#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
......@@ -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`.
/**
......
......@@ -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
{
......
#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
......@@ -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:
......
......@@ -3,8 +3,6 @@
#include <string>
#include <vector>
#include <amdis/utility/String.hpp>
namespace AMDiS
{
namespace filesystem
......
#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
#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
......@@ -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
#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...>;
};
}
......