FEI Version of the Day
fei_VectorReducer.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_VectorReducer_hpp_
00045 #define _fei_VectorReducer_hpp_
00046 
00047 #include <fei_iosfwd.hpp>
00048 #include <fei_VectorSpace.hpp>
00049 #include <fei_Reducer.hpp>
00050 #include <fei_Vector.hpp>
00051 
00052 #undef fei_file
00053 #define fei_file "fei_VectorReducer.hpp"
00054 
00055 #include <fei_ErrMacros.hpp>
00056 
00057 namespace fei {
00058 
00059   class VectorReducer : public fei::Vector {
00060   public:
00061 
00063     VectorReducer(fei::SharedPtr<fei::Reducer> reducer,
00064                   fei::SharedPtr<fei::Vector> target,
00065             bool isSolutionVector=false);
00066 
00068     virtual ~VectorReducer();
00069 
00071     fei::SharedPtr<fei::Vector> getTargetVector()
00072       { return(target_); }
00073 
00077     const char* typeName() const { return(target_->typeName()); }
00078 
00081     int update(double a,
00082          const fei::Vector* x,
00083          double b);
00084 
00091     int scatterToOverlap();
00092 
00096     int gatherFromOverlap(bool accumulate = true);
00097 
00099     int putScalar(double scalar);
00100 
00104     int sumIn(int numValues, const int* indices, const double* values,
00105         int vectorIndex=0);
00106 
00110     int copyIn(int numValues, const int* indices, const double* values,
00111          int vectorIndex=0);
00112 
00115     fei::SharedPtr<fei::VectorSpace> getVectorSpace() const
00116       { return(target_->getVectorSpace()); }
00117 
00120     void setVectorSpace(fei::SharedPtr<fei::VectorSpace> vecSpace)
00121     { target_->setVectorSpace( vecSpace ); }
00122 
00129     int sumInFieldData(int fieldID,
00130            int idType,
00131            int numIDs,
00132            const int* IDs,
00133            const double* data,
00134            int vectorIndex=0);
00135 
00142     int copyInFieldData(int fieldID,
00143       int idType,
00144       int numIDs,
00145       const int* IDs,
00146       const double* data,
00147       int vectorIndex=0);
00148 
00155     int copyOutFieldData(int fieldID,
00156        int idType,
00157        int numIDs,
00158        const int* IDs,
00159        double* data,
00160        int vectorIndex=0);
00161 
00162     int writeToFile(const char* filename,
00163         bool matrixMarketFormat=true);
00164 
00165     int writeToStream(FEI_OSTREAM& ostrm,
00166           bool matrixMarketFormat=true);
00167 
00168     int copyOut(int numValues,
00169     const int* indices,
00170     double* values,
00171     int vectorIndex=0) const;
00172 
00173   private:
00176     int copyOut_FE(int nodeNumber, int dofOffset, double& value);
00177 
00178     int giveToUnderlyingVector(int numValues,
00179              const int* indices,
00180              const double* values,
00181              bool sumInto=true,
00182              int vectorIndex=0);
00183 
00184     int sumIntoFEVector(int blockID,
00185       int connOffset,
00186       int numNodes,
00187       const int* nodeNumbers,
00188       const int* numIndicesPerNode,
00189       const double* values);
00190 
00191     fei::SharedPtr<fei::Reducer> reducer_;
00192     fei::SharedPtr<fei::Vector> target_;
00193     bool isSolution_;
00194 
00195     int localProc_;
00196     int numProcs_;
00197   };//class VectorReducer
00198 
00199 } //namespace fei
00200 
00201 #endif // _fei_VectorReducer_hpp_
00202 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends