View Issue Details

IDProjectCategoryView StatusLast Update
0003088OpenFOAMPatchpublic2018-10-15 10:39
ReporterwyldckatAssigned Tohenry 
PrioritylowSeverityminorReproducibilitysometimes
Status resolvedResolutionfixed 
Product Version6 
Fixed in Version6 
Summary0003088: Proposition for wmRefresh with Bash to not use aliases
DescriptionIn the recent report 3086 (in the list of related issues below), there was an indication of 'wmRefresh' being used within a bash script and emitting an error because 'wmUnset' was not defined. This is because aliases are not allowed by default as commands within shell scripts.

The train of thought for using 'wmRefresh' within a shell script is as follows:

1. The 'makeParaView' script tells the user to use 'wmRefresh', as does in the last paragraph on the official instructions: https://openfoam.org/download/source/third-party-software/

2. 'wmRefresh' is a shell function in 'etc/config.sh/aliases', so it shouldn't be a problem to use it from a shell script.

3. Therefore, it makes sense to simply use 'wmRefresh' from within a script that tries to automate the compilation and installation of OpenFOAM, including ParaView.

4. The only downside at the moment is the error message we get if we do run 'wmRefresh' from within a script, namely we get this error message:

     [...]/OpenFOAM-6/etc/config.sh/aliases: line 85: wmUnset: command not found


So with this in mind, please find in attachment the proposition to fix this:

  - 'proposition1.patch' - has the proposed modification, namely using the direct source call for 'unset' from within 'wmRefresh'.

  - 'aliases' - the file for replacing 'etc/config.sh/aliases' in OpenFOAM 6 and dev.
TagsNo tags attached.

Relationships

related to 0003086 closedwyldckat Unable to build OpenFOAM 

Activities

wyldckat

2018-10-14 12:47

updater  

aliases (3,405 bytes)
#----------------------------------*-sh-*--------------------------------------
# =========                 |
# \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
#  \\    /   O peration     | Website:  https://openfoam.org
#   \\  /    A nd           | Copyright (C) 2011-2018 OpenFOAM Foundation
#    \\/     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 3 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, see <http://www.gnu.org/licenses/>.
#
# File
#     etc/config.sh/aliases
#
# Description
#     Aliases for working with OpenFOAM
#     Sourced from OpenFOAM-<VERSION>/etc/bashrc and/or ~/.bashrc
#
#------------------------------------------------------------------------------

# Change compiled version aliases
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias wmSet='. $WM_PROJECT_DIR/etc/bashrc'
alias wm64='wmSet WM_ARCH_OPTION=64'
alias wm32='wmSet WM_ARCH_OPTION=32'
alias wmSP='wmSet WM_PRECISION_OPTION=SP'
alias wmDP='wmSet WM_PRECISION_OPTION=DP'
alias wmLP='wmSet WM_PRECISION_OPTION=LP'

# Clear env
alias wmUnset='. $WM_PROJECT_DIR/etc/config.sh/unset'

# Toggle wmakeScheduler on/off
#  - also need to set WM_HOSTS
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
alias wmSchedOn='export WM_SCHEDULER=$WM_PROJECT_DIR/wmake/wmakeScheduler'
alias wmSchedOff='unset WM_SCHEDULER'

# Change directory aliases
# ~~~~~~~~~~~~~~~~~~~~~~~~
alias foam='cd $WM_PROJECT_DIR'

if [ -n "$WM_PROJECT_SITE" ]
then
    alias foamSite='cd $WM_PROJECT_SITE'
else
    alias foamSite='cd $WM_PROJECT_INST_DIR/site'
fi

alias src='cd $FOAM_SRC'
alias lib='cd $FOAM_LIBBIN'
alias app='cd $FOAM_APP'
alias sol='cd $FOAM_SOLVERS'
alias util='cd $FOAM_UTILITIES'
alias tut='cd $FOAM_TUTORIALS'
alias run='cd $FOAM_RUN'


# Refresh the environment
# ~~~~~~~~~~~~~~~~~~~~~~~
# For backward-compatibility unalias wmRefresh if it is defined as an alias
if declare -f wmRefresh > /dev/null
then
    unset wmRefresh
else
    unalias wmRefresh 2> /dev/null
fi

wmRefresh()
{
    wmProjectDir=$WM_PROJECT_DIR
    foamSettings=$FOAM_SETTINGS
    . $wmProjectDir/etc/config.sh/unset
    . $wmProjectDir/etc/bashrc $foamSettings
}


# Change OpenFOAM version
# ~~~~~~~~~~~~~~~~~~~~~~~
unset foamVersion
foamVersion()
{
    if [ "$1" ]; then
        foamInstDir=$FOAM_INST_DIR
        wmUnset
        . $foamInstDir/OpenFOAM-$1/etc/bashrc
        foam
        echo "Changed to OpenFOAM-$1" 1>&2
    else
        echo "OpenFOAM-$WM_PROJECT_VERSION" 1>&2
    fi
}


# Change ParaView version
# ~~~~~~~~~~~~~~~~~~~~~~~
unset foamPV
foamPV()
{
    . $WM_PROJECT_DIR/etc/config.sh/paraview ParaView_VERSION=$1
    echo "paraview-$ParaView_VERSION  (major: $ParaView_MAJOR)" 1>&2
}


#------------------------------------------------------------------------------
aliases (3,405 bytes)
proposition1.patch (350 bytes)
diff --git a/etc/config.sh/aliases b/etc/config.sh/aliases
index 18fe5b2..974208f 100644
--- a/etc/config.sh/aliases
+++ b/etc/config.sh/aliases
@@ -82,7 +82,7 @@ wmRefresh()
 {
     wmProjectDir=$WM_PROJECT_DIR
     foamSettings=$FOAM_SETTINGS
-    wmUnset
+    . $wmProjectDir/etc/config.sh/unset
     . $wmProjectDir/etc/bashrc $foamSettings
 }
 
proposition1.patch (350 bytes)

henry

2018-10-15 10:39

manager   ~0010105

Thanks Bruno

Resolved in OpenFOAM-6 by commit 1cc13ef87a00e5232cc6761edc5cab25664a611b
Resolved in OpenFOAM-dev by commit a0addf5e8f8a8a880c8af8839e67241ac296a043

Issue History

Date Modified Username Field Change
2018-10-14 12:47 wyldckat New Issue
2018-10-14 12:47 wyldckat Status new => assigned
2018-10-14 12:47 wyldckat Assigned To => henry
2018-10-14 12:47 wyldckat File Added: aliases
2018-10-14 12:47 wyldckat File Added: proposition1.patch
2018-10-14 12:48 wyldckat Relationship added related to 0003086
2018-10-15 10:39 henry Status assigned => resolved
2018-10-15 10:39 henry Resolution open => fixed
2018-10-15 10:39 henry Fixed in Version => 6
2018-10-15 10:39 henry Note Added: 0010105