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/)
-   -   How to access an another patch from fvPatchFields? (https://www.cfd-online.com/Forums/openfoam-solving/231145-how-access-another-patch-fvpatchfields.html)

eduardopaiva October 23, 2020 05:58

How to access an another patch from fvPatchFields?
 
Hey guys, this is my first post here and I'm beginner on OpenFOAM and undergraduating.

I'm using of1812 and I need to develop a new boundary condition. Basiclly, I have a duct and that boundary condition is for p_rgh of outlet face. So, I need access the wall patch to apply a correlation that outlet face. What can I do for that?

I'm found in this forum something like this:

// Get the mesh
const fvMesh& mesh(patch().boundaryMesh().mesh());

label patchID = mesh.boundaryMesh().findPatchID(wallName_);
const polyPatch& cPatch = mesh.boundaryMesh()[patchID];

const surfaceScalarField& magSf = mesh.magSf();

scalar patchArea = 0.0;
forAll(cPatch, facei)
{
patchArea += magSf.boundaryField()[patchID][facei];
}

I want to do something similar, but I cannot do mesh.p_rgh(), for exampĺe. Someone knows how can I code this?

Thanks for helping :)

eduardopaiva October 24, 2020 10:41

The solution
 
A colleague helped me, here's the answer:

// Get the mesh
const fvMesh& mesh(patch().boundaryMesh().mesh());

label patchID = mesh.boundaryMesh().findPatchID(wallName_);

const volScalarField& p_rgh_ = this->db().lookupObject<volScalarField>("p_rgh");

const scalarField& pp_rgh_ = p_rgh_.boundaryField()[patchID];

const scalar pWall = gAverage(pp_rgh_);

dlahaye October 25, 2020 04:47

Wonderful of you to share!

Question: in which file do you place these statements to make it work? Alternatively, what does "this" refer to here?

Thank you so much! Domenico.


All times are GMT -4. The time now is 06:33.