Commit 4226a463 authored by Dennis Gläser's avatar Dennis Gläser
Browse files

[newtonvarsbackend] use more generic function names

parent a33a9454
......@@ -53,7 +53,7 @@ class MultiDomainNewtonSolver: public NewtonSolver<Assembler, LinearSolver, Reas
using typename ParentType::Backend;
using typename ParentType::SolutionVector;
static constexpr bool assemblerExportsVariables = Impl::exportsVariables<Assembler>;
static constexpr bool assemblerExportsVariables = Detail::exportsVariables<Assembler>;
template<std::size_t i>
using PrimaryVariableSwitch = typename Detail::GetPVSwitchMultiDomain<Assembler, i>::type;
......@@ -96,7 +96,7 @@ public:
void newtonBeginStep(const Variables& varsCurrentIter) override
{
ParentType::newtonBeginStep(varsCurrentIter);
couplingManager_->updateSolution(Backend::getDofVector(varsCurrentIter));
couplingManager_->updateSolution(Backend::dofs(varsCurrentIter));
}
/*!
......@@ -141,7 +141,7 @@ public:
using namespace Dune::Hybrid;
forEach(std::make_index_sequence<Assembler::Traits::numSubDomains>{}, [&](auto&& id)
{
auto& uCurrentIter = Backend::getDofVector(varsCurrentIter)[id];
auto& uCurrentIter = Backend::dofs(varsCurrentIter)[id];
if constexpr (!assemblerExportsVariables)
this->invokePriVarSwitch_(this->assembler().gridVariables(id),
uCurrentIter, id, HasPriVarsSwitch<std::decay_t<decltype(id)>::value>{});
......@@ -150,7 +150,7 @@ public:
});
ParentType::newtonEndStep(varsCurrentIter, uLastIter);
couplingManager_->updateSolution(Backend::getDofVector(varsCurrentIter));
couplingManager_->updateSolution(Backend::dofs(varsCurrentIter));
}
private:
......@@ -169,7 +169,7 @@ private:
{
using namespace Dune::Hybrid;
auto& priVarSwitch = *elementAt(priVarSwitches_, id);
auto& sol = Backend::getDofVector(vars)[id];
auto& sol = Backend::dofs(vars)[id];
priVarSwitch.reset(sol.size());
priVarsSwitchedInLastIteration_[i] = false;
......
......@@ -205,7 +205,7 @@ private:
// enable models with primary variable switch
// TODO: Always use ParentType::Variables once we require assemblers to export variables
static constexpr bool assemblerExportsVariables = Impl::exportsVariables<Assembler>;
static constexpr bool assemblerExportsVariables = Detail::exportsVariables<Assembler>;
using PriVarSwitchVariables
= std::conditional_t<assemblerExportsVariables,
typename ParentType::Variables,
......@@ -337,7 +337,7 @@ public:
{
// set solution to previous solution & reset time step
Backend::update(vars, this->assembler().prevSol());
this->assembler().resetTimeStep(Backend::getDofVector(vars));
this->assembler().resetTimeStep(Backend::dofs(vars));
if (verbosity_ >= 1)
{
......@@ -387,12 +387,12 @@ public:
if constexpr (hasPriVarsSwitch<PriVarSwitchVariables>)
{
if constexpr (assemblerExportsVariables)
priVarSwitchAdapter_->initialize(Backend::getDofVector(initVars), initVars);
priVarSwitchAdapter_->initialize(Backend::dofs(initVars), initVars);
else // this assumes assembly with solution (i.e. Variables=SolutionVector)
priVarSwitchAdapter_->initialize(initVars, this->assembler().gridVariables());
}
const auto& initSol = Backend::getDofVector(initVars);
const auto& initSol = Backend::dofs(initVars);
// write the initial residual if a convergence writer was set
if (convergenceWriter_)
......@@ -400,7 +400,7 @@ public:
this->assembler().assembleResidual(initVars);
// dummy vector, there is no delta before solving the linear system
auto delta = Backend::makeZeroDofVector(Backend::size(initSol));
auto delta = Backend::zeros(Backend::size(initSol));
convergenceWriter_->write(initSol, delta, this->assembler().residual());
}
......@@ -617,7 +617,7 @@ public:
if constexpr (hasPriVarsSwitch<PriVarSwitchVariables>)
{
if constexpr (assemblerExportsVariables)
priVarSwitchAdapter_->invoke(Backend::getDofVector(vars), vars);
priVarSwitchAdapter_->invoke(Backend::dofs(vars), vars);
else // this assumes assembly with solution (i.e. Variables=SolutionVector)
priVarSwitchAdapter_->invoke(vars, this->assembler().gridVariables());
}
......@@ -853,7 +853,7 @@ protected:
Backend::update(vars, uCurrentIter);
if constexpr (!assemblerExportsVariables)
this->assembler().updateGridVariables(Backend::getDofVector(vars));
this->assembler().updateGridVariables(Backend::dofs(vars));
}
void computeResidualReduction_(const Variables& vars)
......@@ -863,7 +863,7 @@ protected:
if constexpr (Detail::hasNorm<LinearSolver, SolutionVector>())
{
if constexpr (!assemblerExportsVariables)
this->assembler().assembleResidual(Backend::getDofVector(vars));
this->assembler().assembleResidual(Backend::dofs(vars));
else
this->assembler().assembleResidual(vars);
residualNorm_ = this->linearSolver().norm(this->assembler().residual());
......@@ -871,7 +871,7 @@ protected:
else
{
if constexpr (!assemblerExportsVariables)
residualNorm_ = this->assembler().residualNorm(Backend::getDofVector(vars));
residualNorm_ = this->assembler().residualNorm(Backend::dofs(vars));
else
residualNorm_ = this->assembler().residualNorm(vars);
}
......@@ -920,8 +920,8 @@ private:
newtonBegin(vars);
// the given solution is the initial guess
auto uLastIter = Backend::getDofVector(vars);
auto deltaU = Backend::getDofVector(vars);
auto uLastIter = Backend::dofs(vars);
auto deltaU = Backend::dofs(vars);
// setup timers
Dune::Timer assembleTimer(false);
......@@ -939,7 +939,7 @@ private:
// make the current solution to the old one
if (numSteps_ > 0)
uLastIter = Backend::getDofVector(vars);
uLastIter = Backend::dofs(vars);
if (verbosity_ >= 1 && enableDynamicOutput_)
std::cout << "Assemble: r(x^k) = dS/dt + div F - q; M = grad r"
......@@ -996,7 +996,7 @@ private:
if (convergenceWriter_)
{
this->assembler().assembleResidual(vars);
convergenceWriter_->write(Backend::getDofVector(vars), deltaU, this->assembler().residual());
convergenceWriter_->write(Backend::dofs(vars), deltaU, this->assembler().residual());
}
// detect if the method has converged
......@@ -1011,7 +1011,7 @@ private:
{
totalWastedIter_ += numSteps_;
// TODO: what should NewtonFail receive as arg?
auto uCurrentIter = Backend::getDofVector(vars);
auto uCurrentIter = Backend::dofs(vars);
newtonFail(uCurrentIter);
return false;
}
......@@ -1040,7 +1040,7 @@ private:
totalWastedIter_ += numSteps_;
// TODO: what should NewtonFail receive as arg?
auto uCurrentIter = Backend::getDofVector(vars);
auto uCurrentIter = Backend::dofs(vars);
newtonFail(uCurrentIter);
return false;
}
......
......@@ -64,7 +64,7 @@ public:
static std::size_t size(const DofVector& d)
{ return 1; }
static DofVector makeZeroDofVector(std::size_t size)
static DofVector zeros(std::size_t size)
{ return 0.0; }
};
......@@ -82,7 +82,7 @@ public:
static std::size_t size(const DofVector& d)
{ return d.size(); }
static DofVector makeZeroDofVector(std::size_t size)
static DofVector zeros(std::size_t size)
{ DofVector d; d.resize(size); return d; }
};
......@@ -111,7 +111,7 @@ public:
return result;
}
static DofVector makeZeroDofVector(const VectorSizeInfo& size)
static DofVector zeros(const VectorSizeInfo& size)
{
DofVector result;
using namespace Dune::Hybrid;
......@@ -122,7 +122,7 @@ public:
}
};
namespace Impl {
namespace Detail {
template<class Vars>
using SolutionVectorType = typename Vars::SolutionVector;
......@@ -151,11 +151,11 @@ public:
{ v = dofs; }
//! return const reference to dof vector
static const DofVector& getDofVector(const Variables& v)
static const DofVector& dofs(const Variables& v)
{ return v; }
//! return reference to dof vector
static DofVector& getDofVector(Variables& v)
static DofVector& dofs(Variables& v)
{ return v; }
};
......@@ -178,14 +178,14 @@ public:
{ v.update(dofs); }
//! return const reference to dof vector
static const DofVector& getDofVector(const Variables& v)
static const DofVector& dofs(const Variables& v)
{ return v.dofs(); }
//! return reference to dof vector
static DofVector& getDofVector(Variables& v)
static DofVector& dofs(Variables& v)
{ return v.dofs(); }
};
} // end namespace Impl
} // end namespace Detail
/*!
* \ingroup Nonlinear
......@@ -195,7 +195,7 @@ public:
* the time level.
*/
template<class Vars>
using NewtonVariablesBackend = Impl::NewtonVariablesBackend<Vars, Dune::Std::is_detected_v<Impl::SolutionVectorType, Vars>>;
using NewtonVariablesBackend = Detail::NewtonVariablesBackend<Vars, Dune::Std::is_detected_v<Detail::SolutionVectorType, Vars>>;
} // end namespace Dumux
......
......@@ -53,7 +53,7 @@ public:
const SolutionVector &uLastIter) final
{
ParentType::newtonEndStep(varsCurrentIter, uLastIter);
const auto& uCurrentIter = Backend::getDofVector(varsCurrentIter);
const auto& uCurrentIter = Backend::dofs(varsCurrentIter);
// Averages the face velocities of a vertex. Implemented in the model.
// The velocities are stored in the model.
......
......@@ -69,7 +69,7 @@ private:
const SolutionVector &uLastIter,
const SolutionVector &deltaU) final
{
auto uCurrentIter = Backend::getDofVector(varsCurrentIter);
auto uCurrentIter = Backend::dofs(varsCurrentIter);
uCurrentIter = uLastIter;
uCurrentIter -= deltaU;
......
Supports Markdown
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