Commit 9a07ac65 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

make StandardProblemIteration copyable

parent c4f8fac9
...@@ -49,7 +49,7 @@ namespace AMDiS ...@@ -49,7 +49,7 @@ namespace AMDiS
template <class Traits> template <class Traits>
class ProblemStat class ProblemStat
: public ProblemStatBase : public ProblemStatBase
, public StandardProblemIteration , public StandardProblemIterationAdaptor<ProblemStat<Traits>>
{ {
using Self = ProblemStat; using Self = ProblemStat;
...@@ -81,8 +81,7 @@ namespace AMDiS ...@@ -81,8 +81,7 @@ namespace AMDiS
* access values corresponding to this problem in the parameter file. * access values corresponding to this problem in the parameter file.
**/ **/
explicit ProblemStat(std::string const& name) explicit ProblemStat(std::string const& name)
: StandardProblemIteration(dynamic_cast<ProblemStatBase&>(*this)) : name_(name)
, name_(name)
{} {}
/// Constructor taking additionally a reference to a grid that is used /// Constructor taking additionally a reference to a grid that is used
......
...@@ -53,4 +53,44 @@ namespace AMDiS ...@@ -53,4 +53,44 @@ namespace AMDiS
ProblemStatBase& problem_; ProblemStatBase& problem_;
}; };
/// \brief StandardProblemIteration when derived from ProblemStat
/**
* Use this adaptor when multiple inheritance is used:
* ```
* class Problem
* : public ProblemStatBase
* : StandardProblemIterationAdaptor<Problem>
* {};
* ```
*
* **Requirements:**
* - Model must be derived from ProblemStatBase and from StandardProblemIterationAdaptor
**/
template <class Model>
class StandardProblemIterationAdaptor
: public StandardProblemIteration
{
template <class Self>
static ProblemStatBase& asProblemStatBase(Self& self)
{
Model& model = static_cast<Model&>(self);
return dynamic_cast<ProblemStatBase&>(model);
}
public:
StandardProblemIterationAdaptor()
: StandardProblemIteration(asProblemStatBase(*this))
{}
StandardProblemIterationAdaptor(StandardProblemIterationAdaptor const&)
: StandardProblemIteration(asProblemStatBase(*this))
{}
StandardProblemIterationAdaptor(StandardProblemIterationAdaptor&&)
: StandardProblemIteration(asProblemStatBase(*this))
{}
};
} // end namespace AMDiS } // end namespace AMDiS
#include <amdis/AMDiS.hpp> #include <amdis/AMDiS.hpp>
#include <amdis/AdaptStationary.hpp>
#include <amdis/LocalOperators.hpp> #include <amdis/LocalOperators.hpp>
#include <amdis/ProblemStat.hpp> #include <amdis/ProblemStat.hpp>
...@@ -21,6 +22,19 @@ void test() ...@@ -21,6 +22,19 @@ void test()
prob.addMatrixOperator(sot(T(1)), 0, 0); prob.addMatrixOperator(sot(T(1)), 0, 0);
prob.addVectorOperator(zot(T(1)), 0); prob.addVectorOperator(zot(T(1)), 0);
prob.addDirichletBC(BoundaryType{1}, 0,0, T(0)); prob.addDirichletBC(BoundaryType{1}, 0,0, T(0));
AdaptInfo adaptInfo("adapt");
// test copy constructor of problem
auto prob2(prob);
AdaptStationary adaptStat2("adapt", prob2, adaptInfo);
adaptStat2.adapt();
// test move constructor of problem
auto prob3(std::move(prob2));
AdaptStationary adaptStat3("adapt", prob3, adaptInfo);
adaptStat3.adapt();
} }
int main(int argc, char** argv) int main(int argc, char** argv)
......
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