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

Units Doesn't match

Register Blogs Community New Posts Updated Threads Search

Like Tree3Likes
  • 3 Post By Zeppo

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 21, 2017, 11:11
Default Units Doesn't match
  #1
Member
 
Mehdi Aminyavari
Join Date: Feb 2016
Location: Milan
Posts: 35
Rep Power: 10
Mehdi3031 is on a distinguished road
Hello All, I realized something really weird in OpenFoam which I can't find any explanation...
consider the solver interFoam, in creatField.H phi is made as incompressible flow:
#include "createPhi.H"
which in the definition can be found that:
Code:
surfaceScalarField phi
(
    IOobject
    (
        "phi",
        runTime.timeName(),
        mesh,
        IOobject::READ_IF_PRESENT,
        IOobject::AUTO_WRITE
    ),
    linearInterpolate(U) & mesh.Sf()
);
Now, U is [m/s] and Sf is [m^2], so phi should be [m^3/s]. If you printout the dimension of phi from the solver, you'll get the same answer:
Code:
    Info << "phi.dim = "<< phi.dimensions() << endl;
result:
phi.dim = [0 3 -1 0 0 0 0]
SO FAR SO GOOD!!!!
now lets consider the UEqn.H:

Code:
    fvVectorMatrix UEqn
    (
        fvm::ddt(rho, U)
	+ fvm::div(rhoPhi, U)
        + turbulence->divDevRhoReff(U)
    );

which I rewrite it as following so that we can see it better:

    volTensorField SS=fvc::grad(U);
    fvVectorMatrix UEqn
    (
        fvm::ddt(rho, U)
	+ fvm::div(rhoPhi, U)
	- fvm::laplacian(mu, U)
	- fvc::div(  mu*dev2(SS.T())   )
    );
1)Dimension analysis of term "fvm::ddt(rho, U)":
[1/s]*[kg/m^3]*[m/s]= [kg/m^2/s^2] ([1/s] is due to derivative with respect to time)

2)Dimension analysis of term "fvm::laplacian(mu, U)":
[1/m]*[1/m]*[kg/m/s]*[m/s]=[kg/m^2/s^2] ([1/m] is due to derivative with respect to space , "gradient" )

so the divergence term should also have the same unit, lets see:

3)Dimension analysis of term "fvm::div(rhoPhi, U)":
[1/m]*[kg/m^3]*[m^3/s]*[m/s]=[kg/s^2] ([1/m] is due to derivative with respect to space , "gradient" )


WHYYYYYYYYY????

now if u check the last term, you'll realize that the only way to make this term to have the same unit as other term, phi should be [m/s].

ANY COMMENT??
Mehdi3031 is offline   Reply With Quote

Old   April 21, 2017, 13:10
Default
  #2
Member
 
Mehdi Aminyavari
Join Date: Feb 2016
Location: Milan
Posts: 35
Rep Power: 10
Mehdi3031 is on a distinguished road
by the way, this is the case for any other solvers as well!! Not just interFoam...
Mehdi3031 is offline   Reply With Quote

Old   April 21, 2017, 14:16
Default
  #3
Senior Member
 
Zeppo's Avatar
 
Sergei
Join Date: Dec 2009
Posts: 261
Rep Power: 21
Zeppo will become famous soon enough
Don't forget that fvMatrix equations are not formulated in a derivative form but rather in an integral form.It means that every term in your matrix equation represents an integral not derivative. Yes, initially an equation is formulated in a derivative form and then it is integrated over the control volume. Applying Gauss theorem some terms (div, laplacian) are converted from volume integral to surface integral. To learn more about the discretization of equations in FVM see books like these:
  1. Moukalled, Mangani, Darwish - The Finite Volume Method in Computational Fluid Dynamics An Advanced Introduction with OpenFOAMŪ and Matlab (Fluid Mechanics and Its Applications) - 2015
  2. Anderson J. - Computational fluid dynamics. The basics with applications (MGH, 1995)(T)(563s)
  3. Versteeg H, Malalasekera W - An Introduction to Computational Fluid Dynamics. The Finite Volume Method - 2007
  4. Ferziger J.H., Peric M. Computational Methods for Fluid Dynamics - 2002

Source code (as always) is your friend. I marked the relevant lines in code with red color.

1) fvm::ddt(rho, U):
[kg/m^3]*[m/s]*[m^3]/[s] = [kg*m/s^2]

Code:
template<class Type>
tmp<fvMatrix<Type> >
EulerDdtScheme<Type>::fvmDdt
(
    const volScalarField& rho,
    const GeometricField<Type, fvPatchField, volMesh>& vf
)
{
    tmp<fvMatrix<Type> > tfvm
    (
        new fvMatrix<Type>
        (
            vf,
            rho.dimensions()*vf.dimensions()*dimVol/dimTime
        )
    );
    fvMatrix<Type>& fvm = tfvm();

    scalar rDeltaT = 1.0/mesh().time().deltaTValue();

    fvm.diag() = rDeltaT*rho.internalField()*mesh().Vsc();

    if (mesh().moving())
    {
        fvm.source() = rDeltaT
            *rho.oldTime().internalField()
            *vf.oldTime().internalField()*mesh().Vsc0();
    }
    else
    {
        fvm.source() = rDeltaT
            *rho.oldTime().internalField()
            *vf.oldTime().internalField()*mesh().Vsc();
    }

    return tfvm;
}
3) fvm::div(rhoPhi, U):
[kg/m^3]*[m^3/s]*[m/s]=[kg*m/s^2]

Code:
template<class Type>
tmp<fvMatrix<Type> >
gaussConvectionScheme<Type>::fvmDiv
(
    const surfaceScalarField& faceFlux,
    const GeometricField<Type, fvPatchField, volMesh>& vf
) const
{
    tmp<surfaceScalarField> tweights = tinterpScheme_().weights(vf);
    const surfaceScalarField& weights = tweights();

    tmp<fvMatrix<Type> > tfvm
    (
        new fvMatrix<Type>
        (
            vf,
            faceFlux.dimensions()*vf.dimensions()
        )
    );
    fvMatrix<Type>& fvm = tfvm();

    fvm.lower() = -weights.internalField()*faceFlux.internalField();
    fvm.upper() = fvm.lower() + faceFlux.internalField();
    fvm.negSumDiag();

    forAll(vf.boundaryField(), patchI)
    {
        const fvPatchField<Type>& psf = vf.boundaryField()[patchI];
        const fvsPatchScalarField& patchFlux = faceFlux.boundaryField()[patchI];
        const fvsPatchScalarField& pw = weights.boundaryField()[patchI];

        fvm.internalCoeffs()[patchI] = patchFlux*psf.valueInternalCoeffs(pw);
        fvm.boundaryCoeffs()[patchI] = -patchFlux*psf.valueBoundaryCoeffs(pw);
    }

    if (tinterpScheme_().corrected())
    {
        fvm += fvc::surfaceIntegrate(faceFlux*tinterpScheme_().correction(vf));
    }

    return tfvm;
}
Tobi, Mehdi3031 and SHUBHAM9595 like this.
Zeppo is offline   Reply With Quote

Old   April 22, 2017, 10:52
Default
  #4
Member
 
Mehdi Aminyavari
Join Date: Feb 2016
Location: Milan
Posts: 35
Rep Power: 10
Mehdi3031 is on a distinguished road
Bravooo, I see now, Thank you so much for your clear guide
Mehdi3031 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
Thermophysical Property Units johanz OpenFOAM Pre-Processing 2 December 16, 2018 11:08
createPatch Segmentation Fault (CORE DUMPED) sam.ho OpenFOAM Pre-Processing 2 April 21, 2014 03:01
Match Control and Symmetry Boundary Condtions in a quasi 2D calculation peterputer ANSYS Meshing & Geometry 0 May 15, 2012 09:53
gmsh2ToFoam sarajags_89 OpenFOAM 0 November 24, 2009 23:50
Units with use of the Ideal gas law? Chilli83 CFX 2 April 8, 2009 09:05


All times are GMT -4. The time now is 07:31.