14#ifndef DUMUX_COMMON_VARIABLES_BACKEND_HH
15#define DUMUX_COMMON_VARIABLES_BACKEND_HH
21#include <dune/common/indices.hh>
22#include <dune/common/typetraits.hh>
23#include <dune/common/hybridutilities.hh>
24#include <dune/common/std/type_traits.hh>
25#include <dune/common/typetraits.hh>
26#include <dune/istl/bvector.hh>
33template<
class... Args>
43 auto operator()(
const V& v) ->
decltype(std::declval<V>().resize(0))
59template<class DofVector, bool isScalar = Dune::IsNumber<DofVector>::value>
82 template<
class OtherDofVector>
111 if constexpr (Detail::DofBackend::hasResize<Vector>())
117 template<
class OtherDofVector>
118 static void axpy(
typename DofVector::field_type a,
const OtherDofVector& x,
DofVector& y)
120 for (
typename DofVector::size_type i = 0; i < y.size(); ++i)
122 if constexpr (Dune::IsNumber<std::decay_t<
decltype(y[0])>>::value)
134template<
class... Blocks>
138 static constexpr auto numBlocks = DV::size();
140 using VectorSizeInfo = std::array<std::size_t, numBlocks>;
149 VectorSizeInfo result;
150 using namespace Dune::Hybrid;
151 forEach(std::make_index_sequence<numBlocks>{}, [&](
auto i) {
152 result[i] = d[Dune::index_constant<i>{}].size();
161 using namespace Dune::Hybrid;
162 forEach(std::make_index_sequence<numBlocks>{}, [&](
auto i) {
163 result[Dune::index_constant<i>{}].resize(size[i]);
169 template<class Scalar, class OtherDofVector, std::enable_if_t< Dune::IsNumber<Scalar>::value,
int> = 0>
172 using namespace Dune::Hybrid;
173 forEach(std::make_index_sequence<numBlocks>{}, [&](
auto i) {
174 DofBackend<std::decay_t<
decltype(y[Dune::index_constant<i>{}])>>::axpy(
175 a, x[Dune::index_constant<i>{}], y[Dune::index_constant<i>{}]
186template<
class Vars,
bool varsExportSolution>
203 using typename ParentType::DofVector;
static void update(Variables &v, const DofVector &dofs)
update to new solution vector
Definition: variablesbackend.hh:206
Vars Variables
Definition: variablesbackend.hh:202
static const DofVector & dofs(const Variables &v)
return const reference to dof vector
Definition: variablesbackend.hh:210
static DofVector & dofs(Variables &v)
return reference to dof vector
Definition: variablesbackend.hh:214
static void update(Variables &v, const DofVector &dofs)
update to new solution vector
Definition: variablesbackend.hh:232
Vars Variables
the type of the variables object
Definition: variablesbackend.hh:229
static DofVector & dofs(Variables &v)
return reference to dof vector
Definition: variablesbackend.hh:240
static const DofVector & dofs(const Variables &v)
return const reference to dof vector
Definition: variablesbackend.hh:236
typename Vars::SolutionVector DofVector
Definition: variablesbackend.hh:228
Definition: variablesbackend.hh:187
static SizeType size(const DofVector &d)
Return the number of entries in the sub-dof-vectors.
Definition: variablesbackend.hh:147
static void axpy(Scalar a, const OtherDofVector &x, DofVector &y)
Perform axpy operation (y += a * x)
Definition: variablesbackend.hh:170
VectorSizeInfo SizeType
Definition: variablesbackend.hh:144
static DofVector zeros(const SizeType &size)
Make a zero-initialized dof vector instance.
Definition: variablesbackend.hh:158
static SizeType size(const DofVector &d)
Return the number of entries in the dof vector.
Definition: variablesbackend.hh:74
static DofVector zeros(SizeType size)
Make a zero-initialized dof vector instance.
Definition: variablesbackend.hh:78
std::size_t SizeType
Definition: variablesbackend.hh:71
Scalar DofVector
the type of the dofs parametrizing the variables object
Definition: variablesbackend.hh:70
static void axpy(Scalar a, const OtherDofVector &x, DofVector &y)
Perform axpy operation (y += a * x)
Definition: variablesbackend.hh:83
static SizeType size(const DofVector &d)
Return the number of entries in the dof vector.
Definition: variablesbackend.hh:104
static void axpy(typename DofVector::field_type a, const OtherDofVector &x, DofVector &y)
Perform axpy operation (y += a * x)
Definition: variablesbackend.hh:118
std::size_t SizeType
Definition: variablesbackend.hh:101
Vector DofVector
the type of the dofs parametrizing the variables object
Definition: variablesbackend.hh:100
static DofVector zeros(SizeType size)
Make a zero-initialized dof vector instance.
Definition: variablesbackend.hh:108
Class providing operations with primary variable vectors.
Definition: variablesbackend.hh:60
Definition: variablesbackend.hh:34
constexpr auto isValid(const Expression &t)
A function that creates a test functor to do class member introspection at compile time.
Definition: isvalid.hh:81
A helper function for class member function introspection.
Definition: variablesbackend.hh:38
static constexpr auto hasResize()
Definition: variablesbackend.hh:48
typename Vars::SolutionVector SolutionVectorType
Definition: variablesbackend.hh:184
Definition: common/pdesolver.hh:24
Definition: variablesbackend.hh:41
auto operator()(const V &v) -> decltype(std::declval< V >().resize(0))
Definition: variablesbackend.hh:43