9 #ifndef _fei_Vector_Impl_hpp_
10 #define _fei_Vector_Impl_hpp_
12 #include <fei_macros.hpp>
13 #include <fei_VectorTraits.hpp>
15 #include <fei_VectorTraits_CSVec.hpp>
16 #include <fei_VectorTraits_LinSysCore.hpp>
17 #include <fei_VectorTraits_LinProbMgr.hpp>
18 #include <fei_VectorTraits_FEData.hpp>
19 #include <snl_fei_FEVectorTraits.hpp>
20 #include <snl_fei_FEVectorTraits_FED.hpp>
21 #include <fei_SharedIDs.hpp>
22 #include <fei_VectorSpace.hpp>
23 #include <fei_Reducer.hpp>
24 #include <fei_Logger.hpp>
25 #include <fei_Vector.hpp>
26 #include <fei_Vector_core.hpp>
27 #include <fei_iosfwd.hpp>
30 #define fei_file "fei_Vector_Impl.hpp"
32 #include <fei_ErrMacros.hpp>
62 T* vector,
int numLocalEqns,
63 bool isSolutionVector=
false,
64 bool deleteVector=
false);
101 int sumIn(
int numValues,
const int* indices,
const double* values,
107 int copyIn(
int numValues,
const int* indices,
const double* values,
148 int copyInFieldDataLocalIDs(
int fieldID,
169 bool matrixMarketFormat=
true);
172 bool matrixMarketFormat=
true);
191 int vectorIndex=0)
const;
195 int copyOut_FE(
int nodeNumber,
int dofOffset,
double& value);
198 int giveToUnderlyingVector(
int numValues,
200 const double* values,
204 int copyOutOfUnderlyingVector(
int numValues,
207 int vectorIndex=0)
const;
209 int sumIntoFEVector(
int blockID,
212 const int* nodeNumbers,
213 const int* numIndicesPerNode,
215 const double* values);
223 std::string dbgprefix_;
231 T* vector,
int numLocalEqns,
232 bool isSolutionVector,
236 isSolution_(isSolutionVector),
237 deleteVector_(deleteVector),
240 dbgprefix_(
"VecImpl: ")
254 os << dbgprefix_<<
" ctor, numLocalEqns="<<numLocalEqns
255 <<
", typeName: "<<
typeName()<<FEI_ENDL;
258 std::vector<int> idTypes;
260 std::vector<int> eqns;
261 std::vector<double> zeros;
262 for(
size_t i=0; i<idTypes.size(); ++i) {
263 int idType = idTypes[i];
267 iter = idMap.begin(), iterEnd = idMap.end();
268 for(; iter!=iterEnd; ++iter) {
269 int ID = iter->first;
274 zeros.resize(ndof, 0.0);
275 for(
int j=0; j<ndof; ++j) eqns[j] = eqn+j;
276 if (!isSolutionVector) {
277 sumIn(ndof, &eqns[0], &zeros[0]);
280 copyIn(ndof, &eqns[0], &zeros[0]);
287 for(
size_t i=0; i<remoteVecs.size(); ++i) {
288 remoteVecs[i]->clear();
296 if (deleteVector_)
delete vector_;
303 if (output_level_ >= fei::BRIEF_LOGS && output_stream_ != NULL) {
304 FEI_OSTREAM& os = *output_stream_;
305 os << dbgprefix_<<
"putScalar("<<scalar<<
")"<<FEI_ENDL;
308 if (haveFEVector()) {
309 if (scalar != 0.0)
return(-1);
315 for(
unsigned p=0; p<remotelyOwned().size(); ++p) {
316 fei::set_values(*(remotelyOwned()[p]), scalar);
341 if (output_level_ >= fei::BRIEF_LOGS && output_stream_ != NULL) {
342 FEI_OSTREAM& os = *output_stream_;
343 os << dbgprefix_<<
"scatterToOverlap"<<FEI_ENDL;
353 if (output_level_ >= fei::BRIEF_LOGS && output_stream_ != NULL) {
354 FEI_OSTREAM& os = *output_stream_;
355 os << dbgprefix_<<
"setCommSizes"<<FEI_ENDL;
358 Vector_core::setCommSizes();
365 if (output_level_ >= fei::BRIEF_LOGS && output_stream_ != NULL) {
366 FEI_OSTREAM& os = *output_stream_;
367 os << dbgprefix_<<
"gatherFromOverlap"<<FEI_ENDL;
376 const int* indices,
const double* values,
379 if (output_level_ >= fei::BRIEF_LOGS && output_stream_ != NULL) {
380 FEI_OSTREAM& os = *output_stream_;
381 os << dbgprefix_<<
"sumIn(n="<<numValues<<
")"<<FEI_ENDL;
384 return( giveToVector(numValues, indices, values,
true, vectorIndex) );
390 const int* indices,
const double* values,
393 if (output_level_ >= fei::BRIEF_LOGS && output_stream_ != NULL) {
394 FEI_OSTREAM& os = *output_stream_;
395 os << dbgprefix_<<
"copyIn(n="<<numValues<<
")"<<FEI_ENDL;
398 return( giveToVector(numValues, indices, values,
false, vectorIndex) );
405 const double* values,
409 if (output_level_ >= fei::BRIEF_LOGS && output_stream_ != NULL) {
410 FEI_OSTREAM& os = *output_stream_;
411 os << dbgprefix_<<
"giveToUnderlying(";
412 for(
int i=0; i<numValues; ++i) {
413 os <<
"{"<<indices[i]<<
","<<values[i]<<
"} ";
419 numValues, indices, values,
420 sumInto, isSolution_, vectorIndex);
432 int vectorIndex)
const
434 if (output_level_ >= fei::BRIEF_LOGS && output_stream_ != NULL) {
435 FEI_OSTREAM& os = *output_stream_;
436 os << dbgprefix_<<
"copyOutOfUnderlying(n="<<numValues<<
")"<<FEI_ENDL;
440 numValues, indices, values,
441 isSolution_, vectorIndex) );
453 if (output_level_ >= fei::BRIEF_LOGS && output_stream_ != NULL) {
454 FEI_OSTREAM& os = *output_stream_;
455 os << dbgprefix_<<
"sumInFieldData(n="<<numIDs<<
")"<<FEI_ENDL;
458 return( assembleFieldData(fieldID, idType, numIDs, IDs, data,
true, vectorIndex));
470 if (output_level_ >= fei::BRIEF_LOGS && output_stream_ != NULL) {
471 FEI_OSTREAM& os = *output_stream_;
472 os << dbgprefix_<<
"copyInFieldData(n="<<numIDs<<
")"<<FEI_ENDL;
475 return(assembleFieldData(fieldID, idType, numIDs, IDs, data,
false, vectorIndex));
487 if (output_level_ >= fei::BRIEF_LOGS && output_stream_ != NULL) {
488 FEI_OSTREAM& os = *output_stream_;
489 os << dbgprefix_<<
"copyInFieldDataLocalIDs(n="<<numIDs<<
")"<<FEI_ENDL;
492 return(assembleFieldDataLocalIDs(fieldID, idType, numIDs, localIDs, data,
false, vectorIndex));
518 bool matrixMarketFormat)
526 bool matrixMarketFormat)
536 int vectorIndex)
const
538 if (output_level_ >= fei::BRIEF_LOGS && output_stream_ != NULL) {
539 FEI_OSTREAM& os = *output_stream_;
540 os << dbgprefix_<<
"copyOut(n="<<numValues<<
")"<<FEI_ENDL;
551 const int* nodeNumbers,
552 const int* numIndicesPerNode,
554 const double* values)
557 numNodes, nodeNumbers,
558 numIndicesPerNode, dof_ids, values) );
562 #define fei_file "unknown_file"
564 #endif // _fei_Vector_Impl_hpp_
MPI_Comm getCommunicator() const
static int putValuesIn(T *vec, int firstLocalOffset, int numValues, const int *indices, const double *values, bool sum_into, bool isSolnVector=false, int vectorIndex=0)
std::map< T, std::set< int > > map_type
map_type & getSharedIDs()
fei::SharedPtr< fei::VectorSpace > getVectorSpace() const
int writeToStream(FEI_OSTREAM &ostrm, bool matrixMarketFormat=true)
int sumInFieldData(int fieldID, int idType, int numIDs, const int *IDs, const double *data, int vectorIndex=0)
int copyOut(int numValues, const int *indices, double *values, int vectorIndex=0) const
virtual int writeToStream(FEI_OSTREAM &ostrm, bool matrixMarketFormat=true)
int copyOut(int numValues, const int *indices, double *values, int vectorIndex=0) const
void set_vector_space(fei::SharedPtr< fei::VectorSpace > vspace)
int getGlobalIndex(int idType, int ID, int fieldID, int fieldOffset, int whichComponentOfField, int &globalIndex)
int copyOutFieldData(int fieldID, int idType, int numIDs, const int *IDs, double *data, int vectorIndex=0)
void getIDTypes(std::vector< int > &idTypes) const
std::vector< CSVec * > & remotelyOwned()
int putScalar(double scalar)
void setFEVector(bool flag)
virtual int copyOutFieldData(int fieldID, int idType, int numIDs, const int *IDs, double *data, int vectorIndex=0)
int copyIn(int numValues, const int *indices, const double *values, int vectorIndex=0)
OutputLevel output_level_
const char * typeName() const
int update(double a, const fei::Vector *x, double b)
int copyInFieldData(int fieldID, int idType, int numIDs, const int *IDs, const double *data, int vectorIndex=0)
FEI_OSTREAM * output_stream_
fei::SharedPtr< fei::VectorSpace > get_vector_space() const
T * getUnderlyingVector()
int localProc(MPI_Comm comm)
int gatherFromOverlap(bool accumulate=true)
int writeToFile(const char *filename, bool matrixMarketFormat=true)
virtual int writeToFile(const char *filename, bool matrixMarketFormat=true)
void setUnderlyingVector(T *vec)
int sumIn(int numValues, const int *indices, const double *values, int vectorIndex=0)
virtual int scatterToOverlap()
int getNumDegreesOfFreedom(int idType, int ID)
void setVectorSpace(fei::SharedPtr< fei::VectorSpace > vecSpace)
virtual int gatherFromOverlap(bool accumulate=true)
int numProcs(MPI_Comm comm)
int copyOut_FE(int nodeNumber, int dofOffset, double &value)
Vector_Impl(fei::SharedPtr< fei::VectorSpace > vecSpace, T *vector, int numLocalEqns, bool isSolutionVector=false, bool deleteVector=false)