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  DOpEtypes::VectorStorageType control_behavior, DOpEtypes::VectorStorageType 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:68
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
HigherOrderDWRContainerControl(STH &higher_order_sth, IDC &higher_order_idc, DOpEtypes::VectorStorageType control_behavior, DOpEtypes::VectorStorageType 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
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:383
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
Definition: dopetypes.h:68
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:49
const IDC & GetWeightIDC() const
Definition: higher_order_dwrc_control.h:141
Definition: dopetypes.h:68
Definition: dopetypes.h:93
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:66
Definition: dopetypes.h:68
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:50
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:204
virtual ~HigherOrderDWRContainerControl()
Definition: higher_order_dwrc_control.h:85
ResidualEvaluation
Definition: dopetypes.h:91
void ResidualModifier(double &)
Definition: higher_order_dwrc_control.h:313
VectorStorageType
Definition: dopetypes.h:120
ControlVector< VECTOR > & GetPI_h_q()
Definition: higher_order_dwrc_control.h:158
WeightComputation
Definition: dopetypes.h:80
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