diff --git a/applications/solvers/incompressible/boundaryFoam/boundaryFoam.C b/applications/solvers/incompressible/boundaryFoam/boundaryFoam.C index b9b46a3cc9..19933091a0 100644 --- a/applications/solvers/incompressible/boundaryFoam/boundaryFoam.C +++ b/applications/solvers/incompressible/boundaryFoam/boundaryFoam.C @@ -26,8 +26,8 @@ Application boundaryFoam Description - Steady-state solver for 1D turbulent flow, typically to generate boundary - layer conditions at an inlet, for use in a simulation. + Steady-state solver for 1D turbulent flow, typically to generate boundary + layer conditions at an inlet, for use in a simulation. Boundary layer code to calculate the U, k and epsilon distributions. Used to create inlet boundary conditions for experimental comparisons @@ -82,11 +82,14 @@ int main(int argc, char *argv[]) U += (Ubar - UbarStar); gradP += (Ubar - UbarStar)/(1.0/UEqn.A())().weightedAverage(mesh.V()); + label id = y.size() - 1; + scalar wallShearStress = - flowDirection & turbulence->R()()[0] & wallNormal; + flowDirection & turbulence->R()()[id] & wallNormal; scalar yplusWall - = ::sqrt(mag(wallShearStress))*y[0]/laminarTransport.nu()()[0]; +// = ::sqrt(mag(wallShearStress))*y[id]/laminarTransport.nu()()[id]; + = ::sqrt(mag(wallShearStress))*y[id]/turbulence->nuEff()()[id]; Info<< "Uncorrected Ubar = " << (flowDirection & UbarStar.value())<< tab << "pressure gradient = " << (flowDirection & gradP.value()) << tab diff --git a/applications/solvers/incompressible/simpleFoam/Make/options b/applications/solvers/incompressible/simpleFoam/Make/options index e1ffa28773..8a31f7e5ab 100644 --- a/applications/solvers/incompressible/simpleFoam/Make/options +++ b/applications/solvers/incompressible/simpleFoam/Make/options @@ -7,5 +7,4 @@ EXE_LIBS = \ -lincompressibleRASModels \ -lincompressibleTransportModels \ -lfiniteVolume \ - -lmeshTools \ - /* $(LIB_WM_OPTIONS_DIR)/libfbsdmalloc.o */ + -lmeshTools diff --git a/applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C b/applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C index 4b7a09acbf..3c0e18a9cf 100644 --- a/applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C +++ b/applications/utilities/postProcessing/patch/patchIntegrate/patchIntegrate.C @@ -75,7 +75,7 @@ int main(int argc, char *argv[]) } // Give patch area - Info<< " Patch area = " << sum(mesh.Sf()) << endl; + Info<< " Patch area = " << sum(mesh.Sf().boundaryField()[patchi]) << endl; if (fieldHeader.headerClassName() == "volScalarField") { diff --git a/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/Make/files b/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/Make/files new file mode 100644 index 0000000000..58f5dd3974 --- /dev/null +++ b/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/Make/files @@ -0,0 +1,3 @@ +applyWallFunctionBounaryConditions.C + +EXE = $(FOAM_APPBIN)/applyWallFunctionBounaryConditions diff --git a/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/Make/options b/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/Make/options new file mode 100644 index 0000000000..89e52b6d52 --- /dev/null +++ b/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/Make/options @@ -0,0 +1,6 @@ +EXE_INC = \ + -I$(LIB_SRC)/finiteVolume/lnInclude + +EXE_LIBS = \ + -lfiniteVolume + diff --git a/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/applyWallFunctionBounaryConditions.C b/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/applyWallFunctionBounaryConditions.C new file mode 100644 index 0000000000..e571cc4373 --- /dev/null +++ b/applications/utilities/preProcessing/applyWallFunctionBounaryConditions/applyWallFunctionBounaryConditions.C @@ -0,0 +1,279 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2007 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 + +Application + applyWallFunctionBounaryConditions + +Description + Updates OpenFOAM RAS cases to use the new wall function framework + Attempts to determine whether case is compressible or incompressible, or + can be supplied with -compressible command line argument + +\*---------------------------------------------------------------------------*/ + + +#include "argList.H" +#include "fvMesh.H" +#include "Time.H" +#include "volFields.H" +#include "surfaceFields.H" + +#include "wallPolyPatch.H" + +using namespace Foam; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +bool caseIsCompressible(const fvMesh& mesh) +{ + // Attempt flux field + IOobject phiHeader + ( + "phi", + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if (phiHeader.headerOk()) + { + surfaceScalarField phi(phiHeader, mesh); + if (phi.dimensions() == dimDensity*dimVelocity*dimArea) + { + return true; + } + } + + // Attempt density field + IOobject rhoHeader + ( + "rho", + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if (rhoHeader.headerOk()) + { + volScalarField rho(rhoHeader, mesh); + if (rho.dimensions() == dimDensity) + { + return true; + } + } + + // Attempt pressure field + IOobject pHeader + ( + "p", + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if (pHeader.headerOk()) + { + volScalarField p(pHeader, mesh); + if (p.dimensions() == dimMass/sqr(dimTime)/dimLength) + { + return true; + } + } + + // Attempt hydrostatic pressure field + IOobject pdHeader + ( + "pd", + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if (pdHeader.headerOk()) + { + volScalarField pd(pdHeader, mesh); + if (pd.dimensions() == dimMass/sqr(dimTime)/dimLength) + { + return true; + } + } + + // If none of the above are true, assume that the case is incompressible + return false; +} + + +void createVolScalarField +( + const fvMesh& mesh, + const word& fieldName, + const dimensionSet& dims +) +{ + IOobject fieldHeader + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if (!fieldHeader.headerOk()) + { + Info<< "Creating field " << fieldName << nl << endl; + + volScalarField field + ( + IOobject + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + mesh, + dimensionedScalar("zero", dims, 0.0) + ); + + field.write(); + } +} + + +void replaceBoundaryType +( + const fvMesh& mesh, + const word& fieldName, + const word& boundaryType, + const string& boundaryValue +) +{ + IOobject header + ( + fieldName, + mesh.time().timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if (!header.headerOk()) + { + return; + } + + Info<< "Updating boundary types for field " << header.name() << endl; + + const word oldTypeName = IOdictionary::typeName; + const_cast(IOdictionary::typeName) = word::null; + + IOdictionary dict(header); + + const_cast(IOdictionary::typeName) = oldTypeName; + const_cast(dict.type()) = dict.headerClassName(); + + // Make a backup of the old field + word backupName(dict.name() + ".old"); + Info<< " copying " << dict.name() << " to " + << backupName << endl; + IOdictionary dictOld = dict; + dictOld.rename(backupName); + dictOld.regIOobject::write(); + + // Loop through boundary patches and update + const polyBoundaryMesh& bMesh = mesh.boundaryMesh(); + dictionary& boundaryDict = dict.subDict("boundaryField"); + forAll(bMesh, patchI) + { + if (isType(bMesh[patchI])) + { + word patchName = bMesh[patchI].name(); + dictionary& oldPatch = boundaryDict.subDict(patchName); + + dictionary newPatch(dictionary::null); + newPatch.add("type", boundaryType); + newPatch.add("value", ("uniform " + boundaryValue).c_str()); + + oldPatch = newPatch; + } + } + + Info<< " writing updated " << dict.name() << nl << endl; + dict.regIOobject::write(); +} + + +int main(int argc, char *argv[]) +{ + +# include "addTimeOptions.H" + argList::validOptions.insert("compressible", ""); + +# include "setRootCase.H" +# include "createTime.H" +# include "createMesh.H" + + bool compressible = args.options().found("compressible"); + + Info<< "Updating turbulence fields to operate using new run time " + << "selectable" << nl << "wall functions" + << nl << endl; + + if (compressible || caseIsCompressible(mesh)) + { + Info<< "Case treated as compressible" << nl << endl; + createVolScalarField + ( + mesh, + "mut", + dimArea/dimTime*dimDensity + ); + replaceBoundaryType(mesh, "mut", "mutWallFunction", "0"); + } + else + { + Info<< "Case treated as incompressible" << nl << endl; + createVolScalarField(mesh, "nut", dimArea/dimTime); + replaceBoundaryType(mesh, "nut", "nutWallFunction", "0"); + } + + replaceBoundaryType(mesh, "epsilon", "epsilonWallFunction", "0"); + replaceBoundaryType(mesh, "omega", "omegaWallFunction", "0"); + replaceBoundaryType(mesh, "k", "kQRWallFunction", "0"); + replaceBoundaryType(mesh, "q", "kQRWallFunction", "0"); + replaceBoundaryType(mesh, "R", "kQRWallFunction", "(0 0 0 0 0 0)"); + + Info<< "End\n" << endl; + + return 0; +} + + +// ************************************************************************* // diff --git a/src/OSspecific/Unix/regularExpression.H b/src/OSspecific/Unix/regularExpression.H new file mode 100644 index 0000000000..dc574a4c9f --- /dev/null +++ b/src/OSspecific/Unix/regularExpression.H @@ -0,0 +1,121 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 1991-2008 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::regularExpression + +Description + Wrapper around regular expressions. + +SourceFiles + +\*---------------------------------------------------------------------------*/ + +#ifndef regularExpression_H +#define regularExpression_H + +#include +#include + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class regularExpression Declaration +\*---------------------------------------------------------------------------*/ + +class regularExpression +{ + // Private data + + //- Precompiled regular expression + regex_t* preg_; + + + // Private member functions + + //- Disallow default bitwise copy construct + regularExpression(const regularExpression&); + + //- Disallow default bitwise assignment + void operator=(const regularExpression&); + +public: + + + // Constructors + + //- Construct from string + inline regularExpression(const string& s) + { + preg_ = new regex_t; + + if (regcomp(preg_, s.c_str(), REG_EXTENDED|REG_NOSUB) != 0) + { + FatalErrorIn + ( + "regularExpression::regularExpression(const char*)" + ) << "Failed to compile regular expression " << s + << exit(FatalError); + } + } + + + // Destructor + + //- Construct from string + inline ~regularExpression() + { + if (preg_) + { + regfree(preg_); + delete preg_; + } + } + + + // Member functions + + //- Matches? + inline bool matches(const string& s) + { + size_t nmatch = 0; + regmatch_t *pmatch = NULL; + + return regexec(preg_, s.c_str(), nmatch, pmatch, 0) == 0; + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H index c913892c26..95cb34932d 100644 --- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H +++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicList.H @@ -159,15 +159,9 @@ public: //- Assignment of all entries to the given value inline void operator=(const T&); - //- Assignment from List + //- Assignment from List. Also handles assignment from DynamicList. inline void operator=(const List&); - //- Assignment from DynamicList - inline void operator= - ( - const DynamicList& - ); - // IOstream operators diff --git a/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H b/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H index d383480035..da6bd13067 100644 --- a/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H +++ b/src/OpenFOAM/containers/Lists/DynamicList/DynamicListI.H @@ -85,8 +85,10 @@ inline void Foam::DynamicList::setSize } else { + label nextFree = List::size(); allocSize_ = s; List::setSize(allocSize_); + List::size() = nextFree; } } @@ -104,8 +106,10 @@ inline void Foam::DynamicList::setSize } else { + label nextFree = List::size(); allocSize_ = s; List::setSize(allocSize_, t); + List::size() = nextFree; } } @@ -165,7 +169,7 @@ Foam::DynamicList::transfer ) { allocSize_ = l.allocSize(); - List::transfer(l); // take over storage + List::transfer(l); // take over storage. Null l. } @@ -187,9 +191,9 @@ inline void Foam::DynamicList::append(const T& e) List::setSize(allocSize_); } - this->operator[](nextFree - 1) = e; - List::size() = nextFree; + + this->operator[](nextFree - 1) = e; } @@ -204,7 +208,13 @@ inline T Foam::DynamicList::remove() ) << "List is empty" << abort(FatalError); } - return List::operator[](--List::size()); + label nextFree = List::size()-1; + + const T& val = List::operator[](nextFree); + + List::size() = nextFree; + + return val; } @@ -258,18 +268,4 @@ inline void Foam::DynamicList::operator= } -template -inline void Foam::DynamicList::operator= -( - const DynamicList& l -) -{ - List::operator=(l); - // allocSize_ = l.allocSize(); // wrong - allocSize_ = List::size(); - // ^^^^ with this change, we could just use - // DynamicList::operator=(const List&) instead -} - - // ************************************************************************* // diff --git a/src/OpenFOAM/meshes/meshShapes/face/face.C b/src/OpenFOAM/meshes/meshShapes/face/face.C index bb0492735f..502e3e3eec 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/face.C +++ b/src/OpenFOAM/meshes/meshShapes/face/face.C @@ -526,7 +526,7 @@ Foam::point Foam::face::centre(const pointField& meshPoints) const } -Foam::vector Foam::face::normal(const pointField& meshPoints) const +Foam::vector Foam::face::normal(const pointField& p) const { // Calculate the normal by summing the face triangle normals. // Changed to deal with small concavity by using a central decomposition @@ -539,38 +539,43 @@ Foam::vector Foam::face::normal(const pointField& meshPoints) const { return triPointRef ( - meshPoints[operator[](0)], - meshPoints[operator[](1)], - meshPoints[operator[](2)] + p[operator[](0)], + p[operator[](1)], + p[operator[](2)] ).normal(); } - vector n = vector::zero; - - point centrePoint = Foam::average(points(meshPoints)); - label nPoints = size(); - point nextPoint = centrePoint; - register label pI; + point centrePoint = vector::zero; + for (pI = 0; pI < nPoints; pI++) + { + centrePoint += p[operator[](pI)]; + } + centrePoint /= nPoints; + + vector n = vector::zero; + + point nextPoint = centrePoint; + for (pI = 0; pI < nPoints; pI++) { if (pI < nPoints - 1) { - nextPoint = meshPoints[operator[](pI + 1)]; + nextPoint = p[operator[](pI + 1)]; } else { - nextPoint = meshPoints[operator[](0)]; + nextPoint = p[operator[](0)]; } // Note: for best accuracy, centre point always comes last // n += triPointRef ( - meshPoints[operator[](pI)], + p[operator[](pI)], nextPoint, centrePoint ).normal(); diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C index 86a0a618c1..5f16ad1335 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C @@ -241,7 +241,7 @@ void Foam::mapDistribute::distribute Pstream::nonBlocking, domain, reinterpret_cast(subField.begin()), - subField.size() + subField.size()*sizeof(T) ); } } @@ -262,7 +262,7 @@ void Foam::mapDistribute::distribute Pstream::nonBlocking, domain, reinterpret_cast(recvFields[domain].begin()), - recvFields[domain].size() + recvFields[domain].size()*sizeof(T) ); } } diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.C b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.C index 8c21017269..6bcc2af56f 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.C +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.C @@ -66,7 +66,6 @@ primitiveMesh::primitiveMesh() ppPtr_(NULL), cpPtr_(NULL), - allocSize_(0), labels_(0), cellCentresPtr_(NULL), @@ -109,7 +108,6 @@ primitiveMesh::primitiveMesh ppPtr_(NULL), cpPtr_(NULL), - allocSize_(0), labels_(0), cellCentresPtr_(NULL), diff --git a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H index 3868ba2b25..6f24944cbc 100644 --- a/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H +++ b/src/OpenFOAM/meshes/primitiveMesh/primitiveMesh.H @@ -54,6 +54,7 @@ SourceFiles #ifndef primitiveMesh_H #define primitiveMesh_H +#include "DynamicList.H" #include "edgeList.H" #include "pointField.H" #include "SubField.H" @@ -157,10 +158,8 @@ class primitiveMesh // On-the-fly edge addresing storage - //- Temporary storage for addressing. allocSize is the real size - // of the labelList. - mutable label allocSize_; - mutable labelList labels_; + //- Temporary storage for addressing. + mutable DynamicList