CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Q: How to access turbulent production term G from TKE in scalarCodedSource (https://www.cfd-online.com/Forums/openfoam-solving/240535-q-how-access-turbulent-production-term-g-tke-scalarcodedsource.html)

Kbshariff January 11, 2022 05:51

Q: How to access turbulent production term G from TKE in scalarCodedSource
 
1 Attachment(s)
Hello,

I would like to implement a source term into k-epsilon model in a given location using the scalar coded source in fvOptions.

I implemented the k source and it works fine, but the epsilon source term need the production term of the TKE, G. How can I get this term into the equation?

The source term is given in the figure attached herewith.
Attachment 87909



Thank you.

JulioPieri January 11, 2022 08:47

Is this field natively available by the solver?

You can check it by running a "dummy" functionObject that will give you an error and print all available fields:

Code:

FIELDSAVAILABLE
    {
        type                writeObjects;
        libs            ("libfieldFunctionObjects.so");
        executeControl  writeTime;
        writeControl        writeTime;
        objects
        ("HIMYFRIEND");
    }

Check if you can see the field you're looking for printed.

If you can, you may access it with something like

Code:

mesh().lookupObject<volScalarField>("FIELD");
changing Scalar to Vector depending on the type.

If you can't, then you might need to re-write it from the other available fields

Kbshariff January 11, 2022 09:34

Quote:

Originally Posted by JulioPieri (Post 819987)
Is this field natively available by the solver?

You can check it by running a "dummy" functionObject that will give you an error and print all available fields:

Code:

FIELDSAVAILABLE
    {
        type                writeObjects;
        libs            ("libfieldFunctionObjects.so");
        executeControl  writeTime;
        writeControl        writeTime;
        objects
        ("HIMYFRIEND");
    }

Check if you can see the field you're looking for printed.

If you can, you may access it with something like

Code:

mesh().lookupObject<volScalarField>("FIELD");
changing Scalar to Vector depending on the type.

If you can't, then you might need to re-write it from the other available fields


Hello, thanks for the reply, I checked the term is not listed in the available field list.
the TKE production term G is defined in the KEps model as;

It is defined in the .C fine as

Code:

    const volScalarField::Internal G(this->GName(), nut()*GbyNu);
    tgradU.clear();

here

Code:

    // Turbulent kinetic energy equation
    tmp<fvScalarMatrix> kEqn
    (
        fvm::ddt(alpha, rho, k_)
      + fvm::div(alphaRhoPhi, k_)
      - fvm::laplacian(alpha*rho*DkEff(), k_)
    ==
        alpha()*rho()*G
      - fvm::SuSp((2.0/3.0)*alpha()*rho()*divU, k_)
      - fvm::Sp(alpha()*rho()*epsilon_()/k_(), k_)
      + kSource()
      + fvOptions(alpha, rho, k_)
    );

How can I get the production term for the solver?

JulioPieri January 11, 2022 09:52

Hmm so this is harder. I'd try recreating this expression:

Code:

tgradU().v() && dev(twoSymm(tgradU().v())) * nut()
but I'm not sure how to get each of the terms, though they might be accessible.

As alternatives you could edit the code to make this variable accessible, or use swak4Foam that usually have access to more fields. Not sure how to use it for fvOptions though.

Tobermory January 11, 2022 14:57

You are right Julio, but most of those terms (tgradU(), twoSymm(tgradU().v())) will not be stored on the registry, so you'll have to recreate them from the velocity field. Just follow the coding in the kEpsilon model, and you should be fine.


All times are GMT -4. The time now is 01:22.