Coder Social home page Coder Social logo

markstock / vic2d Goto Github PK

View Code? Open in Web Editor NEW
28.0 3.0 4.0 2.21 MB

Two-dimensional semi-Lagrangian vortex method for very low viscosity fluid simulation

License: GNU General Public License v3.0

Makefile 0.17% C 61.88% Fortran 33.93% D 3.64% CMake 0.39%
cfd simulator fluid-dynamics fluid-solver vorticity

vic2d's Introduction

vic2d

A command-line two-dimensional fluid simulator using a novel semi-Lagrangian advection technique

vorticies in a flow

Building vic2d

We are now using CMake to build the code, though you can still use the unmaintained unix Makefile.

git clone https://github.com/markstock/vic2d.git
cd vic2d
mkdir build
cd buil
cmake -DCMAKE_BUILD_TYPE=Release -DUSE_OMP=ON ..
make

Windows users can run the cross-compiled binary included in this distribution (vic2d.exe). Or, to build this Windows binary on a RedHat-flavor Linux machine, the following should work.

sudo dnf install mingw64-libpng-static.noarch mingw64-gcc-gfortran.x86_64 \
	mingw64-gcc-c++.x86_64 mingw64-gcc.x86_64 mingw64-zlib-static.noarch \
	mingw64-zlib.noarch mingw64-libpng.noarch mingw64-libgomp.x86_64
mkdir build_win
cd build_win
cmake -DCMAKE_SYSTEM_NAME=Windows \
	-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc \
	-DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ \
	-DCMAKE_Fortran_COMPILER=x86_64-w64-mingw32-gfortran \
	-DCMAKE_BUILD_TYPE=RelWithDebInfo -DUSE_OMP=ON ..
make

Running vic2d

To get a list of options, run

vic2d -h

Note that all diffusivities are coefficients, so for Reynolds number 10000, you should set momentum diffusivity with -vd 0.0001

Also note that the actual resolution of the output images will be one higher than that given on the command-line. So -x 1024 -y 1024 will generate square PNG images with 1025 pixels on a side. And any input images for such a run should have 1025 pixels on a side. I know, this is not intuitive. I created it this way because for the multigrid solver to function efficiently, you should try to run at resolutions that are small multiples of large factors of 2, so 2560 (5 * 128) is much better than 2544 (159 * 16), and those numbers are easier to remember.

For some sample command lines and output, including links to YouTube videos, check out the old vic2d page.

Theory

This code uses a vortex method solver, which means that pressure doesn't enter in the equations: the formulation is in velocity-vorticity coordinates. The velocity-vorticity inversion is accomplished with MUDPACK, a multigrid solution method. Interpolation to and from the grid is done with a 4th order kernel (M4'). Advection uses a semi-Lagrangian method, in which the vorticity at each grid point is drawn from a 4th order (Runge-Kutta) backward-looking projection. All of these methods contribute to the code's remarkable lack of numerical diffusion - you can run problems with Reynolds numbers in the hundreds of millions - though the drawback is that the simulation is not unconditionally stable.

The first implementation of a semi-Lagrangian vorticity-based solver is in Sawyer & Portnall (1963) A semi-Lagrangian method of solving the vorticity advection equation, Tellus, 15:4, 336-342, DOI: 10.3402/tellusa.v15i4.8862 link.

Notes

This program can create digital output very similar to that made by the traditional technique of ebru, or paper marbling. Here is an excellent web site about this art-making method.

Thanks

This code uses libpng and mudpack, a multigrid solver. All the rest of this ugly, ugly code is mine.

Citing vic2d

I don't get paid for writing or maintaining this, so if you find this tool useful or mention it in your writing, please please cite it by using the following BibTeX entry.

@Misc{vic2d2004,
  author =       {Mark J.~Stock},
  title =        {vic2d:  A command-line two-dimensional fluid simulator using a novel semi-Lagrangian advection technique},
  howpublished = {\url{https://github.com/markstock/vic2d}},
  year =         {2004}
}

vic2d's People

Contributors

jamiejquinn avatar markstock avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vic2d's Issues

Strips of cyan/magenta/yellow in frame 0 of gravity-driven flow example

First of all, thanks for making this free and open source (and with documentation)! I was able to compile and run it, but the output of the case I tried doesn't look like I'd expect.

For the example case "Gravity-driven flow in horizontal channel, Re=100k" from the http://markjstock.org/vic2d/ page, vic2d -x 2048 -y 1152 -px -grav -0.2 1.0 -vd 1e-5 -t -tf run27_1153x2049_bwspread4.png -td 2e-7 -c -cf run27_1153x2049.png -cd 1e-7 -cn 10 produces an odd looking artifact in frame 0:

out_000000

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.