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/)
-   -   Field values at the boundary cells (https://www.cfd-online.com/Forums/openfoam-solving/191142-field-values-boundary-cells.html)

vcvedant August 1, 2017 11:14

Field values at the boundary cells
 
I want to get values of turbulent kinetic energy at the cells of one of the boundary along with its x and y coordinates. I will use these values to modify one of the terms of the realizableKE model.
My approach is to run loop along the patch to get these values before the kEqn.
Which function should I use to get TKE values at the boundary. I have defined the boundary as zeroGradient.

Sugajen August 1, 2017 19:39

check this out!
 
Hi Vedamt,

You are right about running a loop along boundary and patch to get values. I am not aware of the turbulent kinetic energy field variable, but assuming it is TKE, the general method is something like this
Code:

forAll (mesh.boundaryMesh(), patchI)
{
    forAll(TKE.boundaryField()[patchI], faceI)
    {
        scalar tKEVal = TKE.boundaryField()[patchI][faceI];
        scalar Xval = mesh.Cf().boundaryField()[patchI][faceI].x();
        scalar Yval = mesh.Cf().boundaryField()[patchI][faceI].y();
    }
}

best,
Sugajen

vcvedant August 2, 2017 15:35

Reading user labels
 
Quote:

Originally Posted by Sugajen (Post 659187)
Hi Vedamt,

You are right about running a loop along boundary and patch to get values. I am not aware of the turbulent kinetic energy field variable, but assuming it is TKE, the general method is something like this
Code:

forAll (mesh.boundaryMesh(), patchI)
{
    forAll(TKE.boundaryField()[patchI], faceI)
    {
        scalar tKEVal = TKE.boundaryField()[patchI][faceI];
        scalar Xval = mesh.Cf().boundaryField()[patchI][faceI].x();
        scalar Yval = mesh.Cf().boundaryField()[patchI][faceI].y();
    }
}

best,
Sugajen


Thanks for your response. Very much what I required.
One more question that I would need patchI if need to loop over a particular patch. But I want to read the patch value from the user defined files such as CoeffDict.

I have added

Code:

inletID
    (
        dimensioned<label>::lookupOrAddToDict
        (
            "inletID",
            coeffDict_,
            1
        )
    )

but I receive an error:
cannot convert 'Foam::dimensioned<int>' to 'Foam::label {aka int}' in initialization

Can you correct me on this?

Sugajen August 2, 2017 17:19

Sorry, haven't used CoeffDict before.

vcvedant August 2, 2017 17:50

Similar question
 
Dear Sugajen,

When using the code below

Code:

tmp<volScalarField> FST(k_);                       
        forAll(mesh_.C(),cellI)                //loop through all cells defined in mesh
        {
                FST[cellI] = scalar(1);

        }


I get the following error: no match for 'operator []' in 'FST[cellI]'. I tried several things but unable to resolve.


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