AMDiS 2.10
The Adaptive Multi-Dimensional Simulation Toolbox
NewtonIteration.inc.hpp
1#pragma once
2
3#include <amdis/Integrate.hpp>
4#include <amdis/operations/Arithmetic.hpp>
5
6namespace AMDiS {
7
8template <class Problem>
10{
11 if (!toDo.isSet(SOLVE))
12 return Flag(1);
13
14 int iter = adaptInfo.spaceIteration()+1;
15 if (iter <= 0 || (buildCycle_ > 0 && (iter-1) % buildCycle_ == 0)) {
16 prob_->buildAfterAdapt(adaptInfo, 0, true, true); // assemble DF(u0) and F(u)
17 prob_->solver()->init(prob_->systemMatrix()->impl());
18 }
19 else {
20 prob_->buildAfterAdapt(adaptInfo, 0, false, true); // assemble F(u)
21 }
22
23 // Initial guess is zero
24 stepSolution_->resizeZero();
25
26 // solve the linear system
27 Dune::InverseOperatorResult stat;
28 prob_->solver()->apply(stepSolution_->impl(), prob_->rhsVector()->impl(), stat);
29
30 // u = u + d
31 Recursive::transform(prob_->solutionVector()->impl(),
32 Operation::Plus{}, prob_->solutionVector()->impl(), stepSolution_->impl());
33
34 // L2-norm
35 err_ = integrate(sqr(this->stepSolution()), prob_->gridView());
36 if (norm_ > 1) // H1-norm
37 err_ += integrate(unary_dot(gradientOf(this->stepSolution())), prob_->gridView());
38 err_ = std::sqrt(err_);
39
40 adaptInfo.setEstSum(err_, "");
41 return Flag(1);
42}
43
44} // end namespace AMDiS
Holds adapt parameters and infos about the problem.
Definition: AdaptInfo.hpp:26
int spaceIteration() const
Returns spaceIteration_.
Definition: AdaptInfo.hpp:165
void setEstSum(double e, Key key)
Sets est_sum.
Definition: AdaptInfo.hpp:285
The Flag class encapsulates flags which represents simple information. Used e.g. while mesh traversal...
Definition: Flag.hpp:14
constexpr bool isSet(Flag const &f) const
Checks whether all set bits of f.flags_ are set in flags_ too.
Definition: Flag.hpp:156
Flag oneIteration(AdaptInfo &adaptInfo, Flag toDo) override
Implementation of ProblemIterationInterface::oneIteration.
Definition: NewtonIteration.inc.hpp:9
auto gradientOf(Expr const &expr)
Definition: DerivativeGridFunction.hpp:185
Functor that represents A+B.
Definition: Arithmetic.hpp:20