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 virtual ~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, const ValueType initVal);
348
353 MultiVector(MultiVector &&u) noexcept;
354
362 operator=(const MultiVector &u);
363
372
379 begin();
380
389 begin() const;
390
397 end();
398
406 end() const;
407
412 ValueType *
413 data();
414
419 const ValueType *
420 data() const;
421
422
428 void
429 setValue(const ValueType val);
430
435 std::vector<double>
436 l2Norms() const;
437
442 std::vector<double>
443 lInfNorms() const;
444
450 getNumberComponents() const;
451
452 void
453 updateGhostValues(const size_type communicationChannel = 0);
454
455 void
456 accumulateAddLocallyOwned(const size_type communicationChannel = 0);
457
458 void
459 updateGhostValuesBegin(const size_type communicationChannel = 0);
460
461 void
463
464 void
465 accumulateAddLocallyOwnedBegin(const size_type communicationChannel = 0);
466
467 void
469
470 bool
472
473 std::shared_ptr<const utils::mpi::MPIPatternP2P<memorySpace>>
474 getMPIPatternP2P() const;
475
476 std::shared_ptr<LinAlgOpContext<memorySpace>>
477 getLinAlgOpContext() const;
478
480 globalSize() const;
481
483 localSize() const;
484
486 locallyOwnedSize() const;
487
489 ghostSize() const;
490
492 numVectors() const;
493
494 protected:
495 std::unique_ptr<Storage> d_storage;
496 std::shared_ptr<LinAlgOpContext<memorySpace>> d_linAlgOpContext;
503 std::unique_ptr<utils::mpi::MPICommunicatorP2P<ValueType, memorySpace>>
505 std::shared_ptr<const utils::mpi::MPIPatternP2P<memorySpace>>
507 };
508
509 //
510 // helper functions
511 //
512
516 template <typename ValueType, dftefe::utils::MemorySpace memorySpace>
517 void
520
539 template <typename ValueType1,
540 typename ValueType2,
541 utils::MemorySpace memorySpace>
542 void
548 memorySpace> & w);
549
550
569 template <typename ValueType1,
570 typename ValueType2,
571 utils::MemorySpace memorySpace>
572 void
578 memorySpace> & w);
579
580
581
615 template <typename ValueType1,
616 typename ValueType2,
617 utils::MemorySpace memorySpace>
618 void
624
651 template <typename ValueType1,
652 typename ValueType2,
653 utils::MemorySpace memorySpace>
654 void
660
661
662 } // end of namespace linearAlgebra
663} // end of namespace dftefe
665#endif // dftefeMultiVector_h
Definition: LinAlgOpContext.h:52
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:633
std::shared_ptr< const utils::mpi::MPIPatternP2P< memorySpace > > getMPIPatternP2P() const
Definition: MultiVector.t.cpp:704
void updateGhostValuesBegin(const size_type communicationChannel=0)
Definition: MultiVector.t.cpp:650
std::shared_ptr< LinAlgOpContext< memorySpace > > d_linAlgOpContext
Definition: MultiVector.h:496
typename Storage::const_reference const_reference
Definition: MultiVector.h:143
MultiVector & operator=(const MultiVector &u)
Copy assignment operator.
Definition: MultiVector.t.cpp:482
size_type d_ghostSize
Definition: MultiVector.h:501
global_size_type d_globalSize
Definition: MultiVector.h:499
size_type d_numVectors
Definition: MultiVector.h:502
size_type localSize() const
Definition: MultiVector.t.cpp:725
iterator end()
Return iterator pointing to the end of MultiVector data.
Definition: MultiVector.t.cpp:540
std::unique_ptr< utils::mpi::MPICommunicatorP2P< ValueType, memorySpace > > d_mpiCommunicatorP2P
Definition: MultiVector.h:504
size_type d_localSize
Definition: MultiVector.h:498
virtual ~MultiVector()=default
Default Destructor.
size_type locallyOwnedSize() const
Definition: MultiVector.t.cpp:732
typename Storage::const_iterator const_iterator
Definition: MultiVector.h:145
bool isCompatible(const MultiVector< ValueType, memorySpace > &rhs) const
Definition: MultiVector.t.cpp:682
size_type d_locallyOwnedSize
Definition: MultiVector.h:500
void accumulateAddLocallyOwned(const size_type communicationChannel=0)
Definition: MultiVector.t.cpp:641
size_type ghostSize() const
Definition: MultiVector.t.cpp:739
std::vector< double > l2Norms() const
Returns norms of all the vectors in the MultiVector.
Definition: MultiVector.t.cpp:575
typename Storage::reference reference
Definition: MultiVector.h:142
global_size_type globalSize() const
Definition: MultiVector.t.cpp:718
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:626
std::shared_ptr< const utils::mpi::MPIPatternP2P< memorySpace > > d_mpiPatternP2P
Definition: MultiVector.h:506
size_type numVectors() const
Definition: MultiVector.t.cpp:746
iterator begin()
Return iterator pointing to the beginning of MultiVector data.
Definition: MultiVector.t.cpp:526
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:604
void updateGhostValuesEnd()
Definition: MultiVector.t.cpp:659
std::unique_ptr< Storage > d_storage
Definition: MultiVector.h:495
VectorAttributes d_vectorAttributes
Definition: MultiVector.h:497
ValueType * data()
Return the raw pointer to the MultiVector data.
Definition: MultiVector.t.cpp:554
typename Storage::value_type value_type
Definition: MultiVector.h:140
std::shared_ptr< LinAlgOpContext< memorySpace > > getLinAlgOpContext() const
Definition: MultiVector.t.cpp:711
void accumulateAddLocallyOwnedBegin(const size_type communicationChannel=0)
Definition: MultiVector.t.cpp:666
void accumulateAddLocallyOwnedEnd()
Definition: MultiVector.t.cpp:675
MultiVector()=default
Default Constructor.
void setValue(const ValueType val)
Set all entries of the MultiVector to a given value.
Definition: MultiVector.t.cpp:568
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:38
A class template to store the communication pattern (i.e., which entries/nodes to receive from which ...
Definition: MPIPatternP2P.h:197
typeInternal::scalar_type< ValueType1, ValueType2 > scalar_type
Definition: BlasLapackTypedef.h:183
ScalarOp
Definition: BlasLapackTypedef.h:169
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:837
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:769
void swap(MultiVector< ValueType, memorySpace > &X, MultiVector< ValueType, memorySpace > &Y)
Swaps the data of u with this multivector.
Definition: MultiVector.t.cpp:757
int MPIComm
Definition: MPITypes.h:84
MemorySpace
Definition: MemorySpaceType.h:37
dealii includes
Definition: AtomFieldDataSpherical.cpp:31
std::uint64_t size_type
Definition: TypeConfig.h:9
std::uint64_t global_size_type
Definition: TypeConfig.h:10