Sierra Toolkit Version of the Day
DofMapper.hpp
00001 /*------------------------------------------------------------------------*/
00002 /*                 Copyright 2010 Sandia Corporation.                     */
00003 /*  Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive   */
00004 /*  license for use of this work by or on behalf of the U.S. Government.  */
00005 /*  Export of this program may require a license from the                 */
00006 /*  United States Government.                                             */
00007 /*------------------------------------------------------------------------*/
00008 
00009 #ifndef stk_linsys_DofMapper_hpp
00010 #define stk_linsys_DofMapper_hpp
00011 
00012 #include <map>
00013 
00014 #include <stk_util/parallel/Parallel.hpp>
00015 #include <stk_mesh/base/Field.hpp>
00016 #include <stk_mesh/base/BulkData.hpp>
00017 
00018 #include <stk_linsys/FieldIdMap.hpp>
00019 #include <stk_linsys/FeiBaseIncludes.hpp>
00020 
00021 namespace stk {
00024 namespace linsys {
00025 
00052 class DofMapper {
00053  public:
00055   DofMapper(MPI_Comm comm, bool create_reverse_mappings=true);
00056 
00058 //  DofMapper(fei::SharedPtr<fei::VectorSpace> vspace, bool create_reverse_mappings=true);
00059 
00061   virtual ~DofMapper();
00062 
00071   void add_dof_mappings( const stk::mesh::BulkData& mesh_bulk,
00072                          const stk::mesh::Selector& selector,
00073                          stk::mesh::EntityRank ent_type,
00074                          const stk::mesh::FieldBase& field );
00075 
00084   void finalize();
00085 
00089   bool reverse_mappings_enabled() const { return m_reverse_mappings_enabled; }
00090 
00094   int get_field_id(const stk::mesh::FieldBase& field) const;
00095 
00103   int get_global_index(stk::mesh::EntityRank ent_type,
00104                        stk::mesh::EntityId ent_id,
00105                        stk::mesh::FieldBase& field,
00106                        int offset_into_field=0);
00107 
00113   void get_dof(int global_index,
00114                stk::mesh::EntityRank& ent_type,
00115                stk::mesh::EntityId& ent_id,
00116                const stk::mesh::FieldBase*& field,
00117                int& offset_into_field) const;
00118 
00121   const fei::SharedPtr<fei::VectorSpace> get_fei_VectorSpace() const { return m_fei_vecspace; }
00122 
00125   fei::SharedPtr<fei::VectorSpace> get_fei_VectorSpace() { return m_fei_vecspace; }
00126 
00127   const FieldIdMap& get_FieldIdMap() const { return m_field_id_map; }
00128 
00129   FieldIdMap& get_FieldIdMap() { return m_field_id_map; }
00130 
00131  private:
00132 
00133   FieldIdMap m_field_id_map;
00134 
00135   //we store the fei::VectorSpace in a fei::SharedPtr because other fei APIs expect it
00136   //to be that way. e.g., the constructor for fei::MatrixGraph requires a VectorSpace in a
00137   //fei::SharedPtr...
00138   fei::SharedPtr<fei::VectorSpace> m_fei_vecspace;
00139   bool m_reverse_mappings_enabled;
00140   fei::ReverseMapper* m_fei_reversemap;
00141 
00142   DofMapper(const DofMapper &);
00143   void operator = (const DofMapper &);
00144 };//class DofMapper
00145 
00148 }//namespace linsys
00149 }//namespace stk
00150 
00151 #endif
00152 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends