11 template <
class,
class>
class Preconditioner;
16 template <
class,
class,
class,
class>
class PreconditionerFactory;
18 namespace SystemTraits_Detail
20 template <
class Functional>
21 std::integral_constant<int,Functional::stateId>
getStateIdImpl(
decltype(Functional::stateId)*);
23 template <
class Functional>
24 std::integral_constant<int,Functional::yIdx>
getStateIdImpl(
decltype(Functional::yIdx)*);
26 template <
class Functional>
27 std::integral_constant<int,Functional::controlId>
getControlIdImpl(
decltype(Functional::controlId)*);
29 template <
class Functional>
30 std::integral_constant<int,Functional::uIdx>
getControlIdImpl(
decltype(Functional::uIdx)*);
32 template <
class Functional>
33 std::integral_constant<int,Functional::adjointId>
getAdjointIdImpl(
decltype(Functional::adjointId)*);
35 template <
class Functional>
36 std::integral_constant<int,Functional::pIdx>
getAdjointIdImpl(
decltype(Functional::pIdx)*);
38 template <
class Functional>
39 std::integral_constant<int,Functional::lIdx>
getAdjointIdImpl(
decltype(Functional::lIdx)*);
43 template <
class Functional>
46 typedef decltype(SystemTraits_Detail::getStateIdImpl<Functional>(
nullptr)) type;
50 template <
class Functional>
53 typedef decltype(SystemTraits_Detail::getControlIdImpl<Functional>(
nullptr)) type;
57 template <
class Functional>
60 typedef decltype(SystemTraits_Detail::getAdjointIdImpl<Functional>(
nullptr)) type;
65 template <
class Functional,
class Assembler>
66 struct OptimalControlTraits
69 static constexpr int yIdx = getStateId<Functional>();
70 static constexpr int uIdx = getControlId<Functional>();
71 static constexpr int pIdx = getAdjointId<Functional>();
73 static constexpr int stateId = yIdx;
74 static constexpr int adjointId = pIdx;
75 static constexpr int controlId = uIdx;
78 typedef typename Assembler::Grid Grid;
81 typedef typename Assembler::Spaces Spaces;
84 typedef typename Assembler::AnsatzVariableSetDescription AnsatzVariableSetDescription;
85 typedef typename Assembler::TestVariableSetDescription TestVariableSetDescription;
88 static constexpr int stateSpaceId = boost::fusion::result_of::value_at_c<typename AnsatzVariableSetDescription::Variables,stateId>::type::spaceIndex;
89 static constexpr int controlSpaceId = boost::fusion::result_of::value_at_c<typename AnsatzVariableSetDescription::Variables,controlId>::type::spaceIndex;
90 static constexpr int adjointSpaceId = boost::fusion::result_of::value_at_c<typename AnsatzVariableSetDescription::Variables,adjointId>::type::spaceIndex;
96 static_assert(stateComponents == adjointComponents,
"state and adjoint variables should have the same number of components");
99 typedef AssembledGalerkinOperator<Assembler> SystemOperator;
100 typedef AssembledGalerkinOperator<Assembler,pIdx,pIdx+1,yIdx,yIdx+1> StateOperator;
101 typedef AssembledGalerkinOperator<Assembler,pIdx,pIdx+1,uIdx,uIdx+1> ControlOperator;
102 typedef AssembledGalerkinOperator<Assembler,yIdx,yIdx+1,pIdx,pIdx+1> AdjointOperator;
103 typedef AssembledGalerkinOperator<Assembler,uIdx,uIdx+1,uIdx,uIdx+1> NormUOperator;
104 typedef AssembledGalerkinOperator<Assembler,yIdx,yIdx+1,yIdx,yIdx+1> NormYOperator;
105 typedef AssembledGalerkinOperator<Assembler,uIdx,uIdx+1,yIdx,yIdx+1> NormUYOperator;
106 typedef AssembledGalerkinOperator<Assembler,yIdx,yIdx+1,uIdx,uIdx+1> NormYUOperator;
107 typedef AssembledGalerkinOperator<Assembler,uIdx,uIdx+1,pIdx,pIdx+1> ControlOperatorT;
110 typedef typename SystemOperator::Domain Domain;
111 typedef typename SystemOperator::Range Range;
112 typedef typename Functional::AnsatzVars::Scalar Scalar;
113 typedef typename Functional::AnsatzVars::template CoefficientVectorRepresentation<yIdx,yIdx+1> CreateVectorY;
114 typedef typename CreateVectorY::type VectorY;
115 typedef typename Functional::AnsatzVars::template CoefficientVectorRepresentation<uIdx,uIdx+1> CreateVectorU;
116 typedef typename CreateVectorU::type VectorU;
117 typedef typename Functional::AnsatzVars::template CoefficientVectorRepresentation<pIdx,pIdx+1> CreateVectorP;
118 typedef typename CreateVectorP::type VectorP;
119 typedef typename Functional::AnsatzVars::template CoefficientVectorRepresentation<> CreateCoefficientVector;
120 typedef typename CreateCoefficientVector::type CoefficientVector;
121 typedef VectorY StateCoefficientVector;
122 typedef VectorP AdjointCoefficientVector;
123 typedef VectorU ControlCoefficientVector;
124 typedef CreateVectorY StateCoefficientVectorCreator;
125 typedef CreateVectorP AdjointCoefficientVectorCreator;
126 typedef CreateVectorU ControlCoefficientVectorCreator;
129 typedef Dune::Preconditioner<VectorY,VectorP> StatePreconditioner;
130 typedef Dune::Preconditioner<VectorP,VectorY> AdjointPreconditioner;
131 typedef Dune::Preconditioner<VectorU,VectorU> NormUPreconditioner;
134 typedef PreconditionerFactory<Assembler,VectorY,VectorY,Scalar> NormYPreconditionerFactory;
135 typedef PreconditionerFactory<Assembler,VectorU,VectorU,Scalar> NormUPreconditionerFactory;
136 typedef PreconditionerFactory<Assembler,VectorP,VectorY,Scalar> AdjointPreconditionerFactory;
137 typedef PreconditionerFactory<Assembler,VectorY,VectorP,Scalar> StatePreconditionerFactory;
140 typedef MultiGridSolver<Grid,stateComponents> StateMGSolver;
141 typedef MultiGridSolver<Grid,controlComponents> ControlMGSolver;
144 typedef MultiGridPreconditioner<Grid,stateComponents> StateMGPreconditioner;
145 typedef MultiGridPreconditioner<Grid,controlComponents> ControlMGPreconditioner;
constexpr int getStateId()
constexpr int getControlId()
std::integral_constant< int, Functional::controlId > getControlIdImpl(decltype(Functional::controlId) *)
constexpr int getAdjointId()
std::integral_constant< int, Functional::stateId > getStateIdImpl(decltype(Functional::stateId) *)
std::integral_constant< int, Functional::adjointId > getAdjointIdImpl(decltype(Functional::adjointId) *)
static int const m
number of component of this variable