CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   ??fvVectorMatrix+fvVectorField?? (http://www.cfd-online.com/Forums/openfoam-programming-development/113312-fvvectormatrix-fvvectorfield.html)

Svensson February 17, 2013 17:52

??fvVectorMatrix+fvVectorField??
 
Hello All!


I try to remake the icoFoam solver to an solver for stratified almost incompressible liquid and I've an following problem:

I added a new term to momentum equation, which is defined as: - rhoMin+f*(rhoMax-rhoMin)-rho0)/rho0*g
(where rhoMin, rhoMax, rho0 are a constants)

And if I write the momentum equation a intuitive way:

Quote:


fvVectorMatrix UEqn
(
fvm::ddt(U)
+ fvm::div(phi, U)
- fvm::laplacian(nu, U)
);
solve(UEqn == -fvc::grad(p)+ (rhoMin+f*(rhoMax-rhoMin)-rho0)/rho0*g );

dimensionedScalar ks=nu/1000;

fvScalarMatrix SEqn
(
fvm::ddt(f)
+ fvm::div(phi, f)
- fvm::laplacian(ks, f)
);
SEqn.solve();
Solver doesn't work well (velocity is induced, but scalar f isn't transfered)

But if we write the equation as follows

Quote:

fvVectorMatrix UEqn
(
fvm::ddt(U)
+ fvm::div(phi, U)
- fvm::laplacian(nu, U)

/////////////////////////////////////////////////////////////////////////////////
- rhoMin+f*(rhoMax-rhoMin)-rho0)/rho0*g
////////////////////////////////////////////////////////////////////////////////
);

solve(UEqn == -fvc::grad(p));/////////////////////////////////////////////////

dimensionedScalar ks=nu/1000;

fvScalarMatrix SEqn
(
fvm::ddt(f)
+ fvm::div(phi, f)
- fvm::laplacian(ks, f)
);
SEqn.solve();
Solver works normally!

And for me it's realy strange, because expression - fvm::laplacian(nu, U)- rhoMin+f*(rhoMax-rhoMin)-rho0)/rho0*g means that we add matrix coefficient to vector.

Bernhard February 18, 2013 02:53

All of the terms are vectors, i.e. the Laplacian of a vector is a vector and your custom term is also a vector, since you include g. Is this what your confusion is about?

ngj February 18, 2013 03:18

Hi Alexander,

I suppose that you question is about two "identical" modifications to the momentum equation, however, you get two different results on the flow field, correct?

The second implementation is the correct one to choose, simply because you are otherwise solving a pressure equation, which do not know about the additional source term. When you put the source inside fvVectorMatrix, it works correctly with respect to the pressure-velocity coupling.

Kind regards

Niels


All times are GMT -4. The time now is 23:10.