Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
ParaView
VisItBridge
Commits
0a2b981e
Commit
0a2b981e
authored
Dec 10, 2013
by
Dan Lipsa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix 'open an HDF5 file without H5F_CLOSE_SEMI' warning for Chombo and Enzo
parent
6de2bd2d
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
271 additions
and
132 deletions
+271
-132
databases/AvtAlgorithms/CMakeLists.txt
databases/AvtAlgorithms/CMakeLists.txt
+5
-10
databases/AvtAlgorithms/vtkAvtFileFormatAlgorithm.cxx
databases/AvtAlgorithms/vtkAvtFileFormatAlgorithm.cxx
+0
-2
databases/AvtAlgorithms/vtkAvtFileFormatAlgorithm.h
databases/AvtAlgorithms/vtkAvtFileFormatAlgorithm.h
+6
-6
databases/AvtAlgorithms/vtkFileCloseSemiProperty.h
databases/AvtAlgorithms/vtkFileCloseSemiProperty.h
+32
-0
databases/Chombo/avtChomboFileFormat.C
databases/Chombo/avtChomboFileFormat.C
+12
-6
databases/Enzo/avtEnzoFileFormat.C
databases/Enzo/avtEnzoFileFormat.C
+7
-3
databases/LAMMPS/avtLAMMPSDumpFileFormat.C
databases/LAMMPS/avtLAMMPSDumpFileFormat.C
+118
-98
databases/LAMMPS/avtLAMMPSDumpFileFormat.h
databases/LAMMPS/avtLAMMPSDumpFileFormat.h
+91
-7
No files found.
databases/AvtAlgorithms/CMakeLists.txt
View file @
0a2b981e
set
(
Kit_SRCS
vtkAvtFileFormatAlgorithm.h
vtkAvtFileFormatAlgorithm.cxx
vtkAvtMTSDFileFormatAlgorithm.h
vtkAvtMTSDFileFormatAlgorithm.cxx
vtkAvtMTMDFileFormatAlgorithm.h
vtkAvtMTMDFileFormatAlgorithm.cxx
vtkAvtSTSDFileFormatAlgorithm.h
vtkAvtSTSDFileFormatAlgorithm.cxx
vtkAvtSTMDFileFormatAlgorithm.h
vtkAvtSTMDFileFormatAlgorithm.cxx
vtkAvtFileFormatAlgorithm.cxx
vtkAvtMTSDFileFormatAlgorithm.cxx
vtkAvtMTMDFileFormatAlgorithm.cxx
vtkAvtSTSDFileFormatAlgorithm.cxx
vtkAvtSTMDFileFormatAlgorithm.cxx
)
set
(
FullPath_SRCS
)
...
...
databases/AvtAlgorithms/vtkAvtFileFormatAlgorithm.cxx
View file @
0a2b981e
...
...
@@ -956,5 +956,3 @@ void vtkAvtFileFormatAlgorithm::PrintSelf(ostream& os, vtkIndent indent)
this
->
Superclass
::
PrintSelf
(
os
,
indent
);
os
<<
indent
<<
"Output Type: "
<<
this
->
OutputType
<<
"
\n
"
;
}
databases/AvtAlgorithms/vtkAvtFileFormatAlgorithm.h
View file @
0a2b981e
...
...
@@ -30,8 +30,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
========================================================================*/
#ifndef _vtk
VisItReader
_h
#define _vtk
VisItReader
_h
#ifndef _vtk
AvtFileFormatAlgorithm
_h
#define _vtk
AvtFileFormatAlgorithm
_h
#include "vtkIOVisItBridgeModule.h" //for export macro
...
...
@@ -74,7 +74,7 @@ public:
static
vtkAvtFileFormatAlgorithm
*
New
();
vtkTypeMacro
(
vtkAvtFileFormatAlgorithm
,
vtkCompositeDataSetAlgorithm
);
void
PrintSelf
(
ostream
&
os
,
vtkIndent
indent
);
// Description:
// Get the number of point or cell arrays available in the input.
int
GetNumberOfPointArrays
();
...
...
@@ -147,7 +147,7 @@ protected:
// see algorithm for more info
virtual
int
FillOutputPortInformation
(
int
port
,
vtkInformation
*
info
);
//methods that setup selection arrays that the client will interact with
//methods that setup selection arrays that the client will interact with
void
SetupDataArraySelections
();
void
SetupMeshSelections
();
void
SetupMaterialSelections
();
...
...
@@ -155,8 +155,8 @@ protected:
//method to setup the proper block bounds for the data.
//this method is needed to support dynamic block loading
//for certain streaming pipelines
virtual
void
SetupBlockBoundsInformation
(
vtkInformation
*
outInfo
);
virtual
void
SetupBlockBoundsInformation
(
vtkInformation
*
outInfo
);
//method setups the number of timesteps that the file has
void
SetupTemporalInformation
(
vtkInformation
*
outInfo
);
...
...
databases/AvtAlgorithms/vtkFileCloseSemiProperty.h
0 → 100644
View file @
0a2b981e
#ifndef _vtkFileCloseSemiProperty_h
#define _vtkFileCloseSemiProperty_h
/*
* Needs <hdf5.h>, so include this header only after you include the
* hdf5 header. Because you might need to select the right API for hdf5 (such
* as with H5_USE_16_API) the hdf5 header is not included here.
*/
class
vtkFileCloseSemiProperty
{
public:
vtkFileCloseSemiProperty
()
{
this
->
Fapl
=
H5Pcreate
(
H5P_FILE_ACCESS
);
H5Pset_fclose_degree
(
this
->
Fapl
,
H5F_CLOSE_SEMI
);
}
~
vtkFileCloseSemiProperty
()
{
H5Pclose
(
this
->
Fapl
);
}
operator
hid_t
()
const
{
return
this
->
Fapl
;
}
private:
hid_t
Fapl
;
};
#endif
databases/Chombo/avtChomboFileFormat.C
View file @
0a2b981e
...
...
@@ -95,6 +95,7 @@
#define H5_USE_16_API
#include <hdf5.h>
#include <visit-hdf5.h>
#include "vtkFileCloseSemiProperty.h"
#include <boost/cstdint.hpp>
// using boost::boost::int32_t; // This conflicts with Visual Studio 10
using
std
::
string
;
...
...
@@ -448,7 +449,8 @@ avtChomboFileFormat::InitializeReader(void)
//
// Open file
//
file_handle
=
H5Fopen
(
filenames
[
0
],
H5F_ACC_RDONLY
,
H5P_DEFAULT
);
file_handle
=
H5Fopen
(
filenames
[
0
],
H5F_ACC_RDONLY
,
vtkFileCloseSemiProperty
());
if
(
file_handle
<
0
)
{
EXCEPTION1
(
InvalidDBTypeException
,
"Cannot be a Chombo file, since "
...
...
@@ -1344,7 +1346,7 @@ avtChomboFileFormat::InitializeReader(void)
VisItStat_t
fs
;
if
(
VisItStat
(
mappingFilename
.
c_str
(),
&
fs
)
==
0
)
{
hid_t
mapping_file_handle
=
H5Fopen
(
mappingFilename
.
c_str
(),
H5F_ACC_RDONLY
,
H5P_DEFAULT
);
hid_t
mapping_file_handle
=
H5Fopen
(
mappingFilename
.
c_str
(),
H5F_ACC_RDONLY
,
vtkFileCloseSemiProperty
()
);
if
(
mapping_file_handle
>
0
)
{
hid_t
slash
=
H5Gopen
(
mapping_file_handle
,
"/"
);
...
...
@@ -2620,7 +2622,8 @@ avtChomboFileFormat::GetMesh(int patch, const char *meshname)
if
(
file_handle
<
0
)
{
file_handle
=
H5Fopen
(
filenames
[
0
],
H5F_ACC_RDONLY
,
H5P_DEFAULT
);
file_handle
=
H5Fopen
(
filenames
[
0
],
H5F_ACC_RDONLY
,
vtkFileCloseSemiProperty
());
if
(
file_handle
<
0
)
{
EXCEPTION1
(
InvalidDBTypeException
,
"Cannot be a Chombo file, since "
...
...
@@ -3084,7 +3087,8 @@ avtChomboFileFormat::GetVar(int patch, const char *varname)
SNPRINTF
(
name
,
1024
,
"level_%d"
,
level
);
if
(
file_handle
<
0
)
{
file_handle
=
H5Fopen
(
filenames
[
0
],
H5F_ACC_RDONLY
,
H5P_DEFAULT
);
file_handle
=
H5Fopen
(
filenames
[
0
],
H5F_ACC_RDONLY
,
vtkFileCloseSemiProperty
());
if
(
file_handle
<
0
)
{
EXCEPTION1
(
InvalidDBTypeException
,
"Cannot be a Chombo file, since "
...
...
@@ -3189,7 +3193,8 @@ avtChomboFileFormat::GetVar(int patch, const char *varname)
{
if
(
file_handle
<
0
)
{
file_handle
=
H5Fopen
(
filenames
[
0
],
H5F_ACC_RDONLY
,
H5P_DEFAULT
);
file_handle
=
H5Fopen
(
filenames
[
0
],
H5F_ACC_RDONLY
,
vtkFileCloseSemiProperty
());
if
(
file_handle
<
0
)
{
EXCEPTION1
(
InvalidDBTypeException
,
"Cannot be a Chombo file, since "
...
...
@@ -3425,7 +3430,8 @@ avtChomboFileFormat::GetVectorVar(int patch, const char *varname)
SNPRINTF
(
name
,
1024
,
"level_%d"
,
level
);
if
(
file_handle
<
0
)
{
file_handle
=
H5Fopen
(
filenames
[
0
],
H5F_ACC_RDONLY
,
H5P_DEFAULT
);
file_handle
=
H5Fopen
(
filenames
[
0
],
H5F_ACC_RDONLY
,
vtkFileCloseSemiProperty
());
if
(
file_handle
<
0
)
{
EXCEPTION1
(
InvalidDBTypeException
,
"Cannot be a Chombo file, since "
...
...
databases/Enzo/avtEnzoFileFormat.C
View file @
0a2b981e
...
...
@@ -80,6 +80,7 @@
#define H5_USE_16_API
#include <hdf5.h>
#include <visit-hdf5.h>
#include "vtkFileCloseSemiProperty.h"
#endif
using
std
::
string
;
...
...
@@ -629,7 +630,8 @@ avtEnzoFileFormat::DetermineVariablesFromGridFile()
#endif
{
#ifdef HAVE_LIBHDF5
hid_t
fileId
=
H5Fopen
(
gridFileName
.
c_str
(),
H5F_ACC_RDONLY
,
H5P_DEFAULT
);
hid_t
fileId
=
H5Fopen
(
gridFileName
.
c_str
(),
H5F_ACC_RDONLY
,
vtkFileCloseSemiProperty
());
if
(
fileId
<
0
)
{
#ifdef HAVE_LIBHDF4
...
...
@@ -1434,7 +1436,8 @@ avtEnzoFileFormat::GetMesh(int domain, const char *meshname)
return
NULL
;
}
hid_t
fileId
=
H5Fopen
(
particleFileName
.
c_str
(),
H5F_ACC_RDONLY
,
H5P_DEFAULT
);
hid_t
fileId
=
H5Fopen
(
particleFileName
.
c_str
(),
H5F_ACC_RDONLY
,
vtkFileCloseSemiProperty
());
if
(
fileId
<
0
)
{
EXCEPTION1
(
InvalidFilesException
,
particleFileName
.
c_str
());
...
...
@@ -1870,7 +1873,8 @@ avtEnzoFileFormat::GetVar(int domain, const char *varname)
// HDF5 STUFF
string
gridFileName
=
grids
[
domain
+
1
].
gridFileName
;
hid_t
fileId
=
H5Fopen
(
gridFileName
.
c_str
(),
H5F_ACC_RDONLY
,
H5P_DEFAULT
);
hid_t
fileId
=
H5Fopen
(
gridFileName
.
c_str
(),
H5F_ACC_RDONLY
,
vtkFileCloseSemiProperty
());
if
(
fileId
<
0
)
{
EXCEPTION1
(
InvalidFilesException
,
gridFileName
.
c_str
());
...
...
databases/LAMMPS/avtLAMMPSDumpFileFormat.C
View file @
0a2b981e
...
...
@@ -61,6 +61,7 @@
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
using
std
::
istringstream
;
using
std
::
string
;
...
...
@@ -133,10 +134,7 @@ avtLAMMPSDumpFileFormat::GetNTimesteps(void)
void
avtLAMMPSDumpFileFormat
::
FreeUpResources
(
void
)
{
for
(
int
i
=
0
;
i
<
vars
.
size
();
i
++
)
vars
[
i
].
clear
();
vars
.
clear
();
varNames
.
clear
();
atomVars
.
Clear
();
}
...
...
@@ -206,7 +204,7 @@ avtLAMMPSDumpFileFormat::PopulateDatabaseMetaData(avtDatabaseMetaData *md, int t
avtMeshMetaData
*
mmd_bbox
=
new
avtMeshMetaData
(
"unitCell"
,
1
,
0
,
0
,
0
,
3
,
1
,
AVT_
UNSTRUCTURED
_MESH
);
AVT_
POINT
_MESH
);
for
(
int
i
=
0
;
i
<
9
;
i
++
)
mmd_bbox
->
unitCellVectors
[
i
]
=
0
;
mmd_bbox
->
unitCellVectors
[
0
]
=
xMax
-
xMin
;
...
...
@@ -231,13 +229,22 @@ avtLAMMPSDumpFileFormat::PopulateDatabaseMetaData(avtDatabaseMetaData *md, int t
mmd
->
unitCellOrigin
[
2
]
=
zMin
;
md
->
Add
(
mmd
);
AddScalarVarToMetaData
(
md
,
"species"
,
"mesh"
,
AVT_NODECENT
);
for
(
int
v
=
0
;
v
<
nVars
;
v
++
)
{
if
(
v
==
idIndex
||
v
==
speciesIndex
)
continue
;
AddScalarVarToMetaData
(
md
,
varNames
[
v
],
"mesh"
,
AVT_NODECENT
);
}
if
(
atomVars
.
HasIds
())
{
AddScalarVarToMetaData
(
md
,
"id"
,
"mesh"
,
AVT_NODECENT
);
}
if
(
atomVars
.
HasTypes
())
{
AddScalarVarToMetaData
(
md
,
"species"
,
"mesh"
,
AVT_NODECENT
);
}
for
(
AtomInfo
::
name_iterator
v
=
atomVars
.
GetVariableNamesBegin
();
v
!=
atomVars
.
GetVariableNamesEnd
();
++
v
)
{
AddScalarVarToMetaData
(
md
,
*
v
,
"mesh"
,
AVT_NODECENT
);
}
md
->
SetCycles
(
cycles
);
md
->
SetCyclesAreAccurate
(
true
);
...
...
@@ -302,35 +309,35 @@ avtLAMMPSDumpFileFormat::GetMesh(int timestep, const char *name)
z
=
zMax
;
pts
->
SetPoint
(
j
,
x
,
y
,
z
);
}
vtkCellArray
*
lines
=
vtkCellArray
::
New
();
pd
->
SetLines
(
lines
);
lines
->
Delete
();
for
(
int
k
=
0
;
k
<
12
;
k
++
)
{
lines
->
InsertNextCell
(
2
);
lines
->
InsertCellPoint
(
voxVerticesFromEdges
[
k
][
0
]);
lines
->
InsertCellPoint
(
voxVerticesFromEdges
[
k
][
1
]);
}
lines
->
FastDelete
();
return
pd
;
}
if
(
meshname
!=
"mesh"
)
{
return
NULL
;
}
vtkPolyData
*
pd
=
vtkPolyData
::
New
();
vtkPoints
*
pts
=
vtkPoints
::
New
();
pts
->
SetNumberOfPoints
(
nAtoms
[
timestep
]);
pd
->
SetPoints
(
pts
);
pts
->
Delete
();
for
(
int
j
=
0
;
j
<
nAtoms
[
timestep
]
;
j
++
)
for
(
vtkIdType
j
=
0
;
j
<
nAtoms
[
timestep
]
;
j
++
)
{
double
x
=
v
ars
[
xIndex
][
j
];
double
y
=
v
ars
[
yIndex
][
j
];
double
z
=
v
ars
[
zIndex
][
j
];
double
x
=
atomV
ars
[
xIndex
][
j
];
double
y
=
atomV
ars
[
yIndex
][
j
];
double
z
=
atomV
ars
[
zIndex
][
j
];
if
(
xScaled
)
x
=
xMin
+
(
xMax
-
xMin
)
*
x
;
if
(
yScaled
)
...
...
@@ -339,16 +346,30 @@ avtLAMMPSDumpFileFormat::GetMesh(int timestep, const char *name)
z
=
zMin
+
(
zMax
-
zMin
)
*
z
;
pts
->
SetPoint
(
j
,
x
,
y
,
z
);
}
vtkCellArray
*
verts
=
vtkCellArray
::
New
();
pd
->
SetVerts
(
verts
);
verts
->
Delete
();
for
(
int
k
=
0
;
k
<
nAtoms
[
timestep
]
;
k
++
)
pd
->
SetPoints
(
pts
);
pts
->
FastDelete
();
const
vtkIdType
numCells
=
nAtoms
[
timestep
];
const
vtkIdType
arrayLen
=
numCells
*
2
;
//since these are verts
vtkIdTypeArray
*
rawCellArray
=
vtkIdTypeArray
::
New
();
rawCellArray
->
SetNumberOfValues
(
arrayLen
);
vtkIdType
pointId
=
0
;
for
(
vtkIdType
k
=
0
;
k
<
arrayLen
;
k
+=
2
,
++
pointId
)
{
verts
->
InsertNextCell
(
1
);
verts
->
InsertCellP
oint
(
k
);
rawCellArray
->
SetValue
(
k
,
1
);
rawCellArray
->
SetValue
(
k
+
1
,
p
oint
Id
);
}
vtkCellArray
*
verts
=
vtkCellArray
::
New
();
verts
->
SetCells
(
numCells
,
rawCellArray
);
pd
->
SetVerts
(
verts
);
rawCellArray
->
FastDelete
();
verts
->
FastDelete
();
return
pd
;
}
...
...
@@ -387,26 +408,24 @@ avtLAMMPSDumpFileFormat::GetVar(int timestep, const char *varname)
// element is a built-in variable
if
(
string
(
varname
)
==
"species"
)
{
vtkFloatArray
*
scalars
=
vtkFloatArray
::
New
();
scalars
->
SetNumberOfTuples
(
nAtoms
[
timestep
]);
float
*
ptr
=
(
float
*
)
scalars
->
GetVoidPointer
(
0
);
for
(
int
i
=
0
;
i
<
nAtoms
[
timestep
];
i
++
)
{
ptr
[
i
]
=
speciesVar
[
i
];
}
return
scalars
;
vtkIntArray
*
species
=
vtkIntArray
::
New
();
species
->
SetNumberOfTuples
(
nAtoms
[
timestep
]);
int
*
ptr
=
(
int
*
)
species
->
GetVoidPointer
(
0
);
std
::
copy
(
atomVars
.
GetTypes
().
begin
(),
atomVars
.
GetTypes
().
end
(),
ptr
);
return
species
;
}
int
varIndex
=
-
1
;
for
(
int
v
=
0
;
v
<
nVars
;
v
++
)
else
if
(
string
(
varname
)
==
"id"
)
{
if
(
varNames
[
v
]
==
varname
)
{
varIndex
=
v
;
break
;
}
vtkIntArray
*
ids
=
vtkIntArray
::
New
();
ids
->
SetNumberOfTuples
(
nAtoms
[
timestep
]);
int
*
ptr
=
(
int
*
)
ids
->
GetVoidPointer
(
0
)
;
std
::
copy
(
atomVars
.
GetIds
().
begin
(),
atomVars
.
GetIds
().
end
(),
ptr
)
;
return
ids
;
}
int
varIndex
=
atomVars
.
GetVarIndex
(
varname
);
if
(
varIndex
==
-
1
)
{
EXCEPTION1
(
InvalidVariableException
,
varname
);
...
...
@@ -416,10 +435,7 @@ avtLAMMPSDumpFileFormat::GetVar(int timestep, const char *varname)
vtkFloatArray
*
scalars
=
vtkFloatArray
::
New
();
scalars
->
SetNumberOfTuples
(
nAtoms
[
timestep
]);
float
*
ptr
=
(
float
*
)
scalars
->
GetVoidPointer
(
0
);
for
(
int
i
=
0
;
i
<
nAtoms
[
timestep
];
i
++
)
{
ptr
[
i
]
=
vars
[
varIndex
][
i
];
}
std
::
copy
(
atomVars
[
varIndex
].
begin
(),
atomVars
[
varIndex
].
end
(),
ptr
);
return
scalars
;
}
...
...
@@ -485,42 +501,44 @@ avtLAMMPSDumpFileFormat::ReadTimeStep(int timestep)
OpenFileAtBeginning
();
in
.
seekg
(
file_positions
[
timestep
]);
speciesVar
.
resize
(
nAtoms
[
timestep
]);
for
(
int
v
=
0
;
v
<
vars
.
size
();
v
++
)
{
// id and species are ints; don't bother with the float arrays for them
if
(
v
==
idIndex
||
v
==
speciesIndex
)
continue
;
vars
[
v
].
resize
(
nAtoms
[
timestep
]);
}
std
::
vector
<
double
>
tmpVars
(
nVars
);
int
tmpID
,
tmpSpecies
;
atomVars
.
SetNumberOfAtoms
(
nAtoms
[
timestep
]);
int
tmpID
=
0
,
tmpSpecies
=
0
;
char
buff
[
1000
];
// read all the atoms
// the atoms aren't in ascending id order. Instead
// they are just N atoms with unique ids that can be any positive value
// for now we drop the ids completely
for
(
int
a
=
0
;
a
<
nAtoms
[
timestep
];
a
++
)
{
in
.
getline
(
buff
,
1000
);
istringstream
sin
(
buff
);
for
(
int
v
=
0
;
v
<
nVars
;
v
++
)
{
if
(
v
==
speciesIndex
)
sin
>>
tmpSpecies
;
else
if
(
v
==
idIndex
)
sin
>>
tmpID
;
else
sin
>>
tmpVars
[
v
];
}
--
tmpID
;
// 1-origin; we need 0-origin
for
(
int
v
=
0
;
v
<
nVars
;
v
++
)
int
lineIndex
=
0
;
int
atomVarIndex
=
0
;
while
(
sin
.
good
())
{
if
(
v
==
idIndex
||
v
==
speciesIndex
)
continue
;
vars
[
v
][
tmpID
]
=
tmpVars
[
v
];
if
(
lineIndex
==
speciesIndex
)
{
sin
>>
tmpSpecies
;
atomVars
.
SetType
(
a
,
tmpSpecies
-
1
);
}
else
if
(
lineIndex
==
idIndex
)
{
//skip the id
//they arent consecutive or all below the number
//of atoms + 1
sin
>>
tmpID
;
atomVars
.
SetId
(
a
,
tmpID
);
}
else
{
sin
>>
atomVars
[
atomVarIndex
][
a
];
++
atomVarIndex
;
}
++
lineIndex
;
}
speciesVar
[
tmpID
]
=
tmpSpecies
-
1
;
}
}
...
...
@@ -567,7 +585,6 @@ avtLAMMPSDumpFileFormat::ReadAllMetaData()
char
buff
[
1000
];
nTimeSteps
=
0
;
nVars
=
-
1
;
while
(
in
)
{
...
...
@@ -607,54 +624,57 @@ avtLAMMPSDumpFileFormat::ReadAllMetaData()
{
istream
::
pos_type
current_pos
=
in
.
tellg
();
file_positions
.
push_back
(
current_pos
);
if
(
nVars
==
-
1
)
if
(
atomVars
.
GetNumberOfVariables
()
==
0
)
{
istringstream
sin
(
&
buff
[
11
]);
string
varName
;
xScaled
=
yScaled
=
zScaled
=
false
;
int
variableIndex
=
0
;
int
lineIndex
=
0
;
while
(
sin
>>
varName
)
{
if
(
varName
==
"id"
)
idIndex
=
(
in
t
)
varNames
.
size
()
;
idIndex
=
l
in
eIndex
;
else
if
(
varName
==
"type"
)
speciesIndex
=
(
in
t
)
varNames
.
size
()
;
else
if
(
varName
==
"x"
||
varName
==
"xs"
||
speciesIndex
=
l
in
eIndex
;
else
if
(
varName
==
"x"
||
varName
==
"xs"
||
varName
==
"xu"
||
varName
==
"xsu"
)
xIndex
=
(
int
)
varNames
.
size
()
;
xIndex
=
variableIndex
++
;
else
if
(
varName
==
"y"
||
varName
==
"ys"
||
varName
==
"yu"
||
varName
==
"ysu"
)
yIndex
=
(
int
)
varNames
.
size
()
;
yIndex
=
variableIndex
++
;
else
if
(
varName
==
"z"
||
varName
==
"zs"
||
varName
==
"zu"
||
varName
==
"zsu"
)
zIndex
=
(
int
)
varNames
.
size
()
;
zIndex
=
variableIndex
++
;
if
(
varName
==
"xs"
||
"xsu"
)
if
(
varName
==
"xs"
||
varName
==
"xsu"
)
xScaled
=
true
;
if
(
varName
==
"ys"
||
"ysu"
)
if
(
varName
==
"ys"
||
varName
==
"ysu"
)
yScaled
=
true
;
if
(
varName
==
"zs"
||
"zsu"
)
if
(
varName
==
"zs"
||
varName
==
"zsu"
)
zScaled
=
true
;
varNames
.
push_back
(
varName
);
atomVars
.
AddVariable
(
varName
);
++
lineIndex
;
}
nVars
=
(
int
)
varNames
.
size
();
if
(
nVars
==
0
)
if
(
atomVars
.
GetNumberOfVariables
()
==
0
)
{
// OLD FORMAT: Assume "id type x y z"
varNames
.
push_back
(
"id"
);
varNames
.
push_back
(
"type"
);
varNames
.
push_back
(
"x"
);
varNames
.
push_back
(
"y"
);
varNames
.
push_back
(
"z"
);
atomVars
.
AddVariable
(
"id"
);
atomVars
.
AddVariable
(
"type"
);
atomVars
.
AddVariable
(
"x"
);
atomVars
.
AddVariable
(
"y"
);
atomVars
.
AddVariable
(
"z"
);
idIndex
=
0
;
speciesIndex
=
1
;
xIndex
=
2
;
xScaled
=
false
;
yIndex
=
3
;
yScaled
=
false
;
zIndex
=
4
;
zScaled
=
false
;
nVars
=
(
int
)
varNames
.
size
();
//these indices are in the atomVars, id and species
//are line based indices
xIndex
=
0
;
xScaled
=
false
;
yIndex
=
1
;
yScaled
=
false
;
zIndex
=
2
;
zScaled
=
false
;
}
vars
.
resize
(
nVars
);
}
}
}
...
...
databases/LAMMPS/avtLAMMPSDumpFileFormat.h
View file @
0a2b981e
...
...
@@ -34,7 +34,92 @@
class
avtLAMMPSDumpFileFormat
:
public
avtMTSDFileFormat
{
public:
private:
struct
AtomInfo
{
AtomInfo
()
:
vars
(),
names
(),
types
(),
ids
(),
enableType
(
false
),
enableIds
(
false
),
numVars
(
0
){}
void
Clear
()
{
vars
.
resize
(
0
);
names
.
resize
(
0
);
types
.
resize
(
0
);
ids
.
resize
(
0
);
enableType
=
false
;
enableIds
=
false
;
numVars
=
0
;
};
void
AddVariable
(
const
std
::
string
&
name
)
{
//if it is id or type we don't push back since it is stored separately
if
(
name
==
"id"
)
{
enableIds
=
true
;
}
if
(
name
==
"type"
)
{
enableType
=
true
;
}
else
{
names
.
push_back
(
name
);
vars
.
resize
(
names
.
size
());
}
++
numVars
;
}
int
GetNumberOfVariables
()
const
{
return
numVars
;
}
void
SetNumberOfAtoms
(
std
::
size_t
size
)
{
if
(
HasIds
())
{
ids
.
resize
(
size
);
}
if
(
HasTypes
())
{
types
.
resize
(
size
);
}
for
(
std
::
size_t
i
=
0
;
i
<
vars
.
size
();
++
i
)
{
vars
[
i
].
resize
(
size
);
}
}
//helper methods to get the variable names
typedef
std
::
vector
<
std
::
string
>::
const_iterator
name_iterator
;
name_iterator
GetVariableNamesBegin
()
const
{
return
names
.
begin
();
}
name_iterator
GetVariableNamesEnd
()
const
{
return
names
.
end
();
}
int
GetVarIndex
(
const
std
::
string
&
n
)
const