Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
No results found
Show changes
Commits on Source (6)
Showing
with 590 additions and 252 deletions
......@@ -6,13 +6,14 @@ wmakeCheckPwd "$WM_PROJECT_DIR" 2>/dev/null || {
echo " Check your OpenFOAM environment and installation"
exit 1
}
[ -d "$WM_PROJECT_DIR" -a -f "$WM_PROJECT_DIR/etc/bashrc" ] || {
if [ -f "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments ]
then . "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments || \
echo "Argument parse error";
else
echo "Error (${0##*/}) : WM_PROJECT_DIR appears to be incorrect"
echo " Check your OpenFOAM environment and installation"
exit 1
}
. "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments
fi
#------------------------------------------------------------------------------
# Preamble. Report tools or at least the mpirun location
......@@ -45,11 +46,11 @@ echo
"${WM_DIR:-wmake}"/src/Allmake
# Compile ThirdParty libraries and applications
if [ -d "$WM_THIRD_PARTY_DIR" ]
if [ -d "$WM_THIRD_PARTY_DIR" ] && [ -x "$WM_THIRD_PARTY_DIR/Allwmake" ]
then
"$WM_THIRD_PARTY_DIR/Allwmake"
"$WM_THIRD_PARTY_DIR"/Allwmake
else
echo "No ThirdParty directory found - skipping"
echo "No ThirdParty directory, or missing Allwmake - skipping"
fi
echo "========================================"
......@@ -74,7 +75,7 @@ fi
# Count files in given directory. Ignore "Test-*" binaries.
_foamCountDirEntries()
{
(cd "$1" 2>/dev/null && find -mindepth 1 -maxdepth 1 -type f 2>/dev/null) |\
(cd "$1" 2>/dev/null && find . -mindepth 1 -maxdepth 1 -type f 2>/dev/null) |\
sed -e '\@/Test-@d' | wc -l
}
......@@ -86,10 +87,10 @@ echo " ${WM_PROJECT_DIR##*/}"
echo " $WM_COMPILER ${WM_COMPILER_TYPE:-system} compiler"
echo " ${WM_OPTIONS}, with ${WM_MPLIB} ${FOAM_MPI}"
echo
echo " api = $(foamEtcFile -show-api 2>/dev/null)"
echo " patch = $(foamEtcFile -show-patch 2>/dev/null)"
echo " bin = $(_foamCountDirEntries $FOAM_APPBIN) entries"
echo " lib = $(_foamCountDirEntries $FOAM_LIBBIN) entries"
echo " api = $(bin/foamEtcFile -show-api 2>/dev/null)"
echo " patch = $(bin/foamEtcFile -show-patch 2>/dev/null)"
echo " bin = $(_foamCountDirEntries "$FOAM_APPBIN") entries"
echo " lib = $(_foamCountDirEntries "$FOAM_LIBBIN") entries"
echo
echo "========================================"
......
......@@ -6,13 +6,14 @@ wmakeCheckPwd "$WM_PROJECT_DIR/applications" 2>/dev/null || {
echo " Check your OpenFOAM environment and installation"
exit 1
}
[ -d "$WM_PROJECT_DIR" -a -f "$WM_PROJECT_DIR/etc/bashrc" ] || {
if [ -f "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments ]
then . "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments || \
echo "Argument parse error";
else
echo "Error (${0##*/}) : WM_PROJECT_DIR appears to be incorrect"
echo " Check your OpenFOAM environment and installation"
exit 1
}
. "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments
fi
#------------------------------------------------------------------------------
......
......@@ -90,7 +90,13 @@ namespace Foam
// Hack to do zones which have Lists in them. See above.
bool writeZones(const word& name, const fileName& meshDir, Time& runTime)
bool writeZones
(
const word& name,
const fileName& meshDir,
Time& runTime,
const IOstreamOption::compressionType compression
)
{
IOobject io
(
......@@ -156,7 +162,7 @@ bool writeZones(const word& name, const fileName& meshDir, Time& runTime)
(
IOstream::ASCII,
IOstream::currentVersion,
runTime.writeCompression(),
compression,
true
);
}
......@@ -330,7 +336,7 @@ int main(int argc, char *argv[])
writeMeshObject<pointIOField>("points", meshDir, runTime);
// Write boundary in ascii. This is only needed for fileHandler to
// kick in. Should not give problems since always writing ascii.
writeZones("boundary", meshDir, runTime);
writeZones("boundary", meshDir, runTime, IOstreamOption::UNCOMPRESSED);
writeMeshObject<labelIOList>("pointProcAddressing", meshDir, runTime);
writeMeshObject<labelIOList>("faceProcAddressing", meshDir, runTime);
writeMeshObject<labelIOList>("cellProcAddressing", meshDir, runTime);
......@@ -353,9 +359,11 @@ int main(int argc, char *argv[])
{
// Only do zones when converting from binary to ascii
// The other way gives problems since working on dictionary level.
writeZones("cellZones", meshDir, runTime);
writeZones("faceZones", meshDir, runTime);
writeZones("pointZones", meshDir, runTime);
const IOstreamOption::compressionType compress =
runTime.writeCompression();
writeZones("cellZones", meshDir, runTime, compress);
writeZones("faceZones", meshDir, runTime, compress);
writeZones("pointZones", meshDir, runTime, compress);
}
// Get list of objects from the database
......
......@@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -50,9 +50,9 @@ Description
const label nPointFields =
(
noPointValues
? 0
: objects.count(stringListOps::foundOp<word>(fieldTypes::point))
doPointValues
? objects.count(stringListOps::foundOp<word>(fieldTypes::point))
: 0
);
......@@ -82,7 +82,7 @@ Description
if (doInternal)
{
if (!noPointValues)
if (doPointValues)
{
pInterp.reset(new volPointInterpolation(mesh));
}
......@@ -180,7 +180,7 @@ Description
else if (patchIds.size())
{
patchWriters.resize(patchIds.size());
if (!noPointValues)
if (doPointValues)
{
patchInterps.resize(patchIds.size());
}
......@@ -320,7 +320,7 @@ Description
// PointData
// - only construct pointMesh on request since it constructs
// edge addressing
if (!noPointValues)
if (doPointValues)
{
// Begin PointData
if (internalWriter.valid())
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -510,8 +510,8 @@ int main(int argc, char *argv[])
<< nl << endl;
}
const bool noPointValues = args.found("no-point-data");
if (noPointValues)
const bool doPointValues = !args.found("no-point-data");
if (!doPointValues)
{
Info<< "Point fields and interpolated point data"
<< " disabled with the '-no-point-data' option"
......@@ -523,7 +523,7 @@ int main(int argc, char *argv[])
{
Info<< "Write point ids requested";
if (noPointValues)
if (!doPointValues)
{
Info<< ", but ignored due to the '-no-point-data' option";
}
......@@ -801,9 +801,9 @@ int main(int argc, char *argv[])
// Prune restart fields
objects.prune_0();
if (noPointValues)
if (!doPointValues)
{
// Prune point fields unless specifically requested
// Prune point fields if disabled
objects.filterClasses
(
[](const word& clsName)
......
......@@ -7,14 +7,13 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2017-2018 OpenCFD Ltd.
# Copyright (C) 2017-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# foamEtcFile
# bin/foamEtcFile
#
# Description
# Locate user/group/other file as per '#includeEtc'.
......@@ -61,8 +60,8 @@ options:
-config Add config directory prefix for shell type:
with -csh* for a config.csh/ prefix
with -sh* for a config.sh/ prefix
-show-api Print api value from wmake/rules, or meta-info and exit
-show-patch Print patch value from meta-info and exit
-show-api Print META-INFO api value and exit
-show-patch Print META-INFO patch value and exit
-with-api=NUM Specify alternative api value to search with
-quiet (-q) Suppress all normal output
-silent (-s) Suppress stderr, except -csh-verbose, -sh-verbose output
......@@ -109,54 +108,17 @@ groupDir="${WM_PROJECT_SITE:-$projectDir/site}" # As per foamVersion.H
#-------------------------------------------------------------------------------
# The API locations. See wmake/wmakeBuildInfo
rulesFile="$projectDir/wmake/rules/General/general"
metaInfoDir="$projectDir/META-INFO"
# Get api from rules/General/general
#
# Failure modes:
# - No api information (can't find file etc).
# -> Fatal for building, but could be OK for a stripped down version
#
# Fallback. Get from api-info
#
getApi()
# Get a value from META-INFO/api-info
# $1 : keyword
getApiInfo()
{
local value
value="$(sed -ne '/^ *#/!{ /WM_VERSION.*OPENFOAM=/{ s@^.*OPENFOAM= *\([0-9][0-9]*\).*@\1@p; q }}' $rulesFile 2>/dev/null)"
if [ -z "$value" ] && [ -f "$metaInfoDir/api-info" ]
then
# Fallback. Get from api-info
value="$(sed -ne 's@^ *api *= *\([0-9][0-9]*\).*@\1@p' $metaInfoDir/api-info 2>/dev/null)"
fi
if [ -n "$value" ]
then
echo "$value"
else
return 1
fi
}
# Get patch from meta-info / api-info
#
# Failure modes:
# - No patch information (can't find file etc).
#
getPatchLevel()
{
local value
# Fallback. Get from api-info
value="$(sed -ne 's@^ *patch *= *\([0-9][0-9]*\).*@\1@p' $metaInfoDir/api-info 2>/dev/null)"
value="$(sed -ne 's@^'"$1"' *= *\([0-9][0-9]*\).*@\1@p' "$projectDir"/META-INFO/api-info 2>/dev/null)"
if [ -n "$value" ]
then
echo "$value"
else
echo "Could not determine OPENFOAM '$1' value" 1>&2
return 1
fi
}
......@@ -174,14 +136,12 @@ do
-h | -help*)
printHelp
;;
-show-api)
# Show API and exit
getApi
-show-api) # Show API and exit
getApiInfo api
exit $?
;;
-show-patch)
# Show patch level and exit
getPatchLevel
-show-patch) # Show patch level and exit
getApiInfo patch
exit $?
;;
-with-api=*)
......@@ -257,7 +217,7 @@ done
#-------------------------------------------------------------------------------
# Establish the API value
[ -n "$projectApi" ] || projectApi=$(getApi)
[ -n "$projectApi" ] || projectApi=$(getApiInfo api)
# Split arguments into filename (for searching) and trailing bits for shell eval
......
......@@ -7,7 +7,7 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018 OpenFOAM Foundation
# Copyright (C) 2019 OpenCFD Ltd.
# Copyright (C) 2019-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
......@@ -166,7 +166,7 @@ fi
# No api specified -with-api= or from environment (FOAM_API)
if [ -z "$projectApi" ]
then
projectApi="$(foamEtcFile -show-api 2>/dev/null)"
projectApi="$("$projectDir"/bin/foamEtcFile -show-api 2>/dev/null)"
fi
......
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# openfoam [options] [args]
#
# Description
# Forwarding to the OpenFOAM etc/openfoam bash session script.
#
#------------------------------------------------------------------------------
# Hard-coded directory path (eg, autoconfig)
projectDir="@PROJECT_DIR@"
exec "$projectDir"/etc/openfoam "$@"
#------------------------------------------------------------------------------
......@@ -5,34 +5,36 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2019 OpenCFD Ltd.
# Copyright (C) 2019-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# File
# bin/tools/source-bashrc
#
# Description
# Source user ~/.bashrc and OpenFOAM etc/bashrc
# Source user ~/.bashrc and OpenFOAM etc/bashrc.
# Not normally sourced manually, but from bash with the --rcfile option.
#
# This file is normally not sourced manually,
# but from bash with the --rcfile option.
#------------------------------------------------------------------------------
# Hard-coded value (eg, with autoconfig)
# Hard-coded directory path (eg, autoconfig)
projectDir="@PROJECT_DIR@"
if [ -z "$projectDir" ] || [ "${projectDir#@}" != "$projectDir" ]
then
# Auto-detect (as per OpenFOAM etc/bashrc)
# Auto-detect location (as per OpenFOAM etc/bashrc)
# --
# Assuming this file is $WM_PROJECT_DIR/bin/tools/source-bashrc,
# the next lines should work when sourced by BASH or ZSH shells.
# --
projectDir="${BASH_SOURCE:-${ZSH_NAME:+$0}}"
[ -n "$projectDir" ] && projectDir="$(\cd $(dirname $projectDir)/../.. && \pwd -L)" || unset projectDir
if [ -n "$projectDir" ]
then
projectDir="$(\cd "$(dirname "$projectDir")"/../.. && \pwd -L)" || \
unset projectDir
fi
fi
#------------------------------------------------------------------------------
......@@ -66,7 +68,7 @@ then
# Some feedback
if [ -n "$PS1" ] && [ -d "$WM_PROJECT_DIR" ]
then
info="$(foamEtcFile -show-patch 2>/dev/null)"
info="$("$WM_PROJECT_DIR"/bin/foamEtcFile -show-patch 2>/dev/null)"
# echo "Using: OpenFOAM-$WM_PROJECT_VERSION ($FOAM_API${info:+ patch=$info}) - visit www.openfoam.com" 1>&2
echo "Using: OpenFOAM-$WM_PROJECT_VERSION${info:+ (patch=$info)} - visit www.openfoam.com" 1>&2
......
.TH "OPENFOAM" 1 "OpenFOAM-version" "www.openfoam.com" "OpenFOAM Commands Manual"
.SH NAME
openfoam \- OpenFOAM bash(1) session
.SH SYNOPSIS
\fBopenfoam\fR [\fIOPTIONS\fR] [\fIapplication ...\fR]
.SH DESCRIPTION
Activate an \fBOpenFOAM\fR environment in an interactive or
non-interactive bash(1) session.
If no application is given, an interactive bash session will be used.
If an application (optionally with arguments) is provided, the
OpenFOAM \fIetc/bashrc\fR file will be sourced from the project directory
prior to running the application.
.SH OPTIONS
.TP
\fB\-c\fR \fIcommand\fR
Execute shell commands with OpenFOAM environment
.TP
\fB\-D\fR\fIkey=[value]\fR
Define key/value to pass as a preference
.TP
\fB\-sp\fR
Use single precision for scalar-size
.TP
\fB\-dp\fR
Use double precision for scalar-size
.TP
\fB\-spdp\fR
Use single precision for scalar-size, double for solve-scalar size
.TP
\fB\-int32\fR
Use 32-bit label-size
.TP
\fB\-int64\fR
Use 64-bit label-size
.TP
\fB\-prefix=DIR\fR
Specify alternative OpenFOAM project directory
.TP
\fB\-show-api\fR | \fB\-version\fR
Print META-INFO api value and exit
.TP
\fB\-show-patch\fR
Print META-INFO patch value and exit
.TP
\fB\-show-prefix\fR
Print project directory and exit
.TP
\fB\-help\fR
Print the usage
.SH ARGUMENTS
If arguments remain after option processing, the first argument is
assumed to be an application with options and arguments.
.SH FILES
The \fIetc/bashrc\fR file from the OpenFOAM project directory supplies
the environment settings.
.SH "SEE ALSO"
Online documentation https://www.openfoam.com/documentation/
.SH COPYRIGHT
Copyright \(co 2020 OpenCFD Ltd.
......@@ -6,11 +6,10 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2016-2019 OpenCFD Ltd.
# Copyright (C) 2016-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# File
# etc/bashrc
......@@ -30,11 +29,16 @@
# - $WM_PROJECT_SITE/$FOAM_API/etc/prefs.sh
# - $WM_PROJECT_SITE/etc/prefs.sh
#
# Some settings can also be overridden on the command-line when
# sourcing this file. For example,
#
# . /path/etc/bashrc WM_COMPILER=Clang WM_LABEL_SIZE=64
#
# Environment
# FOAM_VERBOSE (set/unset)
# - add extra verbosity when sourcing files
# FOAM_CONFIG_NOUSER (set/unset)
# - suppress use of user/group configuration files
# FOAM_VERBOSE (set/unset)
# - add extra verbosity when sourcing files
# WM_PROJECT_SITE (optional directory)
# - local site-specific directory, uses WM_PROJECT_DIR/site if unset
#
......
......@@ -132,8 +132,8 @@ then
_foamAddMan "$WM_PROJECT_DIR/doc"
fi
# Interactive shell
if /usr/bin/tty -s 2>/dev/null
# Interactive shell (use PS1, not tty)
if [ -n "$PS1" ]
then
_foamEtc -config aliases
[ "${BASH_VERSINFO:-0}" -ge 4 ] && _foamEtc -config bash_completion
......
......@@ -6,11 +6,10 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2016-2019 OpenCFD Ltd.
# Copyright (C) 2016-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# File
# etc/cshrc
......@@ -30,11 +29,16 @@
# - $WM_PROJECT_SITE/$FOAM_API/etc/prefs.csh
# - $WM_PROJECT_SITE/prefs.csh
#
# Some settings can also be overridden on the command-line when
# sourcing this file. For example,
#
# source /path/etc/cshrc WM_COMPILER=Clang WM_LABEL_SIZE=64
#
# Environment
# FOAM_VERBOSE (set/unset)
# - add extra verbosity when sourcing files
# FOAM_CONFIG_NOUSER (set/unset)
# - suppress use of user/group configuration files
# FOAM_VERBOSE (set/unset)
# - add extra verbosity when sourcing files
# WM_PROJECT_SITE (optional directory)
# - local site-specific directory, uses WM_PROJECT_DIR/site if unset
#
......
......@@ -6,112 +6,135 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2019 OpenCFD Ltd.
# Copyright (C) 2019-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# openfoam [args]
# openfoam [options] [args]
#
# Description
# Open an interactive bash session with an OpenFOAM environment,
# or run an OpenFOAM application (with arguments) after first sourcing
# the OpenFOAM etc/bashrc file from the project directory.
#
# This script normally exists in $WM_PROJECT_DIR/bin/tools but can also
# be modified to use a hard-coded PROJECT_DIR entry and placed elsewhere
# in the filesystem (eg, /usr/bin).
# Note
# This script normally exists in the $WM_PROJECT_DIR/etc/ directory.
# Do not copy/move/link to other locations. Use instead an edited copy of
# `bin/tools/openfoam.in` with a hard-coded projectDir entry.
#
# See OpenFOAM etc/bashrc for (command-line) preferences.
# Some equivalent settings:
# -sp | -DWM_PRECISION_OPTION=SP
# -dp | -DWM_PRECISION_OPTION=DP
# -int32 | -DWM_LABEL_SIZE=32
# -int64 | -DWM_LABEL_SIZE=64
#
# However, the '-D' options grant more flexibility. For example,
# etc/openfoam -DWM_COMPILER=Clang
#
#------------------------------------------------------------------------------
# Hard-coded value (eg, with autoconfig)
projectDir="@PROJECT_DIR@"
if [ -z "$projectDir" ] || [ "${projectDir#@}" != "$projectDir" ]
then
# Auto-detect from location
toolsDir="${0%/*}" # The bin/tools dir
projectDir="${toolsDir%/bin/tools}" # Project dir
case "$projectDir" in
(/bin | /usr/bin | /usr/local/bin)
# This shouldn't happen.
# If copied to a system dir, should also be using hard-coded values!
echo "Warning: suspicious looking project dir: $projectDir" 1>&2
;;
("$toolsDir")
# Eg, called as ./openfoam etc - need to try harder
projectDir="$(\cd $(dirname $0)/../.. && \pwd -L)" || unset projectDir
;;
esac
fi
# Auto-detect from location
projectDir="$(\cd "$(dirname "${0%/*}")" && \pwd -L)"
#------------------------------------------------------------------------------
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
printHelp() {
cat<<USAGE
Usage: ${0##*/} [OPTION] [application ...]
options:
-prefix=DIR Specify alternative OpenFOAM directory
-sp Single precision
-dp Double precision
-spdp Mixed single/double precision
-int32 | -int64 The label-size
-help Print the usage
-c command Execute shell commands with OpenFOAM environment
-Dkey[=value] Define key/value to pass as a preference
-sp Single precision
-dp Double precision
-spdp Mixed single/double precision
-int32 | -int64 The label-size
-prefix=DIR Alternative OpenFOAM project directory
-show-api | -version Print META-INFO api value and exit
-show-patch Print META-INFO patch value and exit
-show-prefix Print project directory and exit
-verbose Set FOAM_VERBOSE=true (interactive only)
-help Print the usage
Open an interactive bash session with an OpenFOAM environment,
or run an OpenFOAM application (with arguments) after first sourcing
the OpenFOAM etc/bashrc file from the project directory:
($projectDir)
For more information: www.OpenFOAM.com
For more information: www.openfoam.com
USAGE
exit 1
exit 0 # A clean exit
}
#-------------------------------------------------------------------------------
# Only preserve settings for non-interactive?
# Get a value from META-INFO/api-info
# $1 : keyword
getApiInfo()
{
value="$(sed -ne 's@^'"$1"' *= *\([0-9][0-9]*\).*@\1@p' "$projectDir"/META-INFO/api-info 2>/dev/null)"
if [ "$#" -eq 0 ]
then
unset _foamSettings FOAM_SETTINGS
else
_foamSettings="$FOAM_SETTINGS"
fi
if [ -n "$value" ]
then
echo "$value"
else
echo "Could not determine OPENFOAM '$1' value" 1>&2
return 1
fi
}
#-------------------------------------------------------------------------------
# No inheritance of FOAM_SETTINGS
unset FOAM_SETTINGS
unset _foamSettings _foamScriptCommand
# Parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help*)
usage
-h | -help* | --help*)
printHelp
;;
-prefix=* | -foam=*)
projectDir="${1#*=}"
-show-api | -version | --version) # Show API and exit
getApiInfo api
exit $?
;;
-show-patch) # Show patch level and exit
getApiInfo patch
exit $?
;;
-show-prefix) # Show project directory and exit
echo "$projectDir"
exit $?
;;
-sp | -SP)
# WM_PRECISION_OPTION=...
_foamSettings="$_foamSettings${_foamSettings:+ }WM_PRECISION_OPTION=SP"
-c) # Shell command
_foamScriptCommand="$2"
[ -n "$_foamScriptCommand" ] || {
echo "$0: missing or bad command argument: $2" 1>&2
exit 1
}
shift 2
break
;;
-dp | -DP)
# WM_PRECISION_OPTION=...
_foamSettings="$_foamSettings${_foamSettings:+ }WM_PRECISION_OPTION=DP"
-D*) # Define key/value to pass as preference
setting="${1#-D}"
if [ -n "$setting" ]
then
_foamSettings="$_foamSettings${_foamSettings:+ }$setting"
fi
;;
-spdp | -SPDP)
# WM_PRECISION_OPTION=...
_foamSettings="$_foamSettings${_foamSettings:+ }WM_PRECISION_OPTION=SPDP"
-sp | -dp | -spdp )
# WM_PRECISION_OPTION=(SP|DP|SPDP)
setting=$(echo "${1#-}" | sed -e 's/-//g;y/sdp/SDP/')
_foamSettings="$_foamSettings${_foamSettings:+ }WM_PRECISION_OPTION=$setting"
;;
-int32 | -int64)
......@@ -119,12 +142,20 @@ do
_foamSettings="$_foamSettings${_foamSettings:+ }WM_LABEL_SIZE=${1#-int}"
;;
-prefix=*)
projectDir="${1#*=}"
;;
-verbose)
export FOAM_VERBOSE=true
;;
--)
shift
break
;;
-*)
echo "Error: unknown option: '$1'" 1>&2
echo "$0: unknown option: '$1'" 1>&2
exit 1
;;
*)
......@@ -136,23 +167,37 @@ done
#-------------------------------------------------------------------------------
# Remove current OpenFOAM environment
if [ -d "$WM_PROJECT_DIR" ] && [ -f "$WM_PROJECT_DIR/etc/config.sh/unset" ]
# Sanity check (installed under /bin, /usr/bin, /usr/local/bin)
# This should not happen.
# If copied to a system dir, should also be using hard-coded values!
if [ "${projectDir%/bin}" != "$projectDir" ]
then
. "$WM_PROJECT_DIR/etc/config.sh/unset"
echo "Warning: suspicious project dir: $projectDir" 1>&2
fi
[ -d "$projectDir" ] || {
echo "Error: no project dir: $projectDir" 1>&2
exit 2
[ -d "$projectDir/META-INFO" ] || {
echo "Warning: missing META-INFO in OpenFOAM directory:" 1>&2
echo " $projectDir" 1>&2
}
_foamSourceBashEnv="$projectDir/etc/bashrc"
if [ "$#" -eq 0 ]
# Remove current OpenFOAM environment
if [ -d "$WM_PROJECT_DIR" ] && [ -f "$WM_PROJECT_DIR/etc/config.sh/unset" ]
then
# Interactive shell
. "$WM_PROJECT_DIR/etc/config.sh/unset" || true
fi
unset interactive
if [ "$#" -eq 0 ] && [ -z "$_foamScriptCommand" ]
then
# Interactive shell, chain off via a file
interactive=true
_foamSourceBashEnv="$projectDir/bin/tools/source-bashrc"
else
# Non-interactive shell, use the OPENFOAM etc/bashrc
_foamSourceBashEnv="$projectDir/etc/bashrc"
fi
[ -f "$_foamSourceBashEnv" ] || {
......@@ -160,34 +205,68 @@ fi
exit 2
}
if [ "$#" -eq 0 ]
if [ -n "$interactive" ]
then
# Source user ~/.bashrc and OpenFOAM etc/bashrc.
# 1) Can either use a tmp file, or 2) chain off to a dedicated file
# We use a dedicated file.
# Interactive shell
# -----------------
# Source ~/.bashrc and OpenFOAM etc/bashrc in one of two ways:
# 1) Generate and use a tmp file
# 2) Chain off to a dedicated file [This is what we use]
if [ -n "$_foamSettings" ]
then
# Pass preferences via the FOAM_SETTINGS mechanism
export FOAM_SETTINGS="$_foamSettings"
fi
## echo "Source with $_foamSourceBashEnv with '$FOAM_SETTINGS'" 1>&2
# Interactive shell (newer bash can use --init-file instead of --rcfile)
# Newer bash can use --init-file instead of --rcfile
exec bash --rcfile "$_foamSourceBashEnv" -i
exit $? # Safety
fi
else
# Non-interactive
# Source bashrc within a function to preserve command-line arguments
# - this will not have aliases, but working non-interactively anyhow
sourceBashrc()
{
. "$_foamSourceBashEnv" $_foamSettings
}
# Non-interactive shell
# ---------------------
# Source bashrc within a function to preserve command-line arguments
# Suppresses aliases as a side-effect, but non-interactive anyhow.
sourceBashrc()
{
. "$_foamSourceBashEnv" $_foamSettings
}
if [ -n "$_foamScriptCommand" ]
then
# A shell command
sourceBashrc
exec bash -c "$_foamScriptCommand" "$@"
exit $? # Safety
fi
# An application or a shell script
# It may actually be a script with a '#!/project-path/bin/openfoam',
# so we need to catch this to avoid infinite recursion.
if [ -f "$1" ] \
&& [ -n "$(sed -ne '1{/^#!.*\/openfoam$/p; q}' "$1" 2>/dev/null)" ]
then
# A shell script
sourceBashrc
exec bash "$@"
else
# An application
sourceBashrc
exec "$@"
fi
#------------------------------------------------------------------------------
......@@ -6,13 +6,14 @@ wmakeCheckPwd "$WM_PROJECT_DIR/src" 2>/dev/null || {
echo " Check your OpenFOAM environment and installation"
exit 1
}
[ -d "$WM_PROJECT_DIR" -a -f "$WM_PROJECT_DIR/etc/bashrc" ] || {
if [ -f "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments ]
then . "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments || \
echo "Argument parse error";
else
echo "Error (${0##*/}) : WM_PROJECT_DIR appears to be incorrect"
echo " Check your OpenFOAM environment and installation"
exit 1
}
. "$WM_PROJECT_DIR"/wmake/scripts/AllwmakeParseArguments
fi
#------------------------------------------------------------------------------
......
#!/bin/sh
# Allwmake with scan-build (clang)
command -v scan-build > /dev/null || {
exec 1>&2
echo "No scan-build found, stopping"
echo
exit 2
}
comp_cc="$(command -v "$(wmake -show-c)")"
comp_cxx="$(command -v "$(wmake -show-cxx)")"
set -x
scan-build --use-cc="$comp_cc" --use-c++="$comp_cxx" \
scan-build \
--use-cc="$(wmake -show-path-c)" \
--use-c++="$(wmake -show-path-cxx)" \
./Allwmake "$@"
#------------------------------------------------------------------------------
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -246,14 +246,14 @@ inline Foam::label Foam::HashSet<Key, Hash>::unset
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
template<class Key, class Hash>
inline bool Foam::HashSet<Key, Hash>::operator()(const Key& key) const
inline bool Foam::HashSet<Key, Hash>::operator()(const Key& key) const noexcept
{
return this->found(key);
}
template<class Key, class Hash>
inline bool Foam::HashSet<Key, Hash>::operator[](const Key& key) const
inline bool Foam::HashSet<Key, Hash>::operator[](const Key& key) const noexcept
{
return this->found(key);
}
......@@ -353,6 +353,14 @@ Foam::HashSet<Key, Hash>::operator^=(const HashSet<Key, Hash>& rhs)
}
template<class Key, class Hash>
inline Foam::HashSet<Key, Hash>&
Foam::HashSet<Key, Hash>::operator+=(const HashSet<Key, Hash>& rhs)
{
return this->operator|=(rhs);
}
template<class Key, class Hash>
inline Foam::HashSet<Key, Hash>&
Foam::HashSet<Key, Hash>::operator-=(const HashSet<Key, Hash>& rhs)
......@@ -419,9 +427,9 @@ template<class Key, class Hash>
inline typename Foam::HashSet<Key, Hash>::iterator
Foam::HashSet<Key, Hash>::begin()
{
return HashTableCore::iterator_begin<iterator>
return iterator
(
static_cast<parent_type&>(*this)
static_cast<parent_type&>(*this).begin()
);
}
......@@ -430,9 +438,9 @@ template<class Key, class Hash>
inline typename Foam::HashSet<Key, Hash>::const_iterator
Foam::HashSet<Key, Hash>::begin() const
{
return HashTableCore::iterator_cbegin<const_iterator>
return const_iterator
(
static_cast<const parent_type&>(*this)
static_cast<const parent_type&>(*this).begin()
);
}
......@@ -441,34 +449,34 @@ template<class Key, class Hash>
inline typename Foam::HashSet<Key, Hash>::const_iterator
Foam::HashSet<Key, Hash>::cbegin() const
{
return HashTableCore::iterator_cbegin<const_iterator>
return const_iterator
(
static_cast<const parent_type&>(*this)
static_cast<const parent_type&>(*this).cbegin()
);
}
template<class Key, class Hash>
inline const typename Foam::HashSet<Key, Hash>::iterator&
Foam::HashSet<Key, Hash>::end()
inline typename Foam::HashSet<Key, Hash>::iterator
Foam::HashSet<Key, Hash>::end() noexcept
{
return HashTableCore::iterator_end<iterator>();
return iterator();
}
template<class Key, class Hash>
inline const typename Foam::HashSet<Key, Hash>::const_iterator&
Foam::HashSet<Key, Hash>::end() const
inline typename Foam::HashSet<Key, Hash>::const_iterator
Foam::HashSet<Key, Hash>::end() const noexcept
{
return HashTableCore::iterator_cend<const_iterator>();
return const_iterator();
}
template<class Key, class Hash>
inline const typename Foam::HashSet<Key, Hash>::const_iterator&
Foam::HashSet<Key, Hash>::cend() const
inline constexpr typename Foam::HashSet<Key, Hash>::const_iterator
Foam::HashSet<Key, Hash>::cend() const noexcept
{
return HashTableCore::iterator_cend<const_iterator>();
return const_iterator();
}
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2019 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -73,10 +73,9 @@ Description
namespace Foam
{
// Forward declarations
// Forward Declarations
template<class T> class MinMax;
/*---------------------------------------------------------------------------*\
Class HashSet Declaration
\*---------------------------------------------------------------------------*/
......@@ -115,12 +114,24 @@ public:
// Constructors
//- Construct null with default (128) table capacity
//- Default construct with default (128) table capacity
HashSet()
:
parent_type()
{}
//- Copy construct
HashSet(const this_type& rhs)
:
parent_type(rhs)
{}
//- Move construct
HashSet(this_type&& rhs)
:
parent_type(std::move(rhs))
{}
//- Construct given initial table capacity
explicit HashSet(const label size)
:
......@@ -128,7 +139,7 @@ public:
{}
//- Construct from Istream with default table capacity
HashSet(Istream& is)
explicit HashSet(Istream& is)
:
parent_type(is)
{}
......@@ -147,18 +158,6 @@ public:
//- Construct from an initializer list of Key
HashSet(std::initializer_list<Key> list);
//- Copy construct
HashSet(const this_type& hs)
:
parent_type(hs)
{}
//- Move construct
HashSet(this_type&& hs)
:
parent_type(std::move(hs))
{}
//- Construct from the keys of another HashTable,
//- the type of values held is arbitrary.
template<class AnyType, class AnyHash>
......@@ -169,7 +168,7 @@ public:
//- Same as found() - return true if key exists in the set.
// Method name compatibility with bitSet and boolList.
bool test(const Key& key) const
bool test(const Key& key) const noexcept
{
return found(key);
}
......@@ -291,13 +290,13 @@ public:
// STL iterators
iterator begin();
const_iterator begin() const;
const_iterator cbegin() const;
inline iterator begin();
inline const_iterator begin() const;
inline const_iterator cbegin() const;
const iterator& end();
const const_iterator& end() const;
const const_iterator& cend() const;
inline iterator end() noexcept;
inline const_iterator end() const noexcept;
inline constexpr const_iterator cend() const noexcept;
// Writing
......@@ -314,10 +313,10 @@ public:
// Member Operators
//- Return true if the entry exists, same as found()
inline bool operator()(const Key& key) const;
inline bool operator()(const Key& key) const noexcept;
//- Return true if the entry exists, same as found().
inline bool operator[](const Key& key) const;
inline bool operator[](const Key& key) const noexcept;
using parent_type::operator=;
......@@ -368,13 +367,10 @@ public:
//- Only retain unique entries (xor)
this_type& operator^=(const this_type& rhs);
//- Add entries to this HashSet
inline this_type& operator+=(const this_type& rhs)
{
return this->operator|=(rhs);
}
//- Add entries to this HashSet. Same as the '|=' operator
inline this_type& operator+=(const this_type& rhs);
//- Remove entries from this HashSet
//- Remove entries from this HashSet. Uses erase()
inline this_type& operator-=(const this_type& rhs);
......@@ -403,7 +399,6 @@ public:
//- Not applicable for HashSet
template<class BinaryPredicate>
label filterEntries(const BinaryPredicate&, const bool) = delete;
};
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -105,7 +105,6 @@ template<class T> class UList;
template<class T, unsigned N> class FixedList;
template<class T, class Key, class Hash> class HashTable;
/*---------------------------------------------------------------------------*\
Class HashTable Declaration
\*---------------------------------------------------------------------------*/
......@@ -171,10 +170,17 @@ public:
//- The third template parameter, the hash index method.
typedef Hash hasher;
//- Pointer type for storing into value_type objects.
// This type is usually 'value_type*'.
typedef T* pointer;
//- Reference to the stored value_type.
// This type is usually 'value_type&'.
typedef T& reference;
//- Const pointer type for the stored value_type.
typedef const T* const_pointer;
//- Const reference to the stored value_type.
typedef const T& const_reference;
......@@ -587,10 +593,10 @@ protected:
//- True if iterator points to an entry
// This can be used directly instead of comparing to end()
inline bool good() const;
inline bool good() const noexcept;
//- True if iterator points to an entry - same as good()
inline bool found() const;
inline bool found() const noexcept;
//- The key associated with the iterator
inline const Key& key() const;
......@@ -607,11 +613,11 @@ protected:
//- Compare hash-entry element pointers.
// Independent of const/non-const access
inline bool operator==(const Iterator<true>& iter) const;
inline bool operator!=(const Iterator<true>& iter) const;
template<bool Any>
inline bool operator==(const Iterator<Any>& iter) const noexcept;
inline bool operator==(const Iterator<false>& iter) const;
inline bool operator!=(const Iterator<false>& iter) const;
template<bool Any>
inline bool operator!=(const Iterator<Any>& iter) const noexcept;
protected:
......@@ -621,11 +627,11 @@ protected:
//- The selected entry.
// MUST be the first member for easy comparison between iterators
// and for reinterpret_cast from nullObject
// and to support reinterpret_cast from nullObject
node_type* entry_;
//- The hash-table container being iterated on.
// Using a pointer allows default bitwise copy/assignment
// Uses pointer for default copy/assignment
table_type* container_;
//- Index within the hash-table data.
......@@ -636,11 +642,11 @@ protected:
// Protected Constructors
//- Construct null (end iterator)
inline Iterator();
//- Default construct (end iterator)
inline constexpr Iterator() noexcept;
//- Construct from begin of hash-table
inline Iterator(bool, table_type* tbl);
inline explicit Iterator(table_type* tbl);
//- Construct by finding key in hash table
Iterator(table_type* tbl, const Key& key);
......@@ -651,10 +657,11 @@ protected:
//- Increment to the next position
inline void increment();
//- Permit an explicit cast to the other (const/non-const) searcher
inline explicit operator const Iterator<!Const>&() const
//- Permit explicit cast to the other (const/non-const) iterator
template<bool Any>
explicit operator const Iterator<Any>&() const
{
return *reinterpret_cast<const Iterator<!Const>*>(this);
return *reinterpret_cast<const Iterator<Any>*>(this);
}
};
......@@ -680,7 +687,9 @@ public:
using key_type = this_type::key_type;
using mapped_type = this_type::mapped_type;
using value_type = this_type::value_type;
using pointer = this_type::pointer;
using reference = this_type::reference;
using const_pointer = this_type::const_pointer;
using const_reference = this_type::const_reference;
......@@ -690,7 +699,7 @@ public:
iterator() = default;
//- Copy construct from similar access type
inline explicit iterator(const Iterator<false>& iter)
explicit iterator(const Iterator<false>& iter)
:
Iterator<false>(iter)
{}
......@@ -739,10 +748,11 @@ public:
using key_type = this_type::key_type;
using mapped_type = const this_type::mapped_type;
using value_type = const this_type::value_type;
using pointer = this_type::const_pointer;
using reference = this_type::const_reference;
// Constructors
// Generated Methods
//- Default construct (end iterator)
const_iterator() = default;
......@@ -750,23 +760,21 @@ public:
//- Copy construct
const_iterator(const const_iterator&) = default;
//- Copy construct from similar access type
inline explicit const_iterator(const Iterator<true>& iter)
:
Iterator<true>(iter)
{}
//- Copy assignment
const_iterator& operator=(const const_iterator&) = default;
//- Copy construct from dissimilar access type
inline explicit const_iterator(const Iterator<false>& iter)
// Constructors
//- Copy construct from any access type
template<bool Any>
const_iterator(const Iterator<Any>& iter)
:
Iterator<true>
(
static_cast<const Iterator<true>&>(iter)
)
Iterator<true>(static_cast<const Iterator<Any>&>(iter))
{}
//- Implicit conversion from dissimilar access type
inline const_iterator(const iterator& iter)
const_iterator(const iterator& iter)
:
const_iterator(reinterpret_cast<const const_iterator&>(iter))
{}
......@@ -790,9 +798,6 @@ public:
// Assignment
//- Copy assignment
const_iterator& operator=(const const_iterator&) = default;
// Allow assign from iterator to const_iterator
const_iterator& operator=(const iterator& iter)
{
......@@ -815,10 +820,17 @@ public:
public:
using value_type = this_type::key_type;
using pointer = const Key*;
using reference = const Key&;
//- Implicit conversion
inline key_iterator_base(const Iter& iter)
//- Default construct (end iterator)
constexpr key_iterator_base() noexcept
:
Iter()
{}
//- Copy construct with implicit conversion
explicit key_iterator_base(const Iter& iter)
:
Iter(iter)
{}
......@@ -851,8 +863,7 @@ public:
//- A const iterator begin/end pair for iterating over keys
const_iterator_pair<const_key_iterator, this_type> keys() const
{
return
const_iterator_pair<const_key_iterator,this_type>(*this);
return const_iterator_pair<const_key_iterator, this_type>(*this);
}
......@@ -867,14 +878,14 @@ public:
//- const_iterator set to the beginning of the HashTable
inline const_iterator cbegin() const;
//- iterator to signal the end for any HashTable
inline const iterator& end();
//- iterator to signal the end (for any HashTable)
inline iterator end() noexcept;
//- const_iterator to signal the end for any HashTable
inline const const_iterator& end() const;
//- const_iterator to signal the end (for any HashTable)
inline const_iterator end() const noexcept;
//- const_iterator to signal the end for any HashTable
inline const const_iterator& cend() const;
//- const_iterator to signal the end (for any HashTable)
inline constexpr const_iterator cend() const noexcept;
// Writing
......
......@@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -62,12 +62,12 @@ struct HashTableCore
//- Return a canonical (power-of-two) of the requested size.
static label canonicalSize(const label requested_size);
//- Construct null
HashTableCore() = default;
//- Define template name and debug
//- Declare type-name (with debug switch)
ClassName("HashTable");
//- Default construct
HashTableCore() = default;
static_assert
(
sizeof(NullObject) >= sizeof(void*),
......@@ -75,34 +75,19 @@ struct HashTableCore
);
//- Factory method to create a non-const iterator begin
template<class IteratorType, class TableType>
inline static IteratorType iterator_begin(TableType& table);
//- Factory method to create a const iterator begin
template<class IteratorType, class TableType>
inline static IteratorType iterator_cbegin(const TableType& table);
//- Factory method to return an iterator end
// Simply reinterprets a NullObject as a hash-table iterator.
template<class IteratorType>
inline static const IteratorType& iterator_end();
//- Factory method to return an iterator cend
// Simply reinterprets a NullObject as a hash-table iterator.
template<class IteratorType>
inline static const IteratorType& iterator_cend();
//- Factory class for creating a begin/end pair for any const iterator.
template<class IteratorType, class TableType>
class const_iterator_pair
{
label size_;
const label size_;
IteratorType iter_;
public:
//- Default construct an empty pair
inline const_iterator_pair();
//- Construct begin/end pair for table
inline const_iterator_pair(const TableType& tbl);
label size() const noexcept { return size_; }
......@@ -111,8 +96,8 @@ struct HashTableCore
inline IteratorType begin() const;
inline IteratorType cbegin() const;
inline const IteratorType& end() const;
inline const IteratorType& cend() const;
inline IteratorType end() const;
inline IteratorType cend() const;
};
};
......