CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Can somebody please explain runTimewrite (https://www.cfd-online.com/Forums/openfoam-solving/59233-can-somebody-please-explain-runtimewrite.html)

jaswi July 21, 2007 18:35

Dear OpenFoam users Can so
 
Dear OpenFoam users

Can somebody explain what does runTime.write() does. I tried to look for the write() member function in Time.H but couldn't find any.

Where can i find the corresponding peace of code !!!!!!

Any help is greatly appreciated

With Best Regards
Jaswinder

martin July 22, 2007 01:53

Hi Jaswinder, Did you use d
 
Hi Jaswinder,

Did you use doxygen? Maybe you can find something on:

http://foam.sourceforge.net/doc/Doxy...e-members.html

Regards,
Martin

hjasak July 22, 2007 06:00

Not too difficult. runTime is
 
Not too difficult. runTime is class type Time:

db/Time/Time.H

which is derived from objectRegistry, which is in turn derived from regIOobject:

db/objectRegistry/objectRegistry.H
db/regIOobject/regIOobject.H

regIOobject has got a fiunction called write() and a virtual function writeObject:

//- Write using given format, version and compression
virtual bool writeObject
(
IOstream::streamFormat fmt,
IOstream::versionNumber ver,
IOstream::compressionType cmp
) const;

//- Write using setting from DB
virtual bool write() const;


Clearly, write is just a wrapper around writeData. This one is over-ridden for objectRegistry and reads:

bool objectRegistry::writeObject
(
IOstream::streamFormat fmt,
IOstream::versionNumber ver,
IOstream::compressionType cmp
) const
{
bool ok = true;

for (const_iterator iter = begin(); iter != end(); ++iter)
{
if (objectRegistry::debug)
{
Pout<< "objectRegistry::write() : "
<< "Considering writing object "
<<>name()
<<>writeOpt()
<< endl;


if (iter()->writeOpt() != NO_WRITE)
{
ok = iter()->writeObject(fmt, ver, cmp) && ok;
}
}

return ok;
}}

Thus: loop over all objects registred in the object registry and offer them to write themselves. Each object will decide if it wants to do so, based on the settings, eg. NO_WRITE or AUTO_WRITE.

Clear?

Hrv

jaswi July 22, 2007 08:05

Thanks Hrv It couldn't be
 
Thanks Hrv

It couldn't be explained any better :-). Answer from the source itself is ought to be clear.

Thanks

Regards
Jaswinder

stephan January 12, 2008 13:22

hi, i would appreciate it i
 
hi,

i would appreciate it if somebody could explain how the lagrangian data is writen.
i could not find the place where dieselspray or cloud are included into the "objectRegistry" so that their data is written.
thanks in advance
stephan

Victor June 28, 2010 03:32

write dataFile
 
Hi at all,

I have a problem with using runTime.write(). I like to write a dataFile only at every writeInterval. The data File contains the position of a flame at every time step. In order to avoid gaps or repetitions in the data-file after a stop in the simulation, the data-file should only be written when the rest of the data is stored to.
I tried it with

if(runTime.write())
{
myStream<<......
}

but this does not work right.
Is there anybody how knows what to do?
Thanks a lot in advance,

Victor

Victor June 28, 2010 04:35

ok, it seems that runTime.write() is the problem! Sorry!

maximeg July 28, 2010 10:04

Hi all!
I'd like to create files every writeInterval (and which have the name of the corresponding writeInterval). I think I have to use runTime.write() or ofstream, but on this last case, it needs a const char argument (impossible to change/increment the file name).
Anybody have any ideas on how to solve this?
Thanks a lot in advance!
Maxime

MartinB July 28, 2010 14:24

Hi Maxime,
you can use
Code:

    if (runTime.outputTime())
#    include "write.H"

to write additional information when a regular time step is written out. Just create a file "write.H" for your solver which handles the output.

When you want to write a volVectorField or volScalarField, the time steps path name is added automatically, so you get your data in different directories, but with the same file name:
Code:

    // write pressure in [Bar]:
    volScalarField p
    (
        IOobject
        (
            "p[Bar]", // the file name
            runTime.timeName(), // path to current time step
            mesh,
            IOobject::NO_READ,
            IOobject::AUTO_WRITE
        ),
        rho_*pd/scalar(100000)
    );
    // explicitly write now:
    p.write();

To create a filename (with time step in filename) for usage with ofstream take this code snippet as an example:
Code:

    fileName casePath = cwd();
    Info << "casePath: " << casePath << endl;
    fileName caseName = casePath.name();
    Info << "caseName: " << caseName << endl;
    fileName myFile = caseName
        + "_"
        + runTime.timeName()
        + ".csv";

To use a new filename every write interval and to close your stream just use curly brackets around your code:
Code:

    {
        OFstream *myStreamPtr = NULL;
        myStreamPtr = new OFstream(myFile);
        *myStreamPtr << "Valuable information..." << endl;
    }

To handle OFstream in parallel so that only the master writes data:
Code:

    OFstream *myStreamPtr = NULL;

    if (Pstream::master())
    {
        myStreamPtr = new OFstream(myFile);
        *myStreamPtr << "Plenty of information" << endl;
    }
... other code, master is collecting data with reduce or Pstream ...
    if (Pstream::master())
    {
        *myStreamPtr << "Information collected from slaves" << endl;
    }

Martin

rob3rt August 2, 2010 07:33

Hi Martin,

I want to implement a transient boundary conditions, hence I need boundaryData file under constant. However, the problem is the property that I want to vary with time is dimensionedScalar (No_Read in CreateFields.H) instead of volScalarField. What can I do to implement this? What Q value should I put in the constant/transportProperties. I have tried to put this in the solver, but doesn't work.

if (runTime.value() > 500)
{
Q = 600;
}
else
{
Q = 0;
}

Suggestions will be very much appreciated.

Thanks in advance.

Robert

ata August 3, 2010 05:53

Timw Varying B.C.
 
Hi Robert
There is some timeVarying... boundary condition in src/finiteVolume/fields/fvPatchFields/derived. May be one of them be useful for you.
Best regards
Good luck

Ata

bgane67 November 27, 2014 11:42

hi
what is writeinterval???


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