FEI Version of the Day
fei_Vector_Local.hpp
00001 /*
00002 // @HEADER
00003 // ************************************************************************
00004 //             FEI: Finite Element Interface to Linear Solvers
00005 //                  Copyright (2005) Sandia Corporation.
00006 //
00007 // Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, the
00008 // U.S. Government retains certain rights in this software.
00009 //
00010 // Redistribution and use in source and binary forms, with or without
00011 // modification, are permitted provided that the following conditions are
00012 // met:
00013 //
00014 // 1. Redistributions of source code must retain the above copyright
00015 // notice, this list of conditions and the following disclaimer.
00016 //
00017 // 2. Redistributions in binary form must reproduce the above copyright
00018 // notice, this list of conditions and the following disclaimer in the
00019 // documentation and/or other materials provided with the distribution.
00020 //
00021 // 3. Neither the name of the Corporation nor the names of the
00022 // contributors may be used to endorse or promote products derived from
00023 // this software without specific prior written permission.
00024 //
00025 // THIS SOFTWARE IS PROVIDED BY SANDIA CORPORATION "AS IS" AND ANY
00026 // EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00027 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
00028 // PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL SANDIA CORPORATION OR THE
00029 // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
00030 // EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00031 // PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00032 // PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
00033 // LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
00034 // NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
00035 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00036 //
00037 // Questions? Contact Alan Williams (william@sandia.gov) 
00038 //
00039 // ************************************************************************
00040 // @HEADER
00041 */
00042 
00043 
00044 #ifndef _fei_Vector_Local_hpp_
00045 #define _fei_Vector_Local_hpp_
00046 
00047 #include <fei_iosfwd.hpp>
00048 #include <fei_SharedPtr.hpp>
00049 #include <fei_VectorSpace.hpp>
00050 #include <fei_Vector.hpp>
00051 
00052 namespace fei {
00053 
00054 class Vector_Local : public fei::Vector {
00055  public:
00056   Vector_Local(fei::SharedPtr<fei::VectorSpace> vecSpace);
00057 
00058   virtual ~Vector_Local();
00059 
00060   const char* typeName() const { return("fei::Vector_Local"); }
00061 
00064     int update(double a,
00065                const fei::Vector* x,
00066                double b);
00067 
00074     int scatterToOverlap();
00075 
00076     void setCommSizes();
00077 
00081     int gatherFromOverlap(bool accumulate = true);
00082 
00084     int putScalar(double scalar);
00085 
00089     int sumIn(int numValues, const int* indices, const double* values,
00090               int vectorIndex=0);
00091 
00095     int copyIn(int numValues, const int* indices, const double* values,
00096                int vectorIndex=0);
00097 
00100     fei::SharedPtr<fei::VectorSpace> getVectorSpace() const;
00101 
00104     void setVectorSpace(fei::SharedPtr<fei::VectorSpace> vecSpace);
00105 
00112     int sumInFieldData(int fieldID,
00113                        int idType,
00114                        int numIDs,
00115                        const int* IDs,
00116                        const double* data,
00117                        int vectorIndex=0);
00118 
00125     int copyInFieldData(int fieldID,
00126                         int idType,
00127                         int numIDs,
00128                         const int* IDs,
00129                         const double* data,
00130                         int vectorIndex=0);
00131 
00132     int copyInFieldDataLocalIDs(int fieldID,
00133                         int idType,
00134                         int numIDs,
00135                         const int* localIDs,
00136                         const double* data,
00137                         int vectorIndex=0);
00138 
00145     int copyOutFieldData(int fieldID,
00146                          int idType,
00147                          int numIDs,
00148                          const int* IDs,
00149                          double* data,
00150                          int vectorIndex=0);
00151 
00152     int copyOut(int numValues, const int* indices,
00153                 double* values, int vectorIndex=0) const;
00154 
00155     int writeToFile(const char* filename,
00156                     bool matrixMarketFormat=true);
00157 
00158     int writeToStream(FEI_OSTREAM& ostrm,
00159                       bool matrixMarketFormat=true);
00160 
00161     std::vector<double>& getCoefs();
00162 
00163  private:
00164   int giveToVector(int numValues, const int* indices,
00165                            const double* values,
00166                            bool sumInto, int vectorIndex);
00167 
00168   int assembleFieldData(int fieldID,
00169                        int idType,
00170                        int numIDs,
00171                        const int* IDs,
00172                        const double* data,
00173                        bool sumInto,
00174                        int vectorIndex);
00175 
00176   int assembleFieldDataLocalIDs(int fieldID,
00177                        int idType,
00178                        int numIDs,
00179                        const int* localIDs,
00180                        const double* data,
00181                        bool sumInto,
00182                        int vectorIndex);
00183 
00184   fei::SharedPtr<fei::VectorSpace> vecSpace_;
00185   std::vector<double> coefs_;
00186   std::map<int,int> global_to_local_;
00187   std::vector<int> work_indices_;
00188 };//class Vector_Local
00189 
00190 }//namespace fei
00191 
00192 #endif
00193 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends