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

How to restart time in the middle of a simulation and write time directories to anoth

Register Blogs Community New Posts Updated Threads Search

Like Tree1Likes
  • 1 Post By marupio

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 4, 2016, 15:12
Default How to restart time in the middle of a simulation and write time directories to anoth
  #1
Senior Member
 
Thomas Oliveira
Join Date: Apr 2015
Posts: 114
Rep Power: 12
t.oliveira is on a distinguished road
Dear Foamers,

I need to:
(1) solve for the velocity field
and then
(2) use this velocity field for the transport of a scalar.

I would like to do that in just one code, so that the mesh and velocity field don't need to be reloaded from step (1) to (2). A sketch of the idea is below:

Code:
        // as in simpleFoam.C
        while (simple.loop())
        {
        // --- Pressure-velocity SIMPLE corrector
            {
                #include "UEqn.H"
                #include "pEqn.H"
            }
            turbulence->correct();
            runTime.write();
        }

    // as in scalarTransportFoam.C
        while (simple.loop())
        {
            while (simple.correctNonOrthogonal())
            {
                solve(fvm::ddt(T) + fvm::div(phi, T) - fvm::laplacian(DT, T)  == fvOptions(T));
            }
            runTime.write();
        }
However, I still have no clue on how to deal with the timesteps so that step 2 writes its output to its own series of time directories. One acceptable solution would be to write the time directories of step 1 in a folder, restart the time, and write the time directories of step 2 in another folder.

Would you have any idea on how to achieve this or other solution?

Any insight, references to documentation or examples, or threads in the forum I may have missed are welcome.

Thank for your attention,
t.oliveira is offline   Reply With Quote

Old   March 4, 2016, 19:24
Default
  #2
Senior Member
 
Wouter van der Meer
Join Date: May 2009
Location: Elahuizen, Netherlands
Posts: 203
Rep Power: 18
wouter is on a distinguished road
hello t.oliveira,

I do not think this is gonna work, because simple foam is not a time dependent solver, time is more or less the name of the iteration steps variables and have nothing to to with the clock time. (steady state solver)
In scalar transport you need this 'clocktime' so the two do not mix.

The best way is to solve with simplefoam and use the converged velocity to calculate the transport of the scalar.

hope this helps,
Wouter
wouter is offline   Reply With Quote

Old   March 7, 2016, 05:30
Default
  #3
Senior Member
 
Thomas Oliveira
Join Date: Apr 2015
Posts: 114
Rep Power: 12
t.oliveira is on a distinguished road
Hi Wouter,

Thanks for your reply. I am aware that the "time" in simpleFoam represents iteration steps, and that's why I want to separate the "time" of simpleFoam from the real time of scalarTransportFoam.

I do intend to solve with simplefoam and use the converged velocity to calculate the transport of the scalar. However, I am looking for a way of doing that withing the same program, so that I save the time that it takes to reconstruct the mesh and reading the velocity field from a file.

Regards,
Thomas
t.oliveira is offline   Reply With Quote

Old   March 7, 2016, 06:20
Default
  #4
Senior Member
 
Thomas Oliveira
Join Date: Apr 2015
Posts: 114
Rep Power: 12
t.oliveira is on a distinguished road
At this moment, I am considering exploring one of these tracks:

i) use subCycling
ii) create a new Foam::Time object
iii) reset time using Foam::Time::setTime

Any thoughts?
t.oliveira is offline   Reply With Quote

Old   March 8, 2016, 16:14
Default How to explicitly couple two solvers / use the results of one solver in another
  #5
Senior Member
 
Thomas Oliveira
Join Date: Apr 2015
Posts: 114
Rep Power: 12
t.oliveira is on a distinguished road
I got a satisfactory solution, but I am almost sure that there must be neater a way of doing it.

My solution involved:

- creating another Foam::argList beside the standard args. The "case" in this other argList is a subdirectory of the original case directory. This allows the "time" directories of the velocity field solver to be written to a separate subdirectory:
Code:
Foam::argList args(argc, argv);
if (!args.checkRootCase())
{
    Foam::FatalError.exit();
}

HashTable<string> directoryVel;
directoryVel.set("case", "flowSolver");
Foam::argList argsVel(args, directoryVel);
if (!argsVel.checkRootCase())
{
    Foam::FatalError.exit();
}
- creating another Foam::Time:
Code:
// Runtime for the solution of velocity and pressure fields
Foam::Time runTimeVel(Foam::word("controlDictVel"), argsVel);
// Runtime for the solution of reactive transport
Foam::Time runTime(Foam::Time::controlDictName, args);
- creating another Foam::fvMesh, fv::IOoptionList and simpleControl

- running the first solver

- mapping the velocity field obtained by the first solver into the velocity field used by the second solver. More tests are needed to verify if this is doing what I expect it to do and that I didn't mess up with pointers and references:

Code:
// U = UVel would work just if U.mesh() == UVel.mesh()
// U.dimensionedInternalField() = UVel.dimensionedInternalField() would work just if U.mesh() == UVel.mesh()
U.dimensionedInternalField().dimensions() = UVel.dimensionedInternalField().dimensions();
U.dimensionedInternalField().Field<vector>::operator=(UVel.dimensionedInternalField());

// U.boundaryField() = UVel.boundaryField() would work if they had same patches      
forAll(UVel.boundaryField(), i)
{
   Field<vector> source = UVel.boundaryField()[i];
   Field<vector> target = U.boundaryField()[i];
   target = source;
}
Before running, I created a subdirectory called "flowSolver". Inside it, I created symbolic links to the folders "0", "constant" and "system".

Best wishes,
Thomas
t.oliveira is offline   Reply With Quote

Old   March 9, 2016, 11:45
Default
  #6
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 437
Rep Power: 22
marupio is on a distinguished road
Good use case for multiSolver.

https://github.com/Marupio/multiSolver/wiki
t.oliveira likes this.
__________________
~~~
Follow me on twitter @DavidGaden
marupio is offline   Reply With Quote

Reply

Tags
output file, timestep


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
Unsteady simulation solution files in parallel gunnersnroses SU2 1 December 15, 2015 14:28
Incompressible simulation brugiere_olivier SU2 2 April 15, 2014 11:12
time step directories naming issue Andrea_85 OpenFOAM 3 April 3, 2014 09:38
Is there a way to write the time step size, time a may FLUENT 6 November 22, 2009 12:52
MFX output of simulation time Richard CFX 0 October 10, 2008 10:50


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