DFT-FE 1.3.0-pre
Density Functional Theory With Finite-Elements
Loading...
Searching...
No Matches
kerkerSolverProblem.h
Go to the documentation of this file.
1// ---------------------------------------------------------------------
2//
3// Copyright (c) 2019-2020 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
21#include <FEBasisOperations.h>
22#ifndef kerkerSolverProblem_H_
23# define kerkerSolverProblem_H_
24
25namespace dftfe
26{
27 /**
28 * @brief poisson solver problem class template. template parameter FEOrderElectro
29 * is the finite element polynomial order for electrostatics
30 *
31 * @author Phani Motamarri
32 */
33 template <dftfe::uInt FEOrderElectro>
35 {
36 public:
37 /// Constructor
38 kerkerSolverProblem(const MPI_Comm &mpi_comm_parent,
39 const MPI_Comm &mpi_comm_domain);
40
41
42
43 /**
44 * @brief initialize the matrix-free data structures
45 *
46 * @param matrixFreeData structure to hold quadrature rule, constraints vector and appropriate dofHandler
47 * @param constraintMatrix to hold constraints in the given problem
48 * @param x vector to be initialized using matrix-free object
49 *
50 */
51 void
52 init(std::shared_ptr<
54 FEBasisOperations<double, double, dftfe::utils::MemorySpace::HOST>>
55 &basisOperationsPtr,
56 dealii::AffineConstraints<double> &constraintMatrix,
58 double kerkerMixingParameter,
59 const dftfe::uInt matrixFreeVectorComponent,
60 const dftfe::uInt matrixFreeQuadratureComponent,
61 const dftfe::uInt matrixFreeAxQuadratureComponent);
62
63
64
65 /**
66 * @brief reinitialize data structures .
67 *
68 * @param x vector to store initial guess and solution
69 * @param gradResidualValues stores the gradient of difference of input electron-density and output electron-density
70 * @param kerkerMixingParameter used in Kerker mixing scheme which usually represents Thomas Fermi wavevector (k_{TF}**2).
71 *
72 */
73 void
77 &quadPointValues);
78
79
80 /**
81 * @brief get the reference to x field
82 *
83 * @return reference to x field. Assumes x field data structure is already initialized
84 */
87
88 /**
89 * @brief Compute A matrix multipled by x.
90 *
91 */
92 void
94
95 /**
96 * @brief Compute right hand side vector for the problem Ax = rhs.
97 *
98 * @param rhs vector for the right hand side values
99 */
100 void
102
103 /**
104 * @brief Jacobi preconditioning.
105 *
106 */
107 void
109 const distributedCPUVec<double> &src,
110 const double omega) const;
111
112 /**
113 * @brief distribute x to the constrained nodes.
114 *
115 */
116 void
118
119
120 /// function needed by dealii to mimic SparseMatrix for Jacobi
121 /// preconditioning
122 void
123 subscribe(std::atomic<bool> *const validity,
124 const std::string &identifier = "") const {};
125
126 /// function needed by dealii to mimic SparseMatrix for Jacobi
127 /// preconditioning
128 void
129 unsubscribe(std::atomic<bool> *const validity,
130 const std::string &identifier = "") const {};
131
132 /// function needed by dealii to mimic SparseMatrix
133 bool
134 operator!=(double val) const
135 {
136 return true;
137 };
138
139 private:
140 /**
141 * @brief required for the cell_loop operation in dealii's MatrixFree class
142 *
143 */
144 void
145 AX(const dealii::MatrixFree<3, double> &matrixFreeData,
147 const distributedCPUVec<double> &src,
148 const std::pair<dftfe::uInt, dftfe::uInt> &cell_range) const;
149
150
151 /**
152 * @brief Compute the diagonal of A.
153 *
154 */
155 void
157
158
159 /// storage for diagonal of the A matrix
161
162
163 /// pointer to the x vector being solved for
165
166 // kerker mixing constant
167 double d_gamma;
168
169 /// matrix free index required to access the DofHandler and
170 /// dealii::AffineConstraints<double> objects corresponding to the problem
172
173 /// matrix free quadrature index
176
177 /// pointer to electron density cell and grad residual data
180 const dealii::DoFHandler<3> *d_dofHandlerPRefinedPtr;
181 const dealii::AffineConstraints<double> *d_constraintMatrixPRefinedPtr;
182 const dealii::MatrixFree<3, double> *d_matrixFreeDataPRefinedPtr;
183 std::shared_ptr<
184 dftfe::basis::
185 FEBasisOperations<double, double, dftfe::utils::MemorySpace::HOST>>
187
188
189 const MPI_Comm d_mpiCommParent;
190 const MPI_Comm mpi_communicator;
193 dealii::ConditionalOStream pcout;
194 };
195
196} // namespace dftfe
197#endif // kerkerSolverProblem_H_
const MPI_Comm mpi_communicator
Definition kerkerSolverProblem.h:190
void vmult(distributedCPUVec< double > &Ax, distributedCPUVec< double > &x)
Compute A matrix multipled by x.
distributedCPUVec< double > * d_xPtr
pointer to the x vector being solved for
Definition kerkerSolverProblem.h:164
void distributeX()
distribute x to the constrained nodes.
dealii::ConditionalOStream pcout
Definition kerkerSolverProblem.h:193
void reinit(distributedCPUVec< double > &x, const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > &quadPointValues)
reinitialize data structures .
dftfe::uInt d_matrixFreeVectorComponent
Definition kerkerSolverProblem.h:171
const dftfe::uInt this_mpi_process
Definition kerkerSolverProblem.h:192
void computeDiagonalA()
Compute the diagonal of A.
kerkerSolverProblem(const MPI_Comm &mpi_comm_parent, const MPI_Comm &mpi_comm_domain)
Constructor.
void subscribe(std::atomic< bool > *const validity, const std::string &identifier="") const
Definition kerkerSolverProblem.h:123
void precondition_Jacobi(distributedCPUVec< double > &dst, const distributedCPUVec< double > &src, const double omega) const
Jacobi preconditioning.
distributedCPUVec< double > & getX()
get the reference to x field
dftfe::uInt d_matrixFreeAxQuadratureComponent
Definition kerkerSolverProblem.h:175
const dftfe::uInt n_mpi_processes
Definition kerkerSolverProblem.h:191
const dealii::MatrixFree< 3, double > * d_matrixFreeDataPRefinedPtr
Definition kerkerSolverProblem.h:182
std::shared_ptr< dftfe::basis::FEBasisOperations< double, double, dftfe::utils::MemorySpace::HOST > > d_basisOperationsPtr
Definition kerkerSolverProblem.h:186
void AX(const dealii::MatrixFree< 3, double > &matrixFreeData, distributedCPUVec< double > &dst, const distributedCPUVec< double > &src, const std::pair< dftfe::uInt, dftfe::uInt > &cell_range) const
required for the cell_loop operation in dealii's MatrixFree class
bool operator!=(double val) const
function needed by dealii to mimic SparseMatrix
Definition kerkerSolverProblem.h:134
distributedCPUVec< double > d_diagonalA
storage for diagonal of the A matrix
Definition kerkerSolverProblem.h:160
double d_gamma
Definition kerkerSolverProblem.h:167
const dealii::DoFHandler< 3 > * d_dofHandlerPRefinedPtr
Definition kerkerSolverProblem.h:180
void computeRhs(distributedCPUVec< double > &rhs)
Compute right hand side vector for the problem Ax = rhs.
const dealii::AffineConstraints< double > * d_constraintMatrixPRefinedPtr
Definition kerkerSolverProblem.h:181
void init(std::shared_ptr< dftfe::basis::FEBasisOperations< double, double, dftfe::utils::MemorySpace::HOST > > &basisOperationsPtr, dealii::AffineConstraints< double > &constraintMatrix, distributedCPUVec< double > &x, double kerkerMixingParameter, const dftfe::uInt matrixFreeVectorComponent, const dftfe::uInt matrixFreeQuadratureComponent, const dftfe::uInt matrixFreeAxQuadratureComponent)
initialize the matrix-free data structures
const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > * d_residualQuadValuesPtr
pointer to electron density cell and grad residual data
Definition kerkerSolverProblem.h:179
dftfe::uInt d_matrixFreeQuadratureComponent
matrix free quadrature index
Definition kerkerSolverProblem.h:174
void unsubscribe(std::atomic< bool > *const validity, const std::string &identifier="") const
Definition kerkerSolverProblem.h:129
const MPI_Comm d_mpiCommParent
Definition kerkerSolverProblem.h:189
Definition MemoryStorage.h:33
Definition FEBasisOperations.h:30
Definition pseudoPotentialToDftfeConverter.cc:34
dealii::LinearAlgebra::distributed::Vector< elem_type, dealii::MemorySpace::Host > distributedCPUVec
Definition headers.h:92
std::uint32_t uInt
Definition TypeConfig.h:10