Commit d766306d authored by Mathieu Westphal's avatar Mathieu Westphal

Add a new AppendReduce Filter

ParaView miss a usable and exposed ReductionFilter
This commit modify the reduction filter
to make it more usable while keeping it's default behavior
for rendering usage. It also expose a AppendReduce
filter which by default Reduce all dataset on all nodes
using an AppendFilter.
This also add a test for the new filter.
parent a0ce32f8
......@@ -138,6 +138,7 @@
<Proxy group="filters" name="Append" />
<Proxy group="filters" name="AppendAttributes" />
<Proxy group="filters" name="AppendPolyData" />
<Proxy group="filters" name="AppendReductionFilter" />
<Proxy group="filters" name="AngularPeriodicFilter" />
<Proxy group="filters" name="ArbitrarySourceStreamTracer" />
<Proxy group="filters" name="BlockIdScalars" />
......
<?xml version="1.0" ?>
<pqevents>
<pqevent object="pqClientMainWindow/menubar" command="activate" arguments="menuSources" />
<pqevent object="pqClientMainWindow/menubar/menuSources" command="activate" arguments="SphereSource" />
<pqevent object="pqClientMainWindow/1QTabBar1" command="set_tab_with_text" arguments="Properties" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/Accept" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/variableToolbar/displayColor/Variables" command="activated" arguments="vtkProcessId" />
<pqevent object="pqClientMainWindow/menubar" command="activate" arguments="menuFilters" />
<pqevent object="pqClientMainWindow/menubar/menuFilters/Alphabetical" command="activate" arguments="AppendReductionFilter" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/Accept" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/variableToolbar/displayColor/Variables" command="activated" arguments="vtkProcessId" />
<pqevent object="pqClientMainWindow/1QTabBar1" command="set_tab_with_text" arguments="Information" />
<pqcheck object="pqClientMainWindow/informationDock/informationWidgetFrame/informationScrollArea/qt_scrollarea_viewport/informationWidget/groupBox/type" property="text" arguments="Unstructured Grid" />
<pqcheck object="pqClientMainWindow/informationDock/informationWidgetFrame/informationScrollArea/qt_scrollarea_viewport/informationWidget/groupBox/dataTypeProperties/DataSet/numberOfCells" property="text" arguments="192" />
<pqcheck object="pqClientMainWindow/informationDock/informationWidgetFrame/informationScrollArea/qt_scrollarea_viewport/informationWidget/groupBox/dataTypeProperties/DataSet/numberOfPoints" property="text" arguments="128" />
<pqevent object="pqClientMainWindow/1QTabBar1" command="set_tab_with_text" arguments="Properties" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/ProxyPanel/ReductionMode/ComboBox" command="activated" arguments="Move all data to one processor" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/Accept" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/1QTabBar1" command="set_tab_with_text" arguments="Information" />
<pqcheck object="pqClientMainWindow/informationDock/informationWidgetFrame/informationScrollArea/qt_scrollarea_viewport/informationWidget/groupBox/dataTypeProperties/DataSet/numberOfPoints" property="text" arguments="64" />
<pqcheck object="pqClientMainWindow/informationDock/informationWidgetFrame/informationScrollArea/qt_scrollarea_viewport/informationWidget/groupBox/dataTypeProperties/DataSet/numberOfCells" property="text" arguments="96" />
<pqcheck object="pqClientMainWindow/informationDock/informationWidgetFrame/informationScrollArea/qt_scrollarea_viewport/informationWidget/groupBox/type" property="text" arguments="Unstructured Grid" />
<pqevent object="pqClientMainWindow/1QTabBar1" command="set_tab_with_text" arguments="Properties" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/ProxyPanel/ReductionMode/ComboBox" command="activated" arguments="Reduce all data to one processor" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/Accept" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/1QTabBar1" command="set_tab_with_text" arguments="Information" />
<pqcheck object="pqClientMainWindow/informationDock/informationWidgetFrame/informationScrollArea/qt_scrollarea_viewport/informationWidget/groupBox/dataTypeProperties/DataSet/numberOfPoints" property="text" arguments="96" />
<pqcheck object="pqClientMainWindow/informationDock/informationWidgetFrame/informationScrollArea/qt_scrollarea_viewport/informationWidget/groupBox/dataTypeProperties/DataSet/numberOfCells" property="text" arguments="144" />
<pqcheck object="pqClientMainWindow/informationDock/informationWidgetFrame/informationScrollArea/qt_scrollarea_viewport/informationWidget/groupBox/type" property="text" arguments="Unstructured Grid" />
<pqevent object="pqClientMainWindow/1QTabBar1" command="set_tab_with_text" arguments="Properties" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/ProxyPanel/ReductionMode/ComboBox" command="activated" arguments="Move all data to one processor" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/Accept" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/menubar" command="activate" arguments="menuSources" />
<pqevent object="pqClientMainWindow/menubar/menuSources" command="activate" arguments="RTAnalyticSource" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/Accept" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/representationToolbar/displayRepresentation/comboBox" command="activated" arguments="Surface" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_vcontainer/1QScrollBar0" command="mousePress" arguments="1,1,0,3,58" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_vcontainer/1QScrollBar0" command="mouseMove" arguments="1,0,0,-12,176" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_vcontainer/1QScrollBar0" command="mouseRelease" arguments="1,0,0,-12,176" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/DisplayFrame/ProxyPanel/Opacity/DoubleRangeWidget/LineEdit" command="set_string" arguments="0" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/DisplayFrame/ProxyPanel/Opacity/DoubleRangeWidget/LineEdit" command="set_string" arguments="0." />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/DisplayFrame/ProxyPanel/Opacity/DoubleRangeWidget/LineEdit" command="set_string" arguments="0.2" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/DisplayFrame/ProxyPanel/Opacity/DoubleRangeWidget/LineEdit" command="key" arguments="16777248" />
<pqevent object="pqClientMainWindow/cameraToolbar/actionResetCamera" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/variableToolbar/displayColor/Variables" command="activated" arguments="vtkProcessId" />
<pqevent object="pqClientMainWindow/menubar" command="activate" arguments="menuFilters" />
<pqevent object="pqClientMainWindow/menubar/menuFilters/Alphabetical" command="activate" arguments="AppendReductionFilter" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_vcontainer/1QScrollBar0" command="mousePress" arguments="1,1,0,7,59" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_vcontainer/1QScrollBar0" command="mouseRelease" arguments="1,0,0,7,59" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/PropertiesFrame/ProxyPanel/ReductionMode/ComboBox" command="activated" arguments="Move all data to one processor" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/Accept" command="activate" arguments="" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_vcontainer/1QScrollBar0" command="mousePress" arguments="1,1,0,12,63" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_vcontainer/1QScrollBar0" command="mouseMove" arguments="1,0,0,-3,151" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_vcontainer/1QScrollBar0" command="mouseRelease" arguments="1,0,0,-3,151" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/DisplayFrame/ProxyPanel/Opacity/DoubleRangeWidget/Slider" command="set_int" arguments="0" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/DisplayFrame/ProxyPanel/Opacity/DoubleRangeWidget/LineEdit" command="set_string" arguments="0" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/DisplayFrame/ProxyPanel/Opacity/DoubleRangeWidget/Slider" command="set_int" arguments="20" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/DisplayFrame/ProxyPanel/Opacity/DoubleRangeWidget/LineEdit" command="set_string" arguments="0.2" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/DisplayFrame/ProxyPanel/Opacity/DoubleRangeWidget/LineEdit" command="set_string" arguments="0.2" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/DisplayFrame/ProxyPanel/Opacity/DoubleRangeWidget/LineEdit" command="key" arguments="16777248" />
<pqevent object="pqClientMainWindow/propertiesDock/propertiesPanel/scrollArea/qt_scrollarea_viewport/scrollAreaWidgetContents/DisplayFrame/ProxyPanel/Opacity/DoubleRangeWidget/LineEdit" command="key" arguments="16777220" />
<pqevent object="pqClientMainWindow/variableToolbar/displayColor/Variables" command="activated" arguments="vtkProcessId" />
<pqevent object="pqClientMainWindow/menubar/menuTools" command="activate" arguments="actionTesting_Window_Size" />
</pqevents>
......@@ -424,7 +424,6 @@ if (PARAVIEW_USE_MPI)
# Test Use Data Partitions for volume rendering
#${CMAKE_CURRENT_SOURCE_DIR}/UseDataPartitions.xml
)
# This test requires a parallel partition to make sense so we
......@@ -433,6 +432,18 @@ if (PARAVIEW_USE_MPI)
TEST_SCRIPTS ${CMAKE_CURRENT_SOURCE_DIR}/UseDataPartitions.xml
)
# Test AppendReduce which can only be tested with non-built-in mode
add_client_server_tests("pvcs"
BASELINE_DIR ${PARAVIEW_TEST_BASELINE_DIR}
TEST_SCRIPTS ${CMAKE_CURRENT_SOURCE_DIR}/AppendReduce.xml
)
# Test AppendReduce which can only be tested with non-built-in mode
add_client_server_tests("pvcrs"
BASELINE_DIR ${PARAVIEW_TEST_BASELINE_DIR}
TEST_SCRIPTS ${CMAKE_CURRENT_SOURCE_DIR}/AppendReduce.xml
)
# Test uses GhostCellsGenerator which is available in MPI only builds.
# As the test use pvtu writer/reader it does not work in built-in mode.
add_client_server_tests("pvcs"
......
......@@ -10817,6 +10817,84 @@ source.</Documentation>
<!-- End ClientServerMoveData -->
</SourceProxy>
<!-- ==================================================================== -->
<SourceProxy class="vtkReductionFilter"
name="AppendReductionFilter"
label="Append Reduce">
<InputProperty command="SetInputConnection"
name="Input">
<ProxyGroupDomain name="groups">
<Group name="sources" />
<Group name="filters" />
</ProxyGroupDomain>
<DataTypeDomain composite_data_supported="0"
name="input_type">
<DataType value="vtkDataSet" />
</DataTypeDomain>
<Documentation>Set the input to the Reduction filter.</Documentation>
</InputProperty>
<StringVectorProperty command="SetPostGatherHelperName"
name="PostGatherHelperName"
panel_visibility="never"
default_values="vtkAppendFilter"
number_of_elements="1">
<Documentation>Set the algorithm that takes multiple inputs and
produces a single reduced output.</Documentation>
</StringVectorProperty>
<IntVectorProperty command="SetReductionMode"
default_values="2"
name="ReductionMode"
number_of_elements="1">
<EnumerationDomain name="enum">
<Entry text="Reduce all data to one processor"
value="0" />
<Entry text="Move all data to one processor"
value="1" />
<Entry text="Reduce all data to all processors"
value="2" />
</EnumerationDomain>
<Documentation>Set the reduction mode. Reducing all data to one
processor means that the destination process will have all data while
each other process will still have it's own data. Moving all to one processor means
that the destination process will have all data while other process have no data
anymore. Reduce all data to all processors is self explanatory.</Documentation>
</IntVectorProperty>
<IntVectorProperty command="SetReductionProcessId"
default_values="0"
name="ReduceTo"
number_of_elements="1">
<IntRangeDomain min="0"
name="range" />
<Hints>
<PropertyWidgetDecorator type="GenericDecorator"
mode="visibility"
property="ReductionMode"
value="2"
inverse="1"/>
<!-- show this widget when ReductionMode is not 2 -->
</Hints>
<Documentation>Set the process to reduce to.</Documentation>
</IntVectorProperty>
<IntVectorProperty command="SetPassThrough"
default_values="-1"
name="OnlyFrom"
number_of_elements="1">
<IntRangeDomain min="-1"
name="range" />
<Documentation>If set to a non-negative value, then produce results
using only the node Id specified.</Documentation>
</IntVectorProperty>
<IntVectorProperty command="SetGenerateProcessIds"
default_values="0"
name="GenerateProcessIds"
number_of_elements="1">
<BooleanDomain name="bool" />
<Documentation>If true, the filter will generate vtkOriginalProcessIds
arrays indicating the process id on which the cell/point was
generated.</Documentation>
</IntVectorProperty>
<!-- End ReductionFilter -->
</SourceProxy>
<!-- ==================================================================== -->
<SourceProxy class="vtkReductionFilter"
name="ReductionFilter">
<InputProperty command="SetInputConnection"
......@@ -10827,6 +10905,25 @@ source.</Documentation>
</ProxyGroupDomain>
<Documentation>Set the input to the Reduction filter.</Documentation>
</InputProperty>
<IntVectorProperty command="SetReductionMode"
default_values="0"
name="ReductionMode"
number_of_elements="1">
<EnumerationDomain name="enum">
<Entry text="Move all data to one processor"
value="0" />
<Entry text="Reduce all data to one processor"
value="1" />
<Entry text="Reduce all data to all processors"
value="2" />
</EnumerationDomain>
</IntVectorProperty>
<IntVectorProperty command="SetReductionProcessId"
default_values="0"
name="ReduceTo"
number_of_elements="1">
</IntVectorProperty>
<StringVectorProperty command="SetPreGatherHelperName"
name="PreGatherHelperName"
number_of_elements="1">
......
......@@ -58,6 +58,8 @@ vtkReductionFilter::vtkReductionFilter()
this->PostGatherHelper = 0;
this->PassThrough = -1;
this->GenerateProcessIds = 0;
this->ReductionMode = vtkReductionFilter::REDUCE_ALL_TO_ONE;
this->ReductionProcessId = 0;
}
//-----------------------------------------------------------------------------
......@@ -345,21 +347,60 @@ void vtkReductionFilter::Reduce(vtkDataObject* input, vtkDataObject* output)
this->PassThrough = -1;
}
if (this->ReductionMode != vtkReductionFilter::REDUCE_ALL_TO_ALL)
{
if (this->ReductionProcessId < 0)
{
vtkWarningMacro("Cannot reduce to process:" << this->ReductionProcessId <<
" it is not a valid process id. Please use a value between 0 and " << numProcs - 1 << " .Reducing to process 0 instead");
this->ReductionProcessId = 0;
}
if (this->ReductionProcessId > numProcs - 1)
{
vtkWarningMacro("Cannot reduce to process:" << this->ReductionProcessId <<
" as there is only " << numProcs << " processes. Reducing to process 0 instead");
this->ReductionProcessId = 0;
}
}
std::vector<vtkSmartPointer<vtkDataObject> > data_sets;
std::vector<vtkSmartPointer<vtkDataObject> > receiveData(numProcs);
if (vtkSelection* sel = vtkSelection::SafeDownCast(preOutput))
{
this->GatherSelection(sel, receiveData, 0);
if (this->ReductionMode == vtkReductionFilter::REDUCE_ALL_TO_ALL)
{
for (int i = 0; i < controller->GetNumberOfProcesses(); i++)
{
this->GatherSelection(sel, receiveData, i);
}
}
else
{
this->GatherSelection(sel, receiveData, this->ReductionProcessId);
}
}
else
{
controller->Gather(preOutput, receiveData, 0);
if (this->ReductionMode == vtkReductionFilter::REDUCE_ALL_TO_ALL)
{
for (int i = 0; i < controller->GetNumberOfProcesses(); i++)
{
controller->Gather(preOutput, receiveData, i);
}
}
else
{
controller->Gather(preOutput, receiveData, this->ReductionProcessId);
}
}
// the reduction from all ranks may return NULL datasets on certain ranks.
// So, we need to handle receiveData having NULLs.
assert(static_cast<int>(receiveData.size()) == numProcs);
if (myId == 0)
if (myId == this->ReductionProcessId ||
this->ReductionMode == vtkReductionFilter::REDUCE_ALL_TO_ALL)
{
if (this->PassThrough >= 0 && receiveData[this->PassThrough] != NULL)
{
......@@ -376,13 +417,15 @@ void vtkReductionFilter::Reduce(vtkDataObject* input, vtkDataObject* output)
}
}
}
else if (myId > 0 && preOutput)
else if (myId != this->ReductionProcessId && preOutput &&
this->ReductionMode == vtkReductionFilter::REDUCE_ALL_TO_ONE)
{
data_sets.push_back(preOutput);
}
// Now run the PostGatherHelper.
// If myId==0, data_sets has datasets collected from all satellites otherwise
// If myId==this->ReductionProcessId or this->ReductionMode == vtkReductionFilter::REDUCE_ALL_TO_ALL
// data_sets has datasets collected from all satellites otherwise
// it contains the current process's result.
if (data_sets.size() > 0)
{
......
......@@ -47,6 +47,35 @@ public:
vtkTypeMacro(vtkReductionFilter, vtkDataObjectAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
typedef enum ReductionModeType
{
REDUCE_ALL_TO_ONE = 0,
MOVE_ALL_TO_ONE = 1,
REDUCE_ALL_TO_ALL = 2
} ReductionModeType;
//@{
/**
* Get/Set the Reduction Mode.
* REDUCE_ALL_TO_ONE is the default behavior.
* It reduces all data on a single node, while other nodes keeps their data.
* MOVE_ALL_TO_ONE Reduce all data on a single node while other nodes delete their data.
* ALL NODES Reduce all data on all nodes.
*/
vtkSetClampMacro(ReductionMode, int, vtkReductionFilter::REDUCE_ALL_TO_ONE,
vtkReductionFilter::REDUCE_ALL_TO_ALL);
vtkGetMacro(ReductionMode, int);
//@}
//@{
/**
* Get/Set the node to reduce to, default is 0.
* Not used with REDUCE_ALL_TO_ALL Reduction mode
*/
vtkSetMacro(ReductionProcessId, int);
vtkGetMacro(ReductionProcessId, int);
//@}
//@{
/**
* Get/Set the pre-reduction helper. Pre-Reduction helper is an algorithm
......@@ -132,6 +161,8 @@ protected:
vtkMultiProcessController* Controller;
int PassThrough;
int GenerateProcessIds;
int ReductionMode;
int ReductionProcessId;
private:
vtkReductionFilter(const vtkReductionFilter&) VTK_DELETE_FUNCTION;
......
82cce496484d91dcad4307f2b67e7c24
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