Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
WriteSLAC.hpp
Go to the documentation of this file.
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 : WriteSLAC.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 WRITESLAC_HPP
31 #define WRITESLAC_HPP
32 
33 #ifndef IS_BUILDING_MB
34 #error "WriteSLAC.hpp isn't supposed to be included into an application"
35 #endif
36 
37 #include <vector>
38 #include <string>
39 
40 #include "moab/Forward.hpp"
41 #include "moab/Range.hpp"
42 #include "moab/ExoIIInterface.hpp"
43 #include "moab/WriterIface.hpp"
44 
45 namespace moab
46 {
47 
48 class WriteUtilIface;
49 
50 class WriteSLAC : public WriterIface
51 {
52 
53  public:
54  //! Constructor
55  WriteSLAC( Interface* impl );
56 
57  //! Destructor
58  virtual ~WriteSLAC();
59 
60  static WriterIface* factory( Interface* );
61 
62  //! writes out a file
63  ErrorCode write_file( const char* file_name,
64  const bool overwrite,
65  const FileOptions& opts,
66  const EntityHandle* output_list,
67  const int num_sets,
68  const std::vector< std::string >& qa_list,
69  const Tag* tag_list = NULL,
70  int num_tags = 0,
71  int export_dimension = 3 );
72 
73  //! struct used to hold data for each block to be output; used by
74  //! initialize_file to initialize the file header for increased speed
76  {
77  int id;
82  EntityType moab_type;
84  };
85 
86  //! struct used to hold data for each nodeset to be output; used by
87  //! initialize_file to initialize the file header for increased speed
89  {
90  int id;
92  std::vector< EntityHandle > nodes;
93  std::vector< double > node_dist_factors;
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
99  {
100  int id;
102  std::vector< EntityHandle > elements;
103  std::vector< int > side_numbers;
105  };
106 
107  protected:
108  //! number of dimensions in this file
109  // int number_dimensions();
110 
111  //! open a file for writing
112  ErrorCode open_file( const char* filename );
113 
114  //! contains the general information about a mesh
115  class MeshInfo
116  {
117  public:
118  unsigned int num_dim;
119  unsigned int num_nodes;
120  unsigned int num_elements;
121  unsigned int num_matsets;
122  unsigned int num_int_hexes;
123  unsigned int num_int_tets;
126 
128  : num_dim( 0 ), num_nodes( 0 ), num_elements( 0 ), num_matsets( 0 ), num_int_hexes( 0 ), num_int_tets( 0 )
129  {
130  }
131  };
132 
133  private:
134  //! interface instance
137 
138  //! file name
139  std::string fileName;
140  int ncFile;
141 
142  //! Cached tags for reading. Note that all these tags are defined when the
143  //! core is initialized.
149 
150  Tag mEntityMark; // used to say whether an entity will be exported
151 
153  std::vector< MaterialSetData >& matset_info,
154  std::vector< NeumannSetData >& neuset_info,
155  std::vector< DirichletSetData >& dirset_info,
156  std::vector< EntityHandle >& matsets,
157  std::vector< EntityHandle >& neusets,
158  std::vector< EntityHandle >& dirsets );
159 
160  ErrorCode initialize_file( MeshInfo& mesh_info );
161 
162  ErrorCode write_nodes( const int num_nodes, const Range& nodes, const int dimension );
163 
164  ErrorCode write_matsets( MeshInfo& mesh_info,
165  std::vector< MaterialSetData >& matset_data,
166  std::vector< NeumannSetData >& neuset_data );
167 
168  ErrorCode get_valid_sides( Range& elems, const int sense, WriteSLAC::NeumannSetData& sideset_data );
169 
170  void reset_matset( std::vector< MaterialSetData >& matset_info );
171 
172  ErrorCode get_neuset_elems( EntityHandle neuset, int current_sense, Range& forward_elems, Range& reverse_elems );
173 
175  std::vector< MaterialSetData >& matset_data,
176  std::vector< NeumannSetData >& neuset_data );
177 };
178 
179 } // namespace moab
180 
181 #endif