From 641cb490b44aeed6a1aa0b02d5a778d005d010a5 Mon Sep 17 00:00:00 2001 From: Mark Olesen <Mark.Olesen@esi-group.com> Date: Mon, 7 Jan 2019 19:04:50 +0100 Subject: [PATCH] ENH: export FOAM_API in dictionary (issue #1158) - uses the value of the OPENFOAM compiler define --- applications/test/dictionary/testDictAPI | 19 +++++++++++++++++++ .../graphics/PVReaders/vtkPVFoam/vtkPVFoam.C | 3 +++ .../PVReaders/vtkPVblockMesh/vtkPVblockMesh.C | 5 ++++- etc/config.csh/unset | 3 ++- etc/config.sh/unset | 3 ++- src/OpenFOAM/global/argList/argList.C | 3 +++ src/OpenFOAM/global/argList/argList.H | 4 +++- 7 files changed, 36 insertions(+), 4 deletions(-) create mode 100644 applications/test/dictionary/testDictAPI diff --git a/applications/test/dictionary/testDictAPI b/applications/test/dictionary/testDictAPI new file mode 100644 index 00000000000..e6091cb9d0b --- /dev/null +++ b/applications/test/dictionary/testDictAPI @@ -0,0 +1,19 @@ +/*--------------------------------*- C++ -*----------------------------------*\ +| ========= | | +| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | +| \\ / O peration | Version: v1812 | +| \\ / A nd | Web: www.OpenFOAM.com | +| \\/ M anipulation | | +\*---------------------------------------------------------------------------*/ +FoamFile +{ + version 2.0; + format ascii; + class dictionary; + object testDict; +} +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +_FOAM_API $FOAM_API; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/utilities/postProcessing/graphics/PVReaders/vtkPVFoam/vtkPVFoam.C b/applications/utilities/postProcessing/graphics/PVReaders/vtkPVFoam/vtkPVFoam.C index 3dc56dc5d0f..a761ac9bf10 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/vtkPVFoam/vtkPVFoam.C +++ b/applications/utilities/postProcessing/graphics/PVReaders/vtkPVFoam/vtkPVFoam.C @@ -318,6 +318,9 @@ Foam::vtkPVFoam::vtkPVFoam fullCasePath = cwd(); } + // OPENFOAM API + setEnv("FOAM_API", std::to_string(OPENFOAM), true); + // The name of the executable, unless already present in the environment setEnv("FOAM_EXECUTABLE", "paraview", false); diff --git a/applications/utilities/postProcessing/graphics/PVReaders/vtkPVblockMesh/vtkPVblockMesh.C b/applications/utilities/postProcessing/graphics/PVReaders/vtkPVblockMesh/vtkPVblockMesh.C index 6a9037c3854..261efaccb70 100644 --- a/applications/utilities/postProcessing/graphics/PVReaders/vtkPVblockMesh/vtkPVblockMesh.C +++ b/applications/utilities/postProcessing/graphics/PVReaders/vtkPVblockMesh/vtkPVblockMesh.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2017 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2017-2019 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -206,6 +206,9 @@ Foam::vtkPVblockMesh::vtkPVblockMesh fullCasePath = cwd(); } + // OPENFOAM API + setEnv("FOAM_API", std::to_string(OPENFOAM), true); + // The name of the executable, unless already present in the environment setEnv("FOAM_EXECUTABLE", "paraview", false); diff --git a/etc/config.csh/unset b/etc/config.csh/unset index 7769d74e610..080b6cd006e 100644 --- a/etc/config.csh/unset +++ b/etc/config.csh/unset @@ -3,7 +3,7 @@ # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | # \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation -# \\/ M anipulation | Copyright (C) 2016-2017 OpenCFD Ltd. +# \\/ M anipulation | Copyright (C) 2016-2019 OpenCFD Ltd. #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM, licensed under GNU General Public License @@ -71,6 +71,7 @@ unsetenv WM_THIRD_PARTY_DIR #------------------------------------------------------------------------------ # Unset FOAM_* environment variables +unsetenv FOAM_API unsetenv FOAM_APPBIN unsetenv FOAM_APP unsetenv FOAM_CODE_TEMPLATES diff --git a/etc/config.sh/unset b/etc/config.sh/unset index 871afe1ecd5..69f32259fd4 100644 --- a/etc/config.sh/unset +++ b/etc/config.sh/unset @@ -3,7 +3,7 @@ # \\ / F ield | OpenFOAM: The Open Source CFD Toolbox # \\ / O peration | # \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation -# \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd. +# \\/ M anipulation | Copyright (C) 2016-2019 OpenCFD Ltd. #------------------------------------------------------------------------------ # License # This file is part of OpenFOAM, licensed under GNU General Public License @@ -62,6 +62,7 @@ unset WM_THIRD_PARTY_DIR #------------------------------------------------------------------------------ # Unset FOAM_* environment variables +unset FOAM_API unset FOAM_APPBIN unset FOAM_APP unset FOAM_CODE_TEMPLATES diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C index 1fee9a35401..79954ac77ff 100644 --- a/src/OpenFOAM/global/argList/argList.C +++ b/src/OpenFOAM/global/argList/argList.C @@ -660,6 +660,9 @@ void Foam::argList::getRootCase() // The name of the executable, unless already present in the environment setEnv("FOAM_EXECUTABLE", executable_, false); + // OPENFOAM API + setEnv("FOAM_API", std::to_string(OPENFOAM), true); + // Set the case and case-name as an environment variable if (rootPath_.isAbsolute()) { diff --git a/src/OpenFOAM/global/argList/argList.H b/src/OpenFOAM/global/argList/argList.H index 1fe2fadb948..5fa1a62c9a4 100644 --- a/src/OpenFOAM/global/argList/argList.H +++ b/src/OpenFOAM/global/argList/argList.H @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2016-2018 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2016-2019 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -57,6 +57,8 @@ Description may be present for some solvers or utilities. Environment variables set by argList or by Time: + - \par FOAM_API + The value of the OPENFOAM compiler define - \par FOAM_CASE The path of the global case. It is the same for serial and parallel jobs. -- GitLab