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