Commit 59d5e69f authored by whitlocb's avatar whitlocb

Merge Cumulative Query Selections to the trunk.



git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@14998 18c085ea-50e0-402c-830e-de6fd14e8384
parent af23a380
......@@ -51,6 +51,9 @@
# Hank Childs, Thu Aug 26 13:47:30 PDT 2010
# Renamed avtCurrentExtentFilter to avtActualExtentsFilter.
#
# Brad Whitlock, Fri Dec 10 16:21:23 PST 2010
# I moved avtThresholdFilter to here from the Threshold plugin.
#
#****************************************************************************/
SET(AVTFILTERS_SOURCES
......@@ -95,6 +98,7 @@ avtStreamlineFilter.C
avtStreamlinePolyDataFilter.C
avtSummationFilter.C
avtSurfaceFilter.C
avtThresholdFilter.C
avtTiledImageCompositor.C
avtTransform.C
avtVertexNormalsFilter.C
......
/*****************************************************************************
*
* Copyright (c) 2000 - 2011, Lawrence Livermore National Security, LLC
* Copyright (c) 2000 - 2010, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-442911
* All rights reserved.
......@@ -142,7 +142,7 @@ avtThresholdFilter::Create()
void
avtThresholdFilter::SetAtts(const AttributeGroup *a)
{
atts = *(const ThresholdAttributes*)a;
atts = *(const ThresholdOpAttributes*)a;
atts.SupplyMissingDefaultsIfAppropriate();
......@@ -188,7 +188,7 @@ avtThresholdFilter::SetAtts(const AttributeGroup *a)
bool
avtThresholdFilter::Equivalent(const AttributeGroup *a)
{
return (atts == *(ThresholdAttributes*)a);
return (atts == *(ThresholdOpAttributes*)a);
}
......@@ -290,7 +290,7 @@ avtThresholdFilter::ProcessOneChunk(
return in_ds;
}
if (atts.GetOutputMeshType() == ThresholdAttributes::PointMesh)
if (atts.GetOutputMeshType() == ThresholdOpAttributes::PointMesh)
{
return ThresholdToPointMesh(in_ds);
}
......@@ -349,11 +349,11 @@ avtThresholdFilter::ProcessOneChunk(
0, 0, 0, vtkDataObject::FIELD_ASSOCIATION_POINTS_THEN_CELLS,
vtkDataSetAttributes::SCALARS);
if (curZonePortions[curVarNum] == (int)ThresholdAttributes::PartOfZone)
if (curZonePortions[curVarNum] == (int)ThresholdOpAttributes::PartOfZone)
{
threshold->AllScalarsOff();
}
else if (curZonePortions[curVarNum] == (int)ThresholdAttributes::EntireZone)
else if (curZonePortions[curVarNum] == (int)ThresholdOpAttributes::EntireZone)
{
threshold->AllScalarsOn();
}
......@@ -667,7 +667,7 @@ avtThresholdFilter::GetAssignments(vtkDataSet *in_ds, const int *dims,
if (varIsPointData)
{
if (curZonePortions[curVarNum] == ThresholdAttributes::PartOfZone)
if (curZonePortions[curVarNum] == ThresholdOpAttributes::PartOfZone)
{
for (zoneNum = 0; zoneNum < zoneCount; zoneNum++)
curVarZDs[zoneNum] = avtStructuredMeshChunker::DISCARD;
......@@ -748,7 +748,7 @@ avtThresholdFilter::UpdateDataObjectInfo(void)
{
GetOutput()->GetInfo().GetValidity().InvalidateZones();
if (atts.GetOutputMeshType() == ThresholdAttributes::PointMesh)
if (atts.GetOutputMeshType() == ThresholdOpAttributes::PointMesh)
{
GetOutput()->GetInfo().GetAttributes().SetTopologicalDimension(0);
}
......@@ -1074,15 +1074,13 @@ avtThresholdFilter::ModifyContract(avtContract_p in_spec)
lowerBound = curLowerBounds[listedVarNum];
upperBound = curUpperBounds[listedVarNum];
selIDs[std::string(curListedVars[listedVarNum])] =
outSpec->GetDataRequest()->AddDataSelection(
new avtDataRangeSelection(
std::string(curListedVars[listedVarNum]),
lowerBound, upperBound
)
std::string curVar(curListedVars[listedVarNum]);
selIDs[curVar] = outSpec->GetDataRequest()->AddDataSelection(
new avtDataRangeSelection(curVar, lowerBound, upperBound)
);
debug1 << "Added variable " << curListedVar[listedVarNum]
debug1 << "Added variable " << curVar
<< " as Data Selection with range ("
<< lowerBound << ", " << upperBound << ")" << endl;
}
......
/*****************************************************************************
*
* Copyright (c) 2000 - 2011, Lawrence Livermore National Security, LLC
* Copyright (c) 2000 - 2010, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-442911
* All rights reserved.
......@@ -40,14 +40,16 @@
// File: avtThresholdFilter.h
// ************************************************************************* //
#ifndef AVT_Threshold_FILTER_H
#define AVT_Threshold_FILTER_H
#ifndef AVT_THRESHOLD_FILTER_H
#define AVT_THRESHOLD_FILTER_H
#include <filters_exports.h>
#include <map>
#include <string>
#include <avtPluginStructuredChunkDataTreeIterator.h>
#include <ThresholdAttributes.h>
#include <ThresholdOpAttributes.h>
#include <avtGhostData.h>
......@@ -91,7 +93,7 @@ class vtkDataSet;
//
// ****************************************************************************
class avtThresholdFilter : public avtPluginStructuredChunkDataTreeIterator
class AVTFILTERS_API avtThresholdFilter : public avtPluginStructuredChunkDataTreeIterator
{
public:
avtThresholdFilter();
......@@ -110,8 +112,8 @@ class avtThresholdFilter : public avtPluginStructuredChunkDataTreeIterator
const std::string &);
protected:
ThresholdAttributes atts;
std::string activeVarName;
ThresholdOpAttributes atts;
std::string activeVarName;
std::map<std::string,int> selIDs;
virtual avtContract_p ModifyContract(avtContract_p);
......
......@@ -42,6 +42,9 @@
# Tom Fogal, Tue Aug 10 12:55:19 MDT 2010
# Added include directory.
#
# Brad Whitlock, Mon Dec 13 16:13:43 PST 2010
# I added avtNamedSelectionExtension.
#
#****************************************************************************/
SET(DATA_SOURCES
......@@ -126,6 +129,7 @@ Pipeline/avtImageTiler.C
Pipeline/avtImageWriter.C
Pipeline/avtMultiWindowSaver.C
Pipeline/avtNamedSelection.C
Pipeline/avtNamedSelectionExtension.C
Pipeline/avtNamedSelectionManager.C
Pipeline/avtNullDataReader.C
Pipeline/avtNullDataWriter.C
......
/*****************************************************************************
*
* Copyright (c) 2000 - 2010, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-442911
* All rights reserved.
*
* This file is part of VisIt. For details, see https://visit.llnl.gov/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer (as noted below) in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the LLNS/LLNL nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
* LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/
#include <avtNamedSelectionExtension.h>
avtNamedSelectionExtension::avtNamedSelectionExtension()
{
}
avtNamedSelectionExtension::~avtNamedSelectionExtension()
{
}
void
avtNamedSelectionExtension::FreeUpResources()
{
}
/*****************************************************************************
*
* Copyright (c) 2000 - 2010, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-442911
* All rights reserved.
*
* This file is part of VisIt. For details, see https://visit.llnl.gov/. The
* full copyright notice is contained in the file COPYRIGHT located at the root
* of the VisIt distribution or at http://www.llnl.gov/visit/copyright.html.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* - Redistributions of source code must retain the above copyright notice,
* this list of conditions and the disclaimer below.
* - Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the disclaimer (as noted below) in the
* documentation and/or other materials provided with the distribution.
* - Neither the name of the LLNS/LLNL nor the names of its contributors may
* be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL LAWRENCE LIVERMORE NATIONAL SECURITY,
* LLC, THE U.S. DEPARTMENT OF ENERGY OR CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
*****************************************************************************/
#ifndef AVT_NAMED_SELECTION_EXTENSION_H
#define AVT_NAMED_SELECTION_EXTENSION_H
#include <pipeline_exports.h>
#include <avtDataObject.h>
#include <SelectionProperties.h>
// ****************************************************************************
// Class: avtNamedSelectionExtension
//
// Purpose:
// This is a base class for objects that can perform additional setup when
// creating named selections. The extra setup can be used to influence how
// the selection is created.
//
// Notes:
//
// Programmer: Brad Whitlock
// Creation: Mon Dec 13 16:09:53 PST 2010
//
// Modifications:
//
// ****************************************************************************
class PIPELINE_API avtNamedSelectionExtension
{
public:
avtNamedSelectionExtension();
virtual ~avtNamedSelectionExtension();
virtual avtDataObject_p GetSelectedData(avtDataObject_p dob,
avtContract_p contract,
const SelectionProperties &props) = 0;
virtual void FreeUpResources();
};
#endif
......@@ -42,6 +42,7 @@
#include <sstream>
#include <avtNamedSelectionManager.h>
#include <avtNamedSelectionExtension.h>
#include <vtkCellData.h>
#include <vtkDataArray.h>
......@@ -108,13 +109,18 @@ avtNamedSelectionManager::GetInstance(void)
return instance;
}
// ****************************************************************************
// Method: avtNamedSelectionManager::CreateNamedSelection
//
// Purpose:
// Creates a named selection from a data object.
//
// Arguments:
// dob : The data object used to create the named selection.
// selProps : The named selection properties.
// ext : The named selection extension object that helps set up the
// pipeline and contract.
//
// Programmer: Hank Childs
// Creation: January 30, 2009
//
......@@ -130,11 +136,16 @@ avtNamedSelectionManager::GetInstance(void)
// Automatically save out an internal named selection, for fault tolerance
// and for save/restore sessions.
//
// Brad Whitlock, Mon Dec 13 15:59:51 PST 2010
// I added support for named selection "extensions" that add more stuff
// to the pipeline before we reexecute it. I also changed things so we pass
// in selection properties.
//
// ****************************************************************************
void
avtNamedSelectionManager::CreateNamedSelection(avtDataObject_p dob,
const std::string &selName)
const SelectionProperties &selProps, avtNamedSelectionExtension *ext)
{
int i;
......@@ -143,6 +154,9 @@ avtNamedSelectionManager::CreateNamedSelection(avtDataObject_p dob,
EXCEPTION1(VisItException, "Named selections only work on data sets");
}
// Save the selection properties.
AddSelectionProperties(selProps);
avtContract_p c1 = dob->GetContractFromPreviousExecution();
avtContract_p contract;
if (c1->GetDataRequest()->NeedZoneNumbers() == false)
......@@ -161,6 +175,7 @@ avtNamedSelectionManager::CreateNamedSelection(avtDataObject_p dob,
// Let the input try to create the named selection ... some have special
// logic, for example the parallel coordinates filter.
//
const std::string &selName = selProps.GetName();
avtNamedSelection *ns = dob->GetSource()->CreateNamedSelection(contract,
selName);
if (ns != NULL)
......@@ -178,15 +193,30 @@ avtNamedSelectionManager::CreateNamedSelection(avtDataObject_p dob,
return;
}
if (c1->GetDataRequest()->NeedZoneNumbers() == false)
bool needZoneNumbers = c1->GetDataRequest()->NeedZoneNumbers() == false;
avtDataset_p ds;
if(ext != 0)
{
debug1 << "Must re-execute pipeline to create named selection" << endl;
dob->Update(contract);
debug1 << "Done re-executing pipeline to create named selection" << endl;
// Perform additional setup using the extension.
avtDataObject_p newdob = ext->GetSelectedData(dob, contract, selProps);
debug5 << "Must execute the pipeline to create the named selection" << endl;
newdob->Update(contract);
debug5 << "Done executing the pipeline to create the named selection" << endl;
CopyTo(ds, newdob);
}
else
{
if (needZoneNumbers)
{
debug1 << "Must re-execute pipeline to create named selection" << endl;
dob->Update(contract);
debug1 << "Done re-executing pipeline to create named selection" << endl;
}
CopyTo(ds, dob);
}
avtDataset_p ds;
CopyTo(ds, dob);
avtDataTree_p tree = ds->GetDataTree();
std::vector<int> doms;
std::vector<int> zones;
......@@ -223,6 +253,10 @@ avtNamedSelectionManager::CreateNamedSelection(avtDataObject_p dob,
}
delete [] leaves;
// Let the extension free its resources. (We could just do this later...)
if(ext != 0)
ext->FreeUpResources();
// Note the poor use of MPI below, coded for expediency, as I believe all
// of the named selections will be small.
int *numPerProcIn = new int[PAR_Size()];
......@@ -518,4 +552,73 @@ avtNamedSelectionManager::CreateQualifiedSelectionName(const std::string &name,
return qualName;
}
// ****************************************************************************
// Method: avtNamedSelectionManager::GetSelectionProperties
//
// Purpose:
// Gets the selection properties based on the selection name.
//
// Arguments:
// selName : The name of the selection for which to get selection properties.
//
// Returns: A pointer to the selection properties or NULL if not found.
//
// Note:
//
// Programmer: Brad Whitlock
// Creation: Tue Dec 14 14:19:56 PST 2010
//
// Modifications:
//
// ****************************************************************************
const SelectionProperties *
avtNamedSelectionManager::GetSelectionProperties(const std::string &selName) const
{
for(size_t i = 0; i < properties.size(); ++i)
{
if(selName == properties[i].GetName())
return &properties[i];
}
return NULL;
}
// ****************************************************************************
// Method: avtNamedSelectionManager::AddSelectionProperties
//
// Purpose:
// Adds the new selection properties to the list of selection properties,
// overwriting properties with the same name, if present.
//
// Arguments:
// srcp : The new selection properties.
//
// Returns:
//
// Note:
//
// Programmer: Brad Whitlock
// Creation: Tue Dec 14 14:21:14 PST 2010
//
// Modifications:
//
// ****************************************************************************
void
avtNamedSelectionManager::AddSelectionProperties(const SelectionProperties &srcp)
{
SelectionProperties *p = NULL;
for(size_t i = 0; i < properties.size(); ++i)
{
if(srcp.GetName() == properties[i].GetName())
{
p = &properties[i];
break;
}
}
if(p != NULL)
*p = srcp;
else
properties.push_back(srcp);
}
......@@ -44,11 +44,11 @@
#include <vector>
#include <avtDataObject.h>
#include <SelectionProperties.h>
#include <visitstream.h>
class avtNamedSelection;
class avtNamedSelectionExtension;
// ****************************************************************************
// Class: avtNamedSelectionManager
......@@ -69,6 +69,15 @@ class avtNamedSelection;
// loading of selections to help with fault tolerance, save/restore
// sessions, etc.
//
// Brad Whitlock, Mon Dec 13 16:15:41 PST 2010
// I added an avtNamedSelectionExtension argument to CreateNamedSelection,
// which lets us pass in an object that can perform additional setup for a
// selection based on its properties. This class manages named selections,
// which are the actual resulting data that is used to restrict selections.
// I also added selection properties which describe how the selection was
// defined. These properties can be queried in the event that we need to
// create a selection using some other method.
//
// ****************************************************************************
class PIPELINE_API avtNamedSelectionManager
......@@ -83,17 +92,24 @@ class PIPELINE_API avtNamedSelectionManager
avtNamedSelection *
GetNamedSelection(const std::string &);
void CreateNamedSelection(avtDataObject_p, const std::string &);
void CreateNamedSelection(avtDataObject_p,
const SelectionProperties &,
avtNamedSelectionExtension *);
void DeleteNamedSelection(const std::string &,
bool expectThisSelToBeThere = true);
bool LoadNamedSelection(const std::string &, bool = false);
void SaveNamedSelection(const std::string &, bool = false);
const SelectionProperties *GetSelectionProperties(const std::string &selName) const;
protected:
static avtNamedSelectionManager *instance;
std::vector<avtNamedSelection *> selList;
void AddSelectionProperties(const SelectionProperties &);
std::vector<SelectionProperties> properties;
private:
// These methods are defined to prevent accidental use of bitwise copy
// implementations. If you want to re-define them to do something
......
......@@ -1067,6 +1067,32 @@ SumIntAcrossAllProcessors(int &value)
#endif
}
// ****************************************************************************
// Function: SumLongAcrossAllProcessors
//
// Purpose:
// Sums a single int across all processors.
//
// Arguments:
// value The input and output.
//
// Programmer: Jeremy Meredith
// Creation: April 17, 2003
//
// Modifications:
//
// ****************************************************************************
void
SumLongAcrossAllProcessors(long &value)
{
#ifdef PARALLEL
long newvalue;
MPI_Allreduce(&value, &newvalue, 1, MPI_LONG, MPI_SUM,
VISIT_MPI_COMM);
value = newvalue;
#endif
}
// ****************************************************************************
// Function: SumDoubleAcrossAllProcessors
......@@ -1221,6 +1247,34 @@ void BroadcastInt(int &i)
#endif
}
// ****************************************************************************
// Function: BroadcastIntArray
//
// Purpose:
// Broadcast an array of int from processor 0 to all other processors.
//
// Arguments:
// array : The array to send (or receive on non-rank-0).
// nArray : The number of values to send/receive.
//
// Returns:
//
// Note:
//
// Programmer: Brad Whitlock
// Creation: Fri May 20 15:00:02 PDT 2011
//
// Modifications:
//
// ****************************************************************************
void BroadcastIntArray(int *array, int nArray)
{
#ifdef PARALLEL
MPI_Bcast(array, nArray, MPI_INT, 0, VISIT_MPI_COMM);
#endif
}
// ****************************************************************************
// Function: BroadcastIntVector
//
......@@ -1355,6 +1409,34 @@ void BroadcastDouble(double &i)
#endif
}
// ****************************************************************************
// Function: BroadcastDoubleArray
//
// Purpose:
// Broadcast an array of double from processor 0 to all other processors.
//
// Arguments:
// array : The array to send (or receive on non-rank-0).
// nArray : The number of values to send/receive.
//
// Returns:
//
// Note:
//
// Programmer: Brad Whitlock
// Creation: Fri May 20 15:00:02 PDT 2011
//
// Modifications:
//
// ****************************************************************************
void BroadcastDoubleArray(double *array, int nArray)
{
#ifdef PARALLEL
MPI_Bcast(array, nArray, MPI_DOUBLE, 0, VISIT_MPI_COMM);
#endif
}
// ****************************************************************************
// Function: BroadcastDoubleVector
//
......@@ -1662,12 +1744,20 @@ bool GetListToRootProc(std::vector<std::string> &vars, int total)
// Creation: June 22, 2009
//
// Modifications:
// Brad Whitlock, Fri May 20 13:54:46 PDT 2011
// I moved the body into a static helper that I templated so I could add
// another version that uses doubles.
//
// ****************************************************************************
void
CollectIntArraysOnRootProc(int *&receiveBuf, int *&receiveCounts,
int *sendBuf, int sendCount)
template <class T>
static void
CollectArraysOnRootProc(T *&receiveBuf, int *&receiveCounts,
T *sendBuf, int sendCount
#ifdef PARALLEL
, MPI_Datatype dataType
#endif
)
{
#ifdef PARALLEL
int rank = PAR_Rank();
......@@ -1702,11 +1792,11 @@ CollectIntArraysOnRootProc(int *&receiveBuf, int *&receiveCounts,
nReceiveBuf += receiveCounts[i];
// Allocate it.
receiveBuf = new int[nReceiveBuf];
receiveBuf = new T[nReceiveBuf];
}
MPI_Gatherv(sendBuf, sendCount, MPI_INT, receiveBuf,
receiveCounts, procOffset, MPI_INT, 0, VISIT_MPI_COMM);
MPI_Gatherv(sendBuf, sendCount, dataType, receiveBuf,
receiveCounts, procOffset, dataType, 0, VISIT_MPI_COMM);
if (rank == 0)
{
......@@ -1716,87 +1806,34 @@ CollectIntArraysOnRootProc(int *&receiveBuf, int *&receiveCounts,
receiveCounts = new int[1];
receiveCounts[0] = sendCount;
receiveBuf = new int[sendCount];
receiveBuf = new T[sendCount];
for (int i = 0; i < sendCount; i++)
receiveBuf[i] = sendBuf[i];
#endif