FEI Version of the Day
fei_Vector_core.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_core_hpp_
00045 #define _fei_Vector_core_hpp_
00046 
00047 #include <fei_iosfwd.hpp>
00048 #include <fei_CSVec.hpp>
00049 #include <fei_VectorSpace.hpp>
00050 #include <fei_Reducer.hpp>
00051 #include <fei_Logger.hpp>
00052 #include <fei_SharedPtr.hpp>
00053 #include <fei_EqnComm.hpp>
00054 
00055 namespace fei {
00056 
00058 class Vector_core : protected fei::Logger {
00059  public:
00061   Vector_core(fei::SharedPtr<fei::VectorSpace> vecSpace, int numLocalEqns);
00062 
00064   virtual ~Vector_core();
00065 
00071   int copyOut(int numValues,
00072         const int* indices,
00073         double* values,
00074         int vectorIndex=0) const;
00075 
00077   virtual int sumIntoFEVector(int blockID,
00078             int connOffset,
00079             int numNodes,
00080             const int* nodeNumbers,
00081             const int* numIndicesPerNode,
00082             const int* dof_ids,
00083             const double* values) = 0;
00084 
00086   virtual int copyOut_FE(int nodeNumber, int dofOffset, double& value) = 0;
00087 
00089   int giveToVector(int numValues,
00090        const int* indices,
00091        const double* values,
00092        bool sumInto=true,
00093        int vectorIndex=0);
00094 
00096   virtual int scatterToOverlap();
00097 
00101   void setOverlap(int numRemoteEqns=0, const int* remoteEqns=NULL);
00102 
00103  protected:
00105   int assembleFieldData(int fieldID,
00106       int idType,
00107       int numIDs,
00108       const int* IDs,
00109       const double* data,
00110       bool sumInto=true,
00111       int vectorIndex=0);
00112 
00114   virtual int gatherFromOverlap(bool accumulate = true);
00115 
00117   virtual int copyOutFieldData(int fieldID,
00118              int idType,
00119              int numIDs,
00120              const int* IDs,
00121              double* data,
00122              int vectorIndex=0);
00123 
00125   virtual int giveToUnderlyingVector(int numValues,
00126              const int* indices,
00127              const double* values,
00128              bool sumInto=true,
00129              int vectorIndex=0) = 0;
00130 
00132   virtual int copyOutOfUnderlyingVector(int numValues,
00133           const int* indices,
00134           double* values,
00135           int vectorIndex=0) const = 0;
00136 
00139   virtual int writeToFile(const char* filename,
00140         bool matrixMarketFormat=true);
00141 
00143   virtual int writeToStream(FEI_OSTREAM& ostrm,
00144           bool matrixMarketFormat=true);
00145 
00147   fei::SharedPtr<fei::VectorSpace> get_vector_space() const
00148     {
00149       return( vecSpace_ );
00150     }
00151 
00153   void set_vector_space(fei::SharedPtr<fei::VectorSpace> vspace)
00154     {
00155       vecSpace_ = vspace;
00156     }
00157 
00159   int firstLocalOffset() const { return( firstLocalOffset_ ); }
00160 
00162   int lastLocalOffset() const { return( lastLocalOffset_ ); }
00163 
00165   std::vector<int>& work_indices() { return( work_indices_ ); }
00167   std::vector<int>& work_indices2(){ return( work_indices2_); }
00168 
00170   bool haveFEVector() { return( haveFEVector_ ); }
00172   void setFEVector(bool flag) {haveFEVector_ = flag; }
00173 
00175   std::vector<CSVec*>& remotelyOwned() { return( remotelyOwned_ ); }
00176   const std::vector<CSVec*>& remotelyOwned() const { return( remotelyOwned_ ); }
00177 
00178  protected:
00179   fei::SharedPtr<fei::EqnComm> eqnComm_;
00180 
00181  private:
00182   fei::SharedPtr<fei::VectorSpace> vecSpace_;
00183 
00184   MPI_Comm comm_;
00185 
00186   int firstLocalOffset_, lastLocalOffset_, numLocal_;
00187 
00188   std::vector<int> work_indices_;
00189   std::vector<int> work_indices2_;
00190 
00191   bool haveFEVector_;
00192 
00193   std::vector<CSVec*> remotelyOwned_;
00194   std::vector<int> sendProcs_;
00195   std::vector<int> recvProcs_;
00196   std::vector<int> recv_sizes_;
00197   bool sendRecvProcsNeedUpdated_;
00198 
00199   bool overlapAlreadySet_;
00200   std::string dbgprefix_;
00201 };//class Vector_core
00202 
00203 }//namespace fei
00204 
00205 #endif
00206 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends