1 #ifndef _fei_Matrix_core_hpp_
2 #define _fei_Matrix_core_hpp_
12 #include <fei_macros.hpp>
14 #include <fei_EqnComm.hpp>
15 #include <fei_fwd.hpp>
16 #include <fei_Vector.hpp>
17 #include <fei_CommUtils.hpp>
18 #include <fei_FillableMat.hpp>
19 #include <fei_MatrixGraph.hpp>
20 #include <fei_Logger.hpp>
30 virtual ~Matrix_core();
32 virtual int giveToMatrix(
int numRows,
const int* rows,
33 int numCols,
const int* cols,
34 const double*
const* values,
62 static void copyTransposeToWorkArrays(
int numRows,
int numCols,
63 const double*
const* values,
64 std::vector<double>& work_1D,
65 std::vector<const double*>& work_2D);
83 const FillableMat* getRemotelyOwnedMatrix(
int proc)
const
85 if (proc_last_requested_ == proc) {
86 return remotelyOwned_last_requested_;
88 FillableMat* remote_mat = NULL;
89 std::map<int,FillableMat*>::const_iterator it = remotelyOwned_.find(proc);
90 if (it != remotelyOwned_.end()) {
91 remote_mat = it->second;
92 remotelyOwned_last_requested_ = remote_mat;
93 proc_last_requested_ = proc;
98 FillableMat* getRemotelyOwnedMatrix(
int proc)
100 if (proc_last_requested_ == proc) {
101 return remotelyOwned_last_requested_;
103 proc_last_requested_ = proc;
104 FillableMat* remote_mat = NULL;
105 std::map<int,FillableMat*>::iterator it = remotelyOwned_.find(proc);
106 if (it == remotelyOwned_.end()) {
107 remote_mat =
new FillableMat;
108 remotelyOwned_.insert(std::make_pair(proc, remote_mat));
111 remote_mat = it->second;
113 remotelyOwned_last_requested_ = remote_mat;
114 return( remote_mat );
117 std::map<int,FillableMat*>& getRemotelyOwnedMatrices();
119 void putScalar_remotelyOwned(
double scalar);
126 virtual int giveToUnderlyingMatrix(
int numRows,
const int* rows,
127 int numCols,
const int* cols,
128 const double*
const* values,
132 virtual int giveToBlockMatrix(
int numRows,
const int* rows,
133 int numCols,
const int* cols,
134 const double*
const* values,
137 virtual int giveToUnderlyingBlockMatrix(
int row,
143 const double*
const* values,
146 void setName(
const char* name);
149 int gatherFromOverlap(
bool accumulate);
162 int copyPointRowsToBlockRow(
int numPtRows,
164 const double*
const* ptValues,
166 const int* blkColDims,
169 int convertPtToBlk(
int numRows,
178 MPI_Comm getCommunicator()
const {
return( comm_ ); }
183 std::vector<int>& globalOffsets() {
return( globalOffsets_ ); }
184 const std::vector<int>& globalOffsets()
const {
return( globalOffsets_ ); }
186 int firstLocalOffset()
const {
return( firstLocalOffset_ ); }
187 int lastLocalOffset()
const {
return( lastLocalOffset_ ); }
189 int numProcs()
const {
return( numProcs_ ); }
190 int localProc()
const {
return( localProc_ ); }
192 bool haveBlockMatrix()
const {
return( haveBlockMatrix_ ); }
193 void setBlockMatrix(
bool flag) {haveBlockMatrix_ = flag; }
195 bool haveFEMatrix()
const {
return( haveFEMatrix_ ); }
196 void setFEMatrix(
bool flag) {haveFEMatrix_ = flag; }
198 int getOwnerProc(
int globalEqn)
const;
202 std::vector<int> work_indices_;
203 std::vector<int> work_indices2_;
205 std::vector<int> work_ints_;
207 std::vector<double> work_data1D_;
208 std::vector<const double*> work_data2D_;
218 int localProc_, numProcs_;
223 std::map<int,FillableMat*> remotelyOwned_;
224 mutable FillableMat* remotelyOwned_last_requested_;
225 std::vector<int> sendProcs_;
226 std::vector<int> recvProcs_;
227 std::vector<std::vector<char> > recv_chars_;
228 std::vector<std::vector<char> > send_chars_;
229 bool sendRecvProcsNeedUpdated_;
230 mutable int proc_last_requested_;
232 bool haveBlockMatrix_;
235 std::vector<int> globalOffsets_;
236 int firstLocalOffset_, lastLocalOffset_;
int localProc(MPI_Comm comm)
int numProcs(MPI_Comm comm)