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  Copyright (C) 2008-2013 by Andreas Lauser
5  Copyright (C) 2009-2011 by Bernd Flemisch
6 
7  This file is part of the Open Porous Media project (OPM).
8 
9  OPM is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 2 of the License, or
12  (at your option) any later version.
13 
14  OPM is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OPM. If not, see <http://www.gnu.org/licenses/>.
21 */
26 #ifndef EWOMS_NEWTON_METHOD_HH
27 #define EWOMS_NEWTON_METHOD_HH
28 
29 #include "nullconvergencewriter.hh"
30 
31 #include <opm/common/Exceptions.hpp>
32 #include <opm/common/ErrorMacros.hpp>
34 #include <opm/material/common/ClassName.hpp>
36 #include <ewoms/common/timer.hh>
37 
38 #include <dune/istl/istlexception.hh>
39 #include <dune/common/version.hh>
40 #if DUNE_VERSION_NEWER(DUNE_COMMON, 2,3)
41 #include <dune/common/parallel/mpihelper.hh>
42 #else
43 #include <dune/common/mpihelper.hh>
44 #endif
45 
46 #include <iostream>
47 #include <sstream>
48 
49 #include <unistd.h>
50 
51 namespace Ewoms {
52 // forward declaration of classes
53 template <class TypeTag>
55 }
56 
57 namespace Ewoms {
58 // forward declaration of property tags
59 namespace Properties {
63 
66 
68 NEW_PROP_TAG(Problem);
69 
71 NEW_PROP_TAG(Model);
72 
74 NEW_PROP_TAG(Scalar);
75 
78 
80 NEW_PROP_TAG(SolutionVector);
81 
83 NEW_PROP_TAG(PrimaryVariables);
84 
86 NEW_PROP_TAG(GlobalEqVector);
87 
89 NEW_PROP_TAG(EqVector);
90 
92 NEW_PROP_TAG(Linearizer);
93 
95 NEW_PROP_TAG(JacobianMatrix);
96 
98 NEW_PROP_TAG(LinearSolverBackend);
99 
101 NEW_PROP_TAG(NewtonVerbose);
102 
104 NEW_PROP_TAG(NewtonConvergenceWriter);
105 
108 NEW_PROP_TAG(NewtonWriteConvergence);
109 
112 NEW_PROP_TAG(ConvergenceWriter);
113 
120 NEW_PROP_TAG(NewtonRawTolerance);
121 
124 NEW_PROP_TAG(NewtonMaxError);
125 
134 NEW_PROP_TAG(NewtonTargetIterations);
135 
137 NEW_PROP_TAG(NewtonMaxIterations);
138 
139 // set default values for the properties
142 SET_BOOL_PROP(NewtonMethod, NewtonWriteConvergence, false);
143 SET_BOOL_PROP(NewtonMethod, NewtonVerbose, true);
144 SET_SCALAR_PROP(NewtonMethod, NewtonRawTolerance, 1e-8);
145 // set the abortion tolerace to some very large value. if not
146 // overwritten at run-time this basically disables abortions
147 SET_SCALAR_PROP(NewtonMethod, NewtonMaxError, 1e100);
148 SET_INT_PROP(NewtonMethod, NewtonTargetIterations, 10);
149 SET_INT_PROP(NewtonMethod, NewtonMaxIterations, 18);
150 } // namespace Properties
151 } // namespace Ewoms
152 
153 namespace Ewoms {
161 template <class TypeTag>
162 class NewtonMethod
163 {
164  typedef typename GET_PROP_TYPE(TypeTag, NewtonMethod) Implementation;
165  typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar;
166  typedef typename GET_PROP_TYPE(TypeTag, Simulator) Simulator;
167  typedef typename GET_PROP_TYPE(TypeTag, Problem) Problem;
168  typedef typename GET_PROP_TYPE(TypeTag, Model) Model;
169 
170  typedef typename GET_PROP_TYPE(TypeTag, SolutionVector) SolutionVector;
171  typedef typename GET_PROP_TYPE(TypeTag, GlobalEqVector) GlobalEqVector;
172  typedef typename GET_PROP_TYPE(TypeTag, PrimaryVariables) PrimaryVariables;
173  typedef typename GET_PROP_TYPE(TypeTag, EqVector) EqVector;
174  typedef typename GET_PROP_TYPE(TypeTag, Linearizer) Linearizer;
175  typedef typename GET_PROP_TYPE(TypeTag, JacobianMatrix) JacobianMatrix;
176  typedef typename GET_PROP_TYPE(TypeTag, LinearSolverBackend) LinearSolverBackend;
177  typedef typename GET_PROP_TYPE(TypeTag, NewtonConvergenceWriter) ConvergenceWriter;
178 
179  typedef typename Dune::MPIHelper::MPICommunicator Communicator;
180  typedef Dune::CollectiveCommunication<Communicator> CollectiveCommunication;
181 
182 public:
183  NewtonMethod(Simulator &simulator)
184  : simulator_(simulator), endIterMsgStream_(std::ostringstream::out),
185  linearSolver_(simulator), comm_(Dune::MPIHelper::getCommunicator()),
186  convergenceWriter_(asImp_())
187  {
188  lastError_ = 1e100;
189  error_ = 1e100;
190  tolerance_ = EWOMS_GET_PARAM(TypeTag, Scalar, NewtonRawTolerance);
191 
192  numIterations_ = 0;
193  }
194 
198  static void registerParameters()
199  {
200  LinearSolverBackend::registerParameters();
201 
202  EWOMS_REGISTER_PARAM(TypeTag, bool, NewtonVerbose,
203  "Specify whether the Newton method should inform "
204  "the user about its progress or not");
205  EWOMS_REGISTER_PARAM(TypeTag, bool, NewtonWriteConvergence,
206  "Write the convergence behaviour of the Newton "
207  "method to a VTK file");
208  EWOMS_REGISTER_PARAM(TypeTag, int, NewtonTargetIterations,
209  "The 'optimimum' number of Newton iterations per "
210  "time step");
211  EWOMS_REGISTER_PARAM(TypeTag, int, NewtonMaxIterations,
212  "The maximum number of Newton iterations per time "
213  "step");
214  EWOMS_REGISTER_PARAM(TypeTag, Scalar, NewtonRawTolerance,
215  "The maximum raw error tolerated by the Newton"
216  "method for considering a solution to be "
217  "converged");
218  EWOMS_REGISTER_PARAM(TypeTag, Scalar, NewtonMaxError,
219  "The maximum error tolerated by the Newton "
220  "method to which does not cause an abort");
221  }
222 
227  bool converged() const
228  { return error_ <= tolerance(); }
229 
233  Problem &problem()
234  { return simulator_.problem(); }
235 
239  const Problem &problem() const
240  { return simulator_.problem(); }
241 
245  Model &model()
246  { return simulator_.model(); }
247 
251  const Model &model() const
252  { return simulator_.model(); }
253 
258  int numIterations() const
259  { return numIterations_; }
260 
265  Scalar tolerance() const
266  { return tolerance_; }
267 
272  void setTolerance(Scalar value)
273  { tolerance_ = value; }
274 
281  bool apply()
282  {
283  // Clear the current line using an ansi escape
284  // sequence. For an explanation see
285  // http://en.wikipedia.org/wiki/ANSI_escape_code
286  const char *clearRemainingLine = "\n";
287  if (isatty(fileno(stdout))) {
288  static const char blubb[] = { 0x1b, '[', 'K', '\r', 0 };
289  clearRemainingLine = blubb;
290  }
291 
292  SolutionVector &nextSolution = model().solution(/*historyIdx=*/0);
293  SolutionVector currentSolution(nextSolution);
294  GlobalEqVector solutionUpdate(nextSolution.size());
295 
296  Linearizer &linearizer = model().linearizer();
297 
298  // tell the implementation that we begin solving
299  asImp_().begin_(nextSolution);
300 
301  linearizeTime_ = 0.0;
302  solveTime_ = 0.0;
303  updateTime_ = 0.0;
304 
305  Timer prePostProcessTimer;
306 
307  try {
308  // execute the method as long as the implementation thinks
309  // that we should do another iteration
310  while (asImp_().proceed_()) {
311  // linearize the problem at the current solution
312 
313  // notify the implementation that we're about to start
314  // a new iteration
315  prePostProcessTimer.start();
316  asImp_().beginIteration_();
317  prePostProcessTimer.stop();
318  simulator_.addPrePostProcessTime(prePostProcessTimer.realTimeElapsed());
319 
320 
321  // make the current solution to the old one
322  currentSolution = nextSolution;
323 
324  if (asImp_().verbose_()) {
325  std::cout << "Linearize: r(x^k) = dS/dt + div F - q; M = grad r"
326  << clearRemainingLine
327  << std::flush;
328  }
329 
331  asImp_().linearize_();
335 
336  if (asImp_().verbose_()) {
337  std::cout << "Solve: M deltax^k = r"
338  << clearRemainingLine
339  << std::flush;
340  }
341 
342  // solve the resulting linear equation system
343  solveTimer_.start();
344 
345  // set the delta vector to zero before solving the linear system!
346  solutionUpdate = 0;
347  // ask the implementation to solve the linearized system
348  auto b = linearizer.residual();
349  bool converged = asImp_().solveLinear_(linearizer.matrix(), solutionUpdate, b);
350  solveTimer_.stop();
352  solveTimer_.halt();
353 
354  if (!converged) {
355  if (asImp_().verbose_())
356  std::cout << "Newton: Newton solver did not converge\n" << std::flush;
357  solveTimer_.stop();
358 
359  prePostProcessTimer.start();
360  asImp_().failed_();
361  prePostProcessTimer.stop();
362  simulator_.addPrePostProcessTime(prePostProcessTimer.realTimeElapsed());
363 
364  return false;
365  }
366 
367  // update the solution
368  if (asImp_().verbose_()) {
369  std::cout << "Update: x^(k+1) = x^k - deltax^k"
370  << clearRemainingLine
371  << std::flush;
372  }
373 
374  // update the current solution (i.e. uOld) with the delta
375  // (i.e. u). The result is stored in u
377  asImp_().updateError_(nextSolution,
378  currentSolution,
379  b,
380  solutionUpdate);
381  asImp_().update_(nextSolution, currentSolution, solutionUpdate, b);
382  updateTimer_.stop();
384  updateTimer_.halt();
385 
386  // tell the implementation that we're done with this iteration
387  prePostProcessTimer.start();
388  asImp_().endIteration_(nextSolution, currentSolution);
389  prePostProcessTimer.stop();
390  simulator_.addPrePostProcessTime(prePostProcessTimer.realTimeElapsed());
391  }
392  }
393  catch (const Dune::Exception &e)
394  {
399  solveTimer_.halt();
400  updateTimer_.halt();
401  if (asImp_().verbose_())
402  std::cout << "Newton method caught exception: \""
403  << e.what() << "\"\n" << std::flush;
404  asImp_().failed_();
405  return false;
406  }
407  catch (const Opm::NumericalProblem &e)
408  {
413  solveTimer_.halt();
414  updateTimer_.halt();
415 
416  if (asImp_().verbose_())
417  std::cout << "Newton method caught exception: \""
418  << e.what() << "\"\n" << std::flush;
419  asImp_().failed_();
420  return false;
421  }
422 
423  // clear current line on terminal
424  if (asImp_().verbose_() && isatty(fileno(stdout)))
425  std::cout << clearRemainingLine
426  << std::flush;
427 
428  // tell the implementation that we're done
429  asImp_().end_();
430 
431  // print the timing summary of the time step
432  if (asImp_().verbose_()) {
433  Scalar elapsedTot =
435  + solveTime_
436  + updateTime_;
437  std::cout << "Linearization/solve/update time: "
438  << linearizeTime_ << "("
439  << 100 * linearizeTime_/elapsedTot << "%)/"
440  << solveTime_ << "("
441  << 100 * solveTime_/elapsedTot << "%)/"
442  << updateTime_ << "("
443  << 100 * updateTime_/elapsedTot << "%)"
444  << "\n" << std::flush;
445  }
446 
447 
448  // if we're not converged, tell the implementation that we've failed, else tell
449  // it that we succeeded
450  if (!asImp_().converged()) {
451  asImp_().failed_();
452  return false;
453  }
454 
455  asImp_().succeeded_();
456  return true;
457  }
458 
464  Scalar linearizeTime() const
465  { return linearizeTime_; }
466 
472  Scalar solveTime() const
473  { return solveTime_; }
474 
480  Scalar updateTime() const
481  { return updateTime_; }
482 
491  Scalar suggestTimeStepSize(Scalar oldTimeStep) const
492  {
493  // be aggressive reducing the time-step size but
494  // conservative when increasing it. the rationale is
495  // that we want to avoid failing in the next time
496  // integration which would be quite expensive
498  Scalar percent = Scalar(numIterations_ - targetIterations_())
499  / targetIterations_();
500  return oldTimeStep / (1.0 + percent);
501  }
502 
503  Scalar percent = Scalar(targetIterations_() - numIterations_)
504  / targetIterations_();
505  return oldTimeStep * (1.0 + percent / 1.2);
506  }
507 
512  std::ostringstream &endIterMsg()
513  { return endIterMsgStream_; }
514 
515 protected:
519  bool verbose_() const
520  {
521  return EWOMS_GET_PARAM(TypeTag, bool, NewtonVerbose) && (comm_.rank() == 0);
522  }
523 
530  void begin_(const SolutionVector &u)
531  {
532  numIterations_ = 0;
533 
534  if (EWOMS_GET_PARAM(TypeTag, bool, NewtonWriteConvergence))
535  convergenceWriter_.beginTimeStep();
536  }
537 
542  {
543  problem().beginIteration();
544  lastError_ = error_;
545  }
546 
550  void linearize_()
551  { model().linearizer().linearize(); }
552 
563  bool solveLinear_(const JacobianMatrix &A,
564  GlobalEqVector &x,
565  GlobalEqVector &b)
566  { return linearSolver_.solve(A, x, b); }
567 
581  void updateError_(const SolutionVector &nextSolution,
582  const SolutionVector &currentSolution,
583  const GlobalEqVector &currentResidual,
584  const GlobalEqVector &solutionUpdate)
585  {
586  lastError_ = error_;
587 
588  // calculate the error as the maximum weighted tolerance of
589  // the solution's residual
590  error_ = 0;
591  for (unsigned i = 0; i < currentResidual.size(); ++i) {
592  if (i >= model().numGridDof() || model().dofTotalVolume(i) <= 0)
593  continue;
594 
595  const auto &r = currentResidual[i];
596  for (unsigned j = 0; j < r.size(); ++j)
597  error_ = std::max(std::abs(r[j] * model().eqWeight(i, j)), error_);
598  }
599 
600  // take the other processes into account
601  error_ = comm_.max(error_);
602 
603  // make sure that the error never grows beyond the maximum
604  // allowed one
605  if (error_ > EWOMS_GET_PARAM(TypeTag, Scalar, NewtonMaxError))
606  OPM_THROW(Opm::NumericalProblem,
607  "Newton: Error " << error_
608  << " is larger than maximum allowed error of "
609  << EWOMS_GET_PARAM(TypeTag, Scalar, NewtonMaxError));
610  }
611 
626  void update_(SolutionVector &nextSolution,
627  const SolutionVector &currentSolution,
628  const GlobalEqVector &solutionUpdate,
629  const GlobalEqVector &currentResidual)
630  {
631  // first, write out the current solution to make convergence
632  // analysis possible
633  asImp_().writeConvergence_(currentSolution, solutionUpdate);
634 
635  // make sure not to swallow non-finite values at this point
636  if (!std::isfinite(solutionUpdate.two_norm2()))
637  OPM_THROW(Opm::NumericalProblem, "Non-finite update!");
638 
639  for (unsigned dofIdx = 0; dofIdx < currentSolution.size(); ++dofIdx) {
640  asImp_().updatePrimaryVariables_(dofIdx,
641  nextSolution[dofIdx],
642  currentSolution[dofIdx],
643  solutionUpdate[dofIdx],
644  currentResidual[dofIdx]);
645  }
646  }
647 
651  void updatePrimaryVariables_(int globalDofIdx,
652  PrimaryVariables& nextValue,
653  const PrimaryVariables& currentValue,
654  const EqVector& update,
655  const EqVector& currentResidual)
656  {
657  nextValue = currentValue;
658  nextValue -= update;
659  }
660 
667  void writeConvergence_(const SolutionVector &currentSolution,
668  const GlobalEqVector &solutionUpdate)
669  {
670  if (EWOMS_GET_PARAM(TypeTag, bool, NewtonWriteConvergence)) {
671  convergenceWriter_.beginIteration();
672  convergenceWriter_.writeFields(currentSolution, solutionUpdate);
673  convergenceWriter_.endIteration();
674  }
675  }
676 
683  void endIteration_(const SolutionVector &nextSolution,
684  const SolutionVector &currentSolution)
685  {
686  ++numIterations_;
687  problem().endIteration();
688 
689  if (asImp_().verbose_()) {
690  std::cout << "Newton iteration " << numIterations_ << ""
691  << " error: " << error_
692  << endIterMsg().str() << "\n" << std::flush;
693  }
694 
695  endIterMsgStream_.str("");
696  }
697 
701  bool proceed_() const
702  {
703  if (asImp_().numIterations() < 1)
704  return true; // we always do at least one iteration
705  else if (asImp_().converged()) {
706  // we are below the specified tolerance, so we don't have to
707  // do more iterations
708  return false;
709  }
710  else if (asImp_().numIterations() >= asImp_().maxIterations_()) {
711  // we have exceeded the allowed number of steps. If the
712  // error was reduced by a factor of at least 4,
713  // in the last iterations we proceed even if we are above
714  // the maximum number of steps
715  return error_ * 4.0 < lastError_;
716  }
717 
718  return true;
719  }
720 
725  void end_()
726  {
727  if (EWOMS_GET_PARAM(TypeTag, bool, NewtonWriteConvergence))
728  convergenceWriter_.endTimeStep();
729  }
730 
736  void failed_()
737  { numIterations_ = targetIterations_() * 2; }
738 
744  void succeeded_()
745  {}
746 
747  // optimal number of iterations we want to achieve
748  int targetIterations_() const
749  { return EWOMS_GET_PARAM(TypeTag, int, NewtonTargetIterations); }
750  // maximum number of iterations we do before giving up
751  int maxIterations_() const
752  { return EWOMS_GET_PARAM(TypeTag, int, NewtonMaxIterations); }
753 
755 
759 
761  Scalar solveTime_;
762  Scalar updateTime_;
763 
764  std::ostringstream endIterMsgStream_;
765 
766  Scalar error_;
767  Scalar lastError_;
768  Scalar tolerance_;
769 
770  // actual number of iterations done so far
772 
773  // the linear solver
774  LinearSolverBackend linearSolver_;
775 
776  // the collective communication used by the simulation (i.e. fake
777  // or MPI)
778  CollectiveCommunication comm_;
779 
780  // the object which writes the convergence behaviour of the Newton
781  // method to disk
782  ConvergenceWriter convergenceWriter_;
783 
784 private:
785  Implementation &asImp_()
786  { return *static_cast<Implementation *>(this); }
787  const Implementation &asImp_() const
788  { return *static_cast<const Implementation *>(this); }
789 };
790 
791 } // namespace Ewoms
792 
793 #endif
void writeConvergence_(const SolutionVector &currentSolution, const GlobalEqVector &solutionUpdate)
Write the convergence behaviour of the newton method to disk.
Definition: newtonmethod.hh:667
Problem & problem()
Returns a reference to the object describing the current physical problem.
Definition: newtonmethod.hh:233
A convergence writer for the Newton method which does nothing.
Definition: nullconvergencewriter.hh:47
void endIteration_(const SolutionVector &nextSolution, const SolutionVector &currentSolution)
Indicates that one Newton iteration was finished.
Definition: newtonmethod.hh:683
Ewoms::Timer updateTimer_
Definition: newtonmethod.hh:758
void beginIteration_()
Indicates the beginning of a Newton iteration.
Definition: newtonmethod.hh:541
Scalar solveTime_
Definition: newtonmethod.hh:761
Scalar tolerance_
Definition: newtonmethod.hh:768
Simulator & simulator_
Definition: newtonmethod.hh:754
SET_SCALAR_PROP(NumericModel, EndTime,-1e100)
The default value for the simulation's end time.
Problem & problem()
Return the object which specifies the pysical setup of the simulation.
Definition: simulator.hh:189
Scalar solveTime() const
Returns the wall time spend so far for solving the linear systems for all iterations of the current t...
Definition: newtonmethod.hh:472
void halt()
Stop the measurement and always return 0 for all timing values.
Definition: timer.hh:86
Scalar suggestTimeStepSize(Scalar oldTimeStep) const
Suggest a new time-step size based on the old time-step size.
Definition: newtonmethod.hh:491
The multi-dimensional Newton method.
Definition: newtonmethod.hh:54
void end_()
Indicates that we're done solving the non-linear system of equations.
Definition: newtonmethod.hh:725
Scalar lastError_
Definition: newtonmethod.hh:767
Scalar updateTime_
Definition: newtonmethod.hh:762
static void registerParameters()
Register all run-time parameters for the Newton method.
Definition: newtonmethod.hh:198
bool proceed_() const
Returns true iff another Newton iteration should be done.
Definition: newtonmethod.hh:701
void begin_(const SolutionVector &u)
Called before the Newton method is applied to an non-linear system of equations.
Definition: newtonmethod.hh:530
std::ostringstream & endIterMsg()
Message that should be printed for the user after the end of an iteration.
Definition: newtonmethod.hh:512
Model & model()
Returns a reference to the numeric model.
Definition: newtonmethod.hh:245
void addPrePostProcessTime(Scalar value)
Definition: simulator.hh:623
SET_INT_PROP(NumericModel, GridGlobalRefinements, 0)
Provides an encapsulation to measure the system time.
Definition: cartesianindexmapper.hh:31
NEW_PROP_TAG(Grid)
The type of the DUNE grid.
STL namespace.
This file provides the infrastructure to retrieve run-time parameters.
int targetIterations_() const
Definition: newtonmethod.hh:748
SET_TYPE_PROP(NumericModel, Scalar, double)
Set the default type of scalar values to double.
Scalar error_
Definition: newtonmethod.hh:766
bool apply()
Run the Newton method.
Definition: newtonmethod.hh:281
Manages the initializing and running of time dependent problems.
Definition: simulator.hh:73
const Model & model() const
Returns a reference to the numeric model.
Definition: newtonmethod.hh:251
Definition: baseauxiliarymodule.hh:35
Ewoms::Timer solveTimer_
Definition: newtonmethod.hh:757
void succeeded_()
Called if the Newton method was successful.
Definition: newtonmethod.hh:744
void updateError_(const SolutionVector &nextSolution, const SolutionVector &currentSolution, const GlobalEqVector &currentResidual, const GlobalEqVector &solutionUpdate)
Update the error of the solution given the previous iteration.
Definition: newtonmethod.hh:581
Scalar tolerance() const
Return the current tolerance at which the Newton method considers itself to be converged.
Definition: newtonmethod.hh:265
ConvergenceWriter convergenceWriter_
Definition: newtonmethod.hh:782
int maxIterations_() const
Definition: newtonmethod.hh:751
NewtonMethod(Simulator &simulator)
Definition: newtonmethod.hh:183
#define EWOMS_REGISTER_PARAM(TypeTag, ParamType, ParamName, Description)
Register a run-time parameter.
Definition: parametersystem.hh:64
std::ostringstream endIterMsgStream_
Definition: newtonmethod.hh:764
Model & model()
Return the physical model used in the simulation.
Definition: simulator.hh:176
A convergence writer for the Newton method which does nothing.
void setTolerance(Scalar value)
Set the current tolerance at which the Newton method considers itself to be converged.
Definition: newtonmethod.hh:272
void update_(SolutionVector &nextSolution, const SolutionVector &currentSolution, const GlobalEqVector &solutionUpdate, const GlobalEqVector &currentResidual)
Update the current solution with a delta vector.
Definition: newtonmethod.hh:626
int numIterations() const
Returns the number of iterations done since the Newton method was invoked.
Definition: newtonmethod.hh:258
void linearize_()
Linearize the global non-linear system of equations.
Definition: newtonmethod.hh:550
void failed_()
Called if the Newton method broke down.
Definition: newtonmethod.hh:736
Scalar updateTime() const
Returns the wall time spend so far for updating the iterative solutions of the non-linear system for ...
Definition: newtonmethod.hh:480
Ewoms::Timer linearizeTimer_
Definition: newtonmethod.hh:756
LinearSolverBackend linearSolver_
Definition: newtonmethod.hh:774
NEW_TYPE_TAG(AuxModule)
Provides the magic behind the eWoms property system.
double realTimeElapsed() const
Return the real time [s] elapsed.
Definition: timer.hh:100
Provides an encapsulation to measure the system time.
Definition: timer.hh:47
bool converged() const
Returns true if the error of the solution is below the tolerance.
Definition: newtonmethod.hh:227
bool verbose_() const
Returns true if the Newton method ought to be chatty.
Definition: newtonmethod.hh:519
SET_BOOL_PROP(FvBaseDiscretization, EnableVtkOutput, true)
Enable the VTK output by default.
void updatePrimaryVariables_(int globalDofIdx, PrimaryVariables &nextValue, const PrimaryVariables &currentValue, const EqVector &update, const EqVector &currentResidual)
Update a single primary variables object.
Definition: newtonmethod.hh:651
bool solveLinear_(const JacobianMatrix &A, GlobalEqVector &x, GlobalEqVector &b)
Solve the linear system of equations .
Definition: newtonmethod.hh:563
void start()
Start counting the time resources used by the simulation.
Definition: timer.hh:68
CollectiveCommunication comm_
Definition: newtonmethod.hh:778
Scalar linearizeTime_
Definition: newtonmethod.hh:760
const Problem & problem() const
Returns a reference to the object describing the current physical problem.
Definition: newtonmethod.hh:239
int numIterations_
Definition: newtonmethod.hh:771
Scalar linearizeTime() const
Returns the wall time spend so far for linearizing the non-linear system for all iterations of the cu...
Definition: newtonmethod.hh:464
#define EWOMS_GET_PARAM(TypeTag, ParamType, ParamName)
Retrieve a runtime parameter.
Definition: parametersystem.hh:95
void stop()
Stop counting the time resources used by the simulation.
Definition: timer.hh:77