Commit ad73a04a authored by hrchilds's avatar hrchilds

Separate streamline and poincare specific code from avtStreamline

into avtStateRecorderIntegralCurve.


git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@11577 18c085ea-50e0-402c-830e-de6fd14e8384
parent 8207de42
......@@ -753,8 +753,13 @@ avtMasterSLAlgorithm::PrintStatus()
// Dave Pugmire, Wed Mar 25 10:04:29 EDT 2009
// Control print information for large domain problems.
//
// Hank Childs, Sat Jun 5 11:29:13 CDT 2010
// Change return type to void, since it wasn't returning anything and the
// calling function wasn't looking for a return value.
//
// ****************************************************************************
bool
void
avtMasterSLAlgorithm::UpdateSlaveStatus(vector<int> &status)
{
int src = status[0];
......
......@@ -152,8 +152,11 @@ class avtMasterSlaveSLAlgorithm : public avtParSLAlgorithm
// detect when slave set is done and mark done. Modify logic in how masters
// make decisions. Add domainOffloading (case 5).
//
// Dave Pugmire, Thu Sep 24 13:52:59 EDT 2009
// Change Execute to RunAlgorithm.
// Dave Pugmire, Thu Sep 24 13:52:59 EDT 2009
// Change Execute to RunAlgorithm.
//
// Hank Childs, Sat Jun 5 11:29:13 CDT 2010
// Change return value of UpdateSlaveStatus.
//
// ****************************************************************************
......@@ -204,7 +207,7 @@ class avtMasterSLAlgorithm : public avtMasterSlaveSLAlgorithm
void FindSlackers(int oobFactor=-1,
bool randomize= true,
bool checkJustUpdated=false);
bool UpdateSlaveStatus(std::vector<int> &);
void UpdateSlaveStatus(std::vector<int> &);
void PrintStatus();
void Case1(int &counter);
......
......@@ -419,7 +419,7 @@ avtParSLAlgorithm::MergeTerminatedSLSequences()
//Merge the sequences together, put them into terminated list.
for (int i = 0; i < seqs.size(); i++)
{
avtStreamline *s = avtStreamline::MergeStreamlineSequence(seqs[i]);
avtStreamline *s = seqs[i][0]->MergeIntegralCurveSequence(seqs[i]);
terminatedSLs.push_back(s);
}
}
......@@ -978,6 +978,10 @@ avtParSLAlgorithm::DoSendSLs(int dst,
// Hank Childs, Fri Jun 4 19:58:30 CDT 2010
// Use avtStreamlines, not avtStreamlineWrappers.
//
// Hank Childs, Sat Jun 5 16:21:27 CDT 2010
// Use the PICS filter to instantiate integral curves, as this is now
// an abstract type.
//
// ****************************************************************************
int
......@@ -1022,7 +1026,7 @@ avtParSLAlgorithm::RecvSLs(list<avtStreamline *> &recvSLs)
for (int j = 0; j < numSLs; j++)
{
avtStreamline *sl = new avtStreamline;
avtStreamline *sl = streamlineFilter->CreateIntegralCurve();
sl->Serialize(MemStream::READ, buff, GetSolver());
recvSLs.push_back(sl);
slCount++;
......
......@@ -89,6 +89,7 @@ Consider the leaveDomains SLs and the balancing at the same time.
#include <avtIntervalTree.h>
#include <avtMetaData.h>
#include <avtParallel.h>
#include <avtStateRecorderIntegralCurve.h>
#include <avtStreamline.h>
#include <avtVector.h>
......@@ -255,6 +256,26 @@ avtStreamlineFilter::~avtStreamlineFilter()
intersectObj->Delete();
}
// ****************************************************************************
// Method: avtStreamlineFilter::CreateIntegralCurve
//
// Purpose:
// Each derived type of avtPICSFilter must know how to create an integral
// curve. The streamline filter creates an avtStateRecorderIntegralCurve.
//
// Programmer: Hank Childs
// Creation: June 5, 2010
//
// ****************************************************************************
avtStreamline *
avtStreamlineFilter::CreateIntegralCurve(void)
{
return new avtStateRecorderIntegralCurve;
}
// ****************************************************************************
// Method: avtStreamlineFilter::ComputeRankList
//
......@@ -1977,12 +1998,13 @@ avtStreamlineFilter::DomainToRank(DomainType &domain)
// ****************************************************************************
void
avtStreamlineFilter::IntegrateDomain(avtStreamline *sl,
avtStreamlineFilter::IntegrateDomain(avtStreamline *sl2,
vtkDataSet *ds,
double *extents,
int maxSteps )
{
int t0 = visitTimer->StartTimer();
avtStateRecorderIntegralCurve *sl = (avtStateRecorderIntegralCurve *)sl2;
sl->scalars.resize(0);
if (coloringVariable != "")
sl->scalars.push_back(coloringVariable);
......@@ -2530,6 +2552,9 @@ avtStreamlineFilter::AddSeedpoints(std::vector<avtVector> &pts,
// Hank Childs, Fri Jun 4 19:58:30 CDT 2010
// Use avtStreamlines, not avtStreamlineWrappers.
//
// Hank Childs, Sat Jun 5 16:26:12 CDT 2010
// Use avtStateRecorderIntegralCurves.
//
// ****************************************************************************
void
......@@ -2537,16 +2562,16 @@ avtStreamlineFilter::CreateStreamlinesFromSeeds(std::vector<avtVector> &pts,
std::vector<avtStreamline *> &streamlines,
std::vector<std::vector<int> > &ids)
{
avtStreamline::ScalarValueType scalarVal = avtStreamline::NONE;
avtStateRecorderIntegralCurve::ScalarValueType scalarVal = avtStateRecorderIntegralCurve::NONE;
if (coloringMethod == STREAMLINE_COLOR_SPEED)
scalarVal = avtStreamline::SPEED;
scalarVal = avtStateRecorderIntegralCurve::SPEED;
else if (coloringMethod == STREAMLINE_COLOR_VORTICITY)
scalarVal = avtStreamline::VORTICITY;
scalarVal = avtStateRecorderIntegralCurve::VORTICITY;
else if (coloringMethod == STREAMLINE_COLOR_VARIABLE)
scalarVal = avtStreamline::SCALAR_VARIABLE;
scalarVal = avtStateRecorderIntegralCurve::SCALAR_VARIABLE;
if (displayMethod == STREAMLINE_DISPLAY_RIBBONS)
scalarVal = (avtStreamline::ScalarValueType)(scalarVal | avtStreamline::VORTICITY);
scalarVal = (avtStateRecorderIntegralCurve::ScalarValueType)(scalarVal | avtStateRecorderIntegralCurve::VORTICITY);
for (int i = 0; i < pts.size(); i++)
......@@ -2565,8 +2590,10 @@ avtStreamlineFilter::CreateStreamlinesFromSeeds(std::vector<avtVector> &pts,
if (streamlineDirection == VTK_INTEGRATE_FORWARD ||
streamlineDirection == VTK_INTEGRATE_BOTH_DIRECTIONS)
{
avtStreamline *sl = new avtStreamline(solver, seedTime0, pts[i],
GetNextStreamlineID());
avtStateRecorderIntegralCurve *sl = new
avtStateRecorderIntegralCurve(solver,
seedTime0, pts[i],
GetNextStreamlineID());
sl->SetScalarValueType(scalarVal);
sl->domain = dom;
......@@ -2580,7 +2607,9 @@ avtStreamlineFilter::CreateStreamlinesFromSeeds(std::vector<avtVector> &pts,
if (streamlineDirection == VTK_INTEGRATE_BACKWARD ||
streamlineDirection == VTK_INTEGRATE_BOTH_DIRECTIONS)
{
avtStreamline *sl = new avtStreamline(solver, seedTime0, pts[i],
avtStateRecorderIntegralCurve *sl = new
avtStateRecorderIntegralCurve(solver,
seedTime0, pts[i],
GetNextStreamlineID());
sl->SetScalarValueType(scalarVal);
sl->domain = dom;
......
......@@ -223,6 +223,9 @@ class avtSLAlgorithm;
// Hank Childs, Fri Jun 4 19:58:30 CDT 2010
// Use avtStreamlines, not avtStreamlineWrappers.
//
// Hank Childs, Sat Jun 5 16:21:27 CDT 2010
// Add virtual method CreateIntegralCurve.
//
// ****************************************************************************
class AVTFILTERS_API avtStreamlineFilter :
......@@ -237,6 +240,8 @@ class AVTFILTERS_API avtStreamlineFilter :
virtual const char *GetDescription(void)
{ return "Creating streamlines"; };
virtual avtStreamline *CreateIntegralCurve();
// Methods to set the filter's attributes.
void SetSourceType(int sourceType);
void SetMaxStepLength(double len);
......
......@@ -41,7 +41,7 @@
// ************************************************************************* //
#include <avtStreamlinePolyDataFilter.h>
#include "avtStreamline.h"
#include <vtkAppendPolyData.h>
#include <vtkCellArray.h>
#include <vtkCleanPolyData.h>
......@@ -53,6 +53,9 @@
#include <vtkRibbonFilter.h>
#include <vtkTubeFilter.h>
#include <avtParallel.h>
#include <avtStateRecorderIntegralCurve.h>
std::string avtStreamlinePolyDataFilter::colorvarArrayName = "colorVar";
std::string avtStreamlinePolyDataFilter::paramArrayName = "params";
std::string avtStreamlinePolyDataFilter::opacityArrayName = "opacity";
......@@ -107,8 +110,7 @@ avtStreamlinePolyDataFilter::CreateStreamlineOutput(
vtkAppendPolyData *append = vtkAppendPolyData::New();
for (int i = 0; i < streamlines.size(); i++)
{
avtStreamline *sl = (avtStreamline *) streamlines[i];
vector<float> thetas;
avtStreamline *sl = streamlines[i];
vtkPolyData *pd = GetVTKPolyData(sl, sl->id);
if (pd == NULL)
......@@ -170,11 +172,15 @@ avtStreamlinePolyDataFilter::CreateStreamlineOutput(
// Dave Pugmire, Tue Apr 6 08:24:44 EDT 2010
// Bug fix for setting opacity.
//
// Hank Childs, Sat Jun 5 16:24:25 CDT 2010
// Use avtStateRecorderIntegralCurves.
//
// ****************************************************************************
vtkPolyData *
avtStreamlinePolyDataFilter::GetVTKPolyData(avtStreamline *sl, int id)
avtStreamlinePolyDataFilter::GetVTKPolyData(avtStreamline *sl2, int id)
{
avtStateRecorderIntegralCurve *sl = (avtStateRecorderIntegralCurve *) sl2;
if (sl == NULL || sl->size() == 0)
return NULL;
......@@ -209,7 +215,7 @@ avtStreamlinePolyDataFilter::GetVTKPolyData(avtStreamline *sl, int id)
params->Allocate(sl->size());
tangents->SetNumberOfComponents(3);
tangents->SetNumberOfTuples(sl->size());
avtStreamline::iterator siter;
avtStateRecorderIntegralCurve::iterator siter;
unsigned int i = 0;
float val = 0.0, theta = 0.0, param = 0.0;
......
......@@ -36,6 +36,9 @@
#
# Modifications:
#
# Hank Childs, Sat Jun 5 16:26:46 CDT 2010
# Add avtStateRecorderIntegralCurve.
#
#****************************************************************************/
SET(AVTIVP_SOURCES
......@@ -46,6 +49,7 @@ avtIVPM3DC1Field.C
avtIVPM3DC1Integrator.C
avtIVPVTKField.C
avtIVPVTKTimeVaryingField.C
avtStateRecorderIntegralCurve.C
avtStreamline.C
MemStream.C
)
......
/*****************************************************************************
*
* Copyright (c) 2000 - 2010, Lawrence Livermore National Security, LLC
* Produced at the Lawrence Livermore National Laboratory
* LLNL-CODE-400124
* 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.
*
*****************************************************************************/
// ************************************************************************* //
// avtStateRecorderIntegralCurve.C //
// ************************************************************************* //
#include <avtStateRecorderIntegralCurve.h>
#include <list>
#include <iostream>
#include <limits>
#include <ImproperUseException.h>
#include <DebugStream.h>
#include <vtkPlane.h>
#include <avtVector.h>
#include <algorithm>
// ****************************************************************************
// Method: avtStateRecorderIntegralCurve constructor
//
// Programmer: Hank Childs
// Creation: June 4, 2010
//
// ****************************************************************************
avtStateRecorderIntegralCurve::avtStateRecorderIntegralCurve(const avtIVPSolver* model, const double& t_start,
const avtVector &p_start, int ID) :
avtStreamline(model, t_start, p_start, ID), scalarValueType(NONE)
{
intersectionsSet = false;
numIntersections = 0;
}
// ****************************************************************************
// Method: avtStateRecorderIntegralCurve constructor
//
// Programmer: Hank Childs
// Creation: June 4, 2010
//
// ****************************************************************************
avtStateRecorderIntegralCurve::avtStateRecorderIntegralCurve() :
scalarValueType(NONE)
{
intersectionsSet = false;
numIntersections = 0;
}
// ****************************************************************************
// Method: avtStateRecorderIntegralCurve destructor
//
// Programmer: Hank Childs
// Creation: June 4, 2010
//
// ****************************************************************************
avtStateRecorderIntegralCurve::~avtStateRecorderIntegralCurve()
{
for(iterator si = begin(); si != end(); si++)
delete *si;
}
// ****************************************************************************
// Method: avtStateRecorderIntegralCurve::GetVariableIdx
//
// Purpose:
// Lookup the index of a variable.
//
// Programmer: Dave Pugmire
// Creation: December 29, 2009
//
// Modifications:
//
// ****************************************************************************
int
avtStateRecorderIntegralCurve::GetVariableIdx(const std::string &var) const
{
for (int i = 0; i < scalars.size(); i++)
if (scalars[i] == var)
return i;
return -1;
}
// ****************************************************************************
// Method: avtStateRecorderIntegralCurve::AnalyzeStep
//
// Purpose:
// Analyzes the current step.
//
// Programmer: Hank Childs
// Creation: June 4, 2010
//
// ****************************************************************************
void
avtStateRecorderIntegralCurve::AnalyzeStep(avtIVPStep *step,
const avtIVPField* field,
avtIVPSolver::TerminateType termType,
double end, avtIVPSolver::Result *result)
{
if (intersectionsSet)
HandleIntersections(step, termType, end, result);
// record step if it was successful
if (*result == avtIVPSolver::OK ||
*result == avtIVPSolver::TERMINATE)
{
//Set scalar value, if any...
if (scalarValueType & VORTICITY)
step->ComputeVorticity(field);
if (scalarValueType & SPEED)
step->ComputeSpeed(field);
if (!scalars.empty())
step->ComputeScalarVariables(scalars, field);
avtIVPStep *s2 = new avtIVPStep(*step);
_steps.push_back(s2);
}
}
// ****************************************************************************
// Method: avtStateRecorderIntegralCurve::begin
//
// Purpose:
// Returns the first iterator.
//
// Programmer: Christoph Garth
// Creation: February 25, 2008
//
// ****************************************************************************
avtStateRecorderIntegralCurve::iterator
avtStateRecorderIntegralCurve::begin() const
{
return _steps.begin();
}
// ****************************************************************************
// Method: avtStateRecorderIntegralCurve::end
//
// Purpose:
// Returns the last iterator.
//
// Programmer: Christoph Garth
// Creation: February 25, 2008
//
// ****************************************************************************
avtStateRecorderIntegralCurve::iterator
avtStateRecorderIntegralCurve::end() const
{
return _steps.end();
}
// ****************************************************************************
// Method: avtStateRecorderIntegralCurve::size
//
// Purpose:
// Returns the number of iterations to do.
//
// Programmer: Christoph Garth
// Creation: February 25, 2008
//
// ****************************************************************************
size_t
avtStateRecorderIntegralCurve::size() const
{
return _steps.size();
}
// ****************************************************************************
// Method: avtStateRecorderIntegralCurve::SetIntersectionObject
//
// Purpose:
// Defines an object for streamline intersection.
//
// Programmer: Dave Pugmire
// Creation: August 10, 2009
//
// Modifications:
//
// Dave Pugmire, Tue Aug 18 08:47:40 EDT 2009
// Store plane equation.
//
// ****************************************************************************
void
avtStateRecorderIntegralCurve::SetIntersectionObject(vtkObject *obj)
{
// Only plane supported for now.
if (!obj->IsA("vtkPlane"))
EXCEPTION1(ImproperUseException, "Only plane supported.");
intersectionsSet = true;
avtVector intersectPlanePt = avtVector(((vtkPlane *)obj)->GetOrigin());
avtVector intersectPlaneNorm = avtVector(((vtkPlane *)obj)->GetNormal());
intersectPlaneNorm.normalize();
intersectPlaneEq[0] = intersectPlaneNorm.x;
intersectPlaneEq[1] = intersectPlaneNorm.y;
intersectPlaneEq[2] = intersectPlaneNorm.z;
intersectPlaneEq[3] = intersectPlanePt.length();
}
// ****************************************************************************
// Method: avtStateRecorderIntegralCurve::HandleIntersections
//
// Purpose:
// Defines an object for streamline intersection.
//
// Programmer: Dave Pugmire
// Creation: August 10, 2009
//
// Modifications:
//
// Dave Pugmire, Tue Aug 18 08:47:40 EDT 2009
// Don't record intersection points, just count them.
//
// Dave Pugmire, Fri Feb 19 16:57:04 EST 2010
// Replace _steps.size()==0 with _steps.empty()
//
// ****************************************************************************
void
avtStateRecorderIntegralCurve::HandleIntersections(avtIVPStep *step,
avtIVPSolver::TerminateType termType,
double end,
avtIVPSolver::Result *result)
{
if (step == NULL || _steps.empty())
return;
avtIVPStep *step0 = _steps.back();
if (IntersectPlane(step0->front(), step->front()))
{
numIntersections++;
if (termType == avtIVPSolver::INTERSECTIONS &&
numIntersections >= (int)end)
{
*result = avtIVPSolver::TERMINATE;
}
}
}
// ****************************************************************************
// Method: avtStateRecorderIntegralCurve::IntersectPlane
//
// Purpose:
// Intersect streamline with a plane.
//
// Programmer: Dave Pugmire
// Creation: August 10, 2009
//
// Modifications:
//
// Dave Pugmire, Tue Aug 18 08:47:40 EDT 2009
// Don't record intersection points, just count them.
//
// Dave Pugmire, Tue Dec 1 11:50:18 EST 2009
// Switch from avtVec to avtVector.
//
// ****************************************************************************
bool
avtStateRecorderIntegralCurve::IntersectPlane(const avtVector &p0, const avtVector &p1)
{
double distP0 = intersectPlaneEq[0] * p0.x +
intersectPlaneEq[1] * p0.y +
intersectPlaneEq[2] * p0.z +
intersectPlaneEq[3];
double distP1 = intersectPlaneEq[0] * p1.x +
intersectPlaneEq[1] * p1.y +
intersectPlaneEq[2] * p1.z +
intersectPlaneEq[3];
#define SIGN(x) ((x) < 0.0 ? -1 : 1)
// If either point on the plane, or points on opposite
// sides of the plane, the line intersects.
if (distP0 == 0.0 || distP1 == 0.0 ||
SIGN(distP0) != SIGN(distP1))
{
return true;
}
return false;
}
// ****************************************************************************
// Method: avtStateRecorderIntegralCurve::Serialize
//
// Purpose:
// Serializes a streamline so it can be sent to another processor.
//
// Programmer: Hank Childs
// Creation: June 4, 2010
//
// ****************************************************************************
void
avtStateRecorderIntegralCurve::Serialize(MemStream::Mode mode, MemStream &buff,
avtIVPSolver *solver)
{
// Have the base class serialize its part
avtStreamline::Serialize(mode, buff, solver);
bool serializeSteps = serializeFlags&SERIALIZE_STEPS;
if (DebugStream::Level5())