moab
WriteCCMIO.hpp
Go to the documentation of this file.
00001 
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 <vector>
00038 #include <string>
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 class WriteUtilIface;
00049 
00050 class WriteCCMIO : public WriterIface
00051 {
00052  
00053 public:
00054 
00056    WriteCCMIO(Interface *impl);
00057 
00059   virtual ~WriteCCMIO();
00060   
00061   static WriterIface* factory( Interface* );
00062 
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 
00077   //int number_dimensions();
00078 
00080   ErrorCode open_file(const char *filename, bool overwrite, CCMIOID &rootID);
00081 
00083   class MeshInfo
00084   {
00085   public:
00086     unsigned int num_dim;
00087     unsigned int num_nodes;
00088     unsigned int num_elements;
00089     unsigned int num_matsets;
00090     unsigned int num_dirsets;
00091     unsigned int num_neusets;
00092     Range nodes;
00093 
00094     MeshInfo() 
00095         : num_dim(0), num_nodes(0), num_elements(0), num_matsets(0), 
00096           num_dirsets(0), num_neusets(0)
00097       {}
00098     
00099   };
00100 
00101     // material set information
00102   class MaterialSetData
00103   {
00104   public:
00105     Range elems; // elements in material set
00106     EntityHandle setHandle; // handle of the material set
00107     EntityType entityType; // entity type of these elements
00108     int verts_per_element; // number of vertices in each element
00109     int matsetId; // id of this matset, from MATERIAL_SET tag
00110     int materialId; // materialid, if any (from CCMIO)
00111     std::string setName; // name for this matset, if any
00112     std::string materialType; // material type for this matset, if any
00113 
00114     MaterialSetData() 
00115             : setHandle(0), entityType(MBMAXTYPE), verts_per_element(0), matsetId(-1),
00116               materialId(-1)
00117     
00118         {}
00119   };
00120   
00121     // neumann set information
00122   class NeumannSetData
00123   {
00124   public:
00125     Range elems; // elements in neumann set
00126     EntityHandle setHandle; // handle of the neumann set
00127     EntityType entityType; // entity type of these elements
00128     int verts_per_element; // number of vertices in each element
00129     int neusetId; // id of this matset, from NEUMANN_SET tag
00130     std::string setName; // name for this neuset, if any
00131 
00132     NeumannSetData() 
00133             : setHandle(0), entityType(MBMAXTYPE), verts_per_element(0), neusetId(-1)
00134         {}
00135   };
00136   
00137 private:
00138 
00140   Interface *mbImpl;
00141   WriteUtilIface* mWriteIface;
00142   
00144   std::string fileName;
00145 
00147   EntityHandle mCurrentMeshHandle;
00148 
00151   Tag mMaterialSetTag;
00152   Tag mDirichletSetTag;
00153   Tag mNeumannSetTag;
00154   Tag mPartitionSetTag;
00155   Tag mHasMidNodesTag;
00156   Tag mGlobalIdTag;
00157   Tag mNameTag, mMaterialIdTag, mMaterialTypeTag;
00158   Tag mRadiationTag, mPorosityIdTag, mSpinIdTag, mGroupIdTag, mColorIdxTag,
00159       mProcessorIdTag, mLightMaterialTag, mFreeSurfaceMaterialTag;
00160   Tag mThicknessTag, mProstarRegionNumberTag, mBoundaryTypeTag, mCreatingProgramTag;
00161 
00162   Tag mEntityMark;   //used to say whether an entity will be exported
00163 
00164   int mDimension; // dimension of entities being exported
00165 
00166   bool mWholeMesh; // if true, whole mesh is being output
00167 
00170   ErrorCode gather_matset_info(std::vector<EntityHandle> &matsets,
00171                                std::vector<MaterialSetData> &matset_data,
00172                                Range &all_verts);
00173   
00175   ErrorCode gather_neuset_info(std::vector<EntityHandle> &neusets,
00176                                std::vector<NeumannSetData> &neuset_data);
00177   
00178   ErrorCode close_and_compress(const char *filename, CCMIOID rootID);
00179     
00180   ErrorCode initialize_file(MeshInfo &mesh_info);
00181 
00183   ErrorCode write_nodes(CCMIOID rootID, const Range& nodes, const int dimension, CCMIOID &verticesID);
00184   
00186   ErrorCode write_cells_and_faces(CCMIOID rootID, 
00187                                   std::vector<WriteCCMIO::MaterialSetData> &matset_data,
00188                                   std::vector<WriteCCMIO::NeumannSetData> &neuset_data,
00189                                   Range &verts, CCMIOID &topologyID);
00190 
00192   ErrorCode write_external_faces(CCMIOID rootID, CCMIOID topologyID, int set_num, Range &facets);
00193   
00194     // get global ids for these entities; allocates gids and passes back,
00195     // caller is responsible for deleting
00196   ErrorCode get_gids(const Range &ents, int *&gids,
00197                        int &minid, int &maxid);
00198   
00199   ErrorCode write_meshes(MeshInfo &mesh_info, 
00200                             std::vector<MaterialSetData> &matset_data,
00201                             std::vector<NeumannSetData> &neuset_data,
00202                             Range &verts,
00203                             const int *vgids);
00204   
00205   ErrorCode get_valid_sides(Range &elems, const int sense,
00206                               WriteCCMIO::NeumannSetData &neuset_data);
00207   
00208   void reset_matset(std::vector<MaterialSetData> &matset_info);
00209   
00210   ErrorCode get_neuset_elems(EntityHandle neuset, int current_sense,
00211                                Range &forward_elems, Range &reverse_elems);
00212   
00213   ErrorCode transform_coords(const int dimension, const int num_nodes, double *coords);
00214 
00215   ErrorCode write_problem_description(CCMIOID rootID, CCMIOID stateID, CCMIOID &problemID,
00216                                       CCMIOID processorID,
00217                                       std::vector<MaterialSetData> &matset_data,
00218                                       std::vector<NeumannSetData> &neuset_data);
00219 
00220     // get the material, dirichlet, neumann, and partition sets to be written,
00221     // either from input sets or in the whole mesh
00222   ErrorCode get_sets(const EntityHandle *ent_handles,
00223                      int num_sets,
00224                      std::vector<EntityHandle> &matsets,
00225                      std::vector<EntityHandle> &dirsets,
00226                      std::vector<EntityHandle> &neusets,
00227                      std::vector<EntityHandle> &partsets);
00228 
00230   ErrorCode create_ccmio_structure(CCMIOID rootID, CCMIOID &stateID,
00231                                    CCMIOID &processorID);
00232 
00234   ErrorCode write_solution_data();
00235   
00237   ErrorCode write_processor(CCMIOID processorID, CCMIOID verticesID, CCMIOID topologyID);
00238 
00240   int moab_to_ccmio_type(EntityType etype, int has_mid_nodes[]);
00241 
00242   ErrorCode write_int_option(const char *opt_name,
00243                              EntityHandle seth,
00244                              Tag &tag, CCMIOID &node);
00245   
00246   ErrorCode write_dbl_option(const char *opt_name,
00247                              EntityHandle seth,
00248                              Tag &tag, CCMIOID &node);
00249 
00250   ErrorCode write_str_option(const char *opt_name,
00251                              EntityHandle seth,
00252                              Tag &tag, CCMIOID &node,
00253                              const char *other_name = NULL);
00254 };
00255 
00256 } // namespace moab
00257 
00258 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines