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 */1516//-------------------------------------------------------------------------17// Filename : WriteTemplate.hpp18//19// Purpose : ExodusII writer20//21// Special Notes : Lots of code taken from verde implementation22//23// Creator : Corey Ernst24//25// Date : 8/0226//27// Owner : Corey Ernst28//-------------------------------------------------------------------------2930#ifndef WRITETemplate_HPP31#define WRITETemplate_HPP3233#ifndef IS_BUILDING_MB34#error"WriteTemplate.hpp isn't supposed to be included into an application"35#endif3637#include<vector>38#include<string>3940#include"moab/Forward.hpp"41#include"moab/Range.hpp"42#include"moab/ExoIIInterface.hpp"43#include"moab/WriterIface.hpp"4445namespace moab
46 {
4748classWriteUtilIface;
4950classWriteTemplate : public WriterIface
51 {
5253public:
54//! Constructor55WriteTemplate( Interface* impl );
5657//! Destructor58virtual ~WriteTemplate();
5960static WriterIface* factory( Interface* );
6162//! writes out a file63ErrorCode write_file( constchar* file_name,
64constbool overwrite,
65const FileOptions& opts,
66const EntityHandle* output_list,
67constint num_sets,
68const std::vector< std::string >& qa_list,
69const Tag* tag_list = NULL,
70int num_tags = 0,
71int export_dimension = 3 );
7273//! struct used to hold data for each block to be output; used by74//! initialize_file to initialize the file header for increased speed75structMaterialSetData76 {
77int id;
78int number_elements;
79int number_nodes_per_element;
80int number_attributes;
81 ExoIIElementType element_type;
82 EntityType moab_type;
83 Range* elements;
84 };
8586//! struct used to hold data for each nodeset to be output; used by87//! initialize_file to initialize the file header for increased speed88structDirichletSetData89 {
90int id;
91int number_nodes;
92 std::vector< EntityHandle > nodes;
93 std::vector< double > node_dist_factors;
94 };
9596//! struct used to hold data for each sideset to be output; used by97//! initialize_file to initialize the file header for increased speed98structNeumannSetData99 {
100int id;
101int number_elements;
102 std::vector< EntityHandle > elements;
103 std::vector< int > side_numbers;
104 EntityHandle mesh_set_handle;
105 };
106107protected:
108//! number of dimensions in this file109// int number_dimensions();110111//! open a file for writing112ErrorCode open_file( constchar* filename );
113114//! contains the general information about a mesh115classMeshInfo116 {
117public:
118unsignedint num_dim;
119unsignedint num_nodes;
120unsignedint num_elements;
121unsignedint num_matsets;
122unsignedint num_dirsets;
123unsignedint num_neusets;
124 Range nodes;
125126MeshInfo()
127 : num_dim( 0 ), num_nodes( 0 ), num_elements( 0 ), num_matsets( 0 ), num_dirsets( 0 ), num_neusets( 0 )
128 {
129 }
130 };
131132private:
133//! interface instance134 Interface* mbImpl;
135 WriteUtilIface* mWriteIface;
136137//! file name138 std::string fileName;
139140//! Cached tags for reading. Note that all these tags are defined when the141//! core is initialized.142 Tag mMaterialSetTag;
143 Tag mDirichletSetTag;
144 Tag mNeumannSetTag;
145 Tag mGlobalIdTag;
146147 Tag mEntityMark; // used to say whether an entity will be exported148149ErrorCode gather_mesh_information( MeshInfo& mesh_info,
150 std::vector< MaterialSetData >& matset_info,
151 std::vector< NeumannSetData >& neuset_info,
152 std::vector< DirichletSetData >& dirset_info,
153 std::vector< EntityHandle >& matsets,
154 std::vector< EntityHandle >& neusets,
155 std::vector< EntityHandle >& dirsets );
156157ErrorCode initialize_file( MeshInfo& mesh_info );
158159ErrorCode write_nodes( constint num_nodes, const Range& nodes, constint dimension );
160161ErrorCode write_matsets( MeshInfo& mesh_info,
162 std::vector< MaterialSetData >& matset_data,
163 std::vector< NeumannSetData >& neuset_data );
164165ErrorCode get_valid_sides( Range& elems, constint sense, WriteTemplate::NeumannSetData& neuset_data );
166167voidreset_matset( std::vector< MaterialSetData >& matset_info );
168169ErrorCode get_neuset_elems( EntityHandle neuset, int current_sense, Range& forward_elems, Range& reverse_elems );
170 };
171172 } // namespace moab173174#endif