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