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 
00082 template <typename T>
00083 void default_part_processing(const std::vector<T*> &entities,
00084            stk::mesh::fem::FEMMetaData &fem_meta)
00085 {
00086   for(size_t i=0; i < entities.size(); i++) {
00087     T* entity = entities[i];
00088     internal_part_processing(entity, fem_meta);
00089   }
00090 }
00091 
00093 template <typename T>
00094 void default_part_processing(const std::vector<T*> &entities, stk::mesh::MetaData &meta,
00095                              stk::mesh::EntityRank)
00096 {
00097   stk::mesh::fem::FEMMetaData &fem_meta = stk::mesh::fem::FEMMetaData::get(meta);
00098   default_part_processing (entities, fem_meta);
00099 }
00100 
00112 void define_output_db( Ioss::Region & io_region,
00113                        const mesh::BulkData& bulk_data,
00114                        const Ioss::Region *input_region = NULL);
00115 
00123 void write_output_db( Ioss::Region & io_region ,
00124                       const mesh::BulkData& bulk);
00125 
00126 
00127 //----------------------------------------------------------------------
00128 
00149 bool is_valid_part_field(const stk::mesh::FieldBase *field,
00150                          stk::mesh::EntityRank part_type,
00151                          stk::mesh::Part &part,
00152                          stk::mesh::Part &universal,
00153                          Ioss::Field::RoleType filter_role,
00154                          bool add_all = false);
00155 
00161 void ioss_add_fields(stk::mesh::Part &part,
00162                      stk::mesh::EntityRank part_type,
00163                      Ioss::GroupingEntity *entity,
00164                      const Ioss::Field::RoleType filter_role,
00165                      bool add_all = false);
00166 
00179 void define_io_fields(Ioss::GroupingEntity *entity,
00180                       Ioss::Field::RoleType role,
00181                       stk::mesh::Part &part,
00182                       stk::mesh::EntityRank part_type);
00183 
00188 const CellTopologyData *map_topology_ioss_to_cell(const Ioss::ElementTopology *topology);
00189 
00195 std::string map_topology_cell_to_ioss( const CellTopologyData *cell_top,
00196                                        int spatial_dimension);
00197 
00209 void get_entity_list(Ioss::GroupingEntity *io_entity,
00210                      stk::mesh::EntityRank part_type,
00211                      const stk::mesh::BulkData &bulk,
00212                      std::vector<stk::mesh::Entity*> &entities);
00213 
00220 void field_data_from_ioss(const stk::mesh::FieldBase *field,
00221                           std::vector<stk::mesh::Entity*> &entities,
00222                           Ioss::GroupingEntity *io_entity,
00223                           const std::string &io_fld_name);
00224 
00231 void field_data_to_ioss(const stk::mesh::FieldBase *field,
00232                         std::vector<stk::mesh::Entity*> &entities,
00233                         Ioss::GroupingEntity *io_entity,
00234                         const std::string &io_fld_name,
00235       Ioss::Field::RoleType filter_role);
00236 
00237 
00242 const mesh::Field<double, mesh::ElementNode> *get_distribution_factor_field(const mesh::Part &p);
00243 
00247 void set_distribution_factor_field(mesh::Part &p,
00248                                    const mesh::Field<double, mesh::ElementNode> &df_field);
00249 
00255 const Ioss::Field::RoleType* get_field_role(const mesh::FieldBase &f);
00256 
00260 void set_field_role(mesh::FieldBase &f, const Ioss::Field::RoleType &role);
00261 
00270 bool is_part_io_part(mesh::Part &part);
00271 
00275 void put_io_part_attribute( mesh::Part &part, Ioss::GroupingEntity *entity = NULL);
00276 
00277 const Ioss::GroupingEntity *get_associated_ioss_entity(const mesh::Part &part);
00278 
00279 void internal_part_processing(Ioss::GroupingEntity *entity, stk::mesh::fem::FEMMetaData &meta);
00280 
00281 void internal_part_processing(Ioss::EntityBlock *entity, stk::mesh::fem::FEMMetaData &meta);
00282 
00284 void internal_part_processing(Ioss::GroupingEntity *entity, stk::mesh::MetaData &meta);
00285 
00287 void internal_part_processing(Ioss::EntityBlock *entity, stk::mesh::MetaData &meta);
00288 
00289 // To minimize ifdefs for the deprecated code:
00290 bool invalid_rank(mesh::EntityRank rank);
00291 mesh::EntityRank part_primary_entity_rank(const mesh::Part &part);
00292 mesh::EntityRank element_rank(const mesh::MetaData &meta);
00293 mesh::EntityRank side_rank(const mesh::MetaData &meta);
00294 mesh::EntityRank face_rank(const mesh::MetaData &meta);
00295 mesh::EntityRank edge_rank(const mesh::MetaData &meta);
00296 mesh::EntityRank node_rank(const mesh::MetaData &meta);
00297 void set_cell_topology(mesh::Part &part, const CellTopologyData * const cell_topology);
00298 const CellTopologyData *get_cell_topology(const mesh::Part &part);
00299 
00300 void initialize_spatial_dimension(mesh::fem::FEMMetaData &fem_meta, size_t spatial_dimension, const std::vector<std::string> &entity_rank_names);
00301 
00303 void initialize_spatial_dimension(mesh::MetaData &meta, size_t spatial_dimension, const std::vector<std::string> &entity_rank_names);
00304 
00305 void get_io_field_type(const stk::mesh::FieldBase *field,
00306                        const stk::mesh::FieldRestriction &res,
00307            std::pair<std::string, Ioss::Field::BasicType> *result);
00312 }//namespace io
00313 }//namespace stk
00314 #endif
00315 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends