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

How to add global Scalar to model?

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Display Modes
Old   September 16, 2011, 05:53
Default How to add global Scalar to model?
  #1
Member
 
Join Date: Aug 2011
Posts: 33
Rep Power: 5
seboxx is on a distinguished road
Hi there,

I am calculating a scalar function over the whole domain of my model, which works out nicely.
Now I would like to have in stored separately for post processing.
But I don't think volScalarField is the right class to save my value since then it would be recalculated at every cell consuming more computation time then necessary.
I think it is a rather easy problem, but somehow I can't find any proper class like globalIOScalar(?!) that fulfills my needs...

I hope someone of you can help me out here ;-)

Thank you,

sebastian
seboxx is offline   Reply With Quote

Old   September 16, 2011, 11:09
Default
  #2
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 397
Rep Power: 12
marupio is on a distinguished road
I use an output dictionary for objects that don't write themselves. Create an IOdictionary, set to runTime.timeName(), and NO_READ, AUTO_WRITE. Then, at every timestep you set the new value:

outputDict.set("nameOfScalar", myScalar);

And it will appear in the time directory.
__________________
~~~
Follow me on twitter @DavidGaden
marupio is offline   Reply With Quote

Old   September 17, 2011, 04:11
Default
  #3
Member
 
Join Date: Aug 2011
Posts: 33
Rep Power: 5
seboxx is on a distinguished road
Hi marupio,

thanks for the advice. But I cannot get it to work.

Quote:
error: 'outputDict' was not declared in this scope
Do I need to include a special library to have this object?
outputDict.set doesn't even appear in the doxygen documentation...
Where did you get that from?

Thanks,

sebastian
seboxx is offline   Reply With Quote

Old   September 17, 2011, 09:12
Default
  #4
Senior Member
 
David Gaden
Join Date: Apr 2009
Location: Winnipeg, Canada
Posts: 397
Rep Power: 12
marupio is on a distinguished road
Sorry I wasn't clear!

Try this:
<code>
// In createField.H:
IOdictionary outputDict
(
IOobject
(
"outputDict",
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::AUTO_WRITE
)
);

// In your solver loop, before runTime.write();
outputDict.set("nameOfScalar", myScalar);
</code>
__________________
~~~
Follow me on twitter @DavidGaden
marupio is offline   Reply With Quote

Old   September 17, 2011, 11:29
Default
  #5
Member
 
Join Date: Aug 2011
Posts: 33
Rep Power: 5
seboxx is on a distinguished road
That worked!

Thank you!
seboxx is offline   Reply With Quote

Reply

Thread Tools
Display Modes

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 On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Solving for an additional species CO in coalChemistryFoam N. A. OpenFOAM Programming & Development 2 November 13, 2014 09:43
how to add radiation model into OpenFOAM1.5-dev+cantera? dahlia-2005 OpenFOAM 9 July 13, 2011 04:33
Low Reynolds k-epsilon model YJZ ANSYS 1 August 20, 2010 13:57
add a source term in kEpsilon model maurice OpenFOAM Running, Solving & CFD 0 May 18, 2009 07:54
IcoFoam parallel woes msrinath80 OpenFOAM Running, Solving & CFD 9 July 22, 2007 02:58


All times are GMT -4. The time now is 13:23.