DFT-FE 1.1.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 <unsigned int 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 unsigned int matrixFreeVectorComponent,
60 const unsigned int matrixFreeQuadratureComponent);
61
62
63
64 /**
65 * @brief reinitialize data structures .
66 *
67 * @param x vector to store initial guess and solution
68 * @param gradResidualValues stores the gradient of difference of input electron-density and output electron-density
69 * @param kerkerMixingParameter used in Kerker mixing scheme which usually represents Thomas Fermi wavevector (k_{TF}**2).
70 *
71 */
72 void
76 &quadPointValues);
77
78
79 /**
80 * @brief get the reference to x field
81 *
82 * @return reference to x field. Assumes x field data structure is already initialized
83 */
86
87 /**
88 * @brief Compute A matrix multipled by x.
89 *
90 */
91 void
93
94 /**
95 * @brief Compute right hand side vector for the problem Ax = rhs.
96 *
97 * @param rhs vector for the right hand side values
98 */
99 void
101
102 /**
103 * @brief Jacobi preconditioning.
104 *
105 */
106 void
108 const distributedCPUVec<double> &src,
109 const double omega) const;
110
111 /**
112 * @brief distribute x to the constrained nodes.
113 *
114 */
115 void
117
118
119 /// function needed by dealii to mimic SparseMatrix for Jacobi
120 /// preconditioning
121 void
122 subscribe(std::atomic<bool> *const validity,
123 const std::string & identifier = "") const {};
124
125 /// function needed by dealii to mimic SparseMatrix for Jacobi
126 /// preconditioning
127 void
128 unsubscribe(std::atomic<bool> *const validity,
129 const std::string & identifier = "") const {};
130
131 /// function needed by dealii to mimic SparseMatrix
132 bool
133 operator!=(double val) const
134 {
135 return true;
136 };
137
138 private:
139 /**
140 * @brief required for the cell_loop operation in dealii's MatrixFree class
141 *
142 */
143 void
144 AX(const dealii::MatrixFree<3, double> & matrixFreeData,
146 const distributedCPUVec<double> & src,
147 const std::pair<unsigned int, unsigned int> &cell_range) const;
148
149
150 /**
151 * @brief Compute the diagonal of A.
152 *
153 */
154 void
156
157
158 /// storage for diagonal of the A matrix
160
161
162 /// pointer to the x vector being solved for
164
165 // kerker mixing constant
166 double d_gamma;
167
168 /// matrix free index required to access the DofHandler and
169 /// dealii::AffineConstraints<double> objects corresponding to the problem
171
172 /// matrix free quadrature index
174
175
176 /// pointer to electron density cell and grad residual data
179 const dealii::DoFHandler<3> * d_dofHandlerPRefinedPtr;
180 const dealii::AffineConstraints<double> *d_constraintMatrixPRefinedPtr;
181 const dealii::MatrixFree<3, double> * d_matrixFreeDataPRefinedPtr;
182 std::shared_ptr<
183 dftfe::basis::
184 FEBasisOperations<double, double, dftfe::utils::MemorySpace::HOST>>
186
187
188 const MPI_Comm d_mpiCommParent;
189 const MPI_Comm mpi_communicator;
190 const unsigned int n_mpi_processes;
191 const unsigned int this_mpi_process;
192 dealii::ConditionalOStream pcout;
193 };
194
195} // namespace dftfe
196#endif // kerkerSolverProblem_H_
const MPI_Comm mpi_communicator
Definition kerkerSolverProblem.h:189
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:163
void distributeX()
distribute x to the constrained nodes.
dealii::ConditionalOStream pcout
Definition kerkerSolverProblem.h:192
void reinit(distributedCPUVec< double > &x, const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > &quadPointValues)
reinitialize data structures .
void AX(const dealii::MatrixFree< 3, double > &matrixFreeData, distributedCPUVec< double > &dst, const distributedCPUVec< double > &src, const std::pair< unsigned int, unsigned int > &cell_range) const
required for the cell_loop operation in dealii's MatrixFree class
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:122
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
const unsigned int n_mpi_processes
Definition kerkerSolverProblem.h:190
const dealii::MatrixFree< 3, double > * d_matrixFreeDataPRefinedPtr
Definition kerkerSolverProblem.h:181
std::shared_ptr< dftfe::basis::FEBasisOperations< double, double, dftfe::utils::MemorySpace::HOST > > d_basisOperationsPtr
Definition kerkerSolverProblem.h:185
bool operator!=(double val) const
function needed by dealii to mimic SparseMatrix
Definition kerkerSolverProblem.h:133
unsigned int d_matrixFreeQuadratureComponent
matrix free quadrature index
Definition kerkerSolverProblem.h:173
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 unsigned int matrixFreeVectorComponent, const unsigned int matrixFreeQuadratureComponent)
initialize the matrix-free data structures
const unsigned int this_mpi_process
Definition kerkerSolverProblem.h:191
distributedCPUVec< double > d_diagonalA
storage for diagonal of the A matrix
Definition kerkerSolverProblem.h:159
double d_gamma
Definition kerkerSolverProblem.h:166
const dealii::DoFHandler< 3 > * d_dofHandlerPRefinedPtr
Definition kerkerSolverProblem.h:179
void computeRhs(distributedCPUVec< double > &rhs)
Compute right hand side vector for the problem Ax = rhs.
const dealii::AffineConstraints< double > * d_constraintMatrixPRefinedPtr
Definition kerkerSolverProblem.h:180
const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > * d_residualQuadValuesPtr
pointer to electron density cell and grad residual data
Definition kerkerSolverProblem.h:178
unsigned int d_matrixFreeVectorComponent
Definition kerkerSolverProblem.h:170
void unsubscribe(std::atomic< bool > *const validity, const std::string &identifier="") const
Definition kerkerSolverProblem.h:128
const MPI_Comm d_mpiCommParent
Definition kerkerSolverProblem.h:188
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