MBDyn-1.7.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
NonlinearSolver Class Referenceabstract

#include <nonlin.h>

Inheritance diagram for NonlinearSolver:
Collaboration diagram for NonlinearSolver:

Classes

class  ConvergenceOnSolution
 
class  ErrGeneric
 
class  ErrSimulationDiverged
 
class  MaxResidualExceeded
 
class  NoConvergence
 
class  TimeStepLimitExceeded
 

Public Types

enum  Type {
  UNKNOWN = -1, NEWTONRAPHSON, MATRIXFREE, LINESEARCH,
  DEFAULT = NEWTONRAPHSON, LASTSOLVERTYPE
}
 

Public Member Functions

 NonlinearSolver (const NonlinearSolverOptions &options)
 
virtual void SetTest (NonlinearSolverTest *pr, NonlinearSolverTest *ps)
 
virtual ~NonlinearSolver (void)
 
virtual bool MakeResTest (Solver *pS, const NonlinearProblem *pNLP, const VectorHandler &Vec, const doublereal &dTol, doublereal &dTest, doublereal &dTestDiff)
 
virtual void Solve (const NonlinearProblem *pNLP, Solver *pS, const integer iMaxIter, const doublereal &Tol, integer &iIterCnt, doublereal &dErr, const doublereal &SolTol, doublereal &dSolErr)=0
 
virtual integer TotalAssembledJacobian (void)
 
virtual NonlinearSolverTestpGetResTest (void)
 
virtual NonlinearSolverTestpGetSolTest (void)
 
- Public Member Functions inherited from SolverDiagnostics
 SolverDiagnostics (unsigned OF=OUTPUT_DEFAULT, DriveCaller *pOM=0)
 
virtual ~SolverDiagnostics (void)
 
void SetNoOutput (void)
 
void SetOutputMeter (DriveCaller *pOM)
 
void SetOutputDriveHandler (const DriveHandler *pDH)
 
void SetOutputFlags (unsigned OF)
 
void AddOutputFlags (unsigned OF)
 
void DelOutputFlags (unsigned OF)
 
MatrixHandler::Norm_t GetCondMatNorm (void) const
 
bool outputMeter (void) const
 
bool outputIters (void) const
 
bool outputRes (void) const
 
bool outputSol (void) const
 
bool outputJac (void) const
 
bool outputStep (void) const
 
bool outputBailout (void) const
 
bool outputCounter (void) const
 
bool outputMatrixConditionNumber (void) const
 
bool outputSolverConditionNumber (void) const
 
bool outputSolverConditionStat (void) const
 
bool outputCPUTime (void) const
 
bool outputMsg (void) const
 

Protected Types

enum  CPUTimeType { CPU_RESIDUAL, CPU_JACOBIAN, CPU_LINEAR_SOLVER, CPU_LAST_TYPE }
 
- Protected Types inherited from SolverDiagnostics
enum  {
  OUTPUT_NONE = 0x0000, OUTPUT_ITERS = 0x0001, OUTPUT_RES = 0x0002, OUTPUT_SOL = 0x0004,
  OUTPUT_JAC = 0x0008, OUTPUT_BAILOUT = 0x0010, OUTPUT_MSG = 0x0020, OUTPUT_COUNTER = 0x0040,
  OUTPUT_MAT_COND_NUM_1 = 0x0080, OUTPUT_MAT_COND_NUM_INF = 0x0100, OUTPUT_SOLVER_COND_NUM = 0x0200, OUTPUT_SOLVER_COND_STAT = 0x400,
  OUTPUT_CPU_TIME = 0x800, OUTPUT_MAT_COND_NUM = OUTPUT_MAT_COND_NUM_1 | OUTPUT_MAT_COND_NUM_INF, OUTPUT_DEFAULT = OUTPUT_MSG, OUTPUT_STEP = (OUTPUT_ITERS | OUTPUT_RES | OUTPUT_SOL | OUTPUT_JAC | OUTPUT_MAT_COND_NUM | OUTPUT_SOLVER_COND_NUM),
  OUTPUT_MASK = 0x07FF
}
 
- Protected Types inherited from NonlinearSolverOptions
enum  ScaleFlags { SCALE_ALGEBRAIC_EQUATIONS_NO = 0, SCALE_ALGEBRAIC_EQUATIONS_YES = 1 }
 

Protected Member Functions

virtual bool MakeSolTest (Solver *pS, const VectorHandler &Vec, const doublereal &dTol, doublereal &dTest)
 
doublereal dGetCondMax () const
 
doublereal dGetCondMin () const
 
doublereal dGetCondAvg () const
 
doublereal dGetTimeCPU (CPUTimeType eType) const
 
void AddCond (doublereal dCond)
 
void AddTimeCPU (doublereal dTime, CPUTimeType eType)
 
- Protected Member Functions inherited from NonlinearSolverOptions
 NonlinearSolverOptions (bool bHonorJacRequest=false, enum ScaleFlags eScaleFlags=SCALE_ALGEBRAIC_EQUATIONS_NO, doublereal dScaleAlgebraic=1.)
 

Protected Attributes

integer Size
 
integer TotJac
 
NonlinearSolverTestpResTest
 
NonlinearSolverTestpSolTest
 
- Protected Attributes inherited from SolverDiagnostics
unsigned OutputFlags
 
DriveCallerpOutputMeter
 
- Protected Attributes inherited from NonlinearSolverOptions
bool bHonorJacRequest
 
enum
NonlinearSolverOptions::ScaleFlags 
eScaleFlags
 
doublereal dScaleAlgebraic
 

Private Attributes

integer iNumCond
 
doublereal dMaxCond
 
doublereal dMinCond
 
doublereal dSumCond
 
doublereal dTimeCPU [CPU_LAST_TYPE]
 

Detailed Description

Definition at line 211 of file nonlin.h.

Member Enumeration Documentation

Enumerator
CPU_RESIDUAL 
CPU_JACOBIAN 
CPU_LINEAR_SOLVER 
CPU_LAST_TYPE 

Definition at line 268 of file nonlin.h.

Enumerator
UNKNOWN 
NEWTONRAPHSON 
MATRIXFREE 
LINESEARCH 
DEFAULT 
LASTSOLVERTYPE 

Definition at line 239 of file nonlin.h.

Constructor & Destructor Documentation

NonlinearSolver::NonlinearSolver ( const NonlinearSolverOptions options)
explicit

Definition at line 434 of file nonlin.cc.

References dTimeCPU.

435 : NonlinearSolverOptions(options),
436 Size(0),
437 TotJac(0),
438 #ifdef USE_MPI
439 bParallel(MPI::Is_initialized()),
440 #endif /* USE_MPI */
441 pResTest(0),
442 pSolTest(0),
443 iNumCond(0),
444 dMaxCond(0.),
445 dMinCond(std::numeric_limits<doublereal>::max()),
446 dSumCond(0.)
447 #ifdef USE_EXTERNAL
448 , ExtStepType(External::ERROR)
449 #endif /* USE_EXTERNAL */
450 {
451  std::memset(dTimeCPU, 0, sizeof(dTimeCPU));
452 }
doublereal dTimeCPU[CPU_LAST_TYPE]
Definition: nonlin.h:288
doublereal dMaxCond
Definition: nonlin.h:285
integer TotJac
Definition: nonlin.h:252
doublereal dMinCond
Definition: nonlin.h:286
integer Size
Definition: nonlin.h:251
NonlinearSolverTest * pSolTest
Definition: nonlin.h:258
NonlinearSolverOptions(bool bHonorJacRequest=false, enum ScaleFlags eScaleFlags=SCALE_ALGEBRAIC_EQUATIONS_NO, doublereal dScaleAlgebraic=1.)
Definition: nonlin.cc:422
integer iNumCond
Definition: nonlin.h:284
doublereal dSumCond
Definition: nonlin.h:287
NonlinearSolverTest * pResTest
Definition: nonlin.h:257
NonlinearSolver::~NonlinearSolver ( void  )
virtual

Definition at line 461 of file nonlin.cc.

References pResTest, pSolTest, and SAFEDELETE.

462 {
465 }
NonlinearSolverTest * pSolTest
Definition: nonlin.h:258
NonlinearSolverTest * pResTest
Definition: nonlin.h:257
#define SAFEDELETE(pnt)
Definition: mynewmem.h:710

Member Function Documentation

void NonlinearSolver::AddCond ( doublereal  dCond)
inlineprotected

Definition at line 331 of file nonlin.h.

References dMaxCond, dMinCond, dSumCond, and iNumCond.

Referenced by NewtonRaphsonSolver::Solve(), and LineSearchSolver::Solve().

332 {
333  iNumCond++;
334  dSumCond += dCond;
335 
336  if (dCond > dMaxCond) {
337  dMaxCond = dCond;
338  }
339 
340  if (dCond < dMinCond) {
341  dMinCond = dCond;
342  }
343 }
doublereal dMaxCond
Definition: nonlin.h:285
doublereal dMinCond
Definition: nonlin.h:286
integer iNumCond
Definition: nonlin.h:284
doublereal dSumCond
Definition: nonlin.h:287
void NonlinearSolver::AddTimeCPU ( doublereal  dTime,
CPUTimeType  eType 
)
inlineprotected

Definition at line 355 of file nonlin.h.

References ASSERT, CPU_LAST_TYPE, and dTimeCPU.

Referenced by NewtonRaphsonSolver::Solve(), and LineSearchSolver::Solve().

356 {
357  ASSERT(eType >= 0);
358  ASSERT(eType < CPU_LAST_TYPE);
359 
360  dTimeCPU[eType] += dTime;
361 }
doublereal dTimeCPU[CPU_LAST_TYPE]
Definition: nonlin.h:288
#define ASSERT(expression)
Definition: colamd.c:977
doublereal NonlinearSolver::dGetCondAvg ( ) const
inlineprotected

Definition at line 277 of file nonlin.h.

References dSumCond, and iNumCond.

Referenced by NewtonRaphsonSolver::Solve(), and LineSearchSolver::Solve().

277 { return dSumCond / iNumCond; }
integer iNumCond
Definition: nonlin.h:284
doublereal dSumCond
Definition: nonlin.h:287
doublereal NonlinearSolver::dGetCondMax ( ) const
inlineprotected

Definition at line 275 of file nonlin.h.

References dMaxCond.

Referenced by NewtonRaphsonSolver::Solve(), and LineSearchSolver::Solve().

275 { return dMaxCond; }
doublereal dMaxCond
Definition: nonlin.h:285
doublereal NonlinearSolver::dGetCondMin ( ) const
inlineprotected

Definition at line 276 of file nonlin.h.

References dMinCond.

Referenced by NewtonRaphsonSolver::Solve(), and LineSearchSolver::Solve().

276 { return dMinCond; }
doublereal dMinCond
Definition: nonlin.h:286
doublereal NonlinearSolver::dGetTimeCPU ( CPUTimeType  eType) const
inlineprotected

Definition at line 346 of file nonlin.h.

References ASSERT, CPU_LAST_TYPE, and dTimeCPU.

Referenced by NewtonRaphsonSolver::Solve(), and LineSearchSolver::Solve().

347 {
348  ASSERT(eType >= 0);
349  ASSERT(eType < CPU_LAST_TYPE);
350 
351  return dTimeCPU[eType];
352 }
doublereal dTimeCPU[CPU_LAST_TYPE]
Definition: nonlin.h:288
#define ASSERT(expression)
Definition: colamd.c:977
bool NonlinearSolver::MakeResTest ( Solver pS,
const NonlinearProblem pNLP,
const VectorHandler Vec,
const doublereal dTol,
doublereal dTest,
doublereal dTestDiff 
)
virtual

Definition at line 474 of file nonlin.cc.

References NonlinearSolverOptions::dScaleAlgebraic, NonlinearSolverOptions::eScaleFlags, DataManager::IsConverged(), NonlinearSolverTest::MakeTest(), Solver::pGetDataManager(), pResTest, NonlinearSolverOptions::SCALE_ALGEBRAIC_EQUATIONS_NO, Size, and NonlinearProblem::TestScale().

Referenced by LineSearchSolver::LineSearch(), BiCGStab::Solve(), Gmres::Solve(), NewtonRaphsonSolver::Solve(), and LineSearchSolver::Solve().

480 {
481  doublereal dScaleAlgEqu;
482  const doublereal dTestScale = pNLP->TestScale(pResTest, dScaleAlgEqu);
483 
485  // f = c / dCoef
486  dScaleAlgEqu = 1.;
487  } else {
488  // f = c * dScaleAlgebraic
489  dScaleAlgEqu *= dScaleAlgebraic;
490  }
491 
492  dTest = pResTest->MakeTest(pS, Size, Vec, true, dScaleAlgEqu, &dTestDiff) * dTestScale;
493  return ((dTest < dTol) && pS->pGetDataManager()->IsConverged());
494 }
bool IsConverged(void) const
Definition: dataman2.cc:2692
enum NonlinearSolverOptions::ScaleFlags eScaleFlags
virtual doublereal TestScale(const NonlinearSolverTest *pTest, doublereal &dAlgebraicEquations) const =0
doublereal dScaleAlgebraic
Definition: nonlin.h:204
virtual doublereal MakeTest(Solver *pS, const integer &Size, const VectorHandler &Vec, bool bResidual=false, doublereal dScaleAlgEqu=1., doublereal *pTestDiff=0)
Definition: nonlin.cc:63
integer Size
Definition: nonlin.h:251
virtual DataManager * pGetDataManager(void) const
Definition: solver.h:395
double doublereal
Definition: colamd.c:52
NonlinearSolverTest * pResTest
Definition: nonlin.h:257

Here is the call graph for this function:

bool NonlinearSolver::MakeSolTest ( Solver pS,
const VectorHandler Vec,
const doublereal dTol,
doublereal dTest 
)
protectedvirtual

Definition at line 497 of file nonlin.cc.

References DataManager::IsConverged(), NonlinearSolverTest::MakeTest(), Solver::pGetDataManager(), pSolTest, and Size.

Referenced by BiCGStab::Solve(), NewtonRaphsonSolver::Solve(), Gmres::Solve(), and LineSearchSolver::Solve().

501 {
502  dTest = pSolTest->MakeTest(pS, Size, Vec);
503  return ((dTest < dTol) && pS->pGetDataManager()->IsConverged());
504 }
bool IsConverged(void) const
Definition: dataman2.cc:2692
virtual doublereal MakeTest(Solver *pS, const integer &Size, const VectorHandler &Vec, bool bResidual=false, doublereal dScaleAlgEqu=1., doublereal *pTestDiff=0)
Definition: nonlin.cc:63
integer Size
Definition: nonlin.h:251
NonlinearSolverTest * pSolTest
Definition: nonlin.h:258
virtual DataManager * pGetDataManager(void) const
Definition: solver.h:395

Here is the call graph for this function:

virtual NonlinearSolverTest* NonlinearSolver::pGetResTest ( void  )
inlinevirtual

Definition at line 315 of file nonlin.h.

References pResTest.

315  {
316  return pResTest;
317  }
NonlinearSolverTest * pResTest
Definition: nonlin.h:257
virtual NonlinearSolverTest* NonlinearSolver::pGetSolTest ( void  )
inlinevirtual

Definition at line 319 of file nonlin.h.

References pSolTest.

319  {
320  return pSolTest;
321  }
NonlinearSolverTest * pSolTest
Definition: nonlin.h:258
void NonlinearSolver::SetTest ( NonlinearSolverTest pr,
NonlinearSolverTest ps 
)
virtual

Definition at line 455 of file nonlin.cc.

References pResTest, and pSolTest.

Referenced by InverseSolver::Prepare(), and Solver::Prepare().

456 {
457  pResTest = pr;
458  pSolTest = ps;
459 }
NonlinearSolverTest * pSolTest
Definition: nonlin.h:258
NonlinearSolverTest * pResTest
Definition: nonlin.h:257
virtual void NonlinearSolver::Solve ( const NonlinearProblem pNLP,
Solver pS,
const integer  iMaxIter,
const doublereal Tol,
integer iIterCnt,
doublereal dErr,
const doublereal SolTol,
doublereal dSolErr 
)
pure virtual
integer NonlinearSolver::TotalAssembledJacobian ( void  )
virtual

Definition at line 468 of file nonlin.cc.

References TotJac.

Referenced by InverseSolver::Advance(), and Solver::Advance().

469 {
470  return TotJac;
471 }
integer TotJac
Definition: nonlin.h:252

Member Data Documentation

doublereal NonlinearSolver::dMaxCond
private

Definition at line 285 of file nonlin.h.

Referenced by AddCond(), and dGetCondMax().

doublereal NonlinearSolver::dMinCond
private

Definition at line 286 of file nonlin.h.

Referenced by AddCond(), and dGetCondMin().

doublereal NonlinearSolver::dSumCond
private

Definition at line 287 of file nonlin.h.

Referenced by AddCond(), and dGetCondAvg().

doublereal NonlinearSolver::dTimeCPU[CPU_LAST_TYPE]
private

Definition at line 288 of file nonlin.h.

Referenced by AddTimeCPU(), dGetTimeCPU(), and NonlinearSolver().

integer NonlinearSolver::iNumCond
private

Definition at line 284 of file nonlin.h.

Referenced by AddCond(), and dGetCondAvg().

NonlinearSolverTest* NonlinearSolver::pResTest
protected

Definition at line 257 of file nonlin.h.

Referenced by MakeResTest(), pGetResTest(), SetTest(), and ~NonlinearSolver().

NonlinearSolverTest* NonlinearSolver::pSolTest
protected

Definition at line 258 of file nonlin.h.

Referenced by MakeSolTest(), pGetSolTest(), SetTest(), and ~NonlinearSolver().

integer NonlinearSolver::TotJac
protected

The documentation for this class was generated from the following files: