|
[Sponsors] |
How to save a time-dependent scalar variable ? |
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
May 5, 2015, 10:35 |
How to save a time-dependent scalar variable ?
|
#1 |
Senior Member
Yann
Join Date: Apr 2012
Location: France
Posts: 1,200
Rep Power: 28 |
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 |
|
May 5, 2015, 11:33 |
|
#2 |
Senior Member
|
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 |
|
May 6, 2015, 13:19 |
|
#3 |
Senior Member
Yann
Join Date: Apr 2012
Location: France
Posts: 1,200
Rep Power: 28 |
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_ ( IOdictionary ( IOobject ( "myVar", time().timeName(), *this, IOobject::MUST_READ, IOobject::AUTO_WRITE ) ) ), 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 |
|
May 6, 2015, 14:01 |
|
#4 | |
Senior Member
|
Example would be great. As if I declare this (quick modification of icoFoam solver)
Code:
IOdictionary test ( IOobject ( "testVar", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE ) ); Code:
test.set<scalar>("deltaT", runTime.deltaT().value()); Quote:
|
||
May 7, 2015, 04:56 |
|
#5 |
Senior Member
Yann
Join Date: Apr 2012
Location: France
Posts: 1,200
Rep Power: 28 |
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; |
|
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Transient simulation not converging | skabilan | OpenFOAM Running, Solving & CFD | 14 | December 17, 2019 00:12 |
AMI interDyMFoam for mixer nu problem | danny123 | OpenFOAM Programming & Development | 8 | September 6, 2013 03:34 |
How to write k and epsilon before the abnormal end | xiuying | OpenFOAM Running, Solving & CFD | 8 | August 27, 2013 16:33 |
dynamic Mesh is faster than MRF???? | sharonyue | OpenFOAM Running, Solving & CFD | 14 | August 26, 2013 08:47 |
emag beta feature: charge density | charlotte | CFX | 4 | March 22, 2011 10:14 |