Sierra Toolkit Version of the Day
IossBridge.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_io_IossBridge_hpp
00010 #define stk_io_IossBridge_hpp
00011 
00012 #include <string>
00013 #include <stk_util/parallel/Parallel.hpp>
00014 #include <stk_mesh/base/Types.hpp>
00015 #include <stk_mesh/fem/CoordinateSystems.hpp>
00016 #include <stk_mesh/fem/FEMMetaData.hpp>
00017 
00018 // TODO: remove this and uses of USE_FEMMETADATA once the migration is done (srkenno@sandia.gov)
00019 
00020 #define USE_FEMMETADATA
00021 #ifdef USE_FEMMETADATA
00022 #include <stk_mesh/fem/FEMHelpers.hpp>
00023 #endif
00024 
00025 #include <stk_mesh/fem/TopologyDimensions.hpp>
00026 #include <Ioss_DBUsage.h>
00027 #include <Ioss_Field.h>
00028 #include <Ioss_SideBlock.h>
00029 #include <Ioss_ElementTopology.h>
00030 
00031 namespace Ioss {
00032   class Region;
00033   class GroupingEntity;
00034   class EntityBlock;
00035   class SideSet;
00036   class Field;
00037   class ElementTopology;
00038 }
00039 
00040 class CellTopologyData;
00041 
00042 namespace stk {
00043 
00057 namespace io {
00058 
00070 bool include_entity(Ioss::GroupingEntity *entity);
00071 
00072 void internal_part_processing(Ioss::GroupingEntity *entity, stk::mesh::fem::FEMMetaData &meta);
00073 
00074 void internal_part_processing(Ioss::EntityBlock *entity, stk::mesh::fem::FEMMetaData &meta);
00075 
00077 void internal_part_processing(Ioss::GroupingEntity *entity, stk::mesh::MetaData &meta);
00078 
00080 void internal_part_processing(Ioss::EntityBlock *entity, stk::mesh::MetaData &meta);
00081 
00092 template <typename T>
00093 void default_part_processing(const std::vector<T*> &entities,
00094            stk::mesh::fem::FEMMetaData &fem_meta)
00095 {
00096   for(size_t i=0; i < entities.size(); i++) {
00097     T* entity = entities[i];
00098     internal_part_processing(entity, fem_meta);
00099   }
00100 }
00101 
00103 template <typename T>
00104 void default_part_processing(const std::vector<T*> &entities, stk::mesh::MetaData &meta,
00105                              stk::mesh::EntityRank)
00106 {
00107   stk::mesh::fem::FEMMetaData &fem_meta = stk::mesh::fem::FEMMetaData::get(meta);
00108   default_part_processing (entities, fem_meta);
00109 }
00110 
00122 void define_output_db( Ioss::Region & io_region,
00123                        const mesh::BulkData& bulk_data,
00124                        const Ioss::Region *input_region = NULL);
00125 
00133 void write_output_db( Ioss::Region & io_region ,
00134                       const mesh::BulkData& bulk);
00135 
00136 
00137 //----------------------------------------------------------------------
00138 
00159 bool is_valid_part_field(const stk::mesh::FieldBase *field,
00160                          stk::mesh::EntityRank part_type,
00161                          stk::mesh::Part &part,
00162                          stk::mesh::Part &universal,
00163                          Ioss::Field::RoleType filter_role,
00164                          bool add_all = false);
00165 
00171 void ioss_add_fields(stk::mesh::Part &part,
00172                      stk::mesh::EntityRank part_type,
00173                      Ioss::GroupingEntity *entity,
00174                      const Ioss::Field::RoleType filter_role,
00175                      bool add_all = false);
00176 
00189 void define_io_fields(Ioss::GroupingEntity *entity,
00190                       Ioss::Field::RoleType role,
00191                       stk::mesh::Part &part,
00192                       stk::mesh::EntityRank part_type);
00193 
00198 const CellTopologyData *map_topology_ioss_to_cell(const Ioss::ElementTopology *topology);
00199 
00205 std::string map_topology_cell_to_ioss( const CellTopologyData *cell_top,
00206                                        int spatial_dimension);
00207 
00219 void get_entity_list(Ioss::GroupingEntity *io_entity,
00220                      stk::mesh::EntityRank part_type,
00221                      const stk::mesh::BulkData &bulk,
00222                      std::vector<stk::mesh::Entity*> &entities);
00223 
00230 void field_data_from_ioss(const stk::mesh::FieldBase *field,
00231                           std::vector<stk::mesh::Entity*> &entities,
00232                           Ioss::GroupingEntity *io_entity,
00233                           const std::string &io_fld_name);
00234 
00241 void field_data_to_ioss(const stk::mesh::FieldBase *field,
00242                         std::vector<stk::mesh::Entity*> &entities,
00243                         Ioss::GroupingEntity *io_entity,
00244                         const std::string &io_fld_name,
00245       Ioss::Field::RoleType filter_role);
00246 
00247 
00252 const mesh::Field<double, mesh::ElementNode> *get_distribution_factor_field(const mesh::Part &p);
00253 
00257 void set_distribution_factor_field(mesh::Part &p,
00258                                    const mesh::Field<double, mesh::ElementNode> &df_field);
00259 
00265 const Ioss::Field::RoleType* get_field_role(const mesh::FieldBase &f);
00266 
00270 void set_field_role(mesh::FieldBase &f, const Ioss::Field::RoleType &role);
00271 
00280 bool is_part_io_part(mesh::Part &part);
00281 
00285 void put_io_part_attribute( mesh::Part &part, Ioss::GroupingEntity *entity = NULL);
00286 
00290 void remove_io_part_attribute(mesh::Part &part);
00291 
00292 const Ioss::GroupingEntity *get_associated_ioss_entity(const mesh::Part &part);
00293 
00294 // To minimize ifdefs for the deprecated code:
00295 bool invalid_rank(mesh::EntityRank rank);
00296 mesh::EntityRank part_primary_entity_rank(const mesh::Part &part);
00297 mesh::EntityRank element_rank(const mesh::MetaData &meta);
00298 mesh::EntityRank side_rank(const mesh::MetaData &meta);
00299 mesh::EntityRank face_rank(const mesh::MetaData &meta);
00300 mesh::EntityRank edge_rank(const mesh::MetaData &meta);
00301 mesh::EntityRank node_rank(const mesh::MetaData &meta);
00302 void set_cell_topology(mesh::Part &part, const CellTopologyData * const cell_topology);
00303 const CellTopologyData *get_cell_topology(const mesh::Part &part);
00304 
00305 void initialize_spatial_dimension(mesh::fem::FEMMetaData &fem_meta, size_t spatial_dimension, const std::vector<std::string> &entity_rank_names);
00306 
00308 void initialize_spatial_dimension(mesh::MetaData &meta, size_t spatial_dimension, const std::vector<std::string> &entity_rank_names);
00309 
00310 void get_io_field_type(const stk::mesh::FieldBase *field,
00311                        const stk::mesh::FieldRestriction &res,
00312            std::pair<std::string, Ioss::Field::BasicType> *result);
00317 }//namespace io
00318 }//namespace stk
00319 #endif
00320 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends