DFT-FE 1.1.0-pre
Density Functional Theory With Finite-Elements
Loading...
Searching...
No Matches
poissonSolverProblem.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#ifndef poissonSolverProblem_H_
20#define poissonSolverProblem_H_
21
24#include "FEBasisOperations.h"
25
26namespace dftfe
27{
28 /**
29 * @brief poisson solver problem class template. template parameter FEOrderElectro
30 * is the finite element polynomial order. FEOrder template parameter is used
31 * in conjunction with FEOrderElectro to determine the order of the Gauss
32 * quadrature rule
33 *
34 * @author Shiva Rudraraju, Phani Motamarri, Sambit Das
35 */
36 template <unsigned int FEOrder, unsigned int FEOrderElectro>
38 {
39 public:
40 /// Constructor
41 poissonSolverProblem(const MPI_Comm &mpi_comm);
42
43
44 /**
45 * @brief clears all datamembers and reset to original state.
46 *
47 *
48 */
49 void
51
52
53 /**
54 * @brief reinitialize data structures for total electrostatic potential solve.
55 *
56 * For Hartree electrostatic potential solve give an empty map to the atoms
57 * parameter.
58 *
59 */
60 void
62 const std::shared_ptr<
64 FEBasisOperations<double, double, dftfe::utils::MemorySpace::HOST>>
65 & basisOperationsPtr,
67 const dealii::AffineConstraints<double> &constraintMatrix,
68 const unsigned int matrixFreeVectorComponent,
69 const unsigned int matrixFreeQuadratureComponentRhsDensity,
70 const unsigned int matrixFreeQuadratureComponentAX,
71 const std::map<dealii::types::global_dof_index, double> &atoms,
72 const std::map<dealii::CellId, std::vector<double>> &smearedChargeValues,
73 const unsigned int smearedChargeQuadratureId,
75 & rhoValues,
76 const bool isComputeDiagonalA = true,
77 const bool isComputeMeanValueConstraints = false,
78 const bool smearedNuclearCharges = false,
79 const bool isRhoValues = true,
80 const bool isGradSmearedChargeRhs = false,
81 const unsigned int smearedChargeGradientComponentId = 0,
82 const bool storeSmearedChargeRhs = false,
83 const bool reuseSmearedChargeRhs = false,
84 const bool reinitializeFastConstraints = false);
85
86
87 /**
88 * @brief get the reference to x field
89 *
90 * @return reference to x field. Assumes x field data structure is already initialized
91 */
94
95 /**
96 * @brief Compute A matrix multipled by x.
97 *
98 */
99 void
101
102 /**
103 * @brief Compute right hand side vector for the problem Ax = rhs.
104 *
105 * @param rhs vector for the right hand side values
106 */
107 void
109
110 /**
111 * @brief Jacobi preconditioning.
112 *
113 */
114 void
116 const distributedCPUVec<double> &src,
117 const double omega) const;
118
119 /**
120 * @brief distribute x to the constrained nodes.
121 *
122 */
123 void
125
126 /// function needed by dealii to mimic SparseMatrix for Jacobi
127 /// preconditioning
128 void
129 subscribe(std::atomic<bool> *const validity,
130 const std::string & identifier = "") const {};
131
132 /// function needed by dealii to mimic SparseMatrix for Jacobi
133 /// preconditioning
134 void
135 unsubscribe(std::atomic<bool> *const validity,
136 const std::string & identifier = "") const {};
137
138 /// function needed by dealii to mimic SparseMatrix
139 bool
140 operator!=(double val) const
141 {
142 return true;
143 };
144
145 private:
146 /**
147 * @brief required for the cell_loop operation in dealii's MatrixFree class
148 *
149 */
150 void
151 AX(const dealii::MatrixFree<3, double> & matrixFreeData,
153 const distributedCPUVec<double> & src,
154 const std::pair<unsigned int, unsigned int> &cell_range) const;
155
156
157 /**
158 * @brief Compute the diagonal of A.
159 *
160 */
161 void
163
164 /**
165 * @brief Compute mean value constraint which is required in case of fully periodic
166 * boundary conditions.
167 *
168 */
169 void
171
172
173 /**
174 * @brief Mean value constraint distibute
175 *
176 */
177 void
179
180 /**
181 * @brief Mean value constraint distibute slave to master
182 *
183 */
184 void
186 distributedCPUVec<double> &vec) const;
187
188
189 /**
190 * @brief Mean value constraint set zero
191 *
192 */
193 void
195
196
197 /// storage for diagonal of the A matrix
199
200 /// storage for smeared charge rhs in case of total potential solve (doesn't
201 /// change every scf)
203
204 /// pointer to dealii MatrixFree object
205 const dealii::MatrixFree<3, double> *d_matrixFreeDataPtr;
206
207 /// pointer to the x vector being solved for
209
210 /// pointer to dealii dealii::AffineConstraints<double> object
211 const dealii::AffineConstraints<double> *d_constraintMatrixPtr;
212
213 /// matrix free index required to access the DofHandler and
214 /// dealii::AffineConstraints<double> objects corresponding to the problem
216
217 /// matrix free quadrature index
219
220 /// matrix free quadrature index
222
223 /// pointer to electron density cell quadrature data
226 /// pointer to smeared charge cell quadrature data
227 const std::map<dealii::CellId, std::vector<double>>
229
230 ///
232
233 /// pointer to map between global dof index in current processor and the
234 /// atomic charge on that dof
235 const std::map<dealii::types::global_dof_index, double> *d_atomsPtr;
236
237 /// shape function gradient integral storage
239
240 /// storage for mean value constraint vector
242
243 /// boolean flag to query if mean value constraint datastructures are
244 /// precomputed
246
247 ///
249
250 ///
252
253 ///
255
256 ///
258
259 /// mean value constraints: mean value constrained node
260 dealii::types::global_dof_index d_meanValueConstraintNodeId;
261
262 /// mean value constraints: constrained proc id containing the mean value
263 /// constrained node
265
266 /// duplicate constraints object with flattened maps for faster access
269 std::shared_ptr<
270 dftfe::basis::
271 FEBasisOperations<double, double, dftfe::utils::MemorySpace::HOST>>
273 ///
275
276 const MPI_Comm mpi_communicator;
277 const unsigned int n_mpi_processes;
278 const unsigned int this_mpi_process;
279 dealii::ConditionalOStream pcout;
280 };
281
282} // namespace dftfe
283#endif // poissonSolverProblem_H_
Overloads dealii's distribute and distribute_local_to_global functions associated with constraints cl...
Definition constraintMatrixInfo.h:43
unsigned int d_matrixFreeQuadratureComponentAX
matrix free quadrature index
Definition poissonSolverProblem.h:221
const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > * d_rhoValuesPtr
pointer to electron density cell quadrature data
Definition poissonSolverProblem.h:225
distributedCPUVec< double > & getX()
get the reference to x field
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 subscribe(std::atomic< bool > *const validity, const std::string &identifier="") const
Definition poissonSolverProblem.h:129
const dealii::AffineConstraints< double > * d_constraintMatrixPtr
pointer to dealii dealii::AffineConstraints<double> object
Definition poissonSolverProblem.h:211
bool d_isFastConstraintsInitialized
Definition poissonSolverProblem.h:274
void clear()
clears all datamembers and reset to original state.
const MPI_Comm mpi_communicator
Definition poissonSolverProblem.h:276
unsigned int d_matrixFreeVectorComponent
Definition poissonSolverProblem.h:215
void computeMeanValueConstraint()
Compute mean value constraint which is required in case of fully periodic boundary conditions.
void distributeX()
distribute x to the constrained nodes.
void computeDiagonalA()
Compute the diagonal of A.
distributedCPUVec< double > d_diagonalA
storage for diagonal of the A matrix
Definition poissonSolverProblem.h:198
void meanValueConstraintDistributeSlaveToMaster(distributedCPUVec< double > &vec) const
Mean value constraint distibute slave to master.
void meanValueConstraintSetZero(distributedCPUVec< double > &vec) const
Mean value constraint set zero.
unsigned int d_smearedChargeQuadratureId
Definition poissonSolverProblem.h:231
void computeRhs(distributedCPUVec< double > &rhs)
Compute right hand side vector for the problem Ax = rhs.
void meanValueConstraintDistribute(distributedCPUVec< double > &vec) const
Mean value constraint distibute.
bool d_isStoreSmearedChargeRhs
Definition poissonSolverProblem.h:251
unsigned int d_meanValueConstraintProcId
Definition poissonSolverProblem.h:264
dealii::ConditionalOStream pcout
Definition poissonSolverProblem.h:279
std::vector< double > d_cellShapeFunctionGradientIntegralFlattened
shape function gradient integral storage
Definition poissonSolverProblem.h:238
dftUtils::constraintMatrixInfo< dftfe::utils::MemorySpace::HOST > d_constraintsInfo
duplicate constraints object with flattened maps for faster access
Definition poissonSolverProblem.h:268
distributedCPUVec< double > d_rhsSmearedCharge
Definition poissonSolverProblem.h:202
const dealii::MatrixFree< 3, double > * d_matrixFreeDataPtr
pointer to dealii MatrixFree object
Definition poissonSolverProblem.h:205
const unsigned int n_mpi_processes
Definition poissonSolverProblem.h:277
const std::map< dealii::CellId, std::vector< double > > * d_smearedChargeValuesPtr
pointer to smeared charge cell quadrature data
Definition poissonSolverProblem.h:228
std::shared_ptr< dftfe::basis::FEBasisOperations< double, double, dftfe::utils::MemorySpace::HOST > > d_basisOperationsPtr
Definition poissonSolverProblem.h:272
void reinit(const std::shared_ptr< dftfe::basis::FEBasisOperations< double, double, dftfe::utils::MemorySpace::HOST > > &basisOperationsPtr, distributedCPUVec< double > &x, const dealii::AffineConstraints< double > &constraintMatrix, const unsigned int matrixFreeVectorComponent, const unsigned int matrixFreeQuadratureComponentRhsDensity, const unsigned int matrixFreeQuadratureComponentAX, const std::map< dealii::types::global_dof_index, double > &atoms, const std::map< dealii::CellId, std::vector< double > > &smearedChargeValues, const unsigned int smearedChargeQuadratureId, const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > &rhoValues, const bool isComputeDiagonalA=true, const bool isComputeMeanValueConstraints=false, const bool smearedNuclearCharges=false, const bool isRhoValues=true, const bool isGradSmearedChargeRhs=false, const unsigned int smearedChargeGradientComponentId=0, const bool storeSmearedChargeRhs=false, const bool reuseSmearedChargeRhs=false, const bool reinitializeFastConstraints=false)
reinitialize data structures for total electrostatic potential solve.
bool d_isMeanValueConstraintComputed
Definition poissonSolverProblem.h:245
void vmult(distributedCPUVec< double > &Ax, distributedCPUVec< double > &x)
Compute A matrix multipled by x.
bool operator!=(double val) const
function needed by dealii to mimic SparseMatrix
Definition poissonSolverProblem.h:140
dealii::types::global_dof_index d_meanValueConstraintNodeId
mean value constraints: mean value constrained node
Definition poissonSolverProblem.h:260
void unsubscribe(std::atomic< bool > *const validity, const std::string &identifier="") const
Definition poissonSolverProblem.h:135
distributedCPUVec< double > d_meanValueConstraintVec
storage for mean value constraint vector
Definition poissonSolverProblem.h:241
distributedCPUVec< double > * d_xPtr
pointer to the x vector being solved for
Definition poissonSolverProblem.h:208
unsigned int d_matrixFreeQuadratureComponentRhsDensity
matrix free quadrature index
Definition poissonSolverProblem.h:218
unsigned int d_smearedChargeGradientComponentId
Definition poissonSolverProblem.h:257
bool d_isReuseSmearedChargeRhs
Definition poissonSolverProblem.h:254
poissonSolverProblem(const MPI_Comm &mpi_comm)
Constructor.
bool d_isGradSmearedChargeRhs
Definition poissonSolverProblem.h:248
const std::map< dealii::types::global_dof_index, double > * d_atomsPtr
Definition poissonSolverProblem.h:235
const unsigned int this_mpi_process
Definition poissonSolverProblem.h:278
void precondition_Jacobi(distributedCPUVec< double > &dst, const distributedCPUVec< double > &src, const double omega) const
Jacobi preconditioning.
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