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 is the value of fvc::grad(U) at boundaries? (https://www.cfd-online.com/Forums/openfoam-programming-development/201810-what-value-fvc-grad-u-boundaries.html)

EmadTandis May 11, 2018 08:41

What is the value of fvc::grad(U) at boundaries?
 
Hello
I am working on a elastic solver in which I need to calculate grad(U) at boundaries. I just read the code of gaussGrad.C and concluded that value of grad(U) at boundaries must be equal to patchInternalField value of grad(U), since it is zeroGradientType. But I got different experience. I need to know how grad(U) works at boundaries.
Any help will be appreciated

EmadTandis May 11, 2018 11:50

I found the reason!
gradScheme class uses a function named "correctBoundaryCondition(vf,fGrad)" using which the gGrad at boundary is corrected by snGrad at boundaries.
I hope it can be of use for fellows.

EmadTandis May 15, 2018 07:44

Quote:

Originally Posted by EmadTandis (Post 692062)
I found the reason!
gradScheme class uses a function named "correctBoundaryCondition(vf,fGrad)" using which the gGrad at boundary is corrected by snGrad at boundaries.
I hope it can be of use for fellows.

Hello Dr Jasak
I need to calculate tangential component of grad(U) at boundaries more accurately. I guess that at boundary, it uses zero gradient condition for this component. Am I right? Is there any way to handle that or I have to develop a code by myself?
Thanks

Zhiheng Wang May 31, 2018 06:24

Gradient along the boundary
 
Let say You got T a parameter at boundary , or volScalarField or If you want Grad on surface as surfaceScalarField
surfaceScalarField SnGrad
(
fvc::snGrad(T) /// Normal component of Grad T
);

volScalarField SnVolGrad
(
IOobject
(
"SnVolGrad",
runTime.timeName(),
mesh
),
mesh,
dimensionedScalar("SnVolGrad", T.dimensions()/dimLength, 0.0)
);

forAll(T.boundaryField(), patchi)
{
SnVolGrad.boundaryFieldRef()[patchi] = SnGrad.boundaryField()[patchi];

}

SnVolGrad.write();
/////////////////////////////////////////////////////////////////////////////////////////////////////

volVectorField GradientY
(
IOobject
(
"GradientY",
runTime.timeName(),
mesh
),

fvc::grad(T)
);


GradientY.write();

volScalarField GradientX
(
IOobject
(
"GradientX",
runTime.timeName(),
mesh
),
fvc::grad(T)().component(0)
);

GradientX.write();

volScalarField Grad_T
(
IOobject
(
"Grad_T",
runTime.timeName(),
mesh
),
mesh,
dimensionedScalar("Grad_T", T.dimensions()/dimLength, 0.0)
);

forAll(SnVolGrad.boundaryField(),patchi)
{
Grad_T.boundaryFieldRef()[patchi] = GradientX.boundaryFieldRef()[patchi] + SnVolGrad.boundaryFieldRef()[patchi];
}
Grad_T.write();



Find suitable way any of above should work


All times are GMT -4. The time now is 21:19.