DistributedVector.hxx
1 // Copyright (C) 2014 INRIA
2 // Author(s): Marc DuruflĂ©
3 //
4 // This file is part of the linear-algebra library Seldon,
5 // http://seldon.sourceforge.net/.
6 //
7 // Seldon is free software; you can redistribute it and/or modify it under the
8 // terms of the GNU Lesser General Public License as published by the Free
9 // Software Foundation; either version 2.1 of the License, or (at your option)
10 // any later version.
11 //
12 // Seldon is distributed in the hope that it will be useful, but WITHOUT ANY
13 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
15 // more details.
16 //
17 // You should have received a copy of the GNU Lesser General Public License
18 // along with Seldon. If not, see http://www.gnu.org/licenses/.
19 
20 #ifndef SELDON_FILE_DISTRIBUTED_VECTOR_HXX
21 
22 namespace Seldon
23 {
24 
26 
31  template<class T, class Allocator
32  = typename SeldonDefaultAllocator<VectFull, T>::allocator>
33  class DistributedVector : public Vector<T, VectFull, Allocator>
34  {
35  protected :
37 
48  MPI_Comm comm_;
49 
50  public :
51  // constructors
53  DistributedVector(const IVect& rows, const MPI_Comm& comm);
55 
56  void SetOverlapRow(const IVect& rows, const MPI_Comm& comm);
57  int GetNbOverlap() const;
58  int GetOverlapRow(int i) const;
59 
60  const MPI_Comm& GetCommunicator() const;
61  void SetCommunicator(const MPI_Comm& comm);
62 
63  };
64 
65 
66  // returns X.Y
67  template<class T1, class Allocator1>
70 
71  // returns X' . Y
72  template<class T1, class Allocator1>
75 
76  // returns euclidian norm of x
77  template<class T, class Allocator>
78  T Norm2(const DistributedVector<complex<T>, Allocator>& x);
79 
80  // returns euclidian norm of x
81  template<class T, class Allocator>
83 
84  template<class T>
85  T minComplex(const T& x, const T& y);
86 
87  template<class T>
88  complex<T> minComplex(const complex<T>& x, const complex<T>& y);
89 
90  template<class T>
91  T maxComplex(const T& x, const T& y);
92 
93  template<class T>
94  complex<T> maxComplex(const complex<T>& x, const complex<T>& y);
95 
96  void ExtractDistributedSharedNumbers(const IVect& MatchingNumber_Subdomain,
97  const Vector<IVect>& MatchingDofOrig_Subdomain,
98  const Vector<bool>& is_local, int nb_ddl_local,
99  IVect& MatchingNumber_Local,
100  Vector<IVect>& MatchingDof_Local);
101 
102  void AssembleVectorMin(Vector<int>& X, Vector<int>& Xproc,
103  const IVect& ProcNumber,
104  const Vector<IVect>& DofNumber,
105  const MPI_Comm& comm, int Nvol, int nb_u, int tag);
106 
107  template<class T>
108  void AssembleVector(Vector<T>& X, const MPI_Op& oper,
109  const IVect& ProcNumber, const Vector<IVect>& DofNumber,
110  const MPI_Comm& comm, int Nvol, int nb_u, int tag);
111 
112  template<class T>
113  void ExchangeVector(Vector<T>& X,
114  const IVect& ProcNumber, const Vector<IVect>& DofNumber,
115  const MPI_Comm& comm, int Nvol, int nb_u, int tag);
116 
117  template<class T, class Treal>
118  void ExchangeRelaxVector(Vector<T>& X, const Treal& omega, int proc,
119  const IVect& ProcNumber,
120  const Vector<IVect>& DofNumber,
121  const MPI_Comm& comm, int Nvol, int nb_u, int tag);
122 
123  template<class T>
124  T DotProd(const DistributedVector<T>& X, const DistributedVector<T>& Y);
125 
126  template<class T>
127  complex<T> DotProd(const DistributedVector<complex<T> >& X,
128  const DistributedVector<T>& Y);
129 
130  template<class T>
131  complex<T> DotProd(const DistributedVector<T>& X,
132  const DistributedVector<complex<T> >& Y);
133 
134  template<class T>
135  T DotProdConj(const DistributedVector<T>& X, const DistributedVector<T>& Y);
136 
137  template<class T>
138  complex<T> DotProdConj(const DistributedVector<complex<T> >& X,
139  const DistributedVector<complex<T> >& Y);
140 
141  template<class T>
142  complex<T> DotProdConj(const DistributedVector<complex<T> >& X,
143  const DistributedVector<T>& Y);
144 
145  template<class T>
146  complex<T> DotProdConj(const DistributedVector<T>& X,
147  const DistributedVector<complex<T> >& Y);
148 
149 }
150 
151 #define SELDON_FILE_DISTRIBUTED_VECTOR_HXX
152 #endif
153 
Seldon::DistributedVector::DistributedVector
DistributedVector()
default constructor
Definition: DistributedVectorInline.cxx:29
Seldon::DistributedVector::GetOverlapRow
int GetOverlapRow(int i) const
returns an overlapped row number
Definition: DistributedVectorInline.cxx:86
Seldon::maxComplex
T maxComplex(const T &x, const T &y)
maximum for real numbers
Definition: DistributedVector.cxx:135
Seldon::Norm2
ClassComplexType< T >::Treal Norm2(const VectorExpression< T, E > &X)
returns 2-norm of an expression with vectors
Definition: Functions_BaseInline.cxx:153
Seldon::DistributedVector::GetNbOverlap
int GetNbOverlap() const
returns the number of rows already counted
Definition: DistributedVectorInline.cxx:75
Seldon::Vector
Definition: SeldonHeader.hxx:207
Seldon::DotProdVector
T1 DotProdVector(const Vector< T1, Storage1, Allocator1 > &X, const Vector< T2, Storage2, Allocator2 > &Y)
Scalar product between two vectors.
Definition: Functions_Vector.cxx:399
Seldon::DistributedVector::OverlapRowNumbers
IVect * OverlapRowNumbers
row numbers shared with other processors
Definition: DistributedVector.hxx:46
Seldon::DistributedVector::GetCommunicator
const MPI_Comm & GetCommunicator() const
returns communicator
Definition: DistributedVectorInline.cxx:99
Seldon::ExtractDistributedSharedNumbers
void ExtractDistributedSharedNumbers(const IVect &MatchingNumber_Subdomain, const Vector< IVect > &MatchingDofOrig_Subdomain, const Vector< bool > &is_local, int nb_ddl_local, IVect &MatchingNumber_Local, Vector< IVect > &MatchingDof_Local)
extracts MatchingNumber_Local / MatchingDof_Local from arrays MatchingNumber_Subdomain / MatchingDofO...
Definition: DistributedVector.cxx:154
Seldon::DistributedVector::SetOverlapRow
void SetOverlapRow(const IVect &rows, const MPI_Comm &comm)
sets overlapped rows and MPI communicator
Definition: DistributedVectorInline.cxx:66
Seldon::DistributedVector::SetCommunicator
void SetCommunicator(const MPI_Comm &comm)
sets communicator
Definition: DistributedVectorInline.cxx:107
Seldon::AssembleVectorMin
void AssembleVectorMin(Vector< int > &X, Vector< int > &Xproc, const IVect &ProcNumber, const Vector< IVect > &DofNumber, const MPI_Comm &comm, int Nvol, int nb_u, int tag)
assembles minimums of two vectors
Definition: DistributedVector.cxx:190
Seldon::minComplex
T minComplex(const T &x, const T &y)
minimum for real numbers
Definition: DistributedVector.cxx:116
Seldon::DistributedVector::comm_
MPI_Comm comm_
MPI communicator grouping processors involved in the computation.
Definition: DistributedVector.hxx:48
Seldon
Seldon namespace.
Definition: Array.cxx:24
Seldon::DotProdConjVector
T1 DotProdConjVector(const Vector< T1, Storage1, Allocator1 > &X, const Vector< T2, Storage2, Allocator2 > &Y)
Scalar product between two vectors conj(X).Y .
Definition: Functions_Vector.cxx:461
Seldon::DistributedVector
class storing a vector distributed over all the processors
Definition: DistributedVector.hxx:33