DFT-FE 1.1.0-pre
Density Functional Theory With Finite-Elements
Loading...
Searching...
No Matches
AtomicCenteredNonLocalOperator.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// @author Kartick Ramakrishnan, Vishal Subramanian, Sambit Das
18//
19
20#ifndef DFTFE_ATOMICCENTEREDNONLOCALOPERATOR_H
21#define DFTFE_ATOMICCENTEREDNONLOCALOPERATOR_H
22#include <MultiVector.h>
23#include <headers.h>
26#include <BLASWrapper.h>
27#include <memory>
28#include <MemorySpaceType.h>
29#include "FEBasisOperations.h"
30#include <headers.h>
31#include <dftUtils.h>
32#include <pseudoUtils.h>
33#include <vectorUtilities.h>
34#include <MPIPatternP2P.h>
35#include <MultiVector.h>
36#include <DeviceTypeConfig.h>
37#include <cmath>
39
40namespace dftfe
41{
42 /**
43 * @brief Enum class that lists
44 * used in the non-local Operator
45 *
46 */
53
54
55
56 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
58 {
59 public:
62 BLASWrapperPtr,
63 std::shared_ptr<
65 basisOperatorPtr,
66 std::shared_ptr<AtomCenteredSphericalFunctionContainer>
67 atomCenteredSphericalFunctionContainer,
68 const MPI_Comm &mpi_comm_parent,
69 const bool memOptMode = false,
70 const bool computeSphericalFnTimesX = true,
71 const bool useGlobalCMatrix = false);
72
73 /**
74 * @brief Resizes various internal data members and selects the kpoint of interest.
75 * @param[in] kPointIndex specifies the k-point of interest
76 */
77 void
78 initialiseOperatorActionOnX(unsigned int kPointIndex);
79 /**
80 * @brief initialises the multivector object, waveFunctionBlockSize and resizes various internal data members.
81 * @param[in] waveFunctionBlockSize sets the wavefunction block size for the
82 * action of the nonlocal operator.
83 * @param[out] sphericalFunctionKetTimesVectorParFlattened, the multivector
84 * that is initialised based on blocksize and partitioner.
85 */
86 void
88 unsigned int waveFunctionBlockSize,
90 &sphericalFunctionKetTimesVectorParFlattened);
91 /**
92 * @brief calls internal function: initialisePartitioner, initialiseKpoint and computeCMatrixEntries
93 * @param[in] updateSparsity flag on whether the sparstiy patten was
94 * updated, hence the partitioner is updated.
95 * @param[in] kPointWeights std::vector<double> of size number of kPoints
96 * @param[out] kPointCoordinates std::vector<double> of kPoint coordinates
97 * @param[in] basisOperationsPtr HOST FEBasisOperations shared_ptr required
98 * to indetify the element ids and quad points
99 * @param[in] quadratureIndex quadrature index for sampling the spherical
100 * function. Quadrature Index is used to reinit basisOperationsPtr
101 */
102 void
104 const bool updateSparsity,
105 const std::vector<double> &kPointWeights,
106 const std::vector<double> &kPointCoordinates,
107 std::shared_ptr<
109 double,
111 basisOperationsPtr,
112 std::shared_ptr<
114 BLASWrapperHostPtr,
115 const unsigned int quadratureIndex);
116 /**
117 * @brief calls internal function: initialisePartitioner, initialiseKpoint and computeCMatrixEntries
118 * @param[in] updateSparsity flag on whether the sparstiy patten was
119 * updated, hence the partitioner is updated.
120 * @param[in] kPointWeights std::vector<double> of size number of kPoints
121 * @param[out] kPointCoordinates std::vector<double> of kPoint coordinates
122 * @param[in] basisOperationsPtr HOST FEBasisOperations shared_ptr required
123 * to indetify the element ids and quad points
124 * @param[in] BLASWrapperHostPtr CPU blasWrapperPtr, used for xcopy calls
125 * @param[in] quadratureIndex quadrature index for sampling the spherical
126 * function. Quadrature Index is used to reinit basisOperationsPtr
127 * @param[in] nonLocalOperatorSrc The source nonLocalOpertor from where the
128 * CMatrix and partitioner is copied. Generally, it is of higher precision.
129 */
130 template <typename ValueTypeSrc>
131 void
133 const bool updateSparsity,
134 const std::vector<double> &kPointWeights,
135 const std::vector<double> &kPointCoordinates,
136 std::shared_ptr<
138 double,
140 basisOperationsPtr,
141 std::shared_ptr<
143 BLASWrapperHostPtr,
144 const unsigned int quadratureIndex,
145 const std::shared_ptr<
147 nonLocalOperatorSrc);
148#if defined(DFTFE_WITH_DEVICE)
149 // for device specific initialise
150 /**
151 * @brief
152 * @param[in] totalAtomsInCurrentProcessor number of atoms in current
153 * processor based on compact support
154 * @param[out] totalNonLocalElements number of nonLocal elements in current
155 * processor
156 * @param[out] numberCellsForEachAtom number of cells associated which each
157 * atom in the current processor. vecot of size totalAtomsInCurrentProcessor
158 * @param[out] numberCellsAccumNonLocalAtoms number of cells accumulated
159 * till iatom in current processor. vector of size
160 * totalAtomsInCurrentProcessor
161 */
162 void
163 initialiseCellWaveFunctionPointers(
165 &cellWaveFunctionMatrix);
166
167 void
168 freeDeviceVectors();
169#endif
170
171 // Getter functions
172 // Returns the vector that takes in nonlocalElementIndex and returns the
173 // cellID
174 const std::vector<unsigned int> &
176 // Returns the number of atoms in current processor
177 unsigned int
179
182
183 unsigned int
185
186 unsigned int
188
189 unsigned int
191
192 bool
193 atomSupportInElement(unsigned int iElem) const;
194
195 unsigned int
196 getGlobalDofAtomIdSphericalFnPair(const unsigned int atomId,
197 const unsigned int alpha) const;
198
199 unsigned int
200 getLocalIdOfDistributedVec(const unsigned int globalId) const;
201
202 std::vector<unsigned int> &
204
205 std::vector<unsigned int> &
207
208 std::vector<unsigned int> &
210
211 const std::vector<ValueType> &
213
214 const std::vector<ValueType> &
216
217 const std::map<unsigned int, std::vector<unsigned int>> &
219
220 const std::vector<unsigned int> &
222
223 const std::vector<unsigned int> &
225
226 const unsigned int
228
229
230 const std::vector<unsigned int> &
232
233 /**
234 * @brief Required in configurational forces. Cummulative sphercial Fn Id. The size is numCells in processor
235 */
236 const std::map<unsigned int, std::vector<unsigned int>> &
238
239 /**
240 * @brief Returns the Flattened vector of sphericalFunctionIDs in order of atomIDs of atoms in processor.
241 */
242 const std::vector<unsigned int> &
244
245 const std::vector<unsigned int> &
247 /**
248 * @brief Computes C^{T}D^{-1}C at the global level for atomId. This is required in PAW
249 */
250 void
252 const unsigned int atomId,
253 std::shared_ptr<
255 BLASWrapperPtr,
257 &Dinverse,
259 PconjtransposePmatrix);
260 // Calls for both device and host
261 /**
262 * @brief compute the action of coupling matrix on sphericalFunctionKetTimesVectorParFlattened.
263 * @param[in] couplingtype structure of coupling matrix
264 * @param[in] couplingMatrix entires of the coupling matrix V in
265 * CVCconjtrans. Ensure that the coupling matrix is padded. Refer to
266 * ONCVclass for template
267 * @param[out] sphericalFunctionKetTimesVectorParFlattened multivector to
268 * store results of CconjtransX which is initiliased using
269 * initialiseFlattenedVector call. The results are stored in
270 * sphericalFunctionKetTimesVectorParFlattened or internal data member based
271 * on flagCopyResultsToMatrix.
272 * @param[in] flagCopyResultsToMatrix flag to confirm whether to scal the
273 * multivector sphericalFunctionKetTimesVectorParFlattened or store results
274 * in internal data member.
275 */
276 void
278 const CouplingStructure couplingtype,
281 & sphericalFunctionKetTimesVectorParFlattened,
282 const bool flagCopyResultsToMatrix = true,
283 const unsigned int kPointIndex = 0);
284
285 /**
286 * @brief After AllReduce function is called this will copy to the nonLocalOperatorClassDatastructure.
287 */
288 void
291 &sphericalFunctionKetTimesVectorParFlattened,
293 /**
294 * @brief copies the results from internal member to sphericalFunctionKetTimesVectorParFlattened, on which ghost values are called.
295 * crucial operation for completion of the full CconjtranX on all cells
296 * @param[in] sphericalFunctionKetTimesVectorParFlattened multivector to
297 * store results of CconjtransX which is initiliased using
298 * initialiseFlattenedVector call
299 * @param[in] skip1 flag for compute-communication overlap in ChFSI on GPUs
300 * @param[in] skip2 flag for compute-communication overlap in ChFSI on GPUs
301 */
302 void
305 & sphericalFunctionKetTimesVectorParFlattened,
306 const bool skipComm = false);
307
308 /**
309 * @brief computes the results of CconjtransX on the cells of interst specied by cellRange
310 * @param[in] X input cell level vector
311 * @param[in] cellRange start and end element id in list of nonlocal
312 * elements
313 */
314 void
315 applyCconjtransOnX(const ValueType * X,
316 const std::pair<unsigned int, unsigned int> cellRange);
317
318
319 /**
320 * @brief computes the results of CconjtransX on nodal X vector
321 * @param[in] X input X nodal vector
322 * elements
323 */
324 void
327
328
329 // Returns the pointer of CTX stored in HOST memory for the atom Index in
330 // the list of atoms with support in the processor.
331 /**
332 * @brief Returns the pointer of CTX stored in HOST memory
333 * @param[in] iAtom atomIndex in the list of atoms with support in the
334 * current processor. NOTE!! One must be careful here
335 */
336 const ValueType *
337 getCconjtansXLocalDataStructure(const unsigned int iAtom) const;
338
339 /**
340 * @brief completes the VCconjX on nodal vector src. The src vector must have all ghost nodes and constraint nodes updated.
341 * @param[in] src input nodal vector on which operator acts on.
342 * @param[in] kPointIndex kPoint of interest for current operation
343 * @param[in] couplingtype structure of coupling matrix
344 * @param[in] couplingMatrix entries of the coupling matrix V in
345 * CVCconjtrans. Ensure the coupling matrix is padded
346 * @param[out] sphericalFunctionKetTimesVectorParFlattened multivector to
347 * store results of CconjtransX which is initiliased using
348 * initialiseFlattenedVector call
349 */
350 void
353 const unsigned int kPointIndex,
354 const CouplingStructure couplingtype,
357 & sphericalFunctionKetTimesVectorParFlattened,
358 const bool flagScaleInternalMatrix = false);
359
360
361 /**
362 * @brief completes the action of CVCconjtranspose on nodal vector src. The src vector must have all ghost nodes and contraint nodes updated.
363 * @param[in] src input nodal vector on which operator acts on.
364 * @param[in] kPointIndex kPoint of interst for current operation
365 * @param[in] couplingtype structure of coupling matrix
366 * @param[in] couplingMatrix entires of the coupling matrix V in
367 * CVCconjtrans
368 * @param[in] sphericalFunctionKetTimesVectorParFlattened multivector to
369 * store results of CconjtransX which is initiliased using
370 * initialiseFlattenedVector call
371 * @param[out] dst output nodal vector where the results of the operator is
372 * copied into.
373 */
374 void
377 const unsigned int kPointIndex,
378 const CouplingStructure couplingtype,
381 &sphericalFunctionKetTimesVectorParFlattened,
383
384 /**
385 * @brief adds the result of CVCtX onto Xout for both CPU and GPU calls
386 * @param[out] Xout memoryStorage object of size
387 * cells*numberOfNodex*BlockSize. Typical case holds the results of H_{loc}X
388 * @param[in] cellRange start and end element id in list of nonlocal
389 * elements
390 */
391 void
392 applyCOnVCconjtransX(ValueType * Xout,
393 const std::pair<unsigned int, unsigned int> cellRange);
394
395
396 /**
397 * @brief adds the result of CVCtX onto Xout for both CPU and GPU calls
398 * @param[out] Xout memoryStorage object of size
399 * cells*numberOfNodex*BlockSize. Typical case holds the results of H_{loc}X
400 * @param[in] cellRange start and end element id in list of nonlocal
401 * elements
402 */
403 void
406
407 std::vector<ValueType>
408 getCmatrixEntries(int kPointIndex, unsigned int atomId, int iElem) const;
409
410 bool
412 const std::pair<unsigned int, unsigned int> cellRange) const;
413 /**
414 * @brief Called only for GPU runs where the coupling matrix has to be padded
415 * @param[in] entries COupling matrix entries without padding in the atomId
416 * order
417 * @param[out] entriesPadded Padding of coupling matrix entries
418 * @param[in] couplingtype Determines the dimension of entriesPadded and the
419 * padding mechanism elements
420 */
421 void
422 paddingCouplingMatrix(const std::vector<ValueType> &entries,
423 std::vector<ValueType> & entriesPadded,
424 const CouplingStructure couplingtype);
425
426 /**
427 * @brief Returns C matrix entries for chargeId and it compact support element Id.
428 */
429 const std::vector<ValueType> &
430 getCmatrixEntriesConjugate(const unsigned int chargeId,
431 const unsigned int iElemComp) const;
432 /**
433 * @brief Returns C conj matrix entries for chargeId and it compact support element Id.
434 */
435 const std::vector<ValueType> &
436 getCmatrixEntriesTranspose(const unsigned int chargeId,
437 const unsigned int iElemComp) const;
438 /**
439 * @brief Returns global C matrix of all atoms.
440 */
441 const std::vector<
442 std::vector<dftfe::utils::MemoryStorage<ValueType, memorySpace>>> &
444
445
446 protected:
447 /**
448 * @brief completes the VCconjX on nodal vector src. The src vector must have all ghost nodes and constraint nodes updated.
449 * @param[in] src input nodal vector on which operator acts on.
450 * @param[in] kPointIndex kPoint of interest for current operation
451 * @param[in] couplingtype structure of coupling matrix
452 * @param[in] couplingMatrix entries of the coupling matrix V in
453 * CVCconjtrans. Ensure the coupling matrix is padded
454 * @param[out] sphericalFunctionKetTimesVectorParFlattened multivector to
455 * store results of CconjtransX which is initiliased using
456 * initialiseFlattenedVector call
457 */
458 void
461 const unsigned int kPointIndex,
462 const CouplingStructure couplingtype,
465 & sphericalFunctionKetTimesVectorParFlattened,
466 const bool flagScaleInternalMatrix = false);
467
468 /**
469 * @brief completes the VCconjX on nodal vector src using global C matrix.
470 * The global C matrix mush have been computed before.
471 * The src vector must have all ghost nodes and constraint nodes updated.
472 * @param[in] src input nodal vector on which operator acts on.
473 * @param[in] kPointIndex kPoint of interest for current operation
474 * @param[in] couplingtype structure of coupling matrix
475 * @param[in] couplingMatrix entries of the coupling matrix V in
476 * CVCconjtrans. Ensure the coupling matrix is padded
477 * @param[out] sphericalFunctionKetTimesVectorParFlattened multivector to
478 * store results of CconjtransX which is initiliased using
479 * initialiseFlattenedVector call
480 */
481 void
484 const unsigned int kPointIndex,
485 const CouplingStructure couplingtype,
488 & sphericalFunctionKetTimesVectorParFlattened,
489 const bool flagScaleInternalMatrix = false);
490
492 std::vector<double> d_kPointWeights;
493 std::vector<double> d_kPointCoordinates;
494 std::shared_ptr<dftfe::linearAlgebra::BLASWrapper<memorySpace>>
496 std::shared_ptr<AtomCenteredSphericalFunctionContainer>
498 std::shared_ptr<
501 std::vector<unsigned int> d_numberCellsForEachAtom;
502
503 std::shared_ptr<
506
507
508 // Required by force.cc
510 // Required for stress compute
511 std::vector<ValueType>
513
514 /// map from cell number to set of non local atom ids (local numbering)
515 std::map<unsigned int, std::vector<unsigned int>>
517
518 /// vector of size num physical cells
519 std::vector<unsigned int> d_nonTrivialSphericalFnPerCell;
520
521 /// vector of size num physical cell with starting index for each cell for
522 /// the above array
523 std::vector<unsigned int> d_nonTrivialSphericalFnsCellStartIndex;
524
526
527 /// map from local nonlocal atomid to vector over cells
528 std::map<unsigned int, std::vector<unsigned int>>
530
532
534
535 // The above set of variables are needed in force class
536
537#ifdef USE_COMPLEX
538 std::vector<distributedCPUVec<std::complex<double>>>
540
541#else
542 std::vector<distributedCPUVec<double>> d_SphericalFunctionKetTimesVectorPar;
543#endif
544
545 std::map<std::pair<unsigned int, unsigned int>, unsigned int>
547
548 std::vector<unsigned int> d_OwnedAtomIdsInCurrentProcessor;
551 std::map<std::pair<unsigned int, unsigned int>, unsigned int>
553 std::vector<std::vector<
554 std::vector<dftfe::utils::MemoryStorage<ValueType, memorySpace>>>>
556 dealii::ConditionalOStream pcout;
557 const MPI_Comm d_mpi_communicator;
558 const unsigned int d_this_mpi_process;
559 const unsigned int d_n_mpi_processes;
562
563 unsigned int d_totalAtomsInCurrentProc; // number of atoms of interst with
564 // compact in current processor
565 unsigned int
566 d_totalNonlocalElems; // number of nonlocal FE celss having nonlocal
567 // contribution in current processor
568 unsigned int d_totalNonLocalEntries; // Total number of nonlocal components
569 unsigned int
570 d_maxSingleAtomContribution; // maximum number of nonlocal indexes across
571 // all atoms of interset
572 std::vector<unsigned int> d_numberCellsAccumNonLocalAtoms;
575 unsigned int d_numberNodesPerElement; // Access from BasisOperator WHile
576 // filling CMatrixEntries
579 unsigned int d_kPointIndex;
581 bool d_isMallocCalled = false;
582 // Host CMatrix Entries are stored here
583 std::vector<std::vector<std::vector<ValueType>>> d_CMatrixEntriesConjugate,
585
586
587
588 private:
589 /**
590 * @brief stores the d_kpointWeights, d_kpointCoordinates. Other data members regarding are computed from container data object
591 * @param[in] kPointWeights std::vector<double> of size number of kPoints
592 * @param[out] kPointCoordinates std::vector<double> of kPoint coordinates
593 */
594 void
595 initKpoints(const std::vector<double> &kPointWeights,
596 const std::vector<double> &kPointCoordinates);
597 /**
598 * @brief creates the partitioner for the distributed vector based on sparsity patten from sphericalFn container.
599 * @param[in] basisOperationsPtr HOST FEBasisOperations shared_ptr required
600 * to indetify the element ids and quad points.
601 */
602 void
604 /**
605 * @brief computes the entries in C matrix for CPUs and GPUs. On GPUs the entries are copied to a flattened vector on device memory.
606 * Further on GPUs, various maps are created crucial for accessing and
607 * padding entries in Cmatrix flattened device.
608 * @param[in] basisOperationsPtr HOST FEBasisOperations shared_ptr required
609 * to indetify the element ids and quad points
610 * @param[in] quadratureIndex quadrature index for sampling the spherical
611 * function. Quadrature Index is used to reinit basisOperationsPtr
612 */
613 void
615 std::shared_ptr<dftfe::basis::FEBasisOperations<
617 double,
618 dftfe::utils::MemorySpace::HOST>> basisOperationsPtr,
619 const unsigned int quadratureIndex);
620
621 template <typename ValueTypeSrc>
622 void
624 const std::shared_ptr<
626 nonLocalOperatorSrc,
627 std::shared_ptr<
629 double,
631 basisOperationsPtr,
632 const unsigned int quadratureIndex);
633
634 template <typename ValueTypeSrc>
635 void
637 const std::shared_ptr<
639 nonLocalOperatorSrc,
640 std::shared_ptr<
642 double,
644 basisOperationsPtr,
645 const unsigned int quadratureIndex);
646
647
648 std::map<
649 unsigned int,
652 std::vector<dftfe::global_size_type>
656 std::vector<unsigned int> d_nonlocalElemIdToCellIdVector;
659 std::vector<unsigned int> d_atomStartIndexGlobal;
661
662 std::vector<
663 std::vector<dftfe::utils::MemoryStorage<ValueType, memorySpace>>>
665
666 std::set<unsigned int> d_setOfAtomicNumber;
667 std::vector<unsigned int> d_mapAtomIdToSpeciesIndex,
669 std::vector<dftfe::utils::MemoryStorage<ValueType, memorySpace>>
671 std::vector<unsigned int> d_mapIAtomicNumToDotProd;
672 std::vector<unsigned int> d_mapiAtomToDotProd;
673
675
676 std::vector<unsigned int> d_mapiAtomTosphFuncWaveStart;
677 std::map<unsigned int, std::vector<unsigned int>> d_listOfiAtomInSpecies;
678
679 /**
680 * @brief computes Global Cmatrix on HOST.
681 * @param[in] basisOperationsPtr HOST FEBasisOperations shared_ptr required
682 * to indetify the element ids and quad points
683 * @param[in] BLASWrapperHostPtr HOST BLASWrapper
684 */
685 void
687 std::shared_ptr<dftfe::basis::FEBasisOperations<
689 double,
690 dftfe::utils::MemorySpace::HOST>> basisOperationsPtr,
691 std::shared_ptr<
693 BLASWrapperHostPtr);
694
695#if defined(DFTFE_WITH_DEVICE)
696 /**
697 * @brief Copies the data from distributed Vector to Padded Memory storage object.
698 * @param[in] sphericalFunctionKetTimesVectorParFlattened Distributed Vector
699 * @param[out] paddedVector Padded Vector of size
700 * noAtomsInProc*maxSingleAtomContribution*Nwfc
701 */
702 void
703 copyDistributedVectorToPaddedMemoryStorageVectorDevice(
705 &sphericalFunctionKetTimesVectorParFlattened,
707
708 /**
709 * @brief Copies Padded Memory storage object to Distributed vector.
710 * @param[in] paddedVector Padded Vector of size
711 * noAtomsInProc*maxSingleAtomContribution*Nwfc
712 * @param[out] sphericalFunctionKetTimesVectorParFlattened Distributed
713 * Vector
714 *
715 */
716 void
717 copyPaddedMemoryStorageVectorToDistributeVectorDevice(
720 &sphericalFunctionKetTimesVectorParFlattened);
721
722
724 d_tempConjtansX;
726 d_sphericalFnTimesWavefunctionMatrix;
727 ValueType **hostPointerCDagger, **hostPointerCDaggeOutTemp,
728 **hostWfcPointers;
729 ValueType * d_wfcStartPointer;
730 ValueType **devicePointerCDagger, **devicePointerCDaggerOutTemp,
731 **deviceWfcPointers;
732 std::vector<unsigned int> d_nonlocalElemIdToLocalElemIdMap;
733
734 // The below memory storage objects receives the copy of the distributed
735 // ketTimesWfc data in a padded form. THe padding is done by
736 // copyDistributedVectorToPaddedMemoryStorageVector
738 d_sphericalFnTimesVectorDevice;
739 // Data structures moved from KSOperatorDevice
740 std::vector<ValueType> d_cellHamiltonianMatrixNonLocalFlattenedConjugate;
742 d_cellHamiltonianMatrixNonLocalFlattenedConjugateDevice;
743 std::vector<ValueType> d_cellHamiltonianMatrixNonLocalFlattenedTranspose;
745 d_cellHamiltonianMatrixNonLocalFlattenedTransposeDevice;
747 d_cellHamMatrixTimesWaveMatrixNonLocalDevice;
749 d_sphericalFnTimesVectorAllCellsDevice;
750 std::vector<ValueType> d_sphericalFnTimesVectorAllCellsReduction;
752 d_sphericalFnTimesVectorAllCellsReductionDevice;
753
755 d_couplingMatrixTimesVectorDevice;
756
757 std::vector<unsigned int> d_sphericalFnIdsParallelNumberingMap;
758 std::vector<int> d_sphericalFnIdsPaddedParallelNumberingMap;
760 d_sphericalFnIdsParallelNumberingMapDevice;
762 d_sphericalFnIdsPaddedParallelNumberingMapDevice;
763 std::vector<int> d_indexMapFromPaddedNonLocalVecToParallelNonLocalVec;
765 d_indexMapFromPaddedNonLocalVecToParallelNonLocalVecDevice;
766 std::vector<unsigned int> d_cellNodeIdMapNonLocalToLocal;
767
769 d_cellNodeIdMapNonLocalToLocalDevice;
770#endif
771 };
772
773
774
775} // namespace dftfe
776#endif // DFTFE_ATOMICCENTEREDNONLOCALOPERATOR_H
std::vector< unsigned int > d_mapAtomIdToSpeciesIndex
Definition AtomicCenteredNonLocalOperator.h:667
const std::map< unsigned int, std::vector< unsigned int > > & getAtomIdToNonTrivialSphericalFnCellStartIndex() const
Required in configurational forces. Cummulative sphercial Fn Id. The size is numCells in processor.
void initKpoints(const std::vector< double > &kPointWeights, const std::vector< double > &kPointCoordinates)
stores the d_kpointWeights, d_kpointCoordinates. Other data members regarding are computed from conta...
std::vector< ValueType > d_atomCenteredKpointIndexedSphericalFnQuadValues
Definition AtomicCenteredNonLocalOperator.h:509
std::vector< unsigned int > d_mapiAtomTosphFuncWaveStart
Definition AtomicCenteredNonLocalOperator.h:676
dftfe::utils::MemoryStorage< unsigned int, memorySpace > d_iElemNonLocalToElemIndexMap
Definition AtomicCenteredNonLocalOperator.h:574
AtomicCenteredNonLocalOperator(std::shared_ptr< dftfe::linearAlgebra::BLASWrapper< memorySpace > > BLASWrapperPtr, std::shared_ptr< dftfe::basis::FEBasisOperations< dataTypes::number, double, memorySpace > > basisOperatorPtr, std::shared_ptr< AtomCenteredSphericalFunctionContainer > atomCenteredSphericalFunctionContainer, const MPI_Comm &mpi_comm_parent, const bool memOptMode=false, const bool computeSphericalFnTimesX=true, const bool useGlobalCMatrix=false)
unsigned int getGlobalDofAtomIdSphericalFnPair(const unsigned int atomId, const unsigned int alpha) const
void applyCconjtransOnX(const ValueType *X, const std::pair< unsigned int, unsigned int > cellRange)
computes the results of CconjtransX on the cells of interst specied by cellRange
void computeCMatrixEntries(std::shared_ptr< dftfe::basis::FEBasisOperations< dataTypes::number, double, dftfe::utils::MemorySpace::HOST > > basisOperationsPtr, const unsigned int quadratureIndex)
computes the entries in C matrix for CPUs and GPUs. On GPUs the entries are copied to a flattened vec...
unsigned int d_sumNonTrivialSphericalFnOverAllCells
Definition AtomicCenteredNonLocalOperator.h:531
std::map< unsigned int, dftfe::utils::MemoryStorage< ValueType, dftfe::utils::MemorySpace::HOST > > d_sphericalFnTimesWavefunMatrix
Definition AtomicCenteredNonLocalOperator.h:651
dealii::IndexSet d_locallyOwnedAtomCenteredFnIdsCurrentProcess
Definition AtomicCenteredNonLocalOperator.h:549
unsigned int d_totalNonlocalElems
Definition AtomicCenteredNonLocalOperator.h:566
std::vector< dftfe::utils::MemoryStorage< ValueType, memorySpace > > d_dotProductAtomicWaveInputWaveTemp
Definition AtomicCenteredNonLocalOperator.h:670
bool d_useGlobalCMatrix
Definition AtomicCenteredNonLocalOperator.h:658
void applyVCconjtransOnXCellLevel(const dftfe::linearAlgebra::MultiVector< ValueType, memorySpace > &src, const unsigned int kPointIndex, const CouplingStructure couplingtype, const dftfe::utils::MemoryStorage< ValueType, memorySpace > &couplingMatrix, dftfe::linearAlgebra::MultiVector< ValueType, memorySpace > &sphericalFunctionKetTimesVectorParFlattened, const bool flagScaleInternalMatrix=false)
completes the VCconjX on nodal vector src. The src vector must have all ghost nodes and constraint no...
std::vector< double > d_kPointWeights
Definition AtomicCenteredNonLocalOperator.h:492
bool d_AllReduceCompleted
Definition AtomicCenteredNonLocalOperator.h:491
unsigned int d_totalAtomsInCurrentProc
Definition AtomicCenteredNonLocalOperator.h:563
const std::vector< ValueType > & getAtomCenteredKpointTimesSphericalFnTimesDistFromAtomQuadValues() const
const dftfe::utils::MemoryStorage< dftfe::global_size_type, memorySpace > & getFlattenedNonLocalCellDofIndexToProcessDofIndexMap() const
std::vector< unsigned int > & getAtomWiseNumberCellsInCompactSupport() const
void applyCVCconjtransOnX(const dftfe::linearAlgebra::MultiVector< ValueType, memorySpace > &src, const unsigned int kPointIndex, const CouplingStructure couplingtype, const dftfe::utils::MemoryStorage< ValueType, memorySpace > &couplingMatrix, dftfe::linearAlgebra::MultiVector< ValueType, memorySpace > &sphericalFunctionKetTimesVectorParFlattened, dftfe::linearAlgebra::MultiVector< ValueType, memorySpace > &dst)
completes the action of CVCconjtranspose on nodal vector src. The src vector must have all ghost node...
std::map< std::pair< unsigned int, unsigned int >, unsigned int > d_sphericalFunctionIdsNumberingMapCurrentProcess
Definition AtomicCenteredNonLocalOperator.h:546
const MPI_Comm d_mpi_communicator
Definition AtomicCenteredNonLocalOperator.h:557
void applyVOnCconjtransX(const CouplingStructure couplingtype, const dftfe::utils::MemoryStorage< ValueType, memorySpace > &couplingMatrix, dftfe::linearAlgebra::MultiVector< ValueType, memorySpace > &sphericalFunctionKetTimesVectorParFlattened, const bool flagCopyResultsToMatrix=true, const unsigned int kPointIndex=0)
compute the action of coupling matrix on sphericalFunctionKetTimesVectorParFlattened.
const std::vector< unsigned int > & getNonTrivialSphericalFnsCellStartIndex() const
std::vector< unsigned int > d_nonTrivialSphericalFnsCellStartIndex
Definition AtomicCenteredNonLocalOperator.h:523
std::vector< unsigned int > d_mapiAtomToDotProd
Definition AtomicCenteredNonLocalOperator.h:672
const unsigned int d_n_mpi_processes
Definition AtomicCenteredNonLocalOperator.h:559
dftfe::utils::MemoryStorage< dftfe::global_size_type, memorySpace > d_flattenedNonLocalCellDofIndexToProcessDofIndexMap
Definition AtomicCenteredNonLocalOperator.h:655
const ValueType * getCconjtansXLocalDataStructure(const unsigned int iAtom) const
Returns the pointer of CTX stored in HOST memory.
void copyPartitionerKPointsAndComputeCMatrixEntries(const bool updateSparsity, const std::vector< double > &kPointWeights, const std::vector< double > &kPointCoordinates, std::shared_ptr< dftfe::basis::FEBasisOperations< dataTypes::number, double, dftfe::utils::MemorySpace::HOST > > basisOperationsPtr, std::shared_ptr< dftfe::linearAlgebra::BLASWrapper< dftfe::utils::MemorySpace::HOST > > BLASWrapperHostPtr, const unsigned int quadratureIndex, const std::shared_ptr< AtomicCenteredNonLocalOperator< ValueTypeSrc, memorySpace > > nonLocalOperatorSrc)
calls internal function: initialisePartitioner, initialiseKpoint and computeCMatrixEntries
unsigned int getTotalNonLocalElementsInCurrentProcessor() const
void applyCOnVCconjtransX(ValueType *Xout, const std::pair< unsigned int, unsigned int > cellRange)
adds the result of CVCtX onto Xout for both CPU and GPU calls
unsigned int getTotalNonLocalEntriesCurrentProcessor() const
void paddingCouplingMatrix(const std::vector< ValueType > &entries, std::vector< ValueType > &entriesPadded, const CouplingStructure couplingtype)
Called only for GPU runs where the coupling matrix has to be padded.
unsigned int d_kPointIndex
Definition AtomicCenteredNonLocalOperator.h:579
dealii::IndexSet d_ghostSphericalFunctionIdsCurrentProcess
Definition AtomicCenteredNonLocalOperator.h:561
std::vector< std::vector< std::vector< ValueType > > > d_CMatrixEntriesConjugate
Definition AtomicCenteredNonLocalOperator.h:583
std::vector< unsigned int > d_OwnedAtomIdsInCurrentProcessor
Definition AtomicCenteredNonLocalOperator.h:548
const unsigned int getTotalNonTrivialSphericalFnsOverAllCells() const
unsigned int d_totalLocallyOwnedNodes
Definition AtomicCenteredNonLocalOperator.h:674
unsigned int d_numberWaveFunctions
Definition AtomicCenteredNonLocalOperator.h:578
std::shared_ptr< dftfe::basis::FEBasisOperations< dataTypes::number, double, memorySpace > > d_basisOperatorPtr
Definition AtomicCenteredNonLocalOperator.h:505
std::vector< std::vector< std::vector< ValueType > > > d_CMatrixEntriesTranspose
Definition AtomicCenteredNonLocalOperator.h:584
unsigned int getLocalIdOfDistributedVec(const unsigned int globalId) const
std::vector< unsigned int > & getAtomWiseNumberCellsAccumulated() const
unsigned int getMaxSingleAtomEntries() const
std::vector< distributedCPUVec< double > > d_SphericalFunctionKetTimesVectorPar
Definition AtomicCenteredNonLocalOperator.h:542
std::map< std::pair< unsigned int, unsigned int >, unsigned int > d_AtomCenteredFnIdsNumberingMapCurrentProcess
Definition AtomicCenteredNonLocalOperator.h:552
const std::vector< unsigned int > & getSphericalFnTimesVectorFlattenedVectorLocalIds() const
Returns the Flattened vector of sphericalFunctionIDs in order of atomIDs of atoms in processor.
bool d_computeSphericalFnTimesX
Definition AtomicCenteredNonLocalOperator.h:657
bool atomPresentInCellRange(const std::pair< unsigned int, unsigned int > cellRange) const
void initialiseOperatorActionOnX(unsigned int kPointIndex)
Resizes various internal data members and selects the kpoint of interest.
const unsigned int d_this_mpi_process
Definition AtomicCenteredNonLocalOperator.h:558
const std::vector< unsigned int > & getNonTrivialSphericalFnsPerCell() const
const std::map< unsigned int, std::vector< unsigned int > > & getCellIdToAtomIdsLocalCompactSupportMap() const
std::vector< std::vector< dftfe::utils::MemoryStorage< ValueType, memorySpace > > > d_CMatrixGlobal
Definition AtomicCenteredNonLocalOperator.h:664
const std::vector< ValueType > & getAtomCenteredKpointIndexedSphericalFnQuadValues() const
unsigned int getTotalAtomInCurrentProcessor() const
void copyGlobalCMatrix(const std::shared_ptr< AtomicCenteredNonLocalOperator< ValueTypeSrc, memorySpace > > nonLocalOperatorSrc, std::shared_ptr< dftfe::basis::FEBasisOperations< dataTypes::number, double, dftfe::utils::MemorySpace::HOST > > basisOperationsPtr, const unsigned int quadratureIndex)
void computeCconjtransCMatrix(const unsigned int atomId, std::shared_ptr< dftfe::linearAlgebra::BLASWrapper< dftfe::utils::MemorySpace::HOST > > BLASWrapperPtr, const dftfe::utils::MemoryStorage< double, dftfe::utils::MemorySpace::HOST > &Dinverse, dftfe::utils::MemoryStorage< ValueType, dftfe::utils::MemorySpace::HOST > PconjtransposePmatrix)
Computes C^{T}D^{-1}C at the global level for atomId. This is required in PAW.
const std::vector< ValueType > & getCmatrixEntriesConjugate(const unsigned int chargeId, const unsigned int iElemComp) const
Returns C matrix entries for chargeId and it compact support element Id.
void applyAllReduceOnCconjtransX(dftfe::linearAlgebra::MultiVector< ValueType, memorySpace > &sphericalFunctionKetTimesVectorParFlattened, const bool skipComm=false)
copies the results from internal member to sphericalFunctionKetTimesVectorParFlattened,...
void applyCOnVCconjtransX(dftfe::linearAlgebra::MultiVector< ValueType, memorySpace > &Xout)
adds the result of CVCtX onto Xout for both CPU and GPU calls
std::map< unsigned int, std::vector< unsigned int > > d_atomIdToNonTrivialSphericalFnCellStartIndex
map from local nonlocal atomid to vector over cells
Definition AtomicCenteredNonLocalOperator.h:529
std::vector< unsigned int > d_nonTrivialSphericalFnPerCell
vector of size num physical cells
Definition AtomicCenteredNonLocalOperator.h:519
std::shared_ptr< dftfe::linearAlgebra::BLASWrapper< memorySpace > > d_BLASWrapperPtr
Definition AtomicCenteredNonLocalOperator.h:495
void copyBackFromDistributedVectorToLocalDataStructure(dftfe::linearAlgebra::MultiVector< ValueType, memorySpace > &sphericalFunctionKetTimesVectorParFlattened, const dftfe::utils::MemoryStorage< double, memorySpace > &scalingVector)
After AllReduce function is called this will copy to the nonLocalOperatorClassDatastructure.
std::shared_ptr< AtomCenteredSphericalFunctionContainer > d_atomCenteredSphericalFunctionContainer
Definition AtomicCenteredNonLocalOperator.h:497
void initialisePartitioner()
creates the partitioner for the distributed vector based on sparsity patten from sphericalFn containe...
std::vector< ValueType > getCmatrixEntries(int kPointIndex, unsigned int atomId, int iElem) const
std::vector< unsigned int > d_nonlocalElemIdToCellIdVector
Definition AtomicCenteredNonLocalOperator.h:656
std::map< unsigned int, std::vector< unsigned int > > d_listOfiAtomInSpecies
Definition AtomicCenteredNonLocalOperator.h:677
const std::vector< unsigned int > & getNonlocalElementToCellIdVector() const
bool atomSupportInElement(unsigned int iElem) const
std::map< unsigned int, std::vector< unsigned int > > d_cellIdToAtomIdsLocalCompactSupportMap
map from cell number to set of non local atom ids (local numbering)
Definition AtomicCenteredNonLocalOperator.h:516
std::vector< std::vector< std::vector< dftfe::utils::MemoryStorage< ValueType, memorySpace > > > > d_CMatrixEntries
Definition AtomicCenteredNonLocalOperator.h:555
void applyCconjtransOnX(const dftfe::linearAlgebra::MultiVector< ValueType, memorySpace > &X)
computes the results of CconjtransX on nodal X vector
const std::vector< unsigned int > & getNonTrivialAllCellsSphericalFnAlphaToElemIdMap() const
std::vector< unsigned int > d_numberCellsForEachAtom
Definition AtomicCenteredNonLocalOperator.h:501
bool d_isMallocCalled
Definition AtomicCenteredNonLocalOperator.h:581
std::vector< unsigned int > d_atomStartIndexGlobal
Definition AtomicCenteredNonLocalOperator.h:659
const std::vector< unsigned int > & getOwnedAtomIdsInCurrentProcessor() const
std::shared_ptr< const utils::mpi::MPIPatternP2P< dftfe::utils::MemorySpace::HOST > > d_mpiPatternP2P
Definition AtomicCenteredNonLocalOperator.h:500
std::vector< unsigned int > d_sphericalFnTimesVectorFlattenedVectorLocalIds
Definition AtomicCenteredNonLocalOperator.h:533
dealii::ConditionalOStream pcout
Definition AtomicCenteredNonLocalOperator.h:556
unsigned int d_maxSingleAtomContribution
Definition AtomicCenteredNonLocalOperator.h:570
std::vector< unsigned int > & getNonLocalElemIdToLocalElemIdMap() const
std::vector< unsigned int > d_mapIAtomicNumToDotProd
Definition AtomicCenteredNonLocalOperator.h:671
unsigned int d_locallyOwnedCells
Definition AtomicCenteredNonLocalOperator.h:577
void applyVCconjtransOnXUsingGlobalC(const dftfe::linearAlgebra::MultiVector< ValueType, memorySpace > &src, const unsigned int kPointIndex, const CouplingStructure couplingtype, const dftfe::utils::MemoryStorage< ValueType, memorySpace > &couplingMatrix, dftfe::linearAlgebra::MultiVector< ValueType, memorySpace > &sphericalFunctionKetTimesVectorParFlattened, const bool flagScaleInternalMatrix=false)
completes the VCconjX on nodal vector src using global C matrix. The global C matrix mush have been c...
std::vector< unsigned int > d_numberCellsAccumNonLocalAtoms
Definition AtomicCenteredNonLocalOperator.h:572
unsigned int d_totalNonLocalEntries
Definition AtomicCenteredNonLocalOperator.h:568
void intitialisePartitionerKPointsAndComputeCMatrixEntries(const bool updateSparsity, const std::vector< double > &kPointWeights, const std::vector< double > &kPointCoordinates, std::shared_ptr< dftfe::basis::FEBasisOperations< dataTypes::number, double, dftfe::utils::MemorySpace::HOST > > basisOperationsPtr, std::shared_ptr< dftfe::linearAlgebra::BLASWrapper< dftfe::utils::MemorySpace::HOST > > BLASWrapperHostPtr, const unsigned int quadratureIndex)
calls internal function: initialisePartitioner, initialiseKpoint and computeCMatrixEntries
unsigned int d_totalNumSphericalFunctionsGlobal
Definition AtomicCenteredNonLocalOperator.h:660
std::vector< dftfe::global_size_type > d_flattenedNonLocalCellDofIndexToProcessDofIndexVector
Definition AtomicCenteredNonLocalOperator.h:653
void copyCMatrixEntries(const std::shared_ptr< AtomicCenteredNonLocalOperator< ValueTypeSrc, memorySpace > > nonLocalOperatorSrc, std::shared_ptr< dftfe::basis::FEBasisOperations< dataTypes::number, double, dftfe::utils::MemorySpace::HOST > > basisOperationsPtr, const unsigned int quadratureIndex)
std::vector< unsigned int > d_mapiAtomToSpeciesIndex
Definition AtomicCenteredNonLocalOperator.h:668
std::vector< double > d_kPointCoordinates
Definition AtomicCenteredNonLocalOperator.h:493
const std::vector< ValueType > & getCmatrixEntriesTranspose(const unsigned int chargeId, const unsigned int iElemComp) const
Returns C conj matrix entries for chargeId and it compact support element Id.
unsigned int d_numberNodesPerElement
Definition AtomicCenteredNonLocalOperator.h:575
bool d_memoryOptMode
Definition AtomicCenteredNonLocalOperator.h:580
const std::vector< std::vector< dftfe::utils::MemoryStorage< ValueType, memorySpace > > > & getGlobalCMatrix() const
Returns global C matrix of all atoms.
void computeGlobalCMatrixVector(std::shared_ptr< dftfe::basis::FEBasisOperations< dataTypes::number, double, dftfe::utils::MemorySpace::HOST > > basisOperationsPtr, std::shared_ptr< dftfe::linearAlgebra::BLASWrapper< dftfe::utils::MemorySpace::HOST > > BLASWrapperHostPtr)
computes Global Cmatrix on HOST.
dealii::IndexSet d_locallyOwnedSphericalFunctionIdsCurrentProcess
Definition AtomicCenteredNonLocalOperator.h:560
std::set< unsigned int > d_setOfAtomicNumber
Definition AtomicCenteredNonLocalOperator.h:666
void applyVCconjtransOnX(const dftfe::linearAlgebra::MultiVector< ValueType, memorySpace > &src, const unsigned int kPointIndex, const CouplingStructure couplingtype, const dftfe::utils::MemoryStorage< ValueType, memorySpace > &couplingMatrix, dftfe::linearAlgebra::MultiVector< ValueType, memorySpace > &sphericalFunctionKetTimesVectorParFlattened, const bool flagScaleInternalMatrix=false)
completes the VCconjX on nodal vector src. The src vector must have all ghost nodes and constraint no...
std::vector< ValueType > d_atomCenteredKpointTimesSphericalFnTimesDistFromAtomQuadValues
Definition AtomicCenteredNonLocalOperator.h:512
void initialiseFlattenedDataStructure(unsigned int waveFunctionBlockSize, dftfe::linearAlgebra::MultiVector< ValueType, memorySpace > &sphericalFunctionKetTimesVectorParFlattened)
initialises the multivector object, waveFunctionBlockSize and resizes various internal data members.
dealii::IndexSet d_ghostAtomCenteredFnIdsCurrentProcess
Definition AtomicCenteredNonLocalOperator.h:550
std::vector< unsigned int > d_nonTrivialAllCellsSphericalFnAlphaToElemIdMap
Definition AtomicCenteredNonLocalOperator.h:525
Definition FEBasisOperations.h:84
Definition BLASWrapper.h:35
An class template to encapsulate a MultiVector. A MultiVector is a collection of vectors belonging t...
Definition MultiVector.h:127
Definition MemoryStorage.h:33
A class template to store the communication pattern (i.e., which entries/nodes to receive from which ...
Definition MPIPatternP2P.h:57
double number
Definition dftfeDataTypes.h:44
@ HOST
Definition MemorySpaceType.h:34
Definition pseudoPotentialToDftfeConverter.cc:34
CouplingStructure
Enum class that lists used in the non-local Operator.
Definition AtomicCenteredNonLocalOperator.h:48
@ dense
Definition AtomicCenteredNonLocalOperator.h:50
@ blockDiagonal
Definition AtomicCenteredNonLocalOperator.h:51
@ diagonal
Definition AtomicCenteredNonLocalOperator.h:49