DFT-EFE
 
Loading...
Searching...
No Matches
MultiVector.h
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (c) 2021. *
3 * The Regents of the University of Michigan and DFT-EFE developers. *
4 * *
5 * This file is part of the DFT-EFE code. *
6 * *
7 * DFT-EFE is free software: you can redistribute it and/or modify *
8 * it under the terms of the Lesser GNU General Public License as *
9 * published by the Free Software Foundation, either version 3 of *
10 * the License, or (at your option) any later version. *
11 * *
12 * DFT-EFE is distributed in the hope that it will be useful, but *
13 * WITHOUT ANY WARRANTY; without even the implied warranty *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
15 * See the Lesser GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU Lesser General Public *
18 * License at the top level of DFT-EFE distribution. If not, see *
19 * <https://www.gnu.org/licenses/>. *
20 ******************************************************************************/
21
22/*
23 * @author Sambit Das, Bikash Kanungo
24 */
25
26
27#ifndef dftefeMultiVector_h
28#define dftefeMultiVector_h
29
30#include <utils/TypeConfig.h>
31#include <utils/Defaults.h>
32#include <utils/MemoryStorage.h>
33#include <utils/MPITypes.h>
34#include <utils/MPIPatternP2P.h>
39#include <memory>
40namespace dftefe
41{
42 namespace linearAlgebra
43 {
132 template <typename ValueType, dftefe::utils::MemorySpace memorySpace>
134 {
135 public:
136 //
137 // typedefs
138 //
141 using pointer = typename Storage::pointer;
144 using iterator = typename Storage::iterator;
146
147 public:
151 MultiVector() = default;
152
156 ~MultiVector() = default;
157
166 MultiVector(const size_type size,
167 const size_type numVectors,
168 std::shared_ptr<LinAlgOpContext<memorySpace>> linAlgOpContext,
169 const ValueType initVal = utils::Types<ValueType>::zero);
170
192 std::unique_ptr<typename MultiVector<ValueType, memorySpace>::Storage>
193 storage,
195 std::shared_ptr<LinAlgOpContext<memorySpace>> linAlgOpContext);
196
208 mpiPatternP2P,
209 std::shared_ptr<LinAlgOpContext<memorySpace>> linAlgOpContext,
210 const size_type numVectors,
211 const ValueType initVal = utils::Types<ValueType>::zero);
212
223 mpiPatternP2P,
224 std::shared_ptr<LinAlgOpContext<memorySpace>> linAlgOpContext,
225 const size_type numVectors,
226 const ValueType min,
227 const ValueType max);
228
251 std::unique_ptr<typename MultiVector<ValueType, memorySpace>::Storage>
252 &storage,
253 std::shared_ptr<const utils::mpi::MPIPatternP2P<memorySpace>>
254 mpiPatternP2P,
255 std::shared_ptr<LinAlgOpContext<memorySpace>> linAlgOpContext,
256 const size_type numVectors);
257
279 const std::pair<global_size_type, global_size_type> locallyOwnedRange,
280 const std::vector<global_size_type> & ghostIndices,
281 const utils::mpi::MPIComm & mpiComm,
282 std::shared_ptr<LinAlgOpContext<memorySpace>> linAlgOpContext,
283 const size_type numVectors,
284 ValueType initVal = utils::Types<ValueType>::zero);
285
305 const std::pair<global_size_type, global_size_type> locallyOwnedRange,
306 const utils::mpi::MPIComm & mpiComm,
307 std::shared_ptr<LinAlgOpContext<memorySpace>> linAlgOpContext,
308 const size_type numVectors,
309 const ValueType initVal = utils::Types<ValueType>::zero);
310
311
331 const utils::mpi::MPIComm & mpiComm,
332 std::shared_ptr<LinAlgOpContext<memorySpace>> linAlgOpContext,
333 const size_type numVectors,
334 const ValueType initVal = utils::Types<ValueType>::zero);
335
340 MultiVector(const MultiVector &u);
341
347 MultiVector(const MultiVector &u,
348 const ValueType initVal = utils::Types<ValueType>::zero);
349
354 MultiVector(MultiVector &&u) noexcept;
355
363 operator=(const MultiVector &u);
364
373
380 begin();
381
390 begin() const;
391
398 end();
399
407 end() const;
408
413 ValueType *
414 data();
415
420 const ValueType *
421 data() const;
422
423
429 void
430 setValue(const ValueType val);
431
436 std::vector<double>
437 l2Norms() const;
438
443 std::vector<double>
444 lInfNorms() const;
445
451 getNumberComponents() const;
452
453 void
454 updateGhostValues(const size_type communicationChannel = 0);
455
456 void
457 accumulateAddLocallyOwned(const size_type communicationChannel = 0);
458
459 void
460 updateGhostValuesBegin(const size_type communicationChannel = 0);
461
462 void
464
465 void
466 accumulateAddLocallyOwnedBegin(const size_type communicationChannel = 0);
467
468 void
470
471 bool
473
474 std::shared_ptr<const utils::mpi::MPIPatternP2P<memorySpace>>
475 getMPIPatternP2P() const;
476
477 std::shared_ptr<LinAlgOpContext<memorySpace>>
478 getLinAlgOpContext() const;
479
481 globalSize() const;
482
484 localSize() const;
485
487 locallyOwnedSize() const;
488
490 ghostSize() const;
491
493 numVectors() const;
494
495 protected:
496 std::unique_ptr<Storage> d_storage;
497 std::shared_ptr<LinAlgOpContext<memorySpace>> d_linAlgOpContext;
504 std::unique_ptr<utils::mpi::MPICommunicatorP2P<ValueType, memorySpace>>
506 std::shared_ptr<const utils::mpi::MPIPatternP2P<memorySpace>>
508 };
509
510 //
511 // helper functions
512 //
513
517 template <typename ValueType, dftefe::utils::MemorySpace memorySpace>
518 void
521
540 template <typename ValueType1,
541 typename ValueType2,
542 utils::MemorySpace memorySpace>
543 void
549 memorySpace> & w);
550
551
570 template <typename ValueType1,
571 typename ValueType2,
572 utils::MemorySpace memorySpace>
573 void
579 memorySpace> & w);
580
581
582
616 template <typename ValueType1,
617 typename ValueType2,
618 utils::MemorySpace memorySpace>
619 void
625
652 template <typename ValueType1,
653 typename ValueType2,
654 utils::MemorySpace memorySpace>
655 void
661
662
663 } // end of namespace linearAlgebra
664} // end of namespace dftefe
666#endif // dftefeMultiVector_h
Definition: LinAlgOpContext.h:38
An class template to encapsulate a MultiVector. A MultiVector is a collection of vectors belonging t...
Definition: MultiVector.h:134
void updateGhostValues(const size_type communicationChannel=0)
Definition: MultiVector.t.cpp:611
std::shared_ptr< const utils::mpi::MPIPatternP2P< memorySpace > > getMPIPatternP2P() const
Definition: MultiVector.t.cpp:682
void updateGhostValuesBegin(const size_type communicationChannel=0)
Definition: MultiVector.t.cpp:628
std::shared_ptr< LinAlgOpContext< memorySpace > > d_linAlgOpContext
Definition: MultiVector.h:497
typename Storage::const_reference const_reference
Definition: MultiVector.h:143
MultiVector & operator=(const MultiVector &u)
Copy assignment operator.
Definition: MultiVector.t.cpp:462
size_type d_ghostSize
Definition: MultiVector.h:502
global_size_type d_globalSize
Definition: MultiVector.h:500
size_type d_numVectors
Definition: MultiVector.h:503
size_type localSize() const
Definition: MultiVector.t.cpp:703
iterator end()
Return iterator pointing to the end of MultiVector data.
Definition: MultiVector.t.cpp:518
std::unique_ptr< utils::mpi::MPICommunicatorP2P< ValueType, memorySpace > > d_mpiCommunicatorP2P
Definition: MultiVector.h:505
size_type d_localSize
Definition: MultiVector.h:499
size_type locallyOwnedSize() const
Definition: MultiVector.t.cpp:710
typename Storage::const_iterator const_iterator
Definition: MultiVector.h:145
bool isCompatible(const MultiVector< ValueType, memorySpace > &rhs) const
Definition: MultiVector.t.cpp:660
size_type d_locallyOwnedSize
Definition: MultiVector.h:501
void accumulateAddLocallyOwned(const size_type communicationChannel=0)
Definition: MultiVector.t.cpp:619
size_type ghostSize() const
Definition: MultiVector.t.cpp:717
std::vector< double > l2Norms() const
Returns norms of all the vectors in the MultiVector.
Definition: MultiVector.t.cpp:553
typename Storage::reference reference
Definition: MultiVector.h:142
global_size_type globalSize() const
Definition: MultiVector.t.cpp:696
~MultiVector()=default
Default Destructor.
typename Storage::pointer pointer
Definition: MultiVector.h:141
size_type getNumberComponents() const
Returns the nunber of vectors in this multi-vector.
Definition: MultiVector.t.cpp:604
std::shared_ptr< const utils::mpi::MPIPatternP2P< memorySpace > > d_mpiPatternP2P
Definition: MultiVector.h:507
size_type numVectors() const
Definition: MultiVector.t.cpp:724
iterator begin()
Return iterator pointing to the beginning of MultiVector data.
Definition: MultiVector.t.cpp:504
typename Storage::iterator iterator
Definition: MultiVector.h:144
std::vector< double > lInfNorms() const
Returns norms of all the vectors in the MultiVector.
Definition: MultiVector.t.cpp:582
void updateGhostValuesEnd()
Definition: MultiVector.t.cpp:637
std::unique_ptr< Storage > d_storage
Definition: MultiVector.h:496
VectorAttributes d_vectorAttributes
Definition: MultiVector.h:498
ValueType * data()
Return the raw pointer to the MultiVector data.
Definition: MultiVector.t.cpp:532
typename Storage::value_type value_type
Definition: MultiVector.h:140
std::shared_ptr< LinAlgOpContext< memorySpace > > getLinAlgOpContext() const
Definition: MultiVector.t.cpp:689
void accumulateAddLocallyOwnedBegin(const size_type communicationChannel=0)
Definition: MultiVector.t.cpp:644
void accumulateAddLocallyOwnedEnd()
Definition: MultiVector.t.cpp:653
MultiVector()=default
Default Constructor.
void setValue(const ValueType val)
Set all entries of the MultiVector to a given value.
Definition: MultiVector.t.cpp:546
Definition: VectorAttributes.h:36
Definition: MemoryStorage.h:38
const ValueType & const_reference
Definition: MemoryStorage.h:58
const ValueType * const_iterator
Definition: MemoryStorage.h:60
ValueType * iterator
Definition: MemoryStorage.h:59
ValueType * pointer
Definition: MemoryStorage.h:56
ValueType & reference
Definition: MemoryStorage.h:57
ValueType value_type
A class template to provide an interface that can act similar to STL vectors but with different Memor...
Definition: MemoryStorage.h:55
Definition: Defaults.h:37
A class template to store the communication pattern (i.e., which entries/nodes to receive from which ...
Definition: MPIPatternP2P.h:197
blas::scalar_type< ValueType1, ValueType2 > scalar_type
Definition: BlasLapackTypedef.h:70
ScalarOp
Definition: BlasLapackTypedef.h:56
void dot(const MultiVector< ValueType1, memorySpace > &u, const MultiVector< ValueType2, memorySpace > &v, blasLapack::scalar_type< ValueType1, ValueType2 > *dotProds, const blasLapack::ScalarOp &opU, const blasLapack::ScalarOp &opV)
Definition: MultiVector.t.cpp:803
void add(blasLapack::scalar_type< ValueType1, ValueType2 > a, const MultiVector< ValueType1, memorySpace > &u, blasLapack::scalar_type< ValueType1, ValueType2 > b, const MultiVector< ValueType2, memorySpace > &v, MultiVector< blasLapack::scalar_type< ValueType1, ValueType2 >, memorySpace > &w)
Perform .
Definition: MultiVector.t.cpp:747
void swap(MultiVector< ValueType, memorySpace > &X, MultiVector< ValueType, memorySpace > &Y)
Swaps the data of u with this multivector.
Definition: MultiVector.t.cpp:735
int MPIComm
Definition: MPITypes.h:83
MemorySpace
Definition: MemorySpaceType.h:37
dealii includes
Definition: AtomFieldDataSpherical.cpp:31
unsigned int size_type
Definition: TypeConfig.h:8
unsigned long int global_size_type
Definition: TypeConfig.h:9