libMesh
Loading...
Searching...
No Matches
plt_loader.C
Go to the documentation of this file.
1// The libMesh Finite Element Library.
2// Copyright (C) 2002-2026 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#include "libmesh/int_range.h"
23
24namespace libMesh
25{
26
27
28
29//---------------------------------------------------------
30// PltLoader static data
31const unsigned int PltLoader::NNodes[4] = {3, 4, 4, 8};
32
33
34
35//-----------------------------------------------------------------------------
36// PltLoader members
38{
39 // clear vectors & strings. Using .erase() for strings instead of .clear()
40 // since GCC 2.95.3 does not support .clear().
41 _version.erase();
42 _title.erase();
43
44 _var_names.clear();
45 _var_types.clear();
46 _zone_types.clear();
47 _zone_names.clear();
48 _zone_pack.clear();
49 _imax.clear();
50 _jmax.clear();
51 _kmax.clear();
52 _data.clear();
53 _conn.clear();
54
55 // reinitialize
56 _is_foreign = false;
57 _n_vars = 0;
58 _n_zones = 0;
59}
60
61
62
63void PltLoader::set_n_vars (const unsigned int nv)
64{
65 _n_vars = nv;
66
67 _var_types.resize (this->n_vars());
68 _var_names.resize (this->n_vars());
69
70 // Default to float data
71 std::fill (_var_types.begin(), _var_types.end(), 1);
72
73 // If the number of zones is set, resize the data.
74 if (this->n_zones())
75 {
76 _data.resize (this->n_zones());
77
78 for (auto z : make_range(this->n_zones()))
79 _data[z].resize (this->n_vars());
80 }
81}
82
83
84
85void PltLoader::set_n_zones (const unsigned int nz)
86{
87 _n_zones = nz;
88
89 _zone_types.resize (this->n_zones());
90 _zone_names.resize (this->n_zones());
91 _zone_pack.resize (this->n_zones());
92
93 _imax.resize (this->n_zones());
94 _jmax.resize (this->n_zones());
95 _kmax.resize (this->n_zones());
96
97 _data.resize (this->n_zones());
98 _conn.resize (this->n_zones());
99
100 // If the number of variables are set, resize the data.
101 if (this->n_vars())
102 for (auto z : make_range(this->n_zones()))
103 _data[z].resize (this->n_vars());
104}
105
106} // namespace libMesh
std::vector< unsigned int > _zone_pack
The data packing for each zone (new version only)
Definition plt_loader.h:418
std::vector< std::string > _zone_names
The name of each zone.
Definition plt_loader.h:413
unsigned int n_zones() const
Definition plt_loader.h:195
std::vector< unsigned int > _kmax
Definition plt_loader.h:425
std::vector< std::vector< int > > _conn
Vectors to hold the connectivity for each zone (only for unstructured files).
Definition plt_loader.h:436
bool _is_foreign
Is the data foreign?
Definition plt_loader.h:377
unsigned int _n_vars
The number of variables in the data set.
Definition plt_loader.h:387
static const unsigned int NNodes[4]
Enum defining the number of nodes for each element type.
Definition plt_loader.h:250
std::vector< unsigned int > _jmax
Definition plt_loader.h:424
std::string _title
The Tecplot data set title.
Definition plt_loader.h:382
std::vector< unsigned int > _zone_types
The type of each zone.
Definition plt_loader.h:408
unsigned int _n_zones
The number of zones.
Definition plt_loader.h:403
std::string _version
The Tecplot Version number string.
Definition plt_loader.h:372
std::vector< std::string > _var_names
The name for each variable.
Definition plt_loader.h:392
std::vector< unsigned int > _var_types
The type of each variable.
Definition plt_loader.h:398
unsigned int n_vars() const
Definition plt_loader.h:180
void set_n_zones(const unsigned int nz)
Definition plt_loader.C:85
void clear()
Clear all data and return to a pristine state.
Definition plt_loader.C:37
std::vector< std::vector< std::vector< float > > > _data
Vector to hold the data.
Definition plt_loader.h:430
void set_n_vars(const unsigned int nv)
Definition plt_loader.C:63
std::vector< unsigned int > _imax
The (imax,jmax,kmax) value for each zone.
Definition plt_loader.h:423
The libMesh namespace provides an interface to certain functionality in the library.
IntRange< T > make_range(T beg, T end)
The 2-parameter make_range() helper function returns an IntRange<T> when both input parameters are of...
Definition int_range.h:176