43 SmartPtr<grid_function_type> u1,
45 ConstSmartPtr<grid_function_type> u0,
52 GridLevel
const &gl = u0->grid_level();
53 time_disc_type &tdisc = *tdisc_dep_type::m_spTimeDisc;
54 typename base_type::solver_type &solver = *base_type::m_spSolver;
57 SmartPtr<grid_function_type> uold;
60 SmartPtr<vector_time_series_type> m_spSolTimeSeries;
61 m_spSolTimeSeries=make_sp(
new vector_time_series_type());
62 m_spSolTimeSeries->clear();
63 m_spSolTimeSeries->push(u0->clone(), t0);
66 SmartPtr<typename base_type::assembled_operator_type> spAssOp;
67 spAssOp = make_sp(
new typename base_type::assembled_operator_type(tdisc_dep_type::m_spTimeDisc, gl));
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);
96 tdisc.prepare_step(m_spSolTimeSeries, dt);
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);
145 UG_ASSERT(
static_cast<typename base_type::vector_type*
> (&*u1) != &(*u0),
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())
174 UG_ASSERT(
static_cast<typename base_type::vector_type*
> (&*u1) != &(*uold),
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();