Commit 4d9792d6 authored by Shawn Waldon's avatar Shawn Waldon

Added test for GenericIO writer and fixed bugs

The new test exposed several bugs in the GenericIO writer and these are
fixed in this commit as well.  Also, I had to add ParaView XML for the
multiblock genericio reader in this commit to get the test to work.

Change-Id: I1695b31f8373ef6864aa3d82e88b73548a9153be
parent 6ab57547
......@@ -293,6 +293,23 @@ if (PARAVIEW_USE_MPI)
# Test uses D3 which is available in MPI only builds.
${CMAKE_CURRENT_SOURCE_DIR}/GridConnectivity.xml
)
if (PARAVIEW_ENABLE_COSMOTOOLS)
# Test the Generic IO file writer in VTKExtensions/CosmoTools
add_client_tests("pv"
--mpi
BASELINE_DIR ${PARAVIEW_TEST_BASELINE_DIR}
TEST_SCRIPTS ${CMAKE_CURRENT_SOURCE_DIR}/GenericIOReadWrite.xml
)
add_client_server_tests("pvcs"
BASELINE_DIR ${PARAVIEW_TEST_BASELINE_DIR}
TEST_SCRIPTS ${CMAKE_CURRENT_SOURCE_DIR}/GenericIOReadWrite.xml
)
add_client_render_server_tests("pvcrs"
BASELINE_DIR ${PARAVIEW_TEST_BASELINE_DIR}
TEST_SCRIPTS ${CMAKE_CURRENT_SOURCE_DIR}/GenericIOReadWrite.xml
)
endif()
endif()
if(PARAVIEW_ENABLE_PYTHON)
list(APPEND TESTS_WITH_BASELINES
......
<?xml version="1.0" ?>
<pqevents>
<pqevent object="pqClientMainWindow/MainControlsToolbar/1QToolButton0" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/FileOpenDialog" command="filesSelected" arguments="$PARAVIEW_DATA_ROOT/genericio/m000.499.allparticles" />
<pqevent object="pqClientMainWindow/pqSelectReaderDialog/listWidget" command="mousePress" arguments="1,1,0,123,8,/12:0" />
<pqevent object="pqClientMainWindow/pqSelectReaderDialog/listWidget" command="mouseRelease" arguments="1,0,0,123,8,/12:0" />
<pqevent object="pqClientMainWindow/pqSelectReaderDialog/okButton" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/ProxyPanel/PointArrayStatus/ArraySelectionWidget/1QHeaderView0" command="mousePress" arguments="1,1,0,0,0,0" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/ProxyPanel/PointArrayStatus/ArraySelectionWidget/1QHeaderView0" command="mouseRelease" arguments="1,0,0,0,0,0" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/ProxyPanel/yAxis/ComboBox" command="set_string" arguments="y" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/ProxyPanel/zAxis/ComboBox" command="set_string" arguments="z" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/Accept" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/MainControlsToolbar/1QToolButton1" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/FileSaveDialog" command="filesSelected" arguments="/tmp/test_writer.gio" />
<pqevent object="pqClientMainWindow/MainControlsToolbar/1QToolButton0" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/FileOpenDialog" command="filesSelected" arguments="/tmp/test_writer.gio" />
<pqevent object="pqClientMainWindow/pqSelectReaderDialog/listWidget" command="mousePress" arguments="1,1,0,177,6,/0:0" />
<pqevent object="pqClientMainWindow/pqSelectReaderDialog/listWidget" command="mouseRelease" arguments="1,0,0,177,6,/0:0" />
<pqevent object="pqClientMainWindow/pqSelectReaderDialog/listWidget" command="mouseDblClick" arguments="1,1,0,177,6,/0:0" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/ProxyPanel/PointArrayStatus/ArraySelectionWidget/1QHeaderView0" command="mousePress" arguments="1,1,0,0,0,0" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/ProxyPanel/PointArrayStatus/ArraySelectionWidget/1QHeaderView0" command="mouseRelease" arguments="1,0,0,0,0,0" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/ProxyPanel/yAxis/ComboBox" command="set_string" arguments="yy" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/ProxyPanel/zAxis/ComboBox" command="set_string" arguments="zz" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/Accept" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/pipelineBrowserDock/pipelineBrowser" command="mousePress" arguments="1,1,0,9,8,/0:0/0:1" />
<pqevent object="pqClientMainWindow/pipelineBrowserDock/pipelineBrowser" command="mouseRelease" arguments="1,0,0,9,8,/0:0/0:1" />
<pqevent object="pqClientMainWindow/variableToolbar/displayColor/Variables" command="set_string" arguments="vx" />
</pqevents>
......@@ -25,6 +25,7 @@ set_property(GLOBAL PROPERTY
${CMAKE_CURRENT_LIST_DIR}/resources/AdaptiveCosmoReader.xml
${CMAKE_CURRENT_LIST_DIR}/resources/CosmoReader.xml
${CMAKE_CURRENT_LIST_DIR}/resources/GenericIOReader.xml
${CMAKE_CURRENT_LIST_DIR}/resources/GenericIOWriter.xml
${CMAKE_CURRENT_LIST_DIR}/resources/MultiResolutionGenericIOReader.xml
## CosmoTools Filters
......
......@@ -156,6 +156,106 @@
</IntVectorProperty>
</SourceProxy>
<SourceProxy class="vtkPGenericIOMultiBlockReader" name="genericio_multiblock">
<StringVectorProperty animateable="0"
command="SetFileName"
name="FileName"
number_of_elements="1"
panel_visibility="never">
<FileListDomain name="files" />
<Documentation>
This property specifies the file name for the GenericIO reader.
</Documentation>
</StringVectorProperty>
<StringVectorProperty information_only="1" name="PointArrayInfo">
<ArraySelectionInformationHelper attribute_name="Point" />
</StringVectorProperty>
<StringVectorProperty command="GetArrayList"
information_only="1"
name="PointArrayListInfo">
<StringArrayHelper />
</StringVectorProperty>
<StringVectorProperty name="xAxis"
command="SetXAxisVariableName"
number_of_elements="1">
<StringListDomain name="array_list">
<RequiredProperties>
<Property function="ArrayList" name="PointArrayListInfo" />
</RequiredProperties>
</StringListDomain>
</StringVectorProperty>
<StringVectorProperty name="yAxis"
command="SetYAxisVariableName"
number_of_elements="1">
<StringListDomain name="array_list">
<RequiredProperties>
<Property function="ArrayList" name="PointArrayListInfo" />
</RequiredProperties>
</StringListDomain>
</StringVectorProperty>
<StringVectorProperty name="zAxis"
command="SetZAxisVariableName"
number_of_elements="1">
<StringListDomain name="array_list">
<RequiredProperties>
<Property function="ArrayList" name="PointArrayListInfo" />
</RequiredProperties>
</StringListDomain>
</StringVectorProperty>
<StringVectorProperty command="SetPointArrayStatus"
element_types="2 0"
information_property="PointArrayInfo"
label="Particle Data"
name="PointArrayStatus"
number_of_elements="0"
number_of_elements_per_command="2"
repeat_command="1">
<ArraySelectionDomain name="array_list">
<RequiredProperties>
<Property function="ArrayList" name="PointArrayInfo" />
</RequiredProperties>
</ArraySelectionDomain>
<Documentation>
This property lists which data arrays to read.
</Documentation>
</StringVectorProperty>
<IntVectorProperty
name="ReadMethod"
command="SetGenericIOType"
number_of_elements="1"
default_values="1">
<EnumerationDomain name="io_method">
<Entry value="0" text="MPI"/>
<Entry value="1" text="Posix"/>
</EnumerationDomain>
<Documentation>
Method used for reading, either MPI or POSIX is used.
</Documentation>
</IntVectorProperty>
<IntVectorProperty
name="BlockAssignmentStrategy"
command="SetBlockAssignment"
number_of_elements="1"
default_values="0">
<EnumerationDomain name="assignment_strategy">
<Entry value="0" text="RoundRobin"/>
<Entry value="1" text="RCB (contiguous)"/>
</EnumerationDomain>
<Documentation>
Method used to assign blocks to processes.
</Documentation>
</IntVectorProperty>
</SourceProxy>
</ProxyGroup>
<ProxyGroup name="sources">
......@@ -216,9 +316,66 @@
</DoubleVectorProperty>
<Hints>
<ReaderFactory extensions="gio"
file_description="GenericIO files" />
file_description="GenericIO files to UnstructuredGrid" />
</Hints>
</SourceProxy>
<SourceProxy class="vtkFileSeriesReader"
file_name_method="SetFileName"
name="GenericIOMultiBlockReader"
si_class="vtkSIMetaReaderProxy"
mpi_required="1" >
<Documentation long_help="Reads a cosmology file into a vtkMultiBlockDataSet."
short_help="Read a cosmology file.">
Reads GenericIO files into a vtkMultiBlockDataSet of unstructured grids.
</Documentation>
<SubProxy>
<Proxy name="Reader"
proxygroup="cosmotools_internal_sources"
proxyname="genericio_multiblock">
</Proxy>
<ExposedProperties>
<Property name="PointArrayListInfo" />
<Property name="PointArrayInfo" />
<Property name="PointArrayStatus" />
<Property name="xAxis" />
<Property name="yAxis" />
<Property name="zAxis" />
<Property name="ReadMethod"/>
<Property name="BlockAssignmentStrategy"/>
</ExposedProperties>
</SubProxy>
<StringVectorProperty command="GetCurrentFileName"
information_only="1"
name="FileNameInfo">
<SimpleStringInformationHelper />
</StringVectorProperty>
<StringVectorProperty animateable="0"
clean_command="RemoveAllFileNames"
command="AddFileName"
information_property="FileNameInfo"
name="FileName"
number_of_elements="1"
panel_visibility="never"
repeat_command="1">
<FileListDomain name="files" />
<Documentation>
The list of files to be read by the reader.
</Documentation>
</StringVectorProperty>
<DoubleVectorProperty information_only="1"
name="TimestepValues"
repeatable="1">
<TimeStepsInformationHelper />
<Documentation>
Available timestep values.
</Documentation>
</DoubleVectorProperty>
<Hints>
<ReaderFactory extensions="gio"
file_description="GenericIO files to MultiBlockDataSet" />
</Hints>
</SourceProxy>
</ProxyGroup>
</ServerManagerConfiguration>
<ServerManagerConfiguration>
<ProxyGroup name="writers">
<WriterProxy name="GenericIOWriter"
class="vtkPGenericIOMultiBlockWriter"
requires_mpi="1"
supports_parallel="1">
<Documentation
short_help="Write GenericIO files from multiblock data.">
Writer to write GenericIO files from multiblock data, each block will
become one rank's data in the GenericIO file.
</Documentation>
<InputProperty name="Input" command="SetInputConnection">
<ProxyGroupDomain name="groups">
<Group name="sources"/>
<Group name="filters"/>
</ProxyGroupDomain>
<DataTypeDomain name="input_type">
<DataType value="vtkMultiBlockDataSet"/>
</DataTypeDomain>
</InputProperty>
<StringVectorProperty
name="FileName"
command="SetFileName"
number_of_elements="1">
<Documentation>
The name of the file to be written.
</Documentation>
</StringVectorProperty>
<Hints>
<Property name="Input" show="0"/>
<Property name="FileName" show="0"/>
<WriterFactory extensions="gio" file_description="Generic IO Files"/>
</Hints>
</WriterProxy>
</ProxyGroup>
</ServerManagerConfiguration>
......@@ -89,26 +89,39 @@ int vtkPGenericIOMultiBlockWriter::FillInputPortInformation(int port, vtkInforma
static inline void addCoordinates(std::map< std::pair< int, std::string >, std::vector< char > >& dataArrays,
gio::GenericIOWriter* writer, vtkUnstructuredGrid* grid, uint64_t blockId)
{
std::pair< int, std::string > x(blockId,"x");
std::pair< int, std::string > y(blockId,"y");
std::pair< int, std::string > z(blockId,"z");
std::string xName = "x", yName = "y", zName = "z";
while (grid->GetPointData()->HasArray(xName.c_str()))
{
xName += "x";
}
while (grid->GetPointData()->HasArray(yName.c_str()))
{
yName += "y";
}
while (grid->GetPointData()->HasArray(zName.c_str()))
{
zName += "z";
}
std::pair< int, std::string > x(blockId,xName);
std::pair< int, std::string > y(blockId,yName);
std::pair< int, std::string > z(blockId,zName);
dataArrays[x] = std::vector< char >();
dataArrays[y] = std::vector< char >();
dataArrays[z] = std::vector< char >();
std::vector< char >& xData = dataArrays[x];
std::vector< char >& yData = dataArrays[y];
std::vector< char >& zData = dataArrays[z];
if (!writer->HasVariable("x"))
if (!writer->HasVariable(xName.c_str()))
{
writer->AddVariable("x",gio::GENERIC_IO_DOUBLE_TYPE,gio::GenericIOWriter::ValueIsPhysCoordX);
writer->AddVariable(xName.c_str(),gio::GENERIC_IO_DOUBLE_TYPE,gio::GenericIOWriter::ValueIsPhysCoordX);
}
if (!writer->HasVariable("y"))
if (!writer->HasVariable(yName.c_str()))
{
writer->AddVariable("y",gio::GENERIC_IO_DOUBLE_TYPE,gio::GenericIOWriter::ValueIsPhysCoordY);
writer->AddVariable(yName.c_str(),gio::GENERIC_IO_DOUBLE_TYPE,gio::GenericIOWriter::ValueIsPhysCoordY);
}
if (!writer->HasVariable("z"))
if (!writer->HasVariable(zName.c_str()))
{
writer->AddVariable("z",gio::GENERIC_IO_DOUBLE_TYPE,gio::GenericIOWriter::ValueIsPhysCoordZ);
writer->AddVariable(zName.c_str(),gio::GENERIC_IO_DOUBLE_TYPE,gio::GenericIOWriter::ValueIsPhysCoordZ);
}
vtkIdType numPoints = grid->GetNumberOfPoints();
xData.resize(numPoints * sizeof(double));
......@@ -351,6 +364,32 @@ void vtkPGenericIOMultiBlockWriter::WriteData()
{
vtkWarningMacro(<< "genericio_global_dimension field data array is missing, this data will not be encoded in the output file.");
}
if (this->Controller->GetNumberOfProcesses() > 1)
{
std::vector< char > hasBlock, duplicates;
hasBlock.resize(input->GetNumberOfBlocks(),0);
duplicates.resize(hasBlock.size());
for (unsigned i = 0; i < input->GetNumberOfBlocks(); ++i)
{
vtkUnstructuredGrid* grid = vtkUnstructuredGrid::SafeDownCast(input->GetBlock(i));
if (grid != NULL)
{
hasBlock[i] = 1;
}
}
this->Controller->AllReduce(&hasBlock[0],&duplicates[0],hasBlock.size(),
vtkCommunicator::LOGICAL_AND_OP);
for (size_t i = 0; i < duplicates.size(); ++i)
{
if (duplicates[i] != 0)
{
vtkErrorMacro(<< "Blocks are duplicated across processes, this writer expects"
" each block to be present on exactly one process. Aborting write operation.");
this->SetErrorCode(78); // I have no idea what to put here, so 78 it is!
return;
}
}
}
for (unsigned i = 0; i < input->GetNumberOfBlocks(); ++i)
{
vtkUnstructuredGrid* grid = vtkUnstructuredGrid::SafeDownCast(input->GetBlock(i));
......
......@@ -27,7 +27,7 @@ class VTKPVVTKEXTENSIONSCOSMOTOOLS_EXPORT vtkPGenericIOMultiBlockWriter : public
{
public:
static vtkPGenericIOMultiBlockWriter* New();
vtkTypeMacro(vtkPGenericIOMultiBlockWriter, vtkObject);
vtkTypeMacro(vtkPGenericIOMultiBlockWriter, vtkWriter);
void PrintSelf(ostream& os, vtkIndent indent);
vtkSetStringMacro(FileName);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment