Nabla Logo programmer
  Advanced Search
  
  Send us a comment/query
 
  Back to main web site
 
  OpenFOAM guides
  - User guide
  - Programmer’s guide
 
  Index
 
  Changes from OpenFOAM 2.2 to 2.3
 
  Trademarks in the guides
  ©2000-2007 Nabla Ltd.

2.5 Temporal discretisation

Although we have described the discretisation of temporal derivatives in Sections  2.4.3 and  2.4.4, we need to consider how to treat the spatial derivatives in a transient problem. If we denote all the spatial terms as Af  \special {t4ht= where A \special {t4ht= is any spatial operator, e.g. Laplacian, then we can express a transient PDE in integral form as

 integral  t+Dt[    integral            integral         ]
        @--  rf  dV +    Af  dV    dt = 0
 t      @t  V           V
\special {t4ht=
(2.30)

Using the Euler implicit method of Equation 2.21, the first term can be expressed as

 integral  t+Dt [@   integral        ]        integral  t+Dt(rP fP V)n - (rPfP V )o
        ---   rf dV    dt =       ----------------------- dt
  t     @t  V                t              Dt
                            (rPfP-V-)n---(rP-fP-V)o-
                         =            Dt          Dt
\special {t4ht=
(2.31)

The second term can be expressed as

 integral  t+Dt [ integral        ]       integral  t+Dt
           Af  dV   dt =        A*f dt
 t       V                t
\special {t4ht=
(2.32)

where A* \special {t4ht= represents the spatial discretisation of A \special {t4ht=. The time integral can be discretised in three ways:

Euler implicit
uses implicit discretisation of the spatial terms, thereby taking current values   n
f  \special {t4ht=.
 integral  t+Dt
      A*f  dt = A*fnDt
 t
      \special {t4ht=
(2.33)

It is first order accurate in time, guarantees boundedness and is unconditionally stable.

Explicit
uses explicit discretisation of the spatial terms, thereby taking old values  o
f  \special {t4ht=.
 integral  t+Dt
      A*f  dt = A*foDt
 t
      \special {t4ht=
(2.34)

It is first order accurate in time and is unstable if the Courant number Co  \special {t4ht= is greater than 1. The Courant number is defined as

       U  •d
Co  = ---f---
      |d|2Dt
      \special {t4ht=
(2.35)

where Uf  \special {t4ht= is a characteristic velocity, e.g. velocity of a wave front, velocity of flow.

Crank Nicholson
uses the trapezoid rule to discretise the spatial terms, thereby taking a mean of current values  n
f  \special {t4ht= and old values  o
f  \special {t4ht=.
 integral  t+Dt            (fn  + fo )
       A*f dt = A*   --------  Dt
 t                      2
      \special {t4ht=
(2.36)

It is second order accurate in time, is unconditionally stable but does not guarantee boundedness.

2.5.1 Treatment of temporal discretisation in OpenFOAM

At present the treatment of the temporal discretisation is controlled by the implementation of the spatial derivatives in the PDE we wish to solve. For example, let us say we wish to solve a transient diffusion equation

@f- = k\ ~/ 2f
 @t
\special {t4ht=
(2.37)

An Euler implicit implementation of this would read


    solve(fvm::ddt(phi) == kappa*fvm::laplacian(phi))
where we use the fvm class to discretise the Laplacian term implicitly. An explicit implementation would read


    solve(fvm::ddt(phi) == kappa*fvc::laplacian(phi))
where we now use the fvc class to discretise the Laplacian term explicitly. The Crank Nicholson scheme can be implemented by the mean of implicit and explicit terms:


    solve
        (
        fvm::ddt(phi)
        ==
        kappa*0.5*(fvm::laplacian(phi) + fvc::laplacian(phi))
        )