DOpE
backward_euler_problem.h
Go to the documentation of this file.
1 
24 #ifndef BackwardEulerProblem_H_
25 #define BackwardEulerProblem_H_
26 
27 #include "initialproblem.h"
28 #include "primal_ts_base.h"
29 
30 namespace DOpE
31 {
50  template<typename OPTPROBLEM, typename SPARSITYPATTERN, typename VECTOR,
51  int dopedim, int dealdim, template<int, int> class FE = dealii::FESystem,
52  template<int, int> class DH = dealii::DoFHandler>
53  class BackwardEulerProblem : public PrimalTSBase<OPTPROBLEM,
54  SPARSITYPATTERN, VECTOR, dopedim, dealdim, FE, DH>
55  {
56  public:
57  BackwardEulerProblem(OPTPROBLEM& OP) :
58  PrimalTSBase<OPTPROBLEM, SPARSITYPATTERN, VECTOR, dopedim, dealdim,
59  FE, DH>(OP)
60  {
61  initial_problem_ = NULL;
62  }
64  {
65  if (initial_problem_ != NULL)
66  delete initial_problem_;
67  }
68 
69  /******************************************************/
70 
76  std::string
78  {
79  return "backward Euler";
80  }
81  /******************************************************/
82 
88  BackwardEulerProblem<OPTPROBLEM, SPARSITYPATTERN, VECTOR, dopedim,
89  dealdim, FE, DH>, VECTOR, dealdim>&
91  {
92  if (initial_problem_ == NULL)
93  {
94  initial_problem_ = new InitialProblem<
95  BackwardEulerProblem<OPTPROBLEM, SPARSITYPATTERN, VECTOR,
96  dopedim, dealdim, FE, DH>, VECTOR, dealdim>(*this);
97  }
98  return *initial_problem_;
99  }
100 
101  /******************************************************/
102 
109  BackwardEulerProblem<OPTPROBLEM, SPARSITYPATTERN, VECTOR, dopedim,
110  dealdim, FE, DH> &
112  {
113  return *this;
114  }
115 
116  /******************************************************/
117 
149  template<typename EDC>
150  void
151  ElementEquation(const EDC & edc,
152  dealii::Vector<double> &local_vector, double scale, double /*scale_ico*/)
153  {
154  if (this->GetPart() == "New")
155  {
156  dealii::Vector<double> tmp(local_vector);
157  tmp = 0.0;
158  this->GetProblem().ElementEquation(edc, tmp,
159  scale,
160  scale);
161  local_vector += tmp;
162 
163  tmp = 0.0;
164  this->GetProblem().ElementTimeEquation(edc, tmp, scale);
165  local_vector += tmp;
166 
167  this->GetProblem().ElementTimeEquationExplicit(edc, local_vector,
168  scale);
169  }
170  else if (this->GetPart() == "Old")
171  {
172  this->GetProblem().ElementTimeEquation(edc, local_vector,
173  (-1) * scale);
174  }
175  else
176  {
177  abort();
178  }
179  }
180 
181  /******************************************************/
182 
202  template<typename EDC>
203  void
204  ElementRhs(const EDC & edc,
205  dealii::Vector<double> &local_vector, double scale)
206  {
207  if (this->GetPart() == "New")
208  {
209  this->GetProblem().ElementRhs(edc, local_vector,
210  scale);
211  }
212  else if (this->GetPart() == "Old")
213  {
214  }
215  else
216  {
217  abort();
218  }
219  }
220 
221  /******************************************************/
222 
247  void
249  const std::map<std::string, const dealii::Vector<double>*> &param_values,
250  const std::map<std::string, const VECTOR*> &domain_values,
251  VECTOR& rhs_vector, double scale)
252  {
253  if (this->GetPart() == "New")
254  {
255  this->GetProblem().PointRhs(param_values, domain_values, rhs_vector,
256  scale);
257  }
258  else if (this->GetPart() == "Old")
259  {
260  }
261  else
262  {
263  abort();
264  }
265  }
266 
267  /******************************************************/
268 
300  template<typename EDC>
301  void
302  ElementMatrix(const EDC & edc,
303  dealii::FullMatrix<double> &local_matrix)
304  {
305  assert(this->GetPart() == "New");
306  dealii::FullMatrix<double> m(local_matrix);
307 
308  this->GetProblem().ElementMatrix(edc, local_matrix,
309  1.,1.);
310 
311  m = 0.;
312  this->GetProblem().ElementTimeMatrix(edc, m);
313  local_matrix.add(1.0, m);
314 
315  m = 0.;
316  this->GetProblem().ElementTimeMatrixExplicit(edc, m);
317  local_matrix.add(1.0, m);
318 
319  }
320 
321  /******************************************************/
322 
338  template<typename FDC>
339  void
340  FaceEquation(const FDC & fdc,
341  dealii::Vector<double> &local_vector, double scale,
342  double /*scale_ico*/)
343  {
344  if (this->GetPart() == "New")
345  {
346  this->GetProblem().FaceEquation(fdc, local_vector,
347  scale,
348  scale);
349  }
350  else if (this->GetPart() == "Old")
351  {
352  }
353  else
354  {
355  abort();
356  }
357  }
358 
359  /******************************************************/
360 
377  template<typename FDC>
378  void
379  InterfaceEquation(const FDC& fdc,
380  dealii::Vector<double> &local_vector, double scale,
381  double /*scale_ico*/)
382  {
383  if (this->GetPart() == "New")
384  {
385  this->GetProblem().InterfaceEquation(fdc, local_vector,
386  scale,
387  scale);
388  }
389  else if (this->GetPart() == "Old")
390  {
391  }
392  else
393  {
394  abort();
395  }
396  }
397 
398  /******************************************************/
399 
414  template<typename FDC>
415  void
416  FaceRhs(const FDC & fdc,
417  dealii::Vector<double> &local_vector, double scale = 1.)
418  {
419  this->GetProblem().FaceRhs(fdc, local_vector,
420  scale);
421  }
422 
423  /******************************************************/
424 
436  template<typename FDC>
437  void
438  FaceMatrix(const FDC & fdc,
439  dealii::FullMatrix<double> &local_matrix)
440  {
441  assert(this->GetPart() == "New");
442  this->GetProblem().FaceMatrix(fdc, local_matrix,
443  1.,1.);
444 
445  }
446 
447  /******************************************************/
448 
460  template<typename FDC>
461  void
462  InterfaceMatrix(const FDC& fdc,
463  dealii::FullMatrix<double> &local_matrix)
464  {
465  assert(this->GetPart() == "New");
466  this->GetProblem().InterfaceMatrix(fdc, local_matrix,
467  1.,1.);
468  }
469 
470  /******************************************************/
471 
487  template<typename FDC>
488  void
489  BoundaryEquation(const FDC & fdc,
490  dealii::Vector<double> &local_vector, double scale,
491  double /*scale_ico*/)
492  {
493  if (this->GetPart() == "New")
494  {
495  this->GetProblem().BoundaryEquation(fdc, local_vector,
496  scale, scale);
497  }
498  else if (this->GetPart() == "Old")
499  {
500  }
501  else
502  {
503  abort();
504  }
505 
506  }
507 
508  /******************************************************/
509 
523  template<typename FDC>
524  void
525  BoundaryRhs(const FDC & fdc,
526  dealii::Vector<double> &local_vector, double scale)
527  {
528  this->GetProblem().BoundaryRhs(fdc, local_vector,
529  scale);
530  }
531 
532  /******************************************************/
533 
546  template<typename FDC>
547  void
548  BoundaryMatrix(const FDC & fdc,
549  dealii::FullMatrix<double> &local_matrix)
550  {
551  assert(this->GetPart() == "New");
552  this->GetProblem().BoundaryMatrix(fdc, local_matrix,
553  1., 1.);
554  }
555 
556  private:
558  BackwardEulerProblem<OPTPROBLEM, SPARSITYPATTERN, VECTOR, dopedim,
559  dealdim, FE, DH>, VECTOR, dealdim> * initial_problem_;
560  };
561 }
562 
563 #endif
void FaceRhs(const FDC &fdc, dealii::Vector< double > &local_vector, double scale=1.)
Definition: backward_euler_problem.h:416
void ElementEquation(const EDC &edc, dealii::Vector< double > &local_vector, double scale, double)
Definition: backward_euler_problem.h:151
void InterfaceEquation(const FDC &fdc, dealii::Vector< double > &local_vector, double scale, double)
Definition: backward_euler_problem.h:379
void PointRhs(const std::map< std::string, const dealii::Vector< double > * > &param_values, const std::map< std::string, const VECTOR * > &domain_values, VECTOR &rhs_vector, double scale)
Definition: backward_euler_problem.h:248
void BoundaryMatrix(const FDC &fdc, dealii::FullMatrix< double > &local_matrix)
Definition: backward_euler_problem.h:548
void ElementRhs(const EDC &edc, dealii::Vector< double > &local_vector, double scale)
Definition: backward_euler_problem.h:204
BackwardEulerProblem(OPTPROBLEM &OP)
Definition: backward_euler_problem.h:57
Definition: primal_ts_base.h:49
Definition: backward_euler_problem.h:53
void BoundaryEquation(const FDC &fdc, dealii::Vector< double > &local_vector, double scale, double)
Definition: backward_euler_problem.h:489
InitialProblem< BackwardEulerProblem< OPTPROBLEM, SPARSITYPATTERN, VECTOR, dopedim, dealdim, FE, DH >, VECTOR, dealdim > & GetInitialProblem()
Definition: backward_euler_problem.h:90
BackwardEulerProblem< OPTPROBLEM, SPARSITYPATTERN, VECTOR, dopedim, dealdim, FE, DH > & GetBaseProblem()
Definition: backward_euler_problem.h:111
void BoundaryRhs(const FDC &fdc, dealii::Vector< double > &local_vector, double scale)
Definition: backward_euler_problem.h:525
~BackwardEulerProblem()
Definition: backward_euler_problem.h:63
Definition: initialproblem.h:42
OPTPROBLEM & GetProblem()
Definition: ts_base.h:480
std::string GetName()
Definition: backward_euler_problem.h:77
std::string GetPart() const
Definition: ts_base.h:493
void FaceEquation(const FDC &fdc, dealii::Vector< double > &local_vector, double scale, double)
Definition: backward_euler_problem.h:340
void FaceMatrix(const FDC &fdc, dealii::FullMatrix< double > &local_matrix)
Definition: backward_euler_problem.h:438
void InterfaceMatrix(const FDC &fdc, dealii::FullMatrix< double > &local_matrix)
Definition: backward_euler_problem.h:462
void ElementMatrix(const EDC &edc, dealii::FullMatrix< double > &local_matrix)
Definition: backward_euler_problem.h:302