CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM (https://www.cfd-online.com/Forums/openfoam/)
-   -   Visualize scalarCodedSource in paraFoam (https://www.cfd-online.com/Forums/openfoam/235374-visualize-scalarcodedsource-parafoam.html)

jdw135 April 12, 2021 16:23

Visualize scalarCodedSource in paraFoam
 
I'm coding a scalarCodedSource to use with my case, and I'm trying to visualize the results in paraFoam. Is there a way to make it write the result of the calculation at each time step?

Essentially, I am making the field

Code:

scalarField& qq = eqn.source();
qq += ...;

and I would like to visualize qq at each time step. Is there something I add to the fvOptions file?

jdw135 April 13, 2021 10:13

Anyone? I know there has to be a way to do this.

NiklasW April 13, 2021 11:58

Hi Jonathan,

I'm not sure, if it's the best solution, but this might work:
Code:

qq += ...;

volScalarField volqq = volScalarField::New("qq",mesh_, 0.0);
volqq.primitiveFieldRef() = qq;
volqq.write();


jdw135 April 14, 2021 11:18

Quote:

Originally Posted by NiklasW (Post 801439)
Hi Jonathan,

I'm not sure, if it's the best solution, but this might work:
Code:

qq += ...;

volScalarField volqq = volScalarField::New("qq",mesh_, 0.0);
volqq.primitiveFieldRef() = qq;
volqq.write();


For whatever reason, that causes the solution to take much longer and won't load anything at all in paraFoam.

NiklasW April 14, 2021 11:28

So it also doesn't create qq files in your time folders?

jdw135 April 14, 2021 14:47

Quote:

Originally Posted by NiklasW (Post 801559)
So it also doesn't create qq files in your time folders?

It does, but now nothing else gets written to the time folders and when I try to open the case in paraFoam, it just hangs forever when I click apply.

jdw135 April 14, 2021 18:52

Correction*

I realized that your code was printing the qq field every time step, rather than every 500 like my controlDict file specifies. That's almost certainly the cause of the slowdown, as my time step is 1e-5 and I'm running for several seconds.

I guess I need to figure out how to make it write only at the same intervals as the rest of my data.

NiklasW April 15, 2021 03:32

Ah, ok, I thought you wanted to write it at each time step ;)

This should do it:
Code:

if (mesh_.time().writeTime())
{
        volScalarField volqq = volScalarField::New("qq",mesh_, 0.0);
        volqq.primitiveFieldRef() = qq;
        volqq.write();
}


jdw135 April 15, 2021 15:09

Quote:

Originally Posted by NiklasW (Post 801610)
Ah, ok, I thought you wanted to write it at each time step ;)

This should do it:
Code:

if (mesh_.time().writeTime())
{
        volScalarField volqq = volScalarField::New("qq",mesh_, 0.0);
        volqq.primitiveFieldRef() = qq;
        volqq.write();
}


This worked perfectly! Thank you so much for the help!


All times are GMT -4. The time now is 03:29.