DFT-EFE
 
Loading...
Searching...
No Matches
Vector.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 Bikash Kanungo
24 */
25
26
27#ifndef dftefeVector_h
28#define dftefeVector_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>
40#include <memory>
41namespace dftefe
42{
43 namespace linearAlgebra
44 {
120 template <typename ValueType, dftefe::utils::MemorySpace memorySpace>
121 class Vector : public MultiVector<ValueType, memorySpace>
122 {
123 public:
124 //
125 // typedefs
126 //
128 using value_type = typename Storage::value_type;
129 using pointer = typename Storage::pointer;
130 using reference = typename Storage::reference;
131 using const_reference = typename Storage::const_reference;
132 using iterator = typename Storage::iterator;
133 using const_iterator = typename Storage::const_iterator;
134
135 //
136 // Forwarding the protected data members from the parent class
137 // MultiVector. This is done to avoid using this->d_parentClassDataMember
138 // or explicit qualification (ParentClass::d_parentClassMember)
139 // and directly use d_parentClassDataMember.
140 //
141 using MultiVector<ValueType, memorySpace>::d_storage;
142 using MultiVector<ValueType, memorySpace>::d_linAlgOpContext;
143 using MultiVector<ValueType, memorySpace>::d_vectorAttributes;
144 using MultiVector<ValueType, memorySpace>::d_localSize;
145 using MultiVector<ValueType, memorySpace>::d_globalSize;
146 using MultiVector<ValueType, memorySpace>::d_locallyOwnedSize;
147 using MultiVector<ValueType, memorySpace>::d_ghostSize;
148 using MultiVector<ValueType, memorySpace>::d_numVectors;
149 using MultiVector<ValueType, memorySpace>::d_mpiCommunicatorP2P;
150 using MultiVector<ValueType, memorySpace>::d_mpiPatternP2P;
151
152
153 public:
157 Vector() = default;
158
162 ~Vector() = default;
163
170 Vector(size_type size,
171 std::shared_ptr<LinAlgOpContext<memorySpace>> linAlgOpContext,
172 ValueType initVal = utils::Types<ValueType>::zero);
173
191 Vector(std::unique_ptr<typename Vector<ValueType, memorySpace>::Storage>
192 storage,
193 std::shared_ptr<LinAlgOpContext<memorySpace>> linAlgOpContext);
194
209 mpiPatternP2P,
210 std::shared_ptr<LinAlgOpContext<memorySpace>> linAlgOpContext,
211 const ValueType initVal = utils::Types<ValueType>::zero);
212
223 mpiPatternP2P,
224 std::shared_ptr<LinAlgOpContext<memorySpace>> linAlgOpContext,
225 const ValueType min,
226 const ValueType max);
227
245 Vector(std::unique_ptr<typename Vector<ValueType, memorySpace>::Storage>
246 &storage,
247 std::shared_ptr<const utils::mpi::MPIPatternP2P<memorySpace>>
248 mpiPatternP2P,
249 std::shared_ptr<LinAlgOpContext<memorySpace>> linAlgOpContext);
250
269 Vector(
270 const std::pair<global_size_type, global_size_type> locallyOwnedRange,
271 const std::vector<dftefe::global_size_type> & ghostIndices,
272 const utils::mpi::MPIComm & mpiComm,
273 std::shared_ptr<LinAlgOpContext<memorySpace>> linAlgOpContext,
274 const ValueType initVal = utils::Types<ValueType>::zero);
275
293 Vector(
294 const std::pair<global_size_type, global_size_type> locallyOwnedRange,
295 const utils::mpi::MPIComm & mpiComm,
296 std::shared_ptr<LinAlgOpContext<memorySpace>> linAlgOpContext,
297 const ValueType initVal = utils::Types<ValueType>::zero);
298
299
320 const utils::mpi::MPIComm & mpiComm,
321 std::shared_ptr<LinAlgOpContext<memorySpace>> linAlgOpContext,
322 const ValueType initVal = utils::Types<ValueType>::zero);
323
329
335 Vector(const Vector<ValueType, memorySpace> &u, ValueType initVal);
336
341 Vector(Vector &&u) noexcept;
342
350
358
363 double
364 l2Norm() const;
365
370 double
371 lInfNorm() const;
372 };
373
374
401 template <typename ValueType1,
402 typename ValueType2,
403 utils::MemorySpace memorySpace>
404 void
410
411 } // end of namespace linearAlgebra
412} // end of namespace dftefe
414#endif // dftefeVector_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
std::shared_ptr< LinAlgOpContext< memorySpace > > d_linAlgOpContext
Definition: MultiVector.h:497
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
std::unique_ptr< utils::mpi::MPICommunicatorP2P< ValueType, memorySpace > > d_mpiCommunicatorP2P
Definition: MultiVector.h:505
size_type d_localSize
Definition: MultiVector.h:499
size_type d_locallyOwnedSize
Definition: MultiVector.h:501
global_size_type globalSize() const
Definition: MultiVector.t.cpp:696
std::shared_ptr< const utils::mpi::MPIPatternP2P< memorySpace > > d_mpiPatternP2P
Definition: MultiVector.h:507
std::unique_ptr< Storage > d_storage
Definition: MultiVector.h:496
VectorAttributes d_vectorAttributes
Definition: MultiVector.h:498
A class that encapsulates a vector. This is a vector in the mathematical sense and not in the sense o...
Definition: Vector.h:122
typename Storage::value_type value_type
Definition: Vector.h:128
typename MultiVector< ValueType, memorySpace >::Storage Storage
Definition: Vector.h:127
Vector()=default
Default constructor.
typename Storage::iterator iterator
Definition: Vector.h:132
typename Storage::const_reference const_reference
Definition: Vector.h:131
double l2Norm() const
Returns norm of the Vector.
Definition: Vector.t.cpp:506
Vector< ValueType, memorySpace > & operator=(const Vector< ValueType, memorySpace > &u)
Copy assignment operator.
Definition: Vector.t.cpp:462
typename Storage::const_iterator const_iterator
Definition: Vector.h:133
typename Storage::reference reference
Definition: Vector.h:130
double lInfNorm() const
Returns norm of the Vector.
Definition: Vector.t.cpp:532
typename Storage::pointer pointer
Definition: Vector.h:129
~Vector()=default
Default Destructor.
Definition: MemoryStorage.h:38
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
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