CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   writeControl for certain times ? (http://www.cfd-online.com/Forums/openfoam-programming-development/98620-writecontrol-certain-times.html)

gary7 March 14, 2012 22:03

writeControl for certain times ?
 
Hi all,

Is that possible to write solution out just at specified times? e.g I want solution at just 20*Dt, 40*Dt and 130*Dt. I don't wanna write out anything else, it's both messy and slow down the simulation...I appreciate any help

Cheers,

gary7 March 16, 2012 16:05

I've not found the solution yet! any idea?

marupio March 16, 2012 17:02

You could create a derived class of Time and use that in your solver. Give it the behaviour you want - perhaps extend its "writeInterval" to "writeIntervalList"...

Or if you want to hack it on your top level of your solver, you know how to write conditionals, and runTime.writeNow() forces it to write.

gary7 March 16, 2012 20:22

Thank you David, well I'm a newbie in OpenFoam and C++...I'd really appreciate it if you could give me more details on that or maybe a code snippet so I can have a better picture of what I need to do...again thanks for your relpy :)

marupio March 16, 2012 20:28

Sure, at the bottom of the solver you are running, it says "runTime.write();" In place of that, put this:

Code:

if
(
    mag(runTime.value() - runTime.deltaT().value() * 20) < SMALL)
 || mag(runTime.value() - runTime.deltaT().value() * 40) < SMALL)
 || mag(runTime.value() - runTime.deltaT().value() * 130) < SMALL)
)
{
    runTime.writeNow();
}

recompile, and then it should behave as you expect. Hope it works for you.

-Dave

gary7 March 18, 2012 16:33

Thank you so much Dave, I really appreciate it :)


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