DOpE
problemcontainer_internal.h
Go to the documentation of this file.
1 
24 #ifndef PROBLEMCONTAINER_INTERNAL_H_
25 #define PROBLEMCONTAINER_INTERNAL_H_
26 
27 namespace DOpE
28 {
35  //FIXME There is the possibility to put more into this class.
36 
37  template<class PDE>
39  {
40  public:
42  : pde_(pde)
43  {
44 
45  }
65  template<class EDC, class DWRC>
66  void
67  ElementErrorContribution(const EDC& edc, const DWRC& dwrc,
68  std::vector<double>& element_contrib, double scale);
69 
70  /******************************************************/
71 
81  template<class FDC, class DWRC>
82  void
83  FaceErrorContribution(const FDC& fdc, const DWRC& dwrc,
84  std::vector<double>& error_contrib, double scale = 1.);
85 
86  /******************************************************/
87 
96  template<class FDC, class DWRC>
97  void
98  BoundaryErrorContribution(const FDC& dc, const DWRC& dwrc,
99  std::vector<double>&, double scale = 1.);
100 
101 
102  const PDE&
103  GetPDE() const
104  {
105  return pde_;
106  }
107 
108  std::string
109  GetType() const
110  {
111  return problem_type_;
112  }
113 
114  unsigned int
115  GetTypeNum() const
116  {
117  return problem_type_num_;
118  }
119 
120  protected:
121  PDE&
123  {
124  return pde_;
125  }
126  void
127  SetTypeInternal(std::string a)
128  {
129  problem_type_ = a;
130  }
131 
132  void
133  SetTypeNumInternal(unsigned int i)
134  {
135  problem_type_num_ = i;
136  }
137 
138  private:
139  std::string problem_type_, algo_type_;
140 
141  unsigned int problem_type_num_;
142  PDE& pde_;
143 
144  };
145 
146  /******************************************************/
147 
148  template<typename PDE>
149  template<class EDC, class DWRC>
150  void
152  const DWRC& dwrc, std::vector<double>& error, double scale)
153  {
154  Assert(GetType() == "error_evaluation", ExcInternalError());
155 
156  if (dwrc.GetResidualEvaluation() == DOpEtypes::strong_residual)
157  {
158 
159  if (dwrc.GetWeightComputation()
161  {
162  EDC* edc_w = ExtractEDC<EDC>(dwrc);
163  switch (dwrc.GetEETerms())
164  {
166  GetPDE().StrongElementResidual(edc, *edc_w, error[0], scale);
167  break;
169  GetPDE().StrongElementResidual_U(edc, *edc_w, error[1], scale);
170  break;
171  case DOpEtypes::mixed:
172  GetPDE().StrongElementResidual(edc, *edc_w, error[0], scale);
173  GetPDE().StrongElementResidual_U(edc, *edc_w, error[1], scale);
174  break;
176  GetPDE().StrongElementResidual(edc, *edc_w, error[0], scale);
177  GetPDE().StrongElementResidual_U(edc, *edc_w, error[1], scale);
178  GetPDE().StrongElementResidual_Control(edc, *edc_w, error[2], scale);
179  break;
180  default:
181  throw DOpEException("Not implemented for this EETerm.",
182  "ProblemContainerInternal::ElementErrorContribution");
183  break;
184  }
185 
186  }
187  else if (dwrc.GetWeightComputation() == DOpEtypes::element_diameter)
188  {
189  switch (dwrc.GetEETerms())
190  {
192  GetPDE().StrongElementResidual(edc, edc, error[0], scale);
193  break;
195  GetPDE().StrongElementResidual_U(edc, edc, error[1], scale);
196  break;
197  case DOpEtypes::mixed:
198  GetPDE().StrongElementResidual(edc, edc, error[0], scale);
199  GetPDE().StrongElementResidual_U(edc, edc, error[1], scale);
200  break;
202  GetPDE().StrongElementResidual (edc, edc, error[0], scale);
203  GetPDE().StrongElementResidual_U (edc, edc, error[1], scale);
204  GetPDE().StrongElementResidual_Control(edc, edc, error[2], scale);
205  break;
206  default:
207  throw DOpEException("Not implemented for this EETerm.",
208  "ProblemContainerInternal::ElementErrorContribution");
209  break;
210  }
211  }
212  else
213  {
214  throw DOpEException("Not implemented for this WeightComputation.",
215  "ProblemContainerInternal::ElementErrorContribution");
216  }
217  }
218  else
219  {
220  throw DOpEException("Not implemented for this ResidualEvaluation.",
221  "ProblemContainerInternal::ElementErrorContribution");
222  }
223  }
224 
225  /******************************************************/
226 
227  template<typename PDE>
228  template<class FDC, class DWRC>
229  void
231  const DWRC& dwrc, std::vector<double>& error, double scale)
232  {
233  Assert(GetType() == "error_evaluation", ExcInternalError());
234 
235  if (dwrc.GetResidualEvaluation() == DOpEtypes::strong_residual)
236  {
237 
238  if (dwrc.GetWeightComputation()
240  {
241  FDC* fdc_w = ExtractFDC<FDC>(dwrc);
242  switch (dwrc.GetEETerms())
243  {
245  GetPDE().StrongFaceResidual(fdc, *fdc_w, error[0], scale);
246  break;
248  GetPDE().StrongFaceResidual_U(fdc, *fdc_w, error[1], scale);
249  break;
250  case DOpEtypes::mixed:
251  GetPDE().StrongFaceResidual(fdc, *fdc_w, error[0], scale);
252  GetPDE().StrongFaceResidual_U(fdc, *fdc_w, error[1], scale);
253  break;
255  GetPDE().StrongFaceResidual (fdc, *fdc_w, error[0], scale);
256  GetPDE().StrongFaceResidual_U (fdc, *fdc_w, error[1], scale);
257  GetPDE().StrongFaceResidual_Control(fdc, *fdc_w, error[2], scale);
258  break;
259  default:
260  throw DOpEException("Not implemented for this EETerm.",
261  "ProblemContainerInternal::FaceErrorContribution");
262  break;
263  }
264  }
265  else if (dwrc.GetWeightComputation() == DOpEtypes::element_diameter)
266  {
267  switch (dwrc.GetEETerms())
268  {
270  GetPDE().StrongFaceResidual(fdc, fdc, error[0], scale);
271  break;
273  GetPDE().StrongFaceResidual_U(fdc, fdc, error[1], scale);
274  break;
275  case DOpEtypes::mixed:
276  GetPDE().StrongFaceResidual(fdc, fdc, error[0], scale);
277  GetPDE().StrongFaceResidual_U(fdc, fdc, error[1], scale);
278  break;
280  GetPDE().StrongFaceResidual (fdc, fdc, error[0], scale);
281  GetPDE().StrongFaceResidual_U (fdc, fdc, error[1], scale);
282  GetPDE().StrongFaceResidual_Control(fdc, fdc, error[2], scale);
283  break;
284  default:
285  throw DOpEException("Not implemented for this EETerm.",
286  "ProblemContainerInternal::FaceErrorContribution");
287  break;
288  }
289 
290  }
291  else
292  {
293  throw DOpEException("Not implemented for this WeightComputation.",
294  "ProblemContainerInternal::FaceErrorContribution");
295  }
296  }
297  else
298  {
299  throw DOpEException("Not implemented for this ResidualEvaluation.",
300  "ProblemContainerInternal::FaceErrorContribution");
301  }
302  }
303 
304  /******************************************************/
305 
306  template<typename PDE>
307  template<class FDC, class DWRC>
308  void
310  const DWRC& dwrc, std::vector<double>& error, double scale)
311  {
312  Assert(GetType() == "error_evaluation", ExcInternalError());
313 
314  if (dwrc.GetResidualEvaluation() == DOpEtypes::strong_residual)
315  {
316  if (dwrc.GetWeightComputation()
318  {
319  FDC* fdc_w = ExtractFDC<FDC>(dwrc);
320  switch (dwrc.GetEETerms())
321  {
323  GetPDE().StrongBoundaryResidual(fdc, *fdc_w, error[0], scale);
324  break;
326  GetPDE().StrongBoundaryResidual_U(fdc, *fdc_w, error[1], scale);
327  break;
328  case DOpEtypes::mixed:
329  GetPDE().StrongBoundaryResidual(fdc, *fdc_w, error[0], scale);
330  GetPDE().StrongBoundaryResidual_U(fdc, *fdc_w, error[1], scale);
331  break;
333  GetPDE().StrongBoundaryResidual (fdc, *fdc_w, error[0], scale);
334  GetPDE().StrongBoundaryResidual_U (fdc, *fdc_w, error[1], scale);
335  GetPDE().StrongBoundaryResidual_Control(fdc, *fdc_w, error[2], scale);
336  break;
337  default:
338  throw DOpEException("Not implemented for this EETerm.",
339  "ProblemContainerInternal::BoundaryErrorContribution");
340  break;
341  }
342  }
343  else if (dwrc.GetWeightComputation() == DOpEtypes::element_diameter)
344  {
345  switch (dwrc.GetEETerms())
346  {
348  GetPDE().StrongBoundaryResidual(fdc, fdc, error[0], scale);
349  break;
351  GetPDE().StrongBoundaryResidual_U(fdc, fdc, error[1], scale);
352  break;
353  case DOpEtypes::mixed:
354  GetPDE().StrongBoundaryResidual(fdc, fdc, error[0], scale);
355  GetPDE().StrongBoundaryResidual_U(fdc, fdc, error[1], scale);
356  break;
358  GetPDE().StrongBoundaryResidual (fdc, fdc, error[0], scale);
359  GetPDE().StrongBoundaryResidual_U (fdc, fdc, error[1], scale);
360  GetPDE().StrongBoundaryResidual_Control(fdc, fdc, error[2], scale);
361  break;
362  default:
363  throw DOpEException("Not implemented for this EETerm.",
364  "ProblemContainerInternal::BoundaryErrorContribution");
365  break;
366  }
367  }
368  else
369  {
370  throw DOpEException("Not implemented for this WeightComputation.",
371  "ProblemContainerInternal::BoundaryErrorContribution");
372 
373  }
374  }
375  else
376  {
377  throw DOpEException("Not implemented for this ResidualEvaluation.",
378  "ProblemContainerInternal::BoundaryErrorContribution");
379  }
380  }
381 }
382 
383 #endif /* PROBLEMCONTAINER_INTERNAL_H_ */
Definition: dopetypes.h:68
void FaceErrorContribution(const FDC &fdc, const DWRC &dwrc, std::vector< double > &error_contrib, double scale=1.)
Definition: problemcontainer_internal.h:230
std::string GetType() const
Definition: problemcontainer_internal.h:109
Definition: problemcontainer_internal.h:38
Definition: dopetypes.h:68
Definition: dopetypes.h:82
const PDE & GetPDE() const
Definition: problemcontainer_internal.h:103
ProblemContainerInternal(PDE &pde)
Definition: problemcontainer_internal.h:41
void SetTypeInternal(std::string a)
Definition: problemcontainer_internal.h:127
void SetTypeNumInternal(unsigned int i)
Definition: problemcontainer_internal.h:133
Definition: dopetypes.h:68
Definition: dopetypes.h:93
void ElementErrorContribution(const EDC &edc, const DWRC &dwrc, std::vector< double > &element_contrib, double scale)
Definition: problemcontainer_internal.h:151
Definition: dopetypes.h:68
unsigned int GetTypeNum() const
Definition: problemcontainer_internal.h:115
void BoundaryErrorContribution(const FDC &dc, const DWRC &dwrc, std::vector< double > &, double scale=1.)
Definition: problemcontainer_internal.h:309
Definition: dopeexception.h:35
PDE & GetPDE()
Definition: problemcontainer_internal.h:122