Compare commits

...

3 Commits

Author SHA1 Message Date
127f4268af CONFIG: bump 2106 patch level to 211215 2021-12-15 11:08:43 +01:00
0bd1b0feac BACKPORT: config script bugfixes
- align with fixes for v2112

- align foamConfigurePaths with v2112 modifications

CONFIG: scan scotch-64.h as possible fallback (#1904)

- For RedHat 8, the /usr/include/scotch.h is actually wrapped
  with a condition check based on LP64 vs ILP32, so need to check
  with those headers if the first one failed.
2021-12-10 14:00:10 +01:00
42178fdd5d BACKPORT: simpler hashing of string-types
includes:

    ENH: simplify hashing overloads of string-types

    - this revises the changes made in 95cd8ee75c to replace the
      SFINAE-type of handling of string hashes with direct definitions.

      This places a bit more burden on the developer if creating hashable
      classes derived from std::string or variants of Foam::string, but
      improves reliability when linking.

    STYLE: drop template key defaulting from HashSet

    - this was never used and `HashSet<>` is much less transparent
      than writing `HashSet<word>` or `wordHashSet`

    STYLE: use Hash<word> instead of string::hasher for runTimeSelectionTables
2021-12-09 18:00:59 +01:00
21 changed files with 725 additions and 379 deletions

View File

@ -1,2 +1,2 @@
api=2106
patch=0
patch=211215

View File

@ -7,7 +7,7 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2016-2020 OpenCFD Ltd.
# Copyright (C) 2016-2021 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -42,11 +42,11 @@ printHelp() {
Obsolete options:
-foamInstall DIR [obsolete]
-projectName NAME [obsolete]
-sigfpe|-no-sigfpe [obsolete - now under etc/controlDict]
-archOption 32|64 [obsolete setting of 'WM_ARCH_OPTION' - edit manually]
-sigfpe|-no-sigfpe [obsolete] now under etc/controlDict
-archOption 32|64 [obsolete] now edit WM_ARCH_OPTION manually
Equivalent options:
-version -foamVersion --projectVersion
-version --projectVersion | -foamVersion
-archOption --archOption
-third -ThirdParty
-paraview --paraviewVersion | -paraviewVersion
@ -55,6 +55,8 @@ Equivalent options:
-scotch-path --scotchArchPath | -scotchArchPath
-system-compiler -system
-third-compiler -third
-sys-openmpi -openmpi-system
-openmpi -openmpi-third
HELP_COMPAT
exit 0 # A clean exit
@ -89,10 +91,9 @@ Compiler
mpc-VERSION For ThirdParty gcc (mpc-system for system library)
MPI
-mpi NAME specify 'WM_MPLIB' type (eg, INTELMPI, etc)
-openmpi VER use ThirdParty openmpi, with version for 'FOAM_MPI'
-openmpi-system use system openmpi
-openmpi-third use ThirdParty openmpi (using default version)
-mpi=NAME Specify 'WM_MPLIB' type (eg, INTELMPI, etc)
-openmpi[=VER] Use ThirdParty openmpi, with version for 'FOAM_MPI'
-sys-openmpi[=MAJ] Use system openmpi, with specified major version
Components versions (ThirdParty)
-adios VER specify 'adios2_version'
@ -120,12 +121,12 @@ Components specified by absolute path
-scotch-path DIR Path for 'SCOTCH_ARCH_PATH' (overrides -scotch)
Graphics
-paraview VER specify 'ParaView_VERSION' (eg, 5.4.1 or system)
-paraview VER specify 'ParaView_VERSION' (eg, 5.9.0 or system)
-paraview-qt VER specify 'ParaView_QT' (eg, qt-system)
-paraview-path DIR specify 'ParaView_DIR' (eg, /opt/ParaView-5.4.1)
-paraview-path DIR specify 'ParaView_DIR' (eg, /opt/ParaView-5.9.0)
-llvm VER specify 'mesa_llvm'
-mesa VER specify 'mesa_version' (eg, mesa-13.0.1)
-vtk VER specify 'vtk_version' (eg, VTK-7.1.0)
-vtk VER specify 'vtk_version' (eg, VTK-9.0.0)
-llvm-path DIR Path for 'LLVM_ARCH_PATH' (overrides -llvm)
-mesa-path DIR Path for 'MESA_ARCH_PATH' (overrides -mesa)
-vtk-path DIR Path for 'VTK_DIR' (overrides -vtk)
@ -212,12 +213,13 @@ _inlineSed()
# Local filename (for reporting)
localFile="$(echo "$file" | sed -e "s#^$projectDir/##")"
grep -q "$regexp" "$file" && sed -i -e "$cmd" "$file" || { \
if grep -q "$regexp" "$file" && sed -i -e "$cmd" "$file"
then
[ -n "$msg" ] && echo " $msg ($localFile)"
else
echo "Failed: ${msg:-replacement} in $localFile"
return 1
}
[ -n "$msg" ] && echo " $msg ($localFile)"
fi
return 0
}
@ -278,8 +280,8 @@ replaceEtc()
local file="$1"
shift
file=$(_foamEtc "$file")
replace $file "$@"
file="$(_foamEtc "$file")"
replace "$file" "$@"
}
@ -289,24 +291,36 @@ replaceEtcCsh()
local file="$1"
shift
file=$(_foamEtc "$file")
replaceCsh $file "$@"
file="$(_foamEtc "$file")"
replaceCsh "$file" "$@"
}
# Get the option's value (argument), or die on missing or empty argument
# $1 option
# $2 value
# Returns values via optValue, nOptArgs variables!!
optValue=""
nOptArgs=0 # The number of args to shift
getOptionValue()
{
local value="$2"
[ -n "$value" ] || die "'$1' option requires an argument"
optValue="${1#*=}"
if [ "$optValue" = "$1" ]
then
# Eg, -option value
optValue="$2"
[ -n "$optValue" ] || die "'$1' option requires an argument"
nOptArgs=1
else
# Eg, -option=value
nOptArgs=0
fi
# Remove any surrounding double quotes
value="${value%\"}"
value="${value#\"}"
echo "$value"
optValue="${optValue%\"}"
optValue="${optValue#\"}"
}
@ -366,7 +380,7 @@ removeCshMagic()
#------------------------------------------------------------------------------
unset adjusted optMpi
unset adjusted
# Parse options
while [ "$#" -gt 0 ]
do
@ -421,26 +435,37 @@ CONFIG_CSH
[ -n "$FOAM_CONFIG_ETC" ] || unset FOAM_CONFIG_ETC
;;
-project-path)
-project-path=* | -project-path)
# Replace WM_PROJECT_DIR=...
optionValue=$(getOptionValue "$@")
replaceEtc bashrc WM_PROJECT_DIR "\"$optionValue\""
replaceEtcCsh cshrc WM_PROJECT_DIR "\"$optionValue\""
getOptionValue "$@"
shift "${nOptArgs:-0}"
removeBashMagic $(_foamEtc bashrc)
removeCshMagic $(_foamEtc cshrc)
if [ -n "$optValue" ]
then
replaceEtc bashrc WM_PROJECT_DIR "\"$optValue\""
replaceEtcCsh cshrc WM_PROJECT_DIR "\"$optValue\""
adjusted=true
shift
removeBashMagic "$(_foamEtc bashrc)"
removeCshMagic "$(_foamEtc cshrc)"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-version | -foamVersion | --projectVersion)
-version=* | -version | -foamVersion | --projectVersion)
# Replace WM_PROJECT_VERSION=...
optionValue=$(getOptionValue "$@")
replaceEtc bashrc WM_PROJECT_VERSION "$optionValue"
replaceEtcCsh cshrc WM_PROJECT_VERSION "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc bashrc WM_PROJECT_VERSION "$optValue"
replaceEtcCsh cshrc WM_PROJECT_VERSION "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-sp | -SP | -float32)
@ -466,131 +491,168 @@ CONFIG_CSH
-int32 | -int64)
# Replace WM_LABEL_SIZE=...
optionValue="${1#-int}"
replaceEtc bashrc WM_LABEL_SIZE "$optionValue"
replaceEtcCsh cshrc WM_LABEL_SIZE "$optionValue"
optValue="${1#-int}"
replaceEtc bashrc WM_LABEL_SIZE "$optValue"
replaceEtcCsh cshrc WM_LABEL_SIZE "$optValue"
adjusted=true
;;
## Compiler ##
-clang)
-clang=* | -clang)
# Replace default_clang_version=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/compiler default_clang_version "$optionValue"
replaceEtc config.csh/compiler default_clang_version "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/compiler default_clang_version "$optValue"
replaceEtc config.csh/compiler default_clang_version "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-gcc)
-gcc=* | -gcc)
# Replace default_gcc_version=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/compiler default_gcc_version "$optionValue"
replaceEtc config.csh/compiler default_gcc_version "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/compiler default_gcc_version "$optValue"
replaceEtc config.csh/compiler default_gcc_version "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-system-compiler | -system)
# Replace WM_COMPILER_TYPE=... and WM_COMPILER=...
optionValue=$(getOptionValue "$@")
replaceEtc bashrc \
WM_COMPILER_TYPE system \
WM_COMPILER "$optionValue"
replaceEtcCsh cshrc \
WM_COMPILER_TYPE system \
WM_COMPILER "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc bashrc \
WM_COMPILER_TYPE system \
WM_COMPILER "$optValue"
replaceEtcCsh cshrc \
WM_COMPILER_TYPE system \
WM_COMPILER "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-third-compiler | -third | -ThirdParty)
# Replace WM_COMPILER_TYPE=... and WM_COMPILER=...
optionValue=$(getOptionValue "$@")
replaceEtc bashrc \
WM_COMPILER_TYPE ThirdParty \
WM_COMPILER "$optionValue"
replaceEtcCsh cshrc \
WM_COMPILER_TYPE ThirdParty \
WM_COMPILER "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc bashrc \
WM_COMPILER_TYPE ThirdParty \
WM_COMPILER "$optValue"
replaceEtcCsh cshrc \
WM_COMPILER_TYPE ThirdParty \
WM_COMPILER "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
gmp-[4-9]* | gmp-system)
# gcc-related package
replaceEtc config.sh/compiler default_gmp_version "$1"
replaceEtc config.csh/compiler default_gmp_version "$1"
optValue="${1#-}"
replaceEtc config.sh/compiler default_gmp_version "$optValue"
replaceEtc config.csh/compiler default_gmp_version "$optValue"
adjusted=true
;;
mpfr-[2-9]* | mpfr-system)
# gcc-related package
replaceEtc config.sh/compiler default_mpfr_version "$1"
replaceEtc config.csh/compiler default_mpfr_version "$1"
optValue="${1#-}"
replaceEtc config.sh/compiler default_mpfr_version "$optValue"
replaceEtc config.csh/compiler default_mpfr_version "$optValue"
adjusted=true
;;
mpc-[0-9]* | mpc-system)
# gcc-related package
replaceEtc config.sh/compiler default_mpc_version "$1"
replaceEtc config.csh/compiler default_mpc_version "$1"
optValue="${1#-}"
replaceEtc config.sh/compiler default_mpc_version "$optValue"
replaceEtc config.csh/compiler default_mpc_version "$optValue"
adjusted=true
;;
## MPI ##
-mpi)
-mpi=* | -mpi)
# Explicitly set WM_MPLIB=...
optionValue=$(getOptionValue "$@")
replaceEtc bashrc WM_MPLIB "$optionValue"
replaceEtcCsh cshrc WM_MPLIB "$optionValue"
optMpi=system
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc bashrc WM_MPLIB "$optValue"
replaceEtcCsh cshrc WM_MPLIB "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-openmpi)
# Replace FOAM_MPI=openmpi-<digits>.. and set to use third-party
# The edit is slightly fragile, but works
expected="openmpi-[1-9][.0-9]*"
optMpi=$(getOptionValue "$@")
_matches "$optMpi" "$expected" || \
die "'$1' has bad value: '$optMpi'"
_inlineSed $(_foamEtc config.sh/mpi) \
"FOAM_MPI=$expected" \
"FOAM_MPI=$optMpi" \
"Replaced 'FOAM_MPI=$expected' by 'FOAM_MPI=$optMpi'"
_inlineSed $(_foamEtc config.csh/mpi) \
"FOAM_MPI $expected" \
"FOAM_MPI $optMpi" \
"Replaced 'FOAM_MPI $expected' by 'FOAM_MPI $optMpi'"
replaceEtc bashrc WM_MPLIB OPENMPI
replaceEtcCsh cshrc WM_MPLIB OPENMPI
adjusted=true
shift
;;
-openmpi-system)
-sys-openmpi=* | -sys-openmpi | -openmpi-system)
optValue="$(echo "$1" | sed -ne 's/^.*mpi=\([1-9][0-9]*\).*/\1/p')"
# Explicitly set WM_MPLIB=SYSTEMOPENMPI
replaceEtc bashrc WM_MPLIB SYSTEMOPENMPI
replaceEtcCsh cshrc WM_MPLIB SYSTEMOPENMPI
optMpi=system
adjusted=true
if [ -n "$optValue" ]
then
replaceEtc bashrc WM_MPLIB SYSTEMOPENMPI"$optValue"
replaceEtcCsh cshrc WM_MPLIB SYSTEMOPENMPI"$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-openmpi-third)
# Explicitly set WM_MPLIB=OPENMPI, using default setting for openmpi
-openmpi=* | -openmpi | -openmpi-third)
# Explicitly set WM_MPLIB=OPENMPI
# - use default setting for openmpi, or
# replace FOAM_MPI=openmpi-<digits>..
# The edit is slightly fragile, but works
expected="openmpi-[1-9][.0-9]*"
optValue="$(echo "$1" | sed -ne 's/^.*mpi=//p')"
if [ -n "$optValue" ]
then
if [ "${optValue#openmpi-}" = "$optValue" ]
then
optValue="openmpi-$optValue"
fi
_matches "$optValue" "$expected" || \
die "'${1%=*}' has bad value: '$optValue'"
_inlineSed "$(_foamEtc config.sh/mpi)" \
"FOAM_MPI=$expected" \
"FOAM_MPI=$optValue" \
"Replaced 'FOAM_MPI=$expected' by 'FOAM_MPI=$optValue'"
_inlineSed "$(_foamEtc config.csh/mpi)" \
"FOAM_MPI=$expected" \
"FOAM_MPI=$optValue" \
"Replaced 'FOAM_MPI $expected' by 'FOAM_MPI $optValue'"
fi
replaceEtc bashrc WM_MPLIB OPENMPI
replaceEtcCsh cshrc WM_MPLIB OPENMPI
optMpi=third
adjusted=true
;;
@ -599,146 +661,242 @@ CONFIG_CSH
-adios | -adios2)
# Replace adios2_version=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/adios2 adios2_version "$optionValue"
replaceEtc config.csh/adios2 adios2_version "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/adios2 adios2_version "$optValue"
replaceEtc config.csh/adios2 adios2_version "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-adios-path | -adios2-path)
# Replace ADIOS2_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/adios2 ADIOS2_ARCH_PATH "\"$optionValue\""
replaceEtcCsh config.csh/adios2 ADIOS2_ARCH_PATH "\"$optionValue\""
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/adios2 ADIOS2_ARCH_PATH "\"$optValue\""
replaceEtcCsh config.csh/adios2 ADIOS2_ARCH_PATH "\"$optValue\""
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-boost)
# Replace boost_version=... (config is cgal or CGAL)
optionValue=$(getOptionValue "$@")
getOptionValue "$@"
shift "${nOptArgs:-0}"
cfgName=cgal; _foamEtc -q config.sh/"$cfgName" || cfgName=CGAL
replaceEtc config.sh/"$cfgName" boost_version "$optionValue"
replaceEtc config.csh/"$cfgName" boost_version "$optionValue"
adjusted=true
shift
if [ -n "$optValue" ]
then
replaceEtc config.sh/"$cfgName" boost_version "$optValue"
replaceEtc config.csh/"$cfgName" boost_version "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-boost-path)
# Replace BOOST_ARCH_PATH=... (config is cgal or CGAL)
optionValue=$(getOptionValue "$@")
getOptionValue "$@"
shift "${nOptArgs:-0}"
cfgName=cgal; _foamEtc -q config.sh/"$cfgName" || cfgName=CGAL
replaceEtc config.sh/"$cfgName" BOOST_ARCH_PATH "\"$optionValue\""
replaceEtc config.csh/"$cfgName" BOOST_ARCH_PATH "\"$optionValue\""
adjusted=true
shift
if [ -n "$optValue" ]
then
replaceEtc config.sh/"$cfgName" BOOST_ARCH_PATH "\"$optValue\""
replaceEtc config.csh/"$cfgName" BOOST_ARCH_PATH "\"$optValue\""
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-cgal)
# Replace cgal_version=... (config is cgal or CGAL)
optionValue=$(getOptionValue "$@")
getOptionValue "$@"
shift "${nOptArgs:-0}"
cfgName=cgal; _foamEtc -q config.sh/"$cfgName" || cfgName=CGAL
replaceEtc config.sh/"$cfgName" cgal_version "$optionValue"
replaceEtc config.csh/"$cfgName" cgal_version "$optionValue"
adjusted=true
shift
if [ -n "$optValue" ]
then
replaceEtc config.sh/"$cfgName" cgal_version "$optValue"
replaceEtc config.csh/"$cfgName" cgal_version "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-cgal-path)
# Replace CGAL_ARCH_PATH=... (config is cgal or CGAL)
optionValue=$(getOptionValue "$@")
getOptionValue "$@"
shift "${nOptArgs:-0}"
cfgName=cgal; _foamEtc -q config.sh/"$cfgName" || cfgName=CGAL
replaceEtc config.sh/"$cfgName" CGAL_ARCH_PATH "$optionValue"
replaceEtcCsh config.csh/"$cfgName" CGAL_ARCH_PATH "$optionValue"
adjusted=true
shift
if [ -n "$optValue" ]
then
replaceEtc config.sh/"$cfgName" CGAL_ARCH_PATH "$optValue"
replaceEtcCsh config.csh/"$cfgName" CGAL_ARCH_PATH "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-fftw)
# Replace fftw_version=...
optionValue=$(getOptionValue "$@")
getOptionValue "$@"
shift "${nOptArgs:-0}"
# config.sh/fftw or config.sh/FFTW
cfgName=fftw; _foamEtc -q config.sh/"$cfgName" || cfgName=FFTW
replaceEtc config.sh/"$cfgName" fftw_version "$optionValue"
replaceEtc config.csh/"$cfgName" fftw_version "$optionValue"
adjusted=true
shift
if [ -n "$optValue" ]
then
replaceEtc config.sh/"$cfgName" fftw_version "$optValue"
replaceEtc config.csh/"$cfgName" fftw_version "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-fftw-path)
# Replace FFTW_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
getOptionValue "$@"
shift "${nOptArgs:-0}"
# config.sh/fftw or config.sh/FFTW
cfgName=fftw; _foamEtc -q config.sh/"$cfgName" || cfgName=FFTW
replaceEtc config.sh/"$cfgName" FFTW_ARCH_PATH "\"$optionValue\""
replaceEtcCsh config.csh/"$cfgName" FFTW_ARCH_PATH "\"$optionValue\""
adjusted=true
shift
if [ -n "$optValue" ]
then
replaceEtc config.sh/"$cfgName" FFTW_ARCH_PATH "\"$optValue\""
replaceEtcCsh config.csh/"$cfgName" FFTW_ARCH_PATH "\"$optValue\""
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-cmake)
# Replace cmake_version=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/cmake cmake_version "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/cmake cmake_version "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-cmake-path)
# Replace CMAKE_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/cmake CMAKE_ARCH_PATH "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/cmake CMAKE_ARCH_PATH "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-kahip)
# Replace KAHIP_VERSION=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/kahip KAHIP_VERSION "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/kahip KAHIP_VERSION "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-kahip-path)
# Replace KAHIP_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/kahip KAHIP_ARCH_PATH "\"$optionValue\""
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/kahip KAHIP_ARCH_PATH "\"$optValue\""
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-metis)
# Replace METIS_VERSION=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/metis METIS_VERSION "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/metis METIS_VERSION "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-metis-path)
# Replace METIS_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/metis METIS_ARCH_PATH "\"$optionValue\""
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/metis METIS_ARCH_PATH "\"$optValue\""
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-scotch | -scotchVersion | --scotchVersion)
# Replace SCOTCH_VERSION=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/scotch SCOTCH_VERSION "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/scotch SCOTCH_VERSION "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-scotch-path | -scotchArchPath | --scotchArchPath)
# Replace SCOTCH_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/scotch SCOTCH_ARCH_PATH "\"$optionValue\""
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/scotch SCOTCH_ARCH_PATH "\"$optValue\""
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
@ -747,107 +905,156 @@ CONFIG_CSH
-paraview | -paraviewVersion | --paraviewVersion)
# Replace ParaView_VERSION=...
expected="[5-9][.0-9]*" # but also accept system
optionValue=$(getOptionValue "$@")
_matches "$optionValue" "$expected" || \
[ "$optionValue" != "${optionValue%system}" ] || \
die "'$1' has bad value: '$optionValue'"
replaceEtc config.sh/paraview ParaView_VERSION "$optionValue"
replaceEtc config.csh/paraview ParaView_VERSION "$optionValue"
adjusted=true
shift
getOptionValue "$@"
_matches "$optValue" "$expected" || \
[ "$optValue" != "${optValue%system}" ] || \
die "'${1%=*}' has bad value: '$optValue'"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/paraview ParaView_VERSION "$optValue"
replaceEtc config.csh/paraview ParaView_VERSION "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-paraview-qt)
# Replace ParaView_QT=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/paraview ParaView_QT "$optionValue"
replaceEtc config.csh/paraview ParaView_QT "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/paraview ParaView_QT "$optValue"
replaceEtc config.csh/paraview ParaView_QT "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-paraview-path | -paraviewInstall | --paraviewInstall)
# Replace ParaView_DIR=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/paraview ParaView_DIR \""$optionValue\""
replaceEtcCsh config.csh/paraview ParaView_DIR \""$optionValue\""
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/paraview ParaView_DIR \""$optValue\""
replaceEtcCsh config.csh/paraview ParaView_DIR \""$optValue\""
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-llvm)
# Replace mesa_llvm=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/vtk mesa_llvm "$optionValue"
replaceEtc config.csh/vtk mesa_llvm "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/vtk mesa_llvm "$optValue"
replaceEtc config.csh/vtk mesa_llvm "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-mesa)
# Replace mesa_version=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/vtk mesa_version "$optionValue"
replaceEtc config.csh/vtk mesa_version "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/vtk mesa_version "$optValue"
replaceEtc config.csh/vtk mesa_version "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-vtk)
# Replace vtk_version=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/vtk vtk_version "$optionValue"
replaceEtc config.csh/vtk vtk_version "$optionValue"
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/vtk vtk_version "$optValue"
replaceEtc config.csh/vtk vtk_version "$optValue"
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-llvm-path)
# Replace LLVM_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/vtk LLVM_ARCH_PATH \""$optionValue\""
replaceEtcCsh config.csh/vtk LLVM_ARCH_PATH \""$optionValue\""
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/vtk LLVM_ARCH_PATH \""$optValue\""
replaceEtcCsh config.csh/vtk LLVM_ARCH_PATH \""$optValue\""
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-mesa-path)
# Replace MESA_ARCH_PATH...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/vtk MESA_ARCH_PATH \""$optionValue\""
replaceEtcCsh config.csh/vtk MESA_ARCH_PATH \""$optionValue\""
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/vtk MESA_ARCH_PATH \""$optValue\""
replaceEtcCsh config.csh/vtk MESA_ARCH_PATH \""$optValue\""
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
-vtk-path)
# Replace VTK_DIR...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/vtk VTK_DIR \""$optionValue\""
replaceEtcCsh config.csh/vtk VTK_DIR \""$optionValue\""
adjusted=true
shift
getOptionValue "$@"
shift "${nOptArgs:-0}"
if [ -n "$optValue" ]
then
replaceEtc config.sh/vtk VTK_DIR \""$optValue\""
replaceEtcCsh config.csh/vtk VTK_DIR \""$optValue\""
adjusted=true
else
: "${adjusted:=empty}"
fi
;;
## Misc ##
# Obsolete flags
-sigfpe | -no-sigfpe)
echo "Enable/disable FOAM_SIGFPE now via controlDict" 1>&2
;;
-archOption | --archOption)
# Replace WM_ARCH_OPTION=...
optionValue=$(getOptionValue "$@")
echo "Ignoring $1 option: no longer supported" 1>&2
shift
;;
# Obsolete options
-archOption | --archOption | \
-foamInstall | --foamInstall | -projectName | --projectName)
# Removed for 1812
optionValue=$(getOptionValue "$@")
echo "Ignoring $1 option: obsolete" 1>&2
shift
echo "Ignoring obsolete option: $1" 1>&2
getOptionValue "$@"
shift "${nOptArgs:-0}"
;;
*)

View File

@ -99,7 +99,7 @@ case "none":
breaksw
case "system":
# Obtain major.minor from `paraview --version`
# Obtain (major.minor) from `paraview --version`
set pv_api=`paraview --version | sed -ne 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/p'`
if ("${pv_api}" == "") then
@ -156,6 +156,7 @@ default:
if ( -r "$ParaView_DIR" ) then
setenv PATH "${ParaView_DIR}/bin:${PATH}"
set pvLibDir="unknown"
set pv_libdirs=""
# QT libraries as required, and Qt5_DIR for the root directory.
# Another possibility: "qtpaths --qt-version"
@ -168,7 +169,7 @@ default:
endsw
foreach libDir ("lib$WM_COMPILER_LIB_ARCH" "lib")
if ( -d "${qtDir}/${libDir}" ) then
setenv LD_LIBRARY_PATH "${qtDir}/${libDir}:${LD_LIBRARY_PATH}"
set pv_libdirs="${qtDir}/${libDir}"
break
endif
end
@ -182,11 +183,11 @@ default:
set pvLibDir="${libDir}/paraview-${pv_api}"
if ( -d "${ParaView_DIR}/${pvLibDir}" ) then
switch ("$pv_api")
case 5.[0-4]*:
case 5.[0-4]:
set libDir="$pvLibDir" # Needs lib/paraview-X.X (not lib)
breaksw
endsw
setenv LD_LIBRARY_PATH "${ParaView_DIR}/${libDir}:${LD_LIBRARY_PATH}"
set pv_libdirs="${ParaView_DIR}/${libDir}:${pv_libdirs}"
break
endif
set pvLibDir="unknown"
@ -200,6 +201,18 @@ default:
set pv_plugin_dir="${pv_plugin_dir} (missing)" # For message
endif
# Any extra library directories
if ( "$pv_libdirs" != "" ) then
switch ("$WM_ARCH")
case darwin*:
setenv DYLD_LIBRARY_PATH "${pv_libdirs}:$DYLD_LIBRARY_PATH"
breaksw
default:
setenv LD_LIBRARY_PATH "${pv_libdirs}:$LD_LIBRARY_PATH"
breaksw
endsw
endif
if ($?FOAM_VERBOSE && $?prompt) then
echo "Using paraview"
echo " ParaView_DIR : $ParaView_DIR"
@ -225,6 +238,6 @@ endif
unsetenv ParaView_VERSION ParaView_QT
unset archDir libDir
unset pv_api pv_plugin_dir pvLibDir pvPython qtDir
unset pv_api pv_plugin_dir pv_libdirs pvLibDir pvPython qtDir
#------------------------------------------------------------------------------

View File

@ -82,11 +82,13 @@ case Linux:
endsw
breaksw
# Presume x86_64, with clang (not gcc) as system compiler
# arm64 or x86_64 architectures
case Darwin:
setenv WM_ARCH darwin64
if ( "$WM_COMPILER" == Gcc ) setenv WM_COMPILER Clang
echo "openfoam: darwin support is clang/llvm only"
if ( "$WM_COMPILER" == Gcc ) then
setenv WM_COMPILER Clang
echo "openfoam (darwin): using clang instead of gcc"
endif
breaksw
# Presume x86_64, with mingw cross-compiled
@ -96,7 +98,7 @@ case MSYS*:
if ( "$WM_COMPILER" == Gcc ) setenv WM_COMPILER Mingw
setenv WM_COMPILER_LIB_ARCH 64 # Consistent with linux64Mingw
echo "openfoam: windows support (mingw64) is runtime only"
;;
breaksw
case SunOS*:
setenv WM_ARCH solaris64
@ -146,12 +148,12 @@ setenv FOAM_USER_APPBIN "$WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/bin"
setenv FOAM_USER_LIBBIN "$WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/lib"
# Prepend wmake to the path - not required for runtime-only environment
set foundDir="${WM_PROJECT_DIR}/wmake"
set _foamFoundDir="${WM_PROJECT_DIR}/wmake"
if ( $?WM_DIR ) then
if ( -d "${WM_DIR}" ) set foundDir="${WM_DIR}"
if ( -d "${WM_DIR}" ) set _foamFoundDir="${WM_DIR}"
endif
if ( -d "$foundDir" ) then
setenv PATH "${foundDir}:${PATH}"
if ( -d "$_foamFoundDir" ) then
setenv PATH "${_foamFoundDir}:${PATH}"
else
unsetenv WM_DIR
endif
@ -321,7 +323,7 @@ endsw
# Cleanup
# ~~~~~~~
unset archDir siteDir foundDir archOption
unset archOption archDir siteDir _foamFoundDir
unset gcc_version gccDir
unset gmp_version gmpDir mpfr_version mpfrDir mpc_version mpcDir
unset clang_version clangDir

View File

@ -6,7 +6,7 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2016-2020 OpenCFD Ltd.
# Copyright (C) 2016-2021 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -106,6 +106,11 @@ unsetenv FOAM_USER_APPBIN
unsetenv FOAM_USER_LIBBIN
unsetenv FOAM_UTILITIES
# Build related
unsetenv FOAM_BUILDROOT
unsetenv FOAM_THIRD_PARTY_BUILDROOT
unsetenv FOAM_THIRD_PARTY_SOURCES
# Older, unused variables
# Before 1812
@ -116,7 +121,14 @@ unsetenv FOAM_INST_DIR
unsetenv MPI_ARCH_PATH
unsetenv MPI_BUFFER_SIZE
unsetenv OPAL_PREFIX
# Cleanup mpi prefix values if set to one of the paths on foamOldDirs
if ( $?foamClean ) then
# openmpi:
if ( "`$foamClean -env=OPAL_PREFIX $foamOldDirs`" == "" ) unsetenv OPAL_PREFIX
# intelmpi:
if ( "`$foamClean -env=I_MPI_ROOT $foamOldDirs`" == "" ) unsetenv I_MPI_ROOT
endif
#------------------------------------------------------------------------------
@ -153,21 +165,30 @@ unsetenv SCOTCH_ARCH_PATH
# PATH, LD_LIBRARY_PATH, MANPATH
if ( $?foamClean ) then
eval `$foamClean -csh-env=PATH "$foamOldDirs"`
if ($?LD_LIBRARY_PATH) then
eval `$foamClean -csh-env=LD_LIBRARY_PATH "$foamOldDirs"`
if ("${LD_LIBRARY_PATH}" == "") unsetenv LD_LIBRARY_PATH
endif
if ($?MANPATH) then
eval `$foamClean -csh-env=MANPATH "$foamOldDirs"`
if ("${MANPATH}" == "") unsetenv MANPATH
endif
if ($?LD_LIBRARY_PATH) then
eval `$foamClean -csh-env=LD_LIBRARY_PATH "$foamOldDirs"`
endif
if ($?DYLD_LIBRARY_PATH) then
eval `$foamClean -csh-env=DYLD_LIBRARY_PATH "$foamOldDirs"`
endif
endif
if ($?MANPATH) then
if ("${MANPATH}" == "") unsetenv MANPATH
endif
if ($?LD_LIBRARY_PATH) then
if ("${LD_LIBRARY_PATH}" == "") unsetenv LD_LIBRARY_PATH
endif
if ($?DYLD_LIBRARY_PATH) then
if ("${DYLD_LIBRARY_PATH}" == "") unsetenv DYLD_LIBRARY_PATH
endif
# Remove any shadow env variables
unsetenv FOAM_DYLD_LIBRARY_PATH
#------------------------------------------------------------------------------
# Cleanup aliases
@ -214,6 +235,6 @@ endif
#------------------------------------------------------------------------------
# Intermediate variables (do as last for a clean exit code)
unset cleaned foamClean foamOldDirs
unset cleaned foamClean foamOldDirs _foamFoundDir
#------------------------------------------------------------------------------

View File

@ -118,7 +118,7 @@ case "$ParaView_VERSION" in
;;
([0-9]*)
# Extract API from VERSION
# Extract API (major.minor) from VERSION
pv_api=$(echo "$ParaView_VERSION" | \
sed -ne 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/p')
;;
@ -131,6 +131,7 @@ case "$ParaView_VERSION" in
if [ -r "$ParaView_DIR" ]
then
export PATH="$ParaView_DIR/bin:$PATH"
unset pv_libdirs
# QT libraries as required, and Qt5_DIR for the root directory.
# Another possibility: "qtpaths --qt-version"
@ -146,7 +147,7 @@ case "$ParaView_VERSION" in
do
if [ -d "$qtDir/$libDir" ]
then
export LD_LIBRARY_PATH="$qtDir/$libDir:$LD_LIBRARY_PATH"
pv_libdirs="$qtDir/$libDir"
break
fi
done
@ -161,11 +162,11 @@ case "$ParaView_VERSION" in
if [ -d "$ParaView_DIR/$pvLibDir" ]
then
case "$pv_api" in
(5.[0-4]*)
(5.[0-4])
libDir="$pvLibDir" # Needs lib/paraview-X.X (not lib)
;;
esac
export LD_LIBRARY_PATH="$ParaView_DIR/$libDir:$LD_LIBRARY_PATH"
pv_libdirs="$ParaView_DIR/$libDir:${pv_libdirs}"
break
fi
unset pvLibDir
@ -180,6 +181,16 @@ case "$ParaView_VERSION" in
pv_plugin_dir="${pv_plugin_dir} (missing)" # For message
fi
# Any extra library directories
if [ -n "$pv_libdirs" ]
then
case "$WM_ARCH" in
(darwin*)
export DYLD_LIBRARY_PATH="${pv_libdirs}:$DYLD_LIBRARY_PATH" ;;
(*) export LD_LIBRARY_PATH="${pv_libdirs}:$LD_LIBRARY_PATH" ;;
esac
fi
if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then
echo "Using paraview" 1>&2
@ -208,6 +219,6 @@ then
fi
unset archDir libDir
unset pv_api pv_plugin_dir pvLibDir pvPython qtDir
unset pv_api pv_plugin_dir pv_libdirs pvLibDir pvPython qtDir
#------------------------------------------------------------------------------

View File

@ -78,11 +78,15 @@ Linux)
esac
;;
# Presume x86_64, with clang (not gcc) as system compiler
# arm64 or x86_64 architectures
Darwin)
WM_ARCH=darwin64
[ "$WM_COMPILER" = Gcc ] && WM_COMPILER=Clang
echo "openfoam: darwin support is clang/llvm only" 1>&2
# Defult to clang (not gcc) as system compiler
if [ "$WM_COMPILER" = Gcc ]
then
WM_COMPILER=Clang
echo "openfoam (darwin): using clang instead of gcc" 1>&2
fi
;;
# Presume x86_64, with mingw cross-compiled
@ -143,14 +147,14 @@ export FOAM_USER_LIBBIN="$WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/lib"
# Prepend wmake to the path - not required for runtime-only environment
foundDir="$WM_PROJECT_DIR/wmake"
_foamFoundDir="$WM_PROJECT_DIR/wmake"
if [ -d "$WM_DIR" ]
then
foundDir="${WM_DIR}"
_foamFoundDir="${WM_DIR}"
fi
if [ -d "$foundDir" ]
if [ -d "$_foamFoundDir" ]
then
PATH="$foundDir:$PATH"
PATH="$_foamFoundDir:$PATH"
else
unset WM_DIR
fi
@ -264,7 +268,7 @@ GCC_NOT_FOUND
if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then
echo "Using ThirdParty compiler"
echo " ${gccDir##*/} (${gmpDir##*/} $${mpfrDir##*/} ${mpcDir##*/})"
echo " ${gccDir##*/} (${gmpDir##*/} ${mpfrDir##*/} ${mpcDir##*/})"
fi
;;
@ -312,7 +316,7 @@ esac
# Cleanup
# ~~~~~~~
unset archDir siteDir foundDir archOption
unset archOption archDir siteDir _foamFoundDir
unset gcc_version gccDir
unset gmp_version gmpDir mpfr_version mpfrDir mpc_version mpcDir
unset clang_version clangDir

View File

@ -6,7 +6,7 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2016-2020 OpenCFD Ltd.
# Copyright (C) 2016-2021 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -95,6 +95,11 @@ unset FOAM_USER_APPBIN
unset FOAM_USER_LIBBIN
unset FOAM_UTILITIES
# Build related
unset FOAM_BUILDROOT
unset FOAM_THIRD_PARTY_BUILDROOT
unset FOAM_THIRD_PARTY_SOURCES
# Older, unused variables
# Before 1812
@ -106,10 +111,13 @@ unset FOAM_INST_DIR
unset MPI_ARCH_PATH
unset MPI_BUFFER_SIZE
# Undefine OPAL_PREFIX if set to one of the paths on foamOldDirs
if [ -n "$foamClean" ] && [ -z "$($foamClean -env=OPAL_PREFIX $foamOldDirs)" ]
# Cleanup mpi prefix values if set to one of the paths on foamOldDirs
if [ -n "$foamClean" ]
then
unset OPAL_PREFIX
# openmpi:
[ -z "$($foamClean -env=OPAL_PREFIX $foamOldDirs)" ] && unset OPAL_PREFIX
# intelmpi:
[ -z "$($foamClean -env=I_MPI_ROOT $foamOldDirs)" ] && unset I_MPI_ROOT
fi
#------------------------------------------------------------------------------
@ -154,12 +162,17 @@ unset SCOTCH_ARCH_PATH
if [ -n "$foamClean" ]
then
eval "$($foamClean -sh-env=PATH $foamOldDirs)"
eval "$($foamClean -sh-env=LD_LIBRARY_PATH $foamOldDirs)"
eval "$($foamClean -sh-env=MANPATH $foamOldDirs)"
eval "$($foamClean -sh-env=LD_LIBRARY_PATH $foamOldDirs)"
eval "$($foamClean -sh-env=DYLD_LIBRARY_PATH $foamOldDirs)"
fi
[ -n "$LD_LIBRARY_PATH" ] || unset LD_LIBRARY_PATH
[ -n "$MANPATH" ] || unset MANPATH
[ -n "$LD_LIBRARY_PATH" ] || unset LD_LIBRARY_PATH
[ -n "$DYLD_LIBRARY_PATH" ] || unset DYLD_LIBRARY_PATH
# Remove any shadow env variables
unset FOAM_DYLD_LIBRARY_PATH
#------------------------------------------------------------------------------
# Cleanup aliases and functions
@ -218,6 +231,6 @@ unset _of_complete_cache_
#------------------------------------------------------------------------------
# Intermediate variables (do as last for a clean exit code)
unset cleaned foamClean foamOldDirs
unset cleaned foamClean foamOldDirs _foamFoundDir
#------------------------------------------------------------------------------

View File

@ -52,7 +52,7 @@ Typedef
Foam::wordHashSet
Description
A HashSet with (the default) word keys.
A HashSet with word keys and string hasher.
Typedef
Foam::labelHashSet
@ -75,12 +75,22 @@ namespace Foam
// Forward Declarations
template<class T> class MinMax;
template<class Key, class Hash> class HashSet;
// Common hash-set types
//- A HashSet of words, uses string hasher.
typedef HashSet<word, Hash<word>> wordHashSet;
//- A HashSet of labels, uses label hasher.
typedef HashSet<label, Hash<label>> labelHashSet;
/*---------------------------------------------------------------------------*\
Class HashSet Declaration
\*---------------------------------------------------------------------------*/
template<class Key=word, class Hash=Foam::Hash<Key>>
template<class Key, class Hash=Foam::Hash<Key>>
class HashSet
:
public HashTable<zero::null, Key, Hash>
@ -401,14 +411,7 @@ public:
};
// Typedefs
//- A HashSet with word keys.
typedef HashSet<word> wordHashSet;
//- A HashSet with label keys and label hasher.
typedef HashSet<label, Hash<label>> labelHashSet;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Global Functions

View File

@ -39,9 +39,10 @@ Description
namespace Foam
{
template<class Key, class Hash> class HashSet;
template<class T, class Key, class Hash> class HashTable;
template<class T, class Key, class Hash> class HashPtrTable;
template<class Key, class Hash> class HashSet;
template<class T> class Map;
template<class T> class PtrMap;

View File

@ -56,7 +56,7 @@ Description
< \
argNames##ConstructorPtr, \
::Foam::word, \
::Foam::string::hasher \
::Foam::Hash<::Foam::word> \
> argNames##ConstructorTable; \
\
/* Construct from argList function pointer table pointer */ \

View File

@ -5,8 +5,8 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Original code Copyright (C) 2012-2018 Bernhard Gschaider
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2012-2018 Bernhard Gschaider
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -65,7 +65,7 @@ public:
// Constructors
//- Construct null
//- Default construct
exprString() = default;
//- Copy construct
@ -189,6 +189,16 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace expressions
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Hashing for exprString is the same as string
template<> struct Hash<expressions::exprString> : string::hasher {};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -30,12 +30,9 @@ Class
Description
Hash function class.
The default definition is for primitives.
Non-primitives used to hash entries on hash tables will likely need
Non-primitives used to hash entries on hash tables will need
a specialized version.
Note
The second template parameter (bool) is used for SFINAE overloading,
\*---------------------------------------------------------------------------*/
#ifndef Hash_H
@ -43,8 +40,6 @@ Note
#include "Hasher.H"
#include <cstdint>
#include <string>
#include <type_traits>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -55,7 +50,7 @@ namespace Foam
Class Hash Declaration
\*---------------------------------------------------------------------------*/
template<class T, class SFINAEType=bool>
template<class T>
struct Hash
{
unsigned operator()(const T& obj, unsigned seed=0) const
@ -67,35 +62,7 @@ struct Hash
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Specialization for trivial (integer) types
#undef FOAM_INTHASHER
#define FOAM_INTHASHER(IntType) \
/*! \brief Hashing specialization for IntType */ \
/*! Unseeded (single value) uses natural order, otherwise incremental */ \
template<> struct Hash<IntType> \
{ \
unsigned operator()(const IntType val) const \
{ \
return static_cast<unsigned>(val); \
} \
unsigned operator()(const IntType val, unsigned seed) const \
{ \
return Foam::Hasher(&val, sizeof(IntType), seed); \
} \
}
FOAM_INTHASHER(bool);
FOAM_INTHASHER(char);
FOAM_INTHASHER(int32_t);
FOAM_INTHASHER(int64_t);
FOAM_INTHASHER(uint32_t);
#undef FOAM_INTHASHER
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Hashing specialization for nullptr. Always 0
//- Hashing of nullptr, always 0
template<>
struct Hash<std::nullptr_t>
{
@ -105,7 +72,7 @@ struct Hash<std::nullptr_t>
}
};
//- Hashing specialization for pointers, interpret pointer as a integer type
//- Hashing of pointers, treat as unsigned integer
template<>
struct Hash<void*>
{
@ -119,20 +86,32 @@ struct Hash<void*>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Hashing partial specialization for derived string types
template<class StringType>
struct Hash
<
StringType,
typename std::enable_if
<std::is_base_of<std::string, StringType>::value, bool>::type
>
{
unsigned operator()(const std::string& str, unsigned seed=0) const
{
return Foam::Hasher(str.data(), str.length(), seed);
// Specialization for common integral types
#undef FOAM_HASH_SPECIALIZATION
#define FOAM_HASH_SPECIALIZATION(Type) \
\
/*! \brief Hashing of integral type: Type */ \
/*! Unseeded (single value) uses natural order, otherwise incremental */ \
template<> \
struct Hash<Type> \
{ \
unsigned operator()(const Type val) const \
{ \
return static_cast<unsigned>(val); \
} \
unsigned operator()(const Type val, unsigned seed) const \
{ \
return Foam::Hasher(&val, sizeof(Type), seed); \
} \
}
};
FOAM_HASH_SPECIALIZATION(bool);
FOAM_HASH_SPECIALIZATION(char);
FOAM_HASH_SPECIALIZATION(int32_t);
FOAM_HASH_SPECIALIZATION(int64_t);
FOAM_HASH_SPECIALIZATION(uint32_t);
#undef FOAM_HASH_SPECIALIZATION
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -58,10 +58,15 @@ namespace Foam
// Forward Declarations
class fileName;
class token;
template<class T> class List;
template<class T> class UList;
typedef List<word> wordList;
//- Hashing for fileName
template<> struct Hash<fileName> : string::hasher {};
/*---------------------------------------------------------------------------*\
Class fileName Declaration
\*---------------------------------------------------------------------------*/

View File

@ -58,6 +58,10 @@ class token;
Istream& operator>>(Istream& is, keyType& val);
Ostream& operator<<(Ostream& os, const keyType& val);
//- Hashing for keyType
template<> struct Hash<keyType> : string::hasher {};
/*---------------------------------------------------------------------------*\
Class keyType Declaration
\*---------------------------------------------------------------------------*/
@ -237,6 +241,8 @@ public:
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// IOstream Operators
//- Read operator

View File

@ -62,11 +62,14 @@ namespace Foam
{
// Forward Declarations
class string;
class word;
class wordRe;
class Istream;
class Ostream;
template<class T> struct Hash;
/*---------------------------------------------------------------------------*\
Class string Declaration
\*---------------------------------------------------------------------------*/
@ -150,7 +153,8 @@ public:
}
};
//- Hashing functor for string and derived string classes
//- Deprecated hashing functor - use hasher
// \deprecated(2021-04) - use hasher
struct hash : string::hasher {};
@ -333,6 +337,17 @@ public:
};
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
//- Hashing for Foam::string
template<> struct Hash<string> : string::hasher {};
//- Hashing for std:::string
template<> struct Hash<std::string> : string::hasher {};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// IOstream Operators
//- Read operator

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd.
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -55,6 +55,10 @@ class word;
Istream& operator>>(Istream& is, word& val);
Ostream& operator<<(Ostream& os, const word& val);
//- Hashing for word
template<> struct Hash<word> : string::hasher {};
/*---------------------------------------------------------------------------*\
Class word Declaration
\*---------------------------------------------------------------------------*/
@ -204,6 +208,8 @@ public:
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// IOstream Operators
//- Read operator

View File

@ -70,6 +70,10 @@ class wordRe;
Istream& operator>>(Istream& is, wordRe& val);
Ostream& operator<<(Ostream& os, const wordRe& val);
//- Hashing for wordRe
template<> struct Hash<wordRe> : string::hasher {};
/*---------------------------------------------------------------------------*\
Class wordRe Declaration
\*---------------------------------------------------------------------------*/
@ -249,6 +253,8 @@ public:
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// IOstream Operators
//- Read operator

View File

@ -106,6 +106,15 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace ensight
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Hashing for FileName is the same as string
template<> struct Hash<ensight::FileName> : string::hasher {};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -104,6 +104,16 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace ensight
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
//- Hashing for VarName is the same as string
template<> struct Hash<ensight::VarName> : string::hasher {};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -5,7 +5,7 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2020 OpenCFD Ltd.
# Copyright (C) 2018-2021 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
@ -70,6 +70,10 @@
# when MPI_ARCH_PATH=/usr/lib64/openmpi
# and mpicc --showme:compile -> -I/usr/include/openmpi-x86_64
#
# NB: for RedHat (8+) /usr/include/scotch.h is a wrapper that includes
# /usr/include/scotch-64.h (LP64 mode)
# or /usr/include/scotch-32.h (ILP32 mode)
# In either case, int is 32 bits
#
# openSUSE
# --------
@ -90,7 +94,7 @@
no_scotch()
{
unset HAVE_SCOTCH SCOTCH_ARCH_PATH SCOTCH_INC_DIR SCOTCH_LIB_DIR
unset SCOTCH_VERSION
unset SCOTCH_VERSION SCOTCH_LIBNAME_SUFFIX
unset HAVE_PTSCOTCH PTSCOTCH_ARCH_PATH PTSCOTCH_INC_DIR PTSCOTCH_LIB_DIR
}
@ -161,6 +165,36 @@ search_scotch()
return 2
}
# ----------------------------------
# Extract 'typedef int64_t SCOTCH_Num' etc from header file
# - ensure consistent size between OpenFOAM and scotch header
# - for some systems, scotch.h includes scotch-64.h (for example).
local label
for hdr in \
"$header" \
"${header%/*}"/scotch-64.h \
"${header%/*}"/scotch-32.h \
;
do
if [ -f "$hdr" ]
then
label=$(sed -ne \
's/^.*typedef *\([^ ]*\) *SCOTCH_Num.*/\1/p' \
"$hdr")
if [ -n "$label" ]
then
header="$hdr" # Appears successful
break
fi
fi
done
: "${label:=unknown}" # Safety
# Transform (int32_t | int64_t) -> (int32 | int64)
case "$label" in (int32_t | int64_t) label="${label%_t}" ;; esac
# Library
[ -n "$library" ] \
|| library=$(findLibrary -prefix="$prefix" -name="$libName" -local="$localDir") \
@ -171,16 +205,6 @@ search_scotch()
# ----------------------------------
local label
# Ensure consistent sizes between OpenFOAM and scotch header
# extract 'typedef int64_t SCOTCH_Num' or equivalent
label=$(sed -ne \
's/^.*typedef *\([^ ]*\) *SCOTCH_Num.*/\1/p' \
"$header")
: "${label:=unknown}"
# No SCOTCH_VERSION set? Try to obtain from header
# extract #define SCOTCH_VERSION, SCOTCH_RELEASE, SCOTCH_PATCHLEVEL
[ -n "$SCOTCH_VERSION" ] || \
@ -198,7 +222,8 @@ search_scotch()
: "${SCOTCH_VERSION:=scotch}" # Failsafe value
case "$WM_LABEL_SIZE:$label" in
(32:int32_t | 32:int | 64:int64_t | 64:long)
( 32:int32 | 32:int \
| 64:int64 | 64:long )
;;
(*)
@ -212,7 +237,7 @@ search_scotch()
esac
# OK
echo "scotch (label=$label) - $prefix"
echo "scotch ($label) - $prefix"
export HAVE_SCOTCH=true
export SCOTCH_ARCH_PATH="$prefix"
export SCOTCH_INC_DIR="${header%/*}" # Basename