FEI Package Browser (Single Doxygen Collection) Version of the Day
Loading...
Searching...
No Matches
fei_Vector_core.hpp
Go to the documentation of this file.
1/*--------------------------------------------------------------------*/
2/* Copyright 2005 Sandia Corporation. */
3/* Under the terms of Contract DE-AC04-94AL85000, there is a */
4/* non-exclusive license for use of this work by or on behalf */
5/* of the U.S. Government. Export of this program may require */
6/* a license from the United States Government. */
7/*--------------------------------------------------------------------*/
8
9#ifndef _fei_Vector_core_hpp_
10#define _fei_Vector_core_hpp_
11
12#include <fei_iosfwd.hpp>
13#include <fei_CSVec.hpp>
14#include <fei_VectorSpace.hpp>
15#include <fei_Reducer.hpp>
16#include <fei_Logger.hpp>
17#include <fei_SharedPtr.hpp>
18#include <fei_EqnComm.hpp>
19
20namespace fei {
21
23class Vector_core : protected fei::Logger {
24 public:
26 Vector_core(fei::SharedPtr<fei::VectorSpace> vecSpace, int numLocalEqns);
27
29 virtual ~Vector_core();
30
36 int copyOut(int numValues,
37 const int* indices,
38 double* values,
39 int vectorIndex=0) const;
40
42 virtual int sumIntoFEVector(int blockID,
43 int connOffset,
44 int numNodes,
45 const int* nodeNumbers,
46 const int* numIndicesPerNode,
47 const int* dof_ids,
48 const double* values) = 0;
49
51 virtual int copyOut_FE(int nodeNumber, int dofOffset, double& value) = 0;
52
54 int giveToVector(int numValues,
55 const int* indices,
56 const double* values,
57 bool sumInto=true,
58 int vectorIndex=0);
59
61 virtual int scatterToOverlap();
62
66 void setOverlap(int numRemoteEqns=0, const int* remoteEqns=NULL);
67
68 protected:
70 int assembleFieldData(int fieldID,
71 int idType,
72 int numIDs,
73 const int* IDs,
74 const double* data,
75 bool sumInto=true,
76 int vectorIndex=0);
77
78 int assembleFieldDataLocalIDs(int fieldID,
79 int idType,
80 int numIDs,
81 const int* localIDs,
82 const double* data,
83 bool sumInto=true,
84 int vectorIndex=0);
85
86 void setCommSizes();
88 virtual int gatherFromOverlap(bool accumulate = true);
89
91 virtual int copyOutFieldData(int fieldID,
92 int idType,
93 int numIDs,
94 const int* IDs,
95 double* data,
96 int vectorIndex=0);
97
99 virtual int giveToUnderlyingVector(int numValues,
100 const int* indices,
101 const double* values,
102 bool sumInto=true,
103 int vectorIndex=0) = 0;
104
106 virtual int copyOutOfUnderlyingVector(int numValues,
107 const int* indices,
108 double* values,
109 int vectorIndex=0) const = 0;
110
113 virtual int writeToFile(const char* filename,
114 bool matrixMarketFormat=true);
115
117 virtual int writeToStream(FEI_OSTREAM& ostrm,
118 bool matrixMarketFormat=true);
119
125
128 {
129 vecSpace_ = vspace;
130 }
131
133 int firstLocalOffset() const { return( firstLocalOffset_ ); }
134
136 int lastLocalOffset() const { return( lastLocalOffset_ ); }
137
139 std::vector<int>& work_indices() { return( work_indices_ ); }
141 std::vector<int>& work_indices2(){ return( work_indices2_); }
142
144 bool haveFEVector() { return( haveFEVector_ ); }
146 void setFEVector(bool flag) {haveFEVector_ = flag; }
147
149 std::vector<CSVec*>& remotelyOwned() { return( remotelyOwned_ ); }
150 const std::vector<CSVec*>& remotelyOwned() const { return( remotelyOwned_ ); }
151 std::vector<int>& remotelyOwnedProcs() { return( remotelyOwnedProcs_ ); }
152 const std::vector<int>& remotelyOwnedProcs() const { return( remotelyOwnedProcs_ ); }
153
155 std::vector<int>::iterator iter = std::lower_bound(remotelyOwnedProcs_.begin(), remotelyOwnedProcs_.end(), proc);
156 fei::CSVec* return_vec = NULL;
157 size_t offset = iter - remotelyOwnedProcs_.begin();
158 if (iter == remotelyOwnedProcs_.end() || *iter != proc) {
159 remotelyOwnedProcs_.insert(iter, proc);
160 return_vec = new fei::CSVec;
161 remotelyOwned_.insert(remotelyOwned_.begin()+offset, return_vec);
162 }
163 else {
164 return_vec = remotelyOwned_[offset];
165 }
166
167 return return_vec;
168 }
169
170 const fei::CSVec* getRemotelyOwned(int proc) const {
171 std::vector<int>::const_iterator iter = std::lower_bound(remotelyOwnedProcs_.begin(), remotelyOwnedProcs_.end(), proc);
172 if (iter == remotelyOwnedProcs_.end() || *iter != proc) {
173 throw std::runtime_error("failed to find remote-vec for specified processor.");
174 }
175
176 size_t offset = iter - remotelyOwnedProcs_.begin();
177 return remotelyOwned_[offset];
178 }
179
180 protected:
182
183 private:
184 void pack_send_buffers(const std::vector<int>& sendProcs,
185 const std::vector<fei::CSVec*>& remotelyOwned,
186 std::vector<std::vector<char> >& send_chars,
187 bool resize_buffer,
188 bool zeroRemotelyOwnedAfterPacking);
189
191
193
195
196 std::vector<int> work_indices_;
197 std::vector<int> work_indices2_;
198
200
201 std::vector<int> remotelyOwnedProcs_;
202 std::vector<CSVec*> remotelyOwned_;
203 std::vector<int> sendProcs_;
204 std::vector<int> recvProcs_;
205 std::vector<int> recv_sizes_;
206 std::vector<std::vector<char> > recv_chars_;
207 std::vector<std::vector<char> > send_chars_;
209
211 std::string dbgprefix_;
212};//class Vector_core
213
214}//namespace fei
215
216#endif
217
const fei::CSVec * getRemotelyOwned(int proc) const
std::vector< int > recvProcs_
const std::vector< int > & remotelyOwnedProcs() const
fei::SharedPtr< fei::EqnComm > eqnComm_
void pack_send_buffers(const std::vector< int > &sendProcs, const std::vector< fei::CSVec * > &remotelyOwned, std::vector< std::vector< char > > &send_chars, bool resize_buffer, bool zeroRemotelyOwnedAfterPacking)
std::vector< int > recv_sizes_
std::vector< int > & remotelyOwnedProcs()
virtual int sumIntoFEVector(int blockID, int connOffset, int numNodes, const int *nodeNumbers, const int *numIndicesPerNode, const int *dof_ids, const double *values)=0
fei::SharedPtr< fei::VectorSpace > vecSpace_
virtual int gatherFromOverlap(bool accumulate=true)
std::vector< int > & work_indices()
int assembleFieldDataLocalIDs(int fieldID, int idType, int numIDs, const int *localIDs, const double *data, bool sumInto=true, int vectorIndex=0)
int lastLocalOffset() const
std::vector< int > & work_indices2()
std::vector< int > work_indices2_
int copyOut(int numValues, const int *indices, double *values, int vectorIndex=0) const
int giveToVector(int numValues, const int *indices, const double *values, bool sumInto=true, int vectorIndex=0)
virtual int writeToFile(const char *filename, bool matrixMarketFormat=true)
std::vector< int > remotelyOwnedProcs_
std::vector< std::vector< char > > send_chars_
Vector_core(fei::SharedPtr< fei::VectorSpace > vecSpace, int numLocalEqns)
int firstLocalOffset() const
virtual int giveToUnderlyingVector(int numValues, const int *indices, const double *values, bool sumInto=true, int vectorIndex=0)=0
std::vector< int > work_indices_
void set_vector_space(fei::SharedPtr< fei::VectorSpace > vspace)
virtual int copyOut_FE(int nodeNumber, int dofOffset, double &value)=0
virtual int writeToStream(FEI_OSTREAM &ostrm, bool matrixMarketFormat=true)
fei::CSVec * getRemotelyOwned(int proc)
virtual int copyOutOfUnderlyingVector(int numValues, const int *indices, double *values, int vectorIndex=0) const =0
void setOverlap(int numRemoteEqns=0, const int *remoteEqns=NULL)
std::vector< CSVec * > remotelyOwned_
virtual int scatterToOverlap()
virtual int copyOutFieldData(int fieldID, int idType, int numIDs, const int *IDs, double *data, int vectorIndex=0)
std::vector< std::vector< char > > recv_chars_
std::vector< int > sendProcs_
std::vector< CSVec * > & remotelyOwned()
int assembleFieldData(int fieldID, int idType, int numIDs, const int *IDs, const double *data, bool sumInto=true, int vectorIndex=0)
fei::SharedPtr< fei::VectorSpace > get_vector_space() const
void setFEVector(bool flag)
const std::vector< CSVec * > & remotelyOwned() const
#define FEI_OSTREAM
#define MPI_Comm
Definition fei_mpi.h:56