Commit 566eeb20 authored by Mathieu Westphal's avatar Mathieu Westphal
Browse files

Add a UserData parameters to vtkFunctionSet::FunctionValues

This adds a new UserData parameters to FunctionValues
so any type of data can be passed down.
parent 86955c82
......@@ -63,6 +63,7 @@ public:
*/
static vtkGenericInterpolatedVelocityField *New();
using Superclass::FunctionValues;
/**
* Evaluate the velocity field, f, at (x, y, z, t).
* For now, t is ignored.
......
......@@ -43,8 +43,11 @@ public:
* x and f have to point to valid double arrays of appropriate
* sizes obtained with GetNumberOfFunctions() and
* GetNumberOfIndependentVariables.
* If you inherit this class, make sure to reimplement at least one of the two
* FunctionValues signatures.
*/
virtual int FunctionValues(double* x, double* f) = 0;
virtual int FunctionValues(double* x, double* f) { return this->FunctionValues(x, f, nullptr); }
virtual int FunctionValues(double* x, double* f, void* vtkNotUsed(userData)) { return this->FunctionValues(x, f); }
/**
* Return the number of functions. Note that this is constant for
......
......@@ -61,7 +61,7 @@ int vtkRungeKutta2::ComputeNextStep(double* xprev, double* dxprev, double* xnext
this->Derivs[i] = dxprev[i];
}
}
else if (!this->FunctionSet->FunctionValues(this->Vals, this->Derivs))
else if ( !this->FunctionSet->FunctionValues(this->Vals, this->Derivs, userData) )
{
memcpy(xnext, this->Vals, (numVals-1)*sizeof(double));
return OUT_OF_DOMAIN;
......@@ -75,7 +75,7 @@ int vtkRungeKutta2::ComputeNextStep(double* xprev, double* dxprev, double* xnext
this->Vals[numVals-1] = t + delT/2.0;
// Obtain the derivatives at x_i + dt/2 * dx_i
if (!this->FunctionSet->FunctionValues(this->Vals, this->Derivs))
if (!this->FunctionSet->FunctionValues(this->Vals, this->Derivs, userData))
{
memcpy(xnext, this->Vals, (numVals-1)*sizeof(double));
delTActual = delT/2.0; // we've only taken half of a time step
......
......@@ -97,7 +97,7 @@ int vtkRungeKutta4::ComputeNextStep(double* xprev, double* dxprev, double* xnext
this->Derivs[i] = dxprev[i];
}
}
else if (!this->FunctionSet->FunctionValues(this->Vals, this->Derivs))
else if ( !this->FunctionSet->FunctionValues(this->Vals, this->Derivs, userData) )
{
memcpy(xnext, this->Vals, (numVals-1)*sizeof(double));
return OUT_OF_DOMAIN;
......@@ -110,7 +110,7 @@ int vtkRungeKutta4::ComputeNextStep(double* xprev, double* dxprev, double* xnext
this->Vals[numVals-1] = t + delT/2.0;
// 2
if (!this->FunctionSet->FunctionValues(this->Vals, this->NextDerivs[0]))
if (!this->FunctionSet->FunctionValues(this->Vals, this->NextDerivs[0], userData))
{
memcpy(xnext, this->Vals, (numVals-1)*sizeof(double));
delTActual = delT/2.0; // we've been able to take half a step
......@@ -124,7 +124,7 @@ int vtkRungeKutta4::ComputeNextStep(double* xprev, double* dxprev, double* xnext
this->Vals[numVals-1] = t + delT/2.0;
// 3
if (!this->FunctionSet->FunctionValues(this->Vals, this->NextDerivs[1]))
if (!this->FunctionSet->FunctionValues(this->Vals, this->NextDerivs[1], userData))
{
memcpy(xnext, this->Vals, (numVals-1)*sizeof(double));
delTActual = delT/2.0; // we've been able to take half a step
......@@ -138,7 +138,7 @@ int vtkRungeKutta4::ComputeNextStep(double* xprev, double* dxprev, double* xnext
this->Vals[numVals-1] = t + delT;
// 4
if (!this->FunctionSet->FunctionValues(this->Vals, this->NextDerivs[2]))
if (!this->FunctionSet->FunctionValues(this->Vals, this->NextDerivs[2], userData))
{
memcpy(xnext, this->Vals, (numVals-1)*sizeof(double));
delTActual = delT; // we've been able to take a full step but couldn't finish the algorithm
......
......@@ -239,7 +239,8 @@ int vtkRungeKutta45::ComputeAStep(
this->NextDerivs[0][i] = dxprev[i];
}
}
else if (!this->FunctionSet->FunctionValues(this->Vals, this->NextDerivs[0]))
else if ( !this->FunctionSet->FunctionValues(this->Vals,
this->NextDerivs[0], userData))
{
for(i=0; i<numVals-1; i++)
{
......@@ -264,7 +265,8 @@ int vtkRungeKutta45::ComputeAStep(
}
this->Vals[numVals-1] = t + delT*A[i-1];
if (!this->FunctionSet->FunctionValues(this->Vals, this->NextDerivs[i]))
if ( !this->FunctionSet->FunctionValues(this->Vals,
this->NextDerivs[i], userData))
{
for(int l = 0; l < numVals - 1; l++)
{
......
......@@ -55,6 +55,7 @@ public:
void SetLastCellId( vtkIdType c ) override
{ this->Superclass::SetLastCellId( c ); }
using Superclass::FunctionValues;
/**
* Evaluate the velocity field f at point p.
* If it succeeds, then both the last data set (this->LastDataSet) and
......
......@@ -185,6 +185,7 @@ public:
{ this->Caching = from->Caching; }
using Superclass::FunctionValues;
/**
* Evaluate the velocity field f at point (x, y, z).
*/
......
......@@ -74,6 +74,7 @@ public:
*/
static vtkCachingInterpolatedVelocityField *New();
using Superclass::FunctionValues;
//@{
/**
* Evaluate the velocity field, f={u,v,w}, at {x, y, z}.
......
......@@ -102,6 +102,7 @@ public:
*/
void AddDataSet( vtkDataSet * dataset ) override;
using Superclass::FunctionValues;
/**
* Evaluate the velocity field f at point (x, y, z).
*/
......
......@@ -79,6 +79,7 @@ public:
*/
void AddDataSet( vtkDataSet * dataset ) override;
using Superclass::FunctionValues;
/**
* Evaluate the velocity field f at point (x, y, z).
*/
......
......@@ -77,6 +77,7 @@ public:
*/
static vtkTemporalInterpolatedVelocityField *New();
using Superclass::FunctionValues;
//@{
/**
* Evaluate the velocity field, f, at (x, y, z, t).
......
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