CFD Online Logo CFD Online URL
Home > Forums


Register Blogs Members List Search Today's Posts Mark Forums Read

  1. Old Comment

    bash script for noob and OpenFoam

    I also think it's a good idea create a script to manage the case.

    My idea is generate a shell-script running inside of each case, and then manage the results from a main script running outside of all the cases.

    In the case I show you can change the structure of the script by a function and then pass the name of the variables 'RASmod' and 'MeshName' from the main script to this one.

    If you are running in parallel and once you know that your case setup is correct, I think you can define in controlDict your sample functions to extract the profiles or whatever you're interesting. And then you don't need the reconstructPar function, wich is time consuming specially in unsteady.

    What I mean is, at the end you have a main script placed on the top of your cases and different cases with the corresponding script to manage everything in the case. At the end of the simulation, some folders with different samples will be created, then you can manage it from you main script to call another script, let say written in octave to plot the profiles, save the images, etc.

    This is what I'm doing.

    An example of my first script working as a script and not as a function, and of course called from the terminal.

    run script:

    echo case erased
    mkdir -p logs
    RASmod=inout.kwSSTLowRe #CC: codeCase = {1->0.5mm, 2->1.0mm, 3->1.5mm, 4->2.0mm}
    fluentMeshToFoam constant/polyMesh/mesh/$MeshName > logs/fluentMeshToFoam.log
    echo mesh generated
    decomposePar > logs/decomposePar.log
    echo decomposition done
    echo running the solver
    time mpirun -np 4 simpleFoam -parallel > logs/simpleFoam.log
    echo end of the simulation
    reconstructPar > logs/reconstructPar.log
    echo reconstruction done
    yPlusRAS > logs/yPlusRAS.log
    echo yPlusRAS computed
    wallShearStress > logs/wallShearStress.log
    echo wallShearStress computed
    sample -latestTime > logs/sample.log
    echo sample done
    cd logs
    gnuplot residuals
    cd ..
    echo residuals ploted
    mv sets/streamLines/ ./
    file=$(ls sets/)
    mv sets/$file/* sets/
    rm -r sets/$file
    rm -r -f /home/$RASmod
    cp -r sets /home/$RASmod
    echo sample moved
    echo work DONE

    erase script:

    source ~/.bashrc
    cd constant/polyMesh
    rm -f faces neighbour owner points *Zones
    cd ../../
    rm -r -f sets streamLines logs/*.log probes processor* 0/y 0/yPlus 0/R 0/wallShearStress

    a function that I created to erase all the time step in case except 0

    function RemoveAllCases
    rm -r -f 0.* #also could remove the case 0.old!!!

    for (( i=1; i<=9; i++)); do
    rm -r -f $i*
    Of course I did everything before to know OpenFOAM has its own function to manage the script, so I suggest you to use it! it's more elegant and less time consuming.
    Posted May 26, 2013 at 09:20 by s.espintolosa s.espintolosa is offline
    Updated May 26, 2013 at 16:48 by s.espintolosa (privacy of the roots directories in some part of the code)

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