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

1D advection equation

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   September 11, 2012, 04:57
Default 1D advection equation
  #1
Member
 
Join Date: Mar 2012
Location: Munich, Germany
Posts: 67
Rep Power: 14
treima is on a distinguished road
Hello,

I´m trying to solve the onedimensional advection equation

\frac{\partial}{\partial t} u + \frac{\partial}{\partial x} u = 0

with OpenFOAM.

I took following code:
Code:
    solve
    (
        fvm::ddt(u) + coeff*fvc::div(u * unitVector_x)
    );
But now occours a problem, the solution shows some waves (you can see in the attached picutre). My boundary conditions are

left boundary - fixedValue, uniform 1
right boundary - zeroGradient
lower boundary - zeroGradient
upper boundary - zeroGradient

Normally there is should be one frontline, all values on the left of the frontline should be 1 and all values on the right 0.

Does anyone have any suggestions concerning my problem?

I had several ideas, why there occure this error. This equation is hyperbolic, another pde of this type is the euler-equation in rhoCentralFoam. Do I have to do some interpolation, too? Or are the numerical errors from OpenFOAM this huge? I´ve tried with a very small timestep (1e-06), too. No improvement occured


regards
treima
Attached Images
File Type: jpg advection.jpg (35.8 KB, 129 views)
treima is offline   Reply With Quote

Old   September 12, 2012, 08:40
Default
  #2
Cyp
Senior Member
 
Cyprien
Join Date: Feb 2010
Location: Stanford University
Posts: 299
Rep Power: 18
Cyp is on a distinguished road
Hi !

The equation you want to solve is hyperbolic and require a special discretization scheme like flux limiter. For exemple, if you want to solve the equation :

\frac{\partial S}{\partial t} + \nabla \textbf{.} \textbf{F}(S)

If phi is the flux (F(S)) defined otherwise, you can set a van Leer scheme defining

Code:
surfaceScalarField phiS = fvc::flux(phi/S,S, "div(phi,S)");

solve
(
fvm::ddt(S) + fvc::div(phiS)
);
and indicate the vanLeer scheme in fvScheme :
Code:
divSchemes
{
    div(phi,S)  Gauss vanLeer;
}
The solution is then much more stable. You can adapt easily this example to your situation.

Question about your equation : is it

\frac{\partial  \textbf{U}}{\partial t} + \textbf{C}\nabla \textbf{.} \textbf{U}

or

\frac{\partial  \textbf{U}}{\partial t} + \textbf{C}\nabla \textbf{.} U_{x}\textbf{e}_{x}

?

Regards,
Cyp
Cyp is offline   Reply With Quote

Old   September 12, 2012, 10:35
Default
  #3
Senior Member
 
Hisham's Avatar
 
Hisham Elsafti
Join Date: Apr 2011
Location: Braunschweig, Germany
Posts: 257
Blog Entries: 10
Rep Power: 17
Hisham is on a distinguished road
Hello,

On a side note: I think you should implement a generic solution (3D) and introduce the one-dimensional condition by defining all side patches (parallel to dimension of interest) as empty!

Regards
Hisham
Hisham is offline   Reply With Quote

Old   September 13, 2012, 04:37
Default
  #4
Member
 
Join Date: Mar 2012
Location: Munich, Germany
Posts: 67
Rep Power: 14
treima is on a distinguished road
Thanks for your advice, it helped me a lot to solve my problem!

The background for solving the onedimensional advection equation was to have a "simple" first step into the world of hypberbolic equations in OpenFOAM.
Of course it is more useful to implement a 3D solution of the problem, so it should be this equation:

\frac{\partial}{\partial t} u + c (\nabla \cdot u) = 0

My code looks like the following. u is a volScalarField.

Code:
volVectorField uVector (u * normalVector);

surfaceScalarField phiU ("phiU", fvc::interpolate(uVector) & mesh.Sf());

surfaceScalarField phiUflux = fvc::flux(phiU, U, "div(phiU,u)");

solve
(
    fvm::ddt(u) + c*fvc::div(phiUflux)
);
Perhaps the first line is not so nice, but you can define a normal vector which fits for the problem, in my case (1,0,0).

I´ve changed my boundary conditions, too. For the upper and the lower boundary I take "empty" and not "zeroGradient".

Dou you have any suggestions for improving my code?

As you can see in the screenshot below, this solution works for the problem shown in my first post. In the next days I´ll do some tests for other geometries and, if this works, I`ll take more complicated hyperbolic equations.


regards
treima
Attached Images
File Type: jpg advection.jpg (27.7 KB, 134 views)
treima is offline   Reply With Quote

Old   January 6, 2019, 10:20
Default
  #5
Senior Member
 
Reviewer #2
Join Date: Jul 2015
Location: Knoxville, TN
Posts: 141
Rep Power: 10
randolph is on a distinguished road
Hi,

I know this is an old post. But I think what this post discussed (one direction reconstruction) will not be sufficient for handling the hyperbolic system. It may work in this simple testing case. The multi-direction reconstruction should be implemented, such as MUSCL. And then either solve/approximate the local Riemann problem at the interface or use some sort of Riemann-free technique, such as Kurganov and Tadmor central scheme (what used by rhoCentralFoam). However, the entropy satisfied the weak solution is not guaranteed until some other fix is introduced.

Thanks,
Rdf
randolph 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
Calculation of the Governing Equations Mihail CFX 7 September 7, 2014 06:27
Model crashes while solving advection diffusion equation cooljd Main CFD Forum 3 August 23, 2012 10:40
Total variation diminishing scheme for advection or advection dispersion equation cooljd Main CFD Forum 7 July 27, 2012 08:32
error message cuteapathy CFX 14 March 20, 2012 06:45
Constant velocity of the material Sas CFX 15 July 13, 2010 08:56


All times are GMT -4. The time now is 15:25.