Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
WriteAns.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 : 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 
47 class WriteUtilIface;
48 
49 class WriteAns : public WriterIface
50 {
51 
52  public:
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
75  {
76  int id;
81  EntityType moab_type;
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
88  {
89  int id;
91  std::vector< EntityHandle > nodes;
92  std::vector< double > node_dist_factors;
93  };
94 
95  //! struct used to hold data for each sideset to be output; used by
96  //! initialize_file to initialize the file header for increased speed
98  {
99  int id;
101  std::vector< EntityHandle > elements;
102  std::vector< int > side_numbers;
104  };
105 
106  protected:
107  //! number of dimensions in this file
108  // int number_dimensions();
109 
110  //! open a file for writing
111  // ErrorCode open_file(const char *filename);
112 
113  //! contains the general information about a mesh
114  class MeshInfo
115  {
116  public:
117  unsigned int num_dim;
118  unsigned int num_nodes;
119  unsigned int num_elements;
120  unsigned int num_matsets;
121  unsigned int num_dirsets;
122  unsigned int num_neusets;
124 
126  : num_dim( 0 ), num_nodes( 0 ), num_elements( 0 ), num_matsets( 0 ), num_dirsets( 0 ), num_neusets( 0 )
127  {
128  }
129  };
130 
131  private:
132  //! interface instance
134  // WriteUtilIface* mWriteIface;
135 
136  //! file name
137  std::string fileName;
138 
139  //! Meshset Handle for the mesh that is currently being read
141 
142  //! Cached tags for reading. Note that all these tags are defined when the
143  //! core is initialized.
149 
150  ErrorCode write_nodes( const int num_nodes, const Range& nodes, const int dimension, const char* file_name );
151 };
152 
153 } // namespace moab
154 
155 #endif