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/)
-   -   GeometricField read (https://www.cfd-online.com/Forums/openfoam-programming-development/201586-geometricfield-read.html)

mnajafi May 4, 2018 12:48

GeometricField read
 
Hi
After hour of search and find no solution I'm going to ask this question. There is for sure similar questions in the forum but I didn't find them.
I want to read a GeometricField, say p, from time folders in a loop. Following program works but it's not a good solution of course:
Code:

    label endTimeIndex=std::floor(runTime.endTime().value()/runTime.deltaTValue());
    for (int j=0;j<=endTimeIndex;j++)
    {
        volScalarField p
        (
            IOobject
            (
                "p",
                runTime.timeName(),
                mesh,
                IOobject::MUST_READ,
                IOobject::AUTO_WRITE
          ),
          mesh
        );
       
        Info<<runTime.timeName()<<endl;
        Info<<"p:"<<endl<<p<<endl;
        runTime++;
    }

I was looking for an option like p.readFields() or p.readIfPresent() (which are established by constructors of GeometricField) to avoid redefinition of p in each loop. But these members are private and they are not accessible from main. What shall I do?
Thanks


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