From 51399bbbd16d3a1a869d3e034cb363612ffb50d9 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 24 Feb 2011 13:21:39 +0100 Subject: [PATCH] STYLE: use dynamicCode/ instead of codeStream/ for dynamically generated code --- ReleaseNotes-dev | 8 ++++---- bin/tools/CleanFunctions | 10 +++++----- doc/changes/{codeStream.org => dynamicCode.org} | 9 +++++---- .../{codeStream => dynamicCode}/codeStreamTemplate.C | 0 .../fixedValueFvPatchScalarFieldTemplate.C | 0 .../fixedValueFvPatchScalarFieldTemplate.H | 0 etc/controlDict | 2 +- etc/settings.csh | 5 +++-- etc/settings.sh | 5 +++-- .../db/dynamicLibrary/codeStream/codeStreamTools.C | 10 +++++----- 10 files changed, 26 insertions(+), 23 deletions(-) rename doc/changes/{codeStream.org => dynamicCode.org} (93%) rename etc/codeTemplates/{codeStream => dynamicCode}/codeStreamTemplate.C (100%) rename etc/codeTemplates/{codeStream => dynamicCode}/fixedValueFvPatchScalarFieldTemplate.C (100%) rename etc/codeTemplates/{codeStream => dynamicCode}/fixedValueFvPatchScalarFieldTemplate.H (100%) diff --git a/ReleaseNotes-dev b/ReleaseNotes-dev index cb57f5cf9f..7583a3d999 100644 --- a/ReleaseNotes-dev +++ b/ReleaseNotes-dev @@ -140,7 +140,7 @@ + only files that can be re-read are being checked. Drastic reduction of number of files to check. *** *New* #codeStream dictionary entry - Uses on-the-fly compilation of OpenFOAM C++ code to construct dictionary. + Uses dynamic compilation of OpenFOAM C++ code to construct dictionary. E.g. in blockMeshDict: #+BEGIN_SRC c++ convertToMeters 0.001; @@ -160,7 +160,7 @@ #}; } #+END_SRC - See also ./[[doc/changes/codeStream.org]] + See also ./[[doc/changes/dynamicCode.org]] * Solvers A number of new solvers have been developed for a range of engineering @@ -191,7 +191,7 @@ + takes optional fieldName to sample + directMapped patch added 'normal' method to calculate sample points to e.g. sample fields just above wall (e.g. for streaklines) - + *New* codedFixedValue: Uses the on-the-fly code compilation from #codeStream + + *New* codedFixedValue: Uses the dynamic code compilation from #codeStream to provide an in-line fixedValueFvPatchScalarField. E.g. #+BEGIN_SRC c++ outlet @@ -206,7 +206,7 @@ #}; } #+END_SRC - See also [[./doc/changes/codeStream.org]] + See also [[./doc/changes/dynamicCode.org]] * Utilities There have been some utilities added and updated in this release. diff --git a/bin/tools/CleanFunctions b/bin/tools/CleanFunctions index 458fdc026e..3c1c9412d9 100644 --- a/bin/tools/CleanFunctions +++ b/bin/tools/CleanFunctions @@ -57,13 +57,13 @@ cleanTimeDirectories() # -# Remove codeStream subdirectory if it looks appropriate +# Remove dynamicCode subdirectory if it looks appropriate # -cleanCodeStream() +cleanDynamicCode() { - if [ -d system -a -d codeStream ] + if [ -d system -a -d dynamicCode ] then - rm -rf codeStream > /dev/null 2>&1 + rm -rf dynamicCode > /dev/null 2>&1 fi } @@ -71,7 +71,7 @@ cleanCodeStream() cleanCase() { cleanTimeDirectories - cleanCodeStream + cleanDynamicCode rm -rf processor* > /dev/null 2>&1 rm -rf probes* > /dev/null 2>&1 diff --git a/doc/changes/codeStream.org b/doc/changes/dynamicCode.org similarity index 93% rename from doc/changes/codeStream.org rename to doc/changes/dynamicCode.org index 6e26ba9810..1cd3d3338a 100644 --- a/doc/changes/codeStream.org +++ b/doc/changes/dynamicCode.org @@ -1,6 +1,6 @@ # -*- mode: org; -*- # -#+TITLE: =codeStream=: On-the-fly code compilation +#+TITLE: =dynamicCode=: Dynamic code compilation #+AUTHOR: OpenCFD Ltd. #+DATE: TBA #+LINK: http://www.openfoam.com @@ -47,12 +47,13 @@ =code=, =codeInclude=, =codeOptions= sections (these are just strings) and calculates the SHA1 checksum of the contents. - it copies a template file - =($FOAM_CODESTREAM_TEMPLATES/codeStreamTemplate.C)=, substituting all + =(~OpenFOAM/codeTemplates/dynamicCode/codeStreamTemplate.C)= or + =($FOAM_CODE_TEMPLATES/codeStreamTemplate.C)=, substituting all occurences of =code=, =codeInclude=, =codeOptions=. - - it writes library source files to =codeStream/= and compiles + - it writes library source files to =dynamicCode/= and compiles it using =wmake libso=. - the resulting library is generated under - =codeStream/platforms/$WM_OPTIONS/lib= and is loaded (=dlopen=, =dlsym=) + =dynamicCode/platforms/$WM_OPTIONS/lib= and is loaded (=dlopen=, =dlsym=) and the function executed - the function will have written its output into the Ostream which then gets used to construct the entry to replace the whole =#codeStream= section. diff --git a/etc/codeTemplates/codeStream/codeStreamTemplate.C b/etc/codeTemplates/dynamicCode/codeStreamTemplate.C similarity index 100% rename from etc/codeTemplates/codeStream/codeStreamTemplate.C rename to etc/codeTemplates/dynamicCode/codeStreamTemplate.C diff --git a/etc/codeTemplates/codeStream/fixedValueFvPatchScalarFieldTemplate.C b/etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.C similarity index 100% rename from etc/codeTemplates/codeStream/fixedValueFvPatchScalarFieldTemplate.C rename to etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.C diff --git a/etc/codeTemplates/codeStream/fixedValueFvPatchScalarFieldTemplate.H b/etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.H similarity index 100% rename from etc/codeTemplates/codeStream/fixedValueFvPatchScalarFieldTemplate.H rename to etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.H diff --git a/etc/controlDict b/etc/controlDict index 4aa8a3ec0a..cc45466672 100644 --- a/etc/controlDict +++ b/etc/controlDict @@ -39,7 +39,7 @@ InfoSwitches writePrecision 6; writeJobInfo 0; - // Allow case-supplied c++ code (#codeStream, codedFixedValue) + // Allow case-supplied C++ code (#codeStream, codedFixedValue) allowSystemOperations 0; } diff --git a/etc/settings.csh b/etc/settings.csh index a48a188382..48b234a337 100644 --- a/etc/settings.csh +++ b/etc/settings.csh @@ -63,8 +63,9 @@ setenv FOAM_SITE_LIBBIN $WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION/platforms/ setenv FOAM_USER_APPBIN $WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/bin setenv FOAM_USER_LIBBIN $WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/lib -# codeStream templates -setenv FOAM_CODESTREAM_TEMPLATE_DIR $WM_PROJECT_DIR/etc/codeTemplates/codeStream +# dynamicCode templates +# - default location is the "~OpenFOAM/codeTemplates/dynamicCode" expansion +# setenv FOAM_CODE_TEMPLATES $WM_PROJECT_DIR/etc/codeTemplates/dynamicCode # convenience setenv FOAM_APP $WM_PROJECT_DIR/applications diff --git a/etc/settings.sh b/etc/settings.sh index 9281ffba95..beebfacf74 100644 --- a/etc/settings.sh +++ b/etc/settings.sh @@ -86,8 +86,9 @@ export FOAM_SITE_LIBBIN=$WM_PROJECT_INST_DIR/site/$WM_PROJECT_VERSION/platforms/ export FOAM_USER_APPBIN=$WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/bin export FOAM_USER_LIBBIN=$WM_PROJECT_USER_DIR/platforms/$WM_OPTIONS/lib -# codeStream templates -export FOAM_CODESTREAM_TEMPLATE_DIR=$WM_PROJECT_DIR/etc/codeTemplates/codeStream +# dynamicCode templates +# - default location is the "~OpenFOAM/codeTemplates/dynamicCode" expansion +# export FOAM_CODE_TEMPLATES=$WM_PROJECT_DIR/etc/codeTemplates/dynamicCode # convenience export FOAM_APP=$WM_PROJECT_DIR/applications diff --git a/src/OpenFOAM/db/dynamicLibrary/codeStream/codeStreamTools.C b/src/OpenFOAM/db/dynamicLibrary/codeStream/codeStreamTools.C index cf252d1f8b..e29732ce8d 100644 --- a/src/OpenFOAM/db/dynamicLibrary/codeStream/codeStreamTools.C +++ b/src/OpenFOAM/db/dynamicLibrary/codeStream/codeStreamTools.C @@ -41,10 +41,10 @@ int Foam::codeStreamTools::allowSystemOperations const Foam::word Foam::codeStreamTools::codeTemplateEnvName - = "FOAM_CODESTREAM_TEMPLATES"; + = "FOAM_CODE_TEMPLATES"; const Foam::fileName Foam::codeStreamTools::codeTemplateDirName - = "codeTemplates/codeStream"; + = "codeTemplates/dynamicCode"; // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // @@ -73,7 +73,7 @@ void Foam::codeStreamTools::checkSecurity Foam::fileName Foam::codeStreamTools::codePath(const word& subDirName) { - return stringOps::expand("$FOAM_CASE/codeStream/" + subDirName); + return stringOps::expand("$FOAM_CASE/dynamicCode/" + subDirName); } @@ -81,7 +81,7 @@ Foam::fileName Foam::codeStreamTools::libPath(const word& codeName) { return stringOps::expand ( - "$FOAM_CASE/codeStream/platforms/$WM_OPTIONS/lib/lib" + "$FOAM_CASE/dynamicCode/platforms/$WM_OPTIONS/lib/lib" + codeName + ".so" ); } @@ -95,7 +95,7 @@ Foam::string Foam::codeStreamTools::libTarget(const word& codeName) Foam::fileName Foam::codeStreamTools::findTemplate(const word& templateFile) { - // try to get template from FOAM_CODESTREAM_TEMPLATES + // try to get template from FOAM_CODE_TEMPLATES fileName templateDir(Foam::getEnv(codeTemplateEnvName)); fileName file;