Commit b044345e authored by Lasse Hinrichsen's avatar Lasse Hinrichsen
Browse files

Use autoCopy when copying vector blocks

This way, types that implement AutonomousValue can specify into what
type they are copied. This can be applied e.g. for proxy types such as
the BlockVectorWindow used in ISTL's VariableBlockVector.

For types that do not implement AutonomousValue, the behavior should
not change.
parent 9861405e
Pipeline #29461 passed with stage
in 3 minutes and 25 seconds
......@@ -145,14 +145,12 @@ auto coordinateRestriction(const ShiftedBoxConstrainedQuadraticFunctional<M, V,
{
using Range = R;
using LocalMatrix = std::decay_t<decltype(f.quadraticPart()[i][i])>;
using LocalVector = std::decay_t<decltype(f.originalLinearPart()[i])>;
using LocalLowerObstacle = std::decay_t<decltype(f.originalLowerObstacle()[i])>;
using LocalUpperObstacle = std::decay_t<decltype(f.originalUpperObstacle()[i])>;
using namespace Dune::MatrixVector;
namespace H = Dune::Hybrid;
LocalVector ri = f.originalLinearPart()[i];
auto ri = autoCopy(f.originalLinearPart()[i]);
const LocalMatrix* Aii_p = nullptr;
const auto& Ai = f.quadraticPart()[i];
......@@ -164,12 +162,14 @@ auto coordinateRestriction(const ShiftedBoxConstrainedQuadraticFunctional<M, V,
Imp::mmv(Aij, f.origin()[j], ri, PriorityTag<1>());
});
LocalLowerObstacle dli = f.originalLowerObstacle()[i];
LocalUpperObstacle dui = f.originalUpperObstacle()[i];
auto dli = autoCopy(f.originalLowerObstacle()[i]);
auto dui = autoCopy(f.originalUpperObstacle()[i]);
dli -= f.origin()[i];
dui -= f.origin()[i];
return BoxConstrainedQuadraticFunctional<LocalMatrix&, LocalVector, LocalLowerObstacle, LocalUpperObstacle, Range>(*Aii_p, std::move(ri), std::move(dli), std::move(dui));
return BoxConstrainedQuadraticFunctional<LocalMatrix&, decltype(ri), decltype(dli), decltype(dui), Range>(*Aii_p, std::move(ri), std::move(dli), std::move(dui));
}
......
......@@ -106,12 +106,11 @@ template<class M, class V, class R, class Index>
auto coordinateRestriction(const ShiftedQuadraticFunctional<M,V,R>& f, const Index& i)
{
using LocalMatrix = std::decay_t<decltype(f.quadraticPart()[i][i])>;
using LocalVector = std::decay_t<decltype(f.originalLinearPart()[i])>;
using namespace Dune::MatrixVector;
namespace H = Dune::Hybrid;
LocalVector ri = f.originalLinearPart()[i];
auto ri = autoCopy(f.originalLinearPart()[i]);
const LocalMatrix* Aii_p = nullptr;
const auto& Ai = f.quadraticPart()[i];
......@@ -129,7 +128,7 @@ auto coordinateRestriction(const ShiftedQuadraticFunctional<M,V,R>& f, const Ind
#endif
});
return QuadraticFunctional<LocalMatrix&, LocalVector, R>(*Aii_p, std::move(ri));
return QuadraticFunctional<LocalMatrix&, decltype(ri), R>(*Aii_p, std::move(ri));
}
/** \brief Coordinate restriction of a quadratic functional
......
......@@ -62,7 +62,7 @@ void gaussSeidelLoop(V& x, const F& f, const BV& ignore, const LS& localSolver)
#ifdef NEW_TNNMG_COMPUTE_ITERATES_DIRECTLY
localSolver(x[i], fLocal, ignore[i]);
#else
auto localCorrection = x[i];
auto localCorrection = autoCopy(x[i]);
localCorrection = 0;
localSolver(localCorrection, fLocal, ignore[i]);
x[i] += localCorrection;
......@@ -105,7 +105,7 @@ void gaussSeidelLoop(V& x, const F& f, const BV& ignore, const LS& localSolvers)
#ifdef NEW_TNNMG_COMPUTE_ITERATES_DIRECTLY
localSolver(x[i], fLocal, ignore[i]);
#else
auto localCorrection = x[i];
auto localCorrection = autoCopy(x[i]);
localCorrection = 0;
H::elementAt(localSolvers, i)(localCorrection, fLocal, ignore[i]);
x[i] += localCorrection;
......
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