|
[Sponsors] |
January 10, 2019, 15:03 |
Dimensions of fvc::div()
|
#1 |
New Member
Gavin Ridley
Join Date: Jan 2019
Location: Tennessee, USA
Posts: 25
Rep Power: 7 |
Hello all,
I'm trying to modify some of the heat conduction terms in interCondensatingEvaporatingFoam in OpenFOAM-plus. I'm encountering some dimensions errors, and think I've created an example below which illustrates my confusion best. I expect that taking the divergence of the gradient of a dimensionless variable would have the dimensions of 1/length^2, but this seems to not be the case. Consider this code: Code:
Info << "Units of alpha:" << alpha1.dimensions() << endl; surfaceScalarField mygrad(fvc::snGrad(alpha1)); Info << "Units of grad(alpha):" << mygrad.dimensions() << endl; volScalarField mydiv(fvc::div(mygrad)); Info << "Units of div(grad(alpha)):" << mydiv.dimensions() << endl; Code:
Units of alpha:[0 0 0 0 0 0 0] Units of grad(alpha):[0 -1 0 0 0 0 0] Units of div(grad(alpha)):[0 -2 0 0 0 0 0] Code:
Units of alpha:[0 0 0 0 0 0 0] Units of grad(alpha):[0 -1 0 0 0 0 0] Units of div(grad(alpha)):[0 -4 0 0 0 0 0] Calculating gradients at cell centers seems to give the expected result, using the below code: Code:
Info << "Units of alpha:" << alpha1.dimensions() << endl; volVectorField mygrad(fvc::grad(alpha1)); Info << "Units of grad(alpha):" << mygrad.dimensions() << endl; volScalarField mydiv(fvc::div(mygrad)); Info << "Units of div(grad(alpha)):" << mydiv.dimensions() << endl; |
|
January 11, 2019, 18:13 |
|
#2 | |
Senior Member
Andrew Somorjai
Join Date: May 2013
Posts: 175
Rep Power: 13 |
Quote:
Look in the comments! |
||
January 11, 2019, 20:08 |
|
#3 | |
Senior Member
Daniel
Join Date: Mar 2013
Location: Noshahr, Iran
Posts: 348
Rep Power: 21 |
Quote:
The link you have posted is talking about divergence of gradient of a function called "g" that is of L^-2 dimension...then the dimension of the Laplacian of "g" becomes L^-4. However, the "alpha" function in the first post is dimension-less... |
||
January 11, 2019, 20:09 |
|
#4 | |
Senior Member
Andrew Somorjai
Join Date: May 2013
Posts: 175
Rep Power: 13 |
Quote:
I'd like to see the actual proof myself. |
||
January 11, 2019, 20:20 |
|
#5 |
Senior Member
Daniel
Join Date: Mar 2013
Location: Noshahr, Iran
Posts: 348
Rep Power: 21 |
||
January 11, 2019, 21:33 |
|
#6 |
New Member
Gavin Ridley
Join Date: Jan 2019
Location: Tennessee, USA
Posts: 25
Rep Power: 7 |
I appreciate the replies! Unfortunately, I understand that transcendental functions are dimensionless. The question here pertains to the fact that each spatial derivative should have units of inverse length, so a Laplacian should have inverse area units. Unfortunately it seems that obtaining gradients via snGrad then taking divergence gives a differing result (not inverse area, as it should be).
How exactly does that stack exchange post pertain to that? |
|
January 11, 2019, 21:53 |
|
#7 | |
Senior Member
Daniel
Join Date: Mar 2013
Location: Noshahr, Iran
Posts: 348
Rep Power: 21 |
Quote:
Meaning of "fvc::div(phi)" |
||
January 11, 2019, 22:01 |
|
#8 |
New Member
Gavin Ridley
Join Date: Jan 2019
Location: Tennessee, USA
Posts: 25
Rep Power: 7 |
No, that doesn't explain the units here unfortunately. Even if you interpret divergence as integral of divergence over a cell volume, i.e. the sum of the surfaceScalarField times face areas, you should still not get the units which openfoam returns in the example above.
|
|
January 11, 2019, 22:29 |
|
#9 | |
Senior Member
Daniel
Join Date: Mar 2013
Location: Noshahr, Iran
Posts: 348
Rep Power: 21 |
Quote:
Incompatible dimensions.... fvc::div() actually divide the final result by the volume [m^3] that's why the unit of div(phi) is [0 0 -1 0 0 0 0] in your case: fvc::div(grad(Alpha)) -->> [0 0 -1 0 0 0 0] / [0 0 -3 0 0 0 0] Edit: that was a mistake, I did somehow mix everything: in your case: fvc::div(grad(Alpha)) -->> [0 0 -1 0 0 0 0] / [0 0 3 0 0 0 0] Last edited by Daniel_Khazaei; January 13, 2019 at 16:43. |
||
January 13, 2019, 14:10 |
|
#10 | |
New Member
Gavin Ridley
Join Date: Jan 2019
Location: Tennessee, USA
Posts: 25
Rep Power: 7 |
Thanks Daniel, I see what you're saying and agree that the post you provided gives some good insight. Unfortunately, it still doesn't make sense though; this does not give reason for divergence(grad(alpha)) to not have units of 1/length**2.
You say: Quote:
As a result of dividing by volume. Volume is units of [0 0 3 0 0 0 0], not [0 0 -3 0 0 0 0]. Also, since the grad(alpha) is defined as grad(alpha)*faceArea, the units should be [0 0 1 0 0 0 0]. Taking what they said about the fvc::div operator, you sum the surfaceScalarField values then divide by volume, this is [0 0 1 0 0 0 0] / [0 0 3 0 0 0 0] which should be units of 1/area i.e. [0 0 -2 0 0 0 0]. This is what I expect, but OpenFOAM clearly gives a different answer, as evidenced by the original post. |
||
January 13, 2019, 17:06 |
|
#11 | |
Senior Member
Daniel
Join Date: Mar 2013
Location: Noshahr, Iran
Posts: 348
Rep Power: 21 |
Quote:
What has been said on that post by "The surfaceField are presumed to be equal to field*Aface" is about "phi" as an example which is calculated by fvc::interpolate(U) & mesh.sf(), The unit of phi here will be: Code:
[0 1 -1 0 0 0 0]*[0 2 0 0 0 0 0] = [0 3 -1 0 0 0 0] Code:
[0 3 -1 0 0 0 0] / [0 3 0 0 0 0 0] = [0 0 -1 0 0 0 0] Code:
[0 -1 0 0 0 0 0] Code:
[0 -1 0 0 0 0 0] / [0 3 0 0 0 0 0] = [0 -4 0 0 0 0 0] Last edited by Daniel_Khazaei; January 15, 2019 at 22:40. |
||
January 13, 2019, 22:40 |
|
#12 |
New Member
Gavin Ridley
Join Date: Jan 2019
Location: Tennessee, USA
Posts: 25
Rep Power: 7 |
Thanks very much for the explanation Daniel! This makes sense. So to obtain the true divergence, I have to multiply "mygrad" by face areas first? To be honest, I'm surprised that ::div doesn't automatically do this. I wonder why not. I cannot thank you enough for helping me figure this out... I was certainly scratching my head over this for a few hours this past week!
|
|
January 15, 2019, 15:29 |
|
#13 | |
Senior Member
Daniel
Join Date: Mar 2013
Location: Noshahr, Iran
Posts: 348
Rep Power: 21 |
Quote:
surfaceScalarFields are variables defined on the faces of each cell and it should be used for variables that actually have physical meaning when defined on the surface, e.g. mass flux(rho*U*A) fvc::div(anything) will give a result as long as you follow its rules and the provided argument doesn't violates any mathematical or C++ methods defined for it! Whether the given argument and its divergence actually have any physical meaning or not is a different story and of-course non of fvc::div() business. |
||
Tags |
dimensions, fvc::div, units |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Different dimensions for = dimensions : [0 2 -1 0 0 0 0] = [0 4 -3 0 0 0 0] | mohakbl111 | OpenFOAM Running, Solving & CFD | 5 | February 6, 2019 06:37 |
Grid with huge dimensions | Sadegh.A | Mesh Generation & Pre-Processing | 0 | December 30, 2018 16:23 |
FOAM FATAL ERROR for Different dimensions | rupesh_w | OpenFOAM Running, Solving & CFD | 2 | April 27, 2016 05:14 |
Incompatible dimensions for operation | ruben23 | OpenFOAM Running, Solving & CFD | 2 | June 12, 2015 05:14 |
Software that can stretch the overall dimensions of a mesh. | Robert_B | Main CFD Forum | 2 | January 27, 2012 08:39 |