snGradCorrection
Hello,
I am trying to modify a utility to get the normal gradient of a scalar field at boundaries. I was getting some strange results from using fvc::snGrad, and i read in the Programmers Guide that one might benefit from using fvc::snGradCorrection if the mesh is not orthogonal (which is the case here). I tried this, but when compiling the utility I get the error: error: ‘snGradCorrection’ is not a member of ‘Foam::fvc’ I'm a beginner with OpenFOAM, and haven't delved too deeply into its code yet, so I'm a little lost on how to find out what I'm doing wrong. Any help will be appreciated. |
Hi,
there is no fvc::snGradCorrection, but you can use fvc::snGrad and then set snGradSchemes to corrected in your fvSchemes. This will calculate the surface normal gradient with non-orthogonal correction. As regards snGrad at the boundaries, by default OpenFOAM sets non-orthogonal correction to zero at the boundary (see Jasak Thesis) so the accuracy is only good on orthogonal grids. If you do need correction at the boundaries, you need to implement custom boundary conditions with non-orthogonal correction. Philip |
Let me see if i've understood you:
fvc::snGrad may be corrected for non-orthogonal meshes, but it will be no use for me if i'm only interested in the boundaries? snGradSchemes in the system/fvSchemes of my case was already set to "corrected". Is this what is used by my custom utility? |
Quote:
Quote:
Code:
00176 // Return gradient at boundary Therefore if you are interested in orthogonal correction at the boundaries, you could implement a custom boundary condition where you define the snGrad as (taken from fixedDisplacementFvPatchVectorField.C found here): Code:
115 const fvPatchField<tensor>& gradField = Philip |
corrected snGradient
Hi
i want to discrete momentom Eqn and i need formulation of corrected sngradient in OF. please help me |
Philip,
What could be the reason you think? Thanks, Rdf |
Hi Rdf,
I am not sure of the reason; for the diffusion operator, it can make a big difference e.g. look at the gradT field with laplacianFoam on a mesh with non-orthogonal cells near the boundary. In fact, as far as I know, some forks of OpenFOAM (e.g. Caelus) enable this boundary non-orthogonal correction by default for all physics. Philip |
Quote:
Does Foam::fvPatchField<Type>::snGrad() only excuted when the fixedValue is used? Here is my observation with fvPatchField<Type>::snGrad() and I do not exactly sure about what is the use of the fvPatchField<Type>::snGrad(). First, in the fixedValueFvPatchField.C, there is no fvPatchField<Type>::snGrad(). While, in the fixedGradientFvPatchField.H, fvPatchField<Type>::snGrad() return the gradient that you defined. Am I missing something? Second, fvPatchField<Type>::snGrad() only referenced by wall functions and snGradScheme< Type >::snGrad(). Third, where does the solver need the fvPatchField<Type>::snGrad()? I thought the BC condition only impact the solution through the function valueInternalCoeffs, valueBoundaryCoeffs, gradientInternalCoeffs(), and gradientBoundaryCoeffs(). |
Quote:
Code:
laplacian(DT,T) Gauss linear secondOrderCorrected; https://sourceforge.net/projects/ope...t-OFW10-77.pdf Note: With a fixed gradient BC it can recover 2nd order using only the least squares gradient reconstruction. Using the standard Gauss gradient reconstruction, 2nd order not possible because the boundary face value is unknown. We therefore implemented a corrected Gauss gradient, corrGauss, which iterates to improve the accuracy. The default is 2 iterations and improves the accuracy to somewhere between 1st and 2nd order. -Chris |
Here are two papers for the future reference
A case-study in open-source CFD code verification, Part I: Convergence rate loss diagnosis https://www.sciencedirect.com/scienc...78475417303774 A case-study in open-source CFD code verification. Part II: Boundary condition non-orthogonal correction https://www.sciencedirect.com/scienc...78475417303762 |
Hi randolph,
See my replies below. Quote:
Quote:
Quote:
Quote:
Also, I said above, it will affect the calculation of the gradient field. Hope it helps, Philip |
Quote:
Thank you very much! It is much clear to me now! Rdf |
Hi Philip,
I spend some time reading the implementation of the snGrad(). However, I have some trouble with understanding the calling sequence. For example, the fixed gradient, which is defined as: Code:
https://cpp.openfoam.org/v5/classFoa...4a9_cgraph.png I am noob in both C++ and OpenFoam. I am very new to the handling of a unstrucured non-orthogonal grid. Could you please help me to understand the implementation of snGrad(). Particularly, how exactly the snGrad() work with other functions, such as valueInternalCoeffs(), valueBoundaryCoeffs(),gradientInternalCoeffs(), gradientBoundaryCoeffs(), to influent the solution. Thanks, Rdf |
All times are GMT -4. The time now is 14:41. |