CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (https://www.cfd-online.com/Forums/openfoam-solving/)
-   -   Momentum source containing div(tensor) using fvOptions (https://www.cfd-online.com/Forums/openfoam-solving/244316-momentum-source-containing-div-tensor-using-fvoptions.html)

sreehahaha August 2, 2022 08:46

Momentum source containing div(tensor) using fvOptions
 
Hi Foamers,

I'm fairly new to OpenFOAM and I'm using v6. In my momentum equations, I have a source term that contains a divergence of a random symmetric stress tensor. Is it possible to define this term using fvOptions? If yes, please let me know how.

Many thanks in advance!
sreehahaha

agustinvo August 2, 2022 10:50

How is that tensor defined? If it is already defined in your solver you could add the term directly there.
Otherwise you could try with a codeStream fvOption

sreehahaha August 2, 2022 11:25

Thanks for the reply agustinvo.

I already tried adding this term directly into the UEqn definition within a new solver (myIcoFoam). However, it looks like it has some issues. That is why I thought to use fvOptions instead. But, I'm confused how to define div(tensor) in fvOptions. If possible, could you please elaborate your suggestion on using codeStream? Many thanks!

agustinvo August 3, 2022 19:21

What are these issues? Can you show your equations?

I am not an expert in codeStream, however I think it could be easy to add it in your solver if the tensor is already created there.

sreehahaha August 4, 2022 07:37

Hi agustinvo,

Sorry for the slight delay in replying. So my UEqn goes like:

Code:

        fvVectorMatrix UEqn
        (
            fvm::ddt(U)
          + fvm::div(phi, U)
          - fvm::laplacian(nu, U)
          ==
              fvc::div(stochTau)/rho
        );

The stochastic stress tensor is defined already in a separate header file as:

Code:

      forAll(stochTau,i)
{
        Tcell=T.internalField()[i]; // local temperature
        rhocell=rho.internalField()[i]; local density
        visc=nu.value()*rhocell; // viscosity=kinematic_viscosity*density
        dv=mesh.V()[i]; //cell volume
        dt=runTime.deltaTValue();

        dummy=vector(rnumxx.scalarNormal(),rnumyy.scalarNormal(),rnumzz.scalarNormal()); //random vector; uncorrleated elements
        diag=dummy&chol; //correlated elements with sum=0. [chol is predefined and this step is correct]
        stochTau[i]=Foam::sqrt(2*visc*kb*Tcell/dv/dt)*symmTensor(diag.x(),rnumxy.scalarNormal(),rnumxz.scalarNormal(),diag.y(),rnumyz.scalarNormal(),diag.z());

}

Looking at its definition, everything seems fine. The issue that I face is that when I look at the variance of the resulting velocity normalised with 3*kb*T/rho/dV, I get 0.25 instead of 1. The normalising factor comes from equipartition theorem. What I noted is that if I multiply the RHS with 2, I get the expected result of 1. I don't understand where I'm missing this factor. Any help is much appreciated.

agustinvo August 4, 2022 10:20

I would need to see the reference model to check what can be missing. Do you have a test case? Which OpenFOAM version are you using?


All times are GMT -4. The time now is 02:56.