How to save a time-dependent scalar variable ?
Hello Foamers,
I'm currently working on a custom solver and there is something I can't figure out. The solver calculates and uses a scalar variable (a rotational speed). It works fine but since this variable isn't written anywhere, I can't stop a case and restart it later. My first idea was to use an IOobject to write this variable with the other data in each time directory but I can't figure how. Since it's only a single scalar I have to use a IOdictionary but I'm unable to write data in it. So dear experienced users, how would you deal with this ? Any suggestions are welcome. Thanks, Yann |
Hi,
You can try to use UniformDimensionedField [1]. Constructor [2] will fit, if you have scalar value, or [3] if you would like to read it. See $FOAM_SRC/src/finiteVolume/cfdTools/general/include/readGravitationalAcceleration.H for example of syntax. 1. http://foam.sourceforge.net/docs/cpp/a02750.html 2. http://foam.sourceforge.net/docs/cpp...767af9c8b8573a 3. http://foam.sourceforge.net/docs/cpp...12a8bffe2acdf7 |
Thanks for your reply Alexey. I'm going to try it but I might have the same problem.
I worked a bit on this dictionary thing. I work within a modified mixerGgiFvMesh class which inherits from the dynamicFvMesh class. Here is how my dictionary is declared in myMixerGgiFvMesh.C : Code:
myVarDict_ But if I change "*this" to, lets say, "mesh()", I get an error when compiling saying : Code:
error: ‘mesh’ was not declared in this scope Any idea how to write the dictionary file in each time directory? Thanks, Yann |
Example would be great. As if I declare this (quick modification of icoFoam solver)
Code:
IOdictionary test Code:
test.set<scalar>("deltaT", runTime.deltaT().value()); Quote:
|
Thanks again for your kind help Alexey.
I already tried to use thisDb() instead of *this but it doesn't change anything, the dictionary isn't written in time folders. But I'm sure my dictionary is properly declared since the first value is read from the "0" folder and if I do a : Code:
Info<< "reading myVarDict : " << readScalar(myVarDict_.lookup("myVar")) << endl; |
All times are GMT -4. The time now is 13:07. |