newtonmethod.hh
Go to the documentation of this file.
1// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2// vi: set et ts=4 sw=4 sts=4:
3/*
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 2 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18
19 Consult the COPYING file in the top-level source directory of this
20 module for the precise wording of the license and the list of
21 copyright holders.
22*/
27#ifndef EWOMS_NEWTON_METHOD_HH
28#define EWOMS_NEWTON_METHOD_HH
29
30#include <dune/common/classname.hh>
31#include <dune/common/parallel/mpihelper.hh>
32
33#include <dune/istl/istlexception.hh>
34
35#include <opm/common/Exceptions.hpp>
36
37#include <opm/material/densead/Math.hpp>
38
40
44
48
50
51#include <algorithm>
52#include <cmath>
53#include <cstddef>
54#include <exception>
55#include <iostream>
56#include <sstream>
57#include <string>
58
59namespace Opm {
60
61// forward declaration of classes
62template <class TypeTag>
63class NewtonMethod;
64
65}
66
67namespace Opm::Properties {
68
69namespace TTag {
70
73struct NewtonMethod {};
74
75} // namespace TTag
76
77// set default values for the properties
78template<class TypeTag>
79struct NewtonMethod<TypeTag, TTag::NewtonMethod>
81
82template<class TypeTag>
85
86} // namespace Opm::Properties
87
88namespace Opm {
89
97template <class TypeTag>
99{
105
114
115 using Communicator = typename Dune::MPIHelper::MPICommunicator;
116 using CollectiveCommunication = typename Dune::Communication<typename Dune::MPIHelper::MPICommunicator>;
117
118public:
119 explicit NewtonMethod(Simulator& simulator)
120 : simulator_(simulator)
121 , endIterMsgStream_(std::ostringstream::out)
122 , error_(1e100)
123 , lastError_(1e100)
124 , linearSolver_(simulator)
125 , comm_(Dune::MPIHelper::getCommunicator())
126 , convergenceWriter_(asImp_())
127 {
128 params_.read();
129 }
130
134 static void registerParameters()
135 {
136 LinearSolverBackend::registerParameters();
138 }
139
147 {}
148
153 bool converged() const
154 { return error_ <= tolerance(); }
155
159 Problem& problem()
160 { return simulator_.problem(); }
161
165 const Problem& problem() const
166 { return simulator_.problem(); }
167
171 Model& model()
172 { return simulator_.model(); }
173
177 const Model& model() const
178 { return simulator_.model(); }
179
184 Scalar tolerance() const
185 { return params_.tolerance_; }
186
191 void setTolerance(Scalar value)
192 { params_.tolerance_ = value; }
193
201 void applyUpdate(SolutionVector& nextSolution,
202 const SolutionVector& currentSolution,
203 const GlobalEqVector& solutionUpdate,
204 const GlobalEqVector& currentResidual)
205 {
206 asImp_().update_(nextSolution, currentSolution, solutionUpdate, currentResidual);
207 }
208
215 bool apply()
216 {
217 const bool istty = isTty(stdout);
218
219 // Clear the current line using an ansi escape
220 // sequence. For an explanation see
221 // http://en.wikipedia.org/wiki/ANSI_escape_code
222 const char* clearRemainingLine = "\n";
223 if (istty) {
224 static const char ansiClear[] = { 0x1b, '[', 'K', '\r', 0 };
225 clearRemainingLine = ansiClear;
226 }
227
228 // make sure all timers are prestine
233
234 SolutionVector& nextSolution = model().solution(/*historyIdx=*/0);
235 SolutionVector currentSolution(nextSolution);
236 GlobalEqVector solutionUpdate(nextSolution.size());
237
238 Linearizer& linearizer = model().linearizer();
239
240 TimerGuard prePostProcessTimerGuard(prePostProcessTimer_);
241
242 // tell the implementation that we begin solving
244 asImp_().begin_(nextSolution);
246
247 try {
248 TimerGuard innerPrePostProcessTimerGuard(prePostProcessTimer_);
249 TimerGuard linearizeTimerGuard(linearizeTimer_);
250 TimerGuard updateTimerGuard(updateTimer_);
251 TimerGuard solveTimerGuard(solveTimer_);
252
253 // execute the method as long as the implementation thinks
254 // that we should do another iteration
255 while (asImp_().proceed_()) {
256 // linearize the problem at the current solution
257
258 // notify the implementation that we're about to start
259 // a new iteration
261 asImp_().beginIteration_();
263
264 // make the current solution to the old one
265 currentSolution = nextSolution;
266
267 if (asImp_().verbose_()) {
268 std::cout << "Linearize: r(x^k) = dS/dt + div F - q; M = grad r"
269 << clearRemainingLine
270 << std::flush;
271 }
272
273 // do the actual linearization
275 asImp_().linearizeDomain_();
276 asImp_().linearizeAuxiliaryEquations_();
278
280 auto& residual = linearizer.residual();
281 const auto& jacobian = linearizer.jacobian();
282 bool preparedOnGpu = false;
283#if HAVE_CUDA && OPM_IS_COMPILING_WITH_GPU_COMPILER
284 if constexpr (getPropValue<TypeTag, Properties::RunAssemblyOnGpu>()) {
285 if (linearizer.gpuSystemActive()) {
286 preparedOnGpu = linearSolver_.prepareGpu(
287 linearizer.gpuJacobian(), linearizer.flattenedGpuResidual());
288 }
289 }
290#endif
291 if (!preparedOnGpu) {
292 linearSolver_.prepare(jacobian, residual);
293 }
294 linearSolver_.setResidual(residual);
295 linearSolver_.getResidual(residual);
297
298 // The preSolve_() method usually computes the errors, but it can do
299 // something else in addition. TODO: should its costs be counted to
300 // the linearization or to the update?
302 asImp_().preSolve_(currentSolution, residual);
304
305 if (!asImp_().proceed_()) {
306 if (asImp_().verbose_() && istty) {
307 std::cout << clearRemainingLine << std::flush;
308 }
309
310 // tell the implementation that we're done with this iteration
312 asImp_().endIteration_(nextSolution, currentSolution);
314
315 break;
316 }
317
318 // solve the resulting linear equation system
319 if (asImp_().verbose_()) {
320 std::cout << "Solve: M deltax^k = r"
321 << clearRemainingLine
322 << std::flush;
323 }
324
326 // solve A x = b, where b is the residual, A is its Jacobian and x is the
327 // update of the solution
328 linearSolver_.setMatrix(jacobian);
329 solutionUpdate = 0.0;
330 const bool conv = linearSolver_.solve(solutionUpdate);
332
333 if (!conv) {
335 if (asImp_().verbose_()) {
336 std::cout << "Newton: Linear solver did not converge\n" << std::flush;
337 }
338
340 asImp_().failed_();
342
343 return false;
344 }
345
346 // update the solution
347 if (asImp_().verbose_()) {
348 std::cout << "Update: x^(k+1) = x^k - deltax^k"
349 << clearRemainingLine
350 << std::flush;
351 }
352
353 // update the current solution (i.e. uOld) with the delta
354 // (i.e. u). The result is stored in u
356 asImp_().postSolve_(currentSolution,
357 residual,
358 solutionUpdate);
359 asImp_().update_(nextSolution, currentSolution, solutionUpdate, residual);
361
362 if (asImp_().verbose_() && istty) {
363 // make sure that the line currently holding the cursor is prestine
364 std::cout << clearRemainingLine
365 << std::flush;
366 }
367
368 // tell the implementation that we're done with this iteration
370 asImp_().endIteration_(nextSolution, currentSolution);
372 }
373 }
374 catch (const Dune::Exception& e)
375 {
376 if (asImp_().verbose_()) {
377 std::cout << "Newton method caught exception: \""
378 << e.what() << "\"\n" << std::flush;
379 }
380
382 asImp_().failed_();
384
385 return false;
386 }
387 catch (const NumericalProblem& e)
388 {
389 if (asImp_().verbose_()) {
390 std::cout << "Newton method caught exception: \""
391 << e.what() << "\"\n" << std::flush;
392 }
393
395 asImp_().failed_();
397
398 return false;
399 }
400
401 // clear current line on terminal
402 if (asImp_().verbose_() && istty) {
403 std::cout << clearRemainingLine
404 << std::flush;
405 }
406
407 // tell the implementation that we're done
409 asImp_().end_();
411
412 // print the timing summary of the time step
413 if (asImp_().verbose_()) {
414 Scalar elapsedTot =
418 std::cout << "Linearization/solve/update time: "
420 << 100 * linearizeTimer_.realTimeElapsed() / elapsedTot << "%)/"
421 << solveTimer_.realTimeElapsed() << "("
422 << 100 * solveTimer_.realTimeElapsed() / elapsedTot << "%)/"
423 << updateTimer_.realTimeElapsed() << "("
424 << 100 * updateTimer_.realTimeElapsed() / elapsedTot << "%)"
425 << "\n" << std::flush;
426 }
427
428
429 // if we're not converged, tell the implementation that we've failed
430 if (!asImp_().converged()) {
432 asImp_().failed_();
434 return false;
435 }
436
437 // if we converged, tell the implementation that we've succeeded
439 asImp_().succeeded_();
441
442 return true;
443 }
444
453 Scalar suggestTimeStepSize(Scalar oldDt) const
454 {
455 // be aggressive reducing the time-step size but
456 // conservative when increasing it. the rationale is
457 // that we want to avoid failing in the next time
458 // integration which would be quite expensive
459 const int nit = problem().iterationContext().iteration();
460 if (lastSolveFailed_ || nit > params_.targetIterations_) {
461 const int overshoot = lastSolveFailed_ ? params_.targetIterations_ : nit - params_.targetIterations_;
462 Scalar percent = Scalar(overshoot) / params_.targetIterations_;
463 Scalar nextDt = std::max(problem().minTimeStepSize(),
464 oldDt / (Scalar{1.0} + percent));
465 return nextDt;
466 }
467
468 Scalar percent = Scalar(params_.targetIterations_ - nit) / params_.targetIterations_;
469 Scalar nextDt = std::max(problem().minTimeStepSize(),
470 oldDt*(Scalar{1.0} + percent / Scalar{1.2}));
471 return nextDt;
472 }
473
478 std::ostringstream& endIterMsg()
479 { return endIterMsgStream_; }
480
486 { linearSolver_.eraseMatrix(); }
487
491 LinearSolverBackend& linearSolver()
492 { return linearSolver_; }
493
497 const LinearSolverBackend& linearSolver() const
498 { return linearSolver_; }
499
501 { return prePostProcessTimer_; }
502
503 const Timer& linearizeTimer() const
504 { return linearizeTimer_; }
505
506 const Timer& solveTimer() const
507 { return solveTimer_; }
508
509 const Timer& updateTimer() const
510 { return updateTimer_; }
511
512protected:
516 bool verbose_() const
517 { return params_.verbose_ && (comm_.rank() == 0); }
518
525 void begin_(const SolutionVector&)
526 {
527 lastSolveFailed_ = false;
528
529 problem().resetIterationForNewTimestep();
530
531 if (params_.writeConvergence_) {
532 convergenceWriter_.beginTimeStep();
533 }
534 }
535
540 {
541 // start with a clean message stream
542 endIterMsgStream_.str("");
543 const auto& comm = simulator_.gridView().comm();
544 bool succeeded = true;
545 try {
546 problem().beginIteration();
547 }
548 catch (const std::exception& e) {
549 succeeded = false;
550
551 std::cout << "rank " << simulator_.gridView().comm().rank()
552 << " caught an exception while pre-processing the problem:" << e.what()
553 << "\n" << std::flush;
554 }
555
556 succeeded = comm.min(succeeded);
557
558 if (!succeeded) {
559 throw NumericalProblem("pre processing of the problem failed");
560 }
561
563 }
564
570 { model().linearizer().linearizeDomain(); }
571
573 {
574 model().linearizer().linearizeAuxiliaryEquations();
575 model().linearizer().finalize();
576 }
577
578 void preSolve_(const SolutionVector&,
579 const GlobalEqVector& currentResidual)
580 {
581 const auto& constraintsMap = model().linearizer().constraintsMap();
583 Scalar newtonMaxError = params_.maxError_;
584
585 // calculate the error as the maximum weighted tolerance of
586 // the solution's residual
587 error_ = 0;
588 for (unsigned dofIdx = 0; dofIdx < currentResidual.size(); ++dofIdx) {
589 // do not consider auxiliary DOFs for the error
590 if (dofIdx >= model().numGridDof() || model().dofTotalVolume(dofIdx) <= 0.0) {
591 continue;
592 }
593
594 // also do not consider DOFs which are constraint
595 if (enableConstraints_()) {
596 if (constraintsMap.count(dofIdx) > 0) {
597 continue;
598 }
599 }
600
601 const auto& r = currentResidual[dofIdx];
602 for (unsigned eqIdx = 0; eqIdx < r.size(); ++eqIdx) {
603 error_ = max(std::abs(r[eqIdx] * model().eqWeight(dofIdx, eqIdx)), error_);
604 }
605 }
606
607 // take the other processes into account
608 error_ = comm_.max(error_);
609
610 // make sure that the error never grows beyond the maximum
611 // allowed one
612 if (error_ > newtonMaxError) {
613 throw NumericalProblem("Newton: Error " + std::to_string(double(error_)) +
614 " is larger than maximum allowed error of " +
615 std::to_string(double(newtonMaxError)));
616 }
617 }
618
631 void postSolve_(const SolutionVector&,
632 const GlobalEqVector&,
633 GlobalEqVector& solutionUpdate)
634 {
635 // loop over the auxiliary modules and ask them to post process the solution
636 // vector.
637 const auto& comm = simulator_.gridView().comm();
638 for (unsigned i = 0; i < simulator_.model().numAuxiliaryModules(); ++i) {
639 bool succeeded = true;
640 try {
641 simulator_.model().auxiliaryModule(i)->postSolve(solutionUpdate);
642 }
643 catch (const std::exception& e) {
644 succeeded = false;
645
646 std::cout << "rank " << simulator_.gridView().comm().rank()
647 << " caught an exception while post processing an auxiliary module:" << e.what()
648 << "\n" << std::flush;
649 }
650
651 succeeded = comm.min(succeeded);
652
653 if (!succeeded) {
654 throw NumericalProblem("post processing of an auxilary equation failed");
655 }
656 }
657 }
658
673 void update_(SolutionVector& nextSolution,
674 const SolutionVector& currentSolution,
675 const GlobalEqVector& solutionUpdate,
676 const GlobalEqVector& currentResidual)
677 {
678 const auto& constraintsMap = model().linearizer().constraintsMap();
679
680 // first, write out the current solution to make convergence
681 // analysis possible
682 asImp_().writeConvergence_(currentSolution, solutionUpdate);
683
684 // make sure not to swallow non-finite values at this point
685 if (!std::isfinite(solutionUpdate.one_norm())) {
686 throw NumericalProblem("Non-finite update!");
687 }
688
689 std::size_t numGridDof = model().numGridDof();
690 for (unsigned dofIdx = 0; dofIdx < numGridDof; ++dofIdx) {
691 if (enableConstraints_()) {
692 if (constraintsMap.count(dofIdx) > 0) {
693 const auto& constraints = constraintsMap.at(dofIdx);
694 asImp_().updateConstraintDof_(dofIdx,
695 nextSolution[dofIdx],
696 constraints);
697 }
698 else {
699 asImp_().updatePrimaryVariables_(dofIdx,
700 nextSolution[dofIdx],
701 currentSolution[dofIdx],
702 solutionUpdate[dofIdx],
703 currentResidual[dofIdx]);
704 }
705 }
706 else {
707 asImp_().updatePrimaryVariables_(dofIdx,
708 nextSolution[dofIdx],
709 currentSolution[dofIdx],
710 solutionUpdate[dofIdx],
711 currentResidual[dofIdx]);
712 }
713 }
714
715 // update the DOFs of the auxiliary equations
716 std::size_t numDof = model().numTotalDof();
717 for (std::size_t dofIdx = numGridDof; dofIdx < numDof; ++dofIdx) {
718 nextSolution[dofIdx] = currentSolution[dofIdx];
719 nextSolution[dofIdx] -= solutionUpdate[dofIdx];
720 }
721 }
722
726 void updateConstraintDof_(unsigned,
727 PrimaryVariables& nextValue,
728 const Constraints& constraints)
729 { nextValue = constraints; }
730
735 PrimaryVariables& nextValue,
736 const PrimaryVariables& currentValue,
737 const EqVector& update,
738 const EqVector&)
739 {
740 nextValue = currentValue;
741 nextValue -= update;
742 }
743
750 void writeConvergence_(const SolutionVector& currentSolution,
751 const GlobalEqVector& solutionUpdate)
752 {
753 if (params_.writeConvergence_) {
754 convergenceWriter_.beginIteration();
755 convergenceWriter_.writeFields(currentSolution, solutionUpdate);
756 convergenceWriter_.endIteration();
757 }
758 }
759
766 void endIteration_(const SolutionVector&,
767 const SolutionVector&)
768 {
769 problem().advanceIteration();
770
771 const auto& comm = simulator_.gridView().comm();
772 bool succeeded = true;
773 try {
774 problem().endIteration();
775 }
776 catch (const std::exception& e) {
777 succeeded = false;
778
779 std::cout << "rank " << simulator_.gridView().comm().rank()
780 << " caught an exception while letting the problem post-process:" << e.what()
781 << "\n" << std::flush;
782 }
783
784 succeeded = comm.min(succeeded);
785
786 if (!succeeded) {
787 throw NumericalProblem("post processing of the problem failed");
788 }
789
790 if (asImp_().verbose_()) {
791 std::cout << "Newton iteration " << problem().iterationContext().iteration() << ""
792 << " error: " << error_
793 << endIterMsg().str() << "\n" << std::flush;
794 }
795 }
796
800 bool proceed_() const
801 {
802 if (problem().iterationContext().iteration() < 1) {
803 return true; // we always do at least one full iteration
804 }
805 else if (asImp_().converged()) {
806 // we are below the specified tolerance, so we don't have to
807 // do more iterations
808 return false;
809 }
810 else if (problem().iterationContext().iteration() >= params_.maxIterations_) {
811 // we have exceeded the allowed number of steps. If the
812 // error was reduced by a factor of at least 4,
813 // in the last iterations we proceed even if we are above
814 // the maximum number of steps
815 return error_ * 4.0 < lastError_;
816 }
817
818 return true;
819 }
820
825 void end_()
826 {
827 if (params_.writeConvergence_) {
828 convergenceWriter_.endTimeStep();
829 }
830 }
831
837 void failed_()
838 { lastSolveFailed_ = true; }
839
846 {}
847
848 static bool enableConstraints_()
849 { return getPropValue<TypeTag, Properties::EnableConstraints>(); }
850
851 Simulator& simulator_;
852
857
858 std::ostringstream endIterMsgStream_;
859
860 Scalar error_;
863
864 // Flags that the last solve failed, triggering a timestep reduction.
865 bool lastSolveFailed_ = false;
866 // the linear solver
867 LinearSolverBackend linearSolver_;
868
869 // the collective communication used by the simulation (i.e. fake
870 // or MPI)
871 CollectiveCommunication comm_;
872
873 // the object which writes the convergence behaviour of the Newton
874 // method to disk
875 ConvergenceWriter convergenceWriter_;
876
877private:
878 Implementation& asImp_()
879 { return *static_cast<Implementation *>(this); }
880
881 const Implementation& asImp_() const
882 { return *static_cast<const Implementation *>(this); }
883};
884
885} // namespace Opm
886
887#endif
The multi-dimensional Newton method.
Definition: newtonmethod.hh:99
bool verbose_() const
Returns true if the Newton method ought to be chatty.
Definition: newtonmethod.hh:516
Timer linearizeTimer_
Definition: newtonmethod.hh:854
void end_()
Indicates that we're done solving the non-linear system of equations.
Definition: newtonmethod.hh:825
const Timer & updateTimer() const
Definition: newtonmethod.hh:509
const Timer & linearizeTimer() const
Definition: newtonmethod.hh:503
Timer solveTimer_
Definition: newtonmethod.hh:855
const Timer & solveTimer() const
Definition: newtonmethod.hh:506
bool proceed_() const
Returns true iff another Newton iteration should be done.
Definition: newtonmethod.hh:800
static bool enableConstraints_()
Definition: newtonmethod.hh:848
const LinearSolverBackend & linearSolver() const
Returns the linear solver backend object for external use.
Definition: newtonmethod.hh:497
void updatePrimaryVariables_(unsigned, PrimaryVariables &nextValue, const PrimaryVariables &currentValue, const EqVector &update, const EqVector &)
Update a single primary variables object.
Definition: newtonmethod.hh:734
void setTolerance(Scalar value)
Set the current tolerance at which the Newton method considers itself to be converged.
Definition: newtonmethod.hh:191
std::ostringstream & endIterMsg()
Message that should be printed for the user after the end of an iteration.
Definition: newtonmethod.hh:478
static void registerParameters()
Register all run-time parameters for the Newton method.
Definition: newtonmethod.hh:134
Timer prePostProcessTimer_
Definition: newtonmethod.hh:853
void postSolve_(const SolutionVector &, const GlobalEqVector &, GlobalEqVector &solutionUpdate)
Update the error of the solution given the previous iteration.
Definition: newtonmethod.hh:631
const Timer & prePostProcessTimer() const
Definition: newtonmethod.hh:500
Scalar lastError_
Definition: newtonmethod.hh:861
bool apply()
Run the Newton method.
Definition: newtonmethod.hh:215
void writeConvergence_(const SolutionVector &currentSolution, const GlobalEqVector &solutionUpdate)
Write the convergence behaviour of the newton method to disk.
Definition: newtonmethod.hh:750
Scalar error_
Definition: newtonmethod.hh:860
bool lastSolveFailed_
Definition: newtonmethod.hh:865
void begin_(const SolutionVector &)
Called before the Newton method is applied to an non-linear system of equations.
Definition: newtonmethod.hh:525
void failed_()
Called if the Newton method broke down.
Definition: newtonmethod.hh:837
void update_(SolutionVector &nextSolution, const SolutionVector &currentSolution, const GlobalEqVector &solutionUpdate, const GlobalEqVector &currentResidual)
Update the current solution with a delta vector.
Definition: newtonmethod.hh:673
void preSolve_(const SolutionVector &, const GlobalEqVector &currentResidual)
Definition: newtonmethod.hh:578
Timer updateTimer_
Definition: newtonmethod.hh:856
const Model & model() const
Returns a reference to the numeric model.
Definition: newtonmethod.hh:177
LinearSolverBackend linearSolver_
Definition: newtonmethod.hh:867
void succeeded_()
Called if the Newton method was successful.
Definition: newtonmethod.hh:845
Scalar tolerance() const
Return the current tolerance at which the Newton method considers itself to be converged.
Definition: newtonmethod.hh:184
LinearSolverBackend & linearSolver()
Returns the linear solver backend object for external use.
Definition: newtonmethod.hh:491
void linearizeDomain_()
Linearize the global non-linear system of equations associated with the spatial domain.
Definition: newtonmethod.hh:569
const Problem & problem() const
Returns a reference to the object describing the current physical problem.
Definition: newtonmethod.hh:165
Scalar suggestTimeStepSize(Scalar oldDt) const
Suggest a new time-step size based on the old time-step size.
Definition: newtonmethod.hh:453
bool converged() const
Returns true if the error of the solution is below the tolerance.
Definition: newtonmethod.hh:153
CollectiveCommunication comm_
Definition: newtonmethod.hh:871
Problem & problem()
Returns a reference to the object describing the current physical problem.
Definition: newtonmethod.hh:159
NewtonMethodParams< Scalar > params_
Definition: newtonmethod.hh:862
void eraseMatrix()
Causes the solve() method to discared the structure of the linear system of equations the next time i...
Definition: newtonmethod.hh:485
void applyUpdate(SolutionVector &nextSolution, const SolutionVector &currentSolution, const GlobalEqVector &solutionUpdate, const GlobalEqVector &currentResidual)
Public wrapper for applying a Newton update to a solution vector.
Definition: newtonmethod.hh:201
void updateConstraintDof_(unsigned, PrimaryVariables &nextValue, const Constraints &constraints)
Update the primary variables for a degree of freedom which is constraint.
Definition: newtonmethod.hh:726
std::ostringstream endIterMsgStream_
Definition: newtonmethod.hh:858
ConvergenceWriter convergenceWriter_
Definition: newtonmethod.hh:875
NewtonMethod(Simulator &simulator)
Definition: newtonmethod.hh:119
void finishInit()
Finialize the construction of the object.
Definition: newtonmethod.hh:146
void linearizeAuxiliaryEquations_()
Definition: newtonmethod.hh:572
Model & model()
Returns a reference to the numeric model.
Definition: newtonmethod.hh:171
Simulator & simulator_
Definition: newtonmethod.hh:851
void beginIteration_()
Indicates the beginning of a Newton iteration.
Definition: newtonmethod.hh:539
void endIteration_(const SolutionVector &, const SolutionVector &)
Indicates that one Newton iteration was finished.
Definition: newtonmethod.hh:766
A convergence writer for the Newton method which does nothing.
Definition: nullconvergencewriter.hh:51
A simple class which makes sure that a timer gets stopped if an exception is thrown.
Definition: timerguard.hh:42
Provides an encapsulation to measure the system time.
Definition: timer.hpp:46
void start()
Start counting the time resources used by the simulation.
void halt()
Stop the measurement reset all timing values.
double realTimeElapsed() const
Return the real time [s] elapsed during the periods the timer was active since the last reset.
double stop()
Stop counting the time resources.
Declare the properties used by the infrastructure code of the finite volume discretizations.
Declares the properties required by the black oil model.
Definition: fvbaseprimaryvariables.hh:161
Definition: blackoilmodel.hh:74
Definition: blackoilbioeffectsmodules.hh:45
bool isTty(std::FILE *stream)
Is the given stream attached to a terminal?
typename Properties::Detail::GetPropImpl< TypeTag, Property >::type::type GetPropType
get the type alias defined in the property (equivalent to old macro GET_PROP_TYPE(....
Definition: propertysystem.hh:233
std::string to_string(const ConvergenceReport::ReservoirFailure::Type t)
Struct holding the parameters for NewtonMethod.
Definition: newtonmethodparams.hpp:71
static void registerParameters()
Registers the parameters in parameter system.
Specifies the type of the class which writes out the Newton convergence.
Definition: newtonmethodproperties.hh:40
Specifies the type of the actual Newton method.
Definition: newtonmethodproperties.hh:32
Definition: newtonmethod.hh:73