FEI Version of the Day
fei_Record.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_Record_hpp_
00045 #define _fei_Record_hpp_
00046 
00047 #include <fei_macros.hpp>
00048 
00049 namespace fei {
00050 class FieldMask;
00051 
00054 template<typename GlobalIDType>
00055 class Record {
00056 public:
00058   Record();
00059 
00061   Record(const Record<GlobalIDType>& src)
00062     : isInLocalSubdomain_(src.isInLocalSubdomain_),
00063       ID_(src.ID_),
00064       number_(src.number_),
00065       fieldMask_(src.fieldMask_),
00066       offsetIntoEqnNumbers_(src.offsetIntoEqnNumbers_),
00067       ownerProc_(src.ownerProc_),
00068       hasSlaveDof_(src.hasSlaveDof_)
00069     {}
00070 
00072   virtual ~Record();
00073 
00075   void setID(const GlobalIDType& ID)
00076   {
00077     ID_ = ID;
00078   }
00079 
00081   GlobalIDType getID() const
00082   {
00083     return(ID_);
00084   }
00085 
00087   void setNumber(const GlobalIDType& num)
00088   {
00089     number_ = num;
00090   }
00091 
00093   GlobalIDType getNumber() const
00094   {
00095     return(number_);
00096   }
00097 
00099   bool operator==(const Record<GlobalIDType>& rcd) const
00100   {
00101     return( ID_ == rcd.ID_ );
00102   }
00103 
00105   bool operator!=(const Record<GlobalIDType>& rcd) const
00106   {
00107     return( ID_ != rcd.ID_ );
00108   }
00109 
00111   bool operator<(const Record<GlobalIDType>& rcd) const
00112   {
00113     return( ID_ < rcd.ID_ );
00114   }
00115 
00117   bool operator>(const Record<GlobalIDType>& rcd) const
00118   {
00119     return( ID_ > rcd.ID_ );
00120   }
00121 
00123   void setOwnerProc(int owner)
00124   {
00125     ownerProc_ = owner;
00126   }
00127 
00129   int getOwnerProc() const
00130   {
00131     return(ownerProc_);
00132   }
00133 
00135   void setFieldMask(fei::FieldMask* fm)
00136   {
00137     fieldMask_ = fm;
00138   }
00139 
00141   fei::FieldMask* getFieldMask()
00142   {
00143     return( fieldMask_ );
00144   }
00145 
00147   const fei::FieldMask* getFieldMask() const
00148   {
00149     return( fieldMask_ );
00150   }
00151 
00154   void setOffsetIntoEqnNumbers(int offset)
00155   {
00156     offsetIntoEqnNumbers_ = offset;
00157   }
00158 
00161   int getOffsetIntoEqnNumbers() const
00162   {
00163     return(offsetIntoEqnNumbers_);
00164   }
00165 
00166   bool hasSlaveDof() const
00167   { return( hasSlaveDof_ ); }
00168 
00169   void hasSlaveDof(bool flag)
00170   { hasSlaveDof_ = flag; }
00171 
00173   bool isInLocalSubdomain_;
00174 
00175   Record<GlobalIDType>& operator=(const Record<GlobalIDType>& src)
00176   {
00177     isInLocalSubdomain_ = src.isInLocalSubdomain_;
00178     ID_ = src.ID_;
00179     number_ = src.number_;
00180     fieldMask_ = src.fieldMask_;
00181     offsetIntoEqnNumbers_ = src.offsetIntoEqnNumbers_;
00182     ownerProc_ = src.ownerProc_;
00183     hasSlaveDof_ = src.hasSlaveDof_;
00184     return *this;
00185   }
00186 
00187 private:
00188 
00189   GlobalIDType ID_;
00190   GlobalIDType number_;
00191 
00192   fei::FieldMask* fieldMask_;
00193 
00194   int offsetIntoEqnNumbers_;
00195 
00196   int ownerProc_;
00197 
00198   bool hasSlaveDof_;
00199 };
00200 
00202 template<class GlobalIDType>
00203 class Record_Operator {
00204   public:
00206     virtual ~Record_Operator(){}
00207 
00209     virtual void operator()(Record<GlobalIDType>& record) = 0;
00210 
00211 };//class Record_Operator
00212 
00213 template<class GlobalIDType>
00214 fei::Record<GlobalIDType>::Record()
00215   : isInLocalSubdomain_(false),
00216     ID_(-1),
00217     number_(-1),
00218     fieldMask_(NULL),
00219     offsetIntoEqnNumbers_(0),
00220     ownerProc_(-1),
00221     hasSlaveDof_(false)
00222 {
00223 }
00224 
00225 template<class GlobalIDType>
00226 fei::Record<GlobalIDType>::~Record()
00227 {
00228 }
00229 
00230 
00231 } //namespace fei
00232 
00233 #endif // _fei_Record_hpp_
00234 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Friends