Showing posts with label Gambit. Show all posts
Showing posts with label Gambit. Show all posts

Monday, 22 March 2010

Gambit example: model a 2D channel

"CFD example: laminar flow along a 2D channel" applied SALOME to model and mesh a 2D channel geometry for Code_Saturne to perform the simulation. However, someone likes to use Gambit, a product from ANSYS Fluent, and of course, the same example can also be made with the help of Gambit. Furthermore, similar to SALOME using Python for automatisation, Gambit has Journal file to automatise the manual procedure. The present post aims to translate the previous example into Gambit Journal file in order to show an illustration for beginners.

Basic instructions

1. comments. A comment line in Gambit Journal is headed with a forward slash, /.

/ This line is commented.

2. variables. One is able to define a variable with a name beginning with $. The variable represents a float point value.

$length = 0.1

3. arrays. Array names are also begun with $. In Gambit Journal, array is indexed by a 1 based number, which is quoted by a pair of square parenthesis, []. The index range of an array should be given at the definition declaration of the array itself.

declare $points[1 : 3]
$points[1] = 1.0
$points[2] = 0.0
$points[3] = 0.0

4. For the construction method of points, edges and faces, it is quite concise as well. Please refer to the simple example given in the next section.

The example

Once again, according to the philosophy of executing commands on terminals, Gambit Journal scripts are used to illustrate the example.

///////////////////////////////////////////////////////////////////////
/ Geometry construction and meshing creation for a typical
/ 2d channel flow between two infinite parallel plates.
/
/ Written by: salad
/ Manchester, UK
/ 06/12/2009
///////////////////////////////////////////////////////////////////////
/
/ L = 0.1 m, D = 0.005 m
/
/     C  --------- B
/       |         |
/ -->   |         |
/     O  --------- A
/
/ V_in = 0.05 m/s
/ t    = 50 degree C
///////////////////////////////////////////////////////////////////////

Define the variables and points, and then construct edges and faces accordingly.

/ Variable Definition
$length = 0.1
$height = 0.005

/ points
vertex create "O" coordinates 0
vertex create "A" coordinates $length
vertex create "B" coordinates $length $height
vertex create "C" coordinates 0 $height

/ edges
edge create "OA" straight "O" "A"
edge create "AB" straight "A" "B"
edge create "BC" straight "B" "C"
edge create "CO" straight "C" "O"

/ faces
face create "DUCT" wireframe "OA" "AB" "BC" "CO"

After the geometry is constructed, build the mesh, define the boundaries, and then create a zone corresponding to the 2D face "DUCT". Note that, differing from the SALOME example, here the 2D model is not extruded along the z axis, because originally, I wrote the script for Fluent to use at that moment.

/ mesh
edge mesh "CO" intervals 50
edge mesh "OA" intervals 250
face mesh "DUCT"

/ boundary
physics create "inlet" btype "VELOCITY_INLET" edge "CO"
physics create "bottom" btype "WALL" edge "OA"
physics create "top" btype "WALL" edge "BC"
physics create "outlet" btype "PRESSURE_OUTLET" edge "AB"

/ zones
physics create "duct_v" ctype "FLUID" face "DUCT"

Finally, export the mesh file for future use.

/ export
export uns "2d_duct_flow.msh"

Sunday, 6 December 2009

Gambit and Fluent on 64 bit Ubuntu

Installation

It seems that Gambit doesn't include a 64 bit version. However, 32 bit Gambit can be installed and used on a 64 bit Ubuntu (I tried on a Ubuntu 9.10 amd64). When trying to launch it, there will be an error saying the ARCH is not compatible. The solution is exporting a variable "FLUENT_ARCH" before the go.

:/$ export FLUENT_ARCH="lnx86"

Then Gambit will not complain about the uncompatible architecture.

Different from Gambit, Fluent does include a 64 bit version. But remember the variable FLUENT_ARCH has to be switched back before trying to run a 64 bit Fluent; (similarly, if the Fluent used is also a 32 bit version, the variable value "lnx86" has to be kept).

:/$ export FLUENT_ARCH="lnamd64"

To avoid the inconvenience, launch scripts can be written to simplify the procedure.

Besides, another potential problem which could be encountered when trying to launch Fluent within Ubuntu 9.10 is the lack of libstdc++.so.5 is complained. This library was actually provided via package libstdc++5, which is however abandoned after Ubuntu 9.10. However, it can still be found from a Debian source, by which I downloaded the package libstdc++5_3.3.6-18_amd64.deb and fixed the error.

Tutorial

A helpful tutorial on Gambit and Fluent can be found from here, although it is using Windows.

UDF (User Defined Functions) is important for extending the flexibility of Fluent. A programming guide of UDF can be found from this pdf file, and this is the complete UDF manual.

Example

An interesting wave tank example was found from a useful post. It is for a solution of the 2D laminar fluid flow in a tank with oscillating motion of a wall by using multi-phase models. More instructions on this example can be found from the Fluent website, from which related mesh files can also be downloaded.

A detailed set up procedure of the example was described in this pdf file as well.