[vtkusers] interpolating using RungaKutta4

tom fogal tfogal at apollo.sr.unh.edu
Thu Aug 26 13:18:26 EDT 2004


Berk,

Thanks for your reply. I added a switch on the return value of
ComputeNextStep(), and it is coming back with 0.

I tried stepping through the code as you suggested. It appears to be
working fine, I am thinking that perhaps I am using too small a
timestep to notice the difference? Lines 146 -> 149 read:

    xnext[i] = xprev[i] + delT*(this->Derivs[i]/6.0 +
                                this->NextDerivs[0][i]/3.0 +
                                this->NextDerivs[1][i]/3.0 +
                                this->NextDerivs[2][i]/6.0);

delT is reasonably large (0.5), but all of this->Derivs and
this->NextDerivs are neglible: (-1.<something>e-15 or so). So my guess
is the reason I am not seeing much change is a combination of a weak
field and a small timestep?

Thanks again,

-tom

 <1093535251.4154.32.camel at silverymoon>Berk Geveci writes:
>What values does ComputeNextStep() return? The ComputeNextStep()
>is a very simple and short function. You can easily figure out
>what is going wrong by putting a break point in it and following
>the execution. I could tell you more if I had access to the datasets.
>
>-Berk
>
>
>On Thu, 2004-08-26 at 11:12, tom fogal wrote:
>> I'm trying to interpolate a point using RungaKutta4 and I'm not getting
>> the results I would have expected.
>> 
>>    float seed[2][3];
>>    float delT = 0.5;
>>    float unused;
>>    vtkInterpolateDataSetAttributes *IntDataSetAttr;
>>    vtkInterpolatedVelocityField    *IntVelField;
>>    vtkRungaKutta4                  *RG4;
>>    MyCustomReaderObject            *src[2];
>> 
>>    ... initialize data ...
>> 
>>    IntDataSetAttr->AddInput(src[0]->GetOutput());
>>    IntDataSetAttr->AddInput(src[1]->GetOutput());
>>    IntDataSetAttr->SetT(0.5);
>>    IntDataSetAttr->Update();
>>    IntVelField->AddDataSet(IntDataSetAttr->GetOutput());
>>    IntVelField->SelectVectors("V");
>>    RG4->SetFunctionSet(IntVelField);
>> 
>>    seed[0][0] = 0.1;
>>    seed[0][1] = 0.2;
>>    seed[0][2] = 0.3;
>>    seed[1][0] = 0.5;
>>    seed[1][1] = 0.6;
>>    seed[1][2] = 0.7;
>>    // seed[1] is for return value
>>    RG4->ComputeNextStep(seed[0], seed[1], 0.0, delT, unused, unused);
>> 
>>    std::cout << "interpolated points (start \t finish):\n"
>>              << "\t x: " << seed[0][0] << '\t' << seed[1][0] << '\n'
>>              << "\t y: " << seed[0][1] << '\t' << seed[1][1] << '\n'
>>              << "\t z: " << seed[0][2] << '\t' << seed[1][2] << '\n';
>> 
>> I used to not set seed[1] but I was curious to see if it would use
>> those values. ComputeNextStep seems to only copy seed[0] to seed[1].
>> Any ideas what I'm doing wrong here? How is one supposed to use
>> RungaKutta4 ?
>> 
>> TIA,
>> 
>> -tom



More information about the vtkusers mailing list