Skip to content
Snippets Groups Projects
Commit 8542a88b authored by Kenneth Moreland's avatar Kenneth Moreland Committed by Kitware Robot
Browse files

Merge topic 'adios2-vtx-misspell'


24959a33 Add protection for missing arrays in ADIOS2 VTX reader

Acked-by: default avatarKitware Robot <kwrobot@kitware.com>
Tested-by: default avatarbuildbot <buildbot@kitware.com>
Reviewed-by: default avatarWilliam F Godoy <williamfgc@yahoo.com>
Acked-by: default avatarWilliam F Godoy <williamfgc@yahoo.com>
Merge-request: !11426
parents 3085c814 24959a33
No related branches found
No related tags found
No related merge requests found
Add protection for missing arrays in ADIOS2 VTX reader
Previously, when the ADIOS2 VTX reader read in most data arrays from the
ADIOS2 file, it would silently leave a null array if that array did not
exist. This opened up the likely consequence of the program later
crashing when the reader attempted to use this array.
Instead, the reader now reports an error when an array it attempts to
read in is missing. This prevents subsequent problems.
......@@ -457,6 +457,41 @@ void WriteBPFileNoPieceVTU(const std::string& fileName)
fs.close();
}
void WriteBPFileMissingTypes(const std::string& fileName)
{
const std::string unstructureGridSchema = R"(
<VTKFile type="UnstructuredGrid">
<UnstructuredGrid>
<Piece>
<Points>
<DataArray Name="vertices" />
</Points>
<Cells>
<DataArray Name="connectivity" />
<DataArray Name="types" />
</Cells>
<PointData>
<DataArray Name="sol" />
</PointData>
</Piece>
</UnstructuredGrid>
</VTKFile>)";
ADIOS_OPEN(fs, fileName);
std::vector<uint32_t> dummyConnectivity(18, 1);
std::vector<double> dummyVertices(9, 1.05);
std::vector<double> dummySol(3, -1);
fs.write("type", 1);
fs.write("connectivity", dummyConnectivity.data(), {}, {}, {});
fs.write("vertices", dummyVertices.data(), {}, {}, {});
fs.write("sol", dummySol.data(), {}, {}, {});
fs.write_attribute("vtk.xml", unstructureGridSchema);
fs.close();
}
void WriteBPFileUnsupportedShape(const std::string& fileName)
{
const std::string unstructureGridSchema = R"(
......@@ -704,6 +739,7 @@ int UnitTestIOADIOS2VTX(int argc, char* argv[])
ADIOS2VTK_UNIT_TEST(WriteBPFileWrongNodePC2)
ADIOS2VTK_UNIT_TEST(WriteBPFileNoPieceVTI)
ADIOS2VTK_UNIT_TEST(WriteBPFileNoPieceVTU)
ADIOS2VTK_UNIT_TEST(WriteBPFileMissingTypes)
ADIOS2VTK_UNIT_TEST(WriteBPFileUnsupportedShape)
ADIOS2VTK_UNIT_TEST(WriteBPFileUnsupportedType)
}
......
......@@ -69,6 +69,8 @@ void VTXSchema::GetDataArray(
if (type.empty())
{
throw std::invalid_argument(
"ERROR: variable `" + variableName + "` not present " + "in Engine " + this->Engine.Name());
}
#define declare_type(T) \
else if (type == adios2::GetType<T>()) \
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment