DFT-FE 1.1.0-pre
Density Functional Theory With Finite-Elements
Loading...
Searching...
No Matches
nonLinearSolver.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (c) 2017-2025 The Regents of the University of Michigan and DFT-FE
4// authors.
5//
6// This file is part of the DFT-FE code.
7//
8// The DFT-FE code is free software; you can use it, redistribute
9// it, and/or modify it under the terms of the GNU Lesser General
10// Public License as published by the Free Software Foundation; either
11// version 2.1 of the License, or (at your option) any later version.
12// The full text of the license can be found in the file LICENSE at
13// the top level of the DFT-FE distribution.
14//
15// ---------------------------------------------------------------------
16//
17
18
19
20#ifndef NonLinearSolver_h
21#define NonLinearSolver_h
22
23
24#include "headers.h"
25
26namespace dftfe
27{
28 //
29 // forward declarations
30 //
32
33 /**
34 * @brief Base class for non-linear algebraic solver.
35 *
36 * @author Sambit Das
37 */
39 {
40 //
41 // types
42 //
43 public:
52
53 //
54 // methods
55 //
56 public:
57 /**
58 * @brief Destructor.
59 */
60 virtual ~nonLinearSolver() = 0;
61
62 /**
63 * @brief Solve non-linear algebraic equation.
64 *
65 * @param problem[in] nonlinearSolverProblem object.
66 * @param checkpointFileName[in] if string is non-empty, creates checkpoint file
67 * named checkpointFileName for every nonlinear iteration.
68 * @param restart[in] boolean specifying whether this is a restart solve.
69 * @return Return value indicating success or failure.
70 */
71 virtual ReturnValueType
73 const std::string checkpointFileName = "",
74 const bool restart = false) = 0;
75
76 virtual void
77 save(const std::string &checkpointFileName) = 0;
78
79
80 protected:
81 /**
82 * @brief Constructor.
83 *
84 */
85 nonLinearSolver(const unsigned int debugLevel,
86 const unsigned int maxNumberIterations,
87 const double tolerance = 0);
88
89
90 protected:
91 /**
92 * @brief Get tolerance.
93 *
94 * @return Value of the tolerance.
95 */
96 double
97 getTolerance() const;
98
99 /**
100 * @brief Get maximum number of iterations.
101 *
102 * @return Maximum number of iterations.
103 */
104 unsigned int
106
107 /**
108 * @brief Get debug level.
109 *
110 * @return Debug level.
111 */
112 unsigned int
114
115
116 /// controls the verbosity of the printing
117 const unsigned int d_debugLevel;
118
119 /// maximum number of nonlinear solve iterations
120 const unsigned int d_maxNumberIterations;
121
122 /// nonlinear solve stopping tolerance
123 const double d_tolerance;
124 };
125
126} // namespace dftfe
127
128#endif // NonLinearSolver_h
const double d_tolerance
nonlinear solve stopping tolerance
Definition nonLinearSolver.h:123
virtual ReturnValueType solve(nonlinearSolverProblem &problem, const std::string checkpointFileName="", const bool restart=false)=0
Solve non-linear algebraic equation.
unsigned int getMaximumNumberIterations() const
Get maximum number of iterations.
double getTolerance() const
Get tolerance.
const unsigned int d_debugLevel
controls the verbosity of the printing
Definition nonLinearSolver.h:117
virtual ~nonLinearSolver()=0
Destructor.
virtual void save(const std::string &checkpointFileName)=0
nonLinearSolver(const unsigned int debugLevel, const unsigned int maxNumberIterations, const double tolerance=0)
Constructor.
unsigned int getDebugLevel() const
Get debug level.
ReturnValueType
Definition nonLinearSolver.h:45
@ MAX_ITER_REACHED
Definition nonLinearSolver.h:49
@ RESTART
Definition nonLinearSolver.h:50
@ FAILURE
Definition nonLinearSolver.h:47
@ LINESEARCH_FAILED
Definition nonLinearSolver.h:48
@ SUCCESS
Definition nonLinearSolver.h:46
const unsigned int d_maxNumberIterations
maximum number of nonlinear solve iterations
Definition nonLinearSolver.h:120
Abstract class for solver functions.
Definition nonlinearSolverProblem.h:30
Definition pseudoPotentialToDftfeConverter.cc:34