1 /** 2 * MOAB, a Mesh-Oriented datABase, is a software component for creating, 3 * storing and accessing finite element mesh data. 4 * 5 * Copyright 2004 Sandia Corporation. Under the terms of Contract 6 * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government 7 * retains certain rights in this software. 8 * 9 * This library is free software; you can redistribute it and/or 10 * modify it under the terms of the GNU Lesser General Public 11 * License as published by the Free Software Foundation; either 12 * version 2.1 of the License, or (at your option) any later version. 13 * 14 */ 15 16 //------------------------------------------------------------------------- 17 // Filename : WriteTEMPLATE.hpp 18 // 19 // Purpose : ExodusII writer 20 // 21 // Special Notes : Lots of code taken from verde implementation 22 // 23 // Creator : Corey Ernst 24 // 25 // Date : 8/02 26 // 27 // Owner : Corey Ernst 28 //------------------------------------------------------------------------- 29 30 #ifndef WRITEANS_HPP 31 #define WRITEANS_HPP 32 33 #ifndef IS_BUILDING_MB 34 #error "WriteAns.hpp isn't supposed to be included into an application" 35 #endif 36 37 #include <string> 38 39 #include "moab/Forward.hpp" 40 #include "moab/Range.hpp" 41 #include "moab/ExoIIInterface.hpp" 42 #include "moab/WriterIface.hpp" 43 44 namespace moab { 45 46 class WriteUtilIface; 47 48 class WriteAns : public WriterIface 49 { 50 51 public: 52 53 //! Constructor 54 WriteAns(Interface *impl); 55 56 //! Destructor 57 virtual ~WriteAns(); 58 59 static WriterIface* factory( Interface* ); 60 61 //! writes out a file 62 ErrorCode write_file(const char *file_name, 63 const bool overwrite, 64 const FileOptions& opts, 65 const EntityHandle *output_list, 66 const int num_sets, 67 const std::vector<std::string>& qa_list, 68 const Tag* tag_list = NULL, 69 int num_tags = 0, 70 int export_dimension = 3); 71 72 //! struct used to hold data for each block to be output; used by 73 //! initialize_file to initialize the file header for increased speed 74 struct MaterialSetData 75 { 76 int id; 77 int number_elements; 78 int number_nodes_per_element; 79 int number_attributes; 80 ExoIIElementType element_type; 81 EntityType moab_type; 82 Range *elements; 83 }; 84 85 //! struct used to hold data for each nodeset to be output; used by 86 //! initialize_file to initialize the file header for increased speed 87 struct DirichletSetData 88 { 89 int id; 90 int number_nodes; 91 std::vector< EntityHandle > nodes; 92 std::vector< double > node_dist_factors; 93 94 }; 95 96 //! struct used to hold data for each sideset to be output; used by 97 //! initialize_file to initialize the file header for increased speed 98 struct NeumannSetData 99 { 100 int id; 101 int number_elements; 102 std::vector<EntityHandle> elements; 103 std::vector<int> side_numbers; 104 EntityHandle mesh_set_handle; 105 }; 106 107 108 protected: 109 110 //! number of dimensions in this file 111 //int number_dimensions(); 112 113 //! open a file for writing 114 //ErrorCode open_file(const char *filename); 115 116 //! contains the general information about a mesh 117 class MeshInfo 118 { 119 public: 120 unsigned int num_dim; 121 unsigned int num_nodes; 122 unsigned int num_elements; 123 unsigned int num_matsets; 124 unsigned int num_dirsets; 125 unsigned int num_neusets; 126 Range nodes; 127 MeshInfo()128 MeshInfo() 129 : num_dim(0), num_nodes(0), num_elements(0), num_matsets(0), 130 num_dirsets(0), num_neusets(0) 131 {} 132 133 }; 134 135 private: 136 137 //! interface instance 138 Interface *mbImpl; 139 //WriteUtilIface* mWriteIface; 140 141 //! file name 142 std::string fileName; 143 144 //! Meshset Handle for the mesh that is currently being read 145 EntityHandle mCurrentMeshHandle; 146 147 //! Cached tags for reading. Note that all these tags are defined when the 148 //! core is initialized. 149 Tag mMaterialSetTag; 150 Tag mDirichletSetTag; 151 Tag mNeumannSetTag; 152 Tag mGlobalIdTag; 153 Tag mMatSetIdTag; 154 155 ErrorCode write_nodes(const int num_nodes, const Range& nodes, 156 const int dimension, const char *file_name ); 157 158 }; 159 160 } // namespace moab 161 162 #endif 163