Thursday, December 25, 2014

Here is a bit on Fortran basics. There will be a continuation of this with functions, subroutines and modules. If there are any mistakes, please do point out. Thanks.
Fortran_verybasics.pdf

Friday, December 12, 2014


CFD - Jargon

by A De Souza, NAFEMS




Monday, December 8, 2014


Hyperbolic, Convection dominated flows -- Lectures by Toro & Chi Wang Shu


This link shows the video of Toro talking about Hyperbolic equations and finite volume and DG frameworks. This lecture is very helpful to get a better understanding and kind of a crash course about  solving hyperbolic equations the numerical schemes that can used for specific problems their properties and so on... 




If you are interested in higher order methods and more of DG methods, follow the videos by Chi Wang Shu.





This channel on YouTube Link to Channel, will be very helpful to follow on lectures for convection dominated problems and higher order methods.

Have a good time breaking your head and finding the way around these very beautifully built numerical schemes!!!  Enjoy!!!  :) And we are open for discussions!!!



Wednesday, November 19, 2014



Intel Software Tools Webinar Series Archive


A collection of Intel webinars. Most of them related to MKL, MPI-3 and Xeon Phi.

Click here to open the page.



Thursday, October 30, 2014


far-fetched yet fun

Monday, October 27, 2014


Parallel debugging (MPI) - Part 1

Ahem, ahem, searching a needle in a hay stack is easy compared to parallel debugging in MPI, or as a matter parallel debugging. Having overstated the problem in our hands, there are few solutions or workarounds of how to get our hands in the dirty waters and have some fun.



There are two ways (as always) to get our work done, either use free tools or give an arm or leg to buy a fancy debugger.

1. Fancy debuggers,  Allinea DDTTotalViewIntel (Windows)Intel (Linux) to name some.
2. Free debuggers, gdb / valgrind to some extent, Eclipse PTP, etc
(Let us know for any others out there)

Read complete article by the chaps at OpenMPI.

1. gdb

gdb can be used as follows;

mpirun -np <NP> xterm -e gdb ./program 

This the launches xterm windows in which I can do

run <arg1> <arg2> ... <argN>

Should work the same with ddd (GUI for gdb)

2. valgrind (more at this link)

First of all, you have to make sure that Valgrind 3.2.0 or later is installed, and Open MPI is compiled with Memchecker enabled. Then simply run you application with Valgrind, e.g.:

mpirun -np 2 valgrind ./program



3. Eclipse PTP 

Official pageDownload page for Eclipse ParallelRelease Notes

More coming soon on this, looks interesting as they claim to have a parallel debugger !


Other Useful Links :

Some advanced tools, STAT.

A comparison on Wikipedia can be found here.


Sunday, October 26, 2014

Hello all,

I would like to bring in your attention about the power of python, for application in scientific computing. Whilst many people use Fortran,C/C++ for scientific python, a lot of tasks can be automated such as plotting graphs, creating contours calling several external libraries and coupling codes without the need of mixed language programming.

Here's a quick and basic introduction to scipy (Scientific python) which describes the scientific computing based in python:

Click here



Please do comment, suggest, correct and add to our posts

Friday, October 24, 2014


CFD Post-processing in Blender

To generate colourful pictures

Tools needed : paraview and Blender


Tuesday, October 7, 2014


PetSc Tutorial (C type) - Introduction


After a long struggle (3 days) on getting my hands-on PetSc library, I have compiled few helpful quickies to getting a legacy (or user) code to exploit PetSc functionality. This is not a complete tutorial and I have skipped parts which I do not use !

What is PetSc ?
A numerical algorithms framework with standard linear solvers (and more) for scalable (or super) computers. It is written in C, but can be called fom FORTRAN, C/C++, Python, Java and can run on virtually any OS. It is highly portable but has a steep learning curve (atleast till you get the hang of it).

  • It is built on MPI, BLAS, LAPACK.
  • And it works on objects like Vec (array) and Mat (Matrices).
  • Parallelism & options can be set at runtime. (One code for sequential & parallel)
  • Also, has capabilities to work with (MPI + ...) OpenMP, CUDA, etc
  • Has interfaces to a huge number of standard libraries.

One good tutorial (out of many) would be http://59a2.org/files/20130618-PRACE.pdf



Saturday, September 20, 2014


Parallelization of UDFs in ANSYS FLUENT
by


Most of the UDFs that we create in-house are programmed for serial mode of ANSYS FLUENT since it only involves basic coding in C program with required marcos and our UDF is ready. However, parallel mode of ANSYS FLUENT has tremendously reduced the simulation time and hence it becomes very important for us to modify our serial UDFs to support parallel processing as well. But, here comes the challenge for us (mechanical engineers) to write down a parallel processing code in C program.

See the full-post here from learnCAx.com SOURCE

Wednesday, September 17, 2014


Some OpenSource CFD and Mesh codes

This is part 2 of the post Open Sourced CFD and Mesh codes
  1. Xfoil: 2D viscous/inviscid interactive code. http://web.mit.edu/drela/Public/web/xfoil/ . More of a low computational cost design code.
  2. AVL: 3D vortex lattice code: http://web.mit.edu/drela/Public/web/avl/ . Another code with low computational overhead.
  3. OpenFoam: 3D, very versatile code. Active user community. Various pre-build packages as well. http://www.openfoam.com/
  4. XLR5: http://xflr5.sourceforge.net/xflr5.htm wings/aerofoil code. Again aimed more at the low computational effort/disgn scenario.
  5. FreeCFD: open source CFD project. . 3D implicit density based solver. Site also has a forum. (Site link expired, will update newer link as sonn as we find it)
  6. Gerris : http://gfs.sourceforge.net/wiki/index.php/Main_Page . supported by National Institute of Water and Atmospheric research, lots of multi phase stuff, immersed boundary conditions etc. Good users guide/example cases.
  7. SU stanford univeristy OpenSource CFD code http://su2.stanford.edu/
  8. Code Saturn: http://code-saturne.blogspot.co.uk/ finite volume CFD
  9. Incompact3D by Laizet  Incompact3d is based on a Cartesian mesh. The use of such a simplified mesh offers the opportunity to implement high-order compact schemes in the code for the spatial discretisation whilst an Immersed Boundary Method (IBM) allows the implementation of any solid wall/bluff body geometry inside the computational domain. The main originality of the code is that the Poisson equation (to ensure the incompressibility) is fully solved in the spectral space via the modified wave number formalism, no matter what the boundary conditions are (periodic, free-slip, no-slip, inflow/outflow, etc.). Note finally that the pressure mesh is staggered from the velocity one by half a mesh to avoid spurious pressure oscillations that can be introduced by the IBM. (Thanks Sulfi for pointing it out)
  10. OpenFOAM on Windows by Nishit Joseph, Cross compiled binaries of OpenFOAM-2.1.x using OpenMPI. More on his sourceforge page. (Thanks Santosh for pointing it out)
  11. A nice list of mesh generators LINK

Mesh generators:

  1. Qhull: http://www.qhull.org/
  2. Triangle: http://www.cs.cmu.edu/~quake/triangle.html
  3. Gmsh: http://geuz.org/gmsh/ (uses tetgen and netgen algorithms)
  4. Tetgen: http://tetgen.berlios.de/
  5. netgen: http://www.hpfem.jku.at/netgen/
  6. sumo: http://www.larosterna.com/sumo.html - highly recommend this! comes with many geometries already loaded of full aircraft. Volume mesh generation via tetgen.
  7. http://engits.eu/en/engrid: volume grid generation with CFD in mind.
Thanks to Laurence Griffiths University of Bristol, for the list !



Saturday, September 6, 2014


Scientific development in Windows : Setting Up

Yes ! reluctantly I have been fiddling with Windows for scientific development. I am presently involved in a project, in collaboration with some big guys (in terms of coding). Windows happens to used by one of the developers, although the parallel jobs are submitted on Scientific Linux clusters. So, I thought why not try it out. phew.

There are two ways to go about this, one the paid way and two the free way ! Paid ways are many which include the use of Microsoft Visual Studio with Intel Visual FORTRAN and many others out there.

However, there are other ways to go about this in the open-source (free) community. I have used only one of them, so feel free to throw-in your ideas/experience as well. As, I have been used to the command-line and makefile in Linux, I am comfortable in working with some transition between Linux & Windows.

For the compilers, I am using Cygwin (takes a lot of time & space, nearly 20gigs to install - I left it for a full night to install, also make sure to include the compilers, kde-openbox, parallel compilers and any libraries / applications you might need like gnuplot, vim, etc) but there are other alternatives as well. It is to be noted that Cygwin has MPI support as well, and I am using eclipse as an editor and I don't want to be bothered at the moment to setup eclipse properly and use Cygwin compilers directly.

Well, that's it for some start !

Monday, March 10, 2014

Hello,

This post describes the methodology of setting up and running a LES simulation  in ANSYS-FLUENT, a very brief description about the meshing and solution procedure is presented here. Compared to RANS, LES simulations require finer grids since it aims in resolving the large scales of turbulent motion thus providing a better insight of the flow physics however LES is a transient simulation and the computation cost of LES much higher than that of RANS, for a detailed review please see :

1.) Piomelli, A primer on DNS/LES.

2.) Grid-point requirements for large eddy simulation: Chapman's estimates revisited. H. Choi and P. Moin. Physics of Fluids, 24(1), 2012

(also see the original Chapman's paper in the late '70s ~78-79)

3.) Turbulent flows, Pope (2006).

I am not describing the theory of LES here as there are several good books available and I would recommend reading, chapters 1-7 in Pope, and chapter 13 on LES. Chapters 6 and 7 in Pope's book explains about turbulence in free shear turbulent flows (jets, self-similarity) and chapter 7 describes about stable attached turbulent flows (pipes, channels). I would highly recommend reading these as they explain the significance of certain parameters like y+, u_tau, law of the wall, the regimes in a turbulent velocity profile and so on.

The present tutorial is based on pipe flow at Re = 24,580 (experimental data of Toonder & Nieuwstadt, and DNS data of X. Wu and Moin is available) .

1.) Create a pipe geometry in ICEM-CFD,




The dimensions of the pipe are : 2.5m in length, 0.2m in diameter.

2.) Create a 3D bounding block :

 associate the edges around the circle to the circle at both the faces.

3.) split the block in the form of an o-grid : for this select the the single block and the faces on the circles


4.) For better mesh quality, set an offset of 0.65

5.) Input the number of nodes and ratios (the near wall spacing, y+ here is 0.25 ) and the wall paralle spacing of 25.0 (x+ ), this is achieved by inputting the correct number of nodes in each of the directions.


I had input 65 nodes in the wall normal spacing, and 55 nodes in the z-direction.

6.) The boundary conditions play an important role in LES simulations, in the present study periodic boundary conditions with a pressure-gradient is used, the pressure gradient is calculated based on the u_friction velocity (u_tau), in case of pipe flow :

dp/dx = (-4u_fric^2/rho) , for channel :  dp/dx = (-2u_fric^2/rho)

u_fric = sqrt(tau_w/rho)

(Refer pope for the derivations and explanations)

 Periodicity can be defined in icem or in fluent, in the present case periodicity is defined in icem :
 go to the mesh button in mesh, click on set up periodicity :


set translational periodicity, and in this case the periodicity is in the x-direction based on the length of the pipe, therefore : 2.5 0.0 0.0

select the vertices on the periodic faces (circles)


Once selected, you can view the periodic faces by selecting faces : view periodic faces :






Now you can create the parts : inlet, wall etc. and save the mesh and translate it to fluent

Alternatively you can set up periodicity in fluent, but sometimes you may end up with errors such as ''segmentation-violation'' especially in the case of large meshes.


7.) Setting up LES in fluent :

I would suggest running a RANS simulation in a similar coarser mesh with pbc in fluent and then interpolating the RANS solution in the present case.  After interpolation, you can add fluctuating components to the RANS velocity profile by :

/solve/init/init-instantaneous-vel

Once done, change the viscous model as Large Eddy Simulation, start with the standard Smagorinsky-Lily model. The default values of Cs (0.1) is  good enough for simple attached flows, for flows involving large separations and instabilities the dynamic subgrid model can be used or the value of Cs can be set from available  literature.

Set the periodic boundary condition of pressure-gradient in the boundary conditions, mass-flow could also be used but the pressure-gradient seems to be more stable and provide better convergence.

For the pressure-velocity coupling, SIMPLEC algorithm is used and the bounded central differencing scheme is used for the velocity and in case of the time advancement the 2nd order backward euler implicit is used.  (bounded 2nd order implicit)

You can define a small iso-curve near the wall for monitoring statistical convergence of velcocity (defined under surface monitor)

Define the timestep of the simulation such that your CFL number is less than 1.0

CFL = U*delta_x/delta_T where delta_x is your wall parallel spacing, I would recommend a CFL of 0.50 and the number of inner iterations around 15-20.

You can run the simulation now!


Some points to be noted :

Make sure that in each time step your residuals drop down by the order of 2. You may achieve a statistically stationary state in 2-3 flow through times (FTT) , 1 FTT is defined as the time taken by a particle to cross the entire domain. Do not collect any unsteady data statistics until statistical stationary state has been reached. Once you have reached statistical convergence, you can switch on the sampling interval and unsteady data collection .. meanwhile you could monitor your CFL number, plot q-criterion for the evolution of turbulence.



You can check for the convergence of your solution by comparing the wall shear stress of the CFD with the momentum-balance equation, which reads as :

-dp/dx (pi*r^2*L)=tau_wall(2*pi*r*L)

or alternatively you could check for the skin friction coefficient (Cf) and friction factor (f) (f=4Cf), and compare with correlations..



Questions welcome...

Thanks and Regards,
Deepak

Tuesday, March 4, 2014





Please watch the entire module 7 for Unstructured grid generation methods.




Collection of Computation Fluid Dynamics (CFD) source codes, freely downloadable and intended to be useful for educational purposes.

  • Hyperbolic and parabolic model equations
    Schemes for model equations
    C codes that implement conservative difference schemes, explicit and implicit, for hyperbolic and parabolic model equations in 1D - modeq.tar.gz

    FCT-schemes
    Sample C/C++ codes that implement some FCT schemes for hyperbolic model equations in 1D - fct.tar.gz

  • One-dimensional conservation laws of gas dynamics

    First order Godunov schemes
    Piecewise-constant approximation to the solution within computational cells, single step advancing in time. Several source codes in ANSI C with different solvers of the Riemann problem are available:
    •  exact procedure of Godunov - godunov.tar.gz
    • approximate flux-difference splitting (FDS) of Roe - roe_fds.tar.gz
    • approximate linearized characteristic-based Riemann solver (LCS): lcs.tar.gz - (Fortran 77 and C sources available). Description of LCS solver downloadable as gzipped PS file - solver.ps.gz
    Higher order Godunov-type schemes
    Piecewise-parabolic spatial reconstruction, minmod() limiter function, LCS solver, three- and two- step Runge-Kutta in time. Sources in C are available for:
    • Two- and three-step schemes that use non-iterative (LCS), iterative (LCSS), and weakly linearized (WLCS) versions of characteristic-based Riemann solver and a program for exact solution of Riemann problem: lcs3.tar.gz
    • Two-step scheme for variable composition mixture of gases: lcs2mix.tar.gz
     A set of different 1D schemes; demo package
    Four different schemes solving "subsonic" and "supersonic" Riemann problems, with numerical and exact solutions
    compared - sch1d.tar.gz. This package contains:
        1) a non-conservative characteristic-based scheme,
        2) Godunov scheme (as in godunov.tar.gz),
        3) three step higher-order scheme (as in lcs3.tar.gz),
        4) one-step higher-order scheme.

  • Two-dimensional conservation laws of gas dynamics

    Higher order Godunov-type "generic" 2D scheme
    Rectangular mesh, piecewise-parabolic spatial reconstruction, minmod() limiter function, characteristic-based solver LCS, three step Runge-Kutta in time. C source - lcs2d3.tar.gz

    Higher order scheme for 2D equations in axisymmetrical form
    Higher order Godunov-type scheme applied to aeroacoustical problem: a finite-amplitude wave issuing from 1D duct into the 2D atmosphere. Standard C source code - noise.tar.gz

  • Large Eddy Simulation

    Cartesian grid compressible LES
    Piecewise-parabolic distribution within computational cells, two-step time integration, 3D, unsteady filtered Navier-Stokes equations.
    Description of LES numerical scheme downloadable as gzipped PS file - les.ps.gz.
    Test examples in C are available for:
    High performance LES
    Parallel implementation of LES of turbulent flows (uses MPI):

  • Combustion
    Propagation of 1D pre-mixed laminar (normal) flame
    Numerical scheme for 1D normal premixed combustion based on above listed high-resolution Godunov scheme lcs2mix. C source code - normal.tar.gz

  • Flow Visualization
    WinField 1.07
    Visualization of scalar flowfield given by rectangular table. Win32 binary and C source - winfield.zip


    source : http://www.reocities.com/MotorCity/pit/9939/freecfd.htm

Sunday, March 2, 2014


Essential Startup kit for Parallel Development

Got a new laptop with some serious horse-power, and here are the tolls that I am setting up for some CFD (some scientific computing) development stuff. Apart from some compilers, libraries, dependencies, etc I adding some post-processors and CFD related tools to make our lives easier. So here's the list (I am on Ubuntu by the way). Feel free to comment on adding more stuff.

The keywords for Ubuntu's sudo apt-get install * are presented in brackets, wherever applicable.

Compilers
gcc / g++ (gcc / g++)
gfortran (gfortran)
openmpi (openmpi)
opencl / cuda
octave

IDE
kate (kate)
vim (vim)
ECLIPSE Parallel (get from eclipse website)

Version-Control
Github (git-core)

Pre-Processors
GMSH ( link )

Debuggers
valgrind (valgrind)
gprof (comes with gcc)

Post-Processors
ParaView (paraview)
ViSiT
MayaVi
gnuplot
engauge-digitizer

Documentation
Doxygen (doxygen)
LaTeX (texlive-full)

Subscribe to RSS Feed Follow me on Twitter!