CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Software User Forums > OpenFOAM > OpenFOAM Programming & Development

Gauss linear gradient calculation discrepancy

Register Blogs Members List Search Today's Posts Mark Forums Read

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   February 15, 2020, 13:31
Default Gauss linear gradient calculation discrepancy
  #1
pod
New Member
 
Join Date: Jun 2015
Posts: 16
Rep Power: 10
pod is on a distinguished road
Hello everyone,
I am trying to calculate in OF301 the gradient of a volScalarField without using fvc::grad (I set Gauss linear as scheme in the case study). Also, I have fully orthogonal hexahedrons.

So I try something like below:

Code:
// this is in setField
volVectorField gradT
    (
		IOobject
		(
		    "gradT",
		    runTime.timeName(),
		    fluidRegions[i],
		    IOobject::NO_READ,
		    IOobject::NO_WRITE
		),
		fluidRegions[i],
		dimensionedVector("gradT", dimensionSet(0,-1,0,1,0,0,0), vector::zero)
    );
//

surfaceScalarField Tface = linearInterpolate(T);
    
    const fvMesh& mesh = Tface.mesh();
	const labelList& own = mesh.owner();
	const labelList& nei = mesh.neighbour();
	const vectorField& Sf = mesh.Sf();
    
    forAll(own, facei)
    {
	        gradT[own[facei]] += Sf[facei]*Tface[facei]/mesh.V()[own[facei]];
	        gradT[nei[facei]] -= Sf[facei]*Tface[facei]/mesh.V()[nei[facei]];
    }
    
    forAll(mesh.boundary(), patchi)
    {
         const labelList& pFaceCells =
             mesh.boundary()[patchi].faceCells();
         const vectorField& pSf = mesh.Sf().boundaryField()[patchi];
         const scalarField& pTface = Tface.boundaryField()[patchi];
 
         forAll(mesh.boundary()[patchi], facei)
         {
                gradT[pFaceCells[facei]] += pSf[facei]*pTface[facei]/mesh.V()[pFaceCells[facei]];
         }
    }
    
    gradT.correctBoundaryConditions();
    
    Info<< "\nDIFFERENCE\n" << max(mag(fvc::grad(T)-gradT)) << "\n" << endl;
which is more or less the same thing done by the member function gradf in gaussGrad.C.

However, if I try to compare the resulting gradient to the one calculated using the function fvc::grad, I see a considerable difference.

Am I missing something? Maybe the surfaceScalarField is not calculated through the linearInterpolate function?

Thank you very much
Cheers
pod is offline   Reply With Quote

Reply

Tags
fvc::grad(), gauss gradient

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
2nd Order Convergence Problem for 3D Airfoil turkmengokce OpenFOAM Running, Solving & CFD 1 September 10, 2015 08:20
bounded Gauss upwind Scheme deepinheart OpenFOAM Running, Solving & CFD 1 February 23, 2015 06:57
BC for turbulent internal flow yhoarau OpenFOAM Running, Solving & CFD 3 January 22, 2015 09:02
2D isothermal cylinder not converging UPengineer OpenFOAM Running, Solving & CFD 7 March 13, 2014 06:17
solution diverges when linear upwind interpolation scheme is used subash OpenFOAM 0 May 29, 2010 02:23


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