Commit 971f9012 authored by allens's avatar allens

added new methods and clean up - most notable is the switch from float to...

added new methods and clean up - most notable is the switch from float to double in the staterecorder whcih was causing problems as the samples were doubles but history floats.

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@21813 18c085ea-50e0-402c-830e-de6fd14e8384
parent 3913d5f2
......@@ -110,6 +110,8 @@ avtFTLEIC::avtFTLEIC() : avtIntegralCurve()
maxDistance = 0.;
doTime = false;
maxTime = 0.;
time = 0.;
distance = 0.;
terminatedBecauseOfMaxSteps = false;
......@@ -197,6 +199,7 @@ void avtFTLEIC::AnalyzeStep( avtIVPStep &step,
// CheckForTermination will modify the step if it goes beyond the
// termination criteria. (Example: streamlines will split a step if it
// is terminating by distance.)
time = step.GetT1();
distance += step.GetLength();
p_end = step.GetP1();
}
......
......@@ -75,8 +75,10 @@ public:
virtual void Serialize(MemStream::Mode mode, MemStream &buff,
avtIVPSolver *solver, SerializeFlags serializeFlags);
// virtual bool UseFixedTerminationTime(void) { return doTime; };
// virtual double FixedTerminationTime(void) { return maxTime; };
virtual bool UseFixedTerminationTime(void) { return doTime; };
virtual double FixedTerminationTime(void) { return maxTime; };
virtual bool UseFixedTerminationDistance(void) { return doDistance; };
virtual double FixedTerminationDistance(void) { return maxDistance; };
bool TerminatedBecauseOfMaxSteps(void)
{ return terminatedBecauseOfMaxSteps; };
......@@ -86,9 +88,10 @@ public:
avtFTLEIC& operator=( const avtFTLEIC& );
public:
virtual bool CheckForTermination(avtIVPStep& step, avtIVPField *);
virtual bool CheckForTermination(avtIVPStep& step, avtIVPField *);
virtual double getDistance() { return distance; }
virtual double GetTime() { return time; }
virtual double GetDistance() { return distance; }
virtual void AnalyzeStep( avtIVPStep &step, avtIVPField *field);
......@@ -99,16 +102,17 @@ public:
avtVector GetStartPoint() { return p_start; }
avtVector GetEndPoint() { return p_end; }
protected:
unsigned int numSteps;
public:
unsigned int maxSteps;
protected:
unsigned int numSteps;
bool doDistance;
double maxDistance;
bool doTime;
double maxTime;
bool terminatedBecauseOfMaxSteps;
double time;
double distance;
avtVector p_start, p_end;
......
......@@ -124,6 +124,12 @@ class avtIVPStep: public std::vector<avtVector>
{
public:
avtIVPStep()
{
t0 = 0;
t1 = 0;
}
unsigned int GetDegree() const
{
return size()-1;
......
......@@ -128,6 +128,19 @@ class IVP_API ICStatus
//Get
bool OK() const {return CheckBit(STATUS_OK);}
bool Error() const {return !OK();}
bool TerminatedOnly() const // i.e. terminated only due the maxSteps
{
if( Error() ||
EncounteredSpatialBoundary() || EncounteredTemporalBoundary() ||
ExitedSpatialBoundary() || ExitedTemporalBoundary() ||
NumericalError() || BadStepError() )
return false;
else if( OK() && TerminationMet() )
return true;
else
return false;
}
bool Terminated() const
{
return Error() || TerminationMet() ||
......@@ -424,7 +437,4 @@ inline std::ostream& operator<<(std::ostream& out,
return out;
}
#endif // AVT_INTEGRAL_CURVE_H
......@@ -52,8 +52,9 @@
#include <avtVector.h>
#include <algorithm>
const double avtStateRecorderIntegralCurve::epsilon = 100.0*(std::numeric_limits<float>::epsilon() *
std::numeric_limits<float>::epsilon());
const double avtStateRecorderIntegralCurve::epsilon =
100.0*(std::numeric_limits<float>::epsilon() *
std::numeric_limits<float>::epsilon());
// ****************************************************************************
......@@ -74,6 +75,7 @@ avtStateRecorderIntegralCurve::avtStateRecorderIntegralCurve(
int ID) :
avtIntegralCurve(model, dir, t_start, p_start, v_start, ID), historyMask(mask)
{
time = 0.0;
distance = 0.0;
sequenceCnt = 0;
_serializeFlags = SERIALIZE_NO_OPT;
......@@ -90,6 +92,7 @@ avtStateRecorderIntegralCurve::avtStateRecorderIntegralCurve(
avtStateRecorderIntegralCurve::avtStateRecorderIntegralCurve()
{
time = 0.0;
distance = 0.0;
sequenceCnt = 0;
_serializeFlags = SERIALIZE_NO_OPT;
......@@ -143,7 +146,7 @@ void avtStateRecorderIntegralCurve::RecordStep(const avtIVPField* field,
Sample prevSamp = GetSample(nSamp-1);
if ((p-prevSamp.position).length2() < epsilon)
{
std::vector<float>::iterator m = history.begin() + (nSamp-1)*GetSampleStride();
std::vector<double>::iterator m = history.begin() + (nSamp-1)*GetSampleStride();
history.erase(m, history.end());
}
}
......@@ -227,6 +230,8 @@ avtStateRecorderIntegralCurve::AnalyzeStep( avtIVPStep& step,
// CheckForTermination will modify the step if it goes beyond the
// termination criteria. (Example: streamlines will split a step if it
// is terminating by distance.)
time = step.GetT1();
distance += step.GetLength();
RecordStep( field, step, step.GetT1() );
......@@ -289,11 +294,15 @@ size_t avtStateRecorderIntegralCurve::GetSampleStride() const
avtStateRecorderIntegralCurve::Sample
avtStateRecorderIntegralCurve::GetSample( size_t n ) const
{
std::vector<float>::const_iterator m = history.begin() + n*GetSampleStride();
std::vector<double>::const_iterator m =
history.begin() + n*GetSampleStride();
Sample s;
if( historyMask & SAMPLE_TIME )
s.time = *(m++);
else
s.time = 0;
if( historyMask & SAMPLE_POSITION )
{
......@@ -301,28 +310,42 @@ avtStateRecorderIntegralCurve::GetSample( size_t n ) const
s.position.y = *(m++);
s.position.z = *(m++);
}
else
s.position = avtVector(0,0,0);
if( historyMask & SAMPLE_VELOCITY )
{
s.velocity.x = *(m++);
s.velocity.y = *(m++);
s.velocity.z = *(m++);
}
else
s.velocity = avtVector(0,0,0);
if( historyMask & SAMPLE_VORTICITY )
s.vorticity = *(m++);
else
s.vorticity = 0;
if( historyMask & SAMPLE_ARCLENGTH )
s.arclength = *(m++);
else
s.arclength = 0;
if( historyMask & SAMPLE_SCALAR0 )
s.scalar0 = *(m++);
else
s.scalar0 = 0;
if( historyMask & SAMPLE_SCALAR1 )
s.scalar1 = *(m++);
else
s.scalar1 = 0;
if( historyMask & SAMPLE_SCALAR2 )
s.scalar2 = *(m++);
else
s.scalar2 = 0;
return s;
}
......@@ -581,3 +604,39 @@ avtStateRecorderIntegralCurve::SameCurve(avtIntegralCurve *ic)
return (id == sic->id) && (sequenceCnt == sic->sequenceCnt);
}
// ****************************************************************************
// Method: avtStateRecorderIntegralCurve::Get
//
// Purpose:
// QUick access to member values
//
// Programmer: Allen Sanderson
// Creation: September 8, 2013
//
// ****************************************************************************
double avtStateRecorderIntegralCurve::GetTime()
{
if( GetNumberOfSamples() )
return GetSample( GetNumberOfSamples() - 1 ).time;
else
return time;
}
double avtStateRecorderIntegralCurve::GetDistance()
{
if( GetNumberOfSamples() )
return GetSample( GetNumberOfSamples() - 1 ).arclength;
else
return distance;
}
avtVector avtStateRecorderIntegralCurve::GetEndPoint()
{
if( GetNumberOfSamples() )
return GetSample( GetNumberOfSamples() - 1 ).position;
else
return ivp->GetCurrentY();
}
......@@ -148,14 +148,14 @@ public:
virtual void PrepareForFinalCommunication(void)
{ _serializeFlags = avtIntegralCurve::SERIALIZE_STEPS; };
typedef std::vector<float>::const_iterator iterator;
size_t GetNumberOfSamples() const;
Sample GetSample( size_t n ) const;
virtual bool CheckForTermination(avtIVPStep &step, avtIVPField *) = 0;
virtual double getDistance() { return distance; }
virtual double GetTime();
virtual double GetDistance();
virtual avtVector GetEndPoint();
protected:
avtStateRecorderIntegralCurve( const avtStateRecorderIntegralCurve& );
......@@ -169,9 +169,10 @@ public:
unsigned char historyMask;
protected:
double time;
double distance;
std::vector<float> history;
std::vector<double> history;
static const double epsilon;
void RecordStep( const avtIVPField* field,
......
......@@ -204,16 +204,13 @@ avtStreamlineIC::CheckForTermination(avtIVPStep& step, avtIVPField *field)
if( !shouldTerminate && numSteps >= maxSteps )
{
terminatedBecauseOfMaxSteps = true;
speedAtTermination = step.GetV(step.GetT1()).length();
shouldTerminate = true;
speedAtTermination = step.GetV(step.GetT1()).length();
}
// Update other termination criteria.
numSteps += 1;
// Done by state recorder, which may need to record state
//distance += step.GetLength();
return shouldTerminate;
}
......
......@@ -85,6 +85,8 @@ public:
avtIVPSolver *solver, SerializeFlags serializeFlags);
virtual bool UseFixedTerminationTime(void) { return doTime; };
virtual double FixedTerminationTime(void) { return maxTime; };
virtual bool UseFixedTerminationDistance(void) { return doDistance; };
virtual double FixedTerminationDistance(void) { return maxDistance; };
bool TerminatedBecauseOfMaxSteps(void)
{ return terminatedBecauseOfMaxSteps; };
......
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