62 m_spSolTimeSeries->clear();
63 m_spSolTimeSeries->push(u0->clone(), t0);
72 number currdt = base_type::m_dt;
75 double final_dt = base_type::m_dt;
77 if(!base_type::m_bNoLogOut)
78 UG_LOG(
"+++ Integrating: [\t"<< t0 <<
"\t, \t"<< t1 <<
"\t] with\t" << currdt <<
"\n");
80 while(!hasTerminated(t, t0, t1)) {
81 if(!base_type::m_bNoLogOut)
82 UG_LOG(
"+++ Timestep +++" << step <<
"\n");
84 if (this->debug_writer_valid())
86 char debug_name_ext[16]; snprintf(debug_name_ext, 16,
"%04d", step);
87 this->enter_debug_writer_section(std::string(
"SimpleTimeIntegrator_step") + debug_name_ext);
91 UG_COND_THROW(currdt < base_type::get_dt_min(),
"Time step size below minimum. ABORTING!")
92 number dt = std::min(currdt, t1-t);
97 if (solver.
prepare(*u1) ==
false)
99 if(!base_type::m_bNoLogOut)
100 UG_LOG(
"Initialization failed! RETRY");
102 currdt *= base_type::get_reduction_factor();
108 if (solver.
apply(*u1))
115 if(!base_type::m_bNoLogOut)
120 this->notify_finalize_step(u1, step, t+dt, dt);
129 uold = m_spSolTimeSeries->push_discard_oldest(u1->clone(), t).template cast_static<grid_function_type>();
136 UG_LOG(
"Solution failed! RETRY");
137 currdt *= base_type::get_reduction_factor();
142 if (step == 1 && m_spDerivative.valid())
144 UG_LOG(
"Computing consistency error: "<< std::endl);
146 "Huhh: Different vectors required!");
147 *m_spDerivative = *u0;
148 m_initial_consistency_error = m_spBanachSpace->distance(*m_spDerivative, *u1);
151 if (this->debug_writer_valid())
153 this->leave_debug_writer_section();
154 char debug_name_ext[16]; snprintf(debug_name_ext, 16,
"%04d", step);
155 this->write_debug(*u1, std::string(
"TimeSolution_step") + debug_name_ext);
162 if(base_type::m_bNoLogOut)
164 this->notify_finalize_step(u1, step, t, final_dt);
168 if (m_spDerivative.valid())
175 "Huhh: Different vectors required!");
177 VecScaleAdd(
static_cast<typename TAlgebra::vector_type&
>(*m_spDerivative),
178 1.0/final_dt,
static_cast<typename TAlgebra::vector_type&
>(*u1),
179 -1.0/final_dt,
static_cast<typename TAlgebra::vector_type&
>(*uold));
183 m_spSolTimeSeries->clear();
214 m_spSolTimeSeries->clear();
215 m_spSolTimeSeries->push(u0->clone(), t0);
219 solver.
init(spAssOp);
223 number currdt = base_type::m_dt;
226 double final_dt = base_type::m_dt;
228 if(!base_type::m_bNoLogOut)
229 UG_LOG(
"+++ Integrating: ["<< t0 <<
", "<< t1 <<
"] with " << currdt <<
"\n");
231 while(!hasTerminated(t, t0, t1))
233 if(!base_type::m_bNoLogOut)
234 UG_LOG(
"++++++ TIMESTEP " << step++ <<
" BEGIN (current time: " << t <<
") ++++++\n");
237 UG_COND_THROW(currdt < base_type::get_dt_min(),
"Time step size below minimum. ABORTING!")
238 number dt = std::min(currdt, t1-t);
250 if(!base_type::m_bNoLogOut)
251 UG_LOG(
"+++ STAGE "<<
s <<
" BEGIN +++\n");
258 if (solver.
prepare(*u1) ==
false)
break;
261 if (!solver.
apply(*u1))
break;
270 m_spSolTimeSeries->push_discard_oldest(oldest, t);
273 if(!base_type::m_bNoLogOut)
274 UG_LOG(
"+++ STAGE "<<
s <<
" END +++\n");
276 }
while ((++
s) <=num_stages);
282 if(!base_type::m_bNoLogOut)
283 UG_LOG(
"Solution failed! RETRY");
285 currdt *= this->get_reduction_factor();
291 if(!base_type::m_bNoLogOut)
293 this->notify_finalize_step(u1, step, t, dt);
297 if (!hasTerminated(t, t0, t1))
301 if(!base_type::m_bNoLogOut)
302 UG_LOG(
"++++++ TIMESTEP " << step++ <<
" END (current time: " << t <<
") ++++++\n");
306 if(base_type::m_bNoLogOut)
308 this->notify_finalize_step(u1, step, t, final_dt);
bool apply_single_stage(SmartPtr< grid_function_type > u1, number t1, ConstSmartPtr< grid_function_type > u0, number t0)
Definition simple_integrator_impl.hpp:42
bool apply_multi_stage(SmartPtr< grid_function_type > u1, number t1, ConstSmartPtr< grid_function_type > u0, number t0)
Definition simple_integrator_impl.hpp:191
void VecScaleAdd(double &dest, double alpha1, const double &v1, double alpha2, const double &v2)