|
[Sponsors] |
September 14, 2016, 11:29 |
Reading field only at the first time folder
|
#1 |
Member
Join Date: Sep 2014
Posts: 32
Rep Power: 11 |
Hello everyone,
I am implementing a new solver with openfoam, I need to subtract a constant source term from the momentum equation. Since this source term is constant and is pre-obtained, it is better to only save it in the first time step folder. The following is the code (in red) I am using now, but this would end up with saving this term in every time step folder. If anyone hows how to implement it ? Info<< "Reading field dU0dt\n" << endl; volVectorField dU0dt ( IOobject ( "dU0dt", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ), mesh ); ps: Saving this constant term in /constant folder is not an option, since it would work with parallel computing. Therefore, it is better to be saved in the time folder. |
|
September 14, 2016, 15:50 |
|
#2 |
New Member
Tony
Join Date: May 2016
Posts: 22
Rep Power: 9 |
Hi yongxiang,
I'm quite new at this, but this looks like it works. In createFields.H I wrote the following code snippet: Code:
Info<< "Reading field dU0dt\n" << endl; volVectorField dU0dt ( IOobject ( "dU0dt", runTime.constant(), mesh, IOobject::MUST_READ, IOobject::NO_WRITE ), mesh ); Before the while (runTime.run()) loop: Code:
bool write_dUdT = true; I placed it after runTime.write(); Code:
if(write_dUdT){ dU0dt.write(); write_dUdT = false; } After the first time step, it will create a constant (placed in your constant folder) which will then be referred to (and unedited) for following calculations. -- Note, I am not sure if you need this value for your first timestep, If you do, you should probably initialize it with some approximation. You could also move the dU0dt.write(); further up in the solver and use READ_IF_PRESENT. -- Let me know if this helps, Tony |
|
September 14, 2016, 16:58 |
|
#3 |
Member
Join Date: Sep 2014
Posts: 32
Rep Power: 11 |
Hi Tony,
thanks very much for your reply. You provide me an option to complete my desired task. However, the thing is if dU0dt is saved in the /constant folder, there would be problem with parallel computation. As far as I understood, the parallel computation only decompose the /polyMesh folder, where the mesh is stored, into different /processor* folder. Therefore, if dU0dt is stored in the /constant folder, it would not be decomposed, which would make the parallel computing fail. That's why I think saving dU0dt in time folder would be better, since it would be automatically decomposed for parallel computation. I know function like: runTime.constant(), and runTime.timeName(), but do you know something like: runTime.startTime() or runTime.timeName(startTime) or runTime.timeName().startTime() which would allow us to read the dU0dt always from the startTime folder. (All the above are not working as I already tried.) Thanks again for your suggestion. Yongxiang |
|
September 14, 2016, 19:26 |
|
#4 |
New Member
Tony
Join Date: May 2016
Posts: 22
Rep Power: 9 |
Whoops,
Sorry about that... Note: I accidently posted an incorrect solution. I'll keep looking for a solution. Last edited by AnthonyP; September 14, 2016 at 19:38. Reason: Incorrect solution. |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
simpleFoam error - "Floating point exception" | mbcx4jc2 | OpenFOAM Running, Solving & CFD | 12 | August 4, 2015 02:20 |
''unknown radialModelType type Gidaspow'' PROBLEM WITH THE BED TUTORIAL | AndoniBM | OpenFOAM Running, Solving & CFD | 2 | March 25, 2015 18:44 |
same geometry,structured and unstructured mesh,different behaviour. | sharonyue | OpenFOAM Running, Solving & CFD | 13 | January 2, 2013 22:40 |
Upgraded from Karmic Koala 9.10 to Lucid Lynx10.04.3 | bookie56 | OpenFOAM Installation | 8 | August 13, 2011 04:03 |
Differences between serial and parallel runs | carsten | OpenFOAM Bugs | 11 | September 12, 2008 11:16 |