Commit cbb08446 authored by hrchilds's avatar hrchilds

Separate the sequence tracking communication pattern from the avtIntegralCurve base class.


git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@11598 18c085ea-50e0-402c-830e-de6fd14e8384
parent da71df69
......@@ -92,6 +92,9 @@ class avtICAlgorithm;
// Rename all methods and data members to reflect integral curves, not
// streamlines.
//
// Hank Childs, Tue Jun 8 09:11:36 CDT 2010
// Added communication pattern enum and virtual method.
//
// ****************************************************************************
class AVTFILTERS_API avtPICSFilter :
......@@ -99,6 +102,13 @@ class AVTFILTERS_API avtPICSFilter :
virtual public avtDatasetToDatasetFilter
{
public:
typedef enum
{
RestoreSequence = 0,
ReturnToOriginatingProcessor,
LeaveOnCurrentProcessor,
UndefinedCommunicationPattern
} CommunicationPattern;
avtPICSFilter();
virtual ~avtPICSFilter();
......@@ -112,6 +122,7 @@ class AVTFILTERS_API avtPICSFilter :
const double& t_start,
const avtVector &p_start, int ID) = 0;
virtual std::vector<avtVector> GetInitialLocations() = 0;
virtual CommunicationPattern GetCommunicationPattern() = 0;
// Methods to set the filter's attributes.
void SetMaxStepLength(double len);
......
......@@ -41,7 +41,11 @@
// ************************************************************************* //
#include "avtParICAlgorithm.h"
#include <avtStateRecorderIntegralCurve.h>
#include <TimingsManager.h>
#include <VisItException.h>
using namespace std;
......@@ -137,17 +141,45 @@ avtParICAlgorithm::InitializeBuffers(vector<avtIntegralCurve *> &seedPts,
// Method: avtParICAlgorithm::PostRunAlgorithm
//
// Purpose:
// Cleanup.
// Carry out whatever communication pattern is necessary to get the
// integral curves in their intended location.
//
// Programmer: Dave Pugmire
// Creation: September 24, 2009
//
// Modifications:
//
// Hank Childs, Tue Jun 8 09:30:45 CDT 2010
// Add infrastructure to support new communication patterns.
//
// ****************************************************************************
void
avtParICAlgorithm::PostRunAlgorithm()
{
ExchangeICSteps();
// We are enumerating the possible communication styles and then just
// calling the correct one. This is an okay solution if there are a small
// number of styles (which there are right now). That said, it would be
// perfectly fine if someone wanted to make this more extensible to handle
// a wide array of communication patterns ... it just didn't seem worth
// the effort when this was implemented.
avtPICSFilter::CommunicationPattern pattern =
picsFilter->GetCommunicationPattern();
if (pattern == avtPICSFilter::RestoreSequence)
RestoreIntegralCurveSequence();
else if (pattern == avtPICSFilter::LeaveOnCurrentProcessor)
;
else if (pattern == avtPICSFilter::ReturnToOriginatingProcessor)
{
EXCEPTION1(VisItException,
"This communication pattern has not been implemented.");
}
else
{
EXCEPTION1(VisItException, "Undefined communication pattern");
}
}
// ****************************************************************************
......@@ -213,7 +245,7 @@ CountIDs(list<avtIntegralCurve *> &l, int id)
}
// ****************************************************************************
// Method: avtParICAlgorithm::ExchangeICSteps
// Method: avtParICAlgorithm::RestoreIntegralCurveSequence
//
// Purpose:
// Communicate streamlines pieces to destinations.
......@@ -230,13 +262,17 @@ CountIDs(list<avtIntegralCurve *> &l, int id)
// Hank Childs, Fri Jun 4 19:58:30 CDT 2010
// Use avtStreamlines, not avtStreamlineWrappers.
//
// Hank Childs, Tue Jun 8 09:30:45 CDT 2010
// Rename method, as we plan to add more communication methods.
//
// ****************************************************************************
void
avtParICAlgorithm::ExchangeICSteps()
avtParICAlgorithm::RestoreIntegralCurveSequence()
{
debug5<<"ExchangeICSteps: communicatedICs: "<<communicatedICs.size();
debug5<<" terminatedICs: "<<terminatedICs.size()<<endl;
debug5<<"RestoreIntegralCurveSequence: communicatedICs: "
<<communicatedICs.size()
<<" terminatedICs: "<<terminatedICs.size()<<endl;
//Communicate to everyone where the terminators are located.
//Do this "N" streamlines at a time, so we don't have a super big buffer.
......@@ -249,8 +285,8 @@ avtParICAlgorithm::ExchangeICSteps()
long *idBuffer = new long[2*N], *myIDs = new long[2*N];
//Sort the terminated/communicated ICs by id.
terminatedICs.sort(avtIntegralCurve::IdSeqCompare);
communicatedICs.sort(avtIntegralCurve::IdSeqCompare);
terminatedICs.sort(avtStateRecorderIntegralCurve::IdSeqCompare);
communicatedICs.sort(avtStateRecorderIntegralCurve::IdSeqCompare);
vector<vector<avtIntegralCurve *> >sendICs(N);
vector<int> owners(N);
......@@ -283,7 +319,7 @@ avtParICAlgorithm::ExchangeICSteps()
int idx = (*t)->id % N;
myIDs[idx] = rank;
myIDs[idx+N] += 1;
debug5<<"I own id= "<<(*t)->id<<" "<<(*t)->sequenceCnt<<" idx= "<<idx<<endl;
debug5<<"I own id= "<<(*t)->id<<" "<<(((avtStateRecorderIntegralCurve *)*t))->sequenceCnt<<" idx= "<<idx<<endl;
}
t++;
......@@ -296,7 +332,7 @@ avtParICAlgorithm::ExchangeICSteps()
{
int idx = (*c)->id % N;
myIDs[idx+N] += 1;
debug5<<"I have "<<(*c)->id<<" "<<(*c)->sequenceCnt<<" idx= "<<idx<<endl;
debug5<<"I have "<<(*c)->id<<" "<<(((avtStateRecorderIntegralCurve *)*c))->sequenceCnt<<" idx= "<<idx<<endl;
}
c++;
}
......@@ -324,7 +360,7 @@ avtParICAlgorithm::ExchangeICSteps()
terminatedICs.push_back(s);
else
{
s->serializeFlags = avtIntegralCurve::SERIALIZE_STEPS; //Write IC steps.
((avtStateRecorderIntegralCurve *)s)->serializeFlags = avtIntegralCurve::SERIALIZE_STEPS; //Write IC steps.
sendICs[idx].push_back(s);
owners[idx] = owner;
}
......@@ -353,7 +389,7 @@ avtParICAlgorithm::ExchangeICSteps()
RecvICs(terminatedICs);
//See if we have all the sequences we need.
terminatedICs.sort(avtIntegralCurve::IdSeqCompare);
terminatedICs.sort(avtStateRecorderIntegralCurve::IdSeqCompare);
bool needMore = false;
for (int i = 0; i < N && !needMore; i++)
if (idBuffer[i] == rank)
......@@ -389,13 +425,16 @@ avtParICAlgorithm::ExchangeICSteps()
// Hank Childs, Fri Jun 4 19:58:30 CDT 2010
// Use avtStreamlines, not avtStreamlineWrappers.
//
// Hank Childs, Tue Jun 8 09:30:45 CDT 2010
// Reflect movement of some routines to state recorder IC class.
//
// ****************************************************************************
void
avtParICAlgorithm::MergeTerminatedICSequences()
{
//Sort them by id and sequence so we can process them one at a time.
terminatedICs.sort(avtIntegralCurve::IdSeqCompare);
terminatedICs.sort(avtStateRecorderIntegralCurve::IdSeqCompare);
//Split them up into sequences.
vector<vector<avtIntegralCurve *> > seqs;
......@@ -422,7 +461,8 @@ avtParICAlgorithm::MergeTerminatedICSequences()
//Merge the sequences together, put them into terminated list.
for (int i = 0; i < seqs.size(); i++)
{
avtIntegralCurve *s = seqs[i][0]->MergeIntegralCurveSequence(seqs[i]);
avtIntegralCurve *s =
avtStateRecorderIntegralCurve::MergeIntegralCurveSequence(seqs[i]);
terminatedICs.push_back(s);
}
}
......@@ -855,17 +895,20 @@ avtParICAlgorithm::RecvMsgs(std::vector<std::vector<int> > &msgs)
// Hank Childs, Fri Jun 4 19:58:30 CDT 2010
// Use avtStreamlines, not avtStreamlineWrappers.
//
// Hank Childs, Tue Jun 8 09:30:45 CDT 2010
// Use virtual methods to reduce dependence on a specific communication
// pattern.
//
// ****************************************************************************
void
avtParICAlgorithm::SendICs(int dst,
vector<avtIntegralCurve*> &ics)
avtParICAlgorithm::SendICs(int dst, vector<avtIntegralCurve*> &ics)
{
for (int i = 0; i < ics.size(); i++)
{
avtIntegralCurve *ic = ics[i];
ic->serializeFlags |= avtIntegralCurve::SERIALIZE_INC_SEQ;
ic->PrepareForSend();
}
if (DoSendICs(dst, ics))
......@@ -878,7 +921,7 @@ avtParICAlgorithm::SendICs(int dst,
list<avtIntegralCurve*>::const_iterator si = communicatedICs.begin();
bool found = false;
for (si = communicatedICs.begin(); !found && si != communicatedICs.end(); si++)
found = ((*si)->id == ic->id && (*si)->sequenceCnt == ic->sequenceCnt);
found = (*si)->SameCurve(ic);
if (!found)
communicatedICs.push_back(ic);
......
......@@ -86,6 +86,9 @@
// Hank Childs, Mon Jun 7 14:57:13 CDT 2010
// Rename Initialize method to be InitializeBuffers to prevent name collision.
//
// Hank Childs, Tue Jun 8 09:30:45 CDT 2010
// Rename method to make its communication pattern more clear.
//
// ****************************************************************************
class avtParICAlgorithm : public avtICAlgorithm
......@@ -103,7 +106,7 @@ class avtParICAlgorithm : public avtICAlgorithm
void InitRequests();
void CheckPendingSendRequests();
void CleanupAsynchronous();
void ExchangeICSteps();
void RestoreIntegralCurveSequence();
void PostRecvStatusReq(int idx);
void PostRecvICReq(int idx);
void SendMsg(int dest, std::vector<int> &msg);
......
......@@ -201,6 +201,9 @@ class vtkAppendPolyData;
// Hank Childs, Sat Jun 5 15:02:43 PDT 2010
// Separated out much of the base infrastructure into the avtPICSFilter.
//
// Hank Childs, Tue Jun 8 09:30:45 CDT 2010
// Add method GetCommunicationPattern.
//
// ****************************************************************************
class AVTFILTERS_API avtStreamlineFilter : virtual public avtPICSFilter
......@@ -268,6 +271,8 @@ class AVTFILTERS_API avtStreamlineFilter : virtual public avtPICSFilter
void GenerateSeedPointsFromPointList(std::vector<avtVector> &pts);
virtual std::vector<avtVector> GetInitialLocations(void);
virtual CommunicationPattern GetCommunicationPattern(void)
{ return RestoreSequence; };
};
......
......@@ -101,6 +101,7 @@ avtIntegralCurve::avtIntegralCurve(const avtIVPSolver* model,
status = STATUS_UNSET;
domain = -1;
sortKey = 0;
terminated = false;
id = ID;
......@@ -108,10 +109,6 @@ avtIntegralCurve::avtIntegralCurve(const avtIVPSolver* model,
terminationType = avtIVPSolver::TIME;
lastStepValid = false;
sequenceCnt = 0;
sortKey = 0;
serializeFlags = 0;
}
......@@ -147,6 +144,7 @@ avtIntegralCurve::avtIntegralCurve()
status = STATUS_UNSET;
domain = -1;
sortKey = 0;
terminated = false;
id = -1;
......@@ -154,11 +152,6 @@ avtIntegralCurve::avtIntegralCurve()
terminationType = avtIVPSolver::TIME;
lastStepValid = false;
sequenceCnt = 0;
sortKey = 0;
serializeFlags = 0;
}
......@@ -593,6 +586,10 @@ avtIntegralCurve::CurrentLocation(avtVector &end)
// Separate out portions related to Streamline and Poincare into
// avtStateRecorderIntegralCurve.
//
// Hank Childs, Tue Jun 8 09:30:45 CDT 2010
// Separate out portions related to sequence tracking into
// avtStateRecorderIntegralCurve.
//
// ****************************************************************************
void
......@@ -633,68 +630,10 @@ avtIntegralCurve::Serialize(MemStream::Mode mode, MemStream &buff,
_ivpSolver->PutState(solverState);
}
if ((serializeFlags & SERIALIZE_INC_SEQ) && mode == MemStream::WRITE)
{
long seqCnt = sequenceCnt+1;
buff.io(mode, seqCnt);
}
else
buff.io(mode, sequenceCnt);
if (DebugStream::Level5())
debug5 << "DONE: avtIntegralCurve::Serialize. sz= "<<buff.buffLen() << endl;
}
// ****************************************************************************
// Method: avtIntegralCurve::IdSeqCompare
//
// Purpose:
// Sort streamlines by id, then sequence number.
//
// Programmer: Dave Pugmire
// Creation: September 24, 2009
//
// Modifications:
//
// Hank Childs, Fri Jun 4 19:58:30 CDT 2010
// Move this method from avtStreamlineWrapper.
//
// ****************************************************************************
bool
avtIntegralCurve::IdSeqCompare(const avtIntegralCurve *icA,
const avtIntegralCurve *icB)
{
if (icA->id == icB->id)
return icA->sequenceCnt < icB->sequenceCnt;
return icA->id < icB->id;
}
// ****************************************************************************
// Method: avtIntegralCurve::IdRevSeqCompare
//
// Purpose:
// Sort streamlines by id, then reverse sequence number.
//
// Programmer: Dave Pugmire
// Creation: September 24, 2009
//
// Modifications:
//
// Hank Childs, Fri Jun 4 19:58:30 CDT 2010
// Move this method from avtStreamlineWrapper.
//
// ****************************************************************************
bool
avtIntegralCurve::IdRevSeqCompare(const avtIntegralCurve *icA,
const avtIntegralCurve *icB)
{
if (icA->id == icB->id)
return icA->sequenceCnt > icB->sequenceCnt;
return icA->id < icB->id;
}
bool
avtIntegralCurve::DomainCompare(const avtIntegralCurve *icA,
const avtIntegralCurve *icB)
......
......@@ -171,6 +171,9 @@ class IVP_API DomainType
// Separate out portions specific to Poincare and Streamline into
// avtStateRecorderIntegralCurve.
//
// Hank Childs, Tue Jun 8 09:30:45 CDT 2010
// Put sequence tracking code into avtStateRecorderIntegralCurve.
//
// ****************************************************************************
class IVP_API avtIntegralCurve
......@@ -212,17 +215,11 @@ class IVP_API avtIntegralCurve
void Debug() const;
virtual void Serialize(MemStream::Mode mode, MemStream &buff,
avtIVPSolver *solver);
// Could be static ... only virtual to get to the right method.
// (Temporary solution until we build a communicator class.)
virtual avtIntegralCurve*
MergeIntegralCurveSequence(
std::vector<avtIntegralCurve *> &v) {;};
static bool IdSeqCompare(const avtIntegralCurve *slA,
const avtIntegralCurve *slB);
static bool IdRevSeqCompare(const avtIntegralCurve *slA,
const avtIntegralCurve *slB);
avtIVPSolver *solver);
virtual void PrepareForSend(void) { ; };
virtual bool SameCurve(avtIntegralCurve *ic)
{ return id == ic->id; };
static bool DomainCompare(const avtIntegralCurve *slA,
const avtIntegralCurve *slB);
......@@ -253,13 +250,10 @@ class IVP_API avtIntegralCurve
// Helpers needed for figuring out which domain to use next
std::vector<DomainType> seedPtDomainList;
DomainType domain;
Status status;
unsigned long serializeFlags;
long sequenceCnt;
long long sortKey;
Status status;
long id;
protected:
......
......@@ -66,6 +66,9 @@ avtStateRecorderIntegralCurve::avtStateRecorderIntegralCurve(const avtIVPSolver*
{
intersectionsSet = false;
numIntersections = 0;
sequenceCnt = 0;
serializeFlags = 0;
}
......@@ -82,6 +85,8 @@ avtStateRecorderIntegralCurve::avtStateRecorderIntegralCurve() :
{
intersectionsSet = false;
numIntersections = 0;
sequenceCnt = 0;
serializeFlags = 0;
}
......@@ -345,6 +350,12 @@ avtStateRecorderIntegralCurve::IntersectPlane(const avtVector &p0, const avtVect
// Programmer: Hank Childs
// Creation: June 4, 2010
//
// Modifications:
//
// Hank Childs, Tue Jun 8 09:30:45 CDT 2010
// Add portions for sequence tracking, which were previously in the base
// class.
//
// ****************************************************************************
void
......@@ -391,6 +402,14 @@ avtStateRecorderIntegralCurve::Serialize(MemStream::Mode mode, MemStream &buff,
}
}
if ((serializeFlags & SERIALIZE_INC_SEQ) && mode == MemStream::WRITE)
{
long seqCnt = sequenceCnt+1;
buff.io(mode, seqCnt);
}
else
buff.io(mode, sequenceCnt);
serializeFlags = 0;
if (DebugStream::Level5())
debug5 << "DONE: avtStateRecorderIntegralCurve::Serialize. sz= "<<buff.buffLen() << endl;
......@@ -431,7 +450,8 @@ avtStateRecorderIntegralCurve::MergeIntegralCurveSequence(std::vector<avtIntegra
return v[0];
//Sort the streamlines by Id,seq.
std::sort(v.begin(), v.end(), avtIntegralCurve::IdRevSeqCompare);
std::sort(v.begin(), v.end(),
avtStateRecorderIntegralCurve::IdRevSeqCompare);
//Make sure all ids are the same.
if (v.front()->id != v.back()->id)
......@@ -460,3 +480,79 @@ avtStateRecorderIntegralCurve::MergeIntegralCurveSequence(std::vector<avtIntegra
return s;
}
// ****************************************************************************
// Method: avtStateRecorderIntegralCurve::IdSeqCompare
//
// Purpose:
// Sort streamlines by id, then sequence number.
//
// Programmer: Dave Pugmire
// Creation: September 24, 2009
//
// Modifications:
//
// Hank Childs, Fri Jun 4 19:58:30 CDT 2010
// Move this method from avtStreamlineWrapper.
//
// ****************************************************************************
bool
avtStateRecorderIntegralCurve::IdSeqCompare(const avtIntegralCurve *icA,
const avtIntegralCurve *icB)
{
avtStateRecorderIntegralCurve *sicA = (avtStateRecorderIntegralCurve *) icA;
avtStateRecorderIntegralCurve *sicB = (avtStateRecorderIntegralCurve *) icB;
if (sicA->id == sicB->id)
return sicA->sequenceCnt < sicB->sequenceCnt;
return sicA->id < sicB->id;
}
// ****************************************************************************
// Method: avtStateRecorderIntegralCurve::IdRevSeqCompare
//
// Purpose:
// Sort streamlines by id, then reverse sequence number.
//
// Programmer: Dave Pugmire
// Creation: September 24, 2009
//
// Modifications:
//
// Hank Childs, Fri Jun 4 19:58:30 CDT 2010
// Move this method from avtStreamlineWrapper.
//
// ****************************************************************************
bool
avtStateRecorderIntegralCurve::IdRevSeqCompare(const avtIntegralCurve *icA,
const avtIntegralCurve *icB)
{
avtStateRecorderIntegralCurve *sicA = (avtStateRecorderIntegralCurve *) icA;
avtStateRecorderIntegralCurve *sicB = (avtStateRecorderIntegralCurve *) icB;
if (sicA->id == sicB->id)
return sicA->sequenceCnt > sicB->sequenceCnt;
return sicA->id < sicB->id;
}
// ****************************************************************************
// Method: avtStateRecorderIntegralCurve::SameCurve
//
// Purpose:
// Checks to see if two curves are the same.
//
// Programmer: Hank Childs
// Creation: June 8, 2010
//
// ****************************************************************************
bool
avtStateRecorderIntegralCurve::SameCurve(avtIntegralCurve *ic)
{
avtStateRecorderIntegralCurve *sic = (avtStateRecorderIntegralCurve *) ic;
return (id == sic->id) && (sequenceCnt == sic->sequenceCnt);
}
......@@ -58,6 +58,11 @@
// Programmer: Hank Childs (refactoring of work from others)
// Creation: June 4, 2010
//
// Modifications:
//
// Hank Childs, Tue Jun 8 09:30:45 CDT 2010
// Place sequence tracking code from base class into this class.
//
// ****************************************************************************
class IVP_API avtStateRecorderIntegralCurve : public avtIntegralCurve
......@@ -82,9 +87,20 @@ class IVP_API avtStateRecorderIntegralCurve : public avtIntegralCurve
virtual void Serialize(MemStream::Mode mode, MemStream &buff,
avtIVPSolver *solver);
virtual void PrepareForSend(void)
{ serializeFlags |= SERIALIZE_INC_SEQ; };
virtual bool SameCurve(avtIntegralCurve *ic);
int GetVariableIdx(const std::string &var) const;
static avtIntegralCurve*
MergeIntegralCurveSequence(
std::vector<avtIntegralCurve *> &v);
static bool IdSeqCompare(const avtIntegralCurve *slA,
const avtIntegralCurve *slB);
static bool IdRevSeqCompare(const avtIntegralCurve *slA,
const avtIntegralCurve *slB);
protected:
avtStateRecorderIntegralCurve( const avtStateRecorderIntegralCurve& );
avtStateRecorderIntegralCurve& operator=( const avtStateRecorderIntegralCurve& );
......@@ -99,16 +115,14 @@ class IVP_API avtStateRecorderIntegralCurve : public avtIntegralCurve
// Integration steps.
std::vector<avtIVPStep*> _steps;
unsigned long serializeFlags;
long sequenceCnt;
protected:
virtual void AnalyzeStep(avtIVPStep *step,
const avtIVPField* field,
avtIVPSolver::TerminateType termType,
double end, avtIVPSolver::Result *result);
// Could be static ... only virtual to get to the right method.
// (Temporary solution until we build a communicator class.)
virtual avtIntegralCurve*
MergeIntegralCurveSequence(
std::vector<avtIntegralCurve *> &v);
// Intersection points.
bool intersectionsSet;
......
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