6 template<
class TDomain,
class TAlgebra>
63 inline bool hasTerminated(
double tCurrent,
double tStart,
double tFinal)
const
78 template<
typename TDomain,
typename TAlgebra>
94 m_spSolTimeSeries->clear();
95 m_spSolTimeSeries->push(u0->clone(), t0);
100 solver.
init(spAssOp);
104 number currdt = base_type::m_dt;
107 double final_dt = base_type::m_dt;
109 if(!base_type::m_bNoLogOut)
110 UG_LOG(
"+++ Integrating: [\t"<< t0 <<
"\t, \t"<< t1 <<
"\t] with\t" << currdt <<
"\n");
112 while(!hasTerminated(t, t0, t1)) {
113 if(!base_type::m_bNoLogOut)
114 UG_LOG(
"+++ Timestep +++" << step <<
"\n");
116 if (this->debug_writer_valid())
118 char debug_name_ext[16]; snprintf(debug_name_ext, 16,
"%04d", step);
119 this->enter_debug_writer_section(std::string(
"SimpleTimeIntegrator_step") + debug_name_ext);
123 UG_COND_THROW(currdt < base_type::get_dt_min(),
"Time step size below minimum. ABORTING!")
124 number dt = std::min(currdt, t1-t);
129 if (solver.
prepare(*u1) ==
false)
131 if(!base_type::m_bNoLogOut)
132 UG_LOG(
"Initialization failed! RETRY");
134 currdt *= base_type::get_reduction_factor();
140 if (solver.
apply(*u1))
147 if(!base_type::m_bNoLogOut)
152 this->notify_finalize_step(u1, step, t+dt, dt);
161 uold = m_spSolTimeSeries->push_discard_oldest(u1->clone(), t).template cast_static<grid_function_type>();
168 UG_LOG(
"Solution failed! RETRY");
169 currdt *= base_type::get_reduction_factor();
174 if (step == 1 && m_spDerivative.valid())
176 UG_LOG(
"Computing consistency error: "<< std::endl);
178 "Huhh: Different vectors required!");
179 *m_spDerivative = *u0;
180 m_initial_consistency_error = m_spBanachSpace->distance(*m_spDerivative, *u1);
186 this->leave_debug_writer_section();
189 if(base_type::m_bNoLogOut)
191 this->notify_finalize_step(u1, step, t, final_dt);
195 if (m_spDerivative.valid())
202 "Huhh: Different vectors required!");
210 m_spSolTimeSeries->clear();
216 template<
typename TDomain,
typename TAlgebra>
235 m_spSolTimeSeries->clear();
236 m_spSolTimeSeries->push(u0->clone(), t0);
240 solver.
init(spAssOp);
244 number currdt = base_type::m_dt;
247 double final_dt = base_type::m_dt;
249 if(!base_type::m_bNoLogOut)
250 UG_LOG(
"+++ Integrating: ["<< t0 <<
", "<< t1 <<
"] with " << currdt <<
"\n");
252 while(!hasTerminated(t, t0, t1))
254 if(!base_type::m_bNoLogOut)
255 UG_LOG(
"++++++ TIMESTEP " << step++ <<
" BEGIN (current time: " << t <<
") ++++++\n");
258 UG_COND_THROW(currdt < base_type::get_dt_min(),
"Time step size below minimum. ABORTING!")
259 number dt = std::min(currdt, t1-t);
271 if(!base_type::m_bNoLogOut)
272 UG_LOG(
"+++ STAGE "<<
s <<
" BEGIN +++\n");
279 if (solver.
prepare(*u1) ==
false)
break;
282 if (!solver.
apply(*u1))
break;
291 m_spSolTimeSeries->push_discard_oldest(oldest, t);
294 if(!base_type::m_bNoLogOut)
295 UG_LOG(
"+++ STAGE "<<
s <<
" END +++\n");
297 }
while ((++
s) <=num_stages);
303 if(!base_type::m_bNoLogOut)
304 UG_LOG(
"Solution failed! RETRY");
306 currdt *= this->get_reduction_factor();
312 if(!base_type::m_bNoLogOut)
314 this->notify_finalize_step(u1, step, t, dt);
318 if (!hasTerminated(t, t0, t1))
322 if(!base_type::m_bNoLogOut)
323 UG_LOG(
"++++++ TIMESTEP " << step++ <<
" END (current time: " << t <<
") ++++++\n");
327 if(base_type::m_bNoLogOut)
329 this->notify_finalize_step(u1, step, t, final_dt);
integration of non-linear systems (with bounds on dt)
Definition: time_integrator.hpp:1097
base_type::vector_type vector_type
Definition: time_integrator.hpp:1100
virtual bool apply(X &u)=0
virtual bool prepare(X &u)=0
virtual bool init(SmartPtr< IOperator< Y, X > > N)=0
ITimeDiscDependentObject.
Definition: time_integrator.hpp:620
SmartPtr< time_disc_type > m_spTimeDisc
Definition: time_integrator.hpp:630
virtual void set_stage(size_t stage)=0
virtual void prepare_step(SmartPtr< VectorTimeSeries< vector_type > > prevSol, number dt)=0
virtual number future_time() const=0
virtual size_t num_stages() const=0
double m_precisionBound
Definition: time_integrator.hpp:512
Integrate (a non-linear problem) over a given time interval.
Definition: simple_integrator.hpp:11
SimpleTimeIntegrator(SmartPtr< time_disc_type > tDisc, SmartPtr< grid_function_space_type > spSpace)
Definition: simple_integrator.hpp:31
number get_consistency_error() const
Definition: simple_integrator.hpp:53
void set_banach_space(SmartPtr< IGridFunctionSpace< grid_function_type > > spSpace)
Definition: simple_integrator.hpp:56
SimpleTimeIntegrator(SmartPtr< time_disc_type > tDisc)
Definition: simple_integrator.hpp:24
bool apply_single_stage(SmartPtr< grid_function_type > u1, number t1, ConstSmartPtr< grid_function_type > u0, number t0)
Definition: simple_integrator.hpp:79
bool hasTerminated(double tCurrent, double tStart, double tFinal) const
Definition: simple_integrator.hpp:63
void set_derivative(SmartPtr< grid_function_type > udot)
Definition: simple_integrator.hpp:47
IGridFunctionSpace< grid_function_type > grid_function_space_type
Definition: simple_integrator.hpp:20
ITimeDiscretization< TAlgebra > time_disc_type
Definition: simple_integrator.hpp:17
VectorTimeSeries< typename base_type::vector_type > vector_time_series_type
Definition: simple_integrator.hpp:21
SmartPtr< grid_function_type > m_spDerivative
Definition: simple_integrator.hpp:72
SmartPtr< grid_function_type > get_derivative()
Definition: simple_integrator.hpp:50
bool apply(SmartPtr< grid_function_type > u1, number t1, ConstSmartPtr< grid_function_type > u0, number t0)
Definition: simple_integrator.hpp:38
base_type::grid_function_type grid_function_type
Definition: simple_integrator.hpp:19
SmartPtr< IGridFunctionSpace< grid_function_type > > m_spBanachSpace
metric
Definition: simple_integrator.hpp:70
TAlgebra::vector_type vector_type
Definition: simple_integrator.hpp:18
number m_initial_consistency_error
Definition: simple_integrator.hpp:74
bool apply_multi_stage(SmartPtr< grid_function_type > u1, number t1, ConstSmartPtr< grid_function_type > u0, number t0)
Definition: simple_integrator.hpp:217
ITimeDiscDependentObject< TAlgebra > tdisc_dep_type
Definition: simple_integrator.hpp:13
INonlinearTimeIntegrator< TDomain, TAlgebra > base_type
Definition: simple_integrator.hpp:16
ParallelVector< Vector< double > > vector_type
void VecAssign(GPUVector< T > &dest, const GPUVector< T > &v1)
const NullSmartPtr SPNULL
#define UG_ASSERT(expr, msg)
#define UG_COND_THROW(cond, msg)
void VecScaleAdd(double &dest, double alpha1, const double &v1, double alpha2, const double &v2)
SmartPtr< T, FreePolicy > make_sp(T *inst)
function ProblemDisc new(problemDesc, dom)