CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM

Write out temp object during simulation

Register Blogs Community New Posts Updated Threads Search

Like Tree2Likes
  • 2 Post By olesen

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   August 6, 2010, 14:01
Default Write out temp object during simulation
  #1
Senior Member
 
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 16
deji is on a distinguished road
I would like to write out a temporary volScalarField object:
virtual tmp<volScalarField> alphaEff

during simulation. Is this possible to do in OpenFOAM somehow?

Best regards
Deji
deji is offline   Reply With Quote

Old   August 6, 2010, 14:51
Default
  #2
Senior Member
 
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23
l_r_mcglashan will become famous soon enough
Why make it temporary if you want to write it out?

And I've never seen a virtual variable before.

However, I see what you're getting at. You can use .write() to write that object to file at any point in a simulation. Or you can create an IOobject with AUTO_WRITE, and assign alphaEff to it. Then it will be output every writeInterval (in controlDict).
__________________
Laurence R. McGlashan :: Website
l_r_mcglashan is offline   Reply With Quote

Old   August 7, 2010, 05:11
Default
  #3
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,684
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by l_r_mcglashan View Post
Why make it temporary if you want to write it out?

And I've never seen a virtual variable before.
I think he's referring to the method itself, which is virtual and which returns a tmp<volScalarField>.
olesen is offline   Reply With Quote

Old   August 7, 2010, 05:19
Default
  #4
Senior Member
 
Mark Olesen
Join Date: Mar 2009
Location: https://olesenm.github.io/
Posts: 1,684
Rep Power: 40
olesen has a spectacular aura aboutolesen has a spectacular aura about
Quote:
Originally Posted by deji View Post
I would like to write out a temporary volScalarField object:
virtual tmp<volScalarField> alphaEff

during simulation. Is this possible to do in OpenFOAM somehow?
No problem, just use the write() method but note that this method belongs to the underlying class and not to tmp<> itself.

Since the alphaEff method returns a tmp<volScalarField> you'll either need to dereference it, or create a volScalarField from it.

Option 1 (not particularly elegant), create a volScalarField:
Code:
{
   volScalarField alphaEff = turb.alphaEff();
   alphaEff.write();
}
Option 2, using a dereferenced tmp:
Code:
{
   tmp<volScalarField> talphaEff = turb.alphaEff();
   talphaEff().write();
}
Option 3 is the most succinct and also uses a dereferenced tmp but without an intermediate variable. This is what I'd use.
Code:
   turb.alphaEff()().write();
I hope this helps.
mm.abdollahzadeh and Hughtong like this.
olesen is offline   Reply With Quote

Old   August 7, 2010, 07:23
Default
  #5
Senior Member
 
Laurence R. McGlashan
Join Date: Mar 2009
Posts: 370
Rep Power: 23
l_r_mcglashan will become famous soon enough
Although you may not want to write out the file evey time step. Perhaps enclose it in this?

Code:
if(runTime.outputTime())
{
     turb.alphaEff()().write(); 
}
__________________
Laurence R. McGlashan :: Website
l_r_mcglashan is offline   Reply With Quote

Old   August 7, 2010, 18:01
Default
  #6
Senior Member
 
n/a
Join Date: Sep 2009
Posts: 199
Rep Power: 16
deji is on a distinguished road
Thank you very much guys. I will try your suggestions in my computation.

Best regards
Deji
deji is offline   Reply With Quote

Old   June 4, 2013, 09:39
Default
  #7
Member
 
Saba Saeb
Join Date: Dec 2010
Location: Erlangen, Germany
Posts: 32
Rep Power: 15
saba_saeb is on a distinguished road
Anyone happen to know how I can output nuTilda field calculated in SpalartAllmaras model?

Cheers,
Saba
saba_saeb is offline   Reply With Quote

Reply


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
mesh file for flow over a circular cylinder Ardalan Main CFD Forum 7 December 15, 2020 13:06
Simulation doesn't meet reality Hans FloEFD, FloWorks & FloTHERM 1 June 9, 2010 08:59
Replacing mesh while running a simulation akultane CFX 1 November 15, 2009 13:46
What's the best order to run this simulation in? siw CFX 1 November 4, 2009 19:42
Overflow problem in steady simulation ReeKo CFX 11 October 8, 2008 17:57


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