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

Calculating fvc::grad as a surfaceScalarField

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   March 20, 2019, 02:56
Default Calculating fvc::grad as a surfaceScalarField
  #1
Member
 
benoit favier
Join Date: Jun 2017
Posts: 64
Rep Power: 8
Benben is on a distinguished road
Hello,

I am trying to modify reactingFoam from openfoam 6.0 so that i can save the flux of species.

I created a volScalarField to save this value
Code:
volVectorField flux_N2
(
    IOobject
    (
        "flux_N2",
        runTime.timeName(),
        mesh,
        IOobject::READ_IF_PRESENT,
        IOobject::AUTO_WRITE
    ),
    mesh,
    dimensionedVector("flux_N2_0", dimensionSet(1,-2,-1,0,0,0,0), Foam::vector(0,0,0))
);
And i modified YEqn.h to save the flux of N2:
Code:
//Saving Zn flux
if (Yi.name() == "N2")
{
    flux_Zn = rho*U*Yi - rho*D_i*fvc::grad(Yi)();
}
My problem is that this returns a volVectorField, and i want the flux for each cell face. How can i obtain a similar volSurfaceField ?
Benben is offline   Reply With Quote

Old   March 20, 2019, 03:54
Default
  #2
Senior Member
 
Santiago Lopez Castano
Join Date: Nov 2012
Posts: 354
Rep Power: 15
Santiago is on a distinguished road
Have you tried snGrad?
Santiago is offline   Reply With Quote

Old   March 20, 2019, 07:42
Default
  #3
Member
 
benoit favier
Join Date: Jun 2017
Posts: 64
Rep Power: 8
Benben is on a distinguished road
Hello, thank you for your help.

Unfortunately, it seems that snGrad returns a surfaceScalarField and not a surfaceVectorField. It returns a scalar because it seems to perform a dot product of the gradient with the normal to the cell.
Benben is offline   Reply With Quote

Old   March 21, 2019, 02:47
Default
  #4
Member
 
benoit favier
Join Date: Jun 2017
Posts: 64
Rep Power: 8
Benben is on a distinguished road
I found this post regarding the calculation of the gaussGrad.
It seems to be possible to calculate the vector at the interface, but not with high level functions.
Benben is offline   Reply With Quote

Old   March 21, 2019, 04:42
Default
  #5
Senior Member
 
Santiago Lopez Castano
Join Date: Nov 2012
Posts: 354
Rep Power: 15
Santiago is on a distinguished road
Quote:
Originally Posted by Benben View Post
Hello, thank you for your help.

Unfortunately, it seems that snGrad returns a surfaceScalarField and not a surfaceVectorField. It returns a scalar because it seems to perform a dot product of the gradient with the normal to the cell.
You asked for a face flux, which is a scalar. If you multiply such scalar by the surface area normal you get the flux by components.

If you want the gradient at the face centre, calculate it using fvc::grad and then interpolate the vector to the face centre. I dont see other way that doesnt involve creating a dual mesh
Santiago is offline   Reply With Quote

Reply


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
Questions on dynamicTopoFvMesh danvica OpenFOAM Running, Solving & CFD 80 April 16, 2019 16:58
Long output in terminal. ssa_cfd OpenFOAM Running, Solving & CFD 1 March 18, 2019 05:25
DPMFoam - Serious Error --particle-laden flow in simple geometric config benz25 OpenFOAM Running, Solving & CFD 27 December 19, 2017 20:47
''unknown radialModelType type Gidaspow'' PROBLEM WITH THE BED TUTORIAL AndoniBM OpenFOAM Running, Solving & CFD 2 March 25, 2015 18:44
How to update polyPatchbs localPoints liu OpenFOAM Running, Solving & CFD 6 December 30, 2005 17:27


All times are GMT -4. The time now is 12:24.