|
[Sponsors] |
November 30, 2022, 04:14 |
Save data between two time steps
|
#1 |
New Member
Charles Guaquiere
Join Date: Sep 2022
Posts: 14
Rep Power: 3 |
Dear foamers,
I need to save different values during a time step to use them for the next time step, to do that I thought of using 2 volVectorFields defined in the constructor to "stored" values in vectors components: Code:
sigma_n ( IOobject ( "sigma_n", this->owner_.mesh().time().timeName(), this->owner_.mesh(), IOobject::NO_READ, IOobject::AUTO_WRITE ), this->owner_.mesh(), dimensionedVector("sigma_n", dimless, vector(10e-12, 10e-12, 10e-12)) ), u_n ( IOobject ( "u_n", this->owner_.mesh().time().timeName(), this->owner_.mesh(), IOobject::NO_READ, IOobject::AUTO_WRITE ), this->owner_.mesh(), dimensionedVector("u_n", dimless, vector(0, 0, 0)) ) Code:
const volVectorField& sigma_n = obr.lookupObject<volVectorField>("sigma_n"); volVectorField& sigma_nMod = const_cast<volVectorField&>(sigma_n); const volVectorField& u_n = obr.lookupObject<volVectorField>("u_n"); volVectorField& u_nMod = const_cast<volVectorField&>(u_n); Code:
u_nMod.primitiveFieldRef()[celli].component(0) = UTurb.component(0); u_nMod.primitiveFieldRef()[celli].component(1) = UTurb.component(1); u_nMod.primitiveFieldRef()[celli].component(2) = UTurb.component(2); sigma_nMod.primitiveFieldRef()[celli].component(0) = sigma_x; sigma_nMod.primitiveFieldRef()[celli].component(1) = sigma_y; sigma_nMod.primitiveFieldRef()[celli].component(2) = sigma_z; So I wonder if it's possible to save datas in volVectorFIeld between two consecutive time step with this method, if not can you help me to find another solution ? I'am beginner in programming under OpenFOAM so any idea could be helpful for me ! Thanks in advance! Best regards |
|
July 4, 2023, 05:19 |
|
#2 |
New Member
Join Date: Feb 2018
Posts: 17
Rep Power: 8 |
Hi Charles,
I am struggling to do a similar thing where I need the values of a vectorField to be carried over to the next timestep. Did you manage to solve your problem? Thanks! |
|
July 4, 2023, 05:57 |
|
#3 | |
New Member
Charles Guaquiere
Join Date: Sep 2022
Posts: 14
Rep Power: 3 |
Quote:
To solve this problem I modified other files in the code (for turbulent dispersion) to add the vector fields I need as "input variables" in the turbulent dispersion model. With this solution this fields are automatically saved at each time steps and you can use them. But the different lines of code I added in my previous message can also do it. If you need more informations don't hesitate. |
||
July 5, 2023, 05:21 |
|
#4 |
New Member
Join Date: Feb 2018
Posts: 17
Rep Power: 8 |
Thanks for your quick reply!
I think I'll need to do some re-coding of other files as well.. The issue is the field I wanted to modify is vectorField which makes it more difficult in some ways. I'm trying now to generate a volVectorField which atleast allows me to use the oldTimes method. Lets see. Thanks anyways! |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
how to export all time steps' data | alubacyj | CFX | 11 | June 22, 2023 18:18 |
How to export time series of variables for one point? | mary mor | OpenFOAM Post-Processing | 8 | July 19, 2017 10:54 |
pressure in incompressible solvers e.g. simpleFoam | chrizzl | OpenFOAM Running, Solving & CFD | 13 | March 28, 2017 05:49 |
[General] 2 datas on one plot | Akuji | ParaView | 46 | December 1, 2013 14:06 |
same geometry,structured and unstructured mesh,different behaviour. | sharonyue | OpenFOAM Running, Solving & CFD | 13 | January 2, 2013 22:40 |