76 :
public IOperator< GridFunction<TDomain, TAlgebra> >,
77 public TimeIntegratorSubject<TDomain, TAlgebra>
81 typedef TAlgebra algebra_type;
82 typedef typename TAlgebra::vector_type vector_type;
83 typedef typename TAlgebra::matrix_type matrix_type;
86 typedef TDomain domain_type;
87 typedef GridFunction<TDomain, TAlgebra> grid_function_type;
94 double m_precisionBound;
102 : m_dt(1.0), m_lower_tim(0.0), m_upper_tim(0.0), m_precisionBound(1e-10), m_bNoLogOut(
false)
120 virtual void init(grid_function_type
const& u)
120 virtual void init(grid_function_type
const& u) {
…}
134 { UG_THROW(
"Please init with grid function!"); }
146 void apply(grid_function_type& u1,
const grid_function_type& u0)
147 { UG_THROW(
"Fix interfaces!"); }
146 void apply(grid_function_type& u1,
const grid_function_type& u0) {
…}
149 virtual bool apply(SmartPtr<grid_function_type> u1, number t1, ConstSmartPtr<grid_function_type> u0, number t0) = 0;
155 double get_time_step()
158 void set_precision_bound(
double precisionBound)
159 { m_precisionBound = precisionBound;
return; }
161 void set_no_log_out(
bool bNoLogOut)
162 { m_bNoLogOut = bNoLogOut;
return; }
169class ILinearTimeIntegrator :
public ITimeIntegrator<TDomain, TAlgebra>
173 typedef ITimeIntegrator<TDomain, TAlgebra> base_type;
174 typedef typename base_type::vector_type vector_type;
175 typedef ILinearOperatorInverse<vector_type> linear_solver_type;
176 typedef AssembledLinearOperator<TAlgebra> assembled_operator_type;
179 ILinearTimeIntegrator()
182 ILinearTimeIntegrator(SmartPtr<linear_solver_type> lSolver)
183 : base_type(), m_spLinearSolver(lSolver)
187 void set_linear_solver(SmartPtr<linear_solver_type> lSolver)
188 { m_spLinearSolver=lSolver;}
191 SmartPtr<linear_solver_type> m_spLinearSolver;
215class LinearTimeIntegrator :
216 public ILinearTimeIntegrator<TDomain, TAlgebra>,
217 public ITimeDiscDependentObject<TAlgebra>
223 typedef ITimeDiscDependentObject<TAlgebra> tdisc_dep_type;
225 typedef ILinearTimeIntegrator<TDomain, TAlgebra> base_type;
226 typedef ITimeDiscretization<TAlgebra> time_disc_type;
227 typedef typename base_type::grid_function_type grid_function_type;
228 typedef VectorTimeSeries<typename base_type::vector_type> vector_time_series_type;
231 LinearTimeIntegrator (SmartPtr< time_disc_type> tDisc)
232 : base_type(), ITimeDiscDependentObject<TAlgebra>(tDisc) {}
234 LinearTimeIntegrator (SmartPtr< time_disc_type> tDisc, SmartPtr<typename base_type::linear_solver_type> lSolver)
235 : base_type(lSolver), ITimeDiscDependentObject<TAlgebra>(tDisc) {}
237 bool apply(SmartPtr<grid_function_type> u1, number t1, ConstSmartPtr<grid_function_type> u0, number t0);
243class ConstStepLinearTimeIntegrator :
244 public ILinearTimeIntegrator<TDomain, TAlgebra>,
245 public ITimeDiscDependentObject<TAlgebra>
248 typedef ITimeDiscDependentObject<TAlgebra> tdisc_dep_type;
250 typedef ILinearTimeIntegrator<TDomain, TAlgebra> base_type;
251 typedef ITimeDiscretization<TAlgebra> time_disc_type;
252 typedef typename base_type::linear_solver_type linear_solver_type;
253 typedef typename base_type::grid_function_type grid_function_type;
254 typedef VectorTimeSeries<typename base_type::vector_type> vector_time_series_type;
264 ConstStepLinearTimeIntegrator (SmartPtr<time_disc_type> tDisc)
265 : base_type(), ITimeDiscDependentObject<TAlgebra>(tDisc), m_numSteps(1) {}
267 ConstStepLinearTimeIntegrator (SmartPtr<time_disc_type> tDisc, SmartPtr<typename base_type::linear_solver_type> lSolver)
268 : base_type(lSolver), ITimeDiscDependentObject<TAlgebra>(tDisc), m_numSteps(1) {}
270 void set_num_steps(
int steps) {m_numSteps = steps;}
272 bool apply(SmartPtr<grid_function_type> u1, number t1, ConstSmartPtr<grid_function_type> u0, number t0);
278class TimeIntegratorLinearAdaptive :
279 public ILinearTimeIntegrator<TDomain, TAlgebra>,
280 public ITimeDiscDependentObject<TAlgebra>
283 typedef ITimeDiscDependentObject<TAlgebra> tdisc_dep_type;
286 typedef ILinearTimeIntegrator<TDomain, TAlgebra> base_type;
287 typedef ITimeDiscretization<TAlgebra> time_disc_type;
288 typedef typename base_type::grid_function_type grid_function_type;
289 typedef VectorTimeSeries<typename base_type::vector_type> vector_time_series_type;
293 SmartPtr<time_disc_type> m_spTimeDisc2;
295 double m_tol, m_dtmin, m_dtmax;
299 TimeIntegratorLinearAdaptive (SmartPtr<time_disc_type> tDisc1, SmartPtr<time_disc_type> tDisc2)
300 : base_type(), ITimeDiscDependentObject<TAlgebra>(tDisc1), m_tol(1e-2), m_dtmin(-1.0), m_dtmax(-1.0)
302 m_spTimeDisc2 = tDisc2;
305 void init(grid_function_type
const& u)
305 void init(grid_function_type
const& u) {
…}
312 bool apply(SmartPtr<grid_function_type> u1, number t1, ConstSmartPtr<grid_function_type> u0, number t0);
314 void set_tol(
double tol) {m_tol = tol;}
315 void set_time_step_min(number dt) {m_dtmin = dt;}
316 void set_time_step_max(number dt) {m_dtmax = dt;}
349class INonlinearTimeIntegrator
350:
public ITimeIntegrator<TDomain, TAlgebra>
353 typedef ITimeIntegrator<TDomain, TAlgebra> base_type;
354 typedef typename base_type::vector_type vector_type;
355 typedef IOperatorInverse<vector_type> solver_type;
356 typedef AssembledOperator<TAlgebra> assembled_operator_type;
358 INonlinearTimeIntegrator()
361 void set_solver(SmartPtr<solver_type> solver)
362 { m_spSolver=solver;}
364 ConstSmartPtr<solver_type> get_solver()
const
365 {
return m_spSolver;}
367 SmartPtr<solver_type> get_solver()
368 {
return m_spSolver;}
370 void set_dt_min(
double min) { m_dtBounds.set_dt_min(min); }
371 double get_dt_min() {
return m_dtBounds. get_dt_min(); }
373 void set_dt_max(
double max) { m_dtBounds.set_dt_max(max); }
374 double get_dt_max() {
return m_dtBounds.get_dt_max(); }
376 void set_reduction_factor(
double dec) { m_dtBounds.set_reduction_factor(dec); }
377 double get_reduction_factor() {
return m_dtBounds.get_reduction_factor(); }
379 void set_increase_factor(
double inc) { m_dtBounds.set_increase_factor(inc); }
380 double get_increase_factor() {
return m_dtBounds.get_increase_factor(); }
383 SmartPtr<solver_type> m_spSolver;
391class DiscontinuityIntegrator :
392 public INonlinearTimeIntegrator<TDomain, TAlgebra>
396 typedef INonlinearTimeIntegrator<TDomain, TAlgebra> base_type;
397 typedef typename base_type::grid_function_type grid_function_type;
399 DiscontinuityIntegrator(SmartPtr<base_type> baseIntegrator) :
400 base_type(), m_wrappedIntegrator(baseIntegrator), m_timePoints() {};
402 bool apply(SmartPtr<grid_function_type> u1, number t1, ConstSmartPtr<grid_function_type> u0, number t0)
405 auto tpoint = m_timePoints.begin();
406 double tcurr = (tpoint == m_timePoints.end()) ? t1 : (*tpoint);
411 bool status = m_wrappedIntegrator->apply(u1, tcurr*(1.0-eps), u0, t0);
412 this->notify_finalize_step(u1, dstep++, tcurr, tcurr-t0);
415 while (tpoint != m_timePoints.end())
418 double tnext = (tpoint == m_timePoints.end()) ? t1 : (*tpoint);
422 status = status && m_wrappedIntegrator->apply(u1, tnext*(1.0-eps), u1, tcurr);
423 this->notify_finalize_step(u1, dstep++, tnext, tnext-tcurr);
427 this->notify_end(u1, dstep, t1, 0.0);
431 void insert_points (std::vector<double> points)
433 m_timePoints = points;
436 SmartPtr<base_type> m_wrappedIntegrator;
437 std::vector<double> m_timePoints;
virtual void init(grid_function_type const &u)
init operator depending on a function u
Definition time_integrator.hpp:120