25#ifndef DUMUX_SWITCHABLE_PRIMARY_VARIABLES_HH
26#define DUMUX_SWITCHABLE_PRIMARY_VARIABLES_HH
28#include <dune/common/ftraits.hh>
29#include <dune/common/exceptions.hh>
38template<
class PrimaryVariables,
class StateType>
41 using ParentType = PrimaryVariables;
44 using ParentType::ParentType;
46 using ParentType::operator=;
52 DUNE_THROW(Dune::InvalidStateException,
"Model demands setting a primary variable state (like a phase presence)"
53 <<
" but none was set! Use its setState method to set the state.");
63 state_ = std::move(
state);
75 bool stateIsSet_{
false};
82template<
class PrimaryVariables,
class StateType>
85 static constexpr std::size_t
numEq = PrimaryVariables::size();
86 using type = PrimaryVariables;
94template <
class PrimaryVariables,
class StateType>
95struct FieldTraits<
Dumux::SwitchablePrimaryVariables<PrimaryVariables, StateType>>
96:
public FieldTraits<PrimaryVariables>
A helper to deduce a vector with the same size as numbers of equations.
Definition: common/pdesolver.hh:36
Definition: numeqvector.hh:33
static constexpr std::size_t numEq
Definition: numeqvector.hh:34
A primary variable vector with a state to allow variable switches.
Definition: switchableprimaryvariables.hh:40
void invalidateState()
Invalidate the state.
Definition: switchableprimaryvariables.hh:68
StateType state() const
Ask for the state of this primary variable object, e.g. the phase presence.
Definition: switchableprimaryvariables.hh:49
void setState(StateType state)
Set the state of this primary variable object, e.g. the phase presence.
Definition: switchableprimaryvariables.hh:59
PrimaryVariables type
Definition: switchableprimaryvariables.hh:86