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/applications/test/codeStream/codeStreamDict1 b/applications/test/codeStream/codeStreamDict1
index 54fb3d0efe..ec94ddb173 100644
--- a/applications/test/codeStream/codeStreamDict1
+++ b/applications/test/codeStream/codeStreamDict1
@@ -14,10 +14,15 @@ FoamFile
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-// #include "codeStreamDefaults"
+// values from outer-scope
+begIter 0;
+endIter 200;
writeInterval #codeStream
{
+ // values from inner-scope
+ nDumps 5;
+
codeInclude
#{
#include "fvCFD.H"
@@ -30,14 +35,15 @@ writeInterval #codeStream
code
#{
- scalar start = 0;
- scalar end = 100;
- label nDumps = 5;
- label interval = end - start;
- Info<<"on-the-fly: " << ((interval)/nDumps) << endl;
- os << ((interval)/nDumps);
+ label interval = ($endIter - $begIter);
+ label nDumps = $nDumps;
+ os << (interval / nDumps);
#};
};
+// play with cleanup
+#remove begIter
+
+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/applications/test/dictionary/testDictCalc b/applications/test/dictionary/testDictCalc
deleted file mode 100644
index d57031f8d6..0000000000
--- a/applications/test/dictionary/testDictCalc
+++ /dev/null
@@ -1,31 +0,0 @@
-/*--------------------------------*- C++ -*----------------------------------*\
-| ========= | |
-| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
-| \\ / O peration | Version: Any |
-| \\ / A nd | Web: www.OpenFOAM.com |
-| \\/ M anipulation | |
-\*---------------------------------------------------------------------------*/
-FoamFile
-{
- version 2.0;
- format ascii;
- class dictionary;
- object testDictCalc;
-}
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-flowRatePerHour 720;
-
-x 10;
-y 20;
-z t s v;
-p #calc{ 1 + 2 + 10 * 15 + $x - $y };
-
-// this calculation is in-place, but does not work inside a string:
-flowRate "The flow rate " #calc{ $flowRatePerHour / 3600 } "kg/s";
-
-// this is also okay
-x #calc{ $x * 1E-3 };
-
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/applications/test/dictionary/testDictCalcError b/applications/test/dictionary/testDictCalcError
deleted file mode 100644
index 911df9feb8..0000000000
--- a/applications/test/dictionary/testDictCalcError
+++ /dev/null
@@ -1,46 +0,0 @@
-/*--------------------------------*- C++ -*----------------------------------*\
-| ========= | |
-| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
-| \\ / O peration | Version: Any |
-| \\ / A nd | Web: www.OpenFOAM.com |
-| \\/ M anipulation | |
-\*---------------------------------------------------------------------------*/
-FoamFile
-{
- version 2.0;
- format ascii;
- class dictionary;
- object testDictCalcError;
-}
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-flowRatePerHour 720;
-
-x 10;
-y 20;
-z t s v;
-// z #test{ // this
-// 123 - 456
-// // comments // are
-// /* stripped
-// * 10
-// * {}
-// */
-// + 1 /*100 */ 10
-// };
-
-p this calculation #calc{
- 1xxx1 + 2 + 10 * 15 +
- $x - $y
- // $x + $y
-}
-is done inplace;
-
-
-flowRate #calc{ $flowRatePerHour / 3600};
-
-xxx yyy;
-foo 30;
-bar 15;
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/applications/test/string/Test-string.C b/applications/test/string/Test-string.C
index d117f50c41..e9639c4736 100644
--- a/applications/test/string/Test-string.C
+++ b/applications/test/string/Test-string.C
@@ -22,11 +22,13 @@ License
along with OpenFOAM. If not, see .
Description
+ Test some string functionality
\*---------------------------------------------------------------------------*/
#include "string.H"
#include "stringOps.H"
+#include "dictionary.H"
#include "IOstreams.H"
using namespace Foam;
@@ -38,9 +40,19 @@ int main(int argc, char *argv[])
{
string test
(
- " $HOME kjhkjhkjh \" \\$HOME/tyetyery ${FOAM_RUN} \n ; hkjh ;$ "
+ " $HOME kjhkjhkjh \" \\$HOME/tyetyery ${FOAM_RUN} \n ; hkjh ;$ with "
+ " $(DONOTSUBST) some other ${USER} entries "
);
+ dictionary dict;
+ dict.add("HOME", "myHome");
+
+ dictionary subDict;
+ subDict.add("value1", "test1");
+ subDict.add("value2", "test2");
+ dict.add("FOAM_RUN", subDict);
+
+
Info<< "string:" << test << nl << "hash:"
<< unsigned(string::hash()(test)) << endl;
@@ -73,7 +85,10 @@ int main(int argc, char *argv[])
Info<< string(test).replaceAll("kj", "zzz") << endl;
Info<< string(test).replaceAll("kj", "z") << endl;
- Info<< string(test).expand() << endl;
+ Info<< "expanded: " << string(test).expand() << endl;
+
+ Info<<"dictionary-based substitution: " << dict << endl;
+ Info<< "expandDict: " << stringOps::expandDict(test, dict) << endl;
string test2("~OpenFOAM/controlDict");
Info<< test2 << " => " << test2.expand() << endl;
diff --git a/applications/utilities/mesh/conversion/fluentMeshToFoam/extrudedQuadCellShape.C b/applications/utilities/mesh/conversion/fluentMeshToFoam/extrudedQuadCellShape.C
index 52725b34fa..901243eaad 100644
--- a/applications/utilities/mesh/conversion/fluentMeshToFoam/extrudedQuadCellShape.C
+++ b/applications/utilities/mesh/conversion/fluentMeshToFoam/extrudedQuadCellShape.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
@@ -47,7 +47,7 @@ cellShape extrudedQuadCellShape
faceList& frontAndBackFaces
)
{
- const static cellModel* hexModelPtr_ = NULL;
+ static const cellModel* hexModelPtr_ = NULL;
if (!hexModelPtr_)
{
diff --git a/applications/utilities/mesh/conversion/fluentMeshToFoam/extrudedTriangleCellShape.C b/applications/utilities/mesh/conversion/fluentMeshToFoam/extrudedTriangleCellShape.C
index 954906998c..5d21940f31 100644
--- a/applications/utilities/mesh/conversion/fluentMeshToFoam/extrudedTriangleCellShape.C
+++ b/applications/utilities/mesh/conversion/fluentMeshToFoam/extrudedTriangleCellShape.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
@@ -48,7 +48,7 @@ cellShape extrudedTriangleCellShape
faceList& frontAndBackFaces
)
{
- const static cellModel* prismModelPtr_ = NULL;
+ static const cellModel* prismModelPtr_ = NULL;
if (!prismModelPtr_)
{
diff --git a/applications/utilities/mesh/conversion/sammToFoam/calcPointCells.C b/applications/utilities/mesh/conversion/sammToFoam/calcPointCells.C
index 70466aad5e..b38fd92071 100644
--- a/applications/utilities/mesh/conversion/sammToFoam/calcPointCells.C
+++ b/applications/utilities/mesh/conversion/sammToFoam/calcPointCells.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
@@ -32,7 +32,7 @@ Description
void sammMesh::calcPointCells() const
{
- const static label UNIT_POINT_CELLS = 12;
+ static const label UNIT_POINT_CELLS = 12;
if (pointCellsPtr_)
{
diff --git a/applications/utilities/mesh/conversion/star3ToFoam/calcPointCells.C b/applications/utilities/mesh/conversion/star3ToFoam/calcPointCells.C
index f3f4c36ef6..a76c8db4e4 100644
--- a/applications/utilities/mesh/conversion/star3ToFoam/calcPointCells.C
+++ b/applications/utilities/mesh/conversion/star3ToFoam/calcPointCells.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
@@ -32,7 +32,7 @@ Description
void starMesh::calcPointCells() const
{
- const static label UNIT_POINT_CELLS = 12;
+ static const label UNIT_POINT_CELLS = 12;
if (pointCellsPtr_)
{
diff --git a/applications/utilities/miscellaneous/foamDebugSwitches/Make/options b/applications/utilities/miscellaneous/foamDebugSwitches/Make/options
index 14c5e10a3e..abee4af7eb 100644
--- a/applications/utilities/miscellaneous/foamDebugSwitches/Make/options
+++ b/applications/utilities/miscellaneous/foamDebugSwitches/Make/options
@@ -19,7 +19,6 @@ EXE_LIBS = \
-ldynamicMesh \
-ledgeMesh \
-lengine \
- -lextrudeModel \
-lfieldFunctionObjects \
-lfileFormats \
-lfiniteVolume \
@@ -43,7 +42,6 @@ EXE_LIBS = \
-lliquidMixtureProperties \
-lliquidProperties \
-lmeshTools \
- -lMGridGenGAMGAgglomeration \
-lmolecularMeasurements \
-lmolecule \
-lmultiphaseInterFoam \
diff --git a/applications/utilities/parallelProcessing/decomposePar/lagrangianFieldDecomposer.C b/applications/utilities/parallelProcessing/decomposePar/lagrangianFieldDecomposer.C
index 4392395af0..c9ab1ffbbe 100644
--- a/applications/utilities/parallelProcessing/decomposePar/lagrangianFieldDecomposer.C
+++ b/applications/utilities/parallelProcessing/decomposePar/lagrangianFieldDecomposer.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
@@ -100,7 +100,7 @@ Foam::lagrangianFieldDecomposer::lagrangianFieldDecomposer
(
new passiveParticle
(
- positions_,
+ procMesh,
ppi.position(),
procCelli,
false
@@ -112,7 +112,7 @@ Foam::lagrangianFieldDecomposer::lagrangianFieldDecomposer
particleIndices_.setSize(pi);
- IOPosition(positions_).write();
+ IOPosition >(positions_).write();
}
diff --git a/applications/utilities/postProcessing/graphics/fieldview9Reader/readerDatabase.H b/applications/utilities/postProcessing/graphics/fieldview9Reader/readerDatabase.H
index 771e6cd6bd..607b891be9 100644
--- a/applications/utilities/postProcessing/graphics/fieldview9Reader/readerDatabase.H
+++ b/applications/utilities/postProcessing/graphics/fieldview9Reader/readerDatabase.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
@@ -25,8 +25,8 @@ Class
Foam::readerDatabase
Description
- Singleton caching OpenFOAM database and mesh and various. Used in Fv reader
- to keep track of data inbetween callbacks.
+ Singleton caching OpenFOAM database and mesh and various.
+ Used in Fv reader to keep track of data in between callbacks.
SourceFiles
readerDatabase.C
@@ -54,7 +54,7 @@ class fileName;
class instant;
/*---------------------------------------------------------------------------*\
- Class readerDatabase Declaration
+ Class readerDatabase Declaration
\*---------------------------------------------------------------------------*/
class readerDatabase
@@ -107,7 +107,7 @@ public:
//- Debug flag. Note: uses envvar instead of controlDict since
// *this is static as well. Might be initialized before controlDict
// read.
- const static bool debug_;
+ static const bool debug_;
// Constructors
diff --git a/applications/utilities/preProcessing/mapFields/mapLagrangian.C b/applications/utilities/preProcessing/mapFields/mapLagrangian.C
index 36dd981719..97a999b62c 100644
--- a/applications/utilities/preProcessing/mapFields/mapLagrangian.C
+++ b/applications/utilities/preProcessing/mapFields/mapLagrangian.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
@@ -24,8 +24,7 @@ License
\*---------------------------------------------------------------------------*/
#include "MapLagrangianFields.H"
-#include "Cloud.H"
-#include "passiveParticle.H"
+#include "passiveParticleCloud.H"
#include "meshSearch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -44,7 +43,9 @@ static label findCell(const Cloud& cloud, const point& pt)
label tetFaceI = -1;
label tetPtI = -1;
- cloud.findCellFacePt(pt, cellI, tetFaceI, tetPtI);
+ const polyMesh& mesh = cloud.pMesh();
+
+ mesh.findCellFacePt(pt, cellI, tetFaceI, tetPtI);
if (cellI >= 0)
{
@@ -55,8 +56,6 @@ static label findCell(const Cloud& cloud, const point& pt)
// See if particle on face by finding nearest face and shifting
// particle.
- const polyMesh& mesh = cloud.pMesh();
-
meshSearch meshSearcher(mesh, false);
label faceI = meshSearcher.findNearestBoundaryFace(pt);
@@ -67,7 +66,7 @@ static label findCell(const Cloud& cloud, const point& pt)
const point perturbPt = (1-perturbFactor)*pt+perturbFactor*cc;
- cloud.findCellFacePt(perturbPt, cellI, tetFaceI, tetPtI);
+ mesh.findCellFacePt(perturbPt, cellI, tetFaceI, tetPtI);
return cellI;
}
@@ -124,7 +123,7 @@ void mapLagrangian(const meshToMesh& meshToMeshInterp)
Info<< nl << " processing cloud " << cloudDirs[cloudI] << endl;
// Read positions & cell
- Cloud sourceParcels
+ passiveParticleCloud sourceParcels
(
meshSource,
cloudDirs[cloudI],
@@ -134,13 +133,15 @@ void mapLagrangian(const meshToMesh& meshToMeshInterp)
<< " parcels from source mesh." << endl;
// Construct empty target cloud
- Cloud targetParcels
+ passiveParticleCloud targetParcels
(
meshTarget,
cloudDirs[cloudI],
IDLList()
);
+ particle::TrackingData td(targetParcels);
+
label sourceParticleI = 0;
// Indices of source particles that get added to targetParcels
@@ -176,15 +177,14 @@ void mapLagrangian(const meshToMesh& meshToMeshInterp)
(
new passiveParticle
(
- targetParcels,
+ meshTarget,
targetCc[targetCells[i]],
targetCells[i]
)
);
passiveParticle& newP = newPtr();
- scalar fraction = 0;
- label faceI = newP.track(iter().position(), fraction);
+ label faceI = newP.track(iter().position(), td);
if (faceI < 0 && newP.cell() >= 0)
{
@@ -246,7 +246,7 @@ void mapLagrangian(const meshToMesh& meshToMeshInterp)
if (addParticles.size())
{
- IOPosition(targetParcels).write();
+ IOPosition(targetParcels).write();
// addParticles now contains the indices of the sourceMesh
// particles that were appended to the target mesh.
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 90%
rename from doc/changes/codeStream.org
rename to doc/changes/dynamicCode.org
index bcef4c166b..9ea400ef4b 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
@@ -13,7 +13,7 @@
provide the actual dictionary entry. The snippet gets provided as three
sections of C++ code which just gets inserted into a template:
- =code= section: the actual body of the code. It gets called with arguments
- =const dictionary& dict, OStream& os= and the C++ code can do a
+ =OStream& os, const dictionary& dict= and the C++ code can do a
=dict.lookup= to find current dictionary values.
- optional =codeInclude= section: any #include statements to include OpenFOAM
files.
@@ -47,15 +47,17 @@
=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 =constant/codeStream/= and compiles
+ - it writes library source files to =dynamicCode/= and compiles
it using =wmake libso=.
- - the resulting library gets loaded (=dlopen=, =dlsym=) and the function
- executed
+ - the resulting library is generated under
+ =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.
- - using the sha1 means that same code will only be compiled and loaded once.
+ - using the SHA1 means that same code will only be compiled and loaded once.
* Boundary condition: =codedFixedValue=
This uses the code from codeStream to have an in-line specialised
diff --git a/etc/codeTemplates/codeStream/codeStreamTemplate.C b/etc/codeTemplates/dynamicCode/codeStreamTemplate.C
similarity index 97%
rename from etc/codeTemplates/codeStream/codeStreamTemplate.C
rename to etc/codeTemplates/dynamicCode/codeStreamTemplate.C
index 50a47e1b1a..35ff81f476 100644
--- a/etc/codeTemplates/codeStream/codeStreamTemplate.C
+++ b/etc/codeTemplates/dynamicCode/codeStreamTemplate.C
@@ -44,8 +44,8 @@ extern "C"
{
void ${typeName}
(
- const dictionary& dict,
- Ostream& os
+ Ostream& os,
+ const dictionary& dict
)
{
//{{{ begin code
diff --git a/etc/codeTemplates/codeStream/fixedValueFvPatchScalarFieldTemplate.C b/etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.C
similarity index 86%
rename from etc/codeTemplates/codeStream/fixedValueFvPatchScalarFieldTemplate.C
rename to etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.C
index 417b77ee68..d1213a4bea 100644
--- a/etc/codeTemplates/codeStream/fixedValueFvPatchScalarFieldTemplate.C
+++ b/etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.C
@@ -35,6 +35,22 @@ ${codeInclude}
namespace Foam
{
+// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
+
+extern "C"
+{
+ // dynamicCode:
+ // SHA1 = ${SHA1sum}
+ //
+ // unique function name that can be checked if the correct library version
+ // has been loaded
+ bool ${typeName}_${SHA1sum}()
+ {
+ return true;
+ }
+}
+
+
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
${typeName}FixedValueFvPatchScalarField::
@@ -94,6 +110,13 @@ ${typeName}FixedValueFvPatchScalarField
{}
+// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
+
+${typeName}FixedValueFvPatchScalarField::
+~${typeName}FixedValueFvPatchScalarField()
+{}
+
+
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void ${typeName}FixedValueFvPatchScalarField::updateCoeffs()
@@ -110,7 +133,7 @@ void ${typeName}FixedValueFvPatchScalarField::updateCoeffs()
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-makePatchTypeField
+makeRemovablePatchTypeField
(
fvPatchScalarField,
${typeName}FixedValueFvPatchScalarField
diff --git a/etc/codeTemplates/codeStream/fixedValueFvPatchScalarFieldTemplate.H b/etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.H
similarity index 98%
rename from etc/codeTemplates/codeStream/fixedValueFvPatchScalarFieldTemplate.H
rename to etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.H
index b6ef87c8bc..c9a2d1c160 100644
--- a/etc/codeTemplates/codeStream/fixedValueFvPatchScalarFieldTemplate.H
+++ b/etc/codeTemplates/dynamicCode/fixedValueFvPatchScalarFieldTemplate.H
@@ -121,6 +121,9 @@ public:
);
}
+ //- Destructor
+ virtual ~${typeName}FixedValueFvPatchScalarField();
+
// Member functions
diff --git a/etc/controlDict b/etc/controlDict
index 403aa02285..cc45466672 100644
--- a/etc/controlDict
+++ b/etc/controlDict
@@ -1,7 +1,7 @@
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
-| \\ / O peration | Version: 1.7 |
+| \\ / O peration | Version: 2.0 |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
@@ -24,6 +24,7 @@ Documentation
"$WM_PROJECT_USER_DIR/html"
"~OpenFOAM/html"
"$WM_PROJECT_DIR/doc/Doxygen/html"
+ "$WM_PROJECT_DIR/doc/doxygen/html"
);
doxySourceFileExts
(
@@ -32,6 +33,34 @@ Documentation
);
}
+
+InfoSwitches
+{
+ writePrecision 6;
+ writeJobInfo 0;
+
+ // Allow case-supplied C++ code (#codeStream, codedFixedValue)
+ allowSystemOperations 0;
+}
+
+
+OptimisationSwitches
+{
+ fileModificationSkew 10;
+
+ //- Modification checking:
+ // - timeStamp : use modification time on file
+ // - inotify : use inotify framework
+ // - timeStampMaster : do time stamp (and file reading) only on master.
+ // - inotifyMaster : do inotify (and file reading) only on master.
+ fileModificationChecking timeStampMaster;//inotify;timeStamp;inotifyMaster;
+
+ commsType nonBlocking; //scheduled; //blocking;
+ floatTransfer 0;
+ nProcsSimpleSum 0;
+}
+
+
DebugSwitches
{
Analytical 0;
@@ -864,30 +893,6 @@ DebugSwitches
zoneToPoint 0;
}
-InfoSwitches
-{
- writePrecision 6;
- writeJobInfo 0;
-
- // Allow case-supplied c++ code (#codeStream, codedFixedValue)
- allowSystemOperations 0;
-}
-
-OptimisationSwitches
-{
- fileModificationSkew 10;
-
- //- Modification checking:
- // - timeStamp : use modification time on file
- // - inotify : use inotify framework
- // - timeStampMaster : do time stamp (and file reading) only on master.
- // - inotifyMaster : do inotify (and file reading) only on master.
- fileModificationChecking timeStampMaster;//inotify;timeStamp;inotifyMaster;
-
- commsType nonBlocking; //scheduled; //blocking;
- floatTransfer 0;
- nProcsSimpleSum 0;
-}
DimensionedConstants
{
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/Allwmake b/src/Allwmake
index e9a922ab36..37313b73df 100755
--- a/src/Allwmake
+++ b/src/Allwmake
@@ -38,9 +38,9 @@ parallel/decompose/AllwmakeLnInclude
# dummyThirdParty (dummy metisDecomp, scotchDecomp etc) needed by e.g. meshTools
dummyThirdParty/Allwmake $*
+wmake $makeOption finiteVolume
wmake $makeOption lagrangian/basic
wmake $makeOption lagrangian/distributionModels
-wmake $makeOption finiteVolume
wmake $makeOption genericPatchFields
# Build the proper scotchDecomp, metisDecomp etc.
diff --git a/src/OSspecific/POSIX/POSIX.C b/src/OSspecific/POSIX/POSIX.C
index 03eefb623b..e6e54c32c0 100644
--- a/src/OSspecific/POSIX/POSIX.C
+++ b/src/OSspecific/POSIX/POSIX.C
@@ -63,28 +63,28 @@ defineTypeNameAndDebug(Foam::POSIX, 0);
pid_t Foam::pid()
{
- return getpid();
+ return ::getpid();
}
pid_t Foam::ppid()
{
- return getppid();
+ return ::getppid();
}
pid_t Foam::pgid()
{
- return getpgrp();
+ return ::getpgrp();
}
bool Foam::env(const word& envName)
{
- return getenv(envName.c_str()) != NULL;
+ return ::getenv(envName.c_str()) != NULL;
}
Foam::string Foam::getEnv(const word& envName)
{
- char* env = getenv(envName.c_str());
+ char* env = ::getenv(envName.c_str());
if (env)
{
@@ -113,12 +113,12 @@ bool Foam::setEnv
Foam::word Foam::hostName(bool full)
{
char buf[128];
- gethostname(buf, sizeof(buf));
+ ::gethostname(buf, sizeof(buf));
// implementation as per hostname from net-tools
if (full)
{
- struct hostent *hp = gethostbyname(buf);
+ struct hostent *hp = ::gethostbyname(buf);
if (hp)
{
return hp->h_name;
@@ -132,13 +132,13 @@ Foam::word Foam::hostName(bool full)
Foam::word Foam::domainName()
{
char buf[128];
- gethostname(buf, sizeof(buf));
+ ::gethostname(buf, sizeof(buf));
// implementation as per hostname from net-tools
- struct hostent *hp = gethostbyname(buf);
+ struct hostent *hp = ::gethostbyname(buf);
if (hp)
{
- char *p = strchr(hp->h_name, '.');
+ char *p = ::strchr(hp->h_name, '.');
if (p)
{
++p;
@@ -152,7 +152,7 @@ Foam::word Foam::domainName()
Foam::word Foam::userName()
{
- struct passwd* pw = getpwuid(getuid());
+ struct passwd* pw = ::getpwuid(::getuid());
if (pw != NULL)
{
@@ -167,14 +167,14 @@ Foam::word Foam::userName()
bool Foam::isAdministrator()
{
- return (geteuid() == 0);
+ return (::geteuid() == 0);
}
// use $HOME environment variable or passwd info
Foam::fileName Foam::home()
{
- char* env = getenv("HOME");
+ char* env = ::getenv("HOME");
if (env != NULL)
{
@@ -182,7 +182,7 @@ Foam::fileName Foam::home()
}
else
{
- struct passwd* pw = getpwuid(getuid());
+ struct passwd* pw = ::getpwuid(getuid());
if (pw != NULL)
{
@@ -202,18 +202,18 @@ Foam::fileName Foam::home(const word& userName)
if (userName.size())
{
- pw = getpwnam(userName.c_str());
+ pw = ::getpwnam(userName.c_str());
}
else
{
- char* env = getenv("HOME");
+ char* env = ::getenv("HOME");
if (env != NULL)
{
return fileName(env);
}
- pw = getpwuid(getuid());
+ pw = ::getpwuid(::getuid());
}
if (pw != NULL)
@@ -230,7 +230,7 @@ Foam::fileName Foam::home(const word& userName)
Foam::fileName Foam::cwd()
{
char buf[256];
- if (getcwd(buf, sizeof(buf)))
+ if (::getcwd(buf, sizeof(buf)))
{
return buf;
}
@@ -247,7 +247,7 @@ Foam::fileName Foam::cwd()
bool Foam::chDir(const fileName& dir)
{
- return chdir(dir.c_str()) == 0;
+ return ::chdir(dir.c_str()) == 0;
}
@@ -311,7 +311,7 @@ Foam::fileName Foam::findEtcFile(const fileName& name, bool mandatory)
// abort if the file is mandatory, otherwise return null
if (mandatory)
{
- 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);
@@ -591,7 +591,7 @@ Foam::fileNameList Foam::readDir
label nEntries = 0;
// Attempt to open directory and set the structure pointer
- if ((source = opendir(directory.c_str())) == NULL)
+ if ((source = ::opendir(directory.c_str())) == NULL)
{
dirEntries.setSize(0);
@@ -605,7 +605,7 @@ Foam::fileNameList Foam::readDir
else
{
// Read and parse all the entries in the directory
- while ((list = readdir(source)) != NULL)
+ while ((list = ::readdir(source)) != NULL)
{
fileName fName(list->d_name);
@@ -651,7 +651,7 @@ Foam::fileNameList Foam::readDir
// Reset the length of the entries list
dirEntries.setSize(nEntries);
- closedir(source);
+ ::closedir(source);
}
return dirEntries;
@@ -781,7 +781,7 @@ bool Foam::ln(const fileName& src, const fileName& dst)
return false;
}
- if (symlink(src.c_str(), dst.c_str()) == 0)
+ if (::symlink(src.c_str(), dst.c_str()) == 0)
{
return true;
}
@@ -810,11 +810,11 @@ bool Foam::mv(const fileName& src, const fileName& dst)
{
const fileName dstName(dst/src.name());
- return rename(src.c_str(), dstName.c_str()) == 0;
+ return ::rename(src.c_str(), dstName.c_str()) == 0;
}
else
{
- return rename(src.c_str(), dst.c_str()) == 0;
+ return ::rename(src.c_str(), dst.c_str()) == 0;
}
}
@@ -846,7 +846,7 @@ bool Foam::mvBak(const fileName& src, const std::string& ext)
// possible index where we have no choice
if (!exists(dstName, false) || n == maxIndex)
{
- return rename(src.c_str(), dstName.c_str()) == 0;
+ return ::rename(src.c_str(), dstName.c_str()) == 0;
}
}
@@ -873,7 +873,7 @@ bool Foam::rm(const fileName& file)
}
else
{
- return remove(string(file + ".gz").c_str()) == 0;
+ return ::remove(string(file + ".gz").c_str()) == 0;
}
}
@@ -892,7 +892,7 @@ bool Foam::rmDir(const fileName& directory)
struct dirent *list;
// Attempt to open directory and set the structure pointer
- if ((source = opendir(directory.c_str())) == NULL)
+ if ((source = ::opendir(directory.c_str())) == NULL)
{
WarningIn("rmDir(const fileName&)")
<< "cannot open directory " << directory << endl;
@@ -902,7 +902,7 @@ bool Foam::rmDir(const fileName& directory)
else
{
// Read and parse all the entries in the directory
- while ((list = readdir(source)) != NULL)
+ while ((list = ::readdir(source)) != NULL)
{
fileName fName(list->d_name);
@@ -919,7 +919,7 @@ bool Foam::rmDir(const fileName& directory)
<< " while removing directory " << directory
<< endl;
- closedir(source);
+ ::closedir(source);
return false;
}
@@ -933,7 +933,7 @@ bool Foam::rmDir(const fileName& directory)
<< " while removing directory " << directory
<< endl;
- closedir(source);
+ ::closedir(source);
return false;
}
@@ -947,12 +947,12 @@ bool Foam::rmDir(const fileName& directory)
WarningIn("rmDir(const fileName&)")
<< "failed to remove directory " << directory << endl;
- closedir(source);
+ ::closedir(source);
return false;
}
- closedir(source);
+ ::closedir(source);
return true;
}
@@ -990,7 +990,7 @@ bool Foam::ping
struct sockaddr_in destAddr; // will hold the destination addr
u_int addr;
- if ((hostPtr = gethostbyname(destName.c_str())) == NULL)
+ if ((hostPtr = ::gethostbyname(destName.c_str())) == NULL)
{
FatalErrorIn
(
@@ -1003,7 +1003,7 @@ bool Foam::ping
addr = (reinterpret_cast(*(hostPtr->h_addr_list)))->s_addr;
// Allocate socket
- sockfd = socket(AF_INET, SOCK_STREAM, 0);
+ sockfd = ::socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0)
{
FatalErrorIn
@@ -1031,7 +1031,7 @@ bool Foam::ping
if
(
- connect
+ ::connect
(
sockfd,
reinterpret_cast(&destAddr),
@@ -1074,29 +1074,56 @@ int Foam::system(const std::string& command)
void* Foam::dlOpen(const fileName& lib)
{
- return dlopen(lib.c_str(), RTLD_LAZY|RTLD_GLOBAL);
+ return ::dlopen(lib.c_str(), RTLD_LAZY|RTLD_GLOBAL);
}
bool Foam::dlClose(void* handle)
{
- return dlclose(handle) == 0;
+ return ::dlclose(handle) == 0;
}
void* Foam::dlSym(void* handle, const std::string& symbol)
{
- void* fun = dlsym(handle, symbol.c_str());
+ // clear any old errors - see manpage dlopen
+ (void) ::dlerror();
- char *error;
- if ((error = dlerror()) != NULL)
+ // get address of symbol
+ void* fun = ::dlsym(handle, symbol.c_str());
+
+ // find error (if any)
+ char *error = ::dlerror();
+
+ if (error)
{
WarningIn("dlSym(void*, const std::string&)")
<< "Cannot lookup symbol " << symbol << " : " << error
<< endl;
}
+
return fun;
}
+bool Foam::dlSymFound(void* handle, const std::string& symbol)
+{
+ if (handle && !symbol.empty())
+ {
+ // clear any old errors - see manpage dlopen
+ (void) ::dlerror();
+
+ // get address of symbol
+ (void) ::dlsym(handle, symbol.c_str());
+
+ // symbol can be found if there was no error
+ return !::dlerror();
+ }
+ else
+ {
+ return false;
+ }
+}
+
+
// ************************************************************************* //
diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files
index 32112f8737..432f6ccc0e 100644
--- a/src/OpenFOAM/Make/files
+++ b/src/OpenFOAM/Make/files
@@ -189,8 +189,9 @@ db/objectRegistry/objectRegistry.C
db/CallbackRegistry/CallbackRegistryName.C
dll = db/dynamicLibrary
-$(dll)/codeStream/codeStreamTools.C
$(dll)/dlLibraryTable/dlLibraryTable.C
+$(dll)/dynamicCode/dynamicCode.C
+$(dll)/dynamicCode/dynamicCodeContext.C
db/functionObjects/functionObject/functionObject.C
db/functionObjects/functionObjectList/functionObjectList.C
@@ -494,6 +495,8 @@ $(pointBoundaryMesh)/pointBoundaryMesh.C
meshes/boundBox/boundBox.C
+meshes/treeBoundBox/treeBoundBox.C
+
meshTools = meshes/meshTools
$(meshTools)/matchPoints.C
$(meshTools)/mergePoints.C
@@ -571,6 +574,11 @@ $(interpolations)/patchToPatchInterpolation/PatchToPatchInterpolationName.C
algorithms/MeshWave/MeshWaveName.C
algorithms/MeshWave/FaceCellWaveName.C
+algorithms/indexedOctree/indexedOctreeName.C
+algorithms/indexedOctree/treeDataCell.C
+
+
+
graph/curve/curve.C
graph/graph.C
diff --git a/src/meshTools/indexedOctree/indexedOctree.C b/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C
similarity index 98%
rename from src/meshTools/indexedOctree/indexedOctree.C
rename to src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C
index df489a6f95..6020d24d19 100644
--- a/src/meshTools/indexedOctree/indexedOctree.C
+++ b/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C
@@ -25,8 +25,8 @@ License
#include "indexedOctree.H"
#include "linePointRef.H"
-#include "meshTools.H"
#include "OFstream.H"
+#include "ListOps.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@@ -1730,26 +1730,6 @@ void Foam::indexedOctree::traverseNode
point perturbedEnd(pushPoint(octantBb, end, false));
-
- //if (debug)
- {
- // Dump octantBb to obj
- writeOBJ(nodeI, octant);
- // Dump ray to obj as well
- {
- OFstream str("ray.obj");
- meshTools::writeOBJ(str, start);
- meshTools::writeOBJ(str, end);
- str << "l 1 2" << nl;
- }
- WarningIn("indexedOctree::traverseNode(..)")
- << "Did not intersect ray from endpoint:" << end
- << " to startpoint:" << start
- << " with bounding box:" << octantBb << nl
- << "Re-intersecting with perturbed endpoint:" << perturbedEnd
- << endl;
- }
-
traverseNode
(
findAny,
@@ -2316,12 +2296,6 @@ void Foam::indexedOctree::writeOBJ
pointField bbPoints(subBb.points());
label pointVertI = vertI;
- forAll(bbPoints, i)
- {
- meshTools::writeOBJ(str, bbPoints[i]);
- vertI++;
- }
-
forAll(treeBoundBox::edges, i)
{
const edge& e = treeBoundBox::edges[i];
diff --git a/src/meshTools/indexedOctree/indexedOctree.H b/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.H
similarity index 100%
rename from src/meshTools/indexedOctree/indexedOctree.H
rename to src/OpenFOAM/algorithms/indexedOctree/indexedOctree.H
diff --git a/src/meshTools/indexedOctree/indexedOctreeName.C b/src/OpenFOAM/algorithms/indexedOctree/indexedOctreeName.C
similarity index 95%
rename from src/meshTools/indexedOctree/indexedOctreeName.C
rename to src/OpenFOAM/algorithms/indexedOctree/indexedOctreeName.C
index 519d0d5992..4483d42068 100644
--- a/src/meshTools/indexedOctree/indexedOctreeName.C
+++ b/src/OpenFOAM/algorithms/indexedOctree/indexedOctreeName.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/meshTools/indexedOctree/labelBits.H b/src/OpenFOAM/algorithms/indexedOctree/labelBits.H
similarity index 98%
rename from src/meshTools/indexedOctree/labelBits.H
rename to src/OpenFOAM/algorithms/indexedOctree/labelBits.H
index 221881f5bb..58893cbaeb 100644
--- a/src/meshTools/indexedOctree/labelBits.H
+++ b/src/OpenFOAM/algorithms/indexedOctree/labelBits.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
diff --git a/src/meshTools/indexedOctree/treeDataCell.C b/src/OpenFOAM/algorithms/indexedOctree/treeDataCell.C
similarity index 100%
rename from src/meshTools/indexedOctree/treeDataCell.C
rename to src/OpenFOAM/algorithms/indexedOctree/treeDataCell.C
diff --git a/src/meshTools/indexedOctree/treeDataCell.H b/src/OpenFOAM/algorithms/indexedOctree/treeDataCell.H
similarity index 98%
rename from src/meshTools/indexedOctree/treeDataCell.H
rename to src/OpenFOAM/algorithms/indexedOctree/treeDataCell.H
index 06342311e8..7cebddafa9 100644
--- a/src/meshTools/indexedOctree/treeDataCell.H
+++ b/src/OpenFOAM/algorithms/indexedOctree/treeDataCell.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
diff --git a/src/OpenFOAM/db/dictionary/dictionary.H b/src/OpenFOAM/db/dictionary/dictionary.H
index f1196852bf..cb3b03b00f 100644
--- a/src/OpenFOAM/db/dictionary/dictionary.H
+++ b/src/OpenFOAM/db/dictionary/dictionary.H
@@ -477,7 +477,8 @@ public:
// Write
- void write(Ostream&, bool subDict=true) const;
+ //- Write dictionary, normally with sub-dictionary formatting
+ void write(Ostream&, const bool subDict=true) const;
// Member Operators
diff --git a/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.H b/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.H
index 050840c5e4..7713e503af 100644
--- a/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.H
+++ b/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntry.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
@@ -146,7 +146,7 @@ public:
//- Return non-const access to dictionary
dictionary& dict();
- // Write
+ //- Write
void write(Ostream&) const;
//- Return info proxy.
diff --git a/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntryIO.C b/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntryIO.C
index b090188a0d..2477f0450b 100644
--- a/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntryIO.C
+++ b/src/OpenFOAM/db/dictionary/dictionaryEntry/dictionaryEntryIO.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/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C
index 1ae00ea731..92a6b444f1 100644
--- a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C
+++ b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C
@@ -28,16 +28,15 @@ License
#include "IStringStream.H"
#include "OStringStream.H"
#include "IOstreams.H"
-#include "SHA1Digest.H"
-#include "OSHA1stream.H"
-#include "codeStreamTools.H"
#include "stringOps.H"
+#include "dynamicCode.H"
+#include "dynamicCodeContext.H"
#include "dlLibraryTable.H"
#include "OSspecific.H"
#include "Time.H"
-#include "Pstream.H"
#include "PstreamReduceOps.H"
+
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
@@ -71,149 +70,92 @@ bool Foam::functionEntries::codeStream::execute
Istream& is
)
{
- if (isAdministrator())
- {
- FatalIOErrorIn
- (
- "functionEntries::codeStream::execute(..)",
- parentDict
- ) << "This code should not be executed by someone with administrator"
- << " rights due to security reasons." << endl
- << "(it writes a shared library which then gets loaded "
- << "using dlopen)"
- << exit(FatalIOError);
- }
+ dynamicCode::checkSecurity
+ (
+ "functionEntries::codeStream::execute(..)",
+ parentDict
+ );
+ // get code dictionary
+ // must reference parent for stringOps::expand to work nicely
+ dictionary codeDict("#codeStream", parentDict, is);
- // Read three sections of code.
- // Remove any leading whitespace - necessary for compilation options,
- // convenience for includes and body.
- dictionary codeDict(is);
+ // get code, codeInclude, codeOptions
+ dynamicCodeContext context(codeDict);
- // "codeInclude" is optional
- string codeInclude;
- if (codeDict.found("codeInclude"))
- {
- codeInclude = stringOps::trim(codeDict["codeInclude"]);
- }
-
- // "codeOptions" is optional
- string codeOptions;
- if (codeDict.found("codeOptions"))
- {
- codeOptions = stringOps::trim(codeDict["codeOptions"]);
- }
-
- // "code" is mandatory
- string code = stringOps::trim(codeDict["code"]);
-
- // Create SHA1 digest from the contents
- SHA1Digest sha;
- {
- OSHA1stream os;
- os << codeInclude << codeOptions << code;
- sha = os.digest();
- }
-
-
- // codeName = prefix + sha1
- const fileName codeName = "codeStream_" + sha.str();
-
- // write code into _SHA1 subdir
- const fileName codePath = codeStreamTools::codePath("_" + sha.str());
-
- // write library into platforms/$WM_OPTIONS/lib subdir
- const fileName libPath = codeStreamTools::libPath(codeName);
+ // codeName: codeStream + _
+ // codeDir : _
+ dynamicCode dynCode
+ (
+ "codeStream" + context.sha1().str(true),
+ context.sha1().str(true)
+ );
+ // Load library if not already loaded
+ // Version information is encoded in the libPath (encoded with the SHA1)
+ const fileName libPath = dynCode.libPath();
+ // see if library is loaded
void* lib = dlLibraryTable::findLibrary(libPath);
- // try to load if not already loaded
+ bool reuseLib = false;
+
+ // nothing loaded
+ // avoid compilation if possible by loading an existing library
if (!lib && dlLibraryTable::open(libPath, false))
{
lib = dlLibraryTable::findLibrary(libPath);
+ reuseLib = true;
}
- // did not load - need to compile it
+
+ // create library if required
if (!lib)
{
if (Pstream::master())
{
- if (!codeStreamTools::upToDate(codePath, sha))
+ if (!dynCode.upToDate(context))
{
- Info<< "Creating new library in " << libPath << endl;
+ // filter with this context
+ dynCode.reset(context);
- const fileName fileCsrc
+ // compile filtered C template
+ dynCode.addCompileFile(codeTemplateC);
+
+ // define Make/options
+ dynCode.setMakeOptions
(
- codeStreamTools::findTemplate
- (
- codeTemplateC
- )
+ "EXE_INC = -g \\\n"
+ + context.options()
+ + "\n\nLIB_LIBS ="
);
- // not found!
- if (fileCsrc.empty())
+ if (!dynCode.copyOrCreateFiles(true))
{
FatalIOErrorIn
(
"functionEntries::codeStream::execute(..)",
parentDict
- ) << "Could not find the code template: "
- << codeTemplateC << nl
- << codeStreamTools::searchedLocations()
- << exit(FatalIOError);
- }
-
-
- List copyFiles(1);
- copyFiles[0].file() = fileCsrc;
- copyFiles[0].set("codeInclude", codeInclude);
- copyFiles[0].set("code", code);
-
- List filesContents(2);
-
- // Write Make/files
- filesContents[0].first() = "Make/files";
- filesContents[0].second() =
- codeTemplateC + "\n\n"
- + codeStreamTools::libTarget(codeName);
-
- // Write Make/options
- filesContents[1].first() = "Make/options";
- filesContents[1].second() =
- "EXE_INC = -g \\\n"
- + codeOptions
- + "\n\nLIB_LIBS =";
-
- codeStreamTools writer(codeName, copyFiles, filesContents);
- if (!writer.copyFilesContents(codePath))
- {
- FatalIOErrorIn
- (
- "functionEntries::codeStream::execute(..)",
- parentDict
- ) << "Failed writing " <());
+ // all processes must wait for compile
+ bool waiting = true;
+ reduce(waiting, orOp());
if (!dlLibraryTable::open(libPath, false))
{
@@ -227,31 +169,35 @@ bool Foam::functionEntries::codeStream::execute
lib = dlLibraryTable::findLibrary(libPath);
}
- else
+ else if (reuseLib)
{
Info<< "Reusing library in " << libPath << endl;
}
- // Find the library handle.
- void (*function)(const dictionary&, Ostream&);
- function = reinterpret_cast
+ // Find the function handle in the library
+ void (*function)(Ostream&, const dictionary&);
+ function = reinterpret_cast
(
- dlSym(lib, codeName)
+ dlSym(lib, dynCode.codeName())
);
+
if (!function)
{
FatalIOErrorIn
(
"functionEntries::codeStream::execute(..)",
parentDict
- ) << "Failed looking up symbol " << codeName
+ ) << "Failed looking up symbol " << dynCode.codeName()
<< " in library " << lib << exit(FatalIOError);
}
+ // use function to write stream
OStringStream os(is.format());
- (*function)(parentDict, os);
+ (*function)(os, parentDict);
+
+ // get the entry from this stream
IStringStream resultStream(os.str());
entry.read(parentDict, resultStream);
diff --git a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.H b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.H
index e04bdceaa4..10e3262ca1 100644
--- a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.H
+++ b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.H
@@ -135,8 +135,8 @@ public:
static bool execute
(
const dictionary& parentDict,
- primitiveEntry& entry,
- Istream& is
+ primitiveEntry&,
+ Istream&
);
};
diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H
index 6edf2c621c..01f08cea5b 100644
--- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.H
+++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntry.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
@@ -168,6 +168,9 @@ public:
//- Write
void write(Ostream&) const;
+ //- Write, optionally with contents only (no keyword, etc)
+ void write(Ostream&, const bool contentsOnly) const;
+
//- Return info proxy.
// Used to print token information to a stream
InfoProxy info() const
diff --git a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C
index fa9a50efdb..33c3dc8ff7 100644
--- a/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C
+++ b/src/OpenFOAM/db/dictionary/primitiveEntry/primitiveEntryIO.C
@@ -210,31 +210,43 @@ Foam::primitiveEntry::primitiveEntry(const keyType& key, Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
-void Foam::primitiveEntry::write(Ostream& os) const
+void Foam::primitiveEntry::write(Ostream& os, const bool contentsOnly) const
{
- os.writeKeyword(keyword());
+ if (!contentsOnly)
+ {
+ os.writeKeyword(keyword());
+ }
for (label i=0; iwrite(os, false);
}
diff --git a/src/OpenFOAM/db/dynamicLibrary/codeStream/codeStreamTools.C b/src/OpenFOAM/db/dynamicLibrary/codeStream/codeStreamTools.C
deleted file mode 100644
index fc1c6f0ffb..0000000000
--- a/src/OpenFOAM/db/dynamicLibrary/codeStream/codeStreamTools.C
+++ /dev/null
@@ -1,356 +0,0 @@
-/*---------------------------------------------------------------------------*\
- ========= |
- \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
- \\ / O peration |
- \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
- \\/ M anipulation |
--------------------------------------------------------------------------------
-License
- This file is part of OpenFOAM.
-
- OpenFOAM is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- for more details.
-
- You should have received a copy of the GNU General Public License
- along with OpenFOAM; if not, write to the Free Software Foundation,
- Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-\*---------------------------------------------------------------------------*/
-
-#include "codeStreamTools.H"
-#include "stringOps.H"
-#include "IFstream.H"
-#include "OFstream.H"
-#include "OSspecific.H"
-#include "dictionary.H"
-#include "dlLibraryTable.H"
-
-// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
-
-int Foam::codeStreamTools::allowSystemOperations
-(
- Foam::debug::infoSwitch("allowSystemOperations", 0)
-);
-
-
-const Foam::word Foam::codeStreamTools::codeTemplateEnvName
- = "FOAM_CODESTREAM_TEMPLATES";
-
-const Foam::fileName Foam::codeStreamTools::codeTemplateDirName
- = "codeTemplates/codeStream";
-
-
-// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
-
-Foam::fileName Foam::codeStreamTools::baseDir()
-{
- return stringOps::expandEnv("$FOAM_CASE/codeStream");
-}
-
-
-Foam::fileName Foam::codeStreamTools::libSubDir()
-{
- return stringOps::expandEnv("platforms/$WM_OPTIONS/lib");
-}
-
-
-Foam::fileName Foam::codeStreamTools::codePath(const word& subDirName)
-{
- return stringOps::expandEnv
- (
- "$FOAM_CASE/codeStream/" + subDirName
- );
-}
-
-
-Foam::fileName Foam::codeStreamTools::libPath(const word& codeName)
-{
- return stringOps::expandEnv
- (
- "$FOAM_CASE/codeStream/platforms/$WM_OPTIONS/lib/lib"
- + codeName + ".so"
- );
-}
-
-
-Foam::string Foam::codeStreamTools::libTarget(const word& codeName)
-{
- return "LIB = $(PWD)/../platforms/$(WM_OPTIONS)/lib/lib" + codeName;
-}
-
-
-Foam::fileName Foam::codeStreamTools::findTemplate(const word& templateFile)
-{
- // try to get template from FOAM_CODESTREAM_TEMPLATES
- fileName templateDir(Foam::getEnv(codeTemplateEnvName));
-
- fileName file;
- if (!templateDir.empty() && isDir(templateDir))
- {
- file = templateDir/templateFile;
- if (!isFile(file, false))
- {
- file.clear();
- }
- }
-
- // not found - fallback to ~OpenFOAM expansion
- if (file.empty())
- {
- file = findEtcFile(codeTemplateDirName/templateFile);
- }
-
- return file;
-}
-
-
-Foam::string Foam::codeStreamTools::searchedLocations()
-{
- return
- (
- "Under the $"
- + codeTemplateDirName
- + " directory or via via the ~OpenFOAM/"
- + codeTemplateDirName
- + " expansion"
- );
-}
-
-
-// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
-
-void Foam::codeStreamTools::copyAndExpand
-(
- ISstream& is,
- OSstream& os,
- const HashTable& mapping
-) const
-{
- if (!is.good())
- {
- FatalErrorIn
- (
- "codeStreamTools::copyAndExpand()"
- " const"
- ) << "Failed opening for reading " << is.name()
- << exit(FatalError);
- }
-
- if (!os.good())
- {
- FatalErrorIn
- (
- "codeStreamTools::copyAndExpand()"
- " const"
- ) << "Failed writing " << os.name()
- << exit(FatalError);
- }
-
- // Copy file while rewriting $VARS and ${VARS}
- string line;
- do
- {
- is.getLine(line);
-
- // normal expansion according to mapping
- stringOps::inplaceExpand(line, mapping);
-
- // expand according to env variables
- stringOps::inplaceExpandEnv(line, true, true);
-
- os << line.c_str() << nl;
- }
- while (is.good());
-}
-
-
-// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
-
-Foam::codeStreamTools::codeStreamTools()
-{}
-
-
-Foam::codeStreamTools::codeStreamTools
-(
- const word& name,
- const dictionary& dict
-)
-:
- name_(name)
-{
- read(dict);
-}
-
-
-Foam::codeStreamTools::codeStreamTools
-(
- const word& name,
- const List& copyFiles,
- const List& filesContents
-)
-:
- name_(name),
- copyFiles_(copyFiles),
- filesContents_(filesContents)
-{}
-
-
-Foam::codeStreamTools::codeStreamTools(const codeStreamTools& tools)
-:
- name_(tools.name_),
- copyFiles_(tools.copyFiles_),
- filesContents_(tools.filesContents_)
-{}
-
-
-// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
-
-bool Foam::codeStreamTools::copyFilesContents(const fileName& dir) const
-{
- if (!allowSystemOperations)
- {
- FatalErrorIn
- (
- "codeStreamTools::copyFilesContents(const fileName&) const"
- ) << "Loading a shared library using case-supplied code is not"
- << " enabled by default" << nl
- << "because of security issues. If you trust the code you can"
- << " enable this" << nl
- << "facility be adding to the InfoSwitches setting in the system"
- << " controlDict:" << nl << nl
- << " allowSystemOperations 1" << nl << nl
- << "The system controlDict is either" << nl << nl
- << " ~/.OpenFOAM/$WM_PROJECT_VERSION/controlDict" << nl << nl
- << "or" << nl << nl
- << " $WM_PROJECT_DIR/etc/controlDict" << nl
- << endl
- << exit(FatalError);
- }
-
- // Create dir
- mkDir(dir);
-
- // Info<< "set mapping typeName=" << name_ << endl;
- // Copy any template files
- forAll(copyFiles_, i)
- {
- const fileName sourceFile(fileName(copyFiles_[i].file()).expand());
- const fileName destFile(dir/sourceFile.name());
-
- IFstream is(sourceFile);
- //Info<< "Reading from " << is.name() << endl;
- if (!is.good())
- {
- FatalErrorIn
- (
- "codeStreamTools::copyFilesContents(const fileName&)"
- " const"
- ) << "Failed opening " << sourceFile << exit(FatalError);
- }
-
- OFstream os(destFile);
- //Info<< "Writing to " << destFile.name() << endl;
- if (!os.good())
- {
- FatalErrorIn
- (
- "codeStreamTools::copyFilesContents(const fileName&)"
- " const"
- ) << "Failed writing " << destFile << exit(FatalError);
- }
-
- // variables mapping
- HashTable mapping(copyFiles_[i]);
- mapping.set("typeName", name_);
- copyAndExpand(is, os, mapping);
- }
-
-
- // Files that are always written:
- forAll(filesContents_, i)
- {
- const fileName dstFile
- (
- fileName(dir/filesContents_[i].first()).expand()
- );
-
- mkDir(dstFile.path());
- OFstream os(dstFile);
- //Info<< "Writing to " << filesContents_[i].first() << endl;
- if (!os.good())
- {
- FatalErrorIn
- (
- "codeStreamTools::copyFilesContents()"
- " const"
- ) << "Failed writing " << dstFile << exit(FatalError);
- }
- os << filesContents_[i].second().c_str() << endl;
- }
-
- return true;
-}
-
-
-bool Foam::codeStreamTools::writeDigest
-(
- const fileName& dir,
- const SHA1Digest& sha1
-)
-{
- OFstream os(dir/"SHA1Digest");
- os << sha1;
- return os.good();
-}
-
-
-Foam::SHA1Digest Foam::codeStreamTools::readDigest(const fileName& dir)
-{
- IFstream is(dir/"SHA1Digest");
- return SHA1Digest(is);
-}
-
-
-bool Foam::codeStreamTools::upToDate
-(
- const fileName& dir,
- const SHA1Digest& sha1
-)
-{
- if (!exists(dir/"SHA1Digest") || readDigest(dir) != sha1)
- {
- writeDigest(dir, sha1);
- return false;
- }
- else
- {
- return true;
- }
-}
-
-
-bool Foam::codeStreamTools::read(const dictionary& dict)
-{
- dict.lookup("copyFiles") >> copyFiles_;
- dict.lookup("filesContents") >> filesContents_;
-
- return true;
-}
-
-
-void Foam::codeStreamTools::writeDict(Ostream& os) const
-{
- os.writeKeyword("copyFiles") << copyFiles_ << token::END_STATEMENT << nl;
- os.writeKeyword("filesContents") << filesContents_ << token::END_STATEMENT
- << nl;
-}
-
-
-// ************************************************************************* //
diff --git a/src/OpenFOAM/db/dynamicLibrary/codeStream/codeStreamTools.H b/src/OpenFOAM/db/dynamicLibrary/codeStream/codeStreamTools.H
deleted file mode 100644
index 4f158b6aea..0000000000
--- a/src/OpenFOAM/db/dynamicLibrary/codeStream/codeStreamTools.H
+++ /dev/null
@@ -1,216 +0,0 @@
-/*---------------------------------------------------------------------------*\
- ========= |
- \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
- \\ / O peration |
- \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
- \\/ M anipulation |
--------------------------------------------------------------------------------
-License
- This file is part of OpenFOAM.
-
- OpenFOAM is free software; you can redistribute it and/or modify it
- under the terms of the GNU General Public License as published by the
- Free Software Foundation; either version 2 of the License, or (at your
- option) any later version.
-
- OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
- ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
- for more details.
-
- You should have received a copy of the GNU General Public License
- along with OpenFOAM; if not, write to the Free Software Foundation,
- Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-
-Class
- Foam::codeStreamTools
-
-Description
- Base for all things on-the-fly from dictionary
-
-SourceFiles
- codeStreamTools.C
-
-\*---------------------------------------------------------------------------*/
-
-#ifndef codeStreamTools_H
-#define codeStreamTools_H
-
-#include "Tuple2.H"
-#include "Pair.H"
-#include "SHA1Digest.H"
-#include "HashTable.H"
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-namespace Foam
-{
-
-// Forward declaration of classes
-class ISstream;
-class OSstream;
-
-/*---------------------------------------------------------------------------*\
- Class codeStreamTools Declaration
-\*---------------------------------------------------------------------------*/
-
-class codeStreamTools
-{
-public:
- typedef Tuple2 fileAndContent;
-
- //- Helper class for managing file and variables
- class fileAndVars
- :
- public HashTable
- {
- // Private data
- fileName file_;
-
- public:
- //- Construct null
- fileAndVars()
- {}
-
- //- Return the file name
- const fileName& file() const
- {
- return file_;
- }
-
- //- Return the file name
- fileName& file()
- {
- return file_;
- }
- };
-
-
-private:
- // Private data
-
- //- Name for underlying set
- word name_;
-
- //- Files to copy
- List copyFiles_;
-
- //- Direct contents for files
- List filesContents_;
-
-protected:
-
- void copyAndExpand
- (
- ISstream&,
- OSstream&,
- const HashTable& mapping
- ) const;
-
-public:
-
- // Static data members
-
- //- Name of the code template environment variable
- // Used to located the codeTemplateName
- static const word codeTemplateEnvName;
-
- //- Name of the code template sub-directory
- // Used when locating the codeTemplateName via Foam::findEtcFile
- static const fileName codeTemplateDirName;
-
-
- static int allowSystemOperations;
-
-
- // Constructors
-
- //- Construct null
- codeStreamTools();
-
- //- Construct from dictionary
- codeStreamTools(const word& name, const dictionary& dict);
-
- //- Copy from components
- codeStreamTools
- (
- const word& name,
- const List&,
- const List&
- );
-
- //- Construct copy
- codeStreamTools(const codeStreamTools&);
-
-
- // Member functions
-
- //- Directory for compile/link (case-specific)
- // Expanded from \$FOAM_CASE/codeStream
- static fileName baseDir();
-
- //- Subdirectory name for library
- // Expanded from platforms/\$WM_OPTIONS/lib
- static fileName libSubDir();
-
- //- Local path for specified code name
- // Expanded from \$FOAM_CASE/codeStream
- static fileName codePath(const word& subDirName);
-
- //- Local library path for specified code name
- // Expanded from \$FOAM_CASE/platforms/\$WM_OPTIONS/lib
- static fileName libPath(const word& codeName);
-
- //- The library target path for Make/files
- static string libTarget(const word& codeName);
-
-
- //- Find a code-template via the codeTemplateEnvName
- // alternatively in the codeTemplateDirName via Foam::findEtcFile
- static fileName findTemplate(const word& templateName);
-
- //- List searched locations in a format suitable for display an error
- static string searchedLocations();
-
-
-
- const word& name() const
- {
- return name_;
- }
-
- const List& copyFiles() const
- {
- return copyFiles_;
- }
-
- const List >& filesContents() const
- {
- return filesContents_;
- }
-
- bool copyFilesContents(const fileName& dir) const;
-
-
- static void* findLibrary(const fileName& libPath);
-
- static bool writeDigest(const fileName& dir, const SHA1Digest& sha1);
- static SHA1Digest readDigest(const fileName& dir);
- static bool upToDate(const fileName& dir, const SHA1Digest& sha1);
-
- bool read(const dictionary&);
-
- void writeDict(Ostream&) const;
-
-};
-
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-} // End namespace Foam
-
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
-#endif
-
-// ************************************************************************* //
diff --git a/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.C b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.C
new file mode 100644
index 0000000000..2493ad8d16
--- /dev/null
+++ b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.C
@@ -0,0 +1,554 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
+ \\/ M anipulation |
+-------------------------------------------------------------------------------
+License
+ This file is part of OpenFOAM.
+
+ OpenFOAM is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2 of the License, or (at your
+ option) any later version.
+
+ OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with OpenFOAM; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+\*---------------------------------------------------------------------------*/
+
+#include "dynamicCode.H"
+#include "dynamicCodeContext.H"
+#include "stringOps.H"
+#include "IFstream.H"
+#include "OFstream.H"
+#include "OSspecific.H"
+#include "dictionary.H"
+#include "dlLibraryTable.H"
+
+
+// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+
+int Foam::dynamicCode::allowSystemOperations
+(
+ Foam::debug::infoSwitch("allowSystemOperations", 0)
+);
+
+
+const Foam::word Foam::dynamicCode::codeTemplateEnvName
+ = "FOAM_CODE_TEMPLATES";
+
+const Foam::fileName Foam::dynamicCode::codeTemplateDirName
+ = "codeTemplates/dynamicCode";
+
+const char* Foam::dynamicCode::libTargetRoot =
+ "LIB = $(PWD)/../platforms/$(WM_OPTIONS)/lib/lib";
+
+
+// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
+
+void Foam::dynamicCode::checkSecurity
+(
+ const char* title,
+ const dictionary& dict
+)
+{
+ if (isAdministrator())
+ {
+ FatalIOErrorIn
+ (
+ title,
+ dict
+ ) << "This code should not be executed by someone with administrator"
+ << " rights due to security reasons." << nl
+ << "(it writes a shared library which then gets loaded "
+ << "using dlopen)"
+ << exit(FatalIOError);
+ }
+}
+
+
+// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
+
+void Foam::dynamicCode::copyAndFilter
+(
+ ISstream& is,
+ OSstream& os,
+ const HashTable& mapping
+)
+{
+ if (!is.good())
+ {
+ FatalErrorIn
+ (
+ "dynamicCode::copyAndFilter()"
+ " const"
+ ) << "Failed opening for reading " << is.name()
+ << exit(FatalError);
+ }
+
+ if (!os.good())
+ {
+ FatalErrorIn
+ (
+ "dynamicCode::copyAndFilter()"
+ " const"
+ ) << "Failed writing " << os.name()
+ << exit(FatalError);
+ }
+
+ // Copy file while rewriting $VARS and ${VARS}
+ string line;
+ do
+ {
+ is.getLine(line);
+
+ // expand according to mapping
+ // expanding according to env variables might cause too many
+ // surprises
+ stringOps::inplaceExpand(line, mapping);
+ os.writeQuoted(line, false) << nl;
+ }
+ while (is.good());
+}
+
+
+bool Foam::dynamicCode::resolveTemplates
+(
+ const UList& templateNames,
+ DynamicList& resolvedFiles,
+ DynamicList& badFiles
+)
+{
+ // try to get template from FOAM_CODESTREAM_TEMPLATES
+ const fileName templateDir(Foam::getEnv(codeTemplateEnvName));
+
+ bool allOkay = true;
+ forAll(templateNames, fileI)
+ {
+ const fileName& templateName = templateNames[fileI];
+
+ fileName file;
+ if (!templateDir.empty() && isDir(templateDir))
+ {
+ file = templateDir/templateName;
+ if (!isFile(file, false))
+ {
+ file.clear();
+ }
+ }
+
+ // not found - fallback to ~OpenFOAM expansion
+ if (file.empty())
+ {
+ file = findEtcFile(codeTemplateDirName/templateName);
+ }
+
+ if (file.empty())
+ {
+ badFiles.append(templateName);
+ allOkay = false;
+ }
+ else
+ {
+ resolvedFiles.append(file);
+ }
+ }
+
+ return allOkay;
+}
+
+
+bool Foam::dynamicCode::writeCommentSHA1(Ostream& os) const
+{
+ const bool hasSHA1 = filterVars_.found("SHA1sum");
+
+ if (hasSHA1)
+ {
+ os << "/* dynamicCode:\n * SHA1 = ";
+ os.writeQuoted(filterVars_["SHA1sum"], false) << "\n */\n";
+ }
+
+ return hasSHA1;
+}
+
+
+bool Foam::dynamicCode::createMakeFiles() const
+{
+ // Create Make/files
+ if (compileFiles_.empty())
+ {
+ return false;
+ }
+
+ const fileName dstFile(this->codePath()/"Make/files");
+
+ // Create dir
+ mkDir(dstFile.path());
+
+ OFstream os(dstFile);
+ //Info<< "Writing to " << dstFile << endl;
+ if (!os.good())
+ {
+ FatalErrorIn
+ (
+ "dynamicCode::createMakeFiles()"
+ " const"
+ ) << "Failed writing " << dstFile
+ << exit(FatalError);
+ }
+
+ writeCommentSHA1(os);
+
+ // Write compile files
+ forAll(compileFiles_, fileI)
+ {
+ os.writeQuoted(compileFiles_[fileI], false) << nl;
+ }
+
+ os << nl
+ << libTargetRoot << codeName_.c_str() << nl;
+
+ return true;
+}
+
+
+bool Foam::dynamicCode::createMakeOptions() const
+{
+ // Create Make/options
+ if (compileFiles_.empty() || makeOptions_.empty())
+ {
+ return false;
+ }
+
+ const fileName dstFile(this->codePath()/"Make/options");
+
+ // Create dir
+ mkDir(dstFile.path());
+
+ OFstream os(dstFile);
+ //Info<< "Writing to " << dstFile << endl;
+ if (!os.good())
+ {
+ FatalErrorIn
+ (
+ "dynamicCode::createMakeOptions()"
+ " const"
+ ) << "Failed writing " << dstFile
+ << exit(FatalError);
+ }
+
+ writeCommentSHA1(os);
+ os.writeQuoted(makeOptions_, false) << nl;
+
+ return true;
+}
+
+
+bool Foam::dynamicCode::writeDigest(const SHA1Digest& sha1) const
+{
+ const fileName file = digestFile();
+ mkDir(file.path());
+
+ OFstream os(file);
+ sha1.write(os, true) << nl;
+
+ return os.good();
+}
+
+
+bool Foam::dynamicCode::writeDigest(const std::string& sha1) const
+{
+ const fileName file = digestFile();
+ mkDir(file.path());
+
+ OFstream os(file);
+ os << '_';
+ os.writeQuoted(sha1, false) << nl;
+
+ return os.good();
+}
+
+
+// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
+
+Foam::dynamicCode::dynamicCode(const word& codeName, const word& codeDirName)
+:
+ codeRoot_(stringOps::expand("$FOAM_CASE/dynamicCode")),
+ libSubDir_(stringOps::expand("platforms/$WM_OPTIONS/lib")),
+ codeName_(codeName),
+ codeDirName_(codeDirName)
+{
+ if (codeDirName_.empty())
+ {
+ codeDirName_ = codeName_;
+ }
+
+ clear();
+}
+
+
+// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
+
+void Foam::dynamicCode::clear()
+{
+ compileFiles_.clear();
+ copyFiles_.clear();
+ createFiles_.clear();
+ filterVars_.clear();
+ filterVars_.set("typeName", codeName_);
+ filterVars_.set("SHA1sum", SHA1Digest().str());
+
+ // provide default Make/options
+ makeOptions_ =
+ "EXE_INC = -g\n"
+ "\n\nLIB_LIBS = ";
+}
+
+
+void Foam::dynamicCode::reset
+(
+ const dynamicCodeContext& context
+)
+{
+ clear();
+ setFilterContext(context);
+}
+
+
+void Foam::dynamicCode::addCompileFile(const fileName& name)
+{
+ compileFiles_.append(name);
+}
+
+
+void Foam::dynamicCode::addCopyFile(const fileName& name)
+{
+ copyFiles_.append(name);
+}
+
+
+void Foam::dynamicCode::addCreateFile
+(
+ const fileName& name,
+ const string& contents
+)
+{
+ createFiles_.append(fileAndContent(name, contents));
+}
+
+
+void Foam::dynamicCode::setFilterContext
+(
+ const dynamicCodeContext& context
+)
+{
+ filterVars_.set("code", context.code());
+ filterVars_.set("codeInclude", context.include());
+ filterVars_.set("SHA1sum", context.sha1().str());
+}
+
+
+void Foam::dynamicCode::setFilterVariable
+(
+ const word& key,
+ const std::string& value
+)
+{
+ filterVars_.set(key, value);
+}
+
+
+void Foam::dynamicCode::setMakeOptions(const std::string& content)
+{
+ makeOptions_ = content;
+}
+
+
+bool Foam::dynamicCode::copyOrCreateFiles(const bool verbose) const
+{
+ if (verbose)
+ {
+ Info<< "Creating new library in " << this->libPath() << endl;
+ }
+
+ if (!allowSystemOperations)
+ {
+ FatalErrorIn
+ (
+ "dynamicCode::copyOrCreateFiles() const"
+ ) << "Loading a shared library using case-supplied code is not"
+ << " enabled by default" << nl
+ << "because of security issues. If you trust the code you can"
+ << " enable this" << nl
+ << "facility be adding to the InfoSwitches setting in the system"
+ << " controlDict:" << nl << nl
+ << " allowSystemOperations 1" << nl << nl
+ << "The system controlDict is either" << nl << nl
+ << " ~/.OpenFOAM/$WM_PROJECT_VERSION/controlDict" << nl << nl
+ << "or" << nl << nl
+ << " $WM_PROJECT_DIR/etc/controlDict" << nl
+ << endl
+ << exit(FatalError);
+ }
+
+ const label nFiles = compileFiles_.size() + copyFiles_.size();
+
+ DynamicList resolvedFiles(nFiles);
+ DynamicList badFiles(nFiles);
+
+ // resolve template, or add to bad-files
+ resolveTemplates(compileFiles_, resolvedFiles, badFiles);
+ resolveTemplates(copyFiles_, resolvedFiles, badFiles);
+
+ if (!badFiles.empty())
+ {
+ FatalErrorIn
+ (
+ "dynamicCode::copyFilesContents(..)"
+ ) << "Could not find the code template(s): "
+ << badFiles << nl
+ << "Under the $" << codeTemplateEnvName
+ << " directory or via via the ~OpenFOAM/"
+ << codeTemplateDirName << " expansion"
+ << exit(FatalError);
+ }
+
+
+
+ // Create dir
+ const fileName outputDir = this->codePath();
+
+ // Create dir
+ mkDir(outputDir);
+
+ // Copy/filter files
+ forAll(resolvedFiles, fileI)
+ {
+ const fileName& srcFile = resolvedFiles[fileI];
+ const fileName dstFile(outputDir/srcFile.name());
+
+ IFstream is(srcFile);
+ //Info<< "Reading from " << is.name() << endl;
+ if (!is.good())
+ {
+ FatalErrorIn
+ (
+ "dynamicCode::copyFilesContents(const fileName&)"
+ " const"
+ ) << "Failed opening " << srcFile
+ << exit(FatalError);
+ }
+
+ OFstream os(dstFile);
+ //Info<< "Writing to " << dstFile.name() << endl;
+ if (!os.good())
+ {
+ FatalErrorIn
+ (
+ "dynamicCode::copyFilesContents(const fileName&)"
+ " const"
+ ) << "Failed writing " << dstFile
+ << exit(FatalError);
+ }
+
+ // Copy lines while expanding variables
+ copyAndFilter(is, os, filterVars_);
+ }
+
+
+ // Create files:
+ forAll(createFiles_, fileI)
+ {
+ const fileName dstFile
+ (
+ outputDir/stringOps::expand(createFiles_[fileI].first())
+ );
+
+ mkDir(dstFile.path());
+ OFstream os(dstFile);
+ //Info<< "Writing to " << createFiles_[fileI].first() << endl;
+ if (!os.good())
+ {
+ FatalErrorIn
+ (
+ "dynamicCode::copyOrCreateFiles()"
+ " const"
+ ) << "Failed writing " << dstFile
+ << exit(FatalError);
+ }
+ os.writeQuoted(createFiles_[fileI].second(), false) << nl;
+ }
+
+
+ // Create Make/files + Make/options
+ createMakeFiles();
+ createMakeOptions();
+
+ writeDigest(filterVars_["SHA1sum"]);
+
+ return true;
+}
+
+
+bool Foam::dynamicCode::wmakeLibso() const
+{
+ const Foam::string wmakeCmd("wmake libso " + this->codePath());
+ Info<< "Invoking " << wmakeCmd << endl;
+
+ if (Foam::system(wmakeCmd))
+ {
+ return false;
+ }
+ else
+ {
+ return true;
+ }
+}
+
+
+bool Foam::dynamicCode::upToDate(const SHA1Digest& sha1) const
+{
+ const fileName file = digestFile();
+
+ if (!exists(file, false) || SHA1Digest(IFstream(file)()) != sha1)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+
+bool Foam::dynamicCode::upToDate(const dynamicCodeContext& context) const
+{
+ return upToDate(context.sha1());
+}
+
+
+// bool Foam::dynamicCode::openLibrary() const
+// {
+// return dlLibraryTable::openLibrary(this->libPath(), false);
+// }
+//
+//
+// bool Foam::dynamicCode::closeLibrary() const
+// {
+// return dlLibraryTable::closeLibrary(this->libPath(), false);
+// }
+//
+//
+// void* Foam::dynamicCode::findLibrary() const
+// {
+// return dlLibraryTable::findLibrary(this->libPath());
+// }
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.H b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.H
new file mode 100644
index 0000000000..af7f996c08
--- /dev/null
+++ b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCode.H
@@ -0,0 +1,290 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
+ \\/ M anipulation |
+-------------------------------------------------------------------------------
+License
+ This file is part of OpenFOAM.
+
+ OpenFOAM is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2 of the License, or (at your
+ option) any later version.
+
+ OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with OpenFOAM; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Class
+ Foam::dynamicCode
+
+Description
+ Tools for handling dynamic code compilation
+
+SourceFiles
+ dynamicCode.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef dynamicCode_H
+#define dynamicCode_H
+
+#include "Tuple2.H"
+#include "SHA1Digest.H"
+#include "HashTable.H"
+#include "DynamicList.H"
+#include "dlLibraryTable.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+// Forward declaration of classes
+class dynamicCodeContext;
+class ISstream;
+class OSstream;
+
+/*---------------------------------------------------------------------------*\
+ Class dynamicCode Declaration
+\*---------------------------------------------------------------------------*/
+
+class dynamicCode
+{
+public:
+ typedef Tuple2 fileAndContent;
+
+private:
+ // Private data
+
+ //- Root for dynamic code compilation
+ fileName codeRoot_;
+
+ //- Subdirectory name for loading libraries
+ const fileName libSubDir_;
+
+ //- Name for code
+ word codeName_;
+
+ //- Name for code subdirectory
+ word codeDirName_;
+
+ //- Files to copy and filter
+ DynamicList compileFiles_;
+
+ //- Files to copy and filter
+ DynamicList copyFiles_;
+
+ //- Direct contents for files
+ DynamicList createFiles_;
+
+ //- Variables to use during filtering
+ HashTable filterVars_;
+
+ //- Contents for Make/options
+ std::string makeOptions_;
+
+
+ // Private Member Functions
+
+ //- Disallow default bitwise copy construct
+ dynamicCode(const dynamicCode&);
+
+ //- Disallow default bitwise assignment
+ void operator=(const dynamicCode&);
+
+
+protected:
+
+ // Static data members
+
+ //- Root of the LIB target for Make/files
+ static const char* libTargetRoot;
+
+
+ // Protected Member Functions
+
+ //- Copy lines while expanding variables
+ static void copyAndFilter
+ (
+ ISstream&,
+ OSstream&,
+ const HashTable& mapping
+ );
+
+ //- Resolve code-templates via the codeTemplateEnvName
+ // alternatively in the codeTemplateDirName via Foam::findEtcFile
+ static bool resolveTemplates
+ (
+ const UList& templateNames,
+ DynamicList& resolvedFiles,
+ DynamicList& badFiles
+ );
+
+ //- Write SHA1 value as C-comment
+ bool writeCommentSHA1(Ostream&) const;
+
+ //- Copy/create Make/files prior to compilation
+ bool createMakeFiles() const;
+
+ //- Copy/create Make/options prior to compilation
+ bool createMakeOptions() const;
+
+
+ //- Write digest to Make/SHA1Digest
+ bool writeDigest(const SHA1Digest&) const;
+
+ //- Write digest to Make/SHA1Digest
+ bool writeDigest(const std::string&) const;
+
+
+public:
+
+ // Static data members
+
+ //- Name of the code template environment variable
+ // Used to located the codeTemplateName
+ static const word codeTemplateEnvName;
+
+ //- Name of the code template sub-directory
+ // Used when locating the codeTemplateName via Foam::findEtcFile
+ static const fileName codeTemplateDirName;
+
+ //- Flag if system operations are allowed
+ static int allowSystemOperations;
+
+
+ // Static Member functions
+
+ //- Check security for creating dynamic code
+ static void checkSecurity(const char* title, const dictionary&);
+
+
+ // Constructors
+
+ //- Construct for a specified code name and code directory name
+ // Defaults to using the code name for the code directory name
+ dynamicCode
+ (
+ const word& codeName,
+ const word& codeDirName = ""
+ );
+
+
+ // Member functions
+
+ //- Return the code-name
+ const word& codeName() const
+ {
+ return codeName_;
+ }
+
+ //- Return the code-dirname
+ const word& codeDirName() const
+ {
+ return codeDirName_;
+ }
+
+ //- Root for dynamic code compilation
+ // Expanded from \$FOAM_CASE/dynamicCode
+ const fileName& codeRoot() const
+ {
+ return codeRoot_;
+ }
+
+ //- Subdirectory name for loading libraries
+ // Expanded from platforms/\$WM_OPTIONS/lib
+ fileName libSubDir() const
+ {
+ return libSubDir_;
+ }
+
+ //- Path for specified code name
+ // Corresponds to codeRoot()/codeDirName()
+ fileName codePath() const
+ {
+ return codeRoot_/codeDirName_;
+ }
+
+ //- Library path for specified code name
+ // Corresponds to codeRoot()/libSubDir()/lib\.so
+ fileName libPath() const
+ {
+ return codeRoot_/libSubDir_/"lib" + codeName_ + ".so";
+ }
+
+ //- Path for SHA1Digest
+ // Corresponds to codePath()/Make/SHA1Digest
+ fileName digestFile() const
+ {
+ return codeRoot_/codeDirName_/"Make/SHA1Digest";
+ }
+
+
+ //- Clear files and variables
+ void clear();
+
+ //- Clear files and reset variables to specified context
+ void reset(const dynamicCodeContext&);
+
+
+ //- Add a file template name, which will be found and filtered
+ void addCompileFile(const fileName& name);
+
+ //- Add a file template name, which will be found and filtered
+ void addCopyFile(const fileName& name);
+
+ //- Add a file to create with its contents. Will not be filtered
+ void addCreateFile(const fileName& name, const string& contents);
+
+ //- Define filter variables for code, codeInclude, SHA1sum
+ void setFilterContext(const dynamicCodeContext&);
+
+ //- Define a filter variable
+ void setFilterVariable(const word& key, const std::string& value);
+
+ //- Define contents for Make/options
+ void setMakeOptions(const std::string& content);
+
+
+ //- Verify if the copied code is up-to-date, based on Make/SHA1Digest
+ bool upToDate(const dynamicCodeContext& context) const;
+
+ //- Verify if the copied code is up-to-date, based on Make/SHA1Digest
+ bool upToDate(const SHA1Digest& sha1) const;
+
+ //- Copy/create files prior to compilation
+ bool copyOrCreateFiles(const bool verbose = false) const;
+
+ //- Compile a libso
+ bool wmakeLibso() const;
+
+// //- Open the libPath() library
+// bool openLibrary() const;
+//
+// //- Close the libPath() library
+// bool closeLibrary() const;
+//
+// //- Find the handle of the libPath() library
+// void* findLibrary() const;
+
+
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCodeContext.C b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCodeContext.C
new file mode 100644
index 0000000000..44ca8f6fda
--- /dev/null
+++ b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCodeContext.C
@@ -0,0 +1,69 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
+ \\/ M anipulation |
+-------------------------------------------------------------------------------
+License
+ This file is part of OpenFOAM.
+
+ OpenFOAM is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2 of the License, or (at your
+ option) any later version.
+
+ OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with OpenFOAM; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+\*---------------------------------------------------------------------------*/
+
+#include "dynamicCodeContext.H"
+#include "stringOps.H"
+#include "OSHA1stream.H"
+
+
+// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
+
+Foam::dynamicCodeContext::dynamicCodeContext(const dictionary& dict)
+:
+ dict_(dict),
+ code_(stringOps::trim(dict["code"])),
+ include_(),
+ options_()
+{
+ // expand dictionary entries
+ stringOps::inplaceExpand(code_, dict);
+
+ // note: removes any leading/trailing whitespace
+ // - necessary for compilation options, convenient for includes
+ // and body.
+
+ // optional
+ if (dict.found("codeInclude"))
+ {
+ include_ = stringOps::trim(dict["codeInclude"]);
+ stringOps::inplaceExpand(include_, dict);
+ }
+
+ // optional
+ if (dict.found("codeOptions"))
+ {
+ options_ = stringOps::trim(dict["codeOptions"]);
+ stringOps::inplaceExpand(options_, dict);
+ }
+
+ // calculate SHA1 digest from include, options, code
+ OSHA1stream os;
+ os << include_ << options_ << code_;
+ sha1_ = os.digest();
+}
+
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCodeContext.H b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCodeContext.H
new file mode 100644
index 0000000000..2aa248c20f
--- /dev/null
+++ b/src/OpenFOAM/db/dynamicLibrary/dynamicCode/dynamicCodeContext.H
@@ -0,0 +1,120 @@
+/*---------------------------------------------------------------------------*\
+ ========= |
+ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
+ \\ / O peration |
+ \\ / A nd | Copyright (C) 2011-2011 OpenCFD Ltd.
+ \\/ M anipulation |
+-------------------------------------------------------------------------------
+License
+ This file is part of OpenFOAM.
+
+ OpenFOAM is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License as published by the
+ Free Software Foundation; either version 2 of the License, or (at your
+ option) any later version.
+
+ OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with OpenFOAM; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+Class
+ Foam::dynamicCodeContext
+
+Description
+ Encapsulation of dynamic code dictionaries
+
+SourceFiles
+ dynamicCodeContext.C
+
+\*---------------------------------------------------------------------------*/
+
+#ifndef dynamicCodeContext_H
+#define dynamicCodeContext_H
+
+#include "dictionary.H"
+#include "SHA1Digest.H"
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+namespace Foam
+{
+
+/*---------------------------------------------------------------------------*\
+ Class dynamicCodeContext Declaration
+\*---------------------------------------------------------------------------*/
+
+class dynamicCodeContext
+{
+ // Private data
+ //- The parent dictionary context
+ const dictionary& dict_;
+
+ //- Mandatory "code" entry
+ string code_;
+
+ //- Optional "codeInclude" entry
+ string include_;
+
+ //- Optional "codeOptions" entry
+ string options_;
+
+ //- Calculated SHA1Digest
+ SHA1Digest sha1_;
+
+public:
+
+ // Constructors
+
+ //- Construct from a dictionary
+ dynamicCodeContext(const dictionary&);
+
+ // Member functions
+
+ //- Return the parent dictionary context
+ const dictionary& dict() const
+ {
+ return dict_;
+ }
+
+ //- Return the code-includes
+ const string& include() const
+ {
+ return include_;
+ }
+
+ //- Return the code-options
+ const string& options() const
+ {
+ return options_;
+ }
+
+ //- Return the code
+ const string& code() const
+ {
+ return code_;
+ }
+
+ //- Return SHA1 digest calculated from include, options, code
+ const SHA1Digest& sha1() const
+ {
+ return sha1_;
+ }
+
+
+};
+
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+} // End namespace Foam
+
+// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
+
+#endif
+
+// ************************************************************************* //
diff --git a/src/OpenFOAM/db/runTimeSelection/construction/addToRunTimeSelectionTable.H b/src/OpenFOAM/db/runTimeSelection/construction/addToRunTimeSelectionTable.H
index f0978ed635..5535ad7510 100644
--- a/src/OpenFOAM/db/runTimeSelection/construction/addToRunTimeSelectionTable.H
+++ b/src/OpenFOAM/db/runTimeSelection/construction/addToRunTimeSelectionTable.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
@@ -21,9 +21,6 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see .
-InClass
- Foam::runTimeSelectionTables
-
Description
Macros for easy insertion into run-time selection tables
@@ -53,6 +50,26 @@ Description
add_##lookup##_##thisType##argNames##ConstructorTo##baseType##Table_ \
(#lookup)
+
+// add to hash-table of functions with typename as the key
+#define addRemovableToRunTimeSelectionTable\
+(baseType,thisType,argNames) \
+ \
+ /* Add the thisType constructor function to the table */ \
+ baseType::addRemovable##argNames##ConstructorToTable< thisType > \
+ addRemovable##thisType##argNames##ConstructorTo##baseType##Table_
+
+
+// add to hash-table of functions with 'lookup' as the key
+#define addRemovableNamedToRunTimeSelectionTable\
+(baseType,thisType,argNames,lookup) \
+ \
+ /* Add the thisType constructor function to the table, find by lookup */ \
+ baseType::addRemovable##argNames##ConstructorToTable< thisType > \
+ addRemovable_##lookup##_##thisType##argNames##ConstructorTo \
+ ##baseType##Table_(#lookup)
+
+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/OpenFOAM/db/runTimeSelection/construction/runTimeSelectionTables.H b/src/OpenFOAM/db/runTimeSelection/construction/runTimeSelectionTables.H
index 4ca3c15f55..977e0f124a 100644
--- a/src/OpenFOAM/db/runTimeSelection/construction/runTimeSelectionTables.H
+++ b/src/OpenFOAM/db/runTimeSelection/construction/runTimeSelectionTables.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
@@ -21,11 +21,8 @@ License
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see .
-Class
- Foam::runTimeSelectionTables
-
Description
- Macros to enable the easy declaration of run-time selection tables.
+ Macros to ease declaration of run-time selection tables.
declareRunTimeSelectionTable is used to create a run-time selection table
for a base-class which holds constructor pointers on the table.
@@ -62,6 +59,12 @@ Description
/* Construct from argList function pointer table pointer */ \
static argNames##ConstructorTable* argNames##ConstructorTablePtr_; \
\
+ /* Table constructor called from the table add function */ \
+ static void construct##argNames##ConstructorTables(); \
+ \
+ /* Table destructor called from the table add function destructor */ \
+ static void destroy##argNames##ConstructorTables(); \
+ \
/* Class to add constructor from argList to table */ \
template< class baseType##Type > \
class add##argNames##ConstructorToTable \
@@ -88,11 +91,41 @@ Description
} \
}; \
\
- /* Table constructor called from the table add function */ \
- static void construct##argNames##ConstructorTables(); \
+ /* Class to add constructor from argList to table */ \
+ /* Remove only the entry (not the table) upon destruction */ \
+ template< class baseType##Type > \
+ class addRemovable##argNames##ConstructorToTable \
+ { \
+ /* retain lookup name for later removal */ \
+ const word& lookup_; \
\
- /* Table destructor called from the table add function destructor */ \
- static void destroy##argNames##ConstructorTables()
+ public: \
+ \
+ static autoPtr< baseType > New argList \
+ { \
+ return autoPtr< baseType >(new baseType##Type parList); \
+ } \
+ \
+ addRemovable##argNames##ConstructorToTable \
+ ( \
+ const word& lookup = baseType##Type::typeName \
+ ) \
+ : \
+ lookup_(lookup) \
+ { \
+ construct##argNames##ConstructorTables(); \
+ argNames##ConstructorTablePtr_->set(lookup, New); \
+ } \
+ \
+ ~addRemovable##argNames##ConstructorToTable() \
+ { \
+ if (argNames##ConstructorTablePtr_) \
+ { \
+ argNames##ConstructorTablePtr_->erase(lookup_); \
+ } \
+ } \
+ };
+
// external use:
@@ -111,6 +144,12 @@ Description
/* Construct from argList function pointer table pointer */ \
static argNames##ConstructorTable* argNames##ConstructorTablePtr_; \
\
+ /* Table constructor called from the table add function */ \
+ static void construct##argNames##ConstructorTables(); \
+ \
+ /* Table destructor called from the table add function destructor */ \
+ static void destroy##argNames##ConstructorTables(); \
+ \
/* Class to add constructor from argList to table */ \
template< class baseType##Type > \
class add##argNames##ConstructorToTable \
@@ -141,11 +180,43 @@ Description
} \
}; \
\
- /* Table constructor called from the table add function */ \
- static void construct##argNames##ConstructorTables(); \
+ /* Class to add constructor from argList to table */ \
+ template< class baseType##Type > \
+ class addRemovable##argNames##ConstructorToTable \
+ { \
+ /* retain lookup name for later removal */ \
+ const word& lookup_; \
\
- /* Table destructor called from the table add function destructor */ \
- static void destroy##argNames##ConstructorTables()
+ public: \
+ \
+ static autoPtr< baseType > New##baseType argList \
+ { \
+ return autoPtr< baseType >(baseType##Type::New parList.ptr()); \
+ } \
+ \
+ addRemovable##argNames##ConstructorToTable \
+ ( \
+ const word& lookup = baseType##Type::typeName \
+ ) \
+ : \
+ lookup_(lookup) \
+ { \
+ construct##argNames##ConstructorTables(); \
+ argNames##ConstructorTablePtr_->set \
+ ( \
+ lookup, \
+ New##baseType \
+ ); \
+ } \
+ \
+ ~addRemovable##argNames##ConstructorToTable() \
+ { \
+ if (argNames##ConstructorTablePtr_) \
+ { \
+ argNames##ConstructorTablePtr_->erase(lookup_); \
+ } \
+ } \
+ };
// internal use:
@@ -157,13 +228,11 @@ Description
void baseType::construct##argNames##ConstructorTables() \
{ \
static bool constructed = false; \
- \
if (!constructed) \
{ \
+ constructed = true; \
baseType::argNames##ConstructorTablePtr_ \
= new baseType::argNames##ConstructorTable; \
- \
- constructed = true; \
} \
}
@@ -244,13 +313,11 @@ Description
void baseType< Targ >::construct##argNames##ConstructorTables() \
{ \
static bool constructed = false; \
- \
if (!constructed) \
{ \
+ constructed = true; \
baseType< Targ >::argNames##ConstructorTablePtr_ \
= new baseType< Targ >::argNames##ConstructorTable; \
- \
- constructed = true; \
} \
}
diff --git a/src/OpenFOAM/db/runTimeSelection/globalFunctions/globalFunctionSelectionTables.H b/src/OpenFOAM/db/runTimeSelection/globalFunctions/globalFunctionSelectionTables.H
index 76481db279..1601c172a0 100644
--- a/src/OpenFOAM/db/runTimeSelection/globalFunctions/globalFunctionSelectionTables.H
+++ b/src/OpenFOAM/db/runTimeSelection/globalFunctions/globalFunctionSelectionTables.H
@@ -85,13 +85,14 @@ Description
} \
}
+
// internal use:
// constructor/destructor aid
#define defineGlobalFunctionSelectionTableConstructDestruct\
(memberFunction,argNames) \
\
/* Table constructor called from the table add function */ \
- void construct##memberFunction##argNames##MemberFunctionTables()\
+ void construct##memberFunction##argNames##MemberFunctionTables() \
{ \
static bool constructed = false; \
if (!constructed) \
@@ -103,7 +104,7 @@ Description
} \
\
/* Table destructor called from the table add function destructor */ \
- void destroy##memberFunction##argNames##MemberFunctionTables()\
+ void destroy##memberFunction##argNames##MemberFunctionTables() \
{ \
if (memberFunction##argNames##MemberFunctionTablePtr_) \
{ \
diff --git a/src/OpenFOAM/db/runTimeSelection/memberFunctions/memberFunctionSelectionTables.H b/src/OpenFOAM/db/runTimeSelection/memberFunctions/memberFunctionSelectionTables.H
index 13835fbb3c..16a3accd41 100644
--- a/src/OpenFOAM/db/runTimeSelection/memberFunctions/memberFunctionSelectionTables.H
+++ b/src/OpenFOAM/db/runTimeSelection/memberFunctions/memberFunctionSelectionTables.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
@@ -98,13 +98,11 @@ Description
void baseType::construct##memberFunction##argNames##MemberFunctionTables()\
{ \
static bool constructed = false; \
- \
if (!constructed) \
{ \
+ constructed = true; \
baseType::memberFunction##argNames##MemberFunctionTablePtr_ \
= new baseType::memberFunction##argNames##MemberFunctionTable;\
- \
- constructed = true; \
} \
}
@@ -191,14 +189,12 @@ Description
MemberFunctionTables() \
{ \
static bool constructed = false; \
- \
if (!constructed) \
{ \
+ constructed = true; \
baseType::memberFunction##argNames##MemberFunctionTablePtr_ \
= new baseType::memberFunction##argNames## \
MemberFunctionTable; \
- \
- constructed = true; \
} \
}
@@ -254,6 +250,7 @@ Description
defineTemplatedMemberFunctionSelectionTableDestructor \
(baseType,memberFunction,argNames,Targ)
+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
diff --git a/src/OpenFOAM/fields/cloud/cloud.C b/src/OpenFOAM/fields/cloud/cloud.C
index c4260f02ee..40eb070bcd 100644
--- a/src/OpenFOAM/fields/cloud/cloud.C
+++ b/src/OpenFOAM/fields/cloud/cloud.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
@@ -41,7 +41,7 @@ Foam::cloud::cloud(const objectRegistry& obr, const word& cloudName)
(
IOobject
(
- ( cloudName.size() ? cloudName : defaultName ),
+ (cloudName.size() ? cloudName : defaultName),
obr.time().timeName(),
prefix,
obr,
@@ -58,4 +58,12 @@ Foam::cloud::~cloud()
{}
+// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
+
+void Foam::cloud::autoMap(const mapPolyMesh&)
+{
+ notImplemented("cloud::autoMap(const mapPolyMesh&)");
+}
+
+
// ************************************************************************* //
diff --git a/src/OpenFOAM/fields/cloud/cloud.H b/src/OpenFOAM/fields/cloud/cloud.H
index a4c4eae51e..0755c6dd61 100644
--- a/src/OpenFOAM/fields/cloud/cloud.H
+++ b/src/OpenFOAM/fields/cloud/cloud.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
@@ -91,7 +91,7 @@ public:
//- Remap the cells of particles corresponding to the
// mesh topology change
- virtual void autoMap(const mapPolyMesh&) = 0;
+ virtual void autoMap(const mapPolyMesh&);
};
diff --git a/src/OpenFOAM/global/argList/argList.C b/src/OpenFOAM/global/argList/argList.C
index 08cc78f762..f055011bce 100644
--- a/src/OpenFOAM/global/argList/argList.C
+++ b/src/OpenFOAM/global/argList/argList.C
@@ -32,7 +32,7 @@ License
#include "JobInfo.H"
#include "labelList.H"
#include "regIOobject.H"
-#include "codeStreamTools.H"
+#include "dynamicCode.H"
#include
@@ -790,7 +790,7 @@ Foam::argList::argList
<< endl;
Info<< "allowSystemOperations : ";
- if (codeStreamTools::allowSystemOperations)
+ if (dynamicCode::allowSystemOperations)
{
Info<< "Allowing user-supplied system call operations" << endl;
}
diff --git a/src/OpenFOAM/include/OSspecific.H b/src/OpenFOAM/include/OSspecific.H
index 38b0d14a10..d68ae1661d 100644
--- a/src/OpenFOAM/include/OSspecific.H
+++ b/src/OpenFOAM/include/OSspecific.H
@@ -190,9 +190,12 @@ void* dlOpen(const fileName& lib);
//- Close a dlopened library using handle. Return true if successful
bool dlClose(void*);
-//- Lookup a symbol in a dlopened library using handle
+//- Lookup a symbol in a dlopened library using handle to library
void* dlSym(void* handle, const std::string& symbol);
+//- Report if symbol in a dlopened library could be found
+bool dlSymFound(void* handle, const std::string& symbol);
+
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.C b/src/OpenFOAM/meshes/polyMesh/polyMesh.C
index f83861aae9..da7ffdc266 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyMesh.C
+++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.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
@@ -1183,10 +1183,123 @@ void Foam::polyMesh::removeFiles(const fileName& instanceDir) const
}
}
+
void Foam::polyMesh::removeFiles() const
{
removeFiles(instance());
}
+void Foam::polyMesh::findCellFacePt
+(
+ const point& pt,
+ label& cellI,
+ label& tetFaceI,
+ label& tetPtI
+) const
+{
+ cellI = -1;
+ tetFaceI = -1;
+ tetPtI = -1;
+
+ const indexedOctree& tree = cellTree();
+
+ // Find nearest cell to the point
+
+ pointIndexHit info = tree.findNearest(pt, sqr(GREAT));
+
+ if (info.hit())
+ {
+ label nearestCellI = tree.shapes().cellLabels()[info.index()];
+
+ // Check the nearest cell to see if the point is inside.
+ findTetFacePt(nearestCellI, pt, tetFaceI, tetPtI);
+
+ if (tetFaceI != -1)
+ {
+ // Point was in the nearest cell
+
+ cellI = nearestCellI;
+
+ return;
+ }
+ else
+ {
+ // Check the other possible cells that the point may be in
+
+ labelList testCells = tree.findIndices(pt);
+
+ forAll(testCells, pCI)
+ {
+ label testCellI = tree.shapes().cellLabels()[testCells[pCI]];
+
+ if (testCellI == nearestCellI)
+ {
+ // Don't retest the nearest cell
+
+ continue;
+ }
+
+ // Check the test cell to see if the point is inside.
+ findTetFacePt(testCellI, pt, tetFaceI, tetPtI);
+
+ if (tetFaceI != -1)
+ {
+ // Point was in the test cell
+
+ cellI = testCellI;
+
+ return;
+ }
+ }
+ }
+ }
+ else
+ {
+ FatalErrorIn
+ (
+ "void Foam::polyMesh::findCellFacePt"
+ "("
+ "const point&, "
+ "label&, "
+ "label&, "
+ "label&"
+ ") const"
+ ) << "Did not find nearest cell in search tree."
+ << abort(FatalError);
+ }
+}
+
+
+void Foam::polyMesh::findTetFacePt
+(
+ const label cellI,
+ const point& pt,
+ label& tetFaceI,
+ label& tetPtI
+) const
+{
+ const polyMesh& mesh = *this;
+
+ tetFaceI = -1;
+ tetPtI = -1;
+
+ List cellTets =
+ polyMeshTetDecomposition::cellTetIndices(mesh, cellI);
+
+ forAll(cellTets, tetI)
+ {
+ const tetIndices& cellTetIs = cellTets[tetI];
+
+ if (cellTetIs.tet(mesh).inside(pt))
+ {
+ tetFaceI = cellTetIs.face();
+ tetPtI = cellTetIs.tetPt();
+
+ return;
+ }
+ }
+}
+
+
// ************************************************************************* //
diff --git a/src/OpenFOAM/meshes/polyMesh/polyMesh.H b/src/OpenFOAM/meshes/polyMesh/polyMesh.H
index 65cf88dbe5..2be783a25e 100644
--- a/src/OpenFOAM/meshes/polyMesh/polyMesh.H
+++ b/src/OpenFOAM/meshes/polyMesh/polyMesh.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
@@ -34,6 +34,7 @@ SourceFiles
polyMeshFromShapeMesh.C
polyMeshIO.C
polyMeshUpdate.C
+ polyMeshFindCell.C
\*---------------------------------------------------------------------------*/
@@ -391,6 +392,7 @@ public:
return *this;
}
+
// Mesh motion
//- Is mesh moving
@@ -508,6 +510,28 @@ public:
//- Remove all files from mesh instance()
void removeFiles() const;
+
+
+ // Helper functions
+
+ //- Find the cell, tetFaceI and tetPtI for the given position
+ void findCellFacePt
+ (
+ const point& pt,
+ label& cellI,
+ label& tetFaceI,
+ label& tetPtI
+ ) const;
+
+ //- Find the tetFaceI and tetPtI for the given position in
+ // the supplied cell, tetFaceI and tetPtI = -1 if not found
+ void findTetFacePt
+ (
+ const label cellI,
+ const point& pt,
+ label& tetFaceI,
+ label& tetPtI
+ ) const;
};
diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.C
index a0fd190585..b0e83ce670 100644
--- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.C
+++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.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
@@ -26,8 +26,6 @@ License
#include "primitiveMesh.H"
#include "demandDrivenData.H"
-// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
-
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::primitiveMesh, 0);
@@ -63,6 +61,8 @@ Foam::primitiveMesh::primitiveMesh()
ppPtr_(NULL),
cpPtr_(NULL),
+ cellTreePtr_(NULL),
+
labels_(0),
cellCentresPtr_(NULL),
@@ -105,6 +105,8 @@ Foam::primitiveMesh::primitiveMesh
ppPtr_(NULL),
cpPtr_(NULL),
+ cellTreePtr_(NULL),
+
labels_(0),
cellCentresPtr_(NULL),
@@ -347,4 +349,36 @@ const Foam::cellShapeList& Foam::primitiveMesh::cellShapes() const
}
+const Foam::indexedOctree&
+Foam::primitiveMesh::cellTree() const
+{
+ if (!cellTreePtr_)
+ {
+ treeBoundBox overallBb(points());
+
+ Random rndGen(261782);
+
+ overallBb = overallBb.extend(rndGen, 1E-4);
+ overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
+ overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
+
+ cellTreePtr_ =
+ new indexedOctree
+ (
+ treeDataCell
+ (
+ false, // not cache bb
+ *this
+ ),
+ overallBb,
+ 8, // maxLevel
+ 10, // leafsize
+ 3.0 // duplicity
+ );
+ }
+
+ return *cellTreePtr_;
+}
+
+
// ************************************************************************* //
diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H
index 23eefb0e0b..cc3bc2c80a 100644
--- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H
+++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.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
@@ -67,6 +67,8 @@ SourceFiles
#include "Map.H"
#include "EdgeMap.H"
#include "boundBox.H"
+#include "indexedOctree.H"
+#include "treeDataCell.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -155,6 +157,9 @@ class primitiveMesh
//- Cell-points
mutable labelListList* cpPtr_;
+ //- Search tree to allow spatial tet searching
+ mutable indexedOctree* cellTreePtr_;
+
// On-the-fly edge addresing storage
@@ -482,6 +487,10 @@ public:
const labelListList& cellPoints() const;
+ //- Build (if necessary) and return the cell search tree
+ const indexedOctree& cellTree() const;
+
+
// Geometric data (raw!)
const vectorField& cellCentres() const;
@@ -814,6 +823,9 @@ public:
//- Clear topological data
void clearAddressing();
+ //- Clear cell tree data
+ void clearCellTree();
+
//- Clear all geometry and addressing unnecessary for CFD
void clearOut();
};
diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshClear.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshClear.C
index f11a901c7d..cc232c162f 100644
--- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshClear.C
+++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshClear.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
@@ -99,6 +99,11 @@ void Foam::primitiveMesh::printAllocated() const
Pout<< " Cell-point" << endl;
}
+ if (cellTreePtr_)
+ {
+ Pout<< " Cell-tree" << endl;
+ }
+
// Geometry
if (cellCentresPtr_)
{
@@ -165,6 +170,14 @@ void Foam::primitiveMesh::clearAddressing()
deleteDemandDrivenData(pePtr_);
deleteDemandDrivenData(ppPtr_);
deleteDemandDrivenData(cpPtr_);
+
+ deleteDemandDrivenData(cellTreePtr_);
+}
+
+
+void Foam::primitiveMesh::clearCellTree()
+{
+ deleteDemandDrivenData(cellTreePtr_);
}
diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshFindCell.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshFindCell.C
index a42befb41a..c7087aa70f 100644
--- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshFindCell.C
+++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMeshFindCell.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
@@ -26,10 +26,8 @@ License
#include "primitiveMesh.H"
#include "cell.H"
-
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
-// Is the point in the cell bounding box
bool Foam::primitiveMesh::pointInCellBB
(
const point& p,
@@ -60,7 +58,6 @@ bool Foam::primitiveMesh::pointInCellBB
}
-// Is the point in the cell
bool Foam::primitiveMesh::pointInCell(const point& p, label celli) const
{
const labelList& f = cells()[celli];
@@ -86,7 +83,6 @@ bool Foam::primitiveMesh::pointInCell(const point& p, label celli) const
}
-// Find the cell with the nearest cell centre
Foam::label Foam::primitiveMesh::findNearestCell(const point& location) const
{
const vectorField& centres = cellCentres();
@@ -109,7 +105,6 @@ Foam::label Foam::primitiveMesh::findNearestCell(const point& location) const
}
-// Find cell enclosing this location
Foam::label Foam::primitiveMesh::findCell(const point& location) const
{
if (nCells() == 0)
diff --git a/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedron.H b/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedron.H
index 7e55cd872c..53e92c7f66 100644
--- a/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedron.H
+++ b/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedron.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
@@ -174,10 +174,10 @@ public:
) const;
//- Return nearest point to p on tetrahedron
- inline pointHit nearestPoint
- (
- const point& p
- ) const;
+ inline pointHit nearestPoint(const point& p) const;
+
+ //- Return true if point is inside tetrahedron
+ inline bool inside(const point& pt) const;
//- Return (min)containment sphere, i.e. the smallest sphere with
// all points inside. Returns pointHit with:
diff --git a/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedronI.H b/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedronI.H
index 38c9eae41c..0051951e6b 100644
--- a/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedronI.H
+++ b/src/OpenFOAM/meshes/primitiveShapes/tetrahedron/tetrahedronI.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
@@ -380,6 +380,82 @@ inline Foam::pointHit Foam::tetrahedron::nearestPoint
}
+template
+bool Foam::tetrahedron::inside(const point& pt) const
+{
+ // For robustness, assuming that the point is in the tet unless
+ // "definitively" shown otherwise by obtaining a positive dot
+ // product greater than a tolerance of SMALL.
+
+ // The tet is defined: tet(Cc, tetBasePt, pA, pB) where the normal
+ // vectors and base points for the half-space planes are:
+ // area[0] = Sa();
+ // area[1] = Sb();
+ // area[2] = Sc();
+ // area[3] = Sd();
+ // planeBase[0] = tetBasePt = b_
+ // planeBase[1] = ptA = c_
+ // planeBase[2] = tetBasePt = b_
+ // planeBase[3] = tetBasePt = b_
+
+ vector n = vector::zero;
+
+ {
+ // 0, a
+ const point& basePt = b_;
+
+ n = Sa();
+ n /= (Foam::mag(n) + VSMALL);
+
+ if (((pt - basePt) & n) > SMALL)
+ {
+ return false;
+ }
+ }
+
+ {
+ // 1, b
+ const point& basePt = c_;
+
+ n = Sb();
+ n /= (Foam::mag(n) + VSMALL);
+
+ if (((pt - basePt) & n) > SMALL)
+ {
+ return false;
+ }
+ }
+
+ {
+ // 2, c
+ const point& basePt = b_;
+
+ n = Sc();
+ n /= (Foam::mag(n) + VSMALL);
+
+ if (((pt - basePt) & n) > SMALL)
+ {
+ return false;
+ }
+ }
+
+ {
+ // 3, d
+ const point& basePt = b_;
+
+ n = Sd();
+ n /= (Foam::mag(n) + VSMALL);
+
+ if (((pt - basePt) & n) > SMALL)
+ {
+ return false;
+ }
+ }
+
+ return true;
+}
+
+
// * * * * * * * * * * * * * * * Ostream Operator * * * * * * * * * * * * * //
template
diff --git a/src/meshTools/octree/treeBoundBox.C b/src/OpenFOAM/meshes/treeBoundBox/treeBoundBox.C
similarity index 100%
rename from src/meshTools/octree/treeBoundBox.C
rename to src/OpenFOAM/meshes/treeBoundBox/treeBoundBox.C
diff --git a/src/meshTools/octree/treeBoundBox.H b/src/OpenFOAM/meshes/treeBoundBox/treeBoundBox.H
similarity index 100%
rename from src/meshTools/octree/treeBoundBox.H
rename to src/OpenFOAM/meshes/treeBoundBox/treeBoundBox.H
diff --git a/src/meshTools/octree/treeBoundBoxI.H b/src/OpenFOAM/meshes/treeBoundBox/treeBoundBoxI.H
similarity index 99%
rename from src/meshTools/octree/treeBoundBoxI.H
rename to src/OpenFOAM/meshes/treeBoundBox/treeBoundBoxI.H
index 7426e04708..1f069feb48 100644
--- a/src/meshTools/octree/treeBoundBoxI.H
+++ b/src/OpenFOAM/meshes/treeBoundBox/treeBoundBoxI.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
diff --git a/src/meshTools/octree/treeBoundBoxList.H b/src/OpenFOAM/meshes/treeBoundBox/treeBoundBoxList.H
similarity index 96%
rename from src/meshTools/octree/treeBoundBoxList.H
rename to src/OpenFOAM/meshes/treeBoundBox/treeBoundBoxList.H
index 610df2c1b1..b82eede2f0 100644
--- a/src/meshTools/octree/treeBoundBoxList.H
+++ b/src/OpenFOAM/meshes/treeBoundBox/treeBoundBoxList.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
diff --git a/src/meshTools/octree/treeBoundBoxTemplates.C b/src/OpenFOAM/meshes/treeBoundBox/treeBoundBoxTemplates.C
similarity index 96%
rename from src/meshTools/octree/treeBoundBoxTemplates.C
rename to src/OpenFOAM/meshes/treeBoundBox/treeBoundBoxTemplates.C
index c8cb5fab5d..09e0a9be7a 100644
--- a/src/meshTools/octree/treeBoundBoxTemplates.C
+++ b/src/OpenFOAM/meshes/treeBoundBox/treeBoundBoxTemplates.C
@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
- \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd.
+ \\ / A nd | Copyright (C) 2010-2011 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
diff --git a/src/OpenFOAM/primitives/hashes/SHA1/SHA1.C b/src/OpenFOAM/primitives/hashes/SHA1/SHA1.C
index 5a54e10d6e..5c97cee6c4 100644
--- a/src/OpenFOAM/primitives/hashes/SHA1/SHA1.C
+++ b/src/OpenFOAM/primitives/hashes/SHA1/SHA1.C
@@ -151,7 +151,7 @@ void Foam::SHA1::processBytes(const void *data, size_t len)
// while (len > 64)
while (len >= 64)
{
- processBlock(memcpy (buffer_, data, 64), 64);
+ processBlock(memcpy(buffer_, data, 64), 64);
data = reinterpret_cast(data) + 64;
len -= 64;
}
@@ -177,7 +177,7 @@ void Foam::SHA1::processBytes(const void *data, size_t len)
{
processBlock(buffer_, 64);
remaining -= 64;
- memcpy (buffer_, &buffer_[16], remaining);
+ memcpy(buffer_, &buffer_[16], remaining);
}
bufLen_ = remaining;
}
@@ -241,10 +241,10 @@ Foam::SHA1::processBlock(const void *data, size_t len)
while (words < endp)
{
uint32_t tm;
- for (int t = 0; t < 16; t++)
+ for (int t = 0; t < 16; ++t)
{
- x[t] = swapBytes (*words);
- words++;
+ x[t] = swapBytes(*words);
+ ++words;
}
R( a, b, c, d, e, F1, K1, x[ 0] );
@@ -343,11 +343,11 @@ void Foam::SHA1::calcDigest(SHA1Digest& dig) const
{
unsigned char *r = dig.v_;
- set_uint32 (r + 0 * sizeof(uint32_t), swapBytes(hashsumA_));
- set_uint32 (r + 1 * sizeof(uint32_t), swapBytes(hashsumB_));
- set_uint32 (r + 2 * sizeof(uint32_t), swapBytes(hashsumC_));
- set_uint32 (r + 3 * sizeof(uint32_t), swapBytes(hashsumD_));
- set_uint32 (r + 4 * sizeof(uint32_t), swapBytes(hashsumE_));
+ set_uint32(r + 0 * sizeof(uint32_t), swapBytes(hashsumA_));
+ set_uint32(r + 1 * sizeof(uint32_t), swapBytes(hashsumB_));
+ set_uint32(r + 2 * sizeof(uint32_t), swapBytes(hashsumC_));
+ set_uint32(r + 3 * sizeof(uint32_t), swapBytes(hashsumD_));
+ set_uint32(r + 4 * sizeof(uint32_t), swapBytes(hashsumE_));
}
else
{
diff --git a/src/OpenFOAM/primitives/hashes/SHA1/SHA1Digest.C b/src/OpenFOAM/primitives/hashes/SHA1/SHA1Digest.C
index 16dbd838cd..bf0730d2e4 100644
--- a/src/OpenFOAM/primitives/hashes/SHA1/SHA1Digest.C
+++ b/src/OpenFOAM/primitives/hashes/SHA1/SHA1Digest.C
@@ -30,6 +30,8 @@ License
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
+const Foam::SHA1Digest Foam::SHA1Digest::null;
+
//! \cond fileScope
static const char hexChars[] = "0123456789abcdef";
//! \endcond
@@ -40,12 +42,18 @@ static const char hexChars[] = "0123456789abcdef";
unsigned char Foam::SHA1Digest::readHexDigit(Istream& is)
{
// Takes into account that 'a' (or 'A') is 10
- static const label alphaOffset = toupper('A') - 10;
+ static const int alphaOffset = toupper('A') - 10;
// Takes into account that '0' is 0
- static const label zeroOffset = int('0');
+ static const int zeroOffset = int('0');
+
+ // silently ignore leading or intermediate '_'
char c = 0;
- is.read(c);
+ do
+ {
+ is.read(c);
+ }
+ while (c == '_');
if (!isxdigit(c))
{
@@ -101,12 +109,21 @@ bool Foam::SHA1Digest::empty() const
}
-std::string Foam::SHA1Digest::str() const
+std::string Foam::SHA1Digest::str(const bool prefixed) const
{
std::string buf;
- buf.resize(length*2);
-
unsigned nChar = 0;
+
+ if (prefixed)
+ {
+ buf.resize(1 + length*2);
+ buf[nChar++] = '_';
+ }
+ else
+ {
+ buf.resize(length*2);
+ }
+
for (unsigned i = 0; i < length; ++i)
{
buf[nChar++] = hexChars[((v_[i] >> 4) & 0xF)];
@@ -117,6 +134,24 @@ std::string Foam::SHA1Digest::str() const
}
+Foam::Ostream& Foam::SHA1Digest::write(Ostream& os, const bool prefixed) const
+{
+ if (prefixed)
+ {
+ os.write('_');
+ }
+
+ for (unsigned i = 0; i < length; ++i)
+ {
+ os.write(hexChars[((v_[i] >> 4) & 0xF)]);
+ os.write(hexChars[(v_[i] & 0xF)]);
+ }
+
+ os.check("SHA1Digest::write(Ostream&, const bool)");
+ return os;
+}
+
+
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
bool Foam::SHA1Digest::operator==(const SHA1Digest& rhs) const
@@ -141,21 +176,26 @@ bool Foam::SHA1Digest::operator==(const std::string& hexdigits) const
return empty();
}
+ // skip possible '_' prefix
+ unsigned charI = 0;
+ if (hexdigits[0] == '_')
+ {
+ ++charI;
+ }
+
// incorrect length - can never match
- if (hexdigits.size() != length*2)
+ if (hexdigits.size() != charI + length*2)
{
return false;
}
- for (unsigned i = 0, charI = 0; i < length; ++i, charI += 2)
+ for (unsigned i = 0; i < length; ++i)
{
const char c1 = hexChars[((v_[i] >> 4) & 0xF)];
const char c2 = hexChars[(v_[i] & 0xF)];
- if (c1 != hexdigits[charI] || c2 != hexdigits[charI+1])
- {
- return false;
- }
+ if (c1 != hexdigits[charI++]) return false;
+ if (c2 != hexdigits[charI++]) return false;
}
return true;
@@ -170,21 +210,26 @@ bool Foam::SHA1Digest::operator==(const char* hexdigits) const
return empty();
}
+ // skip possible '_' prefix
+ unsigned charI = 0;
+ if (hexdigits[0] == '_')
+ {
+ ++charI;
+ }
+
// incorrect length - can never match
- if (strlen(hexdigits) != length*2)
+ if (strlen(hexdigits) != charI + length*2)
{
return false;
}
- for (unsigned i = 0, charI = 0; i < length; ++i, charI += 2)
+ for (unsigned i = 0; i < length; ++i)
{
const char c1 = hexChars[((v_[i] >> 4) & 0xF)];
const char c2 = hexChars[(v_[i] & 0xF)];
- if (c1 != hexdigits[charI] || c2 != hexdigits[charI+1])
- {
- return false;
- }
+ if (c1 != hexdigits[charI++]) return false;
+ if (c2 != hexdigits[charI++]) return false;
}
return true;
@@ -230,16 +275,7 @@ Foam::Istream& Foam::operator>>(Istream& is, SHA1Digest& dig)
Foam::Ostream& Foam::operator<<(Ostream& os, const SHA1Digest& dig)
{
- const unsigned char *v = dig.v_;
-
- for (unsigned i = 0; i < dig.length; ++i)
- {
- os.write(hexChars[((v[i] >> 4) & 0xF)]);
- os.write(hexChars[(v[i] & 0xF)]);
- }
-
- os.check("Ostream& operator<<(Ostream&, const SHA1Digest&)");
- return os;
+ return dig.write(os);
}
diff --git a/src/OpenFOAM/primitives/hashes/SHA1/SHA1Digest.H b/src/OpenFOAM/primitives/hashes/SHA1/SHA1Digest.H
index dca6adc367..e93a72b020 100644
--- a/src/OpenFOAM/primitives/hashes/SHA1/SHA1Digest.H
+++ b/src/OpenFOAM/primitives/hashes/SHA1/SHA1Digest.H
@@ -46,8 +46,8 @@ namespace Foam
{
// Forward declaration of classes
-class Ostream;
class Istream;
+class Ostream;
// Forward declaration of friend functions and operators
class SHA1;
@@ -57,7 +57,7 @@ Istream& operator>>(Istream&, SHA1Digest&);
/*---------------------------------------------------------------------------*\
- Class SHA1Digest Declaration
+ Class SHA1Digest Declaration
\*---------------------------------------------------------------------------*/
class SHA1Digest
@@ -65,57 +65,89 @@ class SHA1Digest
public:
friend class SHA1;
- //- The length of the digest contents
- static const unsigned length = 20;
+ // Static data members
- //- Construct a zero digest
- SHA1Digest();
+ //- The length of the (uncoded) digest contents
+ static const unsigned length = 20;
- //- Construct read a digest
- SHA1Digest(Istream&);
-
- //- Reset the digest to zero
- void clear();
-
- //- Return true if the digest is empty (ie, all zero).
- bool empty() const;
-
- //- Return string representation
- std::string str() const;
-
- //- Equality operator
- bool operator==(const SHA1Digest&) const;
-
- //- Compare to (40-byte) text representation (eg, from sha1sum)
- // An %empty string is equivalent to
- // "0000000000000000000000000000000000000000"
- bool operator==(const std::string& hexdigits) const;
-
- //- Compare to (40-byte) text representation (eg, from sha1sum)
- // A %null or %empty string is equivalent to
- // "0000000000000000000000000000000000000000"
- bool operator==(const char* hexdigits) const;
+ //- A null digest (ie, all zero)
+ static const SHA1Digest null;
- //- Inequality operator
- bool operator!=(const SHA1Digest&) const;
+ // Constructors
- //- Inequality operator
- bool operator!=(const std::string& hexdigits) const;
+ //- Construct a zero digest
+ SHA1Digest();
- //- Inequality operator
- bool operator!=(const char* hexdigits) const;
+ //- Construct read a digest
+ SHA1Digest(Istream&);
- friend Ostream& operator<<(Ostream&, const SHA1Digest&);
- friend Istream& operator>>(Istream&, SHA1Digest&);
+ // Member Functions
+
+ //- Reset the digest to zero
+ void clear();
+
+ //- Return true if the digest is empty (ie, all zero).
+ bool empty() const;
+
+ //- Return (40-byte) text representation, optionally with '_' prefix
+ std::string str(const bool prefixed=false) const;
+
+ //- Write (40-byte) text representation, optionally with '_' prefix
+ Ostream& write(Ostream&, const bool prefixed=false) const;
+
+
+ // Member Operators
+
+ //- Equality operator
+ bool operator==(const SHA1Digest&) const;
+
+ //- Compare to (40-byte) text representation (eg, from sha1sum)
+ // An %empty string is equivalent to
+ // "0000000000000000000000000000000000000000"
+ // The hexdigits may optionally start with a '_' prefix
+ bool operator==(const std::string& hexdigits) const;
+
+ //- Compare to (40-byte) text representation (eg, from sha1sum)
+ // A %null or %empty string is equivalent to
+ // "0000000000000000000000000000000000000000"
+ // The hexdigits may optionally start with a '_' prefix
+ bool operator==(const char* hexdigits) const;
+
+
+ //- Inequality operator
+ bool operator!=(const SHA1Digest&) const;
+
+ //- Inequality operator
+ bool operator!=(const std::string& hexdigits) const;
+
+ //- Inequality operator
+ bool operator!=(const char* hexdigits) const;
+
+
+
+
+ // IOstream Operators
+
+ //- Read (40-byte) text representation
+ // Since leading and intermediate underscores are skipped, a '_' can
+ // be prefixed to the text representation to use an unquoted
+ // SHA1Digest without parsing ambiguities as a number.
+ friend Istream& operator>>(Istream&, SHA1Digest&);
+
+ //- Write (40-byte) text representation, unquoted and without prefix
+ friend Ostream& operator<<(Ostream&, const SHA1Digest&);
+
private:
+ // Private data
- //- The digest contents
- unsigned char v_[length];
+ //- The digest contents
+ unsigned char v_[length];
- static unsigned char readHexDigit(Istream&);
+ //- Read hexadecimal value, ignoring leading or intermediate '_'
+ static unsigned char readHexDigit(Istream&);
};
diff --git a/src/OpenFOAM/primitives/strings/string/string.C b/src/OpenFOAM/primitives/strings/string/string.C
index 05ad3a5682..4c9218d77e 100644
--- a/src/OpenFOAM/primitives/strings/string/string.C
+++ b/src/OpenFOAM/primitives/strings/string/string.C
@@ -93,8 +93,7 @@ Foam::string& Foam::string::replaceAll
}
-// Expand all occurences of environment variables and initial tilde sequences
-Foam::string& Foam::string::expand(const bool recurse, const bool allowEmptyVar)
+Foam::string& Foam::string::expand(const bool allowEmpty)
{
size_type begVar = 0;
@@ -134,20 +133,15 @@ Foam::string& Foam::string::expand(const bool recurse, const bool allowEmptyVar)
if (endVar != npos && endVar != begVar)
{
- string varName = substr
+ const string varName = substr
(
begVar + 1 + delim,
endVar - begVar - 2*delim
);
- string varValue = getEnv(varName);
-
+ const string varValue = getEnv(varName);
if (varValue.size())
{
- if (recurse)
- {
- varValue.expand(recurse, allowEmptyVar);
- }
std::string::replace
(
begVar,
@@ -156,7 +150,7 @@ Foam::string& Foam::string::expand(const bool recurse, const bool allowEmptyVar)
);
begVar += varValue.size();
}
- else if (allowEmptyVar)
+ else if (allowEmpty)
{
std::string::replace
(
diff --git a/src/OpenFOAM/primitives/strings/string/string.H b/src/OpenFOAM/primitives/strings/string/string.H
index 8dec948567..618ce6bb59 100644
--- a/src/OpenFOAM/primitives/strings/string/string.H
+++ b/src/OpenFOAM/primitives/strings/string/string.H
@@ -180,13 +180,10 @@ public:
// - leading "~user" : home directory for specified user
// - leading "~OpenFOAM" : site/user OpenFOAM configuration directory
//
+ // Any unknown entries are removed silently if allowEmpty is true
// \sa
// Foam::findEtcFile
- string& expand
- (
- const bool recurse=false,
- const bool allowEmptyVar = false
- );
+ string& expand(const bool allowEmpty = false);
//- Remove repeated characters returning true if string changed
bool removeRepeated(const char);
diff --git a/src/OpenFOAM/primitives/strings/stringOps/stringOps.C b/src/OpenFOAM/primitives/strings/stringOps/stringOps.C
index 49142b10ec..99e7fb8ab3 100644
--- a/src/OpenFOAM/primitives/strings/stringOps/stringOps.C
+++ b/src/OpenFOAM/primitives/strings/stringOps/stringOps.C
@@ -24,7 +24,9 @@ License
\*---------------------------------------------------------------------------*/
#include "stringOps.H"
+#include "typeInfo.H"
#include "OSspecific.H"
+#include "OStringStream.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -73,10 +75,17 @@ Foam::string& Foam::stringOps::inplaceExpand
{
string::iterator iter = s.begin() + begVar + 1;
+ // more generous in accepting keywords than for env variables
while
(
iter != s.end()
- && (isalnum(*iter) || *iter == '_')
+ &&
+ (
+ isalnum(*iter)
+ || *iter == '.'
+ || *iter == ':'
+ || *iter == '_'
+ )
)
{
++iter;
@@ -86,10 +95,14 @@ Foam::string& Foam::stringOps::inplaceExpand
if (endVar != string::npos && endVar != begVar)
{
- string varName = s.substr
+ const word varName
(
- begVar + 1 + delim,
- endVar - begVar - 2*delim
+ s.substr
+ (
+ begVar + 1 + delim,
+ endVar - begVar - 2*delim
+ ),
+ false
);
HashTable::const_iterator fnd =
@@ -130,24 +143,145 @@ Foam::string& Foam::stringOps::inplaceExpand
}
-Foam::string Foam::stringOps::expandEnv
+Foam::string Foam::stringOps::expand
(
const string& original,
- const bool recurse,
- const bool allowEmptyVar
+ const dictionary& dict,
+ const char sigil
)
{
string s(original);
- return inplaceExpandEnv(s, recurse, allowEmptyVar);
+ return inplaceExpand(s, dict, sigil);
}
-// Expand all occurences of environment variables and initial tilde sequences
-Foam::string& Foam::stringOps::inplaceExpandEnv
+Foam::string& Foam::stringOps::inplaceExpand
(
string& s,
- const bool recurse,
- const bool allowEmptyVar
+ const dictionary& dict,
+ const char sigil
+)
+{
+ string::size_type begVar = 0;
+
+ // Expand $VAR or ${VAR}
+ // Repeat until nothing more is found
+ while
+ (
+ (begVar = s.find(sigil, begVar)) != string::npos
+ && begVar < s.size()-1
+ )
+ {
+ if (begVar == 0 || s[begVar-1] != '\\')
+ {
+ // Find end of first occurrence
+ string::size_type endVar = begVar;
+ string::size_type delim = 0;
+
+ if (s[begVar+1] == '{')
+ {
+ endVar = s.find('}', begVar);
+ delim = 1;
+ }
+ else
+ {
+ string::iterator iter = s.begin() + begVar + 1;
+
+ // more generous in accepting keywords than for env variables
+ while
+ (
+ iter != s.end()
+ &&
+ (
+ isalnum(*iter)
+ || *iter == '.'
+ || *iter == ':'
+ || *iter == '_'
+ )
+ )
+ {
+ ++iter;
+ ++endVar;
+ }
+ }
+
+ if (endVar != string::npos && endVar != begVar)
+ {
+ const word varName
+ (
+ s.substr
+ (
+ begVar + 1 + delim,
+ endVar - begVar - 2*delim
+ ),
+ false
+ );
+
+
+ // lookup in the dictionary
+ const entry* ePtr = dict.lookupEntryPtr(varName, true, true);
+
+ // if defined - copy its entries
+ if (ePtr)
+ {
+ OStringStream buf;
+ if (ePtr->isDict())
+ {
+ ePtr->dict().write(buf, false);
+ }
+ else
+ {
+ // fail for other types
+ dynamicCast
+ (
+ *ePtr
+ ).write(buf, true);
+ }
+
+ s.std::string::replace
+ (
+ begVar,
+ endVar - begVar + 1,
+ buf.str()
+ );
+ begVar += buf.str().size();
+ }
+ else
+ {
+ // not defined - leave original string untouched
+ begVar = endVar;
+ }
+ }
+ else
+ {
+ break;
+ }
+ }
+ else
+ {
+ ++begVar;
+ }
+ }
+
+ return s;
+}
+
+
+Foam::string Foam::stringOps::expand
+(
+ const string& original,
+ const bool allowEmpty
+)
+{
+ string s(original);
+ return inplaceExpand(s, allowEmpty);
+}
+
+
+Foam::string& Foam::stringOps::inplaceExpand
+(
+ string& s,
+ const bool allowEmpty
)
{
string::size_type begVar = 0;
@@ -188,20 +322,19 @@ Foam::string& Foam::stringOps::inplaceExpandEnv
if (endVar != string::npos && endVar != begVar)
{
- string varName = s.substr
+ const word varName
(
- begVar + 1 + delim,
- endVar - begVar - 2*delim
+ s.substr
+ (
+ begVar + 1 + delim,
+ endVar - begVar - 2*delim
+ ),
+ false
);
- string varValue = getEnv(varName);
-
+ const string varValue = getEnv(varName);
if (varValue.size())
{
- if (recurse)
- {
- varValue.expand(recurse, allowEmptyVar);
- }
s.std::string::replace
(
begVar,
@@ -210,7 +343,7 @@ Foam::string& Foam::stringOps::inplaceExpandEnv
);
begVar += varValue.size();
}
- else if (allowEmptyVar)
+ else if (allowEmpty)
{
s.std::string::replace
(
@@ -221,7 +354,10 @@ Foam::string& Foam::stringOps::inplaceExpandEnv
}
else
{
- FatalErrorIn("string::expand(const bool, const bool)")
+ FatalErrorIn
+ (
+ "stringOps::inplaceExpand(string&, const bool)"
+ )
<< "Unknown variable name " << varName << '.'
<< exit(FatalError);
}
@@ -294,7 +430,7 @@ Foam::string Foam::stringOps::trimLeft(const string& s)
if (!s.empty())
{
string::size_type beg = 0;
- while (isspace(s[beg]))
+ while (beg < s.size() && isspace(s[beg]))
{
++beg;
}
@@ -314,7 +450,7 @@ Foam::string& Foam::stringOps::inplaceTrimLeft(string& s)
if (!s.empty())
{
string::size_type beg = 0;
- while (isspace(s[beg]))
+ while (beg < s.size() && isspace(s[beg]))
{
++beg;
}
@@ -380,4 +516,5 @@ Foam::string& Foam::stringOps::inplaceTrim(string& s)
return s;
}
+
// ************************************************************************* //
diff --git a/src/OpenFOAM/primitives/strings/stringOps/stringOps.H b/src/OpenFOAM/primitives/strings/stringOps/stringOps.H
index d9756a2705..cfd7993739 100644
--- a/src/OpenFOAM/primitives/strings/stringOps/stringOps.H
+++ b/src/OpenFOAM/primitives/strings/stringOps/stringOps.H
@@ -36,6 +36,7 @@ SourceFiles
#define stringOps_H
#include "string.H"
+#include "dictionary.H"
#include "HashTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -54,6 +55,8 @@ namespace stringOps
// -# variables
// - "$VAR", "${VAR}"
//
+ // Any unknown entries are removed
+ //
// \note the leading sigil can be changed to avoid conflicts with other
// string expansions
string expand
@@ -69,6 +72,8 @@ namespace stringOps
// -# variables
// - "$VAR", "${VAR}"
//
+ // Any unknown entries are removed
+ //
// \note the leading sigil can be changed to avoid conflicts with other
// string expansions
string& inplaceExpand
@@ -78,6 +83,39 @@ namespace stringOps
const char sigil = '$'
);
+ //- Expand occurences of variables according to the dictionary
+ // Expansion includes:
+ // -# variables
+ // - "$VAR", "${VAR}"
+ //
+ // Any unknown entries are left as-is
+ //
+ // \note the leading sigil can be changed to avoid conflicts with other
+ // string expansions
+ string expand
+ (
+ const string&,
+ const dictionary& dict,
+ const char sigil = '$'
+ );
+
+
+ //- Inplace expand occurences of variables according to the dictionary
+ // Expansion includes:
+ // -# variables
+ // - "$VAR", "${VAR}"
+ //
+ // Any unknown entries are left as-is
+ //
+ // \note the leading sigil can be changed to avoid conflicts with other
+ // string expansions
+ string& inplaceExpand
+ (
+ string&,
+ const dictionary& dict,
+ const char sigil = '$'
+ );
+
//- Expand initial tildes and all occurences of environment variables
// Expansion includes:
@@ -90,13 +128,13 @@ namespace stringOps
// - leading "~user" : home directory for specified user
// - leading "~OpenFOAM" : site/user OpenFOAM configuration directory
//
+ // Any unknown entries are removed silently if allowEmpty is true
// \sa
// Foam::findEtcFile
- string expandEnv
+ string expand
(
const string&,
- const bool recurse=false,
- const bool allowEmptyVar = false
+ const bool allowEmpty = false
);
@@ -111,13 +149,13 @@ namespace stringOps
// - leading "~user" : home directory for specified user
// - leading "~OpenFOAM" : site/user OpenFOAM configuration directory
//
+ // Any unknown entries are removed silently if allowEmpty is true
// \sa
// Foam::findEtcFile
- string& inplaceExpandEnv
+ string& inplaceExpand
(
string&,
- const bool recurse=false,
- const bool allowEmptyVar = false
+ const bool allowEmpty = false
);
@@ -128,23 +166,18 @@ namespace stringOps
string& inplaceTrimLeft(string&);
//- Return string trimmed of trailing whitespace
- // NOT IMPLEMENTED
string trimRight(const string&);
//- Trim trailing whitespace inplace
- // NOT IMPLEMENTED
string& inplaceTrimRight(string&);
//- Return string trimmed of leading and trailing whitespace
- // NOT IMPLEMENTED
string trim(const string&);
//- Trim leading and trailing whitespace inplace
- // NOT IMPLEMENTED
string& inplaceTrim(string&);
-
} // End namespace stringOps
diff --git a/src/conversion/meshReader/calcPointCells.C b/src/conversion/meshReader/calcPointCells.C
index 948d15ce81..a1e0f92285 100644
--- a/src/conversion/meshReader/calcPointCells.C
+++ b/src/conversion/meshReader/calcPointCells.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
@@ -33,7 +33,7 @@ Description
void Foam::meshReader::calcPointCells() const
{
- const static label UNIT_POINT_CELLS = 12;
+ static const label UNIT_POINT_CELLS = 12;
if (pointCellsPtr_)
{
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codeProperties.C b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codeProperties.C
index e56fc33635..c104d3d71b 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codeProperties.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codeProperties.C
@@ -24,12 +24,12 @@ License
\*---------------------------------------------------------------------------*/
#include "codeProperties.H"
-#include "Time.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(Foam::codeProperties, 0);
+
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::codeProperties::codeProperties(const IOobject& io)
@@ -41,6 +41,20 @@ Foam::codeProperties::codeProperties(const IOobject& io)
// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
+bool Foam::codeProperties::modified() const
+{
+ modified_ = modified_ || regIOobject::modified();
+
+ return modified_;
+}
+
+
+void Foam::codeProperties::setUnmodified() const
+{
+ modified_ = false;
+}
+
+
bool Foam::codeProperties::read()
{
if (regIOobject::read())
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codeProperties.H b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codeProperties.H
index 6916fa362f..f8d855274f 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codeProperties.H
+++ b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codeProperties.H
@@ -25,7 +25,7 @@ Class
Foam::codeProperties
Description
- IOdictionary + flag whether file has changed.
+ IOdictionary with an internal flag to explicitly track when a file changed.
SourceFiles
codeProperties.C
@@ -35,7 +35,6 @@ SourceFiles
#ifndef codeProperties_H
#define codeProperties_H
-#include "MeshObject.H"
#include "IOdictionary.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@@ -53,7 +52,7 @@ class codeProperties
{
// Private data
- //- File change
+ //- Monitor file change
mutable bool modified_;
public:
@@ -69,15 +68,12 @@ public:
// Member Functions
- bool modified() const
- {
- return modified_;
- }
+ //- A sticky version of regIOobject::modified()
+ // Must explicitly clear with setUnmodified()
+ virtual bool modified() const;
- void setUnmodified() const
- {
- modified_ = false;
- }
+ //- Make modification unsticky
+ void setUnmodified() const;
//- Read the dictionary
virtual bool read();
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.C
index b87a560ac0..8175f1b5ed 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.C
+++ b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.C
@@ -33,8 +33,8 @@ License
#include "IFstream.H"
#include "OFstream.H"
#include "SHA1Digest.H"
-#include "OSHA1stream.H"
-#include "codeStreamTools.H"
+#include "dynamicCode.H"
+#include "dynamicCodeContext.H"
#include "codeProperties.H"
#include "stringOps.H"
@@ -78,210 +78,227 @@ Foam::codedFixedValueFvPatchScalarField::dict() const
}
-void Foam::codedFixedValueFvPatchScalarField::writeLibrary
+void Foam::codedFixedValueFvPatchScalarField::createLibrary
(
- const fileName& codePath,
- const fileName& libPath,
- const dictionary& dict
-)
+ dynamicCode& dynCode,
+ const dynamicCodeContext& context
+) const
{
// Write files for new library
- if (!Pstream::master())
+ if (Pstream::master() && !dynCode.upToDate(context))
{
- return;
- }
+ // filter with this context
+ dynCode.reset(context);
- // "codeInclude" is optional
- string codeInclude;
- if (dict.found("codeInclude"))
- {
- codeInclude = stringOps::trim(dict["codeInclude"]);
- }
+ // compile filtered C template
+ dynCode.addCompileFile(codeTemplateC);
- // "codeOptions" is optional
- string codeOptions;
- if (dict.found("codeOptions"))
- {
- codeOptions = stringOps::trim(dict["codeOptions"]);
- }
+ // copy filtered H template
+ dynCode.addCopyFile(codeTemplateH);
- // "code" is mandatory
- string code = stringOps::trim(dict["code"]);
-
- // Create SHA1 digest from the contents
- SHA1Digest sha;
- {
- OSHA1stream os;
- os << codeInclude << codeOptions << code;
- sha = os.digest();
- }
-
-// Info<<"old SHA1: " << sha1_ << nl
-// <<"new SHA1: " << sha << endl;
-
-
- // (void) codeStreamTools::upToDate(codePath, sha)
- // TODO: compile on-demand
- if (true)
- {
- Info<< "Creating new library in " << libPath << endl;
-
- const fileName fileCsrc(codeStreamTools::findTemplate(codeTemplateC));
- const fileName fileHsrc(codeStreamTools::findTemplate(codeTemplateH));
-
- // not found!
- if (fileCsrc.empty() || fileHsrc.empty())
- {
- FatalIOErrorIn
- (
- "codedFixedValueFvPatchScalarField::writeLibrary(..)",
- dict
- ) << "Could not find one or both code templates: "
- << codeTemplateC << ", " << codeTemplateH << nl
- << codeStreamTools::searchedLocations()
- << exit(FatalIOError);
- }
-
-
-
- List copyFiles(2);
- copyFiles[0].file() = fileCsrc;
- copyFiles[0].set("codeInclude", codeInclude);
- copyFiles[0].set("code", code);
-
- copyFiles[1].file() = fileHsrc;
-
-
- List filesContents(2);
-
- // Write Make/files
- filesContents[0].first() = "Make/files";
- filesContents[0].second() =
- codeTemplateC + "\n\n"
- + codeStreamTools::libTarget(redirectType_);
-
- // Write Make/options
- filesContents[1].first() = "Make/options";
- filesContents[1].second() =
+ // define Make/options
+ dynCode.setMakeOptions
+ (
"EXE_INC = -g \\\n"
"-I$(LIB_SRC)/finiteVolume/lnInclude\\\n"
- + codeOptions
- + "\n\nLIB_LIBS = ";
+ + context.options()
+ + "\n\nLIB_LIBS = "
+ );
- codeStreamTools writer(redirectType_, copyFiles, filesContents);
- if (!writer.copyFilesContents(codePath))
+ if (!dynCode.copyOrCreateFiles(true))
{
FatalIOErrorIn
(
"codedFixedValueFvPatchScalarField::writeLibrary(..)",
- dict
- ) << "Failed writing " << nl
- << copyFiles << nl
- << filesContents
+ context.dict()
+ ) << "Failed writing files for" << nl
+ << dynCode.libPath() << nl
<< exit(FatalIOError);
}
}
}
-void Foam::codedFixedValueFvPatchScalarField::updateLibrary()
+void Foam::codedFixedValueFvPatchScalarField::updateLibrary
+(
+ bool firstTime
+) const
{
- if (isAdministrator())
- {
- FatalIOErrorIn
- (
- "codedFixedValueFvPatchScalarField::updateLibrary()",
- dict_
- ) << "This code should not be executed by someone with administrator"
- << " rights due to security reasons." << endl
- << "(it writes a shared library which then gets loaded "
- << "using dlopen)"
- << exit(FatalIOError);
- }
+ dynamicCode::checkSecurity
+ (
+ "codedFixedValueFvPatchScalarField::updateLibrary()",
+ dict_
+ );
- // write code into redirectType_ subdir
- const fileName codePath = codeStreamTools::codePath(redirectType_);
+ // use codeProperties or in-line
+ const bool useCodeProps = !dict_.found("code");
-// const fileName oldLibPath = codeStreamTools::libPath
-// (
-// redirectType_ + "_" + sha1_
-// );
-
- // write library into platforms/$WM_OPTIONS/lib subdir
- const fileName libPath = codeStreamTools::libPath(redirectType_);
+ const dictionary& codeDict =
+ (
+ useCodeProps
+ ? this->dict().subDict(redirectType_)
+ : dict_
+ );
- //Info<< "codePath:" << codePath << nl
- // << "libPath:" << libPath << endl;
+ autoPtr contextPtr;
+ // write code into redirectType_ subdir as well
+ dynamicCode dynCode(redirectType_);
+ const fileName libPath = dynCode.libPath();
+
+ // see if library is loaded
void* lib = dlLibraryTable::findLibrary(libPath);
- if (dict_.found("code"))
- {
- if (!lib)
- {
- writeLibrary(codePath, libPath, dict_);
- }
- }
- else
- {
- const codeProperties& onTheFlyDict = dict();
+ bool reuseLib = false;
+ bool waiting = false;
- if (onTheFlyDict.modified())
+ if (useCodeProps)
+ {
+ // library may be loaded, but out-of-date
+ const codeProperties& codeProps = this->dict();
+ if (codeProps.modified())
{
- onTheFlyDict.setUnmodified();
+ codeProps.setUnmodified();
// Remove instantiation of fvPatchField provided by library
redirectPatchFieldPtr_.clear();
- // Unload library
+
+ contextPtr.reset(new dynamicCodeContext(codeDict));
+
+ // unload code
if (lib)
{
- if (!dlLibraryTable::close(libPath))
+ firstTime = false;
+ reuseLib = false;
+ lib = 0;
+
+ if (!dlLibraryTable::close(libPath, false))
{
FatalIOErrorIn
(
- "codedFixedValueFvPatchScalarField::updateLibrary(..)",
- onTheFlyDict
- ) << "Failed unloading library " << libPath
+ "codedFixedValueFvPatchScalarField::"
+ "updateLibrary()",
+ contextPtr().dict()
+ ) << "Failed unloading library "
+ << libPath
<< exit(FatalIOError);
}
- lib = NULL;
}
-
- const dictionary& codeDict = onTheFlyDict.subDict(redirectType_);
- writeLibrary(codePath, libPath, codeDict);
}
}
+
+ // library exists (and was not unloaded) - we can leave now
+ if (lib)
+ {
+ return;
+ }
+
+
+ // Remove instantiation of fvPatchField provided by library
+ redirectPatchFieldPtr_.clear();
+
+ if (contextPtr.empty())
+ {
+ contextPtr.reset(new dynamicCodeContext(codeDict));
+ }
+
+ // function name serving as version control - based on the SHA1
+ const string sentinelName
+ = dynCode.codeName() + contextPtr().sha1().str(true);
+
+ // avoid compilation (first time only) by loading an existing library
+ if (firstTime && dlLibraryTable::open(libPath, false))
+ {
+ lib = dlLibraryTable::findLibrary(libPath);
+
+ // verify the loaded version and unload if needed
+ if (lib)
+ {
+ reuseLib = dlSymFound(lib, sentinelName);
+ if (!reuseLib)
+ {
+ lib = 0;
+ if (!dlLibraryTable::close(libPath, false))
+ {
+ FatalIOErrorIn
+ (
+ "codedFixedValueFvPatchScalarField::updateLibrary()",
+ contextPtr().dict()
+ ) << "Failed unloading library "
+ << libPath
+ << exit(FatalIOError);
+ }
+ }
+ }
+ }
+
+
+ // really do need to create library
if (!lib)
{
if (Pstream::master())
{
- const Foam::string wmakeCmd("wmake libso " + codePath);
- Info<< "Invoking " << wmakeCmd << endl;
- if (Foam::system(wmakeCmd))
+ createLibrary(dynCode, contextPtr());
+
+ if (!dynCode.wmakeLibso())
{
FatalIOErrorIn
(
"codedFixedValueFvPatchScalarField::updateLibrary()",
- dict_
- ) << "Failed " << wmakeCmd
+ contextPtr().dict()
+ ) << "Failed wmake " << libPath
<< exit(FatalIOError);
}
}
- bool dummy = true;
- reduce(dummy, orOp());
+ // all processes must wait for compile
+ waiting = true;
+ reduce(waiting, orOp());
- if (!dlLibraryTable::open(libPath))
+ if (!dlLibraryTable::open(libPath, false))
{
FatalIOErrorIn
(
"codedFixedValueFvPatchScalarField::updateLibrary()",
- dict_
+ contextPtr().dict()
) << "Failed loading library " << libPath
<< exit(FatalIOError);
}
+
+ lib = dlLibraryTable::findLibrary(libPath);
+ if (!lib)
+ {
+ FatalIOErrorIn
+ (
+ "codedFixedValueFvPatchScalarField::"
+ "updateLibrary()",
+ contextPtr().dict()
+ ) << "Failed to load library " << libPath
+ << exit(FatalIOError);
+ }
+
+//#if 0
+// Info<<"check " << libPath << " for " << sentinelName << nl;
+// // paranoid - check that signature function is really there
+// lib = dlLibraryTable::findLibrary(libPath);
+// if (!lib || !dlSymFound(lib, sentinelName))
+// {
+// FatalIOErrorIn
+// (
+// "codedFixedValueFvPatchScalarField::"
+// "updateLibrary()",
+// contextPtr().dict()
+// ) << "Failed to load library with correct signature "
+// << libPath
+// << exit(FatalIOError);
+// }
+//#endif
+ }
+ else if (reuseLib)
+ {
+ Info<< "Reusing library in " << libPath << nl;
}
}
@@ -296,7 +313,7 @@ codedFixedValueFvPatchScalarField
)
:
fixedValueFvPatchField(p, iF),
- redirectPatchFieldPtr_(NULL)
+ redirectPatchFieldPtr_()
{}
@@ -312,7 +329,7 @@ codedFixedValueFvPatchScalarField
fixedValueFvPatchField(ptf, p, iF, mapper),
dict_(ptf.dict_),
redirectType_(ptf.redirectType_),
- redirectPatchFieldPtr_(NULL)
+ redirectPatchFieldPtr_()
{}
@@ -327,9 +344,9 @@ codedFixedValueFvPatchScalarField
fixedValueFvPatchField(p, iF, dict),
dict_(dict),
redirectType_(dict.lookup("redirectType")),
- redirectPatchFieldPtr_(NULL)
+ redirectPatchFieldPtr_()
{
- updateLibrary();
+ updateLibrary(true);
}
@@ -342,7 +359,7 @@ codedFixedValueFvPatchScalarField
fixedValueFvPatchField(ptf),
dict_(ptf.dict_),
redirectType_(ptf.redirectType_),
- redirectPatchFieldPtr_(NULL)
+ redirectPatchFieldPtr_()
{}
@@ -356,7 +373,7 @@ codedFixedValueFvPatchScalarField
fixedValueFvPatchField(ptf, iF),
dict_(ptf.dict_),
redirectType_(ptf.redirectType_),
- redirectPatchFieldPtr_(NULL)
+ redirectPatchFieldPtr_()
{}
@@ -378,6 +395,18 @@ Foam::codedFixedValueFvPatchScalarField::redirectPatchField() const
dictionary dict(is);
Info<< "constructing patchField from :" << dict << endl;
+// if (fvPatchScalarField::dictionaryConstructorTablePtr_)
+// {
+// fvPatchScalarField::dictionaryConstructorPtr funcPtr =
+// (
+// fvPatchScalarField::dictionaryConstructorTablePtr_->
+// find(redirectType_)()
+// );
+//
+// Info<< redirectType_ << " FunctionPtr => "
+// << long(funcPtr) << endl;
+// }
+
redirectPatchFieldPtr_.set
(
fvPatchScalarField::New
diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.H
index d08059be3a..7b0ef5a642 100644
--- a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.H
+++ b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.H
@@ -29,8 +29,6 @@ Description
Constructs on-the-fly a new boundary condition (derived from
fixedValueFvPatchScalarField) which is then used to evaluate.
- See also codeStream.
-
Example:
\verbatim
movingWall
@@ -71,7 +69,7 @@ Description
\endverbatim
SeeAlso
- Foam::codeStreamTools for constant paths used
+ Foam::dynamicCode and Foam::functionEntries::codeStream
SourceFiles
codedFixedValueFvPatchScalarField.C
@@ -82,14 +80,16 @@ SourceFiles
#define codedFixedValueFvPatchScalarField_H
#include "fixedValueFvPatchFields.H"
-#include "SHA1Digest.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
+// Forward declaration of classes
class codeProperties;
+class dynamicCode;
+class dynamicCodeContext;
/*---------------------------------------------------------------------------*\
Class codedFixedValueFvPatchScalarField Declaration
@@ -104,10 +104,6 @@ class codedFixedValueFvPatchScalarField
//- Dictionary contents for the boundary condition
mutable dictionary dict_;
- //- SHA1Digest of the Dictionary contents
- // Currently unused, but useful for reloading?
- mutable SHA1Digest sha1_;
-
const word redirectType_;
mutable autoPtr redirectPatchFieldPtr_;
@@ -117,24 +113,21 @@ class codedFixedValueFvPatchScalarField
const codeProperties& dict() const;
- void writeLibrary
- (
- const fileName& dir,
- const fileName& libPath,
- const dictionary& dict
- );
+ void createLibrary(dynamicCode&, const dynamicCodeContext&) const;
- void updateLibrary();
+ //- Update library as required
+ // Use 'firstTime' to alter behaviour
+ void updateLibrary(bool firstTime=false) const;
public:
// Static data members
//- Name of the C code template to be used
- const static word codeTemplateC;
+ static const word codeTemplateC;
//- Name of the H code template to be used
- const static word codeTemplateH;
+ static const word codeTemplateH;
//- Runtime type information
@@ -226,7 +219,7 @@ public:
);
//- Write
- virtual void write(Ostream& os) const;
+ virtual void write(Ostream&) const;
};
diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H
index c534d3e83c..a91f61c577 100644
--- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H
+++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.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
@@ -73,7 +73,7 @@ Ostream& operator<<(Ostream&, const fvPatchField&);
/*---------------------------------------------------------------------------*\
- Class patch Declaration
+ Class fvPatchField Declaration
\*---------------------------------------------------------------------------*/
template
@@ -516,11 +516,40 @@ public:
);
+// use with caution
+#define addRemovableToPatchFieldRunTimeSelection\
+(PatchTypeField, typePatchTypeField) \
+ \
+ addRemovableToRunTimeSelectionTable \
+ ( \
+ PatchTypeField, \
+ typePatchTypeField, \
+ patch \
+ ); \
+ addRemovableToRunTimeSelectionTable \
+ ( \
+ PatchTypeField, \
+ typePatchTypeField, \
+ patchMapper \
+ ); \
+ addRemovableToRunTimeSelectionTable \
+ ( \
+ PatchTypeField, \
+ typePatchTypeField, \
+ dictionary \
+ );
+
+
// for non-templated patch fields
#define makePatchTypeField(PatchTypeField, typePatchTypeField) \
defineTypeNameAndDebug(typePatchTypeField, 0); \
addToPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField)
+// for non-templated patch fields - use with caution
+#define makeRemovablePatchTypeField(PatchTypeField, typePatchTypeField) \
+ defineTypeNameAndDebug(typePatchTypeField, 0); \
+ addRemovableToPatchFieldRunTimeSelection(PatchTypeField, typePatchTypeField)
+
// for templated patch fields
#define makeTemplatePatchTypeField(PatchTypeField, typePatchTypeField) \
diff --git a/src/lagrangian/basic/Cloud/Cloud.C b/src/lagrangian/basic/Cloud/Cloud.C
index c140c449d5..425c8221cd 100644
--- a/src/lagrangian/basic/Cloud/Cloud.C
+++ b/src/lagrangian/basic/Cloud/Cloud.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
@@ -32,12 +32,6 @@ License
#include "OFstream.H"
#include "wallPolyPatch.H"
-// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
-
-template
-const Foam::scalar Foam::Cloud::trackingCorrectionTol = 1e-5;
-
-
// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
template
@@ -47,7 +41,7 @@ void Foam::Cloud::calcCellWallFaces() const
PackedBoolList& cellWallFaces = cellWallFacesPtr_();
- const polyBoundaryMesh& patches = pMesh().boundaryMesh();
+ const polyBoundaryMesh& patches = polyMesh_.boundaryMesh();
forAll(patches, patchI)
{
@@ -78,9 +72,7 @@ Foam::Cloud::Cloud
cloud(pMesh),
IDLList(),
polyMesh_(pMesh),
- particleCount_(0),
labels_(),
- cellTree_(),
nTrackingRescues_(),
cellWallFacesPtr_()
{
@@ -104,9 +96,7 @@ Foam::Cloud::Cloud
cloud(pMesh, cloudName),
IDLList(),
polyMesh_(pMesh),
- particleCount_(0),
labels_(),
- cellTree_(),
nTrackingRescues_(),
cellWallFacesPtr_()
{
@@ -121,236 +111,6 @@ Foam::Cloud::Cloud
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
-template
-void Foam::Cloud::findCellFacePt
-(
- const point& pt,
- label& cellI,
- label& tetFaceI,
- label& tetPtI
-) const
-{
- cellI = -1;
- tetFaceI = -1;
- tetPtI = -1;
-
- const indexedOctree& tree = cellTree();
-
- // Find nearest cell to the point
-
- pointIndexHit info = tree.findNearest(pt, sqr(GREAT));
-
- if (info.hit())
- {
- label nearestCellI = tree.shapes().cellLabels()[info.index()];
-
- // Check the nearest cell to see if the point is inside.
- findFacePt(nearestCellI, pt, tetFaceI, tetPtI);
-
- if (tetFaceI != -1)
- {
- // Point was in the nearest cell
-
- cellI = nearestCellI;
-
- return;
- }
- else
- {
- // Check the other possible cells that the point may be in
-
- labelList testCells = tree.findIndices(pt);
-
- forAll(testCells, pCI)
- {
- label testCellI = tree.shapes().cellLabels()[testCells[pCI]];
-
- if (testCellI == nearestCellI)
- {
- // Don't retest the nearest cell
-
- continue;
- }
-
- // Check the test cell to see if the point is inside.
- findFacePt(testCellI, pt, tetFaceI, tetPtI);
-
- if (tetFaceI != -1)
- {
- // Point was in the test cell
-
- cellI = testCellI;
-
- return;
- }
- }
- }
- }
- else
- {
- FatalErrorIn
- (
- "void Foam::Cloud::findCellFacePt"
- "("
- "const point& pt, "
- "label& cellI, "
- "label& tetFaceI, "
- "label& tetPtI"
- ") const"
- ) << "Did not find nearest cell in search tree."
- << abort(FatalError);
- }
-}
-
-
-template
-void Foam::Cloud::findFacePt
-(
- label cellI,
- const point& pt,
- label& tetFaceI,
- label& tetPtI
-) const
-{
- tetFaceI = -1;
- tetPtI = -1;
-
- List cellTets = polyMeshTetDecomposition::cellTetIndices
- (
- polyMesh_,
- cellI
- );
-
- forAll(cellTets, tetI)
- {
- const tetIndices& cellTetIs = cellTets[tetI];
-
- if (inTet(pt, cellTetIs.tet(polyMesh_)))
- {
- tetFaceI = cellTetIs.face();
- tetPtI = cellTetIs.tetPt();
-
- return;
- }
- }
-}
-
-
-template
-bool Foam::Cloud::inTet
-(
- const point& pt,
- const tetPointRef& tet
-) const
-{
- // For robustness, assuming that the point is in the tet unless
- // "definitively" shown otherwise by obtaining a positive dot
- // product greater than a tolerance of SMALL.
-
- // The tet is defined: tet(Cc, tetBasePt, pA, pB) where the normal
- // vectors and base points for the half-space planes are:
- // area[0] = tet.Sa();
- // area[1] = tet.Sb();
- // area[2] = tet.Sc();
- // area[3] = tet.Sd();
- // planeBase[0] = tetBasePt = tet.b()
- // planeBase[1] = ptA = tet.c()
- // planeBase[2] = tetBasePt = tet.b()
- // planeBase[3] = tetBasePt = tet.b()
-
- vector n = vector::zero;
-
- {
- // 0, a
- const point& basePt = tet.b();
-
- n = tet.Sa();
- n /= (mag(n) + VSMALL);
-
- if (((pt - basePt) & n) > SMALL)
- {
- return false;
- }
- }
-
- {
- // 1, b
- const point& basePt = tet.c();
-
- n = tet.Sb();
- n /= (mag(n) + VSMALL);
-
- if (((pt - basePt) & n) > SMALL)
- {
- return false;
- }
- }
-
- {
- // 2, c
- const point& basePt = tet.b();
-
- n = tet.Sc();
- n /= (mag(n) + VSMALL);
-
- if (((pt - basePt) & n) > SMALL)
- {
- return false;
- }
- }
-
- {
- // 3, d
- const point& basePt = tet.b();
-
- n = tet.Sd();
- n /= (mag(n) + VSMALL);
-
- if (((pt - basePt) & n) > SMALL)
- {
- return false;
- }
- }
-
- return true;
-}
-
-
-template
-const Foam::indexedOctree&
-Foam::Cloud::cellTree() const
-{
- if (cellTree_.empty())
- {
- treeBoundBox overallBb(polyMesh_.points());
-
- Random rndGen(261782);
-
- overallBb = overallBb.extend(rndGen, 1E-4);
- overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
- overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL);
-
- cellTree_.reset
- (
- new indexedOctree
- (
- treeDataCell
- (
- false, // not cache bb
- polyMesh_
- ),
- overallBb,
- 8, // maxLevel
- 10, // leafsize
- 3.0 // duplicity
- )
- );
- }
-
- return cellTree_();
-}
-
-
template
const Foam::PackedBoolList& Foam::Cloud::cellHasWallFaces()
const
@@ -364,22 +124,6 @@ const
}
-
-template
-Foam::label Foam::Cloud::getNewParticleID() const
-{
- label id = particleCount_++;
-
- if (id == labelMax)
- {
- WarningIn("Cloud::getNewParticleID() const")
- << "Particle counter has overflowed. This might cause problems"
- << " when reconstructing particle tracks." << endl;
- }
- return id;
-}
-
-
template
void Foam::Cloud::addParticle(ParticleType* pPtr)
{
@@ -399,14 +143,14 @@ void Foam::Cloud::cloudReset(const Cloud& c)
{
// Reset particle cound and particles only
// - not changing the cloud object registry or reference to the polyMesh
- particleCount_ = 0;
+ ParticleType::particleCount_ = 0;
IDLList::operator=(c);
}
template
-template
-void Foam::Cloud::move(TrackingData& td, const scalar trackTime)
+template
+void Foam::Cloud::move(TrackData& td, const scalar trackTime)
{
const polyBoundaryMesh& pbm = pMesh().boundaryMesh();
const globalMeshData& pData = polyMesh_.globalData();
@@ -472,9 +216,9 @@ void Foam::Cloud::move(TrackingData& td, const scalar trackTime)
{
// If we are running in parallel and the particle is on a
// boundary face
- if (Pstream::parRun() && p.faceI_ >= pMesh().nInternalFaces())
+ if (Pstream::parRun() && p.face() >= pMesh().nInternalFaces())
{
- label patchI = pbm.whichPatch(p.faceI_);
+ label patchI = pbm.whichPatch(p.face());
// ... and the face is on a processor patch
// prepare it for transfer
@@ -571,7 +315,7 @@ void Foam::Cloud::move(TrackingData& td, const scalar trackTime)
IDLList newParticles
(
particleStream,
- typename ParticleType::iNew(*this)
+ typename ParticleType::iNew(polyMesh_)
);
label pI = 0;
@@ -600,57 +344,64 @@ void Foam::Cloud::move(TrackingData& td, const scalar trackTime)
template
-void Foam::Cloud::autoMap(const mapPolyMesh& mapper)
+template
+void Foam::Cloud::autoMap
+(
+ TrackData& td,
+ const mapPolyMesh& mapper
+)
{
if (cloud::debug)
{
- Info<< "Cloud::autoMap(const morphFieldMapper& map) "
- "for lagrangian cloud " << cloud::name() << endl;
+ Info<< "Cloud::autoMap(TrackData&, const mapPolyMesh&) "
+ << "for lagrangian cloud " << cloud::name() << endl;
}
const labelList& reverseCellMap = mapper.reverseCellMap();
const labelList& reverseFaceMap = mapper.reverseFaceMap();
// Reset stored data that relies on the mesh
- cellTree_.clear();
+// polyMesh_.clearCellTree();
cellWallFacesPtr_.clear();
forAllIter(typename Cloud, *this, pIter)
{
- if (reverseCellMap[pIter().cellI_] >= 0)
- {
- pIter().cellI_ = reverseCellMap[pIter().cellI_];
+ ParticleType& p = pIter();
- if (pIter().faceI_ >= 0 && reverseFaceMap[pIter().faceI_] >= 0)
+ if (reverseCellMap[p.cell()] >= 0)
+ {
+ p.cell() = reverseCellMap[p.cell()];
+
+ if (p.face() >= 0 && reverseFaceMap[p.face()] >= 0)
{
- pIter().faceI_ = reverseFaceMap[pIter().faceI_];
+ p.face() = reverseFaceMap[p.face()];
}
else
{
- pIter().faceI_ = -1;
+ p.face() = -1;
}
- pIter().initCellFacePt();
+ p.initCellFacePt();
}
else
{
- label trackStartCell = mapper.mergedCell(pIter().cellI_);
+ label trackStartCell = mapper.mergedCell(p.cell());
if (trackStartCell < 0)
{
trackStartCell = 0;
}
- vector p = pIter().position();
+ vector pos = p.position();
- const_cast(pIter().position()) =
+ const_cast(p.position()) =
polyMesh_.cellCentres()[trackStartCell];
- pIter().stepFraction() = 0;
+ p.stepFraction() = 0;
- pIter().initCellFacePt();
+ p.initCellFacePt();
- pIter().track(p);
+ p.track(pos, td);
}
}
}
diff --git a/src/lagrangian/basic/Cloud/Cloud.H b/src/lagrangian/basic/Cloud/Cloud.H
index 3715bcb75c..488fc63f3d 100644
--- a/src/lagrangian/basic/Cloud/Cloud.H
+++ b/src/lagrangian/basic/Cloud/Cloud.H
@@ -25,6 +25,7 @@ Class
Foam::Cloud
Description
+ Base cloud calls templated on particle type
SourceFiles
Cloud.C
@@ -80,15 +81,9 @@ class Cloud
const polyMesh& polyMesh_;
- //- Overall count of particles ever created. Never decreases.
- mutable label particleCount_;
-
//- Temporary storage for addressing. Used in findTris.
mutable DynamicList