CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   Write out temp object during simulation (http://www.cfd-online.com/Forums/openfoam/78946-write-out-temp-object-during-simulation.html)

deji August 6, 2010 14:01

Write out temp object during simulation
 
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

l_r_mcglashan August 6, 2010 14:51

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).

olesen August 7, 2010 05:11

Quote:

Originally Posted by l_r_mcglashan (Post 270605)
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 August 7, 2010 05:19

Quote:

Originally Posted by deji (Post 270598)
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.

l_r_mcglashan August 7, 2010 07:23

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();
}


deji August 7, 2010 18:01

Thank you very much guys. I will try your suggestions in my computation.

Best regards
Deji

saba_saeb June 4, 2013 09:39

Anyone happen to know how I can output nuTilda field calculated in SpalartAllmaras model?

Cheers,
Saba


All times are GMT -4. The time now is 08:55.