CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM

saved data recomputation ....

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree3Likes
  • 1 Post By akidess
  • 1 Post By benk
  • 1 Post By akidess

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   May 3, 2010, 05:09
Default saved data recomputation ....
  #1
New Member
 
Join Date: Apr 2010
Posts: 5
Rep Power: 15
laurencep is on a distinguished road
hello

Is it possible to recompute a OpenFoam calculation to continue it?
If so, somebody knows how we can do that?

thank you
laurencep is offline   Reply With Quote

Old   May 6, 2010, 01:14
Default
  #2
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,683
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by laurencep View Post
hello

Is it possible to recompute a OpenFoam calculation to continue it?
If so, somebody knows how we can do that?

thank you
If you mean continuing from an existing calculation, then the entry
Code:
startFrom       latestTime;
within the system/controlDict will do that. This also happens to be the default if the "startFrom" entry is completely missing. With this you can simply remove any unwanted time directories to define the latest time for a subsequent restart.
olesen is offline   Reply With Quote

Old   June 3, 2010, 14:55
Default
  #3
Senior Member
 
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 19
benk is on a distinguished road
Is there any way to call this while my solver is running?

For example, I'm trying to implement variable deltaT (time step) and if I pick a deltaT that is too high and the solution starts to diverge, I want to restart my simulation based on the latestTime.

Any ideas on how to do this? I've tried using:

runTime.setTime(latestTime, latestTime)
where latestTime = the last stored solution.

When I do this, it does reset the time but it doesn't read the stored solution at latestTime, instead it restarts based on the solution that was previously diverging.
benk is offline   Reply With Quote

Old   June 7, 2010, 04:43
Default
  #4
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 29
akidess will become famous soon enough
Ben, you could try using storeOldTime() and oldTime(). Or maybe you can find some other ideas in the following thread:
http://www.cfd-online.com/Forums/ope...-openfoam.html
mm.abdollahzadeh likes this.
akidess is offline   Reply With Quote

Old   June 7, 2010, 11:14
Default
  #5
Senior Member
 
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 19
benk is on a distinguished road
Hmm, I thought that I could just reset the time, as I did above and then read in the stored data using:

Code:
volScalarField scalarName
(
    IOobject
    (
        "scalar",
        runTime.timeName(),
        mesh,
        IOobject::MUST_READ,
        IOobject::AUTO_WRITE
    ),
    mesh
);
when I do an Info << runTime.timeName() << endl; I get the proper time (ie, the old time that I'm trying to revert back to) but for some reason even this doesn't read in the old stored solution.
benk is offline   Reply With Quote

Old   June 7, 2010, 15:51
Default
  #6
Senior Member
 
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 19
benk is on a distinguished road
Ok, so I know what my problem is but I don't know how to fix it.

I detect whether my solution is diverging using a flag and if it's diverging i have:

Code:
 if (diverging == 1) {

    //reset time to last good time
    runTime.setTime(lastStoredTime, lastStoredTime);

    //read the solution from the last good time
    volScalarField scalar(IOobject("scalar",runTime.timeName(),mesh,IOobject::MUST_READ,IOobject::AUTO_WRITE),mesh);
    
}
The problem that I have is that this will read in the old solution correctly but it creates a new volScalarField that only exists within the if {} statement and not outside the if {} statement. It also creates a new volScalarField when all I want to do is replace the old one.

So one idea that I have is to read in the old solution into a temporary volScalarField and then copy the temporary field to the proper volScalarField. How do I copy the temporary volScalarField into my actual volScalarField?

akidess: I'm not sure how to use storeOldTime() and oldTime(). I tried something like:

scalar.storeOldTime()

but how do I then revert back to this old value?

I tried this: scalar = scalar.oldTime() but this doesn't seem to do anything.
mm.abdollahzadeh likes this.
benk is offline   Reply With Quote

Old   June 8, 2010, 03:48
Default
  #7
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 29
akidess will become famous soon enough
I'm not too sure about the usage of oldTime either, I just stumbled across it in the code. I would have used it the same way you did (maybe an additional nOldTimes() to see if something was stored).

So if that doesn't work, your own approach seems promising. Can you maybe use

Code:
tmp<scalar> old(IOobject("scalar",runTime.timeName(),mesh,IOobject::MUST_READ,IOobject::AUTO_WRITE),mesh);

//scalar is the variable you want to restore, defined "globally"
scalar == old;
Again, I'm kinda just making guesses using the source guide, but I'm interested in your solution!

- Anton
akidess is offline   Reply With Quote

Old   June 8, 2010, 09:33
Default
  #8
Senior Member
 
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 19
benk is on a distinguished road
Thanks for the suggestion. When I try the tmp<scalar> part I get the compiler error:

Code:
error: no matching function for call to Foam::tmp<double>::tmp(Foam::IOobject, Foam::fvMesh&)
note: candidates are: Foam::tmp<T>::tmp(const Foam::tmp<T>&) [with T = double]
note:                 Foam::tmp<T>::tmp(const T&) [with T = double]
note:                 Foam::tmp<T>::tmp(T*) [with T = double]
and when I try the scalar == old part I get:

Code:
error: no match for operator== in scalar == old
note: candidates are: void Foam::GeometricField<Type, PatchField, GeoMesh>::operator==(const Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh> >&) [with Type = double, PatchField = Foam::fvPatchField, GeoMesh = Foam::volMesh]
It looks like I'll have to brush up on my C++ although I think this is actually an easy problem to solve.

I'm surprised that this sort of time control isn't more popular amongst foamers since it could dramatically reduce computation time by allowing large/dynamic time steps.
benk is offline   Reply With Quote

Old   June 8, 2010, 10:03
Default
  #9
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 29
akidess will become famous soon enough
About the first error: We'll have to use a normal scalarField then instead of the tmp<scalar> field. I guess the performance impact won't be noticable anyways.

So did you try

Code:
volScalarField old(IOobject("scalar",runTime.timeName(),mesh,IOobject::MUST_READ,IOobject::AUTO_WRITE),mesh);
restoreScalar == old;
and got an error on "=="? I don't see why that would lead to an error, but you can also see if a regular "=" works. The difference as I understand it is that "=" makes a copy of the field, while "==" will replace the field.

Most Foamers seem happy with the built in time control based on the Courant number. It's good enough for most of my own simulations.
mm.abdollahzadeh likes this.
akidess is offline   Reply With Quote

Old   June 8, 2010, 12:57
Default
  #10
Senior Member
 
Ben K
Join Date: Feb 2010
Location: Ottawa, Canada
Posts: 140
Rep Power: 19
benk is on a distinguished road
Aha, that seems to have worked! (reading old solution into a new volScalarField and then using scalar == scalar_old). Thanks!

I don't have a Courant number because I don't have a momentum balance in my model (which is why I need to use my own method to control the time step).
benk is offline   Reply With Quote

Old   June 9, 2010, 04:14
Default
  #11
Senior Member
 
akidess's Avatar
 
Anton Kidess
Join Date: May 2009
Location: Germany
Posts: 1,377
Rep Power: 29
akidess will become famous soon enough
Great! I was starting to run out of ideas

I had an unstable case where the time adjustment based on the Courant number would lead to an oscillating time step and bad results, and I think a time step control similar to yours could help there as well. For more stable cases it can be a let-down that this method has no means to increase the timestep.

- Anton
akidess is offline   Reply With Quote

Reply

Tags
reject time step, time step

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
[OpenFOAM] Saved DATA doesnt have Patch Names velan ParaView 0 January 9, 2009 07:32
Getting Time Series data from saved unsteady data Atul FLUENT 4 November 26, 2008 05:12
information from saved data files:Unsteady flow Atul FLUENT 5 July 27, 2008 20:05
reading saved case and data maxime henno FLUENT 1 June 12, 2007 06:40
How to update polyPatchbs localPoints liu OpenFOAM Running, Solving & CFD 6 December 30, 2005 17:27


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