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/)
-   -   Reading the patch labels (https://www.cfd-online.com/Forums/openfoam-solving/191202-reading-patch-labels.html)

vcvedant August 3, 2017 10:46

Reading the patch labels
 
Hello,

I need patch ID for some calculations in the kEpsilon.C .
I found on forum that patch can be accessed like:
Code:

label patchID = patch.boundaryMesh.lookupPatchID("patchName")
My questions are:
1. when I am compiling the EXE for this, the patchName does not exist as such since I have not run any solver such as simpleFoam or pisoFoam, or kEpsilon file does not have the mesh details. So, how will it get the patchID given the patchName.
2. I get an error: 'patch' was not declared in this scope
3. How can I read patchID as I read other constants such as Cmu_, sigmaK_ etc from coeffDict?
I tried:
Code:

kEpsilon::kEpsilon(..,...,..):RASModel(....),
inletID
    (
        dimensioned<label>::lookupOrAddToDict
        (
            "inletID",
            1
        )
    )

I get the error: no matching function for call to 'Foam::dimensioned<int>::lookupOrAddToDict(const char [8], int)'

So, how should I get the labelID for the patch names I have described in blockMeshDict?

Sugajen August 3, 2017 14:14

Hi Vedamt,

Code:

string patchName = mesh.boundaryMesh()[patchI].name();
Is this what you're looking for?

vcvedant August 3, 2017 14:29

No. I my idea is to get the patchID from the patchName.
But i don't have patchName available in the RASModel.C or kEpsilon.C
So, I want to get that information from the user.

Sugajen August 3, 2017 14:37

I see what you say. Do have a look at this,
Code:

forAll(mesh.boundaryMesh(), patchI)
{
        string patchNameNeeded = "patchNameInBlockMesh";
        string patchName = mesh.boundaryMesh()[patchI].name();       
        if (patchName.find(patchNameNeeded) != std::string::npos)  // checks if "patchNameInBlockMesh" is in the current patchName
        {
        //
        }
}


vcvedant August 3, 2017 14:59

Thank you Sugajen, this explains well what I needed.

I will post in couple of days when I am able to run the case using this implementation.


All times are GMT -4. The time now is 20:35.