From 81015889f2fd9355eb3fd58570949c5b68b49c2a Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Mon, 3 Feb 2020 11:05:04 +0100 Subject: [PATCH 1/5] CONFIG: provide separate default settings for clang/gcc (fixes #1566) - the foamConfigurePaths script is quite simplistic and aggressive in what it changes. This was particularly evident when using it to change gcc/clang versions. Restructured the corresponding compiler settings to define default versions (eg, "default_gcc_version") that limits the scope of changes performed by foamConfigurePaths and makes it easier to understand if changing manually. --- bin/tools/foamConfigurePaths | 33 +++++++++++++-------------- etc/config.csh/compiler | 25 ++++++++++++++------ etc/config.csh/example/compiler | 10 ++++---- etc/config.csh/example/compiler-Gcc92 | 28 +++++++++++++++++++++++ etc/config.sh/compiler | 28 +++++++++++++++-------- etc/config.sh/example/compiler | 16 +++++-------- etc/config.sh/example/compiler-Gcc92 | 28 +++++++++++++++++++++++ 7 files changed, 121 insertions(+), 47 deletions(-) create mode 100644 etc/config.csh/example/compiler-Gcc92 create mode 100644 etc/config.sh/example/compiler-Gcc92 diff --git a/bin/tools/foamConfigurePaths b/bin/tools/foamConfigurePaths index 4352152125..b267a235e2 100755 --- a/bin/tools/foamConfigurePaths +++ b/bin/tools/foamConfigurePaths @@ -7,11 +7,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 -# . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # Script # foamConfigurePaths @@ -39,8 +38,8 @@ Basic Compiler -system NAME specify 'system' compiler to use (eg, Gcc, Icc,...) -third NAME specify 'ThirdParty' compiler to use (eg, Clang40,...) - -gcc VER specify 'gcc_version' for ThirdParty Gcc - -clang VER specify 'clang_version' for ThirdParty Clang + -gcc VER specify 'default_gcc_version' for ThirdParty Gcc + -clang VER specify 'default_clang_version' for ThirdParty Clang gmp-VERSION for ThirdParty gcc (gmp-system for system library) mpfr-VERSION for ThirdParty gcc (mpfr-system for system library) mpc-VERSION for ThirdParty gcc (mpc-system for system library) @@ -346,19 +345,19 @@ do ## Compiler ## -clang) - # Replace clang_version=... + # Replace default_clang_version=... optionValue=$(getOptionValue "$@") - replace etc/config.sh/compiler clang_version "$optionValue" - replace etc/config.csh/compiler clang_version "$optionValue" + replace etc/config.sh/compiler default_clang_version "$optionValue" + replace etc/config.csh/compiler default_clang_version "$optionValue" adjusted=true shift ;; -gcc) - # Replace gcc_version=... + # Replace default_gcc_version=... optionValue=$(getOptionValue "$@") - replace etc/config.sh/compiler gcc_version "$optionValue" - replace etc/config.csh/compiler gcc_version "$optionValue" + replace etc/config.sh/compiler default_gcc_version "$optionValue" + replace etc/config.csh/compiler default_gcc_version "$optionValue" adjusted=true shift ;; @@ -391,22 +390,22 @@ do gmp-[4-9]* | gmp-system) # gcc-related package - replace etc/config.sh/compiler gmp_version "$1" - replace etc/config.csh/compiler gmp_version "$1" + replace etc/config.sh/compiler default_gmp_version "$1" + replace etc/config.csh/compiler default_gmp_version "$1" adjusted=true ;; mpfr-[2-9]* | mpfr-system) # gcc-related package - replace etc/config.sh/compiler mpfr_version "$1" - replace etc/config.csh/compiler mpfr_version "$1" + replace etc/config.sh/compiler default_mpfr_version "$1" + replace etc/config.csh/compiler default_mpfr_version "$1" adjusted=true ;; mpc-[0-9]* | mpc-system) # gcc-related package - replace etc/config.sh/compiler mpc_version "$1" - replace etc/config.csh/compiler mpc_version "$1" + replace etc/config.sh/compiler default_mpc_version "$1" + replace etc/config.csh/compiler default_mpc_version "$1" adjusted=true ;; diff --git a/etc/config.csh/compiler b/etc/config.csh/compiler index 886dea905b..88300272a1 100644 --- a/etc/config.csh/compiler +++ b/etc/config.csh/compiler @@ -6,11 +6,10 @@ # \\/ M anipulation | #------------------------------------------------------------------------------ # Copyright (C) 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 -# . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # File # etc/config.csh/compiler @@ -24,14 +23,19 @@ switch ("$WM_COMPILER_TYPE") case ThirdParty: - # Default versions of GMP, MPFR, MPC - override as necessary + # Default versions (CLANG, GCC, GMP, MPFR, MPC) - override as necessary - set gmp_version=gmp-system - set mpfr_version=mpfr-system - set mpc_version=mpc-system + set default_clang_version=llvm-3.7.1 + set default_gcc_version=gcc-4.8.5 + + set default_gmp_version=gmp-system + set default_mpfr_version=mpfr-system + set default_mpc_version=mpc-system switch ("$WM_COMPILER") case Gcc: + set gcc_version="$default_gcc_version" + breaksw case Gcc48*: set gcc_version=gcc-4.8.5 breaksw @@ -95,7 +99,10 @@ case ThirdParty: case Gcc92*: set gcc_version=gcc-9.2.0 breaksw + case Clang: + set clang_version="$default_clang_version" + breaksw case Clang37*: set clang_version=llvm-3.7.1 breaksw @@ -126,6 +133,7 @@ case ThirdParty: case Clang90*: set clang_version=llvm-9.0.0 breaksw + default: /bin/cat << UNKNOWN_COMPILER =============================================================================== @@ -143,4 +151,7 @@ UNKNOWN_COMPILER breaksw endsw +unset default_gcc_version default_clang_version +unset default_gmp_version default_mpfr_version default_mpc_version + #------------------------------------------------------------------------------ diff --git a/etc/config.csh/example/compiler b/etc/config.csh/example/compiler index 25e7eacdde..9355dac790 100644 --- a/etc/config.csh/example/compiler +++ b/etc/config.csh/example/compiler @@ -9,15 +9,17 @@ # Copyright (C) 2017 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM, licensed under GNU General Public License -# . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # File # config.csh/example/compiler # - sourced by OpenFOAM-*/etc/config.csh/settings # # Description -# Example of fine tuning ThirdParty compiler settings for OpenFOAM +# Older example of fine tuning compiler settings for OpenFOAM +# +# The preferred mechanism is now with a "compiler-$WM_COMPILER" file +# in one of the etc/ directories. # #------------------------------------------------------------------------------ @@ -26,7 +28,7 @@ eval `$WM_PROJECT_DIR/bin/foamEtcFile -csh -config -mode=o compiler` # Modify/override compiler settings switch ("$WM_COMPILER") -case Gcc70: +case Gcc70*: set gcc_version=gcc-7.0.0 set gmp_version=gmp-6.1.2 set mpfr_version=mpfr-3.1.5 diff --git a/etc/config.csh/example/compiler-Gcc92 b/etc/config.csh/example/compiler-Gcc92 new file mode 100644 index 0000000000..9bf5baeb27 --- /dev/null +++ b/etc/config.csh/example/compiler-Gcc92 @@ -0,0 +1,28 @@ +#----------------------------------*-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. +# +# File +# config.csh/example/compiler-Gcc92 +# - sourced by OpenFOAM-*/etc/config.csh/compiler +# +# Description +# Example of fine tuning compiler settings with a hook +# +#------------------------------------------------------------------------------ + +# Modify/override compiler settings +set gcc_version=gcc-9.2.0 +set gmp_version=gmp-6.2.0 +set mpfr_version=mpfr-4.0.2 +set mpc_version=mpc-1.1.0 + +#------------------------------------------------------------------------------ diff --git a/etc/config.sh/compiler b/etc/config.sh/compiler index 41e73eeba4..36e4fda3bb 100644 --- a/etc/config.sh/compiler +++ b/etc/config.sh/compiler @@ -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 -# . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # File # etc/config.sh/compiler @@ -24,13 +23,21 @@ case "$WM_COMPILER_TYPE" in ThirdParty) - # Default versions of GMP, MPFR, MPC - override as necessary - gmp_version=gmp-system - mpfr_version=mpfr-system - mpc_version=mpc-system + # Default versions (CLANG, GCC, GMP, MPFR, MPC) - override as necessary + + default_clang_version=llvm-3.7.1 + default_gcc_version=gcc-4.8.5 + + default_gmp_version=gmp-system + default_mpfr_version=mpfr-system + default_mpc_version=mpc-system + + gmp_version="$default_gmp_version" + mpfr_version="$default_mpfr_version" + mpc_version="$default_mpc_version" case "$WM_COMPILER" in - Gcc |\ + Gcc) gcc_version="$default_gcc_version" ;; Gcc48*) gcc_version=gcc-4.8.5 ;; Gcc49*) gcc_version=gcc-4.9.4 ;; Gcc51*) gcc_version=gcc-5.1.0 ;; @@ -54,7 +61,7 @@ ThirdParty) Gcc91*) gcc_version=gcc-9.1.0 ;; Gcc92*) gcc_version=gcc-9.2.0 ;; - Clang |\ + Clang) clang_version="$default_clang_version" ;; Clang37*) clang_version=llvm-3.7.1 ;; Clang38*) clang_version=llvm-3.8.1 ;; Clang39*) clang_version=llvm-3.9.1 ;; @@ -83,4 +90,7 @@ UNKNOWN_COMPILER ;; esac +unset default_gcc_version default_clang_version +unset default_gmp_version default_mpfr_version default_mpc_version + #------------------------------------------------------------------------------ diff --git a/etc/config.sh/example/compiler b/etc/config.sh/example/compiler index f55a55b458..385ef8ae7c 100644 --- a/etc/config.sh/example/compiler +++ b/etc/config.sh/example/compiler @@ -9,15 +9,17 @@ # Copyright (C) 2017 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM, licensed under GNU General Public License -# . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # File # config.sh/example/compiler # - sourced by OpenFOAM-*/etc/config.sh/settings # # Description -# Example of fine tuning compiler versions and settings for OpenFOAM +# Older example of fine tuning compiler settings for OpenFOAM. +# +# The preferred mechanism is now with a "compiler-$WM_COMPILER" file +# in one of the etc/ directories. # #------------------------------------------------------------------------------ @@ -26,18 +28,12 @@ eval $($WM_PROJECT_DIR/bin/foamEtcFile -sh -config -mode=o compiler) # Modify/override compiler settings case "$WM_COMPILER" in -Gcc70) +Gcc70*) gcc_version=gcc-7.0.0 gmp_version=gmp-6.1.2 mpfr_version=mpfr-3.1.5 mpc_version=mpc-1.0.3 ;; -Gcc48u) - # Example of using the system GCC 4.8 in Ubuntu 15.10. Keep in mind you - # will also need to create the respective directory in "wmake/rules" - export CC='gcc-4.8' - export CXX='g++-4.8' - ;; esac #------------------------------------------------------------------------------ diff --git a/etc/config.sh/example/compiler-Gcc92 b/etc/config.sh/example/compiler-Gcc92 new file mode 100644 index 0000000000..75b4de4cfa --- /dev/null +++ b/etc/config.sh/example/compiler-Gcc92 @@ -0,0 +1,28 @@ +#----------------------------------*-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. +# +# File +# config.sh/example/compiler-Gcc92 +# - sourced by OpenFOAM-*/etc/config.sh/compiler +# +# Description +# Example of fine tuning compiler settings with a hook +# +#------------------------------------------------------------------------------ + +# Modify/override compiler settings +gcc_version=gcc-9.2.0 +gmp_version=gmp-6.2.0 +mpfr_version=mpfr-4.0.2 +mpc_version=mpc-1.1.0 + +#------------------------------------------------------------------------------ From e53419c0257f20403868ef5bb9299abd7dbe467d Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 3 Feb 2020 11:26:43 +0000 Subject: [PATCH 2/5] ENH: Pstream: use native reduce in SPDP mode. Fixes #1574. --- .../db/IOstreams/Pstreams/PstreamReduceOps.H | 44 ++++++ src/Pstream/dummy/UPstream.C | 45 ++++++ src/Pstream/mpi/UPstream.C | 133 +++++++++++++++++- 3 files changed, 221 insertions(+), 1 deletion(-) diff --git a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamReduceOps.H b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamReduceOps.H index 1df03ba933..414e9097b0 100644 --- a/src/OpenFOAM/db/IOstreams/Pstreams/PstreamReduceOps.H +++ b/src/OpenFOAM/db/IOstreams/Pstreams/PstreamReduceOps.H @@ -200,6 +200,50 @@ void reduce ); +#if defined(WM_SPDP) +void reduce +( + solveScalar& Value, + const sumOp& bop, + const int tag = Pstream::msgType(), + const label comm = UPstream::worldComm +); + +void reduce +( + solveScalar& Value, + const minOp& bop, + const int tag = Pstream::msgType(), + const label comm = UPstream::worldComm +); + +void reduce +( + Vector2D& Value, + const sumOp>& bop, + const int tag = Pstream::msgType(), + const label comm = UPstream::worldComm +); + +void sumReduce +( + solveScalar& Value, + label& Count, + const int tag = Pstream::msgType(), + const label comm = UPstream::worldComm +); + +void reduce +( + solveScalar& Value, + const sumOp& bop, + const int tag, + const label comm, + label& request +); +#endif + + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/Pstream/dummy/UPstream.C b/src/Pstream/dummy/UPstream.C index 313acad689..bf7d9af6e8 100644 --- a/src/Pstream/dummy/UPstream.C +++ b/src/Pstream/dummy/UPstream.C @@ -96,6 +96,51 @@ void Foam::reduce(scalar&, const sumOp&, const int, const label, label&) {} +#if defined(WM_SPDP) +void Foam::reduce +( + solveScalar& Value, + const sumOp& bop, + const int tag, + const label comm +) +{} +void Foam::reduce +( + solveScalar& Value, + const minOp& bop, + const int tag, + const label comm +) +{} +void Foam::reduce +( + Vector2D& Value, + const sumOp>& bop, + const int tag, + const label comm +) +{} +void Foam::sumReduce +( + solveScalar& Value, + label& Count, + const int tag, + const label comm +) +{} +void Foam::reduce +( + solveScalar& Value, + const sumOp& bop, + const int tag, + const label comm, + label& request +) +{} +#endif + + void Foam::UPstream::allToAll ( const labelUList& sendData, diff --git a/src/Pstream/mpi/UPstream.C b/src/Pstream/mpi/UPstream.C index 98fedcd537..65db848206 100644 --- a/src/Pstream/mpi/UPstream.C +++ b/src/Pstream/mpi/UPstream.C @@ -40,10 +40,15 @@ License #include #include -#if defined(WM_SP) || defined(WM_SPDP) +#if defined(WM_SP) #define MPI_SCALAR MPI_FLOAT + #define MPI_SOLVESCALAR MPI_FLOAT +#elif defined(WM_SPDP) + #define MPI_SCALAR MPI_FLOAT + #define MPI_SOLVESCALAR MPI_DOUBLE #elif defined(WM_DP) #define MPI_SCALAR MPI_DOUBLE + #define MPI_SOLVESCALAR MPI_DOUBLE #endif // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -478,6 +483,132 @@ void Foam::reduce } +#if defined(WM_SPDP) +void Foam::reduce +( + solveScalar& Value, + const sumOp& bop, + const int tag, + const label communicator +) +{ + if (UPstream::warnComm != -1 && communicator != UPstream::warnComm) + { + Pout<< "** reducing:" << Value << " with comm:" << communicator + << " warnComm:" << UPstream::warnComm + << endl; + error::printStack(Pout); + } + allReduce(Value, 1, MPI_SOLVESCALAR, MPI_SUM, bop, tag, communicator); +} + + +void Foam::reduce +( + solveScalar& Value, + const minOp& bop, + const int tag, + const label communicator +) +{ + if (UPstream::warnComm != -1 && communicator != UPstream::warnComm) + { + Pout<< "** reducing:" << Value << " with comm:" << communicator + << " warnComm:" << UPstream::warnComm + << endl; + error::printStack(Pout); + } + allReduce(Value, 1, MPI_SOLVESCALAR, MPI_MIN, bop, tag, communicator); +} + + +void Foam::reduce +( + Vector2D& Value, + const sumOp>& bop, + const int tag, + const label communicator +) +{ + if (UPstream::warnComm != -1 && communicator != UPstream::warnComm) + { + Pout<< "** reducing:" << Value << " with comm:" << communicator + << " warnComm:" << UPstream::warnComm + << endl; + error::printStack(Pout); + } + allReduce(Value, 2, MPI_SOLVESCALAR, MPI_SUM, bop, tag, communicator); +} + + +void Foam::sumReduce +( + solveScalar& Value, + label& Count, + const int tag, + const label communicator +) +{ + if (UPstream::warnComm != -1 && communicator != UPstream::warnComm) + { + Pout<< "** reducing:" << Value << " with comm:" << communicator + << " warnComm:" << UPstream::warnComm + << endl; + error::printStack(Pout); + } + Vector2D twoScalars(Value, solveScalar(Count)); + reduce(twoScalars, sumOp>(), tag, communicator); + + Value = twoScalars.x(); + Count = twoScalars.y(); +} + + +void Foam::reduce +( + solveScalar& Value, + const sumOp& bop, + const int tag, + const label communicator, + label& requestID +) +{ +#ifdef MPIX_COMM_TYPE_SHARED + // Assume mpich2 with non-blocking collectives extensions. Once mpi3 + // is available this will change. + MPI_Request request; + solveScalar v = Value; + MPIX_Ireduce + ( + &v, + &Value, + 1, + MPI_SOLVESCALAR, + MPI_SUM, + 0, //root + PstreamGlobals::MPICommunicators_[communicator], + &request + ); + + requestID = PstreamGlobals::outstandingRequests_.size(); + PstreamGlobals::outstandingRequests_.append(request); + + if (UPstream::debug) + { + Pout<< "UPstream::allocateRequest for non-blocking reduce" + << " : request:" << requestID + << endl; + } +#else + // Non-blocking not yet implemented in mpi + reduce(Value, bop, tag, communicator); + requestID = -1; +#endif +} +#endif + + + void Foam::UPstream::allToAll ( const labelUList& sendData, From a100b496068824eab8c0b0d5f6049af5eb7854b1 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 5 Feb 2020 10:24:15 +0100 Subject: [PATCH 3/5] BUG: csh ignores additional parameters (fixes #1582) --- etc/config.csh/setup | 7 +++---- etc/cshrc | 7 +++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/etc/config.csh/setup b/etc/config.csh/setup index 51a92cd054..ecdea3b40f 100644 --- a/etc/config.csh/setup +++ b/etc/config.csh/setup @@ -5,11 +5,10 @@ # \\ / A nd | www.openfoam.com # \\/ M anipulation | #------------------------------------------------------------------------------ -# Copyright (C) 2018-2019 OpenCFD Ltd. +# Copyright (C) 2018-2020 OpenCFD Ltd. #------------------------------------------------------------------------------ # License -# This file is part of OpenFOAM, licensed under GNU General Public License -# . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # File # etc/config.csh/setup @@ -89,7 +88,7 @@ endif # Capture and evaluate any command-line parameters # These can be used to set/unset values, specify additional files etc. -setenv FOAM_SETTINGS "${*}" +setenv FOAM_SETTINGS "$argv[*]" while ( $#argv > 0 ) switch ($argv[1]) diff --git a/etc/cshrc b/etc/cshrc index 91dcace4a6..86fb8bb6cf 100644 --- a/etc/cshrc +++ b/etc/cshrc @@ -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 -# . +# This file is part of OpenFOAM, distributed under GPL-3.0-or-later. # # File # etc/cshrc @@ -176,7 +175,7 @@ endif # Finalize setup of OpenFOAM environment if ( -d "$WM_PROJECT_DIR" ) then if ($?FOAM_VERBOSE && $?prompt) echo "source $WM_PROJECT_DIR/etc/config.csh/setup" - source "$WM_PROJECT_DIR/etc/config.csh/setup" "${*}" + source "$WM_PROJECT_DIR/etc/config.csh/setup" $argv[*] else echo "Error: did not locate installation path for $WM_PROJECT-$WM_PROJECT_VERSION" echo "No directory: $WM_PROJECT_DIR" From 49e63378f82863f1fc56c5c6b4f0e1856b2035e9 Mon Sep 17 00:00:00 2001 From: Andrew Heather <> Date: Mon, 10 Feb 2020 11:44:20 +0000 Subject: [PATCH 4/5] TUT: corrected link to online case. Fixes #1584 --- .../incompressible/pimpleFoam/LES/surfaceMountedCube/README | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tutorials/incompressible/pimpleFoam/LES/surfaceMountedCube/README b/tutorials/incompressible/pimpleFoam/LES/surfaceMountedCube/README index f2d6bff7c5..dbb1ccc0e4 100644 --- a/tutorials/incompressible/pimpleFoam/LES/surfaceMountedCube/README +++ b/tutorials/incompressible/pimpleFoam/LES/surfaceMountedCube/README @@ -13,5 +13,4 @@ Eddy Simulation (IDDES) model For further details please visit: - openfoam.com/documentation/cpp-guide/html/verification-validation-turbulent-surface-mounted-cube.html - + https://www.openfoam.com/documentation/guides/latest/doc/verification-validation-turbulent-surface-mounted-cube.html From ff19bedbc3221036206b6a6cf4cfaf789586cbde Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 12 Feb 2020 16:52:17 +0000 Subject: [PATCH 5/5] BUG: SPDP mode: guaranteeing initial value. Fixes #1590. In differing precisions the PrecisionAdaptor will copy the input array element by element and this can trigger NaN detection. --- .../primitiveMesh/primitiveMeshCellCentresAndVols.C | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellCentresAndVols.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellCentresAndVols.C index c7d4b1bd05..70c9afd550 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellCentresAndVols.C +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshCellCentresAndVols.C @@ -82,15 +82,18 @@ void Foam::primitiveMesh::makeCellCentresAndVols { typedef Vector solveVector; + // Clear the fields for accumulation. Note1: we're doing this before + // any precision conversion since this might complain about illegal numbers. + // Note2: zero is a special value which is perfectly converted into zero + // in the new precision + cellCtrs_s = Zero; + cellVols_s = 0.0; + PrecisionAdaptor tcellCtrs(cellCtrs_s); Field& cellCtrs = tcellCtrs.ref(); PrecisionAdaptor tcellVols(cellVols_s); Field& cellVols = tcellVols.ref(); - // Clear the fields for accumulation - cellCtrs = Zero; - cellVols = 0.0; - const labelList& own = faceOwner(); const labelList& nei = faceNeighbour();