Saturday, December 21, 2013

Github Code

I just wanted to share and link some code that I had uploaded to Github a while ago:

Mainly there are two things:
      -OpenFOAM Code.
      -Incompressible flow solver, and related utilities.

The incompressible flow solver is based on J.B. Perot's Exact Fractional Step Method. I wanted to use this instead of OpenFOAM's PISO for transient flows. Theoretically and practically in my opinion the Exact Fractional Step Method is superior; you can find more information from Perot directly with a simple Google search. From scratch, I coded it in C (with the awesome tool VALGRIND) and got to the point of being able to simulate a 2D box in a wind tunnel using an unstructured-multiblock grid. However, the additional features I required (3D, sliding mesh interface) proved too much in terms of time and effort (especially debugging!), so I reverted back to OpenFOAM.

The OpenFOAM modules are very useful and I use them heavily today. They include mesh motion functions for the AMI moving region and turbulence models. Take a look at them if you are interested.
     -Nested rotating interfaces: regions rotating and translating inside of another rotating region, i.e. cyclorotor simulations.
     -Ramped rotating motion: linear speedup of rotational velocity, to allow for Courant numbers not affected too much by high-velocity transients. This is supposed to allow for faster resolution of low-frequency starting phenomenon in transient simulations.
     -Proper and Official Spalart-Allmaras Turbulence Model: From a research publication written by Spalart himself in 2013. He acknowledges the confusion and variation of in the popular RANS model and establishes the correct and most up-to-date way to implement it. It differs quite a bit from the OpenFOAM standard S-A model.
     -Spalart-Allmaras with ROTATION/CURVATURE CORRECTION: Detailed in Zhang and Yang (2013), this model utilizes the Richardson number to sensitize the S-A to rotation and curvature (R/C), while bypassing the significant additional computation required by standard S-A R/C correction models. The more efficient model is shown in the paper to provide almost identical results to the traditional model in several test cases.
     -And others... take a look!

Friday, December 20, 2013

FEA Convergence: Order of Elements and Sharp Corners!

I found through experience that the caution against using first order elements in FEA is well-founded. Doing a convergence test on a simple rectangular plate fixed at both ends loaded with transverse and normal pressure forces showed that maximum displacement values converged with 10-100 times more nodes using first-order elements compared to using second-order elements. Wow.

However, I could not get maximum von Mises stress to converge due to the presence of sharp corners at the fixed ends, no matter the order of the elements. This apparently is a well known quirk of FEA for so-called 're-entrant corners'.

UPDATE: It turns out there was a dissonance between my intended physical model and the one I implemented in the *BOUNDARY card. All I had to do was add rotational constraints at the boundary. This was revealed to be the problem after I tried to fix the last two layer of nodes at each end.

Although the max stress is more tame now, the stress still does not converge completely. I notice that the max stress, after a certain amount of nodes, moves to the corner from the node adjacent to the corner. I consider the point where the max stress is still not on the corner to be the actual estimated max stress. This is also around the point the maximum displacement converges.

Thus I have found a satisfactory solution for my sharp corner convergence issue.

UPDATE 2: Perhaps a better convergence criterion would be strain energy. I have yet to test this.

Friday, December 13, 2013

Compiling CalculiX CrunchiX (CCX) from Source

I was having errors using CCX provided as the Linux executable on the CalculiX website, so I decided to compile it from source so I can finally get it working. I followed the compilation steps detailed on the CalculiX website, in addition to the following few changes.

I compiled on Ubuntu 12.04 LTS.

In order to compile CalculiX, you also need to install SPOOLES.2.2 and ARPACK.

Installing SPOOLES.2.2 is straightforward, just follow their directions on their website.

Installing ARPACK required a bit more modification. For me, I had to make the following changes in '':
     -Add '-lg2c' flag to LDFLAGS, LNFLAGS, and FFLAGS
     -Changed the fortran compiler to gfortran
     -Changed the MAKE directory to /usr/bin/make (original: /bin/make)
     -Changed the PLAT to INTEL, rather than SUN4
And the following change to 'UTIL/second.f':
     -Changed the two lines:
            REAL                      ETIME
            EXTERNAL           ETIME
            EXTERNAL    REAL        ETIME

Then, I was able to compile CCX as detailed on the website.

Another note about the deck input... I was trying to use the solver on the test cases as provided on the CalculiX website and took me a little while to figure out how to get the post-processed results (colorful stress and strain fields, etc.). I thought the results were written to *.frd file by *EL PRINT (which are already in the test input files), but the Datasets to be displayed in CGX actually have to be written by *EL FILE and *NODE FILE. So, to get the stress and displacement fields I had to type the following into the deck input file:


Where S denotes stress and U denotes displacement. For the rest of the keywords for other fields, you can check the CCX Manual.

Finite Element Analysis (FEA): CalculiX

Good morning,

I wanted to share a great piece of software for Finite Element Analysis, which usually refers to structural solvers. I am using it to verify whether certain structures subjected to certain loads safely operate within displacement and yield stress criterion. I am using it for a prototype of an invention of mine, which I am excited to finally be close to building. This prototype is a result of CFD and FEA analysis. Anyway, the website for CalculiX provides all of the software and helpful installation guides and tutorials.

I also wanted to share a troubleshooting tip for the CalculiX CrunchiX (CCX). Calculix has two components: the GUI and the solver. These are named CalculiX GraphiX (CGX) and CalculiX CrunchiX (CCX). I was getting the following error when trying to use the already-compiled provided CCX executable on the CalculiX website:

ccx: error while loading shared libraries: cannot open shared object file: No such file or directory

I did not have, but I did have I verified this by:


Using the directory location output from the above command, I linked the .so.3 to .so.2 by:

sudo   ln   -s   /usr/lib/x86_64-linux-gnu/   /usr/lib/

And then my executable no longer had the aforementioned error...

HOWEVER, I kept getting other errors. I could do one of two things... Try to install the package that had, or compile CalculiX from source. Since the package containing is deemed obsolete by the Ubuntu developers, I could not find and install it easily. So, I decided to compile CalculiX from source, and I successfully did so. I will create another post for details.