DFT-FE 1.1.0-pre
Density Functional Theory With Finite-Elements
Loading...
Searching...
No Matches
MultiVector.t.cc
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 * @author Sambit Das, Bikash Kanungo
20 */
21#include <Exceptions.h>
22#include <cmath>
23
24namespace dftfe
25{
26 namespace linearAlgebra
27 {
28 /**
29 * @brief Constructor for a \b serial MultiVector using size, numVectors and
30 * init value
31 **/
32 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
34 const size_type size,
36 const ValueType initVal /* = utils::Types<ValueType>::zero*/)
37 {
38 d_storage =
39 std::make_unique<typename MultiVector<ValueType, memorySpace>::Storage>(
40 size * numVectors, initVal);
41 d_globalSize = size;
42 d_locallyOwnedSize = size;
43 d_ghostSize = 0;
47 std::make_shared<const utils::mpi::MPIPatternP2P<memorySpace>>(size);
48 d_mpiCommunicatorP2P = std::make_unique<
51 }
52
53 /**
54 * @brief Constructor for a \serial MultiVector with a predefined
55 * MultiVector::Storage (i.e., utils::MemoryStorage).
56 * This constructor transfers the ownership of the input Storage to the
57 * MultiVector. This is useful when one does not want to allocate new
58 * memory and instead use memory allocated in the MultiVector::Storage
59 * (i.e., utils::MemoryStorage).
60 */
61 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
63 std::unique_ptr<typename MultiVector<ValueType, memorySpace>::Storage>
64 storage,
66 {
67 d_storage = std::move(storage);
68 d_globalSize = d_storage.size();
70 d_ghostSize = 0;
74 std::make_shared<const utils::mpi::MPIPatternP2P<memorySpace>>(
76 d_mpiCommunicatorP2P = std::make_unique<
79 }
80
81 //
82 // Constructor for \distributed MultiVector using an existing
83 // MPIPatternP2P object
84 //
85 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
87 std::shared_ptr<const utils::mpi::MPIPatternP2P<memorySpace>>
88 mpiPatternP2P,
90 const ValueType initVal /* = utils::Types<ValueType>::zero*/)
91 : d_mpiPatternP2P(mpiPatternP2P)
92 {
93 d_globalSize = d_mpiPatternP2P->nGlobalIndices();
94 d_locallyOwnedSize = d_mpiPatternP2P->localOwnedSize();
95 d_ghostSize = d_mpiPatternP2P->localGhostSize();
98 d_storage =
99 std::make_unique<typename MultiVector<ValueType, memorySpace>::Storage>(
100 d_localSize * d_numVectors, initVal);
101 d_mpiCommunicatorP2P = std::make_unique<
103 numVectors);
104 }
105
106 /**
107 * @brief Constructor for a \b distributed MultiVector with a predefined
108 * MultiVector::Storage (i.e., utils::MemoryStorage) and MPIPatternP2P.
109 * This constructor transfers the ownership of the input Storage to the
110 * MultiVector. This is useful when one does not want to allocate new
111 * memory and instead use memory allocated in the input MultiVector::Storage
112 * (i.e., utils::MemoryStorage).
113 */
114 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
116 std::unique_ptr<typename MultiVector<ValueType, memorySpace>::Storage>
117 &storage,
118 std::shared_ptr<const utils::mpi::MPIPatternP2P<memorySpace>>
119 mpiPatternP2P,
120 const size_type numVectors)
121 : d_mpiPatternP2P(mpiPatternP2P)
122 {
123 d_storage = std::move(storage);
124 d_globalSize = d_mpiPatternP2P->nGlobalIndices();
125 d_locallyOwnedSize = d_mpiPatternP2P->localOwnedSize();
126 d_ghostSize = d_mpiPatternP2P->localGhostSize();
129 d_mpiCommunicatorP2P = std::make_unique<
131 numVectors);
132 }
133
134 /**
135 * @brief Constructor for a \distributed MultiVector based on locally
136 * owned and ghost indices.
137 * @note This way of construction is expensive. One should use the other
138 * constructor based on an input MPIPatternP2P as far as possible.
139 */
140 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
142 const std::pair<global_size_type, global_size_type> locallyOwnedRange,
143 const std::vector<global_size_type> & ghostIndices,
144 const MPI_Comm & mpiComm,
145 const size_type numVectors,
146 const ValueType initVal /* = utils::Types<ValueType>::zero*/)
147 {
148 //
149 // TODO Move the warning message to a Logger class
150 //
151 int mpiRank;
152 int err = MPI_Comm_rank(mpiComm, &mpiRank);
153 std::string msg;
154 if (mpiRank == 0)
155 {
156 msg =
157 "WARNING: Constructing a distributed MultiVector using locally owned "
158 "range and ghost indices is expensive. As far as possible, one should "
159 " use the constructor based on an input MPIPatternP2P.";
160 std::cout << msg << std::endl;
161 }
162 ////////////
163
164 d_mpiPatternP2P =
165 std::make_shared<const utils::mpi::MPIPatternP2P<memorySpace>>(
166 locallyOwnedRange, ghostIndices, mpiComm);
167
168 d_mpiCommunicatorP2P = std::make_unique<
170 d_mpiPatternP2P, numVectors);
171
172 d_globalSize = d_mpiPatternP2P->nGlobalIndices();
173 d_locallyOwnedSize = d_mpiPatternP2P->localOwnedSize();
174 d_ghostSize = d_mpiPatternP2P->localGhostSize();
175 d_localSize = d_locallyOwnedSize + d_ghostSize;
176 d_numVectors = numVectors;
177 d_storage =
178 std::make_unique<typename MultiVector<ValueType, memorySpace>::Storage>(
179 d_localSize * numVectors, initVal);
180 }
182 /**
183 * @brief Constructor for a special case of \b distributed MultiVector where none
184 * none of the processors have any ghost indices.
185 * @note This way of construction is expensive. One should use the other
186 * constructor based on an input MPIPatternP2P as far as possible.
187 */
188 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
190 const std::pair<global_size_type, global_size_type> locallyOwnedRange,
191 const MPI_Comm & mpiComm,
192 const size_type numVectors,
193 const ValueType initVal /* = utils::Types<ValueType>::zero*/)
194 {
195 //
196 // TODO Move the warning message to a Logger class
197 //
198 int mpiRank;
199 int err = MPI_Comm_rank(mpiComm, &mpiRank);
200 std::string msg;
201 if (mpiRank == 0)
202 {
203 msg =
204 "WARNING: Constructing a distributed MultiVector using only locally owned "
205 "range is expensive. As far as possible, one should "
206 " use the constructor based on an input MPIPatternP2P.";
207 std::cout << msg << std::endl;
208 }
209 ////////////
210 std::vector<dftfe::global_size_type> ghostIndices;
211 ghostIndices.resize(0);
212 d_mpiPatternP2P =
213 std::make_shared<const utils::mpi::MPIPatternP2P<memorySpace>>(
214 locallyOwnedRange, ghostIndices, mpiComm);
215
216 d_mpiCommunicatorP2P = std::make_unique<
218 d_mpiPatternP2P, numVectors);
219
220 d_globalSize = d_mpiPatternP2P->nGlobalIndices();
221 d_locallyOwnedSize = d_mpiPatternP2P->localOwnedSize();
222 d_ghostSize = d_mpiPatternP2P->localGhostSize();
225 d_storage =
226 std::make_unique<typename MultiVector<ValueType, memorySpace>::Storage>(
227 d_localSize * numVectors, initVal);
228 }
229
230
231 /**
232 * @brief Constructor for a \b distributed MultiVector based on total number of global indices.
233 * The resulting MultiVector will not contain any ghost indices on any of
234 * the processors. Internally, the vector is divided to ensure as much
235 * equitable distribution across all the processors much as possible.
236 * @note This way of construction is expensive. One should use the other
237 * constructor based on an input MPIPatternP2P as far as possible.
238 * Further, the decomposition is not compatible with other ways of
239 * distributed MultiVector construction.
240 */
241 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
244 const MPI_Comm & mpiComm,
245 const size_type numVectors,
246 const ValueType initVal /* = utils::Types<ValueType>::zero*/)
247 {
248 std::vector<dftfe::global_size_type> ghostIndices;
249 ghostIndices.resize(0);
250
251 std::pair<global_size_type, global_size_type> locallyOwnedRange;
252
253 //
254 // TODO Move the warning message to a Logger class
255 //
256 int mpiRank;
257 int err = MPI_Comm_rank(mpiComm, &mpiRank);
258 std::string msg;
259 if (mpiRank == 0)
260 {
261 msg =
262 "WARNING: Constructing a MultiVector using total number of indices across all processors "
263 "is expensive. As far as possible, one should "
264 " use the constructor based on an input MPIPatternP2P.";
265 std::cout << msg << std::endl;
266 }
267
268 int mpiProcess;
269 int errProc = MPI_Comm_size(mpiComm, &mpiProcess);
272 if (mpiRank < globalSize % mpiProcess)
274
275 dftfe::global_size_type startIndex = mpiRank * (globalSize / mpiProcess);
276 if (mpiRank < globalSize % mpiProcess)
277 startIndex += mpiRank;
278 else
279 startIndex += globalSize % mpiProcess;
280
281 locallyOwnedRange.first = startIndex;
282 locallyOwnedRange.second = startIndex + locallyOwnedSize;
283
284
285 ////////////
286
288 std::make_shared<const utils::mpi::MPIPatternP2P<memorySpace>>(
289 locallyOwnedRange, ghostIndices, mpiComm);
290
291 d_mpiCommunicatorP2P = std::make_unique<
295 d_globalSize = d_mpiPatternP2P->nGlobalIndices();
296 d_locallyOwnedSize = d_mpiPatternP2P->localOwnedSize();
297 d_ghostSize = d_mpiPatternP2P->localGhostSize();
300 d_storage =
301 std::make_unique<typename MultiVector<ValueType, memorySpace>::Storage>(
302 d_localSize * numVectors, initVal);
303 }
305
306
307 //
308 // Copy Constructor
309 //
310 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
312 {
313 d_storage =
314 std::make_unique<typename MultiVector<ValueType, memorySpace>::Storage>(
315 (u.d_storage)->size());
316 d_mpiCommunicatorP2P = std::make_unique<
319 *d_storage = *(u.d_storage);
327
328 //
329 // Copy Constructor with reinitialization
330 //
331 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
333 const MultiVector &u,
334 const ValueType initVal /* = utils::Types<ValueType>::zero*/)
336 d_storage =
337 std::make_unique<typename MultiVector<ValueType, memorySpace>::Storage>(
338 (u.d_storage)->size(), initVal);
345 d_mpiCommunicatorP2P = std::make_unique<
348 }
349
350 //
351 // Move Constructor
352 //
353 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
355 {
356 d_storage = std::move(u.d_storage);
357 d_localSize = std::move(u.d_localSize);
358 d_locallyOwnedSize = std::move(u.d_locallyOwnedSize);
359 d_ghostSize = std::move(u.d_ghostSize);
360 d_globalSize = std::move(u.d_globalSize);
361 d_numVectors = std::move(u.d_numVectors);
362 d_mpiCommunicatorP2P = std::move(u.d_mpiCommunicatorP2P);
363 d_mpiPatternP2P = std::move(u.d_mpiPatternP2P);
365
366 //
367 // Copy Assignment
368 //
369 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
372 {
374 std::make_unique<typename MultiVector<ValueType, memorySpace>::Storage>(
375 (u.d_storage)->size());
376 *d_storage = *(u.d_storage);
377 d_mpiCommunicatorP2P = std::make_unique<
386 return *this;
387 }
388
389 //
390 // Move Assignment
391 //
392 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
395 {
396 d_storage = std::move(u.d_storage);
397 d_localSize = std::move(u.d_localSize);
398 d_locallyOwnedSize = std::move(u.d_locallyOwnedSize);
399 d_ghostSize = std::move(u.d_ghostSize);
400 d_globalSize = std::move(u.d_globalSize);
401 d_numVectors = std::move(u.d_numVectors);
402 d_mpiCommunicatorP2P = std::move(u.d_mpiCommunicatorP2P);
403 d_mpiPatternP2P = std::move(u.d_mpiPatternP2P);
404 return *this;
405 }
406
408 //
409 // swap
410 //
411 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
412 void
415 d_storage.swap(u.d_storage);
418
419 const size_type tempLocalSizeLeft = d_localSize;
420 const size_type tempLocallyOwnedSizeLeft = d_locallyOwnedSize;
421 const size_type tempGhostSizeLeft = d_ghostSize;
422 const global_size_type tempGlobalSizeLeft = d_globalSize;
423 const size_type tempNumVectorsLeft = d_numVectors;
424
430
431 u.d_localSize = tempLocalSizeLeft;
432 u.d_locallyOwnedSize = tempLocallyOwnedSizeLeft;
433 u.d_ghostSize = tempGhostSizeLeft;
434 u.d_globalSize = tempGlobalSizeLeft;
435 u.d_numVectors = tempNumVectorsLeft;
436 }
437
438 //
439 // reinit for \distributed MultiVector using an existing
440 // MPIPatternP2P object
441 //
442 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
443 void
446 mpiPatternP2P,
447 const size_type numVectors,
448 const ValueType initVal)
449 {
450 d_globalSize = mpiPatternP2P->nGlobalIndices();
451 d_locallyOwnedSize = mpiPatternP2P->localOwnedSize();
452 d_ghostSize = mpiPatternP2P->localGhostSize();
455 d_storage =
456 std::make_unique<typename MultiVector<ValueType, memorySpace>::Storage>(
457 d_localSize * d_numVectors, initVal);
458 d_mpiPatternP2P = mpiPatternP2P;
459 d_mpiCommunicatorP2P = std::make_unique<
461 numVectors);
463
464 //
465 // reinit for \distributed MultiVector using an existing
466 // MultiVector object
467 //
468 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
469 void
473 }
475
476 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
482
483 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
486 {
487 return d_storage->begin();
488 }
490 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
494 return d_storage->end();
496
497 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
501 return d_storage->end();
502 }
503
504 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
505 ValueType *
507 {
508 return d_storage->data();
509 }
510
511 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
512 const ValueType *
514 {
515 return d_storage->data();
516 }
517
518 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
519 void
521 {
522 d_storage->setValue(val);
523 }
524
525 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
526 void
534
535
536 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
537 void
539 const size_type communicationChannel /*= 0*/)
540 {
541 d_mpiCommunicatorP2P->updateGhostValues(*d_storage, communicationChannel);
542 }
543
544 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
545 void
547 const size_type communicationChannel /*= 0*/)
548 {
549 d_mpiCommunicatorP2P->accumulateAddLocallyOwned(*d_storage,
550 communicationChannel);
551 }
552
553 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
554 void
556 const size_type communicationChannel /*= 0*/)
557 {
558 d_mpiCommunicatorP2P->updateGhostValuesBegin(*d_storage,
559 communicationChannel);
560 }
561
562 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
563 void
568
569 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
570 void
572 const size_type communicationChannel /*= 0*/)
573 {
574 d_mpiCommunicatorP2P->accumulateAddLocallyOwnedBegin(
575 *d_storage, communicationChannel);
576 }
577
578 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
579 void
584
585 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
586 bool
589 {
590 if (d_numVectors != rhs.d_numVectors)
591 return false;
592 else if (d_globalSize != rhs.d_globalSize)
593 return false;
594 else if (d_localSize != rhs.d_localSize)
595 return false;
597 return false;
598 else if (d_ghostSize != rhs.d_ghostSize)
599 return false;
600 else
601 return (d_mpiPatternP2P->isCompatible(*(rhs.d_mpiPatternP2P)));
602 }
603
604 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
605 std::shared_ptr<const utils::mpi::MPIPatternP2P<memorySpace>>
610
611 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
617
618 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
624
625 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
631
632 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
638
639 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
645
646 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
647 template <typename ValueBaseType>
648 void
650 {
653 "[] L2-Norm evaluation not implemented for DEVICE");
654 if (d_locallyOwnedSize > 0)
655 std::transform(begin(), begin() + d_numVectors, normVec, [](auto &a) {
657 });
658 else
659 for (int i = 0; i < d_numVectors; i++)
660 normVec[i] = 0.0;
661 for (auto k = 1; k < d_locallyOwnedSize; ++k)
662 {
663 std::transform(begin() + k * d_numVectors,
664 begin() + (k + 1) * d_numVectors,
665 normVec,
666 normVec,
667 [](auto &a, auto &b) {
668 return b + dftfe::utils::realPart(
670 });
671 }
672 MPI_Allreduce(MPI_IN_PLACE,
673 normVec,
675 dataTypes::mpi_type_id(normVec),
676 MPI_SUM,
677 d_mpiPatternP2P->mpiCommunicator());
678 std::transform(normVec, normVec + d_numVectors, normVec, [](auto &a) {
679 return std::sqrt(a);
680 });
681 }
682
683 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
684 template <typename ValueBaseType>
685 void
686 MultiVector<ValueType, memorySpace>::add(const ValueBaseType *valVec,
687 const MultiVector & u)
688 {
691 "[] Add not implemented for DEVICE");
692 for (auto k = 0; k < d_locallyOwnedSize; ++k)
693 for (auto ib = 0; ib < d_numVectors; ++ib)
694 (*d_storage)[k * d_numVectors + ib] +=
695 valVec[ib] * u.data()[k * d_numVectors + ib];
696 }
697
698 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
699 template <typename ValueBaseType>
700 void
702 const MultiVector & u)
703 {
706 "[] Add not implemented for DEVICE");
707 std::transform(begin(),
709 u.begin(),
710 begin(),
711 [&val](auto &a, auto &b) { return (a + val * b); });
712 }
713
714 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
715 template <typename ValueBaseType1, typename ValueBaseType2>
716 void
718 const ValueBaseType1 valScale,
719 const ValueBaseType2 valAdd,
720 const MultiVector & u)
721 {
724 "[] Add not implemented for DEVICE");
725 std::transform(begin(),
727 u.begin(),
728 begin(),
729 [&valScale, &valAdd](auto &a, auto &b) {
730 return valScale * (a + valAdd * b);
731 });
732 }
733
734 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
735 template <typename ValueBaseType1, typename ValueBaseType2>
736 void
738 const ValueBaseType1 valScale,
739 const ValueBaseType2 valAdd,
740 const MultiVector & u)
741 {
744 "[] Add not implemented for DEVICE");
745 std::transform(begin(),
747 u.begin(),
748 begin(),
749 [&valScale, &valAdd](auto &a, auto &b) {
750 return valScale * a + valAdd * b;
751 });
752 }
753
754 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
755 template <typename ValueBaseType>
756 void
758 {
761 "[] Add not implemented for DEVICE");
762 std::transform(begin(),
764 begin(),
765 [&val](auto &a) { return val * a; });
766 }
767
768 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
769 void
771 ValueType * dotVec)
772 {
775 "[] dot product evaluation not implemented for DEVICE");
776 if (d_locallyOwnedSize > 0)
777 for (auto ib = 0; ib < d_numVectors; ++ib)
778 {
779 dotVec[ib] = (*d_storage)[ib] *
781 }
782 else
783 for (auto ib = 0; ib < d_numVectors; ++ib)
784 {
785 dotVec[ib] = 0.0;
786 }
787 for (auto k = 1; k < d_locallyOwnedSize; ++k)
788 {
789 for (auto ib = 0; ib < d_numVectors; ++ib)
790 {
791 dotVec[ib] += (*d_storage)[k * d_numVectors + ib] *
793 (*(u.d_storage))[k * d_numVectors + ib]);
794 }
795 }
796 MPI_Allreduce(MPI_IN_PLACE,
797 dotVec,
800 MPI_SUM,
801 d_mpiPatternP2P->mpiCommunicator());
802 }
803
804 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
805 void
808 {
809 d_mpiCommunicatorP2P->setCommunicationPrecision(commPrecision);
810 }
811
812 template <typename ValueType, dftfe::utils::MemorySpace memorySpace>
815 {
816 return *(d_storage.get());
817 }
818
819 template <typename ValueType, utils::MemorySpace memorySpace>
820 void
822 const std::shared_ptr<const dealii::Utilities::MPI::Partitioner>
823 & partitioner,
824 const size_type numVectors,
826 {
827 const std::pair<global_size_type, global_size_type> &locallyOwnedRange =
828 partitioner->local_range();
829 // std::cout<<locallyOwnedRange.first<<"
830 // "<<locallyOwnedRange.second<<std::endl;
831 std::vector<global_size_type> ghostIndices;
832 (partitioner->ghost_indices()).fill_index_vector(ghostIndices);
833
834 // for (unsigned int i=0;i<ghostIndices.size();++i)
835 // if (ghostIndices.size()>0)
836 // std::cout<<ghostIndices.back()<<std::endl;
837
838 // std::sort(ghostIndices.begin(),ghostIndices.end());
839 std::shared_ptr<dftfe::utils::mpi::MPIPatternP2P<memorySpace>>
840 mpiPatternP2PPtr =
841 std::make_shared<dftfe::utils::mpi::MPIPatternP2P<memorySpace>>(
842 locallyOwnedRange,
843 ghostIndices,
844 partitioner->get_mpi_communicator());
845
846 multiVector.reinit(mpiPatternP2PPtr, numVectors);
847 }
848
849 } // end of namespace linearAlgebra
850} // namespace dftfe
An class template to encapsulate a MultiVector. A MultiVector is a collection of vectors belonging t...
Definition MultiVector.h:127
void setValue(const ValueType val)
Set all entries of the MultiVector to a given value.
Definition MultiVector.t.cc:520
MultiVector & operator=(const MultiVector &u)
Copy assignment operator.
Definition MultiVector.t.cc:371
void updateGhostValuesBegin(const size_type communicationChannel=0)
Definition MultiVector.t.cc:555
std::shared_ptr< const utils::mpi::MPIPatternP2P< memorySpace > > d_mpiPatternP2P
Definition MultiVector.h:512
void setCommunicationPrecision(utils::mpi::communicationPrecision commPrecision)
Definition MultiVector.t.cc:806
bool isCompatible(const MultiVector< ValueType, memorySpace > &rhs) const
Definition MultiVector.t.cc:587
size_type d_numVectors
Definition MultiVector.h:508
std::shared_ptr< const utils::mpi::MPIPatternP2P< memorySpace > > getMPIPatternP2P() const
Definition MultiVector.t.cc:606
void scale(const ValueBaseType val)
Definition MultiVector.t.cc:757
size_type d_ghostSize
Definition MultiVector.h:507
std::unique_ptr< Storage > d_storage
Definition MultiVector.h:503
std::unique_ptr< utils::mpi::MPICommunicatorP2P< ValueType, memorySpace > > d_mpiCommunicatorP2P
Definition MultiVector.h:510
size_type d_locallyOwnedSize
Definition MultiVector.h:506
typename Storage::iterator iterator
Definition MultiVector.h:137
void accumulateAddLocallyOwnedEnd()
Definition MultiVector.t.cc:580
size_type d_localSize
Definition MultiVector.h:504
void reinit(std::shared_ptr< const utils::mpi::MPIPatternP2P< memorySpace > > mpiPatternP2P, const size_type numVectors, const ValueType initVal=0)
reinit for a distributed MultiVector based on an input MPIPatternP2P.
Definition MultiVector.t.cc:444
void addAndScale(const ValueBaseType1 valScale, const ValueBaseType2 valAdd, const MultiVector &u)
Definition MultiVector.t.cc:717
global_size_type globalSize() const
Definition MultiVector.t.cc:613
iterator begin()
Return iterator pointing to the beginning of MultiVector data.
Definition MultiVector.t.cc:478
size_type localSize() const
Definition MultiVector.t.cc:620
void l2Norm(ValueBaseType *normVec) const
Definition MultiVector.t.cc:649
void scaleAndAdd(const ValueBaseType1 valScale, const ValueBaseType2 valAdd, const MultiVector &u)
Definition MultiVector.t.cc:737
MultiVector()=default
Default Constructor.
void zeroOutGhosts()
Definition MultiVector.t.cc:527
size_type ghostSize() const
Definition MultiVector.t.cc:634
void accumulateAddLocallyOwned(const size_type communicationChannel=0)
Definition MultiVector.t.cc:546
void updateGhostValues(const size_type communicationChannel=0)
Definition MultiVector.t.cc:538
void updateGhostValuesEnd()
Definition MultiVector.t.cc:564
typename Storage::const_iterator const_iterator
Definition MultiVector.h:138
ValueType * data()
Return the raw pointer to the MultiVector data.
Definition MultiVector.t.cc:506
void swap(MultiVector &u)
pointer swap
Definition MultiVector.t.cc:413
const Storage & getData() const
Definition MultiVector.t.cc:814
void add(const ValueBaseType *valVec, const MultiVector &u)
Definition MultiVector.t.cc:686
void dot(const MultiVector &u, ValueType *dotVec)
Definition MultiVector.t.cc:770
global_size_type d_globalSize
Definition MultiVector.h:505
void accumulateAddLocallyOwnedBegin(const size_type communicationChannel=0)
Definition MultiVector.t.cc:571
dftfe::utils::MemoryStorage< ValueType, memorySpace > Storage
Definition MultiVector.h:132
iterator end()
Return iterator pointing to the end of MultiVector data.
Definition MultiVector.t.cc:492
size_type numVectors() const
Definition MultiVector.t.cc:641
static void set(std::size_t size, ValueType *ptr, ValueType val)
Definition MemoryStorage.h:33
Definition MPICommunicatorP2P.h:63
A class template to store the communication pattern (i.e., which entries/nodes to receive from which ...
Definition MPIPatternP2P.h:57
MPI_Datatype mpi_type_id(const int *)
Definition dftfeDataTypes.h:51
Definition BLASWrapper.h:33
void createMultiVectorFromDealiiPartitioner(const std::shared_ptr< const dealii::Utilities::MPI::Partitioner > &partitioner, const size_type numVectors, MultiVector< ValueType, memorySpace > &multiVector)
Definition MultiVector.t.cc:821
communicationPrecision
Definition MPICommunicatorP2P.h:55
double complexConj(const double x)
Definition DataTypeOverloads.h:77
void throwException(bool condition, std::string msg="")
@ DEVICE
Definition MemorySpaceType.h:36
double realPart(const double x)
Definition DataTypeOverloads.h:28
Definition pseudoPotentialToDftfeConverter.cc:34
unsigned int size_type
Definition TypeConfig.h:6
unsigned long int global_size_type
Definition TypeConfig.h:7