CFD Online Discussion Forums

CFD Online Discussion Forums (http://www.cfd-online.com/Forums/)
-   OpenFOAM (http://www.cfd-online.com/Forums/openfoam/)
-   -   Different inlet U values steady state (http://www.cfd-online.com/Forums/openfoam/84005-different-inlet-u-values-steady-state.html)

alex_rubel January 17, 2011 19:53

Different inlet U values steady state
 
Hi everyone, I'm a new user of OpenFOAM and I have to make a lot of simulation to validate the use of OF for my case instead of software like Fluent or CFX.
I'm using simpleFoam and I'm looking for an way to make a yaw study.
I want to create a file with all the u_x u_y u_z values for yaws from 0 to 20 deg and to ask Of to take these values for the inlet automatically. For example every 2000 timestep, 0deg for 2000 timestep and restart automatically with the 2deg value for an other 2000 timestep ...

My other idea is to use "timeVaryingUniformFixedValue" for U :
boundaryField
{
SURFACE_INLET
{
type timeVaryingUniformFixedValue
fileName "FOAM_CASE/U_inlet.timeprof";
outOfBounds clamp;
}
and to create a file U_inlet.timeprof with
(
(0 (3.2294 0 0)) 10 (timestep(u_x u_y u_z))
(2000(x y z))
)
but i don't know of to set a cos/sin dependance for x y and z

I hop I'm clear of what I want and you can help me
Thanks
Alex

sleepdeprivation January 18, 2011 11:37

Have you thought about setting up a script to run the different cases?

check out pyFoam http://openfoamwiki.net/index.php/Contrib_PyFoam
especially pyFoamClearCase.py and pyFoamWriteDictionary.py

chegdan January 18, 2011 16:16

what about a bash script?
 
Although PyFoam is really great, I found it frustrating to learn OpenFoam and PyFoam at the same time. How about just taking an Allrun script (from many of the tutorials) and setting up your cases that are eventually run by your script? A script could look like:

Code:


#!/bin/bash
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions

#move into the first case
cd case1

printf "starting simplFoam"

#print start time
date
#decompose the mesh assuming you have decomposeParDict correct
    runApplication decomposePar

#parallel run with 8 processes
    runParallel simpleFoam 8 system/machines

#reconstruct the domain
    runApplication reconstructPar

#print the end time and date
date

#now move to the second case
cd ../case2

#repeat first set of commands

this of course could be run above the first case and as long as everything has been initialized then it will run well. I suggest getting one working well with all your specifics correct (solver settings, descritization, convergence criteria, initial conditions, etc. ) and then running them in sequence. I really like PyFoam, but it can be tough to get started using without much experience in OF. Good Luck.

Dan

alex_rubel January 18, 2011 18:30

Thanks for your answers, I looked at pyFoam but it's seems hard to get something working in one or two days and i need to set that asap.
Thanks a lot Dan it seems a very good idea, I'm going to try today, I started a Java program with eclipse but get some problems.
I'll try to set the Allrun file.
Thanks again
Alex

alex_rubel January 18, 2011 18:59

I add some thing in your code Dan tell me if it's good. I usually use the following command to run parallel case :
mpirun -np 6 simpleFoam -parallel > log &
I want to know if "runParallel simpleFoam 6 system/machine" will do he same thing

Code:

#!/bin/bash
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions

#move into the first case
cd 4deg

printf "starting simplFoam"

#print start time
date
#copy 0 to 0.org
    cp -r 0 0.org
#run potentialFoam
    runApplication potentialFoam -writep
#decompose the mesh assuming you have decomposeParDict correct
    runApplication decomposePar

#parallel run with 8 processes
    runParallel simpleFoam 6 system/machines

#reconstruct the domain
    runApplication reconstructPar -latestTime

#print the end time and date
date

#now move to the second case
cd ../6deg

#repeat first set of commands


chegdan January 18, 2011 19:14

yeah the mpirun command is in the runParallel simpleFoam 6 system/machines command. The machines file in the system folder must be there and that contains the hostname of the computer (it doesn't need the number of processors for this command).

alex_rubel January 18, 2011 19:22

I don't have a machine file in my system folder. Can you give a copy of this file ?
Thanks

chegdan January 18, 2011 19:33

go to the terminal and type

hostname > machines

then put that file in your system folders

alex_rubel January 18, 2011 19:43

Ok thanks a lot for everything. Hope it will be ok

alex_rubel January 19, 2011 19:12

Hi, I try to launch it this morning and I got this error message :

Quote:

.: 3: Can't open /bin/tools/RunFunctions

chegdan January 19, 2011 19:40

Quote:

Originally Posted by alex_rubel (Post 291218)
Hi, I try to launch it this morning and I got this error message :

Make sure all of your openfoam variables are sourced properly, in this case its $WM_PROJECT_DIR

if you type

echo $WM_PROJECT_DIR

then something like

/home/dcombest/OpenFOAM/OpenFOAM-1.6-ext

should come up. if not then something is wrong with your install.

Dan

alex_rubel January 19, 2011 19:58

I got :
/home/arubel/OpenFOAM/OpenFOAM-1.6

chegdan January 19, 2011 20:30

does /home/arubel/OpenFOAM/OpenFOAM-1.6/bin/tools/RunFuntions exist?
are you calling the script correctly?
If you call it from the directory where is exists then call it by

Code:

./ScriptName
or

Code:

sh ScriptName.sh
are you using the bash shell?
echo $SHELL should give you /bin/bash

It should work if all is set up correctly. Paste the whole script if you want me to try.

alex_rubel January 19, 2011 20:37

I'm using ubuntu so it's a bash shell. And The RunFunctions files exist in the /home/arubel/OpenFOAM/OpenFOAM-1.6/bin/tools/
I don't really understans what i have to do with
Code:

./ScriptName
here is my Allrun file :
Quote:

#!/bin/sh
# Source tutorial run functions
. $WM_PROJECT_DIR/bin/tools/RunFunctions

#move into the first case
cd 4deg

printf "starting simplFoam"

#print start time
date
#copy 0 to 0.org
cp -r 0 0.org
#run potentialFoam
runApplication potentialFoam -writep
#decompose the mesh assuming you have decomposeParDict correct
runApplication decomposePar

#parallel run with 8 processes
runParallel simpleFoam 6 system/machines

#reconstruct the domain
runApplication reconstructPar -latestTime

#print the end time and date
date

#now move to the second case
cd ../6deg

#repeat first set of commands

printf "starting simplFoam"

#print start time
date
#copy 0 to 0.org
cp -r 0 0.org
#run potentialFoam
runApplication potentialFoam -writep
#decompose the mesh assuming you have decomposeParDict correct
runApplication decomposePar

#parallel run with 8 processes
runParallel simpleFoam 6 system/machines

#reconstruct the domain
runApplication reconstructPar -latestTime

#print the end time and date
date

and the RunFunction file :
Quote:

#---------------------------------*- sh -*-------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
# \\/ M anipulation |
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM; if not, write to the Free Software Foundation,
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# Script
# RunFunctions
#
# Description
#
#------------------------------------------------------------------------------

getApplication ()
{
grep application system/controlDict | sed "s/application *\([a-zA-Z]*\);/\1/"
}

runApplication ()
{
APP_RUN=$1; shift
APP_NAME=${APP_RUN##*/}

if [ -f log.$APP_NAME ] ; then
echo "$APP_NAME already run on $PWD: remove log file to run"
else
echo "Running $APP_RUN on $PWD"
$APP_RUN $* > log.$APP_NAME 2>&1
fi
}

runParallel ()
{
APP_RUN=$1; shift

if [ -f $log.$APP_RUN ] ; then
echo "$APP_RUN already run on $PWD: remove log file to run"
else
echo "Running $APP_RUN in parallel on $PWD using $1 processes"
( mpirun -np $1 $APP_RUN -parallel < /dev/null > log.$APP_RUN 2>&1 )
fi
}

compileApplication ()
{
echo "Compiling $1 application"
wmake $1
}

cloneCase ()
{
if [ -d $2 ] ; then
echo "Case already cloned: remove case directory $2 to clone"
else
echo "Cloning $2 case from $1"
mkdir $2
cpfiles="0 system constant"
for f in $cpfiles
do
cp -r $1/$f $2
done
fi
}

#------------------------------------------------------------------------------

chegdan January 19, 2011 20:56

sorry...the ./ScriptName is actually ./Allrun I just wasnt sure what you called your script. I will try this tomorrow morning....Im out of the office.

chegdan January 19, 2011 22:50

I tried your script and it worked where it was suppose to work. I'm not sure what the issue is on your system.

alex_rubel January 19, 2011 23:01

Could it be a problem of authorisation because I always have to use sudo to source something ...

chegdan January 19, 2011 23:27

That might be the problem. My install is in my home directory.


All times are GMT -4. The time now is 13:42.