DOpE
forward_euler_problem.h
Go to the documentation of this file.
1 
24 #ifndef ForwardEulerProblem_H_
25 #define ForwardEulerProblem_H_
26 
27 #include "initialproblem.h"
28 #include "primal_ts_base.h"
29 
30 namespace DOpE
31 {
52  template<typename OPTPROBLEM, typename SPARSITYPATTERN, typename VECTOR,
53  int dopedim, int dealdim,
54  template <int, int> class FE = dealii::FESystem,
55  template <int, int> class DH = dealii::DoFHandler>
56  class ForwardEulerProblem : public PrimalTSBase<OPTPROBLEM,
57  SPARSITYPATTERN, VECTOR, dopedim, dealdim, FE, DH>
58  {
59  public:
60  ForwardEulerProblem(OPTPROBLEM& OP) :
61  PrimalTSBase<OPTPROBLEM, SPARSITYPATTERN, VECTOR, dopedim, dealdim,
62  FE, DH>(OP)
63  {
64  initial_problem_ = NULL;
65  }
67  {
68  if (initial_problem_ != NULL)
69  delete initial_problem_;
70  }
71 
72  /******************************************************/
73 
74  std::string
76  {
77  return "forward Euler";
78  }
79 
80  /******************************************************/
81 
84  {
85  if (initial_problem_ == NULL)
86  {
88  (*this);
89  }
90  return *initial_problem_;
91  }
92 
93  /******************************************************/
94  ForwardEulerProblem<OPTPROBLEM, SPARSITYPATTERN, VECTOR, dopedim,
95  dealdim, FE, DH>&
97  {
98  return *this;
99  }
100  /******************************************************/
101 
102  template<typename EDC>
103  void
104  ElementEquation(const EDC& edc,
105  dealii::Vector<double> &local_vector, double scale, double /*scale_ico*/)
106  {
107  if (this->GetPart() == "New")
108  {
109  dealii::Vector<double> tmp(local_vector);
110  tmp = 0.0;
111  this->GetProblem().ElementEquation(edc, tmp, 0., scale);
112  local_vector += tmp;
113 
114  tmp = 0.0;
115  this->GetProblem().ElementTimeEquation(edc, tmp,
116  scale );
117  local_vector += tmp;
118 
119  this->GetProblem().ElementTimeEquationExplicit(edc, local_vector,
120  scale );
121 
122  }
123  else if (this->GetPart() == "Old")
124  {
125  dealii::Vector<double> tmp(local_vector);
126  tmp = 0.0;
127  this->GetProblem().ElementEquation(edc, tmp, scale, 0.);
128  local_vector += tmp;
129 
130  this->GetProblem().ElementTimeEquation(
131  edc,
132  local_vector,
133  (-1) * scale);
134  }
135  else
136  {
137  abort();
138  }
139  }
140 
141  /******************************************************/
142 
143  template<typename EDC>
144  void
145  ElementRhs(const EDC& edc,
146  dealii::Vector<double> &local_vector, double scale)
147  {
148  if (this->GetPart() == "New")
149  {
150 
151  }
152  else if (this->GetPart() == "Old")
153  {
154  this->GetProblem().ElementRhs(edc, local_vector, scale);
155  }
156  else
157  {
158  abort();
159  }
160  }
161 
162 
163  void
165  const std::map<std::string, const dealii::Vector<double>*> &param_values,
166  const std::map<std::string, const VECTOR*> &domain_values,
167  VECTOR& rhs_vector, double scale)
168  {
169  if (this->GetPart() == "New")
170  {
171  }
172  else if (this->GetPart() == "Old")
173  {
174  this->GetProblem().PointRhs(param_values, domain_values, rhs_vector, scale);
175  }
176  else
177  {
178  abort();
179  }
180  }
181 
182  /******************************************************/
183 
184  template<typename EDC>
185  void
186  ElementMatrix(const EDC& edc,
187  dealii::FullMatrix<double> &local_matrix)
188  {
189  assert(this->GetPart() == "New");
190  dealii::FullMatrix<double> m(local_matrix);
191 
192  this->GetProblem().ElementMatrix(edc, local_matrix, 0., 1.);
193 
194  m = 0.;
195  this->GetProblem().ElementTimeMatrix(edc, m);
196  local_matrix.add(
197  1.0, m);
198 
199  m = 0.;
200  this->GetProblem().ElementTimeMatrixExplicit(edc, m);
201  local_matrix.add(
202  1.0 , m);
203 
204  }
205 
206  /******************************************************/
207 
208  template<typename FDC>
209  void
210  FaceEquation(const FDC& fdc,
211  dealii::Vector<double> &local_vector, double scale, double /*scale_ico*/)
212  {
213  if (this->GetPart() == "New")
214  {
215  this->GetProblem().FaceEquation(fdc, local_vector, 0., scale);
216  }
217  else if (this->GetPart() == "Old")
218  {
219  this->GetProblem().FaceEquation(fdc, local_vector, scale,0.);
220  }
221  else
222  {
223  abort();
224  }
225 
226  }
227  /******************************************************/
228 
229  template<typename FDC>
230  void
231  InterfaceEquation(const FDC& fdc,
232  dealii::Vector<double> &local_vector, double scale, double /*scale_ico*/)
233  {
234  if (this->GetPart() == "New")
235  {
236  this->GetProblem().InterfaceEquation(fdc, local_vector, 0., scale);
237  }
238  else if (this->GetPart() == "Old")
239  {
240  this->GetProblem().InterfaceEquation(fdc, local_vector, scale,0.);
241  }
242  else
243  {
244  abort();
245  }
246 
247  }
248 
249  /******************************************************/
250 
251  template<typename FDC>
252  void
253  FaceRhs(const FDC& fdc,
254  dealii::Vector<double> &local_vector, double scale = 1.)
255  {
256  this->GetProblem().FaceRhs(fdc, local_vector, scale);
257  }
258 
259  /******************************************************/
260 
261  template<typename FDC>
262  void
263  FaceMatrix(const FDC& fdc,
264  dealii::FullMatrix<double> &local_matrix)
265  {
266  assert(this->GetPart() == "New");
267  this->GetProblem().FaceMatrix(fdc, local_matrix, 0., 1.);
268 
269  }
270 
271  /******************************************************/
272 
273  template<typename FDC>
274  void
275  InterfaceMatrix(const FDC& fdc,
276  dealii::FullMatrix<double> &local_matrix)
277  {
278  assert(this->GetPart() == "New");
279  this->GetProblem().InterfaceMatrix(fdc, local_matrix, 0., 1.);
280 
281  }
282 
283  /******************************************************/
284 
285  template<typename FDC>
286  void
287  BoundaryEquation(const FDC& fdc,
288  dealii::Vector<double> &local_vector, double scale, double /*scale_ico*/)
289  {
290  if (this->GetPart() == "New")
291  {
292  this->GetProblem().BoundaryEquation(fdc, local_vector, 0., scale);
293  }
294  else if (this->GetPart() == "Old")
295  {
296  this->GetProblem().BoundaryEquation(fdc, local_vector, scale,0.);
297  }
298  else
299  {
300  abort();
301  }
302 
303  }
304 
305  /******************************************************/
306 
307  template<typename FDC>
308  void
309  BoundaryRhs(const FDC& fdc,
310  dealii::Vector<double> &local_vector, double scale)
311  {
312  this->GetProblem().BoundaryRhs(fdc, local_vector, scale);
313  }
314 
315  /******************************************************/
316 
317  template<typename FDC>
318  void
319  BoundaryMatrix(const FDC& fdc,
320  dealii::FullMatrix<double> &local_matrix)
321  {
322  assert(this->GetPart() == "New");
323  this->GetProblem().BoundaryMatrix(fdc, local_matrix, 0., 1.);
324  }
325  private:
327  };
328 }
329 
330 #endif
void BoundaryRhs(const FDC &fdc, dealii::Vector< double > &local_vector, double scale)
Definition: forward_euler_problem.h:309
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: forward_euler_problem.h:164
void FaceEquation(const FDC &fdc, dealii::Vector< double > &local_vector, double scale, double)
Definition: forward_euler_problem.h:210
void ElementMatrix(const EDC &edc, dealii::FullMatrix< double > &local_matrix)
Definition: forward_euler_problem.h:186
ForwardEulerProblem< OPTPROBLEM, SPARSITYPATTERN, VECTOR, dopedim, dealdim, FE, DH > & GetBaseProblem()
Definition: forward_euler_problem.h:96
Definition: primal_ts_base.h:49
void BoundaryEquation(const FDC &fdc, dealii::Vector< double > &local_vector, double scale, double)
Definition: forward_euler_problem.h:287
void FaceMatrix(const FDC &fdc, dealii::FullMatrix< double > &local_matrix)
Definition: forward_euler_problem.h:263
void InterfaceEquation(const FDC &fdc, dealii::Vector< double > &local_vector, double scale, double)
Definition: forward_euler_problem.h:231
void FaceRhs(const FDC &fdc, dealii::Vector< double > &local_vector, double scale=1.)
Definition: forward_euler_problem.h:253
~ForwardEulerProblem()
Definition: forward_euler_problem.h:66
ForwardEulerProblem(OPTPROBLEM &OP)
Definition: forward_euler_problem.h:60
Definition: initialproblem.h:42
OPTPROBLEM & GetProblem()
Definition: ts_base.h:480
void ElementEquation(const EDC &edc, dealii::Vector< double > &local_vector, double scale, double)
Definition: forward_euler_problem.h:104
Definition: forward_euler_problem.h:56
std::string GetPart() const
Definition: ts_base.h:493
std::string GetName()
Definition: forward_euler_problem.h:75
InitialProblem< ForwardEulerProblem< OPTPROBLEM, SPARSITYPATTERN, VECTOR, dopedim, dealdim, FE, DH >, VECTOR, dealdim > & GetInitialProblem()
Definition: forward_euler_problem.h:83
void InterfaceMatrix(const FDC &fdc, dealii::FullMatrix< double > &local_matrix)
Definition: forward_euler_problem.h:275
void BoundaryMatrix(const FDC &fdc, dealii::FullMatrix< double > &local_matrix)
Definition: forward_euler_problem.h:319
void ElementRhs(const EDC &edc, dealii::Vector< double > &local_vector, double scale)
Definition: forward_euler_problem.h:145