DOpE
higher_order_dwrc_control.h
Go to the documentation of this file.
1 
24 #ifndef _HIGHER_ORDER_DWRC_CONTROL_H_
25 #define _HIGHER_ORDER_DWRC_CONTROL_H_
26 
27 #include "dwrdatacontainer.h"
28 #include <deal.II/fe/fe_tools.h>
29 
30 namespace DOpE
31 {
38  template<class STH, class IDC, class EDC, class FDC, typename VECTOR>
39  class HigherOrderDWRContainerControl : public DWRDataContainer<STH, IDC, EDC, FDC,
40  VECTOR>
41  {
42  public:
55  HigherOrderDWRContainerControl(STH& higher_order_sth, IDC& higher_order_idc,
56  std::string control_behavior, std::string state_behavior, ParameterReader &param_reader,
59  : DWRDataContainer<STH, IDC, EDC, FDC, VECTOR>(ee_terms), _sth_higher_order(
60  higher_order_sth), _idc_higher_order(higher_order_idc), _res_eval(res_eval),
61  _PI_h_u(NULL), _PI_h_z(NULL), _PI_h_q(NULL)
62  {
63  if (this->GetEETerms() == DOpEtypes::primal_only
64  || this->GetEETerms() == DOpEtypes::mixed
66  {
67  _PI_h_z = new StateVector<VECTOR>(&GetHigherOrderSTH(),
68  state_behavior, param_reader);
69  }
70  if (this->GetEETerms() == DOpEtypes::dual_only
71  || this->GetEETerms() == DOpEtypes::mixed
73  {
74  _PI_h_u = new StateVector<VECTOR>(&GetHigherOrderSTH(),
75  state_behavior, param_reader);
76  }
77  if (this->GetEETerms() == DOpEtypes::mixed_control)
78  {
80  control_behavior);
81  }
82  }
83 
84  virtual
86  {
87  if (_PI_h_z != NULL)
88  delete _PI_h_z;
89  if (_PI_h_u != NULL)
90  delete _PI_h_u;
91  if (_PI_h_q != NULL)
92  delete _PI_h_q;
93  }
94 
95  std::string
96  GetName() const
97  {
98  return "DWR-Estimator-with-Control";
99  }
100 
101  template<class STH2>
102  void
103  Initialize(STH2* sth, unsigned int control_n_blocks,
104  std::vector<unsigned int>& control_block_component,
105  unsigned int state_n_blocks,
106  std::vector<unsigned int>& state_block_component)
107  {
108  _sth = dynamic_cast<STH*>(sth);
109  _control_n_blocks = control_n_blocks;
110  _control_block_component = &control_block_component;
111  _state_n_blocks = state_n_blocks;
112  _state_block_component = &state_block_component;
113  }
114 
119  void
120  ReInit(unsigned int n_elements);
121 
122  STH&
124  {
125  return GetHigherOrderSTH();
126  }
127 
128  const STH&
129  GetWeightSTH() const
130  {
131  return GetHigherOrderSTH();
132  }
133 
134  IDC&
136  {
137  return GetHigherOrderIDC();
138  }
139 
140  const IDC&
141  GetWeightIDC() const
142  {
143  return GetHigherOrderIDC();
144  }
145 
148  {
149  return *_PI_h_u;
150  }
151 
154  {
155  return *_PI_h_z;
156  }
159  {
160  return *_PI_h_q;
161  }
162 
168  void
170  {
171  VECTOR u_high;
172  u_high.reinit(GetPI_h_u().GetSpacialVector());
173 
174  dealii::FETools::extrapolate(
175  GetSTH().GetStateDoFHandler().GetDEALDoFHandler(),
176  u.GetSpacialVector(),
177  GetHigherOrderSTH().GetStateDoFHandler().GetDEALDoFHandler(),
178  GetHigherOrderSTH().GetStateDoFConstraints(),
179  GetPI_h_u().GetSpacialVector());
180  dealii::FETools::interpolate(
181  GetSTH().GetStateDoFHandler().GetDEALDoFHandler(),
182  u.GetSpacialVector(),
183  GetHigherOrderSTH().GetStateDoFHandler().GetDEALDoFHandler(),
184  GetHigherOrderSTH().GetStateDoFConstraints(), u_high);
185  GetPI_h_u().GetSpacialVector().add(-1., u_high);
186  }
187 
188  void
189  PreparePI_h_u(const VECTOR& u)
190  {
191  VECTOR u_high;
192  u_high.reinit(GetPI_h_u().GetSpacialVector());
193 
194  dealii::FETools::extrapolate(
195  GetSTH().GetStateDoFHandler().GetDEALDoFHandler(), u,
196  GetHigherOrderSTH().GetStateDoFHandler().GetDEALDoFHandler(),
197  GetHigherOrderSTH().GetStateDoFConstraints(),
198  GetPI_h_u().GetSpacialVector());
199  dealii::FETools::interpolate(
200  GetSTH().GetStateDoFHandler().GetDEALDoFHandler(), u,
201  GetHigherOrderSTH().GetStateDoFHandler().GetDEALDoFHandler(),
202  GetHigherOrderSTH().GetStateDoFConstraints(), u_high);
203  GetPI_h_u().GetSpacialVector().add(-1., u_high);
204  }
205 
211  void
213  {
214  VECTOR z_high;
215  z_high.reinit(GetPI_h_z().GetSpacialVector());
216 
217  dealii::FETools::extrapolate(
218  GetSTH().GetStateDoFHandler().GetDEALDoFHandler(),
219  z.GetSpacialVector(),
220  GetHigherOrderSTH().GetStateDoFHandler().GetDEALDoFHandler(),
221  GetHigherOrderSTH().GetStateDoFConstraints(),
222  GetPI_h_z().GetSpacialVector());
223 
224  dealii::FETools::interpolate(
225  GetSTH().GetStateDoFHandler().GetDEALDoFHandler(),
226  z.GetSpacialVector(),
227  GetHigherOrderSTH().GetStateDoFHandler().GetDEALDoFHandler(),
228  GetHigherOrderSTH().GetStateDoFConstraints(), z_high);
229 
230  GetPI_h_z().GetSpacialVector().add(-1., z_high);
231 
232  }
238  void
240  {
241  VECTOR q_high;
242  q_high.reinit(GetPI_h_q().GetSpacialVector());
243 
244  dealii::FETools::extrapolate(
245  GetSTH().GetControlDoFHandler().GetDEALDoFHandler(),
246  q.GetSpacialVector(),
247  GetHigherOrderSTH().GetControlDoFHandler().GetDEALDoFHandler(),
248  GetHigherOrderSTH().GetControlDoFConstraints(),
249  GetPI_h_q().GetSpacialVector());
250 
251  dealii::FETools::interpolate(
252  GetSTH().GetControlDoFHandler().GetDEALDoFHandler(),
253  q.GetSpacialVector(),
254  GetHigherOrderSTH().GetControlDoFHandler().GetDEALDoFHandler(),
255  GetHigherOrderSTH().GetControlDoFConstraints(), q_high);
256 
257  GetPI_h_q().GetSpacialVector().add(-1., q_high);
258  //FIXME With this construction we can not deal with control contraints,
259  //There, the real weight needs to be build on the elements...
260  }
261 
265  virtual EDC&
267  {
268  return GetHigherOrderIDC().GetElementDataContainer();
269  }
270 
274  virtual FDC&
276  {
277  return GetHigherOrderIDC().GetFaceDataContainer();
278  }
279 
283  bool
284  NeedDual() const
285  {
286  return true;
287  }
288 
294  {
296  }
297 
303  {
304 // return DOpEtypes::strong_residual;
305  return _res_eval;
306  }
307 
312  inline void
313  ResidualModifier(double& /*res*/)
314  {
315 
316  }
317  inline void
318  VectorResidualModifier(dealii::Vector<double>& /*res*/)
319  {
320 
321  }
322 
323  protected:
324  STH&
326  {
327  return *_sth;
328  }
329 
330  STH&
332  {
333  return _sth_higher_order;
334  }
335 
336  const STH&
338  {
339  return _sth_higher_order;
340  }
341 
342  IDC&
344  {
345  return _idc_higher_order;
346  }
347 
348  const IDC&
350  {
351  return _idc_higher_order;
352  }
353 
354  private:
355  unsigned int _control_n_blocks, _state_n_blocks;
356  std::vector<unsigned int>* _control_block_component;
357  std::vector<unsigned int>* _state_block_component;
358 
359  STH& _sth_higher_order;
360  STH* _sth;
361  IDC& _idc_higher_order;
362 
363  const DOpEtypes::ResidualEvaluation _res_eval;
364 
365  StateVector<VECTOR> * _PI_h_u, *_PI_h_z;
366  ControlVector<VECTOR> * _PI_h_q;
367  };
368 
369  template<class STH, class IDC, class EDC, class FDC, typename VECTOR>
370  void
372  unsigned int n_elements)
373  {
375 
376  GetHigherOrderSTH().ReInit(_control_n_blocks, *_control_block_component, _state_n_blocks, *_state_block_component);
377  if (this->GetEETerms() == DOpEtypes::primal_only
378  || this->GetEETerms() == DOpEtypes::mixed
379  || this->GetEETerms() == DOpEtypes::mixed_control)
380  {
381  GetPI_h_z().ReInit();
382  }
383  if (this->GetEETerms() == DOpEtypes::dual_only
384  || this->GetEETerms() == DOpEtypes::mixed
385  || this->GetEETerms() == DOpEtypes::mixed_control)
386  {
387  GetPI_h_u().ReInit();
388  }
389  if( this->GetEETerms() == DOpEtypes::mixed_control)
390  {
391  GetPI_h_q().ReInit();
392  }
393  }
394 }
395 
396 #endif /* HIGHER_ORDER_DWRC_H_ */
Definition: dopetypes.h:66
STH & GetHigherOrderSTH()
Definition: higher_order_dwrc_control.h:331
void PreparePI_h_q(const ControlVector< VECTOR > &q)
Definition: higher_order_dwrc_control.h:239
const STH & GetWeightSTH() const
Definition: higher_order_dwrc_control.h:129
void PreparePI_h_u(const VECTOR &u)
Definition: higher_order_dwrc_control.h:189
Definition: higher_order_dwrc_control.h:39
bool NeedDual() const
Definition: higher_order_dwrc_control.h:284
VECTOR & GetSpacialVector()
Definition: statevector.cc:329
std::string GetName() const
Definition: higher_order_dwrc_control.h:96
Definition: parameterreader.h:36
const STH & GetHigherOrderSTH() const
Definition: higher_order_dwrc_control.h:337
const IDC & GetHigherOrderIDC() const
Definition: higher_order_dwrc_control.h:349
virtual DOpEtypes::ResidualEvaluation GetResidualEvaluation() const
Definition: higher_order_dwrc_control.h:302
void VectorResidualModifier(dealii::Vector< double > &)
Definition: higher_order_dwrc_control.h:318
IDC & GetWeightIDC()
Definition: higher_order_dwrc_control.h:135
HigherOrderDWRContainerControl(STH &higher_order_sth, IDC &higher_order_idc, std::string control_behavior, std::string state_behavior, ParameterReader &param_reader, DOpEtypes::EETerms ee_terms=DOpEtypes::EETerms::mixed, DOpEtypes::ResidualEvaluation res_eval=DOpEtypes::strong_residual)
Definition: higher_order_dwrc_control.h:55
Definition: dopetypes.h:66
void PreparePI_h_u(const StateVector< VECTOR > &u)
Definition: higher_order_dwrc_control.h:169
StateVector< VECTOR > & GetPI_h_z()
Definition: higher_order_dwrc_control.h:153
STH & GetSTH()
Definition: higher_order_dwrc_control.h:325
Definition: controlvector.h:48
const IDC & GetWeightIDC() const
Definition: higher_order_dwrc_control.h:141
Definition: dopetypes.h:66
Definition: dopetypes.h:91
DOpEtypes::EETerms GetEETerms() const
Definition: dwrdatacontainer.h:365
virtual FDC & GetFaceWeight() const
Definition: higher_order_dwrc_control.h:275
virtual DOpEtypes::WeightComputation GetWeightComputation() const
Definition: higher_order_dwrc_control.h:293
EETerms
Definition: dopetypes.h:64
Definition: dopetypes.h:66
void Initialize(STH2 *sth, unsigned int control_n_blocks, std::vector< unsigned int > &control_block_component, unsigned int state_n_blocks, std::vector< unsigned int > &state_block_component)
Definition: higher_order_dwrc_control.h:103
Definition: statevector.h:49
STH & GetWeightSTH()
Definition: higher_order_dwrc_control.h:123
virtual EDC & GetElementWeight() const
Definition: higher_order_dwrc_control.h:266
VECTOR & GetSpacialVector()
Definition: controlvector.cc:118
virtual ~HigherOrderDWRContainerControl()
Definition: higher_order_dwrc_control.h:85
ResidualEvaluation
Definition: dopetypes.h:89
void ResidualModifier(double &)
Definition: higher_order_dwrc_control.h:313
ControlVector< VECTOR > & GetPI_h_q()
Definition: higher_order_dwrc_control.h:158
WeightComputation
Definition: dopetypes.h:78
virtual void ReInit(unsigned int n_elements)
Definition: dwrdatacontainer.h:530
StateVector< VECTOR > & GetPI_h_u()
Definition: higher_order_dwrc_control.h:147
IDC & GetHigherOrderIDC()
Definition: higher_order_dwrc_control.h:343
Definition: dwrdatacontainer.h:545
void PreparePI_h_z(const StateVector< VECTOR > &z)
Definition: higher_order_dwrc_control.h:212
void ReInit(unsigned int n_elements)
Definition: higher_order_dwrc_control.h:371