Newer
Older
#ifndef ROD_SOLVER_HH
#define RODSOLVER
#include <dune/istl/bcrsmatrix.hh>
#include <dune/istl/bvector.hh>
#include "../../common/boxconstraint.hh"
#include "../common/h1seminorm.hh"
#include "rodassembler.hh"
#include "configuration.hh"
/** \brief Riemannian trust-region solver for 3d Cosserat rod problems */
template <class GridType>
class RodSolver
{
const static int blocksize = 6;
// Some types that I need
typedef Dune::BCRSMatrix<Dune::FieldMatrix<double, blocksize, blocksize> > MatrixType;
typedef Dune::BlockVector<Dune::FieldVector<double, blocksize> > CorrectionType;
typedef std::vector<Configuration> SolutionType;
static void setTrustRegionObstacles(double trustRegionRadius,
std::vector<BoxConstraint<blocksize> >& trustRegionObstacles);
public:
RodSolver()
{}
void setup(const GridType& grid,
const RodAssembler<GridType>* rodAssembler,
const SolutionType& x,
int maxTrustRegionSteps,
double initialTrustRegionRadius,
int multigridIterations,
double mgTolerance,
int mu,
int nu1,
int nu2,
int baseIterations,
double baseTolerance,
bool instrumented);
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
void solve();
void setInitialSolution(const SolutionType& x) {
x_ = x;
}
SolutionType getSol() const {return x_;}
protected:
/** \brief The grid */
const GridType* grid_;
/** \brief The solution vector */
SolutionType x_;
/** \brief The initial trust-region radius in the maximum-norm */
double initialTrustRegionRadius_;
/** \brief Maximum number of trust-region steps */
int maxTrustRegionSteps_;
/** \brief Maximum number of iterations of the multigrid basesolver */
int baseIt_;
double baseTolerance_;
/** \brief Number of coarse multigrid iterations (1 for a V-cycle, 2 for a W-cycle) */
int mu_;
/** \brief Number of multigrid presmoothing steps */
int nu1_;
/** \brief Number of multigrid postsmoothing steps */
int nu2_;
/** \brief Maximum number of multigrid iterations */
int multigridIterations_;
/** \brief Error tolerance of the multigrid QP solver */
double qpTolerance_;
/** \brief Hessian matrix */
MatrixType* hessianMatrix_;
/** \brief The assembler for the material law */
const RodAssembler<GridType>* rodAssembler_;
/** \brief The multigrid solver */
Dune::IterativeSolver<MatrixType, CorrectionType>* mmgSolver_;
/** \brief The hierarchy of trust-region obstacles */
std::vector<std::vector<BoxConstraint<blocksize> > > trustRegionObstacles_;
/** \brief Dummy fields containing 'true' everywhere. The multigrid step
expects them :-( */
/** \brief The Dirichlet nodes on all levels */
std::vector<Dune::BitField> dirichletNodes_;
/** \brief The norm used to measure multigrid convergence */
H1SemiNorm<CorrectionType>* h1SemiNorm_;
/** \brief If set to true we log convergence speed and other stuff */
bool instrumented_;
};
#include "rodsolver.cc"
#endif