DOpE
fractional_step_theta_problem.h
Go to the documentation of this file.
1 
24 #ifndef FRACTIONALSTEPTHETAPROBLEM_H_
25 #define FRACTIONALSTEPTHETAPROBLEM_H_
26 
27 #include "initialproblem.h"
28 #include "primal_ts_base.h"
29 
30 namespace DOpE
31 {
57  template<typename OPTPROBLEM, typename SPARSITYPATTERN, typename VECTOR,
58  int dopedim, int dealdim, template<int, int> class FE = dealii::FESystem,
59  template<int, int> class DH = dealii::DoFHandler>
60  class FractionalStepThetaProblem : public PrimalTSBase<OPTPROBLEM,
61  SPARSITYPATTERN, VECTOR, dopedim, dealdim, FE, DH>
62  {
63  public:
64  FractionalStepThetaProblem(OPTPROBLEM& OP) :
65  PrimalTSBase<OPTPROBLEM, SPARSITYPATTERN, VECTOR, dopedim, dealdim,
66  FE, DH>(OP)
67  {
68  fs_theta_ = 1.0 - std::sqrt(2.0) / 2.0;
69  fs_theta_prime_ = 1.0 - 2.0 * fs_theta_;
70  fs_alpha_ = (1.0 - 2.0 * fs_theta_) / (1.0 - fs_theta_);
71  fs_beta_ = 1.0 - fs_alpha_;
72  initial_problem_ = NULL;
73  }
74 
76  {
77  if (initial_problem_ != NULL)
78  delete initial_problem_;
79  }
80 
81  /******************************************************/
82 
83  std::string
85  {
86  return "Fractional-Step-Theta";
87  }
88  /******************************************************/
89 
91  FractionalStepThetaProblem<OPTPROBLEM, SPARSITYPATTERN, VECTOR,
92  dopedim, dealdim, FE, DH>, VECTOR, dealdim>&
94  {
95  if (initial_problem_ == NULL)
96  {
97  initial_problem_ = new InitialProblem<
98  FractionalStepThetaProblem<OPTPROBLEM, SPARSITYPATTERN, VECTOR,
99  dopedim, dealdim, FE, DH>, VECTOR, dealdim>(*this);
100  }
101  return *initial_problem_;
102  }
103 
104  /******************************************************/
105  FractionalStepThetaProblem<OPTPROBLEM, SPARSITYPATTERN, VECTOR, dopedim,
106  dealdim, FE, DH>&
108  {
109  return *this;
110  }
111  /******************************************************/
112 
113  template<typename EDC>
114  void
115  ElementEquation(const EDC& edc,
116  dealii::Vector<double> &local_vector, double scale, double /*scale_ico*/)
117  {
118  if (this->GetPart() == "New_for_1st_and_3rd_cycle")
119  {
120  dealii::Vector<double> tmp(local_vector);
121 
122  tmp = 0.0;
123  this->GetProblem().ElementEquation(edc, tmp,
124  scale * fs_alpha_,
125  scale);
126  local_vector += tmp;
127 
128  tmp = 0.0;
129  this->GetProblem().ElementTimeEquation(edc, tmp, scale / (fs_theta_));
130  local_vector += tmp;
131 
132  this->GetProblem().ElementTimeEquationExplicit(edc, local_vector,
133  scale / (fs_theta_));
134  }
135  else if (this->GetPart() == "Old_for_1st_cycle")
136  {
137  dealii::Vector<double> tmp(local_vector);
138  tmp = 0.0;
139 
140  // The explicit parts with old_time_values; e.g. for fluid problems: laplace, convection, etc.
141  this->GetProblem().ElementEquation(edc, tmp,
142  scale * fs_beta_,
143  0.);
144  local_vector += tmp;
145 
146  this->GetProblem().ElementTimeEquation(edc, local_vector,
147  (-1) * scale / (fs_theta_));
148  }
149  else if (this->GetPart() == "Old_for_3rd_cycle")
150  {
151  dealii::Vector<double> tmp(local_vector);
152  tmp = 0.0;
153 
154  // The explicit parts with old_time_values; e.g. for fluid problems: laplace, convection, etc.
155  this->GetProblem().ElementEquation(edc, tmp,
156  scale * fs_beta_,
157  0.);
158  local_vector += tmp;
159 
160  this->GetProblem().ElementTimeEquation(edc, local_vector,
161  (-1) * scale / (fs_theta_));
162  }
163  else if (this->GetPart() == "New_for_2nd_cycle")
164  {
165  dealii::Vector<double> tmp(local_vector);
166 
167  tmp = 0.0;
168  this->GetProblem().ElementEquation(edc, tmp,
169  scale * fs_beta_,
170  scale);
171  local_vector += tmp;
172 
173  tmp = 0.0;
174  this->GetProblem().ElementTimeEquation(edc, tmp,
175  scale / (fs_theta_prime_));
176  local_vector += tmp;
177 
178  this->GetProblem().ElementTimeEquationExplicit(edc, local_vector,
179  scale / (fs_theta_prime_));
180  }
181  else if (this->GetPart() == "Old_for_2nd_cycle")
182  {
183  dealii::Vector<double> tmp(local_vector);
184  tmp = 0.0;
185 
186  // The explicit parts with old_time_values; e.g. for fluid problems: laplace, convection, etc.
187  this->GetProblem().ElementEquation(edc, tmp,
188  scale * fs_alpha_,
189  0.);
190  local_vector += tmp;
191 
192  this->GetProblem().ElementTimeEquation(edc, local_vector,
193  (-1) * scale / (fs_theta_prime_));
194  }
195  else
196  {
197  abort();
198  }
199  }
200 
201  /******************************************************/
202 
203  template<typename EDC>
204  void
205  ElementRhs(const EDC& edc,
206  dealii::Vector<double> &local_vector, double scale)
207  {
208  if (this->GetPart() == "New_for_1st_and_3rd_cycle")
209  {
210 
211  }
212  else if (this->GetPart() == "Old_for_1st_cycle"
213  || this->GetPart() == "Old_for_3rd_cycle")
214  {
215  this->GetProblem().ElementRhs(edc, local_vector,
216  scale);
217  }
218  else if (this->GetPart() == "New_for_2nd_cycle")
219  {
220  this->GetProblem().ElementRhs(edc, local_vector,
221  scale);
222  }
223  else if (this->GetPart() == "Old_for_2nd_cycle")
224  {
225  }
226  else
227  {
228  abort();
229  }
230  }
231  /******************************************************/
232 
233  void
235  const std::map<std::string, const dealii::Vector<double>*> &param_values,
236  const std::map<std::string, const VECTOR*> &domain_values,
237  VECTOR& rhs_vector, double scale)
238  {
239  if (this->GetPart() == "New_for_1st_and_3rd_cycle")
240  {
241 
242  }
243  else if (this->GetPart() == "Old_for_1st_cycle"
244  || this->GetPart() == "Old_for_3rd_cycle")
245  {
246  this->GetProblem().PointRhs(param_values, domain_values, rhs_vector,
247  scale);
248  }
249  else if (this->GetPart() == "New_for_2nd_cycle")
250  {
251  this->GetProblem().PointRhs(param_values, domain_values, rhs_vector,
252  scale);
253  }
254  else if (this->GetPart() == "Old_for_2nd_cycle")
255  {
256  }
257  else
258  {
259  abort();
260  }
261  }
262 
263  /******************************************************/
264 
265  template<typename EDC>
266  void
267  ElementMatrix(const EDC& edc,
268  dealii::FullMatrix<double> &local_matrix)
269  {
270  if (this->GetPart() == "New_for_1st_and_3rd_cycle")
271  {
272  dealii::FullMatrix<double> m(local_matrix);
273  m = 0.;
274  this->GetProblem().ElementMatrix(edc, m,
275  fs_alpha_,
276  1.);
277  local_matrix.add(1.0, m);
278 
279  m = 0.;
280  this->GetProblem().ElementTimeMatrix(edc, m);
281  local_matrix.add(1.0 / (fs_theta_), m);
282 
283  m = 0.;
284  this->GetProblem().ElementTimeMatrixExplicit(edc, m);
285  local_matrix.add(1.0 / (fs_theta_), m);
286  }
287  else if (this->GetPart() == "New_for_2nd_cycle")
288  {
289  dealii::FullMatrix<double> m(local_matrix);
290  m = 0.;
291  this->GetProblem().ElementMatrix(edc, local_matrix,
292  fs_beta_,
293  1.);
294  local_matrix.add(1.0, m);
295 
296  m = 0.;
297  this->GetProblem().ElementTimeMatrix(edc, m);
298  local_matrix.add(1.0 / (fs_theta_prime_), m);
299 
300  m = 0.;
301  this->GetProblem().ElementTimeMatrixExplicit(edc, m);
302  local_matrix.add(1.0 / (fs_theta_prime_), m);
303  }
304  }
305 
306  /******************************************************/
307 
308  template<typename FDC>
309  void
310  FaceEquation(const FDC& fdc,
311  dealii::Vector<double> &local_vector, double scale, double)
312  {
313  if (this->GetPart() == "New_for_1st_and_3rd_cycle")
314  {
315  this->GetProblem().FaceEquation(fdc, local_vector,
316  scale * fs_alpha_,
317  scale);
318 
319  }
320  else if ((this->GetPart() == "Old_for_1st_cycle")
321  || (this->GetPart() == "Old_for_3rd_cycle"))
322  {
323  this->GetProblem().FaceEquation(fdc, local_vector,
324  scale * fs_beta_,
325  0);
326  }
327  else if (this->GetPart() == "New_for_2nd_cycle")
328  {
329  this->GetProblem().FaceEquation(fdc, local_vector,
330  scale * fs_beta_,
331  scale);
332  }
333  else if (this->GetPart() == "Old_for_2nd_cycle")
334  {
335  this->GetProblem().FaceEquation(fdc, local_vector,
336  scale * fs_alpha_,
337  0.);
338  }
339  else
340  {
341  abort();
342  }
343 
344  }
345 
346  /******************************************************/
347 
348  template<typename FDC>
349  void
350  InterfaceEquation(const FDC& fdc,
351  dealii::Vector<double> &local_vector, double scale,
352  double /*scale_ico*/)
353  {
354  if (this->GetPart() == "New_for_1st_and_3rd_cycle")
355  {
356  this->GetProblem().InterfaceEquation(fdc, local_vector,
357  scale * fs_alpha_,
358  scale);
359 
360  }
361  else if ((this->GetPart() == "Old_for_1st_cycle")
362  || (this->GetPart() == "Old_for_3rd_cycle"))
363  {
364  this->GetProblem().InterfaceEquation(fdc, local_vector,
365  scale * fs_beta_,
366  0);
367  }
368  else if (this->GetPart() == "New_for_2nd_cycle")
369  {
370  this->GetProblem().InterfaceEquation(fdc, local_vector,
371  scale * fs_beta_,
372  scale);
373  }
374  else if (this->GetPart() == "Old_for_2nd_cycle")
375  {
376  this->GetProblem().InterfaceEquation(fdc, local_vector,
377  scale * fs_alpha_,
378  0.);
379  }
380  else
381  {
382  abort();
383  }
384 
385  }
386 
387  /******************************************************/
388 
389  template<typename FDC>
390  void
391  FaceRhs(const FDC& fdc,
392  dealii::Vector<double> &local_vector, double scale = 1.)
393  {
394  this->GetProblem().FaceRhs(fdc, local_vector,
395  scale);
396  }
397 
398  /******************************************************/
399 
400  template<typename FDC>
401  void
402  FaceMatrix(const FDC& fdc,
403  dealii::FullMatrix<double> &local_matrix)
404  {
405  if (this->GetPart() == "New_for_1st_and_3rd_cycle")
406  {
407  dealii::FullMatrix<double> m(local_matrix);
408  m = 0.;
409  this->GetProblem().FaceMatrix(fdc, m,
410  fs_alpha_,
411  1.);
412  local_matrix.add(1., m);
413  }
414  else if (this->GetPart() == "New_for_2nd_cycle")
415  {
416  dealii::FullMatrix<double> m(local_matrix);
417  m = 0.;
418  this->GetProblem().FaceMatrix(fdc, m,
419  fs_beta_,
420  1.);
421  local_matrix.add(1.0, m);
422  }
423 
424  }
425 
426  /******************************************************/
427 
428  template<typename FDC>
429  void
430  InterfaceMatrix(const FDC& fdc,
431  dealii::FullMatrix<double> &local_matrix)
432  {
433  if (this->GetPart() == "New_for_1st_and_3rd_cycle")
434  {
435  dealii::FullMatrix<double> m(local_matrix);
436  m = 0.;
437  this->GetProblem().InterfaceMatrix(fdc, m,
438  fs_alpha_,
439  1.);
440  local_matrix.add(1.0, m);
441  }
442  else if (this->GetPart() == "New_for_2nd_cycle")
443  {
444  dealii::FullMatrix<double> m(local_matrix);
445  m = 0.;
446  this->GetProblem().InterfaceMatrix(fdc, m,
447  fs_beta_,
448  1.);
449  local_matrix.add(1.0, m);
450  }
451 
452  }
453 
454  /******************************************************/
455 
456  template<typename FDC>
457  void
458  BoundaryEquation(const FDC& fdc,
459  dealii::Vector<double> &local_vector, double scale, double)
460  {
461  if (this->GetPart() == "New_for_1st_and_3rd_cycle")
462  {
463  this->GetProblem().BoundaryEquation(fdc, local_vector,
464  scale * fs_alpha_, scale);
465  }
466  else if ((this->GetPart() == "Old_for_1st_cycle")
467  || (this->GetPart() == "Old_for_3rd_cycle"))
468  {
469  this->GetProblem().BoundaryEquation(fdc, local_vector,
470  scale * fs_beta_,
471  0.);
472  }
473  else if (this->GetPart() == "New_for_2nd_cycle")
474  {
475  this->GetProblem().BoundaryEquation(fdc, local_vector,
476  scale * fs_beta_,
477  scale);
478  }
479  else if (this->GetPart() == "Old_for_2nd_cycle")
480  {
481  this->GetProblem().BoundaryEquation(fdc, local_vector,
482  scale * fs_alpha_,
483  0);
484  }
485  else
486  {
487  abort();
488  }
489 
490  }
491 
492  /******************************************************/
493 
494  template<typename FDC>
495  void
496  BoundaryRhs(const FDC& fdc,
497  dealii::Vector<double> &local_vector, double scale)
498  {
499  this->GetProblem().BoundaryRhs(fdc, local_vector,
500  scale);
501  }
502 
503  /******************************************************/
504 
505  template<typename FDC>
506  void
507  BoundaryMatrix(const FDC& fdc,
508  dealii::FullMatrix<double> &local_matrix)
509  {
510  if (this->GetPart() == "New_for_1st_and_3rd_cycle")
511  {
512  dealii::FullMatrix<double> m(local_matrix);
513  m = 0.;
514  this->GetProblem().BoundaryMatrix(fdc, m,
515  fs_alpha_,
516  1.);
517  local_matrix.add(1.0, m);
518  }
519  else if (this->GetPart() == "New_for_2nd_cycle")
520  {
521  dealii::FullMatrix<double> m(local_matrix);
522  m = 0.;
523  this->GetProblem().BoundaryMatrix(fdc, m,
524  fs_beta_,
525  1.);
526  local_matrix.add(1.0, m);
527  }
528  }
529  private:
530  // parameters for FS scheme
531  double fs_theta_;
532  double fs_theta_prime_;
533  double fs_alpha_;
534  double fs_beta_;
535 
537  FractionalStepThetaProblem<OPTPROBLEM, SPARSITYPATTERN, VECTOR,
538  dopedim, dealdim, FE, DH>, VECTOR, dealdim> * initial_problem_;
539  };
540 }
541 
542 #endif
std::string GetName()
Definition: fractional_step_theta_problem.h:84
~FractionalStepThetaProblem()
Definition: fractional_step_theta_problem.h:75
void FaceRhs(const FDC &fdc, dealii::Vector< double > &local_vector, double scale=1.)
Definition: fractional_step_theta_problem.h:391
FractionalStepThetaProblem< OPTPROBLEM, SPARSITYPATTERN, VECTOR, dopedim, dealdim, FE, DH > & GetBaseProblem()
Definition: fractional_step_theta_problem.h:107
void BoundaryMatrix(const FDC &fdc, dealii::FullMatrix< double > &local_matrix)
Definition: fractional_step_theta_problem.h:507
void InterfaceMatrix(const FDC &fdc, dealii::FullMatrix< double > &local_matrix)
Definition: fractional_step_theta_problem.h:430
Definition: fractional_step_theta_problem.h:60
Definition: primal_ts_base.h:49
void FaceEquation(const FDC &fdc, dealii::Vector< double > &local_vector, double scale, double)
Definition: fractional_step_theta_problem.h:310
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: fractional_step_theta_problem.h:234
void ElementEquation(const EDC &edc, dealii::Vector< double > &local_vector, double scale, double)
Definition: fractional_step_theta_problem.h:115
void ElementRhs(const EDC &edc, dealii::Vector< double > &local_vector, double scale)
Definition: fractional_step_theta_problem.h:205
Definition: initialproblem.h:42
InitialProblem< FractionalStepThetaProblem< OPTPROBLEM, SPARSITYPATTERN, VECTOR, dopedim, dealdim, FE, DH >, VECTOR, dealdim > & GetInitialProblem()
Definition: fractional_step_theta_problem.h:93
void InterfaceEquation(const FDC &fdc, dealii::Vector< double > &local_vector, double scale, double)
Definition: fractional_step_theta_problem.h:350
OPTPROBLEM & GetProblem()
Definition: ts_base.h:480
void BoundaryEquation(const FDC &fdc, dealii::Vector< double > &local_vector, double scale, double)
Definition: fractional_step_theta_problem.h:458
void FaceMatrix(const FDC &fdc, dealii::FullMatrix< double > &local_matrix)
Definition: fractional_step_theta_problem.h:402
FractionalStepThetaProblem(OPTPROBLEM &OP)
Definition: fractional_step_theta_problem.h:64
std::string GetPart() const
Definition: ts_base.h:493
void BoundaryRhs(const FDC &fdc, dealii::Vector< double > &local_vector, double scale)
Definition: fractional_step_theta_problem.h:496
void ElementMatrix(const EDC &edc, dealii::FullMatrix< double > &local_matrix)
Definition: fractional_step_theta_problem.h:267