From fd6695d3298d5f8ab96b675150a84f4e026221fe Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 9 Mar 2011 08:45:28 +0100 Subject: [PATCH 1/7] ENH: move WM_ARCH details into settings.csh, settings.sh --- etc/bashrc | 93 ----------------------------------------------- etc/cshrc | 94 ------------------------------------------------ etc/settings.csh | 94 ++++++++++++++++++++++++++++++++++++++++++++++++ etc/settings.sh | 92 +++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 186 insertions(+), 187 deletions(-) diff --git a/etc/bashrc b/etc/bashrc index 310d5fe00d..b2c33f3da0 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -169,99 +169,6 @@ _foamSource `$WM_PROJECT_DIR/bin/foamEtcFile prefs.sh` export FOAM_SETTINGS="$@" _foamEval $@ - -# Detect system type and set environment variables appropriately -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -export WM_ARCH=`uname -s` - -case $WM_ARCH in -Linux) - WM_ARCH=linux - - # compiler specifics - case `uname -m` in - i686) - ;; - - x86_64) - case "$WM_ARCH_OPTION" in - 32) - export WM_COMPILER_ARCH='-64' - export WM_CC='gcc' - export WM_CXX='g++' - export WM_CFLAGS='-m32 -fPIC' - export WM_CXXFLAGS='-m32 -fPIC' - export WM_LDFLAGS='-m32' - ;; - 64) - WM_ARCH=linux64 - export WM_COMPILER_LIB_ARCH=64 - export WM_CC='gcc' - export WM_CXX='g++' - export WM_CFLAGS='-m64 -fPIC' - export WM_CXXFLAGS='-m64 -fPIC' - export WM_LDFLAGS='-m64' - ;; - *) - echo "Unknown WM_ARCH_OPTION '$WM_ARCH_OPTION', should be 32 or 64" - ;; - esac - ;; - - ia64) - WM_ARCH=linuxIA64 - export WM_COMPILER=I64 - ;; - - mips64) - WM_ARCH=SiCortex64 - WM_MPLIB=MPI - export WM_COMPILER_LIB_ARCH=64 - export WM_CC='gcc' - export WM_CXX='g++' - export WM_CFLAGS='-mabi=64 -fPIC' - export WM_CXXFLAGS='-mabi=64 -fPIC' - export WM_LDFLAGS='-mabi=64 -G0' - ;; - - ppc64) - WM_ARCH=linuxPPC64 - export WM_COMPILER_LIB_ARCH=64 - export WM_CC='gcc' - export WM_CXX='g++' - export WM_CFLAGS='-m64 -fPIC' - export WM_CXXFLAGS='-m64 -fPIC' - export WM_LDFLAGS='-m64' - ;; - - *) - echo Unknown processor type `uname -m` for Linux - ;; - esac - ;; - -SunOS) - WM_ARCH=SunOS64 - WM_MPLIB=FJMPI - export WM_COMPILER_LIB_ARCH=64 - export WM_CC='gcc' - export WM_CXX='g++' - export WM_CFLAGS='-mabi=64 -fPIC' - export WM_CXXFLAGS='-mabi=64 -fPIC' - export WM_LDFLAGS='-mabi=64 -G0' - ;; - -*) # an unsupported operating system - cat < 0 ) end -# Detect system type and set environment variables -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -setenv WM_ARCH `uname -s` - -switch ($WM_ARCH) -case Linux: - setenv WM_ARCH linux - - switch (`uname -m`) - case i686: - breaksw - - case x86_64: - switch ($WM_ARCH_OPTION) - case 32: - setenv WM_COMPILER_ARCH '-64' - setenv WM_CC 'gcc' - setenv WM_CXX 'g++' - setenv WM_CFLAGS '-m32 -fPIC' - setenv WM_CXXFLAGS '-m32 -fPIC' - setenv WM_LDFLAGS '-m32' - breaksw - - case 64: - setenv WM_ARCH linux64 - setenv WM_COMPILER_LIB_ARCH 64 - setenv WM_CC 'gcc' - setenv WM_CXX 'g++' - setenv WM_CFLAGS '-m64 -fPIC' - setenv WM_CXXFLAGS '-m64 -fPIC' - setenv WM_LDFLAGS '-m64' - breaksw - - default: - echo "Unknown WM_ARCH_OPTION '$WM_ARCH_OPTION', should be 32 or 64" - breaksw - - endsw - breaksw - - case ia64: - setenv WM_ARCH linuxIA64 - setenv WM_COMPILER I64 - breaksw - - case mips64: - setenv WM_ARCH SiCortex64 - setenv WM_MPLIB MPI - setenv WM_COMPILER_LIB_ARCH 64 - setenv WM_CC 'gcc' - setenv WM_CXX 'g++' - setenv WM_CFLAGS '-mabi=64 -fPIC' - setenv WM_CXXFLAGS '-mabi=64 -fPIC' - setenv WM_LDFLAGS '-mabi=64 -G0' - breaksw - - case ppc64: - setenv WM_ARCH linuxPPC64 - setenv WM_COMPILER_LIB_ARCH 64 - setenv WM_CC 'gcc' - setenv WM_CXX 'g++' - setenv WM_CFLAGS '-m64 -fPIC' - setenv WM_CXXFLAGS '-m64 -fPIC' - setenv WM_LDFLAGS '-m64' - breaksw - - default: - echo Unknown processor type `uname -m` for Linux - breaksw - - endsw - breaksw - -case SunOS: - setenv WM_ARCH SunOS64 - setenv WM_MPLIB FJMPI - setenv WM_COMPILER_LIB_ARCH 64 - setenv WM_CC 'gcc' - setenv WM_CXX 'g++' - setenv WM_CFLAGS '-mabi=64 -fPIC' - setenv WM_CXXFLAGS '-mabi=64 -fPIC' - setenv WM_LDFLAGS '-mabi=64 -G0' - breaksw - -default: - echo - echo "Your '$WM_ARCH' operating system is not supported by this release" - echo "of OpenFOAM. For further assistance, please contact www.OpenFOAM.com" - echo - breaksw - -endsw - - # Clean standard environment variables (PATH, LD_LIBRARY_PATH, MANPATH) # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ set foamClean=$WM_PROJECT_DIR/bin/foamCleanPath diff --git a/etc/settings.csh b/etc/settings.csh index 76beaadb51..5a6b6c273a 100644 --- a/etc/settings.csh +++ b/etc/settings.csh @@ -37,6 +37,100 @@ alias _foamAddLib 'setenv LD_LIBRARY_PATH \!*\:${LD_LIBRARY_PATH}' # prefix to MANPATH alias _foamAddMan 'setenv MANPATH \!*\:${MANPATH}' +#------------------------------------------------------------------------------ +# Set environment variables according to system type +setenv WM_ARCH `uname -s` + +switch ($WM_ARCH) +case Linux: + setenv WM_ARCH linux + + switch (`uname -m`) + case i686: + breaksw + + case x86_64: + switch ($WM_ARCH_OPTION) + case 32: + setenv WM_COMPILER_ARCH '-64' + setenv WM_CC 'gcc' + setenv WM_CXX 'g++' + setenv WM_CFLAGS '-m32 -fPIC' + setenv WM_CXXFLAGS '-m32 -fPIC' + setenv WM_LDFLAGS '-m32' + breaksw + + case 64: + setenv WM_ARCH linux64 + setenv WM_COMPILER_LIB_ARCH 64 + setenv WM_CC 'gcc' + setenv WM_CXX 'g++' + setenv WM_CFLAGS '-m64 -fPIC' + setenv WM_CXXFLAGS '-m64 -fPIC' + setenv WM_LDFLAGS '-m64' + breaksw + + default: + echo "Unknown WM_ARCH_OPTION '$WM_ARCH_OPTION', should be 32 or 64" + breaksw + + endsw + breaksw + + case ia64: + setenv WM_ARCH linuxIA64 + setenv WM_COMPILER I64 + breaksw + + case mips64: + setenv WM_ARCH SiCortex64 + setenv WM_MPLIB MPI + setenv WM_COMPILER_LIB_ARCH 64 + setenv WM_CC 'gcc' + setenv WM_CXX 'g++' + setenv WM_CFLAGS '-mabi=64 -fPIC' + setenv WM_CXXFLAGS '-mabi=64 -fPIC' + setenv WM_LDFLAGS '-mabi=64 -G0' + breaksw + + case ppc64: + setenv WM_ARCH linuxPPC64 + setenv WM_COMPILER_LIB_ARCH 64 + setenv WM_CC 'gcc' + setenv WM_CXX 'g++' + setenv WM_CFLAGS '-m64 -fPIC' + setenv WM_CXXFLAGS '-m64 -fPIC' + setenv WM_LDFLAGS '-m64' + breaksw + + default: + echo Unknown processor type `uname -m` for Linux + breaksw + + endsw + breaksw + +case SunOS: + setenv WM_ARCH SunOS64 + setenv WM_MPLIB FJMPI + setenv WM_COMPILER_LIB_ARCH 64 + setenv WM_CC 'gcc' + setenv WM_CXX 'g++' + setenv WM_CFLAGS '-mabi=64 -fPIC' + setenv WM_CXXFLAGS '-mabi=64 -fPIC' + setenv WM_LDFLAGS '-mabi=64 -G0' + breaksw + +default: + echo + echo "Your '$WM_ARCH' operating system is not supported by this release" + echo "of OpenFOAM. For further assistance, please contact www.OpenFOAM.com" + echo + breaksw + +endsw + + #------------------------------------------------------------------------------ # location of the jobControl directory diff --git a/etc/settings.sh b/etc/settings.sh index edbabe3cb6..e86de7de25 100644 --- a/etc/settings.sh +++ b/etc/settings.sh @@ -60,6 +60,98 @@ _foamAddMan() done } +#------------------------------------------------------------------------------ +# Set environment variables according to system type +export WM_ARCH=`uname -s` + +case "$WM_ARCH" in +Linux) + WM_ARCH=linux + + # compiler specifics + case `uname -m` in + i686) + ;; + + x86_64) + case "$WM_ARCH_OPTION" in + 32) + export WM_COMPILER_ARCH='-64' + export WM_CC='gcc' + export WM_CXX='g++' + export WM_CFLAGS='-m32 -fPIC' + export WM_CXXFLAGS='-m32 -fPIC' + export WM_LDFLAGS='-m32' + ;; + 64) + WM_ARCH=linux64 + export WM_COMPILER_LIB_ARCH=64 + export WM_CC='gcc' + export WM_CXX='g++' + export WM_CFLAGS='-m64 -fPIC' + export WM_CXXFLAGS='-m64 -fPIC' + export WM_LDFLAGS='-m64' + ;; + *) + echo "Unknown WM_ARCH_OPTION '$WM_ARCH_OPTION', should be 32 or 64" + ;; + esac + ;; + + ia64) + WM_ARCH=linuxIA64 + export WM_COMPILER=I64 + ;; + + mips64) + WM_ARCH=SiCortex64 + WM_MPLIB=MPI + export WM_COMPILER_LIB_ARCH=64 + export WM_CC='gcc' + export WM_CXX='g++' + export WM_CFLAGS='-mabi=64 -fPIC' + export WM_CXXFLAGS='-mabi=64 -fPIC' + export WM_LDFLAGS='-mabi=64 -G0' + ;; + + ppc64) + WM_ARCH=linuxPPC64 + export WM_COMPILER_LIB_ARCH=64 + export WM_CC='gcc' + export WM_CXX='g++' + export WM_CFLAGS='-m64 -fPIC' + export WM_CXXFLAGS='-m64 -fPIC' + export WM_LDFLAGS='-m64' + ;; + + *) + echo Unknown processor type `uname -m` for Linux + ;; + esac + ;; + +SunOS) + WM_ARCH=SunOS64 + WM_MPLIB=FJMPI + export WM_COMPILER_LIB_ARCH=64 + export WM_CC='gcc' + export WM_CXX='g++' + export WM_CFLAGS='-mabi=64 -fPIC' + export WM_CXXFLAGS='-mabi=64 -fPIC' + export WM_LDFLAGS='-mabi=64 -G0' + ;; + +*) # an unsupported operating system + cat < Date: Fri, 11 Mar 2011 09:08:45 +0100 Subject: [PATCH 2/7] STYLE: more constness on const char* values --- .../dynamicCode/fixedValueFvPatchScalarFieldTemplate.C | 3 ++- .../dynamicCode/fixedValueFvPatchScalarFieldTemplate.H | 2 +- src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.C | 4 ++-- src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.H | 4 ++-- src/OpenFOAM/global/constants/atomic/atomicConstants.C | 7 ++----- src/OpenFOAM/global/constants/atomic/atomicConstants.H | 7 ++----- .../constants/electromagnetic/electromagneticConstants.C | 6 ++---- .../constants/electromagnetic/electromagneticConstants.H | 6 ++---- .../global/constants/mathematical/mathematicalConstants.H | 4 ++-- .../constants/physicoChemical/physicoChemicalConstants.C | 4 ++-- .../constants/physicoChemical/physicoChemicalConstants.H | 8 ++------ .../global/constants/universal/universalConstants.C | 5 ++--- .../global/constants/universal/universalConstants.H | 5 ++--- src/conversion/meshReader/starcd/STARCDMeshReader.C | 6 +++--- src/conversion/meshReader/starcd/STARCDMeshReader.H | 6 +++--- 15 files changed, 31 insertions(+), 46 deletions(-) diff --git a/etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.C b/etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.C index 280ee4810d..d41c4162e6 100644 --- a/etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.C +++ b/etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.C @@ -76,7 +76,8 @@ makeRemovablePatchTypeField ); -const char* ${typeName}FixedValueFvPatchScalarField::SHA1sum = "${SHA1sum}"; +const char* const ${typeName}FixedValueFvPatchScalarField::SHA1sum = + "${SHA1sum}"; // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // diff --git a/etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.H b/etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.H index 742a9ca01b..9fe2d88f70 100644 --- a/etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.H +++ b/etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.H @@ -56,7 +56,7 @@ class ${typeName}FixedValueFvPatchScalarField public: //- Information about the SHA1 of the code itself - static const char* SHA1sum; + static const char* const SHA1sum; //- Runtime type information TypeName("${typeName}"); diff --git a/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.C b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.C index 00b94cb426..f09ddd297f 100644 --- a/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.C +++ b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.C @@ -48,10 +48,10 @@ const Foam::word Foam::dynamicCode::codeTemplateEnvName const Foam::fileName Foam::dynamicCode::codeTemplateDirName = "codeTemplates/dynamicCode"; -const char* Foam::dynamicCode::libTargetRoot = +const char* const Foam::dynamicCode::libTargetRoot = "LIB = $(PWD)/../platforms/$(WM_OPTIONS)/lib/lib"; -const char* Foam::dynamicCode::topDirName = "dynamicCode"; +const char* const Foam::dynamicCode::topDirName = "dynamicCode"; // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // diff --git a/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.H b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.H index 75764aca3a..0d7a3fb969 100644 --- a/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.H +++ b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.H @@ -106,10 +106,10 @@ protected: // Static data members //- Root of the LIB target for Make/files - static const char* libTargetRoot; + static const char* const libTargetRoot; //- Top-level directory name for copy/compiling - static const char* topDirName; + static const char* const topDirName; // Protected Member Functions diff --git a/src/OpenFOAM/global/constants/atomic/atomicConstants.C b/src/OpenFOAM/global/constants/atomic/atomicConstants.C index 027ebc7367..95cb4bfdcd 100644 --- a/src/OpenFOAM/global/constants/atomic/atomicConstants.C +++ b/src/OpenFOAM/global/constants/atomic/atomicConstants.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -32,7 +32,7 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -const char* Foam::constant::atomic::group = "atomic"; +const char* const Foam::constant::atomic::group = "atomic"; const Foam::dimensionedScalar Foam::constant::atomic::alpha @@ -129,6 +129,3 @@ const Foam::dimensionedScalar Foam::constant::atomic::Eh // ************************************************************************* // - - - diff --git a/src/OpenFOAM/global/constants/atomic/atomicConstants.H b/src/OpenFOAM/global/constants/atomic/atomicConstants.H index b49c57822c..2758a7d8b5 100644 --- a/src/OpenFOAM/global/constants/atomic/atomicConstants.H +++ b/src/OpenFOAM/global/constants/atomic/atomicConstants.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -46,7 +46,7 @@ namespace atomic // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // //- Group name for atomic constants - extern const char* group; + extern const char* const group; //- Fine-structure constant: default SI units: [] extern const dimensionedScalar alpha; @@ -75,6 +75,3 @@ namespace atomic #endif // ************************************************************************* // - - - diff --git a/src/OpenFOAM/global/constants/electromagnetic/electromagneticConstants.C b/src/OpenFOAM/global/constants/electromagnetic/electromagneticConstants.C index 69040f77ee..db1e4e6264 100644 --- a/src/OpenFOAM/global/constants/electromagnetic/electromagneticConstants.C +++ b/src/OpenFOAM/global/constants/electromagnetic/electromagneticConstants.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -32,7 +32,7 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -const char* Foam::constant::electromagnetic::group = "electromagnetic"; +const char* const Foam::constant::electromagnetic::group = "electromagnetic"; const Foam::dimensionedScalar Foam::constant::electromagnetic::mu0 @@ -164,5 +164,3 @@ const Foam::dimensionedScalar Foam::constant::electromagnetic::RK // ************************************************************************* // - - diff --git a/src/OpenFOAM/global/constants/electromagnetic/electromagneticConstants.H b/src/OpenFOAM/global/constants/electromagnetic/electromagneticConstants.H index 2dee7e423f..4646cb86a5 100644 --- a/src/OpenFOAM/global/constants/electromagnetic/electromagneticConstants.H +++ b/src/OpenFOAM/global/constants/electromagnetic/electromagneticConstants.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -46,7 +46,7 @@ namespace electromagnetic // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // //- Group name for electromagnetic constants - extern const char* group; + extern const char* const group; //- Magnetic constant/permeability of free space: default SI units: [H/m] extern const dimensionedScalar mu0; @@ -84,5 +84,3 @@ namespace electromagnetic #endif // ************************************************************************* // - - diff --git a/src/OpenFOAM/global/constants/mathematical/mathematicalConstants.H b/src/OpenFOAM/global/constants/mathematical/mathematicalConstants.H index 3f29fd34d7..68ba1248ee 100644 --- a/src/OpenFOAM/global/constants/mathematical/mathematicalConstants.H +++ b/src/OpenFOAM/global/constants/mathematical/mathematicalConstants.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -45,7 +45,7 @@ namespace mathematical // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - static word group = "mathematical"; + static const char* const group = "mathematical"; const scalar e(M_E); const scalar pi(M_PI); diff --git a/src/OpenFOAM/global/constants/physicoChemical/physicoChemicalConstants.C b/src/OpenFOAM/global/constants/physicoChemical/physicoChemicalConstants.C index 8269c1d9a8..9376e9bccf 100644 --- a/src/OpenFOAM/global/constants/physicoChemical/physicoChemicalConstants.C +++ b/src/OpenFOAM/global/constants/physicoChemical/physicoChemicalConstants.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -32,7 +32,7 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -const char* Foam::constant::physicoChemical::group = "physicoChemical"; +const char* const Foam::constant::physicoChemical::group = "physicoChemical"; const Foam::dimensionedScalar Foam::constant::physicoChemical::R diff --git a/src/OpenFOAM/global/constants/physicoChemical/physicoChemicalConstants.H b/src/OpenFOAM/global/constants/physicoChemical/physicoChemicalConstants.H index 13f61d7352..22dada66a9 100644 --- a/src/OpenFOAM/global/constants/physicoChemical/physicoChemicalConstants.H +++ b/src/OpenFOAM/global/constants/physicoChemical/physicoChemicalConstants.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -46,7 +46,7 @@ namespace physicoChemical // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // //- Group name for physico-chemical constants - extern const char* group; + extern const char* const group; //- Universal gas constant: default SI units: [J/mol/K] extern const dimensionedScalar R; @@ -78,7 +78,3 @@ namespace physicoChemical #endif // ************************************************************************* // - - - - diff --git a/src/OpenFOAM/global/constants/universal/universalConstants.C b/src/OpenFOAM/global/constants/universal/universalConstants.C index e2139daae6..c7886cbefd 100644 --- a/src/OpenFOAM/global/constants/universal/universalConstants.C +++ b/src/OpenFOAM/global/constants/universal/universalConstants.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -30,7 +30,7 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -const char* Foam::constant::universal::group = "universal"; +const char* const Foam::constant::universal::group = "universal"; const Foam::dimensionedScalar Foam::constant::universal::hr @@ -49,4 +49,3 @@ const Foam::dimensionedScalar Foam::constant::universal::hr // ************************************************************************* // - diff --git a/src/OpenFOAM/global/constants/universal/universalConstants.H b/src/OpenFOAM/global/constants/universal/universalConstants.H index acf374bad4..014c5f7f02 100644 --- a/src/OpenFOAM/global/constants/universal/universalConstants.H +++ b/src/OpenFOAM/global/constants/universal/universalConstants.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -46,7 +46,7 @@ namespace universal // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // //- Group name for universal constants - extern const char* group; + extern const char* const group; //- Reduced Planck constant: default SI units: [J/s] extern const dimensionedScalar hr; @@ -62,4 +62,3 @@ namespace universal #endif // ************************************************************************* // - diff --git a/src/conversion/meshReader/starcd/STARCDMeshReader.C b/src/conversion/meshReader/starcd/STARCDMeshReader.C index 39073a7b7e..789a87efd9 100644 --- a/src/conversion/meshReader/starcd/STARCDMeshReader.C +++ b/src/conversion/meshReader/starcd/STARCDMeshReader.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -35,10 +35,10 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -const char* Foam::meshReaders::STARCD::defaultBoundaryName = +const char* const Foam::meshReaders::STARCD::defaultBoundaryName = "Default_Boundary_Region"; -const char* Foam::meshReaders::STARCD::defaultSolidBoundaryName = +const char* const Foam::meshReaders::STARCD::defaultSolidBoundaryName = "Default_Boundary_Solid"; bool Foam::meshReaders::STARCD::keepSolids = false; diff --git a/src/conversion/meshReader/starcd/STARCDMeshReader.H b/src/conversion/meshReader/starcd/STARCDMeshReader.H index 3d33dba557..b18647fc12 100644 --- a/src/conversion/meshReader/starcd/STARCDMeshReader.H +++ b/src/conversion/meshReader/starcd/STARCDMeshReader.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -68,8 +68,8 @@ protected: // Protected Data - static const char* defaultBoundaryName; - static const char* defaultSolidBoundaryName; + static const char* const defaultBoundaryName; + static const char* const defaultSolidBoundaryName; //- Face addressing from pro-STAR faces -> OpenFOAM faces static const int starToFoamFaceAddr[4][6]; From 7a0d3ebd64b5cbcbf10b94d8387f892418986c07 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 11 Mar 2011 17:28:51 +0100 Subject: [PATCH 3/7] ENH: refactor fixedValueFvPatchFieldTemplate - can be reused for other (vector, tensor, ...) field types --- ...ate.C => fixedValueFvPatchFieldTemplate.C} | 60 ++++++++-------- ...ate.H => fixedValueFvPatchFieldTemplate.H} | 72 +++++++++---------- .../codedFixedValueFvPatchScalarField.C | 39 ++++++++-- .../codedFixedValueFvPatchScalarField.H | 5 ++ 4 files changed, 100 insertions(+), 76 deletions(-) rename etc/codeTemplates/dynamicCode/{fixedValueFvPatchScalarFieldTemplate.C => fixedValueFvPatchFieldTemplate.C} (71%) rename etc/codeTemplates/dynamicCode/{fixedValueFvPatchScalarFieldTemplate.H => fixedValueFvPatchFieldTemplate.H} (60%) diff --git a/etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.C b/etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.C similarity index 71% rename from etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.C rename to etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.C index d41c4162e6..0d110e7469 100644 --- a/etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.C +++ b/etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.C @@ -23,7 +23,7 @@ License \*---------------------------------------------------------------------------*/ -#include "fixedValueFvPatchScalarFieldTemplate.H" +#include "fixedValueFvPatchFieldTemplate.H" #include "addToRunTimeSelectionTable.H" #include "fvPatchFieldMapper.H" #include "volFields.H" @@ -71,25 +71,25 @@ extern "C" makeRemovablePatchTypeField ( - fvPatchScalarField, - ${typeName}FixedValueFvPatchScalarField + fvPatch${FieldType}, + ${typeName}FixedValueFvPatch${FieldType} ); -const char* const ${typeName}FixedValueFvPatchScalarField::SHA1sum = +const char* const ${typeName}FixedValueFvPatch${FieldType}::SHA1sum = "${SHA1sum}"; // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -${typeName}FixedValueFvPatchScalarField:: -${typeName}FixedValueFvPatchScalarField +${typeName}FixedValueFvPatch${FieldType}:: +${typeName}FixedValueFvPatch${FieldType} ( const fvPatch& p, - const DimensionedField& iF + const DimensionedField<${TemplateType}, volMesh>& iF ) : - fixedValueFvPatchScalarField(p, iF) + fixedValueFvPatchField<${TemplateType}>(p, iF) { if (${verbose:-false}) { @@ -99,16 +99,16 @@ ${typeName}FixedValueFvPatchScalarField } -${typeName}FixedValueFvPatchScalarField:: -${typeName}FixedValueFvPatchScalarField +${typeName}FixedValueFvPatch${FieldType}:: +${typeName}FixedValueFvPatch${FieldType} ( - const ${typeName}FixedValueFvPatchScalarField& ptf, + const ${typeName}FixedValueFvPatch${FieldType}& ptf, const fvPatch& p, - const DimensionedField& iF, + const DimensionedField<${TemplateType}, volMesh>& iF, const fvPatchFieldMapper& mapper ) : - fixedValueFvPatchScalarField(ptf, p, iF, mapper) + fixedValueFvPatchField<${TemplateType}>(ptf, p, iF, mapper) { if (${verbose:-false}) { @@ -118,15 +118,15 @@ ${typeName}FixedValueFvPatchScalarField } -${typeName}FixedValueFvPatchScalarField:: -${typeName}FixedValueFvPatchScalarField +${typeName}FixedValueFvPatch${FieldType}:: +${typeName}FixedValueFvPatch${FieldType} ( const fvPatch& p, - const DimensionedField& iF, + const DimensionedField<${TemplateType}, volMesh>& iF, const dictionary& dict ) : - fixedValueFvPatchScalarField(p, iF, dict) + fixedValueFvPatchField<${TemplateType}>(p, iF, dict) { if (${verbose:-false}) { @@ -136,13 +136,13 @@ ${typeName}FixedValueFvPatchScalarField } -${typeName}FixedValueFvPatchScalarField:: -${typeName}FixedValueFvPatchScalarField +${typeName}FixedValueFvPatch${FieldType}:: +${typeName}FixedValueFvPatch${FieldType} ( - const ${typeName}FixedValueFvPatchScalarField& ptf + const ${typeName}FixedValueFvPatch${FieldType}& ptf ) : - fixedValueFvPatchScalarField(ptf) + fixedValueFvPatchField<${TemplateType}>(ptf) { if (${verbose:-false}) { @@ -152,14 +152,14 @@ ${typeName}FixedValueFvPatchScalarField } -${typeName}FixedValueFvPatchScalarField:: -${typeName}FixedValueFvPatchScalarField +${typeName}FixedValueFvPatch${FieldType}:: +${typeName}FixedValueFvPatch${FieldType} ( - const ${typeName}FixedValueFvPatchScalarField& ptf, - const DimensionedField& iF + const ${typeName}FixedValueFvPatch${FieldType}& ptf, + const DimensionedField<${TemplateType}, volMesh>& iF ) : - fixedValueFvPatchScalarField(ptf, iF) + fixedValueFvPatchField<${TemplateType}>(ptf, iF) { if (${verbose:-false}) { @@ -171,8 +171,8 @@ ${typeName}FixedValueFvPatchScalarField // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -${typeName}FixedValueFvPatchScalarField:: -~${typeName}FixedValueFvPatchScalarField() +${typeName}FixedValueFvPatch${FieldType}:: +~${typeName}FixedValueFvPatch${FieldType}() { if (${verbose:-false}) { @@ -183,7 +183,7 @@ ${typeName}FixedValueFvPatchScalarField:: // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void ${typeName}FixedValueFvPatchScalarField::updateCoeffs() +void ${typeName}FixedValueFvPatch${FieldType}::updateCoeffs() { if (this->updated()) { @@ -199,7 +199,7 @@ void ${typeName}FixedValueFvPatchScalarField::updateCoeffs() ${code} //}}} end code - fixedValueFvPatchScalarField::updateCoeffs(); + this->fixedValueFvPatchField<${TemplateType}>::updateCoeffs(); } diff --git a/etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.H b/etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.H similarity index 60% rename from etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.H rename to etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.H index 9fe2d88f70..5031d042c5 100644 --- a/etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.H +++ b/etc/codeTemplates/dynamicCode/fixedValueFvPatchFieldTemplate.H @@ -21,21 +21,19 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . -Class - Foam::fixedValueFvPatchScalarFieldTemplate - Description - Template for use with onTheFlyFixedValue. - - fixedValueFvPatchScalarField + Template for use with dynamic code generation of a + fixedValue fvPatchField. + - without state SourceFiles - fixedValueFvPatchScalarFieldTemplate.C + fixedValueFvPatchFieldTemplate.C \*---------------------------------------------------------------------------*/ -#ifndef fixedValueFvPatchScalarFieldTemplate_H -#define fixedValueFvPatchScalarFieldTemplate_H +#ifndef fixedValueFvPatchTemplate${FieldType}_H +#define fixedValueFvPatchTemplate${FieldType}_H #include "fixedValueFvPatchFields.H" @@ -45,14 +43,13 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class fixedValueFvPatchScalarField Declaration + A templated FixedValueFvPatch \*---------------------------------------------------------------------------*/ -class ${typeName}FixedValueFvPatchScalarField +class ${typeName}FixedValueFvPatch${FieldType} : - public fixedValueFvPatchScalarField + public fixedValueFvPatchField<${TemplateType}> { - public: //- Information about the SHA1 of the code itself @@ -65,75 +62,72 @@ public: // Constructors //- Construct from patch and internal field - ${typeName}FixedValueFvPatchScalarField + ${typeName}FixedValueFvPatch${FieldType} ( const fvPatch&, - const DimensionedField& + const DimensionedField<${TemplateType}, volMesh>& ); //- Construct from patch, internal field and dictionary - ${typeName}FixedValueFvPatchScalarField + ${typeName}FixedValueFvPatch${FieldType} ( const fvPatch&, - const DimensionedField&, + const DimensionedField<${TemplateType}, volMesh>&, const dictionary& ); - //- Construct by mapping given - // ${typeName}FixedValueFvPatchScalarField - // onto a new patch - ${typeName}FixedValueFvPatchScalarField + //- Construct by mapping a copy onto a new patch + ${typeName}FixedValueFvPatch${FieldType} ( - const ${typeName}FixedValueFvPatchScalarField&, + const ${typeName}FixedValueFvPatch${FieldType}&, const fvPatch&, - const DimensionedField&, + const DimensionedField<${TemplateType}, volMesh>&, const fvPatchFieldMapper& ); //- Construct as copy - ${typeName}FixedValueFvPatchScalarField + ${typeName}FixedValueFvPatch${FieldType} ( - const ${typeName}FixedValueFvPatchScalarField& + const ${typeName}FixedValueFvPatch${FieldType}& ); //- Construct and return a clone - virtual tmp clone() const + virtual tmp< fvPatch${FieldType} > clone() const { - return tmp + return tmp< fvPatch${FieldType} > ( - new ${typeName}FixedValueFvPatchScalarField(*this) + new ${typeName}FixedValueFvPatch${FieldType}(*this) ); } //- Construct as copy setting internal field reference - ${typeName}FixedValueFvPatchScalarField + ${typeName}FixedValueFvPatch${FieldType} ( - const ${typeName}FixedValueFvPatchScalarField&, - const DimensionedField& + const ${typeName}FixedValueFvPatch${FieldType}&, + const DimensionedField<${TemplateType}, volMesh>& ); //- Construct and return a clone setting internal field reference - virtual tmp clone + virtual tmp< fvPatch${FieldType} > clone ( - const DimensionedField& iF + const DimensionedField<${TemplateType}, volMesh>& iF ) const { - return tmp + return tmp< fvPatch${FieldType} > ( - new ${typeName}FixedValueFvPatchScalarField(*this, iF) + new ${typeName}FixedValueFvPatch${FieldType}(*this, iF) ); } + //- Destructor - virtual ~${typeName}FixedValueFvPatchScalarField(); + virtual ~${typeName}FixedValueFvPatch${FieldType}(); // Member functions - // Evaluation functions - - //- Update the coefficients associated with the patch field - virtual void updateCoeffs(); + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); }; diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.C index fb4fdbef83..0f738d022a 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.C @@ -36,14 +36,16 @@ License #include "dynamicCode.H" #include "dynamicCodeContext.H" #include "stringOps.H" +#include + // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // const Foam::word Foam::codedFixedValueFvPatchScalarField::codeTemplateC - = "fixedValueFvPatchScalarFieldTemplate.C"; + = "fixedValueFvPatchFieldTemplate.C"; const Foam::word Foam::codedFixedValueFvPatchScalarField::codeTemplateH - = "fixedValueFvPatchScalarFieldTemplate.H"; + = "fixedValueFvPatchFieldTemplate.H"; // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // @@ -172,6 +174,24 @@ void Foam::codedFixedValueFvPatchScalarField::unloadLibrary } + +template +void Foam::codedFixedValueFvPatchScalarField::setFieldTemplates +( + dynamicCode& dynCode +) +{ + word fieldType(pTraits::typeName); + + // template type for fvPatchField + dynCode.setFilterVariable("TemplateType", fieldType); + + // Name for fvPatchField - eg, ScalarField, VectorField, ... + fieldType[0] = toupper(fieldType[0]); + dynCode.setFilterVariable("FieldType", fieldType + "Field"); +} + + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // const Foam::IOdictionary& Foam::codedFixedValueFvPatchScalarField::dict() const @@ -216,19 +236,24 @@ void Foam::codedFixedValueFvPatchScalarField::createLibrary // filter with this context dynCode.reset(context); + // take no chances - typeName must be identical to redirectType_ + dynCode.setFilterVariable("typeName", redirectType_); + + // set TemplateType and FieldType filter variables + // (for fvPatchField) + setFieldTemplates(dynCode); + // compile filtered C template dynCode.addCompileFile(codeTemplateC); // copy filtered H template dynCode.addCopyFile(codeTemplateH); - // take no chances - typeName must be identical to redirectType_ - dynCode.setFilterVariable("typeName", redirectType_); // debugging: make BC verbose - // dynCode.setFilterVariable("verbose", "true"); - // Info<<"compile " << redirectType_ << " sha1: " - // << context.sha1() << endl; + // dynCode.setFilterVariable("verbose", "true"); + // Info<<"compile " << redirectType_ << " sha1: " + // << context.sha1() << endl; // define Make/options dynCode.setMakeOptions diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.H index 003f03dc6c..6eb8e9c533 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.H @@ -136,6 +136,11 @@ class codedFixedValueFvPatchScalarField ); + //- Set TemplateType and FieldType filter variables + template + static void setFieldTemplates(dynamicCode&); + + //- Create library based on the dynamicCodeContext void createLibrary(dynamicCode&, const dynamicCodeContext&) const; From 9cbc0efca3d8c25b25214e17bb0468b2ae694565 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 11 Mar 2011 18:32:18 +0100 Subject: [PATCH 4/7] ENH: add support for WM_PROJECT_SITE env variable - alternative to WM_PROJECT_INST_DIR/site for systems with locked down installation paths (eg, when packaged as RPM or deb) When "$WM_PROJECT_SITE" is defined, it is used in favour of "$WM_PROJECT_INST_DIR/site" --- bin/foamEtcFile | 10 ++--- bin/foamLog | 10 +++-- bin/foamNewCase | 2 +- etc/aliases.csh | 7 ++- etc/aliases.sh | 8 +++- etc/settings.csh | 3 ++ etc/settings.sh | 3 ++ src/OSspecific/POSIX/POSIX.C | 73 ++++++++++++++++++++++--------- src/OpenFOAM/include/OSspecific.H | 22 +++++----- 9 files changed, 94 insertions(+), 44 deletions(-) diff --git a/bin/foamEtcFile b/bin/foamEtcFile index 20b5be0fed..a6859b6ae5 100755 --- a/bin/foamEtcFile +++ b/bin/foamEtcFile @@ -204,15 +204,15 @@ fileName="${1#~OpenFOAM/}" unset dirList case "$mode" in *u*) # user - dirList="$dirList $HOME/.${WM_PROJECT:-OpenFOAM}/$version" - dirList="$dirList $HOME/.${WM_PROJECT:-OpenFOAM}" + userDir="$HOME/.${WM_PROJECT:-OpenFOAM}" + dirList="$dirList $userDir/$version $userDir" ;; esac case "$mode" in -*g*) # group - dirList="$dirList $prefixDir/site/$version" - dirList="$dirList $prefixDir/site" +*g*) # group (site) + siteDir="${WM_PROJECT_SITE:-$prefixDir/site}" + dirList="$dirList $siteDir/$version $siteDir" ;; esac diff --git a/bin/foamLog b/bin/foamLog index b5ca4900b0..c86dce622d 100755 --- a/bin/foamLog +++ b/bin/foamLog @@ -33,6 +33,8 @@ #------------------------------------------------------------------------------ Script=${0##*/} toolsDir=${0%/*}/tools +siteDir=${WM_PROJECT_SITE:-${WM_PROJECT_INST_DIR:-}/site} +userDir=$HOME/.OpenFOAM usage() { exec 1>&2 @@ -84,10 +86,10 @@ The value taken will be the first (non-space)word after this column. The database ($Script.db) will taken from these locations: . - $HOME/.OpenFOAM/$WM_PROJECT_VERSION - $HOME/.OpenFOAM - $WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION - $WM_PROJECT_INST_DIR/site + $userDir/$WM_PROJECT_VERSION + $userDir + $siteDir/$WM_PROJECT_VERSION + $siteDir $WM_PROJECT_DIR/etc $toolsDir diff --git a/bin/foamNewCase b/bin/foamNewCase index fda86b4bdd..3abbd76e1e 100755 --- a/bin/foamNewCase +++ b/bin/foamNewCase @@ -30,7 +30,7 @@ # - requires rsync # #------------------------------------------------------------------------------ -siteDir=${WM_PROJECT_INST_DIR:-unknown}/site +siteDir=${WM_PROJECT_SITE:-${WM_PROJECT_INST_DIR:-}/site} userDir=$HOME/.OpenFOAM version=${WM_PROJECT_VERSION:-unknown} templateDir="appTemplates" diff --git a/etc/aliases.csh b/etc/aliases.csh index 76baa71585..314810bef6 100644 --- a/etc/aliases.csh +++ b/etc/aliases.csh @@ -67,6 +67,11 @@ alias foamSol 'cd $FOAM_SOLVERS' alias foamTuts 'cd $FOAM_TUTORIALS' alias foamUtils 'cd $FOAM_UTILITIES' alias foam3rdParty 'cd $WM_THIRD_PARTY_DIR' -alias foamSite 'cd $WM_PROJECT_INST_DIR/site' + +if ( $?WM_PROJECT_SITE ) then + alias foamSite 'cd $WM_PROJECT_SITE' +else + alias foamSite 'cd $WM_PROJECT_INST_DIR/site' +endif # ----------------------------------------------------------------------------- diff --git a/etc/aliases.sh b/etc/aliases.sh index c3d05d4a72..2f3898a90e 100644 --- a/etc/aliases.sh +++ b/etc/aliases.sh @@ -72,6 +72,12 @@ alias foamSol='cd $FOAM_SOLVERS' alias foamTuts='cd $FOAM_TUTORIALS' alias foamUtils='cd $FOAM_UTILITIES' alias foam3rdParty='cd $WM_THIRD_PARTY_DIR' -alias foamSite='cd $WM_PROJECT_INST_DIR/site' + +if [ -n "$WM_PROJECT_SITE" ] +then + alias foamSite='cd $WM_PROJECT_SITE' +else + alias foamSite='cd $WM_PROJECT_INST_DIR/site' +fi # ----------------------------------------------------------------------------- diff --git a/etc/settings.csh b/etc/settings.csh index 5a6b6c273a..ae4da934d9 100644 --- a/etc/settings.csh +++ b/etc/settings.csh @@ -148,6 +148,9 @@ setenv FOAM_LIBBIN $WM_PROJECT_DIR/platforms/$WM_OPTIONS/lib # external (ThirdParty) libraries setenv FOAM_EXT_LIBBIN $WM_THIRD_PARTY_DIR/platforms/$WM_OPTIONS/lib +# default location of site-specific templates etc +# setenv WM_PROJECT_SITE $WM_PROJECT_INST_DIR/site + # shared site executables/libraries # similar naming convention as ~OpenFOAM expansion setenv FOAM_SITE_APPBIN $WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/bin diff --git a/etc/settings.sh b/etc/settings.sh index e86de7de25..17c8c091ee 100644 --- a/etc/settings.sh +++ b/etc/settings.sh @@ -169,6 +169,9 @@ export FOAM_LIBBIN=$WM_PROJECT_DIR/platforms/$WM_OPTIONS/lib # external (ThirdParty) libraries export FOAM_EXT_LIBBIN=$WM_THIRD_PARTY_DIR/platforms/$WM_OPTIONS/lib +# default location of site-specific templates etc +# export WM_PROJECT_SITE=$WM_PROJECT_INST_DIR/site + # shared site executables/libraries # similar naming convention as ~OpenFOAM expansion export FOAM_SITE_APPBIN=$WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/bin diff --git a/src/OSspecific/POSIX/POSIX.C b/src/OSspecific/POSIX/POSIX.C index e6e54c32c0..ff4c2e84ee 100644 --- a/src/OSspecific/POSIX/POSIX.C +++ b/src/OSspecific/POSIX/POSIX.C @@ -253,19 +253,20 @@ bool Foam::chDir(const fileName& dir) Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory) { - // Search user files: - // ~~~~~~~~~~~~~~~~~~ + // + // search for user files in + // * ~/.OpenFOAM/VERSION + // * ~/.OpenFOAM + // fileName searchDir = home()/".OpenFOAM"; if (isDir(searchDir)) { - // Check for user file in ~/.OpenFOAM/VERSION fileName fullName = searchDir/FOAMversion/name; if (isFile(fullName)) { return fullName; } - // Check for version-independent user file in ~/.OpenFOAM fullName = searchDir/name; if (isFile(fullName)) { @@ -274,32 +275,61 @@ Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory) } - // Search site files: - // ~~~~~~~~~~~~~~~~~~ - searchDir = getEnv("WM_PROJECT_INST_DIR"); - if (isDir(searchDir)) + // + // search for group (site) files in + // * $WM_PROJECT_SITE/VERSION + // * $WM_PROJECT_SITE + // + searchDir = getEnv("WM_PROJECT_SITE"); + if (searchDir.size()) { - // Check for site file in $WM_PROJECT_INST_DIR/site/VERSION - fileName fullName = searchDir/"site"/FOAMversion/name; - if (isFile(fullName)) + if (isDir(searchDir)) { - return fullName; - } + fileName fullName = searchDir/FOAMversion/name; + if (isFile(fullName)) + { + return fullName; + } - // Check for version-independent site file in $WM_PROJECT_INST_DIR/site - fullName = searchDir/"site"/name; - if (isFile(fullName)) + fullName = searchDir/name; + if (isFile(fullName)) + { + return fullName; + } + } + } + else + { + // + // OR search for group (site) files in + // * $WM_PROJECT_INST_DIR/site/VERSION + // * $WM_PROJECT_INST_DIR/site + // + searchDir = getEnv("WM_PROJECT_INST_DIR"); + if (isDir(searchDir)) { - return fullName; + fileName fullName = searchDir/"site"/FOAMversion/name; + if (isFile(fullName)) + { + return fullName; + } + + fullName = searchDir/"site"/name; + if (isFile(fullName)) + { + return fullName; + } } } - // Search installation files: - // ~~~~~~~~~~~~~~~~~~~~~~~~~~ + + // + // search for other (shipped) files in + // * $WM_PROJECT_DIR/etc + // searchDir = getEnv("WM_PROJECT_DIR"); if (isDir(searchDir)) { - // Check for shipped OpenFOAM file in $WM_PROJECT_DIR/etc fileName fullName = searchDir/"etc"/name; if (isFile(fullName)) { @@ -311,7 +341,8 @@ Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory) // abort if the file is mandatory, otherwise return null if (mandatory) { - std::cerr<< "--> FOAM FATAL ERROR in Foam::findEtcFile() :" + std::cerr + << "--> FOAM FATAL ERROR in Foam::findEtcFile() :" " could not find mandatory file\n '" << name.c_str() << "'\n\n" << std::endl; ::exit(1); diff --git a/src/OpenFOAM/include/OSspecific.H b/src/OpenFOAM/include/OSspecific.H index d68ae1661d..ec1d5bdcc3 100644 --- a/src/OpenFOAM/include/OSspecific.H +++ b/src/OpenFOAM/include/OSspecific.H @@ -93,22 +93,22 @@ fileName cwd(); // else return false bool chDir(const fileName& dir); -//- Search for \em name -// in the following hierarchy: -// -# personal settings: -// - ~/.OpenFOAM/\/ -// for version-specific files +//- Search for a file from user/group/shipped directories. +// The search scheme allows for version-specific and +// version-independent files using the following hierarchy: +// - \b user settings: +// - ~/.OpenFOAM/\ // - ~/.OpenFOAM/ -// for version-independent files -// -# site-wide settings: +// - \b group (site) settings (when $WM_PROJECT_SITE is set): +// - $WM_PROJECT_SITE/\ +// - $WM_PROJECT_SITE +// - \b group (site) settings (when $WM_PROJECT_SITE is not set): // - $WM_PROJECT_INST_DIR/site/\ -// for version-specific files // - $WM_PROJECT_INST_DIR/site/ -// for version-independent files -// -# shipped settings: +// - \b other (shipped) settings: // - $WM_PROJECT_DIR/etc/ // -// \return the full path name or fileName() if the name cannot be found +// \return The full path name or fileName() if the name cannot be found // Optionally abort if the file cannot be found fileName findEtcFile(const fileName&, bool mandatory=false); From 4739621578ead99b0366f7922e66810bb00a2d5d Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 11 Mar 2011 19:01:14 +0100 Subject: [PATCH 5/7] STYLE: move WM_PROJECT_SITE to bashrc, cshrc - avoid editing of settings.{sh,csh} --- etc/bashrc | 14 +++++++++++--- etc/cshrc | 15 ++++++++++++--- etc/settings.csh | 12 +++++++----- etc/settings.sh | 13 ++++++++----- 4 files changed, 38 insertions(+), 16 deletions(-) diff --git a/etc/bashrc b/etc/bashrc index b2c33f3da0..1417c75b4d 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -108,16 +108,24 @@ then fi -# Location of site/user files -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# Location of installation +# ~~~~~~~~~~~~~~~~~~~~~~~~ export WM_PROJECT_INST_DIR=$FOAM_INST_DIR export WM_PROJECT_DIR=$WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION -export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION # Location of third-party software # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ export WM_THIRD_PARTY_DIR=$WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION +# Location of site-specific templates etc +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# unset is equivalent to $WM_PROJECT_INST_DIR/site +unset WM_PROJECT_SITE + +# Location of user files +# ~~~~~~~~~~~~~~~~~~~~~~ +export WM_PROJECT_USER_DIR=$HOME/$WM_PROJECT/$USER-$WM_PROJECT_VERSION + # Source files, possibly with some verbosity _foamSource() diff --git a/etc/cshrc b/etc/cshrc index 55d1e20aeb..78ad4895a8 100644 --- a/etc/cshrc +++ b/etc/cshrc @@ -103,16 +103,25 @@ setenv FOAM_SIGFPE # NB: the WM_PROJECT_INST_DIR might not be identical between versions set foamOldDirs="$FOAM_INST_DIR $HOME/$WM_PROJECT/$LOGNAME" -# Location of site/user files -# ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +# Location of installation +# ~~~~~~~~~~~~~~~~~~~~~~~~ setenv WM_PROJECT_INST_DIR $FOAM_INST_DIR setenv WM_PROJECT_DIR $WM_PROJECT_INST_DIR/$WM_PROJECT-$WM_PROJECT_VERSION -setenv WM_PROJECT_USER_DIR $HOME/$WM_PROJECT/$LOGNAME-$WM_PROJECT_VERSION # Location of third-party software # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ setenv WM_THIRD_PARTY_DIR $WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION +# Location of site-specific templates etc +# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +# unset is equivalent to $WM_PROJECT_INST_DIR/site +unsetenv WM_PROJECT_SITE + +# Location of user files +# ~~~~~~~~~~~~~~~~~~~~~~ +setenv WM_PROJECT_USER_DIR $HOME/$WM_PROJECT/$LOGNAME-$WM_PROJECT_VERSION + # Source files, possibly with some verbosity alias _foamSource 'if ($?FOAM_VERBOSE && $?prompt) echo "Sourcing: \!*"; if (\!* != "") source \!*' diff --git a/etc/settings.csh b/etc/settings.csh index ae4da934d9..6a0d8e50c2 100644 --- a/etc/settings.csh +++ b/etc/settings.csh @@ -148,13 +148,15 @@ setenv FOAM_LIBBIN $WM_PROJECT_DIR/platforms/$WM_OPTIONS/lib # external (ThirdParty) libraries setenv FOAM_EXT_LIBBIN $WM_THIRD_PARTY_DIR/platforms/$WM_OPTIONS/lib -# default location of site-specific templates etc -# setenv WM_PROJECT_SITE $WM_PROJECT_INST_DIR/site - # shared site executables/libraries # similar naming convention as ~OpenFOAM expansion -setenv FOAM_SITE_APPBIN $WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/bin -setenv FOAM_SITE_LIBBIN $WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/lib +if ( $?WM_PROJECT_SITE ) then + setenv FOAM_SITE_APPBIN $WM_PROJECT_SITE/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/bin + setenv FOAM_SITE_LIBBIN $WM_PROJECT_SITE/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/lib +else + setenv FOAM_SITE_APPBIN $WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/bin + setenv FOAM_SITE_LIBBIN $WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/lib +endif # user executables/libraries setenv FOAM_USER_APPBIN $WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/bin diff --git a/etc/settings.sh b/etc/settings.sh index 17c8c091ee..453695fe8c 100644 --- a/etc/settings.sh +++ b/etc/settings.sh @@ -169,13 +169,16 @@ export FOAM_LIBBIN=$WM_PROJECT_DIR/platforms/$WM_OPTIONS/lib # external (ThirdParty) libraries export FOAM_EXT_LIBBIN=$WM_THIRD_PARTY_DIR/platforms/$WM_OPTIONS/lib -# default location of site-specific templates etc -# export WM_PROJECT_SITE=$WM_PROJECT_INST_DIR/site - # shared site executables/libraries # similar naming convention as ~OpenFOAM expansion -export FOAM_SITE_APPBIN=$WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/bin -export FOAM_SITE_LIBBIN=$WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/lib +if [ -n "$WM_PROJECT_SITE" ] +then + export FOAM_SITE_APPBIN=$WM_PROJECT_SITE/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/bin + export FOAM_SITE_LIBBIN=$WM_PROJECT_SITE/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/lib +else + export FOAM_SITE_APPBIN=$WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/bin + export FOAM_SITE_LIBBIN=$WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION/platforms/$WM_OPTIONS/lib +fi # user executables/libraries export FOAM_USER_APPBIN=$WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/bin From da7a535317c3d3a1963f6de2c1dce549517b18cf Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 11 Mar 2011 19:09:47 +0100 Subject: [PATCH 6/7] ENH: remove old WM_PROJECT_INST_DIR from path(s) in csh too --- etc/cshrc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/etc/cshrc b/etc/cshrc index 78ad4895a8..6fa63e47d1 100644 --- a/etc/cshrc +++ b/etc/cshrc @@ -102,6 +102,11 @@ setenv FOAM_SIGFPE # - remove anything under top-level directory. # NB: the WM_PROJECT_INST_DIR might not be identical between versions set foamOldDirs="$FOAM_INST_DIR $HOME/$WM_PROJECT/$LOGNAME" +if ( $?WM_PROJECT_INST_DIR ) then + if ( "$WM_PROJECT_INST_DIR" != "$FOAM_INST_DIR" ) then + set foamOldDirs="$WM_PROJECT_INST_DIR $foamOldDirs" + endif +endif # Location of installation @@ -136,10 +141,12 @@ while ( $#argv > 0 ) switch ($argv[1]) case *=: # name= -> unsetenv name + if ($?FOAM_VERBOSE && $?prompt) echo "unsetenv $argv[1]:s/=//" eval "unsetenv $argv[1]:s/=//" breaksw case *=*: # name=value -> setenv name value + if ($?FOAM_VERBOSE && $?prompt) echo "setenv $argv[1]:s/=/ /" eval "setenv $argv[1]:s/=/ /" breaksw default: From 684fce06f77587d10bd2d87fe08dba3f8d91bd9f Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 17 Mar 2011 15:59:50 +0100 Subject: [PATCH 7/7] GIT: got hit by copyright years on git push --- src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C | 2 +- .../COxidationDiffusionLimitedRate.H | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C b/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C index ea7de07931..44672474d4 100644 --- a/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C +++ b/src/finiteVolume/fvMatrices/solvers/MULES/MULESTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/lagrangian/coalCombustion/submodels/surfaceReactionModel/COxidationDiffusionLimitedRate/COxidationDiffusionLimitedRate.H b/src/lagrangian/coalCombustion/submodels/surfaceReactionModel/COxidationDiffusionLimitedRate/COxidationDiffusionLimitedRate.H index 18cca9b9f5..ad388b10f8 100644 --- a/src/lagrangian/coalCombustion/submodels/surfaceReactionModel/COxidationDiffusionLimitedRate/COxidationDiffusionLimitedRate.H +++ b/src/lagrangian/coalCombustion/submodels/surfaceReactionModel/COxidationDiffusionLimitedRate/COxidationDiffusionLimitedRate.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License