![]() |
Mesh Oriented datABase
(version 5.4.1)
Array-based unstructured mesh datastructure
|
00001 /**
00002 * MOAB, a Mesh-Oriented datABase, is a software component for creating,
00003 * storing and accessing finite element mesh data.
00004 *
00005 * Copyright 2004 Sandia Corporation. Under the terms of Contract
00006 * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
00007 * retains certain rights in this software.
00008 *
00009 * This library is free software; you can redistribute it and/or
00010 * modify it under the terms of the GNU Lesser General Public
00011 * License as published by the Free Software Foundation; either
00012 * version 2.1 of the License, or (at your option) any later version.
00013 *
00014 */
00015
00016 //-------------------------------------------------------------------------
00017 // Filename : WriteCCMIO.hpp
00018 //
00019 // Purpose : ExodusII writer
00020 //
00021 // Special Notes : Lots of code taken from verde implementation
00022 //
00023 // Creator : Corey Ernst
00024 //
00025 // Date : 8/02
00026 //
00027 // Owner : Corey Ernst
00028 //-------------------------------------------------------------------------
00029
00030 #ifndef WRITECCMIO_HPP
00031 #define WRITECCMIO_HPP
00032
00033 #ifndef IS_BUILDING_MB
00034 #error "WriteCCMIO.hpp isn't supposed to be included into an application"
00035 #endif
00036
00037 #include
00038 #include
00039
00040 #include "moab/Forward.hpp"
00041 #include "moab/Range.hpp"
00042 #include "moab/ExoIIInterface.hpp"
00043 #include "moab/WriterIface.hpp"
00044 #include "ccmio.h"
00045
00046 namespace moab
00047 {
00048
00049 class WriteUtilIface;
00050
00051 class WriteCCMIO : public WriterIface
00052 {
00053
00054 public:
00055 //! Constructor
00056 WriteCCMIO( Interface* impl );
00057
00058 //! Destructor
00059 virtual ~WriteCCMIO();
00060
00061 static WriterIface* factory( Interface* );
00062
00063 //! writes out a file
00064 ErrorCode write_file( const char* file_name,
00065 const bool overwrite,
00066 const FileOptions& opts,
00067 const EntityHandle* output_list,
00068 const int num_sets,
00069 const std::vector< std::string >& qa_list,
00070 const Tag* tag_list = NULL,
00071 int num_tags = 0,
00072 int export_dimension = 3 );
00073
00074 protected:
00075 //! number of dimensions in this file
00076 // int number_dimensions();
00077
00078 //! open a file for writing
00079 ErrorCode open_file( const char* filename, bool overwrite, CCMIOID& rootID );
00080
00081 //! contains the general information about a mesh
00082 class MeshInfo
00083 {
00084 public:
00085 unsigned int num_dim;
00086 unsigned int num_nodes;
00087 unsigned int num_elements;
00088 unsigned int num_matsets;
00089 unsigned int num_dirsets;
00090 unsigned int num_neusets;
00091 Range nodes;
00092
00093 MeshInfo()
00094 : num_dim( 0 ), num_nodes( 0 ), num_elements( 0 ), num_matsets( 0 ), num_dirsets( 0 ), num_neusets( 0 )
00095 {
00096 }
00097 };
00098
00099 // material set information
00100 class MaterialSetData
00101 {
00102 public:
00103 Range elems; // elements in material set
00104 EntityHandle setHandle; // handle of the material set
00105 EntityType entityType; // entity type of these elements
00106 int verts_per_element; // number of vertices in each element
00107 int matsetId; // id of this matset, from MATERIAL_SET tag
00108 int materialId; // materialid, if any (from CCMIO)
00109 std::string setName; // name for this matset, if any
00110 std::string materialType; // material type for this matset, if any
00111
00112 MaterialSetData()
00113 : setHandle( 0 ), entityType( MBMAXTYPE ), verts_per_element( 0 ), matsetId( -1 ), materialId( -1 )
00114
00115 {
00116 }
00117 };
00118
00119 // neumann set information
00120 class NeumannSetData
00121 {
00122 public:
00123 Range elems; // elements in neumann set
00124 EntityHandle setHandle; // handle of the neumann set
00125 EntityType entityType; // entity type of these elements
00126 int verts_per_element; // number of vertices in each element
00127 int neusetId; // id of this matset, from NEUMANN_SET tag
00128 std::string setName; // name for this neuset, if any
00129
00130 NeumannSetData() : setHandle( 0 ), entityType( MBMAXTYPE ), verts_per_element( 0 ), neusetId( -1 ) {}
00131 };
00132
00133 private:
00134 //! interface instance
00135 Interface* mbImpl;
00136 WriteUtilIface* mWriteIface;
00137
00138 //! file name
00139 std::string fileName;
00140
00141 //! Meshset Handle for the mesh that is currently being read
00142 EntityHandle mCurrentMeshHandle;
00143
00144 //! Cached tags for reading. Note that all these tags are defined when the
00145 //! core is initialized.
00146 Tag mMaterialSetTag;
00147 Tag mDirichletSetTag;
00148 Tag mNeumannSetTag;
00149 Tag mPartitionSetTag;
00150 Tag mHasMidNodesTag;
00151 Tag mGlobalIdTag;
00152 Tag mNameTag, mMaterialIdTag, mMaterialTypeTag;
00153 Tag mRadiationTag, mPorosityIdTag, mSpinIdTag, mGroupIdTag, mColorIdxTag, mProcessorIdTag, mLightMaterialTag,
00154 mFreeSurfaceMaterialTag;
00155 Tag mThicknessTag, mProstarRegionNumberTag, mBoundaryTypeTag, mCreatingProgramTag;
00156
00157 Tag mEntityMark; // used to say whether an entity will be exported
00158
00159 int mDimension; // dimension of entities being exported
00160
00161 bool mWholeMesh; // if true, whole mesh is being output
00162
00163 //! gathers elements in each matset, and all the vertices used by them;
00164 //! marks the vertices with the mEntityMark bit flag
00165 ErrorCode gather_matset_info( std::vector< EntityHandle >& matsets,
00166 std::vector< MaterialSetData >& matset_data,
00167 Range& all_verts );
00168
00169 //! gathers elements in each neuset
00170 ErrorCode gather_neuset_info( std::vector< EntityHandle >& neusets, std::vector< NeumannSetData >& neuset_data );
00171
00172 ErrorCode close_and_compress( const char* filename, CCMIOID rootID );
00173
00174 ErrorCode initialize_file( MeshInfo& mesh_info );
00175
00176 //! write vertices to file
00177 ErrorCode write_nodes( CCMIOID rootID, const Range& nodes, const int dimension, CCMIOID& verticesID );
00178
00179 //! write cells and internal/boundary faces, using vgids and verts input
00180 ErrorCode write_cells_and_faces( CCMIOID rootID,
00181 std::vector< WriteCCMIO::MaterialSetData >& matset_data,
00182 std::vector< WriteCCMIO::NeumannSetData >& neuset_data,
00183 Range& verts,
00184 CCMIOID& topologyID );
00185
00186 //! write external faces, including connectivity and connected cells
00187 ErrorCode write_external_faces( CCMIOID rootID, CCMIOID topologyID, int set_num, Range& facets );
00188
00189 // get global ids for these entities; allocates gids and passes back,
00190 // caller is responsible for deleting
00191 ErrorCode get_gids( const Range& ents, int*& gids, int& minid, int& maxid );
00192
00193 ErrorCode write_meshes( MeshInfo& mesh_info,
00194 std::vector< MaterialSetData >& matset_data,
00195 std::vector< NeumannSetData >& neuset_data,
00196 Range& verts,
00197 const int* vgids );
00198
00199 ErrorCode get_valid_sides( Range& elems, const int sense, WriteCCMIO::NeumannSetData& neuset_data );
00200
00201 void reset_matset( std::vector< MaterialSetData >& matset_info );
00202
00203 ErrorCode get_neuset_elems( EntityHandle neuset, int current_sense, Range& forward_elems, Range& reverse_elems );
00204
00205 ErrorCode transform_coords( const int dimension, const int num_nodes, double* coords );
00206
00207 ErrorCode write_problem_description( CCMIOID rootID,
00208 CCMIOID stateID,
00209 CCMIOID& problemID,
00210 CCMIOID processorID,
00211 std::vector< MaterialSetData >& matset_data,
00212 std::vector< NeumannSetData >& neuset_data );
00213
00214 // get the material, dirichlet, neumann, and partition sets to be written,
00215 // either from input sets or in the whole mesh
00216 ErrorCode get_sets( const EntityHandle* ent_handles,
00217 int num_sets,
00218 std::vector< EntityHandle >& matsets,
00219 std::vector< EntityHandle >& dirsets,
00220 std::vector< EntityHandle >& neusets,
00221 std::vector< EntityHandle >& partsets );
00222
00223 //! create state and processor nodes
00224 ErrorCode create_ccmio_structure( CCMIOID rootID, CCMIOID& stateID, CCMIOID& processorID );
00225
00226 //! write solution (tag) data
00227 ErrorCode write_solution_data();
00228
00229 //! finalize processor
00230 ErrorCode write_processor( CCMIOID processorID, CCMIOID verticesID, CCMIOID topologyID );
00231
00232 //! convert MOAB to CCMIO type
00233 int moab_to_ccmio_type( EntityType etype, int has_mid_nodes[] );
00234
00235 ErrorCode write_int_option( const char* opt_name, EntityHandle seth, Tag& tag, CCMIOID& node );
00236
00237 ErrorCode write_dbl_option( const char* opt_name, EntityHandle seth, Tag& tag, CCMIOID& node );
00238
00239 ErrorCode write_str_option( const char* opt_name,
00240 EntityHandle seth,
00241 Tag& tag,
00242 CCMIOID& node,
00243 const char* other_name = NULL );
00244 };
00245
00246 } // namespace moab
00247
00248 #endif