CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   Seeking explanation why solve zeroes out solution in certain circumstances (https://www.cfd-online.com/Forums/openfoam-programming-development/126522-seeking-explanation-why-solve-zeroes-out-solution-certain-circumstances.html)

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;
}



All times are GMT -4. The time now is 04:51.