10#include <boost/timer/timer.hpp>
12#include "dune/istl/solvers.hh"
13#include "dune/istl/preconditioners.hh"
59 typedef typename EvolutionEquation::AnsatzVars::VariableSet
State;
72 typename EvolutionEquation::AnsatzVars
const& ansatzVars_,
75 : gridManager(gridManager_), ansatzVars(ansatzVars_), eq(&eq_,0)
76 , assembler(ansatzVars.spaces),
extrap(0),
99 std::vector<std::pair<double,double>>
const& tolX)
101 boost::timer::cpu_timer timer;
103 std::vector<double> stepFractions(order+1);
104 for (
int i=0; i<=order; ++i)
105 stepFractions[i] = 1.0/(i+1);
108 int const nvars = EvolutionEquation::AnsatzVars::noOfVariables;
109 int const neq = EvolutionEquation::TestVars::noOfVariables;
110 size_t nnz = assembler.
nnz(0,neq,0,nvars,
false);
114 typedef typename EvolutionEquation::AnsatzVars::template CoefficientVectorRepresentation<0,neq>::type CoefficientVectors;
117 State dx(x), dxsum(x), tmp(x);
122 bool const iterative =
false;
128 for (
int i=0; i<=order; ++i)
130 double const tau = stepFractions[i]*dt;
136 bool accurate =
true;
138 int dimension = gridManager.
grid().dimension;
148 CoefficientVectors rhs(assembler.
rhs());
149 CoefficientVectors solution = ansatzVars.zeroCoefficientVector();
153 typedef typename EvolutionEquation::AnsatzVars::template CoefficientVectorRepresentation<0,neq>::type LinearSpaceX;
157 std::cout <<
" eq 0: dof = " << boost::fusion::at_c<0>(dx.data).space().degreesOfFreedom()
158 <<
" pts in mesh = " << gridManager.
grid().size(dimension) << std::endl;
160 std::cout <<
" dimension of grid = " << dimension << std::endl;
172 double iteEps = 1.0e-10;
173 Dune::InverseOperatorResult res;
181 Dune::BiCGSTABSolver<LinearSpaceX> cg(A,trivial,iteEps,iteSteps,
verbosity-1);
182 cg.apply(solution,rhs,res);
187 int steps = iteSteps;
188 int coarsentype = 21;
189 int interpoltype = 0;
196 double strongThreshold = (dimension==2)?0.25:0.6;
197 BoomerAMG<Op> BoomerAMGPrecon(A,steps,coarsentype,interpoltype,tol,cycleType,relaxType,
198 strongThreshold,variant,overlap,syseqn,
verbosity);
200 Dune::BiCGSTABSolver<LinearSpaceX> cg(A,BoomerAMGPrecon,iteEps,iteSteps,
verbosity-1);
201 cg.apply(solution,rhs,res);
210 Dune::BiCGSTABSolver<LinearSpaceX> cg(A,iluk,iteEps,iteSteps,
verbosity-1);
211 cg.apply(solution,rhs,res);
219 Dune::BiCGSTABSolver<LinearSpaceX> cg(A,jacobi,iteEps,iteSteps,
verbosity-1);
221 cg.apply(solution,rhs,res);
226 if ( !(res.converged) || (res.iterations == 2001) ) {
227 std::cout <<
" no of iterations in cg = " << res.iterations << std::endl;
228 std::cout <<
" convergence status of cg = " << res.converged << std::endl;
243 dx.data = solution.data;
250 if (!tolX.empty() && i==0)
260 nnz = assembler.
nnz(0,neq,0,nvars,
false);
276 std::cout <<
" end of limex step" << std::endl;
280 for (
int j=1; j<=i; ++j)
284 tmp = x; tmp += dxsum;
285 State zero(x); zero *= 0;
293 CoefficientVectors rhs(assembler.
rhs());
294 CoefficientVectors solution(EvolutionEquation::AnsatzVars::template CoefficientVectorRepresentation<0,neq>::init(ansatzVars.spaces));
299 typedef typename EvolutionEquation::AnsatzVars::template CoefficientVectorRepresentation<0,neq>::type LinearSpaceX;
306 double iteEps = 1.0e-10;
307 Dune::InverseOperatorResult res;
315 Dune::BiCGSTABSolver<LinearSpaceX> cg(A,trivial,iteEps,iteSteps,
verbosity-1);
316 cg.apply(solution,rhs,res);
321 int steps = iteSteps;
322 int coarsentype = 21;
323 int interpoltype = 0;
330 int dimension = gridManager.
grid().dimension;
331 double strongThreshold = (dimension==2)?0.25:0.6;
332 BoomerAMG<Op> BoomerAMGPrecon(A,steps,coarsentype,interpoltype,tol,cycleType,relaxType,
333 strongThreshold,variant,overlap,syseqn,
verbosity);
335 Dune::BiCGSTABSolver<LinearSpaceX> cg(A,BoomerAMGPrecon,iteEps,iteSteps,
verbosity-1);
336 cg.apply(solution,rhs,res);
345 Dune::BiCGSTABSolver<LinearSpaceX> cg(A,iluk,iteEps,iteSteps,
verbosity-1);
346 cg.apply(solution,rhs,res);
354 Dune::BiCGSTABSolver<LinearSpaceX> cg(A,jacobi,iteEps,iteSteps,
verbosity-1);
355 cg.apply(solution,rhs,res);
360 if ( !(res.converged) || (res.iterations == 2001) )
362 typedef typename Op::field_type field_type;
365 std::cout <<
" no of iterations in cg = " << res.iterations << std::endl;
366 std::cout <<
" convergence status of cg = " << res.converged << std::endl;
367 std::cout <<
"A: " << std::endl;
368 for (
size_t ii=0; ii<nnz; ii++)
369 std::cout << triplet.
ridx[ii] <<
", " << triplet.
cidx[ii] <<
", " << triplet.
data[ii] << std::endl;
370 std::cout <<
"A, end: " << std::endl;
378 dx.data = solution.data;
403 std::vector<std::pair<double,double> > e(ansatzVars.noOfVariables);
412 template <
class OutStream>
432 typename EvolutionEquation::AnsatzVars
const& ansatzVars;
An adaptor presenting a Dune::LinearOperator <domain_type,range_type> interface to a contiguous sub-b...
Grid const & grid() const
Returns a const reference on the owned grid.
Self & setVerbosity(const bool verbosity)
sets the verbosity level of the grid manager
EvolutionEquation::AnsatzVars::VariableSet State
double elapsedTimeSinceReset
double matrixAssemblyTime
void advanceTime(double dt)
State const & step(State const &x, double dt, int order, std::vector< std::pair< double, double > > const &tolX)
Computes a state increment that advances the given state in time. The time in the given evolution equ...
std::vector< std::pair< double, double > > estimateError(State const &x, int i, int j) const
ExtrapolationTableau< State > extrap
Limex(GridManager< typename EvolutionEquation::AnsatzVars::Grid > &gridManager_, EvolutionEquation &eq_, typename EvolutionEquation::AnsatzVars const &ansatzVars_, DirectType st=DirectType::MUMPS, PrecondType precondType_=PrecondType::ILUK, int verbosity_=1)
void reportTime(OutStream &out) const
std::vector< SparseIndexInt > ridx
row indices
std::vector< SparseIndexInt > cidx
column indices
std::vector< Scalar > data
data
Self & setTau(Scalar dt)
Sets the time step size.
ParabolicEquation & parabolicEquation()
Proxy class for the linearization of semi-linear time stepping schemes.
The trivial preconditioner: this is simply the identity that does exactly nothing.
static unsigned int const RHS
TestVariableSetDescription::template CoefficientVectorRepresentation< first, last >::type rhs() const
Returns a contiguous subrange of the rhs coefficient vectors.
static unsigned int const MATRIX
size_t nnz(size_t rbegin=0, size_t rend=TestVariableSetDescription::noOfVariables, size_t cbegin=0, size_t cend=AnsatzVariableSetDescription::noOfVariables, bool extractOnlyLowerTriangle=false) const
Returns the number of structurally nonzero entries in the submatrix defined by the half-open block ra...
void assemble(F const &f, unsigned int flags=Assembler::EVERYTHING, int nThreads=0, bool verbose=false)
Assembly without block filter or cell filter.
void temporalEvaluationRange(double t0, double t1)
Notifies the PDE in which time interval evaluations will be done.
double time() const
Reports the current simulated time for which the evaluations are done.
ParabolicEquation & setTime(double t)
Sets a new time for evaluating PDE coefficients.
Utility classes for the definition and use of variational functionals.
void projectHierarchically(VariableSet< VariableSetDescription > &f)
Projects the given FE function onto the the polynomial ansatz subspace of one order lower....
bool embeddedErrorEstimator(VariableSetDescription const &varDesc, typename VariableSetDescription::VariableSet const &err, typename VariableSetDescription::VariableSet const &sol, Scaling const &scaling, std::vector< std::pair< double, double > > const &tol, GridManager< typename VariableSetDescription::Grid > &gridManager, int verbosity=1)
Embedded error estimation and mesh refinement.
DirectType
Available direct solvers for linear equation systems.
@ MUMPS
MUMPS sparse solver.
@ UMFPACK
UMFPack from SuiteSparse, using 32 bit integer indices.
Hierarchic Finite Elements.
Lagrange Finite Elements.
InverseLinearOperator< DirectSolver< typename AssembledGalerkinOperator< GOP, firstRow, lastRow, firstCol, lastCol >::Domain, typename AssembledGalerkinOperator< GOP, firstRow, lastRow, firstCol, lastCol >::Range > > directInverseOperator(AssembledGalerkinOperator< GOP, firstRow, lastRow, firstCol, lastCol > const &A, DirectType directType, MatrixProperties properties)
void relativeError(Variables const &varDesc, Functions const &f1, Functions const &f2, Functions const &f3, Spaces const &spaces, Scaling const &scaling, OutIter out)