CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (http://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   solve continiuty for velocity (http://www.cfd-online.com/Forums/openfoam-programming-development/89964-solve-continiuty-velocity.html)

 linch June 27, 2011 13:04

solve continiuty for velocity

Hi Foamers,

in compressible solvers continuity is solved for density:
Code:

solve(fvm::ddt(rho) + fvc::div(phi));
with mass flux phi.

But how can I solve continuity for velocity?

Code:

    fvScalarMatrix UEqn     (         fvc::ddt(rho)       + fvm::div(rho,U)     );
And the compiler returned an error:
Quote:
 error: no matching function for call to ‘div(Foam::volScalarField&, Foam::volVectorField&)’
Then I tried: this one:
Code:

fvScalarMatrix UEqn {   fvc::ddt(rho) + fvm::div(fvc::interpolate(rho),U) }
but then I got a type mismatch error:
Quote:
 error: no match for ‘operator+’ in ‘Foam::fvc::ddt(const Foam::GeometricField&) [with Type = double]() + Foam::fvm::div(const Foam::tmp >&, Foam::GeometricField&) [with Type = Foam::Vector](((Foam::GeometricField, Foam::fvPatchField, Foam::volMesh>&)(& U)))’
Code:

    fvScalarMatrix UEqn     (         fvc::ddt(rho)       + fvm::div(rho,phi)     );
->
Quote:
 error: no matching function for call to ‘div(Foam::volScalarField&, Foam::surfaceScalarField&)’
Code:

fvScalarMatrix UEqn     (         fvc::ddt(rho)       + fvm::div(fvc::interpolate(rho),phi)     );
->
Quote:
 error: no matching function for call to ‘div(Foam::tmp >, Foam::surfaceScalarField&)’
Code:

fvVectorMatrix UEqn     (         fvc::ddt(rho)       + fvm::div(fvc::interpolate(rho),U)     );
->
Quote:
 error: no match for ‘operator+’ in ‘Foam::fvc::ddt(const Foam::GeometricField&) [with Type = double]() + Foam::fvm::div(const Foam::tmp >&, Foam::GeometricField&) [with Type = Foam::Vector](((Foam::GeometricField, Foam::fvPatchField, Foam::volMesh>&)(& U)))’
I'm looking forward for an expert-answer :)

Best,

 linch June 27, 2011 13:53

I'm a little bit confused:

thus I am looking for a volVectorField U, my system of equations should be fvVectorMatrix. But the continuity equation is a scalar one and the term div(rho,U) is a scalar field. So for each cell I have 3x unknowns but only 1x equation, right?

On the other hand, it should be possible to obtain continuity-based velocities in 1D. How can it be implemented, if I want to start with an 1D-case?

Furthermore, if I prescribe the temporal density change for each cell and provide velocities for every boundary cell but one, only one velocity field is possible, that satisfies these conditions, am I right? So how this velocity field can be obtained?

 FelixL June 27, 2011 14:37

Hello, linch,

you are right, the continuity equation is a scalar equation so it can only be solved for a single unknown scalar. This may be the density (which would be the easy way) or any velocity component. Still the continuity equation is one equation, so even if you know the temporal variation and the mass fluxes at the boundaries, there will be aribitrary velocity fields which satisfy the continuity equation.

Just imagine the following setup:

A rectangular, twodimensional domain. The continuity equation is

shall be known throughout the domain and at every boundary face it shall be and .

Out of the box there come two different velocity fields to my mind which satisfiy the continuity equation: either one, where , thus or another, where , thus .
The partial derivative of the other mass flux component is then equal to

So it's not possible to obtain a velocity field from the continuity equation without any additional information.

In 1D it should be possible, though, as long as the variation of density is known. Just treat the velocity component as a scalar.

Greetings,
Felix

 linch June 27, 2011 18:02

Thank you Felix,

to treat the velocity as scalar is a great idea!

 linch June 28, 2011 05:31

One more question Felix,

which boundary condition would you suggest for velocity for the open end, since no boundary condition is needed? In 1D, one velocity and known density changes are fully sufficient. Otherwise the system of equations is overdetermined. Is there any "no condition" boundary in OF?

 FelixL June 29, 2011 09:41

I was thinking about it for a bit and I don't think it would make sense doing this with OpenFOAM.
If you know and you want to solve for , the 1D continuity equation simply becomes an ODE. So unless you don't have any other PDEs coupled with the continuity equation, it would make much more sense solving this equation using an ODE solver and not with finite volume methods.

Greetings,
Felix.

 linch June 30, 2011 04:04

Thanks again Felix,

Well, I also have PDEs for enthalpy and components to solve. And the intention is to test, if diffusive heat and mass transfer as well as evaporation models are working in 1D, before adding the momentum equation.

That's the background.

 All times are GMT -4. The time now is 16:58.