AFEPack
MPI_DOF.h
浏览该文件的文档。
00001 
00011 #ifndef __MPI_DOF_h__
00012 #define __MPI_DOF_h__
00013 
00014 #include "MPI_HGeometry.h"
00015 
00016 namespace MPI {
00017   namespace DOF {
00018 
00019     template <class FOREST, class FESPACE>
00020       class GlobalIndex : private std::vector<int> {
00021     public:
00022     typedef FOREST forest_t;
00023     typedef FESPACE fe_space_t;
00024     private:
00025     typedef std::vector<int> base_t;
00026     typedef GlobalIndex<forest_t,fe_space_t> this_t;
00027 
00028     const forest_t * _forest;
00029     const fe_space_t * _fe_sp;
00030 
00031     u_int _n_global_dof;
00032     u_int _n_primary_dof;
00033     int _first_idx;
00034 
00035     property_id_t<BinaryBuffer<> > _pid_global_idx;
00036 
00037     enum { UNUSED_IDX = -1 };
00038 
00039     public:
00040     GlobalIndex() : _forest(NULL), _fe_sp(NULL) {}
00041     explicit GlobalIndex(const forest_t& forest) :
00042     _forest(&forest), _fe_sp(NULL) {}
00043     GlobalIndex(const forest_t& forest, const fe_space_t& fe_sp) :
00044     _forest(&forest), _fe_sp(&fe_sp) {}
00045     GlobalIndex(const this_t& gi) :
00046     base_t(gi), _forest(gi._forest), _fe_sp(gi._fe_sp) {}
00047     
00048     this_t& operator=(const this_t& gi) {
00049       base_t::operator=(gi);
00050       _forest = gi._forest;
00051       _fe_sp = gi._fe_sp;
00052     }
00053 
00055 
00058     const forest_t& forest() const { return *_forest; }
00059     void set_forest(const forest_t& forest) { _forest = &forest; }
00061     
00063 
00066     const fe_space_t& fe_space() const { return *_fe_sp; }
00067     void set_fe_space(const fe_space_t& fe_sp) { _fe_sp = &fe_sp; }
00069 
00071 
00076     u_int n_global_dof() const { return _n_global_dof; } 
00077     u_int n_primary_dof() const { return _n_primary_dof; }
00078     u_int n_local_dof() const { return base_t::size(); }
00079     int first_index() const { return _first_idx; }
00080     int last_index() const { return _first_idx + _n_primary_dof - 1; }
00082 
00086     void build();
00090     void build_primary_index(int * idx_ptr) const;
00091 
00093 
00096     template <class MAP> void build_epetra_map(MAP& map) const;
00097     template <class MAP, class INVMAP> void 
00098       build_epetra_map(MAP& map, INVMAP& inv_map) const;
00100 
00102 
00114     template <class INVEC, class OUTVEC> void
00115     scatter_hypre_vector(INVEC& iv, OUTVEC& ov) const;
00117 
00119 
00122     const int& operator()(u_int i) const { return base_t::operator[](i); }
00123     int& operator()(u_int i) { return base_t::operator[](i); }
00125 
00129     template <class LC, class GC> void
00130       translate(const LC& lc, GC& gc) const;
00131 
00133 
00136     template <int GDIM> void
00137       pack_global_idx(HGeometry<GDIM,fe_space_t::dow> * geo,
00138                       int remote_rank,
00139                       AFEPack::ostream<>& os);
00140     template <int GDIM> void
00141       unpack_global_idx(HGeometry<GDIM,fe_space_t::dow> * geo,
00142                         int remote_rank,
00143                         AFEPack::istream<>& is);
00145 
00147     bool is_dof_on_primary_geometry(u_int i) const;
00148 
00150     int dof_primary_rank(u_int i) const;
00151 
00152     private:
00154     bool _is_dof_on_primary_geometry(u_int i) const;
00155 
00156     void sync_idx(); 
00157 
00158     std::vector<bool> _idopg; 
00159     };
00160 
00161 #include "MPI_DOF.templates.h"
00162   }
00163 }
00164 
00165 
00166 #endif // __MPI_DOF_h__
00167