DFT-FE 1.1.0-pre
Density Functional Theory With Finite-Elements
Loading...
Searching...
No Matches
nonlinearSolverProblem.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#ifndef nonlinearSolverProblem_H_
19#define nonlinearSolverProblem_H_
20#include "headers.h"
21
22namespace dftfe
23{
24 /**
25 * @brief Abstract class for solver functions.
26 *
27 * @author Sambit Das
28 */
30 {
31 public:
32 /**
33 * @brief Constructor.
34 */
36
37 /**
38 * @brief Destructor.
39 */
41
42 /**
43 * @brief Obtain number of unknowns.
44 *
45 * @return Number of unknowns.
46 */
47 virtual unsigned int
48 getNumberUnknowns() const = 0;
49
50 /**
51 * @brief Compute function value (aka energy).
52 *
53 *
54 * @return Function value.
55 */
56 virtual void
57 value(std::vector<double> &functionValue) = 0;
58
59
60 /**
61 * @brief Compute function gradient (aka forces).
62 *
63 * @param gradient STL vector for gradient values.
64 */
65 virtual void
66 gradient(std::vector<double> &gradient) = 0;
67
68 /**
69 * @brief Apply preconditioner to function gradient.
70 *
71 * @param s STL vector for s=-M^{-1} gradient.
72 * @param gradient STL vector for gradient values.
73 */
74 virtual void
75 precondition(std::vector<double> & s,
76 const std::vector<double> &gradient) = 0;
77
78 /**
79 * @brief Update solution.
80 *
81 * @param solution Updated solution.
82 */
83 virtual void
84 update(const std::vector<double> &solution,
85 const bool computeForces = true,
86 const bool useSingleAtomSolutionsInitialGuess = false) = 0;
87
88 /**
89 * @brief Obtain current solution.
90 *
91 * @param solution Space for current solution.
92 */
93 virtual void
94 solution(std::vector<double> &solution) = 0;
95
96 /**
97 * @brief For each unknown indicate whether that unknown should
98 * be accumulated. This functionality is needed in the case of
99 * parallel execution when domain decomposition is
100 * employed. Unknowns residing on processor boundary should only
101 * be accumulated once when dot products of vertex fields are
102 * computed (e.g. residual).
103 *
104 * @return A vector of int values for each unknown. Value of 1
105 * indicates that the unknown should be counted and 0 otherwise.
106 */
107 virtual std::vector<unsigned int>
109
110 /**
111 * @brief check for convergence.
112 *
113 */
114 virtual bool
115 isConverged() const = 0;
116
117 /**
118 * @brief create checkpoint for the current state of the problem i.e problem domain and solution.
119 *
120 */
121 virtual void
122 save() = 0;
123
124 /**
125 * @brief get MPI communicator.
126 *
127 */
128 virtual const MPI_Comm &
130 };
131
132} // namespace dftfe
133#endif // nonlinearSolverProblem_H_
virtual void value(std::vector< double > &functionValue)=0
Compute function value (aka energy).
virtual bool isConverged() const =0
check for convergence.
virtual void solution(std::vector< double > &solution)=0
Obtain current solution.
nonlinearSolverProblem()
Constructor.
virtual std::vector< unsigned int > getUnknownCountFlag() const =0
For each unknown indicate whether that unknown should be accumulated. This functionality is needed in...
virtual void update(const std::vector< double > &solution, const bool computeForces=true, const bool useSingleAtomSolutionsInitialGuess=false)=0
Update solution.
virtual ~nonlinearSolverProblem()=0
Destructor.
virtual const MPI_Comm & getMPICommunicator()=0
get MPI communicator.
virtual unsigned int getNumberUnknowns() const =0
Obtain number of unknowns.
virtual void gradient(std::vector< double > &gradient)=0
Compute function gradient (aka forces).
virtual void precondition(std::vector< double > &s, const std::vector< double > &gradient)=0
Apply preconditioner to function gradient.
virtual void save()=0
create checkpoint for the current state of the problem i.e problem domain and solution.
Definition pseudoPotentialToDftfeConverter.cc:34