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