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/)
-   -   Nonlinear source term like u*(1-u)? (https://www.cfd-online.com/Forums/openfoam-solving/105140-nonlinear-source-term-like-u-1-u.html)

Taozi July 23, 2012 23:24

Nonlinear source term like u*(1-u)?
 
Hello, everyone!

I have a quick question, how to specify nonlinear terms in the solver?

For example, I want to solve the KPP equation which reads
U_t = D*(U_{xx} + U_{yy}) + gamma * U * (1 - U)
(an example in matlab is: http://www.mathworks.com/matlabcentr...tent/pattern.m)

In what way should I express the nonlinear term u*(1-u) in the solver, I tried to do this based on the laplacianFoam.C in several ways, but none seemed to work. I was once told openFOAM can only handle linear forms...

Any help would be really appreciated!

ngj July 24, 2012 03:52

Hi Tom,

It is true that OpenFoam solves the linearised equation, so you have to linearise the equation, e.g. u^(n+1) * (1 - u^n), which makes it possible to formulate a linear set of equations in u^(n+1).

Specifically, merely add the
[CODE]
fvm::Sp( gamma * U, U) // Only the source term!
[CODE]
in your equation, which then automatically makes it into the linearised form. My feel is that you will gain a lot more stability compared to the Matlab script, which seems to be explicit.

BTW: Thanks for the link, it really do create some beautiful patterns and sometimes transient and psychedelic

Kind regards,

Niels

Taozi July 25, 2012 22:09

Quote:

Originally Posted by ngj (Post 373161)
Hi Tom,

It is true that OpenFoam solves the linearised equation, so you have to linearise the equation, e.g. u^(n+1) * (1 - u^n), which makes it possible to formulate a linear set of equations in u^(n+1).

Specifically, merely add the
[CODE]
fvm::Sp( gamma * U, U) // Only the source term!
[CODE]
in your equation, which then automatically makes it into the linearised form. My feel is that you will gain a lot more stability compared to the Matlab script, which seems to be explicit.

BTW: Thanks for the link, it really do create some beautiful patterns and sometimes transient and psychedelic

Kind regards,

Niels

Hi Niels, thank you for your reply. I am a little confused about the handling of the explicit/implicit terms in openfoam. I tried the following line:
solve(fvm::ddt(T) - fvm::laplacian(DT, T) - fvm::Sp(gamma * (1-T), T));
the result doesn't appear right compared with the matlab script in the link: the T become T = 1 throughout the domain (except the boundary which is actually irrelevant) in my result. I don't think openfoam will automatically consider gamma*(1-T) or T as from the previous time step. Were you suggesting I use both T^(n+1) and T^(n) in the equation, then how should I write it? I know there is something like T.oldTime(), should that be used?

ngj July 26, 2012 03:48

Hi

First of all, if you consider carefully the matlab script, then you will find that the boundary values are neglected in the computation of gradients, etc, which you cannot avoid in OpenFoam besides using either zeroGradient (but still considered) or using periodic domains (cyclic).

With respect to the equation you are solving the form:
Code:

fvm::ddt(T) - fvm::laplacian(DT, T) - fvm::Sp(gamma * (1 - T), T)
It treats the first two terms fully implicitly in a manner depending on your temporal discretisation scheme, and the source term reads
Code:

gamma^n * (1 - T^n) * T^(n+1)
so it is a linearised form of your non-linear source term. The discretisation of the source term will also depend on the temporal scheme.

I hope this clarified things a bit.

/ Niels


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