Commit 7e636504 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

small changes everywhere, e.g. cleanup of FileWriter, some operations are corrected

parent 6019643a
Pipeline #994 failed with stage
in 3 minutes and 16 seconds
......@@ -65,24 +65,28 @@ namespace AMDiS
Vector const& dofvector)
: FileWriterInterface(baseName)
, dofvector_(dofvector)
, animation_(false)
{
Parameters::get(baseName + "->ParaView animation", animation_);
int m = Parameters::get<int>(baseName + "->ParaView mode").value_or(0);
mode_ = (m == 0 ? Dune::VTK::ascii : Dune::VTK::appendedraw);
init(baseName, ValueCategory_t<Range>{});
}
template <class ValueCat>
void init(std::string const& baseName, ValueCat)
{
int m = Parameters::get<int>(baseName + "->ParaView mode").value_or(0);
mode_ = (m == 0 ? Dune::VTK::ascii : Dune::VTK::appendedraw);
int subSampling = Parameters::get<int>(baseName + "->subsampling").value_or(0);
if (subSampling > 0)
vtkWriter_ = std::make_shared<Dune::SubsamplingVTKWriter<GridView>>(gridView(), subSampling);
else
vtkWriter_ = std::make_shared<Dune::VTKWriter<GridView>>(gridView());
vtkSeqWriter_ = std::make_shared<Dune::VTKSequenceWriter<GridView>>(vtkWriter_, filename_, dir_, "");
if (animation_)
vtkSeqWriter_ = std::make_shared<Dune::VTKSequenceWriter<GridView>>(vtkWriter_, filename_, dir_, "");
vtkWriter_->addVertexData(dofvector_, Dune::VTK::FieldInfo(name_, VTKFieldType<Range>, VTKFieldSize<Range>));
}
......@@ -91,10 +95,12 @@ namespace AMDiS
/// Implements \ref FileWriterInterface::writeFiles
virtual void writeFiles(AdaptInfo& adaptInfo, bool force) override
{
if (!filesystem::exists(dir_))
error_exit("Output directory '",dir_,"' does not exist!");
test_exit(filesystem::exists(dir_), "Output directory '",dir_,"' does not exist!");
if (vtkSeqWriter_)
vtkSeqWriter_->write(adaptInfo.getTime(), mode_);
else if (vtkWriter_)
vtkWriter_->write(filesystem::path({dir_, filename_}).string(), mode_);
}
protected:
......@@ -109,6 +115,9 @@ namespace AMDiS
std::shared_ptr<Dune::VTKWriter<GridView>> vtkWriter_;
std::shared_ptr<Dune::VTKSequenceWriter<GridView>> vtkSeqWriter_;
// write .pvd if animation=true, otherwise write only .vtu
bool animation_;
// represents VTK::OutputType: ascii, appendedraw
Dune::VTK::OutputType mode_;
};
......
......@@ -294,9 +294,11 @@ namespace AMDiS
{
using RawExpr = Underlying_t<Expr>;
static_assert(Concepts::HasGridFunctionOrder<RawExpr>,
"Polynomial degree of expression can not be deduced. You need to provide an explicit value for polynomial order or a quadrature rule in 'makeOperator()'.");
"Polynomial degree of expression can not be deduced. You need to provide a polynomial order or a quadrature rule in 'makeOperator()'.");
return ExpressionPreOperator<Tag, Expr, tag::deduce>{tag, expr};
return Dune::Hybrid::ifElse(bool_<Concepts::HasGridFunctionOrder<RawExpr>>,
[&](auto) { return ExpressionPreOperator<Tag, Expr, tag::deduce>{tag, expr}; },
[&](auto) { return ExpressionPreOperator<Tag, double, tag::deduce>{tag, 0.0}; });
}
/// Store tag and expression and polynomial order of expression to create a \ref GridFunctionOperator
......
......@@ -59,7 +59,7 @@ template <class Traits>
void ProblemInstat<Traits>::initTimestep(AdaptInfo&)
{
if (oldSolution)
oldSolution->copy(*problemStat.getSolutionVec());
oldSolution->copy(*problemStat.getSolutionVector());
}
} // end namespace AMDiS
......@@ -207,7 +207,7 @@ namespace AMDiS
auto getSystemMatrix() const { return systemMatrix; }
std::shared_ptr<SystemVector> getSolutionVec() const
std::shared_ptr<SystemVector> getSolutionVector() const
{
return solution;
}
......@@ -230,8 +230,8 @@ namespace AMDiS
/// Return a point to the rhs system-vector, \ref rhs
auto getRhs() { return rhs; }
auto getRhs() const { return rhs; }
auto getRhsVector() { return rhs; }
auto getRhsVector() const { return rhs; }
/// Return a pointer to the linear solver, \ref linearSolver
......
......@@ -80,7 +80,8 @@ namespace AMDiS
/// \brief A factory for a composite basis composed of lagrange bases of different degree.
template <class GridView, int... degrees>
struct LagrangeBasis {
struct LagrangeBasis
{
using GlobalBasis
= Dune::Functions::DefaultGlobalBasis<typename Impl::LagrangeBasisBuilder<GridView, degrees...>::type>;
};
......@@ -101,6 +102,12 @@ namespace AMDiS
= Dune::Functions::DefaultGlobalBasis<typename Impl::TaylorHoodBasisBuilder<GridView>::type>;
};
template <class GlobalBasisType>
struct DefaultProblemTraits
{
using GlobalBasis = GlobalBasisType;
};
} // end namespace AMDiS
......
......@@ -155,21 +155,37 @@ namespace AMDiS
namespace Impl
{
template <class T, T... Is>
struct IsEqualImpl;
template <class T, T I0, T... Is>
struct IsEqual
{
template <T I>
using compare = bool_t<I0 == I>;
struct IsEqualImpl<T, I0, Is...>
: public std::is_same<std::integer_sequence<T,I0,Is...>,
std::integer_sequence<T,Is...,I0>> {};
enum { value = all_of_v<compare<Is>::value...> };
};
template <class T>
struct IsEqualImpl<T> { enum { value = true }; };
template <class... Ts>
struct IsSameImpl;
template <class T0, class... Ts>
struct IsSameImpl<T0, Ts...>
: public std::is_same<std::tuple<T0,Ts...>,
std::tuple<Ts...,T0>> {};
template <>
struct IsSameImpl<> { enum { value = true }; };
} // end namespace Impl
template <class T, T... values>
using is_equal = Impl::IsEqual<T,values...>;
using IsEqual = Impl::IsEqualImpl<T,values...>;
template <class T, class... Ts>
using is_one_of = or_t<std::is_same<T, Ts>::value...>;
template <class... Ts>
using IsSame = Impl::IsSameImpl<Ts...>;
} // end namespace AMDiS
......@@ -5,6 +5,7 @@
#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>
......@@ -38,7 +39,7 @@ namespace AMDiS
using Self = MultiTypeMatrix;
using Super = std::tuple<Rows...>;
static_assert(is_equal<int, Rows::dimension...>::value,
static_assert(IsEqual<int, Rows::dimension...>::value,
"All columns must have the same length.");
public:
......@@ -59,7 +60,7 @@ namespace AMDiS
MultiTypeMatrix() = default;
/// Construct tuple by initializing all tuple elements with a constant value
MultiTypeMatrix(real_type value)
explicit MultiTypeMatrix(real_type value)
{
*this = value;
}
......
......@@ -75,7 +75,7 @@ namespace AMDiS
friend auto partial(Id, index_t<0>)
{
return Zero{};
return One{};
}
};
......@@ -126,7 +126,7 @@ namespace AMDiS
template <std::size_t I, class... Int>
constexpr int order(Arg<I> const&, Int... orders)
{
return std::get<I>(std::tie(orders...));
return std::get<I>(std::forward_as_tuple(orders...));
}
template <std::size_t I, std::size_t J>
......
......@@ -61,7 +61,7 @@ namespace AMDiS
// generated unary functors using a macro...
// approximate polynomial order
#ifndef DXOYGEN
#ifndef DOXYGEN
AMDIS_MAKE_UNARY_FUNCTOR( Ceil, std::ceil(x), 0.0 )
AMDIS_MAKE_UNARY_FUNCTOR( Floor, std::floor(x), 0.0 )
AMDIS_MAKE_UNARY_FUNCTOR( Sqrt, std::sqrt(x), 1.0/(2.0 * std::sqrt(x)) )
......
......@@ -5,6 +5,7 @@
#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>
......@@ -16,7 +17,8 @@ namespace AMDiS
template <class F, class... Gs>
struct Composer
{
template <class F_, class... Gs_>
template <class F_, class... Gs_,
REQUIRES( Concepts::Similar<Types<F,Gs...>, Types<F_,Gs_...>>) >
constexpr Composer(F_&& f, Gs_&&... gs)
: f_(std::forward<F_>(f))
, gs_(std::forward<Gs_>(gs)...)
......@@ -33,14 +35,6 @@ namespace AMDiS
std::tuple<Gs...> gs_;
};
#ifdef DUNE_HAVE_CXX_CLASS_TEMPLATE_ARGUMENT_DEDUCTION
// deduction guide for the class \ref composer
template <class F_, class... Gs_>
Composer(F_&&, Gs_&&...)
-> Composer<std::decay_t<F_>, std::decay_t<Gs_>...>;
#endif
#ifndef DOXYGEN
template <class F, class... Gs>
struct ComposerBuilder
......
......@@ -42,6 +42,11 @@ namespace AMDiS
original = this->string();
}
template <class String>
path(std::initializer_list<String> const& list)
: path(list.begin(), list.end())
{}
/// Removes filename path component
path& remove_filename()
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment