18#ifndef KASKADE_TIMESTEPPING_EULERSDC_SDCEULER_HH_
19#define KASKADE_TIMESTEPPING_EULERSDC_SDCEULER_HH_
36#include "dune/common/dynmatrix.hh"
37#include "dune/common/dynvector.hh"
66template<
class Vector,
class Norm,
class Utils,
class TimeGr
id=LobattoTimeGr
id>
82 Norm& norm_, Utils& util_,
84 bool verbose_ =
false) :
85 tbegin(t0), tend(t1), nIntervals(nIntervals_), grid(nIntervals, tbegin, tend),
86 tol(tol_), maxSDCIterations(maxSDCIterations_),
87 norm(norm_), util(util_), norm_t(norm_type), work_t(work_type), verbose(verbose_) {}
100 maxIterNewton = newtIter;
139 std::function<
Vector (
typename Vector::value_type,
Vector const&)> rightHandSide,
143 std::vector<Vector> yi(grid.points().size(), initialValue), dyi(grid.points().size(),
Vector(0.0));
144 std::vector<Vector> y0 = yi;
145 std::vector<Vector> yPrev = yi;
151 std::cout <<
"print entries to the vector yi" << std::endl;
152 for (
auto i = 0u; i < yi.size(); ++i)
153 std::cout <<
"[ " << yi[i] <<
" ]" << std::endl;
157 auto const& tPts = grid.points();
158 auto const& integMat = grid.integrationMatrix();
169 std::vector<Vector> y1 = yi;
170 std::vector<Vector> yCurrent = yi;
171 std::vector<Vector> yNext = yi;
175 while (maxSDCIterations > 0)
180 std::cout <<
"dyi = ";
181 for (
int i = 0; i < dyi.size(); ++i)
183 std::cout <<
"dyi[" << i <<
"] = " << dyi[i] << std::endl;
191 rho = util.sdcContractionFactor(yPrev, yCurrent, yNext, norm);
194 std::cout <<
"\t \t \t \t \t \t \t \t \t \t \t " << rho << std::endl;
196 std::cout <<
"\t \t \t " << rho << std::endl;
199 auto alphaVec = util.computeAlphaVec(tPts, integMat, yPrev, yCurrent, yNext);
210 Iter workModel(tol, y0, y1, norm, util, tPts, integMat, tolNewton, maxIterNewton, rhoit, mmin);
212 maxSDCIterations = workModel.
getIterJ(yPrev, yCurrent, yNext, rho);
213 std::cout <<
"\t \t" << maxSDCIterations;
214 if(maxSDCIterations > 0)
226 tolMat =
RealMatrix(nIntervals, maxSDCIterations, localTol);
231 tolVector = extractLastColumn(tolMat);
232 totalCost = workModel.
computeCost(yPrev, yCurrent, yNext, tolMat);
233 val = std::log(totalCost);
234 std::cout <<
"\t\t" << val;
244 Fed workModel(tol, y0, y1, norm, util, tPts, integMat, dim);
246 maxSDCIterations = workModel.
getIterJ(yPrev, yCurrent, rho);
247 std::cout <<
"\t \t" << maxSDCIterations;
248 if (maxSDCIterations > 0)
260 tolMat =
RealMatrix(nIntervals, maxSDCIterations, localTol);
265 tolVector = extractLastColumn(tolMat);
267 val = std::log(totalCost);
268 std::cout <<
"\t \t" << val;
275 if (maxSDCIterations > 0)
276 std::cout <<
"\t \t \t \t " << totalJ;
278 std::cout <<
"\t \t \t \t \t \t " << totalJ;
284 maxSDCIterations = 1;
301 int maxIterNewton = 1000;
316 auto rows = toleranceMatrix.rows();
317 auto cols = toleranceMatrix.cols();
319 for (
auto i = 0; i < rows; ++i)
321 tolVec[i] = toleranceMatrix[i][cols-1];
Base class to perform SDC iterations based on the forward Euler Method. Total iterations performed de...
void setNaiveLocalTol(field_type locTol)
Vector integrate(Vector const &initialValue, std::function< Vector(typename Vector::value_type, Vector const &)> rightHandSide, Kaskade::AlgorithmType integrate_t)
void setRhoIT(field_type rit)
EulerSDC(field_type t0, field_type t1, size_t nIntervals_, field_type tol_, field_type maxSDCIterations_, Norm &norm_, Utils &util_, Kaskade::NormType norm_type, Kaskade::WorkModelType work_type, bool verbose_=false)
typename Vector::value_type field_type
void setNewtonTolerance(field_type newtTol)
Dune::DynamicVector< double > RealVector
void setNewtonIterations(int newtIter)
Dune::DynamicMatrix< double > RealMatrix
field_type computeCost(RealMatrix const &tolMat)
virtual RealMatrix const & computeLocalTolerances(std::vector< Vector > const &yPrev, std::vector< Vector > const &yCurrent, std::vector< Vector > const &yNext)
Pure virtual function implemented in derived classes for different work models. Computes the local to...
field_type getIterJ(std::vector< Vector > const &yPrev, std::vector< Vector > const &yCurrent, field_type rho)
field_type computeCost(std::vector< Vector > const &yPrev, std::vector< Vector > const &yCurrent, std::vector< Vector > const &yNext, RealMatrix const &tolMat)
field_type getIterJ(std::vector< Vector > const &yPrev, std::vector< Vector > const &yCurrent, std::vector< Vector > const &yNext, field_type rho)
virtual RealMatrix const & computeLocalTolerances(std::vector< Vector > const &yPrev, std::vector< Vector > const &yCurrent, std::vector< Vector > const &yNext)
Pure virtual function implemented in derived classes for different work models. Computes the local to...
Abstract base class of various norms.
Dune::FieldVector< Scalar, dim > Vector
Dune::DynamicVector< double > RealVector
AlgorithmType
enum class to steer the main integrate algorithm in EulerSDC class in a certain way.
WorkModelType
Enum class to define the norm type is class Norm.
NormType
Enum class to define the norm type in class Norm.
Dune::DynamicMatrix< double > RealMatrix
void inexactSDCExplicitEulerIterationStep(Kaskade::SDCTimeGrid const &grid, std::function< Vector(typename Vector::value_type, Vector const &)> rhsFunc, RealVector const &toleranceVector, typename Vector::value_type rho, Kaskade::NormType norm_t, std::vector< Vector > &yi, std::vector< Vector > &dyi, bool verbose=false)