diff --git a/ReleaseNotes-dev b/ReleaseNotes-dev index 06a9bb7c77..57fc61743d 100644 --- a/ReleaseNotes-dev +++ b/ReleaseNotes-dev @@ -190,7 +190,7 @@ outlet { - type codedFixedValue; + type codedFixedValue; value uniform 0; redirectType fixedValue10; @@ -230,6 +230,9 @@ + =extrudeMesh=: - option to add extrusion to existing mesh. - works in parallel + + =snappyHexMesh=: + + extrude across multi-processor boundaries + + preserve faceZones during layering * Post-processing + =paraFoam=, =foamToVTK=: full support for polyhedral cell type in recent Paraview versions. diff --git a/doc/changes/onTheFly.txt b/doc/changes/onTheFly.txt index 0fc0b691b5..9734c1f5a8 100644 --- a/doc/changes/onTheFly.txt +++ b/doc/changes/onTheFly.txt @@ -48,6 +48,9 @@ Example: Look up dictionary entries and do some calculation - the #codeStream entry reads the dictionary following it, extracts the code, codeInclude, codeOptions sections (these are just strings) and calculates the SHA1 checksum of the contents. +- it copies a template file +($FOAM_CODESTREAM_TEMPLATE_DIR/codeStreamTemplate.C), substituting all +occurences of code, codeInclude, codeOptions. - it writes library source files to constant/codeStream/ and compiles it using 'wmake libso'. - the resulting library gets loaded (dlopen, dlsym) and the function @@ -59,11 +62,11 @@ gets used to construct the entry to replace the whole #codeStream section. 3. codedFixedValue This uses the code from codeStream to have an in-line specialised -fixedValueFvPatchScalarField: +fixedValueFvPatchScalarField. For now only for scalars: outlet { - type codedFixedValue; + type codedFixedValue; value uniform 0; redirectType fixedValue10; @@ -103,9 +106,9 @@ internalField #codeStream code #{ - const IOdictionary& d = refCast(dict); + const IOdictionary& d = dynamicCast(dict); const fvMesh& mesh = refCast(d.db()); - scalarField fld(mesh.nCells(), 0.0); + scalarField fld(mesh.nCells(), 12.34); fld.writeEntry("", os); #}; @@ -115,18 +118,22 @@ internalField #codeStream #}; }; -There are unfortunately some exceptions. Following applications read -the field as a dictionary: +* There are unfortunately some exceptions. Following applications read +the field as a dictionary, not as an IOdictionary: - foamFormatConvert - changeDictionaryDict - foamUpgradeCyclics - fieldToCell -Note: above construct has the problem that the boundary conditions are -not evaluated so e.g. processor boundaries will might not hold the opposite -cell value. + +Note: above field initialisation has the problem that the boundary +conditions are not evaluated so e.g. processor boundaries will +not hold the opposite cell value. 6. Other - the implementation is still a bit raw - it compiles code overly much -- parallel running not tested a lot. What about distributed data parallel. +- both codeStream and codedFixedValue take the contents of the dictionary +and extract values and re-assemble list of files and environment vars to +replace. Should just directly pass the dictionary into codeStreamTools. +- parallel running not tested a lot. What about distributed data parallel? diff --git a/etc/codeTemplates/codeStream/codeStreamTemplate.C b/etc/codeTemplates/codeStream/codeStreamTemplate.C new file mode 100644 index 0000000000..af4f82ffc8 --- /dev/null +++ b/etc/codeTemplates/codeStream/codeStreamTemplate.C @@ -0,0 +1,48 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 3 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, see . + +\*---------------------------------------------------------------------------*/ + +${codeInclude} + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +extern "C" +{ +void ${typeName} +( + const dictionary& dict, + Ostream& os +) +{ +${code}; +} +} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// ************************************************************************* // diff --git a/etc/codeTemplates/codeStream/fixedValueFvPatchScalarFieldTemplate.C b/etc/codeTemplates/codeStream/fixedValueFvPatchScalarFieldTemplate.C new file mode 100644 index 0000000000..937fb5b550 --- /dev/null +++ b/etc/codeTemplates/codeStream/fixedValueFvPatchScalarFieldTemplate.C @@ -0,0 +1,124 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 20101-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 3 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, see . + +\*---------------------------------------------------------------------------*/ + +#include "fixedValueFvPatchScalarFieldTemplate.H" +#include "addToRunTimeSelectionTable.H" +#include "fvPatchFieldMapper.H" +#include "volFields.H" +#include "surfaceFields.H" +${codeInclude} + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +${typeName}FixedValueFvPatchScalarField:: +${typeName}FixedValueFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(p, iF) +{} + + +${typeName}FixedValueFvPatchScalarField:: +${typeName}FixedValueFvPatchScalarField +( + const ${typeName}FixedValueFvPatchScalarField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fixedValueFvPatchScalarField(ptf, p, iF, mapper) +{} + + +${typeName}FixedValueFvPatchScalarField:: +${typeName}FixedValueFvPatchScalarField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fixedValueFvPatchScalarField(p, iF, dict) +{} + + +${typeName}FixedValueFvPatchScalarField:: +${typeName}FixedValueFvPatchScalarField +( + const ${typeName}FixedValueFvPatchScalarField& ptf +) +: + fixedValueFvPatchScalarField(ptf) +{} + + +${typeName}FixedValueFvPatchScalarField:: +${typeName}FixedValueFvPatchScalarField +( + const ${typeName}FixedValueFvPatchScalarField& ptf, + const DimensionedField& iF +) +: + fixedValueFvPatchScalarField(ptf, iF) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void ${typeName}FixedValueFvPatchScalarField::updateCoeffs() +{ + if (this->updated()) + { + return; + } + + ${code} + fixedValueFvPatchScalarField::updateCoeffs(); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeField +( + fvPatchScalarField, + ${typeName}FixedValueFvPatchScalarField +); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/etc/codeTemplates/codeStream/fixedValueFvPatchScalarFieldTemplate.H b/etc/codeTemplates/codeStream/fixedValueFvPatchScalarFieldTemplate.H new file mode 100644 index 0000000000..b6ef87c8bc --- /dev/null +++ b/etc/codeTemplates/codeStream/fixedValueFvPatchScalarFieldTemplate.H @@ -0,0 +1,142 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 3 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, see . + +Class + Foam::fixedValueFvPatchScalarFieldTemplate + +Description + Template for use with onTheFlyFixedValue. + - fixedValueFvPatchScalarField + - without state + +SourceFiles + fixedValueFvPatchScalarFieldTemplate.C + +\*---------------------------------------------------------------------------*/ + +#ifndef fixedValueFvPatchScalarFieldTemplate_H +#define fixedValueFvPatchScalarFieldTemplate_H + +#include "fixedValueFvPatchFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class fixedValueFvPatchScalarField Declaration +\*---------------------------------------------------------------------------*/ + +class ${typeName}FixedValueFvPatchScalarField +: + public fixedValueFvPatchScalarField +{ + +public: + + //- Runtime type information + TypeName("${typeName}"); + + + // Constructors + + //- Construct from patch and internal field + ${typeName}FixedValueFvPatchScalarField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch, internal field and dictionary + ${typeName}FixedValueFvPatchScalarField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given + // ${typeName}FixedValueFvPatchScalarField + // onto a new patch + ${typeName}FixedValueFvPatchScalarField + ( + const ${typeName}FixedValueFvPatchScalarField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + ${typeName}FixedValueFvPatchScalarField + ( + const ${typeName}FixedValueFvPatchScalarField& + ); + + //- Construct and return a clone + virtual tmp clone() const + { + return tmp + ( + new ${typeName}FixedValueFvPatchScalarField(*this) + ); + } + + //- Construct as copy setting internal field reference + ${typeName}FixedValueFvPatchScalarField + ( + const ${typeName}FixedValueFvPatchScalarField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp clone + ( + const DimensionedField& iF + ) const + { + return tmp + ( + new ${typeName}FixedValueFvPatchScalarField(*this, iF) + ); + } + + + // Member functions + + // Evaluation functions + + //- Update the coefficients associated with the patch field + virtual void updateCoeffs(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/etc/settings.csh b/etc/settings.csh index 0113cc99a5..a48a188382 100644 --- a/etc/settings.csh +++ b/etc/settings.csh @@ -63,6 +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 + # convenience setenv FOAM_APP $WM_PROJECT_DIR/applications #setenv FOAM_LIB $WM_PROJECT_DIR/lib diff --git a/etc/settings.sh b/etc/settings.sh index aca4187728..9281ffba95 100644 --- a/etc/settings.sh +++ b/etc/settings.sh @@ -86,6 +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 + # convenience export FOAM_APP=$WM_PROJECT_DIR/applications #export FOAM_LIB=$WM_PROJECT_DIR/lib diff --git a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C index 08f61902b8..297430715a 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C @@ -143,14 +143,18 @@ bool Foam::functionEntries::codeStream::execute { Info<< "Creating new library in " << libPath << endl; - fileName templates(Foam::getEnv("OTF_TEMPLATE_DIR")); + fileName templates + ( + Foam::getEnv("FOAM_CODESTREAM_TEMPLATE_DIR") + ); if (!templates.size()) { FatalIOErrorIn ( "functionEntries::codeStream::execute(..)", parentDict - ) << "Please set environment variable OTF_TEMPLATE_DIR" + ) << "Please set environment variable" + " FOAM_CODESTREAM_TEMPLATE_DIR" << " to point to the location of codeStreamTemplate.C" << exit(FatalIOError); } @@ -158,8 +162,8 @@ bool Foam::functionEntries::codeStream::execute List copyFiles(1); copyFiles[0].first() = templates/"codeStreamTemplate.C"; stringPairList bodyVars(2); - bodyVars[0] = Pair("OTF_INCLUDES", codeInclude); - bodyVars[1] = Pair("OTF_BODY", code); + bodyVars[0] = Pair("codeInclude", codeInclude); + bodyVars[1] = Pair("code", code); copyFiles[0].second() = bodyVars; List filesContents(2); diff --git a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStreamTools.C b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStreamTools.C index 2304127433..1667d2be4e 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStreamTools.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStreamTools.C @@ -149,8 +149,8 @@ bool Foam::codeStreamTools::copyFilesContents(const fileName& dir) const // Create dir mkDir(dir); - //Info<< "Setting envvar OTF_TYPENAME=" << name_ << endl; - setEnv("OTF_TYPENAME", name_, true); + //Info<< "Setting envvar typeName=" << name_ << endl; + setEnv("typeName", name_, true); // Copy any template files forAll(copyFiles_, i) { diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.C index 388d013b55..d7f7c3594b 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.C @@ -78,14 +78,15 @@ void Foam::codedFixedValueFvPatchScalarField::writeLibrary // Write files for new library if (Pstream::master()) { - fileName templates(Foam::getEnv("OTF_TEMPLATE_DIR")); + fileName templates(Foam::getEnv("FOAM_CODESTREAM_TEMPLATE_DIR")); if (!templates.size()) { FatalIOErrorIn ( "codedFixedValueFvPatchScalarField::writeLibrary(..)", dict - ) << "Please set environment variable OTF_TEMPLATE_DIR" + ) << "Please set environment variable" + << " FOAM_CODESTREAM_TEMPLATE_DIR" << " to point to the location of " << "fixedValueFvPatchScalarFieldTemplate.C" << exit(FatalIOError); @@ -112,8 +113,8 @@ void Foam::codedFixedValueFvPatchScalarField::writeLibrary templates/"fixedValueFvPatchScalarFieldTemplate.C"; copyFiles[0].second().setSize(2); - copyFiles[0].second()[0] = Pair("OTF_INCLUDES", codeInclude); - copyFiles[0].second()[1] = Pair("OTF_UPDATECOEFFS", code); + copyFiles[0].second()[0] = Pair("codeInclude", codeInclude); + copyFiles[0].second()[1] = Pair("code", code); copyFiles[1].first() = templates/"fixedValueFvPatchScalarFieldTemplate.H"; diff --git a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.H b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.H index f3d6740e91..9b3ed6debf 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/codedFixedValue/codedFixedValueFvPatchScalarField.H @@ -35,7 +35,7 @@ Description movingWall { - type codedFixedValue; + type codedFixedValue; value uniform 0; redirectType rampedFixedValue; // name of generated bc @@ -118,7 +118,7 @@ class codedFixedValueFvPatchScalarField public: //- Runtime type information - TypeName("codedFixedValue"); + TypeName("codedFixedValue"); // Constructors