13#ifndef DUMUX_SWITCHABLE_PRIMARY_VARIABLES_HH
14#define DUMUX_SWITCHABLE_PRIMARY_VARIABLES_HH
16#include <dune/common/ftraits.hh>
17#include <dune/common/exceptions.hh>
26template<
class PrimaryVariables,
class StateType>
29 using ParentType = PrimaryVariables;
32 using ParentType::ParentType;
34 using ParentType::operator=;
40 DUNE_THROW(Dune::InvalidStateException,
"Model demands setting a primary variable state (like a phase presence)"
41 <<
" but none was set! Use its setState method to set the state.");
51 state_ = std::move(
state);
69 bool stateIsSet_{
false};
76template<
class PrimaryVariables,
class StateType>
79 static constexpr std::size_t
numEq = PrimaryVariables::size();
80 using type = PrimaryVariables;
88template <
class PrimaryVariables,
class StateType>
89struct FieldTraits<
Dumux::SwitchablePrimaryVariables<PrimaryVariables, StateType>>
90:
public FieldTraits<PrimaryVariables>
A primary variable vector with a state to allow variable switches.
Definition: switchableprimaryvariables.hh:28
void invalidateState()
Invalidate the state.
Definition: switchableprimaryvariables.hh:62
StateType state() const
Ask for the state of this primary variable object, e.g. the phase presence.
Definition: switchableprimaryvariables.hh:37
bool stateIsSet() const
Ask if the state has been set.
Definition: switchableprimaryvariables.hh:56
void setState(StateType state)
Set the state of this primary variable object, e.g. the phase presence.
Definition: switchableprimaryvariables.hh:47
Definition: common/pdesolver.hh:24
A helper to deduce a vector with the same size as numbers of equations.
PrimaryVariables type
Definition: switchableprimaryvariables.hh:80
Definition: numeqvector.hh:21
static constexpr std::size_t numEq
Definition: numeqvector.hh:22