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 
00055 Entity & declare_element_edge( BulkData & mesh ,
00056                                const stk::mesh::EntityId global_side_id ,
00057                                Entity & elem ,
00058                                const unsigned local_side_id ,
00059                                Part * part = NULL );
00060 
00064 bool element_side_polarity( const Entity & elem ,
00065                             const Entity & side , int local_side_id = -1 );
00066 
00071 Entity & declare_element_side( Entity & elem ,
00072                                Entity & side ,
00073                                const unsigned local_side_id ,
00074                                Part * part = NULL );
00075 
00076 
00077 
00082 Entity & declare_element_edge( Entity & elem ,
00083                                Entity & edge ,
00084                                const unsigned local_edge_id ,
00085                                Part * part = NULL );
00086 
00087 
00088 
00092 template< class Top >
00093 Part &declare_part(FEMMetaData& meta_data, const std::string &name) {
00094   return meta_data.declare_part(name, shards::getCellTopologyData<Top>());
00095 }
00096 
00108 const CellTopologyData * get_subcell_nodes(
00109     const Entity     & entity ,
00110     EntityRank         subcell_rank ,
00111     unsigned           subcell_identifier ,
00112     EntityVector     & subcell_nodes
00113     );
00114 
00119 int get_entity_subcell_id( const Entity            & entity ,
00120                            const EntityRank          subcell_rank,
00121                            const CellTopologyData  * side_topology,
00122                            const EntityVector      & side_nodes );
00123 
00125 bool comm_mesh_counts( BulkData & ,
00126                        std::vector<size_t> & counts ,
00127                        bool = false );
00128 
00129 typedef Field<double*,stk::mesh::ElementNode> ElementNodePointerField ;
00130 
00133 template< class NodeField >
00134 inline
00135 ElementNodePointerField &
00136 declare_element_node_pointer_field(
00137   FEMMetaData & fmd , const std::string & s ,
00138   NodeField & node_field )
00139 {
00140   const unsigned num_states = node_field.number_of_states();
00141 
00142   ElementNodePointerField & f =
00143     fmd.template declare_field< ElementNodePointerField >( s, num_states );
00144 
00145   for ( unsigned i = 0 ; i < num_states ; ++i ) {
00146     FieldState state = (FieldState) i;
00147     fmd.declare_field_relation(
00148       f.field_of_state( state ) ,
00149       fem::get_element_node_stencil(fmd.spatial_dimension()) ,
00150       node_field.field_of_state( state ) );
00151   }
00152 
00153   return f ;
00154 }
00155 
00156 template< class Traits >
00157 void get_parts_with_topology(stk::mesh::BulkData& mesh,
00158                              stk::mesh::PartVector& parts,
00159                              bool skip_topology_root_parts=false)
00160 {
00161   parts.clear();
00162 
00163   stk::mesh::fem::FEMMetaData & fem_meta = stk::mesh::fem::FEMMetaData::get(mesh);
00164 
00165   const stk::mesh::PartVector& all_parts = fem_meta.get_parts();
00166 
00167   stk::mesh::PartVector::const_iterator
00168     iter = all_parts.begin(),
00169     iter_end = all_parts.end();
00170 
00171   const CellTopologyData* topology = shards::getCellTopologyData<Traits>();
00172 
00173   for(; iter!=iter_end; ++iter) {
00174     stk::mesh::Part* part =  *iter;
00175     if (fem_meta.get_cell_topology(*part).getCellTopologyData() == topology) {
00176       if (skip_topology_root_parts && stk::mesh::fem::is_cell_topology_root_part(*part)) {
00177         continue;
00178       }
00179       parts.push_back(part);
00180     }
00181   }
00182 }
00183 
00186 } //namespace fem
00187 } //namespace mesh
00188 } //namespace stk
00189 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends