# Off topic - Some advice on solving Navier-Stokes with FiniteDifference

Matthew Knepley knepley at gmail.com
Thu Aug 13 06:30:42 CDT 2009

```On Thu, Aug 13, 2009 at 2:02 AM, Stephen Wornom <
stephen.wornom at sophia.inria.fr> wrote:

> Matthew Knepley wrote:
>
>> On Wed, Aug 12, 2009 at 10:39 AM, Stephen Wornom <
>> stephen.wornom at sophia.inria.fr <mailto:stephen.wornom at sophia.inria.fr>>
>> wrote:
>>
>>    Matthew Knepley wrote:
>>
>>        1) You should really handle this by creating the constant
>>        vector on the pressure
>>            space and using MatNullSpaceCreate()
>>
>>        2) You can also easily handle this by fixing the pressure at
>>        one point
>>
>>    At what indices or location does one fix the pressure? What value
>>    is it set. Usually pressure is part of the solution. It would seem
>>    to introduce an inconsistency.
>>    I would like to understand how to do it.
>>
>>
>> It does not matter where you fix it or to what value. The absolute value
>> of the pressure is not physically
>> relevant, only pressure differences (which is why only grad p appears).
>>
> Thanks for clarification on this point which is confusing to many of us. So
> why is it necessary to fix a value at a point since as you point out that
> only the grad p appears? If the pressure is not set in the numerical eqns,
> will you agree that the initial pressure sets the value for the numerical
> pressure at least in  time accurate solutions.
>

No! This is the fundamental mathematical difference between compressible and
incompressible flow (see article by Weinan E). In compressible flow,
pressure is a true dynamical
variable, and this is why we need an equation of state to close the system.
In incompressible flow, pressure is merely the Lagrange multiplier that
enforces the divergence-free
constraint. It is not a dynamical variable, and does not have initial
conditions.

>  Fixing the pressure at any point
>> to any value just sets the scale. There is no inconsistency. This is in
>> many many elementary fluid mechanics
>> books.
>>
> Pass along a reference for myself and students.

There is a nice review of incompressible flow by Stefan Turek which goes
over every solution method I have seen.

>
> Thanks again,
> Stephen
>
>>
>> To do this mechanically. Change one row in the operator div (from the div
>> u = 0 equation) to the identity.
>>
>>   Matt
>>
>>
>>    Stephen
>>
>>
>>         Matt
>>
>>
>>        On Wed, Aug 12, 2009 at 10:19 AM, William A. Perkins
>>        <william.perkins at pnl.gov <mailto:william.perkins at pnl.gov>
>>        <mailto:william.perkins at pnl.gov
>>        <mailto:william.perkins at pnl.gov>>> wrote:
>>
>>
>>           Stephen,
>>
>>           There are two ways that I know of to deal with pressure checker
>>           boarding: staggered grids or some form of Rhie-Chow
>>        interpolation.
>>           IMO, these are simple only for uniform, Cartesian grids.
>>         For grids
>>           that are curvilinear, unstructured, non-uniform, and/or
>>           non-orthogonal, things get real complicated. There may be other
>>           methods, but something is required.
>>
>>           Regarding boundary conditions, I would suggest this text book:
>>
>>              H. K. Versteeg and W. Malalasekera. An Introduction to
>>              Computational Fluid Dynamics, the Finite Volume Method. 2nd
>>              edition. Prentice-Hall. 2007
>>
>>           While this book uses the finite volume method, the
>>        explanation of
>>           boundary conditions and staggered grids is very good and
>>        relatively
>>           easy to interpret for finite difference.  I would also
>>        recommend
>>
>>              Joel H. Ferziger and Milovan Peric. Computational
>>        Methods for
>>              Fluid Dynamics. Springer-Verlag, 3rd edition, 2002.
>>
>>           This is a little more general with regard to method
>>        discussing finite
>>           difference and finite volume, but still settling on finite
>>        volume.
>>
>>           My \$0.02: I question the use of finite difference.  For
>>        Navier-Stokes,
>>           the use of finite volume is much more prevalent in
>>        commercial and
>>           research codes.  If your student follows Versteeg and
>>        Malalasekera a
>>           simple, working, staggered grid FV code could be built in a
>>        very short
>>           time.  If something more complicated is needed, it's probably
>>           explained in Ferziger and Peric.
>>
>>           Also My \$0.02: Unless the point of your student's work is to
>>           experience building her own code, why not download
>>        something like
>>           OpenFOAM (http://www.opencfd.co.uk/openfoam/) and just use
>>        it?  I
>>           expect the effort to learn something like OpenFOAM for a simple
>>           application will be much less than writing a new code.
>>
>>           Hope this helps.
>>
>>           Bill
>>
>>           >>>>> "Stephen" == Stephen Wornom
>>        <stephen.wornom at sophia.inria.fr
>>        <mailto:stephen.wornom at sophia.inria.fr>
>>           <mailto:stephen.wornom at sophia.inria.fr
>>        <mailto:stephen.wornom at sophia.inria.fr>>> writes:
>>
>>              Stephen> Shengyong wrote:
>>              >> Hi, Farshid
>>              >>
>>              >> Maybe she should use the staggered grid method which
>>        is very
>>           simple to
>>              >> implement.
>>              Stephen> Does it remain simple for curvilinear meshes?
>>              Stephen> Stephen
>>              >>
>>              >> On Tue, Aug 11, 2009 at 5:16 AM, Farshid Mossaiby
>>           <mossaiby at yahoo.com <mailto:mossaiby at yahoo.com>
>>        <mailto:mossaiby at yahoo.com <mailto:mossaiby at yahoo.com>>
>>              >> <mailto:mossaiby at yahoo.com
>>        <mailto:mossaiby at yahoo.com> <mailto:mossaiby at yahoo.com
>>        <mailto:mossaiby at yahoo.com>>>> wrote:
>>              >>
>>              >> Hi all,
>>              >>
>>              >> Sorry for this off-topic post.
>>              >>
>>              >> I am helping a master studnet which is working on solving
>>              >> Navier-Stokes equation with Finite Difference method.
>>        She is
>>              >> trying to eliminate spourious pressure modes from the
>>        solution.
>>              >> She needs to know some details that are not usually
>>        found in the
>>              >> papers but important when programming, e.g. boundary
>>           condition for
>>              >> pressure. If someone has expertise on this or know a
>>        *simple* FD
>>              >> code, I would be thankful to let me know.
>>              >>
>>              >> Best regards,
>>              >> Farshid Mossaiby
>>              >>
>>              >>
>>              >>
>>              >>
>>              >>
>>              >>
>>              >> --
>>              >> Pang Shengyong
>>              >> Solidification  Simulation Lab,
>>              >> State Key Lab of  Mould & Die Technology,
>>              >> Huazhong Univ. of Sci. & Tech. China
>>
>>
>>           --
>>           Bill Perkins
>>           Research Engineer
>>           Hydrology Group
>>
>>           Pacific Northwest National Laboratory
>>           902 Battelle Boulevard
>>           P.O. Box 999, MSIN K9-36
>>           Richland, WA  99352 USA
>>           Tel:  509-372-6131
>>           Fax: 509-372-6089
>>           william.perkins at pnl.gov <mailto:william.perkins at pnl.gov>
>>        <mailto:william.perkins at pnl.gov <mailto:william.perkins at pnl.gov>>
>>           www.pnl.gov <http://www.pnl.gov> <http://www.pnl.gov>
>>
>>
>>
>>
>>
>>        --        What most experimenters take for granted before they
>> begin
>>        their experiments is infinitely more interesting than any
>>        results to which their experiments lead.
>>        -- Norbert Wiener
>>
>>
>>
>>
>>
>> --
>> What most experimenters take for granted before they begin their
>> experiments is infinitely more interesting than any results to which their
>> -- Norbert Wiener
>>
>
>

--
What most experimenters take for granted before they begin their experiments
is infinitely more interesting than any results to which their experiments