CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Running, Solving & CFD (http://www.cfd-online.com/Forums/openfoam-solving/)
-   -   SonicFoamC (http://www.cfd-online.com/Forums/openfoam-solving/59676-sonicfoamc.html)

coops September 18, 2006 00:26

Hello all, Can someone plea
 
Hello all,

Can someone please tell why, in SonicFoam.C, the rhoEqn.H is included at the start of the runtime loop. Is this used to determine rho? What if (for the first time step) a rho field is already known? Then at the end of the PISO loop rho is determined from psi*p, this seems to be the rho field that is then written. For the next time step the continiuty equation, from the inclusion of rhoEqn.H, is then used again. Does this create another rho field that is then used in the PISO loop?

Hope this question makes sense.

Thanks in advance,

Shaun

hjasak September 18, 2006 03:19

This is the density predictor.
 
This is the density predictor. A new time-step has started and we can update the density field from the equation:

ddt(rho) + div(rho U) = 0

Fluxes (rho U) are known so there's no problem.

The above is a predictor, meaning it is there to make life easier for PISO. This is the only density consistent with the pressure and that's what we need for continuity.

Hope this helps - enjoy,

Hrv

coops September 26, 2006 19:04

Just a quick question for you
 
Just a quick question for you all. When people create their own solvers starting from one of the existing solvers how much of the code normally needs altering. Is it only the equations for the dependant variables that are altered or does most of the code need to be altered for new applications? Also, does modelling turbulence make a model run more stable?

Thanks

Shaun

gschaider September 27, 2006 04:45

Hi Shaun! "Normally needs a
 
Hi Shaun!

"Normally needs altering": The answer "between 1 and 100s line of code, depending on the application" won't make you happy, will it? It really depends: adding some new source-term is in the 1-line range from then on it gets more complicated, but if there is an existing solver that has most of your needed functionality, then you'll spend more time reading docu (and sources) than coding. For the first one. (it gets better after that)

coops May 28, 2007 09:52

Hello All, I have a questio
 
Hello All,

I have a question regarding the following lines in the sonicFoam.C file:

mu*magSqr(symm(fvc::grad(U)))

from the energy equation.

What is this line saying mathematically? I don't understand the magSqr function. I looked at Doxygen and found:

template<>
inline tmp<volscalarfield> magSqr<tensor>::operator()
(
const volTensorField& phi
) const
{
return Foam::tr(phi);
}

where tr is the trace. Can someone let help me understand what this means physically?

Thanks

Shaun

hartinger May 28, 2007 12:20

Hi Shaun, the energy equation
 
Hi Shaun,
the energy equation in sonicFoam is based on the internal energy
// rate of change
fvm::ddt(rho, e)
// convection
+ fvm::div(phi, e)
// conduction
- fvm::laplacian(mu, e)
==
// pressure work
- p*fvc::div(phi/fvc::interpolate(rho))
// viscous dissipation
+ mu*magSqr(symm(fvc::grad(U)))

viscous dissipation is the negative double dot product of stress tensor tau and grad(U):
-tau && grad(U);

in foam-speak tau:
// stress tensor
volTensorField tau =
- mu * (gradU + gradU.T())
+
(2.0/3.0 * mu * fvc::div(U)) * I;

with the definition of the double dot product:
(see "Transport Phenomena", 2nd edition, b. bird, p82)
-(tau && grad(U)) = mu/2.0 * sqr(gradU + gradU.T() - (2.0/3.0 * fvc::div(U)) * I)

neglecting the influence of 2.0/3.0 * fvc::div(U)) * I
and with symm(grad(U)) = 0.5 * ( grad(U) + grad(U).T())
we arrive at
mu*magSqr(symm(fvc::grad(U)))

where magSqr is the magnitude of a tensor and that result is squared.
definition of mag(tensor):
sqrt(0.5 * sum_i(sum_j(sqr(tensor_ij))))

you can puzzle that together yourself by using the programmers guide and "tranport phenomena" by bird

hope that helps
markus

coops May 29, 2007 03:11

Hi all, Thanks Markus that
 
Hi all,

Thanks Markus that did help

Shaun


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