Sierra Toolkit Version of the Day
FEMHelpers.hpp
00001 /*------------------------------------------------------------------------*/
00002 /*                 Copyright 2010, 2011 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_mesh_FEMHelpers_hpp
00010 #define stk_mesh_FEMHelpers_hpp
00011 
00012 #include <stk_mesh/base/Types.hpp>
00013 
00014 #include <stk_mesh/fem/FEMMetaData.hpp>
00015 #include <stk_mesh/fem/CellTopology.hpp>
00016 // This is needed for ElementNode class
00017 #include <stk_mesh/fem/TopologyDimensions.hpp>
00018 
00019 namespace stk {
00020 namespace mesh {
00021 
00022 class Bucket;
00023 class Entity;
00024 
00025 namespace fem {
00026 
00031 //----------------------------------------------------------------------
00035 Entity & declare_element( BulkData & mesh ,
00036                           Part & part ,
00037                           const EntityId elem_id ,
00038                           const EntityId node_id[] );
00039 
00040 
00045 Entity & declare_element_side( BulkData & mesh ,
00046                                const stk::mesh::EntityId global_side_id ,
00047                                Entity & elem ,
00048                                const unsigned local_side_id ,
00049                                Part * part = NULL );
00050 
00054 bool element_side_polarity( const Entity & elem ,
00055                             const Entity & side , int local_side_id = -1 );
00056 
00061 Entity & declare_element_side( Entity & elem ,
00062                                Entity & side ,
00063                                const unsigned local_side_id ,
00064                                Part * part = NULL );
00065 
00066 
00067 
00071 template< class Top >
00072 Part &declare_part(FEMMetaData& meta_data, const std::string &name) {
00073   return meta_data.declare_part(name, shards::getCellTopologyData<Top>());
00074 }
00075 
00087 const CellTopologyData * get_subcell_nodes(
00088     const Entity     & entity ,
00089     EntityRank         subcell_rank ,
00090     unsigned           subcell_identifier ,
00091     EntityVector     & subcell_nodes
00092     );
00093 
00098 int get_entity_subcell_id( const Entity            & entity ,
00099                            const EntityRank          subcell_rank,
00100                            const CellTopologyData  * side_topology,
00101                            const EntityVector      & side_nodes );
00102 
00104 bool comm_mesh_counts( BulkData & ,
00105                        std::vector<size_t> & counts ,
00106                        bool = false );
00107 
00108 typedef Field<double*,stk::mesh::ElementNode> ElementNodePointerField ;
00109 
00112 template< class NodeField >
00113 inline
00114 ElementNodePointerField &
00115 declare_element_node_pointer_field(
00116   FEMMetaData & fmd , const std::string & s ,
00117   NodeField & node_field )
00118 {
00119   const unsigned num_states = node_field.number_of_states();
00120 
00121   ElementNodePointerField & f =
00122     fmd.template declare_field< ElementNodePointerField >( s, num_states );
00123 
00124   for ( unsigned i = 0 ; i < num_states ; ++i ) {
00125     FieldState state = (FieldState) i;
00126     fmd.declare_field_relation(
00127       f.field_of_state( state ) ,
00128       fem::get_element_node_stencil(fmd.spatial_dimension()) ,
00129       node_field.field_of_state( state ) );
00130   }
00131 
00132   return f ;
00133 }
00134 
00135 template< class Traits >
00136 void get_parts_with_topology(stk::mesh::BulkData& mesh,
00137                              stk::mesh::PartVector& parts,
00138                              bool skip_topology_root_parts=false)
00139 {
00140   parts.clear();
00141 
00142   stk::mesh::fem::FEMMetaData & fem_meta = stk::mesh::fem::FEMMetaData::get(mesh);
00143 
00144   const stk::mesh::PartVector& all_parts = fem_meta.get_parts();
00145 
00146   stk::mesh::PartVector::const_iterator
00147     iter = all_parts.begin(),
00148     iter_end = all_parts.end();
00149 
00150   const CellTopologyData* topology = shards::getCellTopologyData<Traits>();
00151 
00152   for(; iter!=iter_end; ++iter) {
00153     stk::mesh::Part* part =  *iter;
00154     if (fem_meta.get_cell_topology(*part).getCellTopologyData() == topology) {
00155       if (skip_topology_root_parts && stk::mesh::fem::is_cell_topology_root_part(*part)) {
00156         continue;
00157       }
00158       parts.push_back(part);
00159     }
00160   }
00161 }
00162 
00165 } //namespace fem
00166 } //namespace mesh
00167 } //namespace stk
00168 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends