19#ifndef poissonSolverProblemWrapper_H_
20#define poissonSolverProblemWrapper_H_
25#ifdef DFTFE_WITH_DEVICE
31#define poissonSolverProblemWrapperTemplates(T1) \
32 std::shared_ptr<poissonSolverProblem<T1>>,
33#define poissonSolverProblemWrapperTemplatesL(T1) \
34 std::shared_ptr<poissonSolverProblem<T1>>
35#include "poissonSolverProblemWrapper.def"
36#undef poissonSolverProblemWrapperTemplates
37#undef poissonSolverProblemWrapperTemplatesL
39 template <
class... Args>
43 switch (feOrderElectro)
45#define poissonSolverProblemWrapperTemplates(T1) \
47 return poissonSolverProblemObject( \
48 std::make_shared<poissonSolverProblem<T1>>( \
49 std::forward<Args>(args)...));
50#define poissonSolverProblemWrapperTemplatesL(T1) \
52 return poissonSolverProblemObject( \
53 std::make_shared<poissonSolverProblem<T1>>( \
54 std::forward<Args>(args)...));
55#include "poissonSolverProblemWrapper.def"
56#undef poissonSolverProblemWrapperTemplates
57#undef poissonSolverProblemWrapperTemplatesL
59 throw std::logic_error{
60 "createPoissonSolverProblemObject dispatch failed"};
70 const MPI_Comm &mpi_comm)
86 std::visit([&](
auto &t) { t->vmult(Ax, x); },
93 std::visit([&](
auto &t) { t->computeRhs(rhs); },
100 const double omega)
const
103 auto const &t) { t->precondition_Jacobi(dst, src, omega); },
110 std::visit([](
auto &t) { t->distributeX(); },
116 const std::string &identifier =
"")
const
121 const std::string &identifier =
"")
const
136 template <
typename... Args>
140 std::visit([&](
auto &t) { t->reinit(std::forward<Args>(args)...); },
148#ifdef DFTFE_WITH_DEVICE
149 using poissonSolverProblemDeviceObject = std::variant<
150# define poissonSolverProblemWrapperTemplates(T1) \
151 std::shared_ptr<poissonSolverProblemDevice<T1>>,
152# define poissonSolverProblemWrapperTemplatesL(T1) \
153 std::shared_ptr<poissonSolverProblemDevice<T1>>
154# include "poissonSolverProblemWrapper.def"
155# undef poissonSolverProblemWrapperTemplates
156# undef poissonSolverProblemWrapperTemplatesL
160 template <
class... Args>
161 inline poissonSolverProblemDeviceObject
162 createPoissonSolverProblemDeviceObject(
dftfe::Int feOrderElectro,
165 switch (feOrderElectro)
167# define poissonSolverProblemWrapperTemplates(T1) \
169 return poissonSolverProblemDeviceObject( \
170 std::make_shared<poissonSolverProblemDevice<T1>>( \
171 std::forward<Args>(args)...));
172# define poissonSolverProblemWrapperTemplatesL(T1) \
174 return poissonSolverProblemDeviceObject( \
175 std::make_shared<poissonSolverProblemDevice<T1>>( \
176 std::forward<Args>(args)...));
177# include "poissonSolverProblemWrapper.def"
178# undef poissonSolverProblemWrapperTemplates
179# undef poissonSolverProblemWrapperTemplatesL
181 throw std::logic_error{
182 "createPoissonSolverProblemDeviceObject dispatch failed"};
187 class poissonSolverProblemDeviceWrapperClass
188 :
public linearSolverProblemDevice
192 poissonSolverProblemDeviceWrapperClass(
const dftfe::Int feOrderElectro,
193 const MPI_Comm &mpi_comm)
194 : d_poissonSolverProblemObject(
195 createPoissonSolverProblemDeviceObject(feOrderElectro, mpi_comm))
198 distributedDeviceVec<double> &
202 [](
auto &t) -> distributedDeviceVec<double> & {
return t->getX(); },
203 d_poissonSolverProblemObject);
206 distributedDeviceVec<double> &
210 [](
auto &t) -> distributedDeviceVec<double> & {
211 return t->getPreconditioner();
213 d_poissonSolverProblemObject);
217 computeAX(distributedDeviceVec<double> &dst,
218 distributedDeviceVec<double> &src)
220 std::visit([&](
auto &t) { t->computeAX(dst, src); },
221 d_poissonSolverProblemObject);
226 computeRhs(distributedCPUVec<double> &rhs)
228 std::visit([&](
auto &t) { t->computeRhs(rhs); },
229 d_poissonSolverProblemObject);
235 std::visit([](
auto &t) { t->setX(); }, d_poissonSolverProblemObject);
241 std::visit([](
auto &t) { t->distributeX(); },
242 d_poissonSolverProblemObject);
246 copyXfromDeviceToHost()
248 std::visit([](
auto &t) { t->copyXfromDeviceToHost(); },
249 d_poissonSolverProblemObject);
255 std::visit([](
auto &t) { t->clear(); }, d_poissonSolverProblemObject);
258 template <
typename... Args>
260 reinit(Args &&...args)
262 std::visit([&](
auto &t) { t->reinit(std::forward<Args>(args)...); },
263 d_poissonSolverProblemObject);
267 poissonSolverProblemDeviceObject d_poissonSolverProblemObject;
dealiiLinearSolverProblem()
Constructor.
void distributeX()
distribute x to the constrained nodes.
Definition poissonSolverProblemWrapper.h:108
void vmult(distributedCPUVec< double > &Ax, distributedCPUVec< double > &x)
Compute A matrix multipled by x.
Definition poissonSolverProblemWrapper.h:84
void computeRhs(distributedCPUVec< double > &rhs)
Compute right hand side vector for the problem Ax = rhs.
Definition poissonSolverProblemWrapper.h:91
poissonSolverProblemWrapperClass(const dftfe::Int feOrderElectro, const MPI_Comm &mpi_comm)
Constructor.
Definition poissonSolverProblemWrapper.h:69
void reinit(Args &&...args)
Definition poissonSolverProblemWrapper.h:138
void clear()
Definition poissonSolverProblemWrapper.h:131
void precondition_Jacobi(distributedCPUVec< double > &dst, const distributedCPUVec< double > &src, const double omega) const
Jacobi preconditioning function.
Definition poissonSolverProblemWrapper.h:98
bool operator!=(double val) const
function needed by dealii to mimic SparseMatrix
Definition poissonSolverProblemWrapper.h:125
poissonSolverProblemObject d_poissonSolverProblemObject
Definition poissonSolverProblemWrapper.h:145
distributedCPUVec< double > & getX()
get the reference to x field
Definition poissonSolverProblemWrapper.h:76
void unsubscribe(std::atomic< bool > *const validity, const std::string &identifier="") const
Definition poissonSolverProblemWrapper.h:120
void subscribe(std::atomic< bool > *const validity, const std::string &identifier="") const
Definition poissonSolverProblemWrapper.h:115
Definition pseudoPotentialToDftfeConverter.cc:34
poissonSolverProblemObject createPoissonSolverProblemObject(dftfe::Int feOrderElectro, Args &&...args)
Definition poissonSolverProblemWrapper.h:57
dealii::LinearAlgebra::distributed::Vector< elem_type, dealii::MemorySpace::Host > distributedCPUVec
Definition headers.h:92
std::int32_t Int
Definition TypeConfig.h:11
std::variant< #define poissonSolverProblemWrapperTemplates(T1) \ #define poissonSolverProblemWrapperTemplatesL(T1) \ # 1 "/github/workspace/include/poissonSolverProblemWrapper.def" 1 poissonSolverProblemWrapperTemplates(2) poissonSolverProblemWrapperTemplates(3) poissonSolverProblemWrapperTemplates(4) poissonSolverProblemWrapperTemplates(5) poissonSolverProblemWrapperTemplates(6) poissonSolverProblemWrapperTemplates(7) poissonSolverProblemWrapperTemplates(8) poissonSolverProblemWrapperTemplates(9) poissonSolverProblemWrapperTemplates(10) poissonSolverProblemWrapperTemplates(11) poissonSolverProblemWrapperTemplates(12) poissonSolverProblemWrapperTemplates(13) poissonSolverProblemWrapperTemplates(14) poissonSolverProblemWrapperTemplates(15) poissonSolverProblemWrapperTemplatesL(16) # 35 "/github/workspace/include/poissonSolverProblemWrapper.h" 2 > poissonSolverProblemObject
Definition poissonSolverProblemWrapper.h:30