Skip to content
Snippets Groups Projects

Feature matrix free solution of linear PDEs

Merged René Heß requested to merge feature/matrix-free into master
18 files
+ 370
51
Compare changes
  • Side-by-side
  • Inline
Files
18
+ 30
0
#ifndef DUNE_PERFTOOL_MATRIXFREE_HH
#define DUNE_PERFTOOL_MATRIXFREE_HH
#include <iostream>
#include <dune/pdelab/backend/istl/seqistlsolverbackend.hh>
namespace Dune{
namespace PDELab{
template <typename GO, typename V>
void solveMatrixFree(GO& go, V& x ){
typedef Dune::PDELab::OnTheFlyOperator<V,V,GO> ISTLOnTheFlyOperator;
ISTLOnTheFlyOperator opb(go);
Dune::Richardson<V,V> richardson(1.0);
Dune::BiCGSTABSolver<V> solverb(opb,richardson,1E-10,5000,2);
Dune::InverseOperatorResult stat;
// evaluate residual w.r.t initial guess
using TrialGridFunctionSpace = typename GO::Traits::TrialGridFunctionSpace;
using W = Dune::PDELab::Backend::Vector<TrialGridFunctionSpace,typename V::ElementType>;
W r(go.testGridFunctionSpace(),0.0);
go.residual(x,r);
// solve the jacobian system
V z(go.trialGridFunctionSpace(),0.0);
solverb.apply(z,r,stat);
x -= z;
}
}
}
#endif
Loading