libMesh
plt_loader.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2017 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 
20 #include "libmesh/plt_loader.h"
21 
22 namespace libMesh
23 {
24 
25 
26 
27 //---------------------------------------------------------
28 // PltLoader static data
29 const unsigned int PltLoader::NNodes[4] = {3, 4, 4, 8};
30 
31 
32 
33 //-----------------------------------------------------------------------------
34 // PltLoader members
36 {
37  // clear vectors & strings. Using .erase() for strings instead of .clear()
38  // since GCC 2.95.3 does not support .clear().
39  _version.erase();
40  _title.erase();
41 
42  _var_names.clear();
43  _var_types.clear();
44  _zone_types.clear();
45  _zone_names.clear();
46  _zone_pack.clear();
47  _imax.clear();
48  _jmax.clear();
49  _kmax.clear();
50  _data.clear();
51  _conn.clear();
52 
53  // reinitialize
54  _is_foreign = false;
55  _n_vars = 0;
56  _n_zones = 0;
57 }
58 
59 
60 
61 void PltLoader::set_n_vars (const unsigned int nv)
62 {
63  _n_vars = nv;
64 
65  _var_types.resize (this->n_vars());
66  _var_names.resize (this->n_vars());
67 
68  // Default to float data
69  std::fill (_var_types.begin(), _var_types.end(), 1);
70 
71  // If the number of zones is set, resize the data.
72  if (this->n_zones())
73  {
74  _data.resize (this->n_zones());
75 
76  for (unsigned int z=0; z<this->n_zones(); z++)
77  _data[z].resize (this->n_vars());
78  }
79 }
80 
81 
82 
83 void PltLoader::set_n_zones (const unsigned int nz)
84 {
85  _n_zones = nz;
86 
87  _zone_types.resize (this->n_zones());
88  _zone_names.resize (this->n_zones());
89  _zone_pack.resize (this->n_zones());
90 
91  _imax.resize (this->n_zones());
92  _jmax.resize (this->n_zones());
93  _kmax.resize (this->n_zones());
94 
95  _data.resize (this->n_zones());
96  _conn.resize (this->n_zones());
97 
98  // If the number of variables are set, resize the data.
99  if (this->n_vars())
100  for (unsigned int z=0; z<this->n_zones(); z++)
101  _data[z].resize (this->n_vars());
102 }
103 
104 } // namespace libMesh
void set_n_zones(const unsigned int nz)
Definition: plt_loader.C:83
std::vector< std::vector< int > > _conn
Vectors to hold the connectivity for each zone (only for unstructured files).
Definition: plt_loader.h:436
std::vector< std::string > _zone_names
The name of each zone.
Definition: plt_loader.h:413
std::vector< std::vector< std::vector< float > > > _data
Vector to hold the data.
Definition: plt_loader.h:430
std::vector< unsigned int > _zone_pack
The data packing for each zone (new version only)
Definition: plt_loader.h:418
unsigned int n_vars() const
Definition: plt_loader.h:180
std::vector< unsigned int > _kmax
Definition: plt_loader.h:425
std::vector< unsigned int > _var_types
The type of each variable.
Definition: plt_loader.h:398
void set_n_vars(const unsigned int nv)
Definition: plt_loader.C:61
void clear()
Clear all data and return to a pristine state.
Definition: plt_loader.C:35
std::vector< unsigned int > _zone_types
The type of each zone.
Definition: plt_loader.h:408
The libMesh namespace provides an interface to certain functionality in the library.
std::vector< unsigned int > _jmax
Definition: plt_loader.h:424
std::vector< unsigned int > _imax
The (imax,jmax,kmax) value for each zone.
Definition: plt_loader.h:423
static const unsigned int NNodes[4]
Enum defining the number of nodes for each element type.
Definition: plt_loader.h:250
std::vector< std::string > _var_names
The name for each variable.
Definition: plt_loader.h:392
std::string _title
The Tecplot data set title.
Definition: plt_loader.h:382
unsigned int _n_vars
The number of variables in the data set.
Definition: plt_loader.h:387
std::string _version
The Tecplot Version number string.
Definition: plt_loader.h:372
bool _is_foreign
Is the data foreign?
Definition: plt_loader.h:377
unsigned int n_zones() const
Definition: plt_loader.h:195
unsigned int _n_zones
The number of zones.
Definition: plt_loader.h:403