chyczewski |
November 19, 2013 17:59 |
Seeking explanation why solve zeroes out solution in certain circumstances
I am hoping someone can help me understand the behavior I'm observing with the code at bottom, which I adapted from scalarTransportFoam.C. Since my equation is stating that T isn't changing, I expect the T before the solve to be the same as T after the solve. However, as it is written, the T after the solve is equal to 0 for all m. If I change the construction of DD to
Code:
for (m=0; m<64, ++m)
{
DD[m] = scalar(l);
}
then the code behaves as I'd expect. Namely, T before is equal to T after (=5).
Can anyone explain why solve is setting T to 0 if I use m in the construction of DD? Thanks.
Code:
#include "fvCFD.H"
#include "fvIOoptionList.H"
#include "simpleControl.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
#include "setRootCase.H"
#include "createTime.H"
#include "createMesh.H"
#include "createFields.H"
#include "createFvOptions.H"
simpleControl simple(mesh);
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Info<< "\nCalculating scalar transport\n" << endl;
#include "CourantNo.H"
int m;
int l = 5;
scalar DD[64];
for (m=0; m<64; ++m)
{
DD[m] = scalar(m);
}
for (m=0; m<64; ++m)
{
forAll(U,i)
{
T[i] = DD[m];
}
Info<<"T Before "<<T[56]<<endl;
solve
(
fvm::ddt(T)
);
Info<<"T After "<<T[56]<<endl;
}
return 0;
}
|