FEI Version of the Day
fei_VectorReducer.hpp
00001 /*--------------------------------------------------------------------*/
00002 /*    Copyright 2005 Sandia Corporation.                              */
00003 /*    Under the terms of Contract DE-AC04-94AL85000, there is a       */
00004 /*    non-exclusive license for use of this work by or on behalf      */
00005 /*    of the U.S. Government.  Export of this program may require     */
00006 /*    a license from the United States Government.                    */
00007 /*--------------------------------------------------------------------*/
00008 
00009 #ifndef _fei_VectorReducer_hpp_
00010 #define _fei_VectorReducer_hpp_
00011 
00012 #include <fei_iosfwd.hpp>
00013 #include <fei_VectorSpace.hpp>
00014 #include <fei_Reducer.hpp>
00015 #include <fei_Vector.hpp>
00016 
00017 #undef fei_file
00018 #define fei_file "fei_VectorReducer.hpp"
00019 
00020 #include <fei_ErrMacros.hpp>
00021 
00022 namespace fei {
00023 
00024   class VectorReducer : public fei::Vector {
00025   public:
00026 
00028     VectorReducer(fei::SharedPtr<fei::Reducer> reducer,
00029                   fei::SharedPtr<fei::Vector> target,
00030             bool isSolutionVector=false);
00031 
00033     virtual ~VectorReducer();
00034 
00036     fei::SharedPtr<fei::Vector> getTargetVector()
00037       { return(target_); }
00038 
00042     const char* typeName() const { return(target_->typeName()); }
00043 
00046     int update(double a,
00047          const fei::Vector* x,
00048          double b);
00049 
00056     int scatterToOverlap();
00057 
00058     void setCommSizes() { target_->setCommSizes(); }
00059 
00063     int gatherFromOverlap(bool accumulate = true);
00064 
00066     int putScalar(double scalar);
00067 
00071     int sumIn(int numValues, const int* indices, const double* values,
00072         int vectorIndex=0);
00073 
00077     int copyIn(int numValues, const int* indices, const double* values,
00078          int vectorIndex=0);
00079 
00082     fei::SharedPtr<fei::VectorSpace> getVectorSpace() const
00083       { return(target_->getVectorSpace()); }
00084 
00087     void setVectorSpace(fei::SharedPtr<fei::VectorSpace> vecSpace)
00088     { target_->setVectorSpace( vecSpace ); }
00089 
00096     int sumInFieldData(int fieldID,
00097            int idType,
00098            int numIDs,
00099            const int* IDs,
00100            const double* data,
00101            int vectorIndex=0);
00102 
00109     int copyInFieldData(int fieldID,
00110       int idType,
00111       int numIDs,
00112       const int* IDs,
00113       const double* data,
00114       int vectorIndex=0);
00115 
00116     int copyInFieldDataLocalIDs(int fieldID,
00117       int idType,
00118       int numIDs,
00119       const int* localIDs,
00120       const double* data,
00121       int vectorIndex=0);
00122 
00129     int copyOutFieldData(int fieldID,
00130        int idType,
00131        int numIDs,
00132        const int* IDs,
00133        double* data,
00134        int vectorIndex=0);
00135 
00136     int writeToFile(const char* filename,
00137         bool matrixMarketFormat=true);
00138 
00139     int writeToStream(FEI_OSTREAM& ostrm,
00140           bool matrixMarketFormat=true);
00141 
00142     int copyOut(int numValues,
00143     const int* indices,
00144     double* values,
00145     int vectorIndex=0) const;
00146 
00147   private:
00150     int copyOut_FE(int nodeNumber, int dofOffset, double& value);
00151 
00152     int giveToUnderlyingVector(int numValues,
00153              const int* indices,
00154              const double* values,
00155              bool sumInto=true,
00156              int vectorIndex=0);
00157 
00158     int sumIntoFEVector(int blockID,
00159       int connOffset,
00160       int numNodes,
00161       const int* nodeNumbers,
00162       const int* numIndicesPerNode,
00163       const double* values);
00164 
00165     fei::SharedPtr<fei::Reducer> reducer_;
00166     fei::SharedPtr<fei::Vector> target_;
00167     bool isSolution_;
00168 
00169     int localProc_;
00170     int numProcs_;
00171   };//class VectorReducer
00172 
00173 } //namespace fei
00174 
00175 #endif // _fei_VectorReducer_hpp_
00176 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends