Showing posts with label Vulcan-CFD. Show all posts
Showing posts with label Vulcan-CFD. Show all posts

Wednesday, November 5, 2014

Pointwise - Converting 2D Plot3d grid files to 2D Plot2d

Introduction
I was trying to use Pointwise to generate Plot2d grids, and I discovered that Pointwise appears to be only capable of generating Plot3d grids.  I couldn't find a solution inside of Pointwise so I wrote the Matlab script below to address it.

A quick explanation on the difference between 2D-Plot3d and 2D-Plot2D grids.  When generating a 2D grid in Pointwise, the program outputs a z-coordinate for each point (which is always 0).  Here's an example of the difference between the 2D-Plot3d and 2D-Plot2d grid file:

2D-Plot3d
2
30 30 1
59 30 1
...xdata(block 1)...
...ydata(block 1)...
...zdata(block 1) = 0...
...xdata(block 2)...
...ydata(block 2)...
...zdata(block 2) = 0...

2D-Plot2d
2
30 30
59 30
...xdata(block 1)...
...ydata(block 1)...
...xdata(block 2)...
...ydata(block 2)...

Why does this matter?  

First, Vulcan doesn't care.  When importing the grid file into vulcanig, the user can specify if it is a Plot3D or Plot2D file, and Vulcan will take care of it.

However, TecPlot DOES care.  Because the output of vulcan is in a true 2D format, TecPlot cannot plot the solution against the 2D-Plot3D grid.  It needs the 2D-Plot2D grid.  


The code

The following code is written in MATLAB

clc; close all; clear all;

%% input
inputFile=['C:\Users\John\Documents\PointwiseExample','\','expansionChamber.x'];
outputFile='grid.x';

%% read in 2D(x=m,y=n,z=1) data
A0 = importdata(inputFile);  %raw data
A=A0;  %raw data to be trucated

% number of blocks in data
numBlocks=A(1);

% grab matrix sizes from the header
for i = 1:numBlocks
    m(i)=A(2+(i-1)*3);
    n(i)=A(3+(i-1)*3);
end

% throw away header info from A
A=A(2+numBlocks*3:end);

% grab x and y data from A and ignore z
for i = 1:numBlocks
    N=m(i)*n(i);
    x{i}=A(1:N);
    A=A(N+1:end);
    y{i}=A(1:N);
    A=A(N+1:end);
    A=A(N+1:end); %delete z
end


%% plot data
figure; hold on
colors=['brkg'];
for i = 1:numBlocks
    plot(x{i},y{i},[colors(i),'+'])
end


%% write 2D(x=m,y=n) data (with the single z value stripped out)
fileID = fopen(outputFile,'w');

% write number of blocks
fprintf(fileID,[num2str(numBlocks) '\r\n']);

% write matrix sizes for each block
for i = 1:numBlocks
    fprintf(fileID,[num2str(m(i)), '\t', num2str(n(i)), '\r\n']);
end

% write x and y data for each block
for i = 1:numBlocks
    p=x{i};
    for k=1:2
        if k==1
            p=x{i};
        else
            p=y{i};
        end
        
        while(length(p)>=4)
    %         fprintf(fileID,[num2str(p(1)), '\t', num2str(p(2)), '\t', num2str(p(3)), '\t',num2str(p(4)), '\r\n']);
            fprintf(fileID,'%1.15e\t%1.15e\t%1.15e\t%1.15e\r\n',p(1),p(2),p(3),p(4));
            p=p(5:end);
        end
        if p~=0
            for j=1:length(p)
                fprintf(fileID,'%1.15e\t', p(j));
            end
            fprintf(fileID,'\r\n');
        end
    
    end
end






Wednesday, October 8, 2014

VULCAN-CFD tutorial 1 - Installation

Intro

The purpose of this tutorial is to document the steps for setting up VULCAN-CFD on Ubuntu or Ubuntu inside of Windows Virtual Box.  I personally have only a limited about of Linux and CFD experience, and there is practically no support for Vulcan online.  I'm posting here both for my record and for those who come after me.  Good luck.

For the following Virtual Box install, I'm using Ubuntu 12.04, Vulcan 6.3.0, openmpi 1.8.3, Virtualbox 4.3, and Windows 7.

For the following Ubuntu stand-alone install, I'm using I'm using Ubuntu 12.04, Vulcan 6.3.0, openmpi 1.8.4.

If you're wanting to install Vulcan in Windows, this tutorial does a fantastic job walking you through the process of setting up Ubuntu in Virtual Box.  Make sure you download the correct Ubuntu build (32/64 bit and version number).  To my knowledge, Ubuntu 12 is the last version that works with Vulcan.

If you're wishing to install Vulcan on a stand-alone Ubuntu install, worry not.  These directions will work for you as well.  Make sure you're using Ubuntu 12 instead of 14.  I don't believe Vulcan-CFD is compatible with Ubuntu 14 yet.

Initial Ubuntu Setup

The video below will walk you through the process.

Below here, I list all of the steps shown above in the video.
  • Update apt-get
sudo apt-get update
  • Install the following packages.  Make sure you're using the latest builds particularly with tcl8.5 and tk8.5.  
sudo apt-get install gfortran build-essential m4 flex g++ tcsh tcl8.5 tk8.5
  • Download and install openmpi, a program that allows for parallel processing.  Go to the Open-Mpi website (http://www.open-mpi.org/), and download the latest build.  Extract the files, and navigate and change the directory in terminal to the openmpi directory (e.g. cd ~/openmpi-1.8.4/ or whatever your directory is).  Execute the following two commands to install:
./configure F77=gfortran FC=gfortran
sudo make all install
  • Create the folder ~/Vulcan and extract your current version into that folder.  The full path to this directory should be ~Vulcan/Ver_6.3.0 or whatever the latest build is.  
  • Create/open the .tcshrc file (a customization file for tcsh) with the following command, copy and paste the following lines in (with any updates to the directories if necessary, and save.  
sudo gedit ~/.tcshrc

setenv LD_LIBRARY_PATH /usr/local/lib
source ~/Vulcan/Ver_6.3.0/Scripts/vulcan_config
source ~/Vulcan/Ver_6.3.0/Scripts/vulcan_config_gui
setenv TCLGRIDGPATH /
setenv TCLTECPLPATH /
setenv TCLPOSTPPATH /
set history=1000
  • Edit the vulcan config file:  ~/Vulcan/Ver_6.3.0/Scripts/vulcan_config, uncomment the following lines, and save.  This link has more details on this step.
Step 1:  setenv PLATf Linux_AMD_GFC_64
Step 2:  setenv VULCAN_comp_prec double_prec
Step 3:  setenv VULCAN_run_mode parallel_openmpi
Step 4:  setenv VULCAN_rmt_protocol ssh
Step 5:  (skip)
Step 6:  setenv VULCAN_METIS disable (this may be wrong)
Step 7:  (skip)
Step 8:   set mpi_cmnd = 'mpiexec -machinefile $vulcan_mpi_hst -n $num_cpus $vulcan_cmnd'
  • Edit the vulcan config gui file:  ~/Vulcan/Ver_6.3.0/Scripts/vulcan_config_gui, uncomment the following lines, and save.  This file sets up some of the vulcan front end and gui programs, but I've found these to be very buggy.  I also don't understand all of the inputs below.  I do the best I can, but I have no doubt that these aren't 100% correct.  I do, however, believe that whatever you put in here doesn't have a big influence on Vulcan's performance.  
Step 1:  setenv WHICHWISH /usr/bin/wish
Step 2:  (skip)
Step 3:  (skip)
Step 4:  (skip)
Step 5:  setenv TCLBROWSER /usr/bin/firefox
Step 6:  setenv TCLEDITOR  /usr/bin/gedit
Step 7:  (see below)
Step 7 here confuses me, and I'm not sure what to put in for each of these inputs.  I do my best, but I know I'm not doing this right.  
setenv VULCAN_sc_nodes_1 1  #(no. of sub-cluster nodes)
setenv VULCAN_sc_cores_1 4  #(no. of processing cores per node)
  • Install Vulcan.  Type the following commands:
tcsh
source ~/.tcshrc
cd  ~/Vulcan/Ver_6.3.0/Scripts/
./install_vulcan new

  • Finally, run a few examples cases to make sure it works.  

Thanks to:

Jonathan French for providing my first introduction to Vulcan as well and help with installation on several occassions.  
Josh Batterson for helping with installation.
Robert Baurle for maintaining Vulcan-CFD and by giving me permission to post this material on the web)