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/istl/bvector.hh>
30template<
class... Args>
41template<class DofVector, bool isScalar = Dune::IsNumber<DofVector>::value>
64 template<
class OtherDofVector>
91 {
DofVector d; d.resize(size);
return d; }
94 template<
class OtherDofVector>
95 static void axpy(
typename DofVector::field_type a,
const OtherDofVector& x,
DofVector& y)
97 for (
typename DofVector::size_type i = 0; i < y.size(); ++i)
106template<
class... Blocks>
110 static constexpr auto numBlocks = DV::size();
112 using VectorSizeInfo = std::array<std::size_t, numBlocks>;
121 VectorSizeInfo result;
122 using namespace Dune::Hybrid;
123 forEach(std::make_index_sequence<numBlocks>{}, [&](
auto i) {
124 result[i] = d[Dune::index_constant<i>{}].size();
133 using namespace Dune::Hybrid;
134 forEach(std::make_index_sequence<numBlocks>{}, [&](
auto i) {
135 result[Dune::index_constant<i>{}].resize(size[i]);
141 template<class Scalar, class OtherDofVector, std::enable_if_t< Dune::IsNumber<Scalar>::value,
int> = 0>
144 using namespace Dune::Hybrid;
145 forEach(std::make_index_sequence<numBlocks>{}, [&](
auto i) {
146 DofBackend<std::decay_t<
decltype(y[Dune::index_constant<i>{}])>>::axpy(
147 a, x[Dune::index_constant<i>{}], y[Dune::index_constant<i>{}]
158template<
class Vars,
bool varsExportSolution>
175 using typename ParentType::DofVector;
197:
public DofBackend<typename Vars::SolutionVector>
static void update(Variables &v, const DofVector &dofs)
update to new solution vector
Definition: variablesbackend.hh:178
Vars Variables
Definition: variablesbackend.hh:174
static const DofVector & dofs(const Variables &v)
return const reference to dof vector
Definition: variablesbackend.hh:182
static DofVector & dofs(Variables &v)
return reference to dof vector
Definition: variablesbackend.hh:186
static void update(Variables &v, const DofVector &dofs)
update to new solution vector
Definition: variablesbackend.hh:204
Vars Variables
the type of the variables object
Definition: variablesbackend.hh:201
static DofVector & dofs(Variables &v)
return reference to dof vector
Definition: variablesbackend.hh:212
static const DofVector & dofs(const Variables &v)
return const reference to dof vector
Definition: variablesbackend.hh:208
typename Vars::SolutionVector DofVector
Definition: variablesbackend.hh:200
Definition: variablesbackend.hh:159
static SizeType size(const DofVector &d)
Return the number of entries in the sub-dof-vectors.
Definition: variablesbackend.hh:119
static void axpy(Scalar a, const OtherDofVector &x, DofVector &y)
Perform axpy operation (y += a * x)
Definition: variablesbackend.hh:142
VectorSizeInfo SizeType
Definition: variablesbackend.hh:116
static DofVector zeros(const SizeType &size)
Make a zero-initialized dof vector instance.
Definition: variablesbackend.hh:130
static SizeType size(const DofVector &d)
Return the number of entries in the dof vector.
Definition: variablesbackend.hh:56
static DofVector zeros(SizeType size)
Make a zero-initialized dof vector instance.
Definition: variablesbackend.hh:60
std::size_t SizeType
Definition: variablesbackend.hh:53
Scalar DofVector
the type of the dofs parametrizing the variables object
Definition: variablesbackend.hh:52
static void axpy(Scalar a, const OtherDofVector &x, DofVector &y)
Perform axpy operation (y += a * x)
Definition: variablesbackend.hh:65
static SizeType size(const DofVector &d)
Return the number of entries in the dof vector.
Definition: variablesbackend.hh:86
static void axpy(typename DofVector::field_type a, const OtherDofVector &x, DofVector &y)
Perform axpy operation (y += a * x)
Definition: variablesbackend.hh:95
std::size_t SizeType
Definition: variablesbackend.hh:83
Vector DofVector
the type of the dofs parametrizing the variables object
Definition: variablesbackend.hh:82
static DofVector zeros(SizeType size)
Make a zero-initialized dof vector instance.
Definition: variablesbackend.hh:90
Class providing operations with primary variable vectors.
Definition: variablesbackend.hh:42
Definition: variablesbackend.hh:31
typename Vars::SolutionVector SolutionVectorType
Definition: variablesbackend.hh:156
Definition: common/pdesolver.hh:24