#!/bin/bash

#------------------------------------------------------------------------------
foamVersion="OpenFOAM-6"


#------------------------------------------------------------------------------
cd ${0%/*} || exit 1
clear
source clean
source .color
source .preamble


#------------------------------------------------------------------------------
echo -e "\n
Start meshing
-------------------------------------------------------------------------------
"


#------------------------------------------------------------------------------
echo -e "   - Create mesh"
ideasUnvToFoam cad/meshSquare.unv > logMeshing


#------------------------------------------------------------------------------
echo -e "   - Change the boundary types in the mesh"
changeDictionary >> logMeshing


#------------------------------------------------------------------------------
echo -e "   - Copy 0.orig to 0 (because next step will make the folders)"
cp -r 0.orig 0


#------------------------------------------------------------------------------
echo -e "\n
-------------------------------------------------------------------------------
End Meshing\n
"


#------------------------------------------------------------------------------
if [ `which interFoam` ]
then

    #--------------------------------------------------------------------------
    echo -e "   - Set the droplets"
    setFields > logSolve


    #--------------------------------------------------------------------------
    echo -e "   - Start simulation (~ 30 minutes)"
    interFoam >> logSolve


    #--------------------------------------------------------------------------
else

    #--------------------------------------------------------------------------
    echo -en "   - Can not start simulation,"
    echo -en " '${RED}interFoam$NC'"
    echo -e " not available"


    #--------------------------------------------------------------------------
fi


#------------------------------------------------------------------------------
echo -e "   - End\n\n"


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