CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   what does constrainHbyA.C do? (https://www.cfd-online.com/Forums/openfoam-programming-development/233868-what-does-constrainhbya-c-do.html)

M.Davoodi February 15, 2021 07:51

what does constrainHbyA.C do?
 
Hi Guys,

Does anyone know what happens on the parts of the constrainHbyA.C code (the part shown by the red and blue fonts?):
It seems that in the red part it is trying to find the value of pressure at the boundaries and then it does NOTHING? No variable is changed or modified here, it just finds the value of pressure and literally does nothing! A bit strange?

Also what about the blue part? It says HbyA value at the boundaries are equal to the value of velocity????! Where does that come from?



\*---------------------------------------------------------------------------*/

#include "constrainHbyA.H"
#include "volFields.H"
#include "fixedFluxExtrapolatedPressureFvPatchScalarField.H "

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

Foam::tmp<Foam::volVectorField> Foam::constrainHbyA
(
const tmp<volVectorField>& tHbyA,
const volVectorField& U,
const volScalarField& p
)
{
tmp<volVectorField> tHbyANew;

if (tHbyA.isTmp())
{
tHbyANew = tHbyA;
tHbyANew.ref().rename("HbyA");
}
else
{
tHbyANew = new volVectorField("HbyA", tHbyA);
}

volVectorField& HbyA = tHbyANew.ref();
volVectorField::Boundary& HbyAbf = HbyA.boundaryFieldRef();

forAll(U.boundaryField(), patchi)
{
if
(
!U.boundaryField()[patchi].assignable()
&& !isA<fixedFluxExtrapolatedPressureFvPatchScalarFie ld>
(
p.boundaryField()[patchi]
)
)
{
HbyAbf[patchi] = U.boundaryField()[patchi];
}
}

return tHbyANew;
}


// **************************************************

mAlletto February 15, 2021 08:25

There is a small description of the function here:

https://openfoamwiki.net/index.php/SimpleFoam


is this of help?

M.Davoodi February 15, 2021 08:47

Quote:

Originally Posted by mAlletto (Post 796244)
There is a small description of the function here:

https://openfoamwiki.net/index.php/SimpleFoam


is this of help?

Many thanks man, it was really helpful. So obvious now that I saw the response (when pressure gradient is zero, HbyA is equal to U!)…

Also a quick question about the red part. Do u have any idea what is that part doing? It says if “!U.boundaryField()[patchi].assignable()
&& !isA<fixedFluxExtrapolatedPressureFvPatchScalarFie ld>”
Then do:

p.boundaryField()[patchi]

?

mAlletto February 15, 2021 12:06

The red text is the argument to the function which checks if it is a fixedfluxpressure boundary condition

M.Davoodi February 15, 2021 12:10

Quote:

Originally Posted by mAlletto (Post 796262)
The red text is the argument to the function which checks if it is a fixedfluxpressure boundary condition

Really helpful, cheers man!


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