Mesh Oriented datABase  (version 5.4.1)
Array-based unstructured mesh datastructure
WriteSLAC.hpp
Go to the documentation of this file.
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      : WriteSLAC.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 WRITESLAC_HPP
00031 #define WRITESLAC_HPP
00032 
00033 #ifndef IS_BUILDING_MB
00034 #error "WriteSLAC.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 
00045 namespace moab
00046 {
00047 
00048 class WriteUtilIface;
00049 
00050 class WriteSLAC : public WriterIface
00051 {
00052 
00053   public:
00054     //! Constructor
00055     WriteSLAC( Interface* impl );
00056 
00057     //! Destructor
00058     virtual ~WriteSLAC();
00059 
00060     static WriterIface* factory( Interface* );
00061 
00062     //! writes out a file
00063     ErrorCode write_file( const char* file_name,
00064                           const bool overwrite,
00065                           const FileOptions& opts,
00066                           const EntityHandle* output_list,
00067                           const int num_sets,
00068                           const std::vector< std::string >& qa_list,
00069                           const Tag* tag_list  = NULL,
00070                           int num_tags         = 0,
00071                           int export_dimension = 3 );
00072 
00073     //! struct used to hold data for each block to be output; used by
00074     //! initialize_file to initialize the file header for increased speed
00075     struct MaterialSetData
00076     {
00077         int id;
00078         int number_elements;
00079         int number_nodes_per_element;
00080         int number_attributes;
00081         ExoIIElementType element_type;
00082         EntityType moab_type;
00083         Range* elements;
00084     };
00085 
00086     //! struct used to hold data for each nodeset to be output; used by
00087     //! initialize_file to initialize the file header for increased speed
00088     struct DirichletSetData
00089     {
00090         int id;
00091         int number_nodes;
00092         std::vector< EntityHandle > nodes;
00093         std::vector< double > node_dist_factors;
00094     };
00095 
00096     //! struct used to hold data for each sideset to be output; used by
00097     //! initialize_file to initialize the file header for increased speed
00098     struct NeumannSetData
00099     {
00100         int id;
00101         int number_elements;
00102         std::vector< EntityHandle > elements;
00103         std::vector< int > side_numbers;
00104         EntityHandle mesh_set_handle;
00105     };
00106 
00107   protected:
00108     //! number of dimensions in this file
00109     // int number_dimensions();
00110 
00111     //! open a file for writing
00112     ErrorCode open_file( const char* filename );
00113 
00114     //! contains the general information about a mesh
00115     class MeshInfo
00116     {
00117       public:
00118         unsigned int num_dim;
00119         unsigned int num_nodes;
00120         unsigned int num_elements;
00121         unsigned int num_matsets;
00122         unsigned int num_int_hexes;
00123         unsigned int num_int_tets;
00124         Range bdy_hexes, bdy_tets;
00125         Range nodes;
00126 
00127         MeshInfo()
00128             : num_dim( 0 ), num_nodes( 0 ), num_elements( 0 ), num_matsets( 0 ), num_int_hexes( 0 ), num_int_tets( 0 )
00129         {
00130         }
00131     };
00132 
00133   private:
00134     //! interface instance
00135     Interface* mbImpl;
00136     WriteUtilIface* mWriteIface;
00137 
00138     //! file name
00139     std::string fileName;
00140     int ncFile;
00141 
00142     //! Cached tags for reading.  Note that all these tags are defined when the
00143     //! core is initialized.
00144     Tag mMaterialSetTag;
00145     Tag mDirichletSetTag;
00146     Tag mNeumannSetTag;
00147     Tag mGlobalIdTag;
00148     Tag mMatSetIdTag;
00149 
00150     Tag mEntityMark;  // used to say whether an entity will be exported
00151 
00152     ErrorCode gather_mesh_information( MeshInfo& mesh_info,
00153                                        std::vector< MaterialSetData >& matset_info,
00154                                        std::vector< NeumannSetData >& neuset_info,
00155                                        std::vector< DirichletSetData >& dirset_info,
00156                                        std::vector< EntityHandle >& matsets,
00157                                        std::vector< EntityHandle >& neusets,
00158                                        std::vector< EntityHandle >& dirsets );
00159 
00160     ErrorCode initialize_file( MeshInfo& mesh_info );
00161 
00162     ErrorCode write_nodes( const int num_nodes, const Range& nodes, const int dimension );
00163 
00164     ErrorCode write_matsets( MeshInfo& mesh_info,
00165                              std::vector< MaterialSetData >& matset_data,
00166                              std::vector< NeumannSetData >& neuset_data );
00167 
00168     ErrorCode get_valid_sides( Range& elems, const int sense, WriteSLAC::NeumannSetData& sideset_data );
00169 
00170     void reset_matset( std::vector< MaterialSetData >& matset_info );
00171 
00172     ErrorCode get_neuset_elems( EntityHandle neuset, int current_sense, Range& forward_elems, Range& reverse_elems );
00173 
00174     ErrorCode gather_interior_exterior( MeshInfo& mesh_info,
00175                                         std::vector< MaterialSetData >& matset_data,
00176                                         std::vector< NeumannSetData >& neuset_data );
00177 };
00178 
00179 }  // namespace moab
00180 
00181 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines