From 161991032ef3822fed883759406ccdc82d8cd3b9 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 1 Feb 2011 18:23:08 +0100 Subject: [PATCH 01/57] STYLE: deactivate coco-cpp until its future is clearer --- src/OpenFOAM/Make/files | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index bf4c345bec..7e293fc7eb 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -164,11 +164,16 @@ $(functionEntries)/includeIfPresentEntry/includeIfPresentEntry.C $(functionEntries)/inputModeEntry/inputModeEntry.C $(functionEntries)/removeEntry/removeEntry.C -calcEntry = $(functionEntries)/calcEntry -$(calcEntry)/calcEntryParser.atg -$(calcEntry)/calcEntryInternal.C -$(calcEntry)/calcEntry.C - +/* + * Requires customized coco-cpp + * could be dropped or activated in the future + */ +/* + calcEntry = $(functionEntries)/calcEntry + $(calcEntry)/calcEntryParser.atg + $(calcEntry)/calcEntryInternal.C + $(calcEntry)/calcEntry.C +*/ IOdictionary = db/IOobjects/IOdictionary $(IOdictionary)/IOdictionary.C From 1129edaf53da3fd313d894d4317ed1a5df0f9ad0 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 1 Feb 2011 18:34:19 +0100 Subject: [PATCH 02/57] STYLE: apps/paraview3/bashrc-EXAMPLE to guide people with non-standard paraview --- etc/apps/paraview3/bashrc-EXAMPLE | 46 +++++++++++++++++++++++++++++++ etc/bashrc | 12 ++++---- 2 files changed, 52 insertions(+), 6 deletions(-) create mode 100644 etc/apps/paraview3/bashrc-EXAMPLE diff --git a/etc/apps/paraview3/bashrc-EXAMPLE b/etc/apps/paraview3/bashrc-EXAMPLE new file mode 100644 index 0000000000..8db47a9ec7 --- /dev/null +++ b/etc/apps/paraview3/bashrc-EXAMPLE @@ -0,0 +1,46 @@ +#----------------------------------*-sh-*-------------------------------------- +# ========= | +# \\ / 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 . +# +# File +# paraview3/bashrc-EXAMPLE +# +# Description +# Example of chaining to the standard paraview3/bashrc with a +# different ParaView_VERSION +# +# Note +# This file could be copied to a user or site location, but should never +# replace the default shipped version as this will cause an infinite loop +# +#------------------------------------------------------------------------------ + +# +# Use other (shipped) bashrc with a different ParaView_VERSION +# + +foamFile=$($WM_PROJECT_DIR/bin/foamEtcFile -mode o apps/paraview3/bashrc 2>/dev/null) +[ $? -eq 0 ] && . $foamFile ParaView_VERSION=3.9.0 + +unset foamFile + +# ----------------------------------------------------------------------------- diff --git a/etc/bashrc b/etc/bashrc index 95c83e82f8..310d5fe00d 100644 --- a/etc/bashrc +++ b/etc/bashrc @@ -122,12 +122,12 @@ export WM_THIRD_PARTY_DIR=$WM_PROJECT_INST_DIR/ThirdParty-$WM_PROJECT_VERSION # Source files, possibly with some verbosity _foamSource() { - while [ $# -ge 1 ] - do - [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1" - . $1 - shift - done + while [ $# -ge 1 ] + do + [ "$FOAM_VERBOSE" -a "$PS1" ] && echo "Sourcing: $1" + . $1 + shift + done } # Evaluate command-line parameters From 1a03d43b57f3ec5788d16e79269e1227abe0d039 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 1 Feb 2011 18:50:19 +0100 Subject: [PATCH 03/57] STYLE: remove comments referring to '' or ' ' --- .../manipulation/insideCells/insideCells.C | 30 +++++++++++-------- .../writers/dx/dxSurfaceWriter.H | 10 +++---- .../writers/ensight/ensightSurfaceWriter.H | 10 +++---- .../writers/foamFile/foamFileSurfaceWriter.H | 10 +++---- .../writers/raw/rawSurfaceWriter.H | 10 +++---- .../writers/starcd/starcdSurfaceWriter.H | 6 ++-- .../sampledSurface/writers/surfaceWriter.H | 12 ++++---- .../writers/vtk/vtkSurfaceWriter.H | 10 +++---- 8 files changed, 52 insertions(+), 46 deletions(-) diff --git a/applications/utilities/mesh/manipulation/insideCells/insideCells.C b/applications/utilities/mesh/manipulation/insideCells/insideCells.C index 967240701e..16a37594d8 100644 --- a/applications/utilities/mesh/manipulation/insideCells/insideCells.C +++ b/applications/utilities/mesh/manipulation/insideCells/insideCells.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 @@ -22,8 +22,8 @@ License along with OpenFOAM. If not, see . Description - Picks up cells with cell centre 'inside' of surface. Requires surface - to be closed and singly connected. + Picks up cells with cell centre 'inside' of surface. + Requires surface to be closed and singly connected. \*---------------------------------------------------------------------------*/ @@ -42,9 +42,16 @@ using namespace Foam; int main(int argc, char *argv[]) { + argList::addNote + ( + "Create a cellSet for cells with their centres inside the defined " + "surface.\n" + "Surface must be closed and singly connected." + ); + argList::noParallel(); - argList::validArgs.append("surface file"); - argList::validArgs.append("destination cellSet"); + argList::validArgs.append("surfaceFile"); + argList::validArgs.append("cellSet"); # include "setRootCase.H" # include "createTime.H" @@ -75,14 +82,13 @@ int main(int argc, char *argv[]) } - Info<< "Selected " << insideCells.size() - << " cells out of " << mesh.nCells() << endl - << endl + Info<< "Selected " << insideCells.size() << " of " << mesh.nCells() + << " cells" << nl << nl << "Writing selected cells to cellSet " << insideCells.name() - << endl << endl - << "Use this cellSet e.g. with subsetMesh : " << endl << endl - << " subsetMesh " << insideCells.name() - << endl << endl; + << nl << nl + << "Use this cellSet e.g. with subsetMesh : " << nl << nl + << " subsetMesh " << insideCells.name() + << nl << endl; insideCells.write(); diff --git a/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.H b/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.H index e4e3af67e6..6ff54c775f 100644 --- a/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.H @@ -96,7 +96,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -110,7 +110,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -124,7 +124,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -138,7 +138,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -152,7 +152,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, diff --git a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.H b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.H index 628c178d4e..ca42fa8f08 100644 --- a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.H @@ -117,7 +117,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -131,7 +131,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -145,7 +145,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -159,7 +159,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -173,7 +173,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, diff --git a/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.H b/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.H index ce19c21455..7912a65acf 100644 --- a/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.H @@ -107,7 +107,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -121,7 +121,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -135,7 +135,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -149,7 +149,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -163,7 +163,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, diff --git a/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.H b/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.H index 5ec4d1ac30..c08b0eee5e 100644 --- a/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.H @@ -128,7 +128,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -142,7 +142,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -156,7 +156,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -170,7 +170,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -184,7 +184,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, diff --git a/src/sampling/sampledSurface/writers/starcd/starcdSurfaceWriter.H b/src/sampling/sampledSurface/writers/starcd/starcdSurfaceWriter.H index bf0a0eb824..be537abed0 100644 --- a/src/sampling/sampledSurface/writers/starcd/starcdSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/starcd/starcdSurfaceWriter.H @@ -129,7 +129,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -143,7 +143,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -157,7 +157,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, diff --git a/src/sampling/sampledSurface/writers/surfaceWriter.H b/src/sampling/sampledSurface/writers/surfaceWriter.H index be26517849..f9d0587164 100644 --- a/src/sampling/sampledSurface/writers/surfaceWriter.H +++ b/src/sampling/sampledSurface/writers/surfaceWriter.H @@ -119,7 +119,7 @@ public: //- Write single surface geometry to file. virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -132,7 +132,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -147,7 +147,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -162,7 +162,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -177,7 +177,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -192,7 +192,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, diff --git a/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.H b/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.H index 322159094b..75af4a347e 100644 --- a/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.H @@ -105,7 +105,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -119,7 +119,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -133,7 +133,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -147,7 +147,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, @@ -161,7 +161,7 @@ public: // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, // //surface/TIME + const fileName& outputDir, // /surface/TIME const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, From ffd20770ddf3a9e236d2217ad62b41c6430edc34 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 4 Feb 2011 18:59:45 +0100 Subject: [PATCH 04/57] ENH: add (non-templated) polynomialFunction STYLE: integrateLimits() -> integrate() for consistency with DataEntry/polynomial. Rename old 'integrate', 'integrateMinus1' methods to 'integral', 'integralMinus1' (ie, substantive instead of verb for clarity). --- .../test/Polynomial/Test-Polynomial.C | 65 ++- src/OpenFOAM/Make/files | 1 + .../functions/Polynomial/Polynomial.C | 109 +++-- .../functions/Polynomial/Polynomial.H | 47 +- .../functions/Polynomial/polynomialFunction.C | 415 ++++++++++++++++++ .../functions/Polynomial/polynomialFunction.H | 246 +++++++++++ .../thermo/hPolynomial/hPolynomialThermo.C | 8 +- 7 files changed, 809 insertions(+), 82 deletions(-) create mode 100644 src/OpenFOAM/primitives/functions/Polynomial/polynomialFunction.C create mode 100644 src/OpenFOAM/primitives/functions/Polynomial/polynomialFunction.H diff --git a/applications/test/Polynomial/Test-Polynomial.C b/applications/test/Polynomial/Test-Polynomial.C index fbfbcc2000..c251bade74 100644 --- a/applications/test/Polynomial/Test-Polynomial.C +++ b/applications/test/Polynomial/Test-Polynomial.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2009-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2009-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -31,6 +31,7 @@ Description #include "IStringStream.H" #include "Polynomial.H" +#include "polynomialFunction.H" #include "Random.H" #include "cpuTime.H" @@ -38,7 +39,7 @@ using namespace Foam; const int PolySize = 8; const scalar coeff[] = { 0.11, 0.45, -0.94, 1.58, -2.58, 0.08, 3.15, -4.78 }; -const char* polyDef = "testPoly (0.11 0.45 -0.94 1.58 -2.58 0.08 3.15 -4.78)"; +const char* polyDef = "(0.11 0.45 -0.94 1.58 -2.58 0.08 3.15 -4.78)"; scalar polyValue(const scalar x) @@ -58,7 +59,7 @@ scalar polyValue(const scalar x) scalar intPolyValue(const scalar x) { - // Hard-coded integrated form of above polynomial + // Hard-coded integral form of above polynomial return coeff[0]*x + coeff[1]/2.0*sqr(x) @@ -109,27 +110,44 @@ int main(int argc, char *argv[]) const label nIters = 1000; scalar sum = 0.0; - Info<< "null poly = " << (Polynomial<8>()) << nl << endl; + Info<< "null poly = " << (Polynomial<8>()) << nl + << "null poly = " << (polynomialFunction(8)) << nl + << endl; - // Polynomial<8> poly("testPoly", IStringStream(polyDef)()); Polynomial<8> poly(coeff); - Polynomial<9> intPoly(poly.integrate(0.0)); + Polynomial<9> intPoly(poly.integral(0.0)); - Info<< "poly = " << poly << endl; - Info<< "intPoly = " << intPoly << nl << endl; + IStringStream is(polyDef); + polynomialFunction polyfunc(is); - Info<< "2*poly = " << 2*poly << endl; - Info<< "poly+poly = " << poly + poly << nl << endl; + Info<< "poly = " << poly << nl + << "intPoly = " << intPoly << nl + << endl; - Info<< "3*poly = " << 3*poly << endl; - Info<< "poly+poly+poly = " << poly + poly + poly << nl << endl; + Info<< "2*poly = " << 2*poly << nl + << "poly+poly = " << poly + poly << nl + << "3*poly = " << 3*poly << nl + << "poly+poly+poly = " << poly + poly + poly << nl + << "3*poly - 2*poly = " << 3*poly - 2*poly << nl + << endl; + + Info<< nl << "--- as polynomialFunction" << nl << endl; + Info<< "polyf = " << polyfunc << nl + << "intPoly = " << poly.integral(0.0) << nl + << endl; + + Info<< "2*polyf = " << 2*polyfunc << nl + << "polyf+polyf = " << polyfunc + polyfunc << nl + << "3*polyf = " << 3*polyfunc << nl + << "polyf+polyf+polyf = " << polyfunc + polyfunc + polyfunc << nl + << "3*polyf - 2*polyf = " << 3*polyfunc - 2*polyfunc << nl + << endl; - Info<< "3*poly - 2*poly = " << 3*poly - 2*poly << nl << endl; Polynomial<8> polyCopy = poly; Info<< "poly, polyCopy = " << poly << ", " << polyCopy << nl << endl; polyCopy = 2.5*poly; - Info<< "2.5*polyCopy = " << polyCopy << nl << endl; + Info<< "2.5*poly = " << polyCopy << nl << endl; Random rnd(123456); for (int i=0; i<10; i++) @@ -139,8 +157,8 @@ int main(int argc, char *argv[]) scalar px = polyValue(x); scalar ipx = intPolyValue(x); - scalar pxTest = poly.evaluate(x); - scalar ipxTest = intPoly.evaluate(x); + scalar pxTest = poly.value(x); + scalar ipxTest = intPoly.value(x); Info<<"\nx = " << x << endl; Info<< " px, pxTest = " << px << ", " << pxTest << endl; @@ -173,10 +191,21 @@ int main(int argc, char *argv[]) sum = 0.0; for (label iter = 0; iter < nIters; ++iter) { - sum += poly.evaluate(loop+iter); + sum += poly.value(loop+iter); } } - Info<< "evaluate: " << sum + Info<< "value: " << sum + << " in " << timer.cpuTimeIncrement() << " s\n"; + + for (int loop = 0; loop < n; ++loop) + { + sum = 0.0; + for (label iter = 0; iter < nIters; ++iter) + { + sum += polyfunc.value(loop+iter); + } + } + Info<< "via function: " << sum << " in " << timer.cpuTimeIncrement() << " s\n"; diff --git a/src/OpenFOAM/Make/files b/src/OpenFOAM/Make/files index 7e293fc7eb..ba3c157b10 100644 --- a/src/OpenFOAM/Make/files +++ b/src/OpenFOAM/Make/files @@ -66,6 +66,7 @@ primitives/functions/DataEntry/makeDataEntries.C primitives/functions/DataEntry/polynomial/polynomial.C primitives/functions/DataEntry/polynomial/polynomialIO.C +primitives/functions/Polynomial/polynomialFunction.C strings = primitives/strings $(strings)/string/string.C diff --git a/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.C b/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.C index 7f9ae731f6..3c642de2d3 100644 --- a/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.C +++ b/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.C @@ -41,6 +41,18 @@ Foam::Polynomial::Polynomial() } +template +Foam::Polynomial::Polynomial +( + const Polynomial& poly +) +: + VectorSpace, scalar, PolySize>(poly), + logActive_(poly.logActive_), + logCoeff_(poly.logCoeff_) +{} + + template Foam::Polynomial::Polynomial(const scalar coeffs[PolySize]) : @@ -68,7 +80,7 @@ Foam::Polynomial::Polynomial(const UList& coeffs) ( "Polynomial::Polynomial(const UList&)" ) << "Size mismatch: Needed " << PolySize - << " but got " << coeffs.size() + << " but given " << coeffs.size() << nl << exit(FatalError); } @@ -79,6 +91,39 @@ Foam::Polynomial::Polynomial(const UList& coeffs) } +// template +// Foam::Polynomial::Polynomial(const polynomialFunction& poly) +// : +// VectorSpace, scalar, PolySize>(), +// logActive_(poly.logActive()), +// logCoeff_(poly.logCoeff()) +// { +// if (poly.size() != PolySize) +// { +// FatalErrorIn +// ( +// "Polynomial::Polynomial(const polynomialFunction&)" +// ) << "Size mismatch: Needed " << PolySize +// << " but given " << poly.size() +// << nl << exit(FatalError); +// } +// +// for (int i = 0; i < PolySize; ++i) +// { +// this->v_[i] = poly[i]; +// } +// } + + +template +Foam::Polynomial::Polynomial(Istream& is) +: + VectorSpace, scalar, PolySize>(is), + logActive_(false), + logCoeff_(0.0) +{} + + template Foam::Polynomial::Polynomial(const word& name, Istream& is) : @@ -111,38 +156,17 @@ Foam::Polynomial::Polynomial(const word& name, Istream& is) } -template -Foam::Polynomial::Polynomial(Istream& is) -: - VectorSpace, scalar, PolySize>(is), - logActive_(false), - logCoeff_(0.0) -{} - - -template -Foam::Polynomial::Polynomial -( - const Polynomial& poly -) -: - VectorSpace, scalar, PolySize>(poly), - logActive_(poly.logActive_), - logCoeff_(poly.logCoeff_) -{} - - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -bool& Foam::Polynomial::logActive() +bool Foam::Polynomial::logActive() const { return logActive_; } template -Foam::scalar& Foam::Polynomial::logCoeff() +Foam::scalar Foam::Polynomial::logCoeff() const { return logCoeff_; } @@ -151,27 +175,27 @@ Foam::scalar& Foam::Polynomial::logCoeff() template Foam::scalar Foam::Polynomial::value(const scalar x) const { - scalar y = this->v_[0]; + scalar val = this->v_[0]; // avoid costly pow() in calculation scalar powX = x; for (label i=1; iv_[i]*powX; + val += this->v_[i]*powX; powX *= x; } if (logActive_) { - y += logCoeff_*log(x); + val += logCoeff_*log(x); } - return y; + return val; } template -Foam::scalar Foam::Polynomial::integrateLimits +Foam::scalar Foam::Polynomial::integrate ( const scalar x1, const scalar x2 @@ -181,7 +205,7 @@ Foam::scalar Foam::Polynomial::integrateLimits { FatalErrorIn ( - "scalar Polynomial::integrateLimits" + "scalar Polynomial::integrate" "(" "const scalar, " "const scalar" @@ -190,22 +214,33 @@ Foam::scalar Foam::Polynomial::integrateLimits << nl << abort(FatalError); } - intPolyType poly = this->integrate(); - return poly.value(x2) - poly.value(x1); + // avoid costly pow() in calculation + scalar powX1 = x1; + scalar powX2 = x2; + + scalar val = this->v_[0]*(powX2 - powX1); + for (label i=1; iv_[i]/(i + 1) * (powX2 - powX1); + powX1 *= x1; + powX2 *= x2; + } + + return val; } template typename Foam::Polynomial::intPolyType -Foam::Polynomial::integrate(const scalar intConstant) +Foam::Polynomial::integral(const scalar intConstant) const { intPolyType newCoeffs; newCoeffs[0] = intConstant; forAll(*this, i) { - newCoeffs[i + 1] = this->v_[i]/(i + 1); + newCoeffs[i+1] = this->v_[i]/(i + 1); } return newCoeffs; @@ -214,14 +249,14 @@ Foam::Polynomial::integrate(const scalar intConstant) template typename Foam::Polynomial::polyType -Foam::Polynomial::integrateMinus1(const scalar intConstant) +Foam::Polynomial::integralMinus1(const scalar intConstant) const { polyType newCoeffs; if (this->v_[0] > VSMALL) { - newCoeffs.logActive() = true; - newCoeffs.logCoeff() = this->v_[0]; + newCoeffs.logActive_ = true; + newCoeffs.logCoeff_ = this->v_[0]; } newCoeffs[0] = intConstant; diff --git a/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.H b/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.H index 06511b0003..5dfa271c8d 100644 --- a/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.H +++ b/src/OpenFOAM/primitives/functions/Polynomial/Polynomial.H @@ -29,14 +29,14 @@ Description poly = logCoeff*log(x) + sum(coeff_[i]*x^i) - where 0 \<= i \<= n + where 0 \<= i \<= N - integer powers, starting at zero - value(x) to evaluate the poly for a given value - integrate(x1, x2) between two scalar values - - integrate() to return a new, intergated coeff polynomial + - integral() to return a new, integral coeff polynomial - increases the size (order) - - integrateMinus1() to return a new, integrated coeff polynomial where + - integralMinus1() to return a new, integral coeff polynomial where the base poly starts at order -1 SourceFiles @@ -85,10 +85,10 @@ class Polynomial // Private data - //- Include the log term? - only activated using integrateMinus1() + //- Include the log term? - only activated using integralMinus1() bool logActive_; - //- Log coefficient - only activated using integrateMinus1() + //- Log coefficient - only activated using integralMinus1() scalar logCoeff_; @@ -104,6 +104,9 @@ public: //- Construct null, with all coefficients = 0.0 Polynomial(); + //- Copy constructor + Polynomial(const Polynomial&); + //- Construct from C-array of coefficients explicit Polynomial(const scalar coeffs[PolySize]); @@ -111,24 +114,21 @@ public: explicit Polynomial(const UList& coeffs); //- Construct from Istream - Polynomial(Istream& is); + Polynomial(Istream&); //- Construct from name and Istream - Polynomial(const word& name, Istream& is); - - //- Copy constructor - Polynomial(const Polynomial& poly); + Polynomial(const word& name, Istream&); // Member Functions // Access - //- Return access to the log term active flag - bool& logActive(); + //- Return true if the log term is active + bool logActive() const; - //- Return access to the log coefficient - scalar& logCoeff(); + //- Return the log coefficient + scalar logCoeff() const; // Evaluation @@ -136,16 +136,17 @@ public: //- Return polynomial value scalar value(const scalar x) const; - //- Return integrated polynomial coefficients - // argument becomes zeroth element (constant of integration) - intPolyType integrate(const scalar intConstant = 0.0); - - //- Return integrated polynomial coefficients when lowest order - // is -1. Argument added to zeroth element - polyType integrateMinus1(const scalar intConstant = 0.0); - //- Integrate between two values - scalar integrateLimits(const scalar x1, const scalar x2) const; + scalar integrate(const scalar x1, const scalar x2) const; + + + //- Return integral coefficients. + // Argument becomes zeroth element (constant of integration) + intPolyType integral(const scalar intConstant = 0.0) const; + + //- Return integral coefficients when lowest order is -1. + // Argument becomes zeroth element (constant of integration) + polyType integralMinus1(const scalar intConstant = 0.0) const; //- Ostream Operator diff --git a/src/OpenFOAM/primitives/functions/Polynomial/polynomialFunction.C b/src/OpenFOAM/primitives/functions/Polynomial/polynomialFunction.C new file mode 100644 index 0000000000..44e82ac26d --- /dev/null +++ b/src/OpenFOAM/primitives/functions/Polynomial/polynomialFunction.C @@ -0,0 +1,415 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 . + +\*---------------------------------------------------------------------------*/ + +#include "polynomialFunction.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(polynomialFunction, 0); +} + + +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + + +Foam::polynomialFunction Foam::polynomialFunction::cloneIntegral +( + const polynomialFunction& poly, + const scalar intConstant +) +{ + polynomialFunction newPoly(poly.size()+1); + + newPoly[0] = intConstant; + forAll(poly, i) + { + newPoly[i+1] = poly[i]/(i + 1); + } + + return newPoly; +} + + +Foam::polynomialFunction Foam::polynomialFunction::cloneIntegralMinus1 +( + const polynomialFunction& poly, + const scalar intConstant +) +{ + polynomialFunction newPoly(poly.size()+1); + + if (poly[0] > VSMALL) + { + newPoly.logActive_ = true; + newPoly.logCoeff_ = poly[0]; + } + + newPoly[0] = intConstant; + for (label i=1; i < poly.size(); ++i) + { + newPoly[i] = poly[i]/i; + } + + return newPoly; +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::polynomialFunction::polynomialFunction(const label order) +: + scalarList(order, 0.0), + logActive_(false), + logCoeff_(0.0) +{ + if (this->empty()) + { + FatalErrorIn + ( + "polynomialFunction::polynomialFunction(const label order)" + ) << "polynomialFunction coefficients are invalid (empty)" + << nl << exit(FatalError); + } +} + + +Foam::polynomialFunction::polynomialFunction(const polynomialFunction& poly) +: + scalarList(poly), + logActive_(poly.logActive_), + logCoeff_(poly.logCoeff_) +{} + + +Foam::polynomialFunction::polynomialFunction(const UList& coeffs) +: + scalarList(coeffs), + logActive_(false), + logCoeff_(0.0) +{ + if (this->empty()) + { + FatalErrorIn + ( + "polynomialFunction::polynomialFunction(const UList&)" + ) << "polynomialFunction coefficients are invalid (empty)" + << nl << exit(FatalError); + } +} + + +Foam::polynomialFunction::polynomialFunction(Istream& is) +: + scalarList(is), + logActive_(false), + logCoeff_(0.0) +{ + if (this->empty()) + { + FatalErrorIn + ( + "polynomialFunction::polynomialFunction(Istream&)" + ) << "polynomialFunction coefficients are invalid (empty)" + << nl << exit(FatalError); + } +} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::polynomialFunction::~polynomialFunction() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +bool Foam::polynomialFunction::logActive() const +{ + return logActive_; +} + + +Foam::scalar Foam::polynomialFunction::logCoeff() const +{ + return logCoeff_; +} + + +Foam::scalar Foam::polynomialFunction::value(const scalar x) const +{ + const scalarList& coeffs = *this; + scalar val = coeffs[0]; + + // avoid costly pow() in calculation + scalar powX = x; + for (label i=1; ilogCoeff_*log(x); + } + + return val; +} + + +Foam::scalar Foam::polynomialFunction::integrate +( + const scalar x1, + const scalar x2 +) const +{ + const scalarList& coeffs = *this; + + if (logActive_) + { + FatalErrorIn + ( + "scalar polynomialFunction::integrate" + "(" + "const scalar, " + "const scalar" + ") const" + ) << "Cannot integrate polynomial with logarithmic coefficients" + << nl << abort(FatalError); + } + + // avoid costly pow() in calculation + scalar powX1 = x1; + scalar powX2 = x2; + + scalar val = coeffs[0]*(powX2 - powX1); + for (label i=1; i poly.size()) + { + forAll(poly, i) + { + coeffs[i] += poly[i]; + } + } + else + { + coeffs.setSize(poly.size(), 0.0); + + forAll(coeffs, i) + { + coeffs[i] += poly[i]; + } + } + + return *this; +} + + +Foam::polynomialFunction& +Foam::polynomialFunction::operator-=(const polynomialFunction& poly) +{ + scalarList& coeffs = *this; + + if (coeffs.size() > poly.size()) + { + forAll(poly, i) + { + coeffs[i] -= poly[i]; + } + } + else + { + coeffs.setSize(poly.size(), 0.0); + + forAll(coeffs, i) + { + coeffs[i] -= poly[i]; + } + } + + return *this; +} + + +Foam::polynomialFunction& +Foam::polynomialFunction::operator*=(const scalar s) +{ + scalarList& coeffs = *this; + forAll(coeffs, i) + { + coeffs[i] *= s; + } + + return *this; +} + + +Foam::polynomialFunction& +Foam::polynomialFunction::operator/=(const scalar s) +{ + scalarList& coeffs = *this; + forAll(coeffs, i) + { + coeffs[i] /= s; + } + + return *this; +} + + +// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * // + +Foam::Ostream& Foam::operator<<(Ostream& os, const polynomialFunction& poly) +{ + // output like VectorSpace + os << token::BEGIN_LIST; + + if (!poly.empty()) + { + for (int i=0; i. + +Class + Foam::polynomialFunction + +Description + Polynomial function representation + + poly = logCoeff*log(x) + sum(coeff_[i]*x^i) + + where 0 \<= i \<= N + + - integer powers, starting at zero + - value(x) to evaluate the poly for a given value + - integrate(x1, x2) between two scalar values + - integral() to return a new, integral coeff polynomial + - increases the size (order) + - integralMinus1() to return a new, integral coeff polynomial where + the base poly starts at order -1 + +SeeAlso + Foam::Polynomial for a templated implementation + +SourceFiles + polynomialFunction.C + +\*---------------------------------------------------------------------------*/ + +#ifndef polynomialFunction_H +#define polynomialFunction_H + +#include "scalarList.H" +#include "Ostream.H" +#include "runTimeSelectionTables.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of classes +class polynomialFunction; + +// Forward declaration of friend functions +Ostream& operator<<(Ostream&, const polynomialFunction&); + + +/*---------------------------------------------------------------------------*\ + Class polynomialFunction Declaration +\*---------------------------------------------------------------------------*/ + +class polynomialFunction +: + private scalarList +{ + // Private data + + //- Include the log term? - only activated using integralMinus1() + bool logActive_; + + //- Log coefficient - only activated using integralMinus1() + scalar logCoeff_; + + + // Private Member Functions + + //- Return integral coefficients. + // Argument becomes zeroth element (constant of integration) + static polynomialFunction cloneIntegral + ( + const polynomialFunction&, + const scalar intConstant = 0.0 + ); + + //- Return integral coefficients when lowest order is -1. + // Argument becomes zeroth element (constant of integration) + static polynomialFunction cloneIntegralMinus1 + ( + const polynomialFunction&, + const scalar intConstant = 0.0 + ); + + + //- Disallow default bitwise assignment + void operator=(const polynomialFunction&); + + + +public: + + //- Runtime type information + TypeName("polynomialFunction"); + + + // Constructors + + //- Construct a particular size, with all coefficients = 0.0 + explicit polynomialFunction(const label); + + //- Copy constructor + polynomialFunction(const polynomialFunction&); + + //- Construct from a list of coefficients + explicit polynomialFunction(const UList& coeffs); + + //- Construct from Istream + polynomialFunction(Istream&); + + + //- Destructor + virtual ~polynomialFunction(); + + + // Member Functions + + //- Return the number of coefficients + using scalarList::size; + + //- Return coefficient + using scalarList::operator[]; + + + // Access + + + //- Return true if the log term is active + bool logActive() const; + + //- Return the log coefficient + scalar logCoeff() const; + + + // Evaluation + + //- Return polynomial value + scalar value(const scalar x) const; + + //- Integrate between two values + scalar integrate(const scalar x1, const scalar x2) const; + + + //- Return integral coefficients. + // Argument becomes zeroth element (constant of integration) + polynomialFunction integral + ( + const scalar intConstant = 0.0 + ) const; + + //- Return integral coefficients when lowest order is -1. + // Argument becomes zeroth element (constant of integration) + polynomialFunction integralMinus1 + ( + const scalar intConstant = 0.0 + ) const; + + + // Member Operators + + polynomialFunction& operator+=(const polynomialFunction&); + polynomialFunction& operator-=(const polynomialFunction&); + + polynomialFunction& operator*=(const scalar); + polynomialFunction& operator/=(const scalar); + + + //- Ostream Operator + friend Ostream& operator<<(Ostream&, const polynomialFunction&); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * // + +polynomialFunction operator+ +( + const polynomialFunction&, + const polynomialFunction& +); + + +polynomialFunction operator- +( + const polynomialFunction&, + const polynomialFunction& +); + + +polynomialFunction operator* +( + const scalar, + const polynomialFunction& +); + + +polynomialFunction operator/ +( + const scalar, + const polynomialFunction& +); + + +polynomialFunction operator* +( + const polynomialFunction&, + const scalar +); + + +polynomialFunction operator/ +( + const polynomialFunction&, + const scalar +); + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/thermophysicalModels/specie/thermo/hPolynomial/hPolynomialThermo.C b/src/thermophysicalModels/specie/thermo/hPolynomial/hPolynomialThermo.C index 15269f6ce2..c86db56ae7 100644 --- a/src/thermophysicalModels/specie/thermo/hPolynomial/hPolynomialThermo.C +++ b/src/thermophysicalModels/specie/thermo/hPolynomial/hPolynomialThermo.C @@ -45,8 +45,8 @@ Foam::hPolynomialThermo::hPolynomialThermo Sf_ *= this->W(); CpCoeffs_ *= this->W(); - hCoeffs_ = CpCoeffs_.integrate(); - sCoeffs_ = CpCoeffs_.integrateMinus1(); + hCoeffs_ = CpCoeffs_.integral(); + sCoeffs_ = CpCoeffs_.integralMinus1(); // Offset h poly so that it is relative to the enthalpy at Tstd hCoeffs_[0] += Hf_ - hCoeffs_.value(specie::Tstd); @@ -73,8 +73,8 @@ Foam::hPolynomialThermo::hPolynomialThermo Sf_ *= this->W(); CpCoeffs_ *= this->W(); - hCoeffs_ = CpCoeffs_.integrate(); - sCoeffs_ = CpCoeffs_.integrateMinus1(); + hCoeffs_ = CpCoeffs_.integral(); + sCoeffs_ = CpCoeffs_.integralMinus1(); // Offset h poly so that it is relative to the enthalpy at Tstd hCoeffs_[0] += Hf_ - hCoeffs_.value(specie::Tstd); From 96edf6f32dde45b388279598c67674c0239680ac Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Tue, 8 Feb 2011 13:48:01 +0100 Subject: [PATCH 05/57] STYLE: pass wordReList instead of wordList to polyBoundaryMesh::patchSet() - make warning optional and reuse in cellDistFuncs::getPatchIDs --- .../polyBoundaryMesh/polyBoundaryMesh.C | 20 ++++--- .../polyBoundaryMesh/polyBoundaryMesh.H | 11 ++-- .../inverseDistanceDiffusivity.C | 2 +- .../inverseDistanceDiffusivity.H | 10 ++-- src/meshTools/cellDist/cellDistFuncs.C | 53 +++++-------------- src/meshTools/cellDist/cellDistFuncs.H | 8 +-- .../field/nearWallFields/nearWallFields.C | 5 +- .../functionObjects/forces/forces/forces.C | 3 +- 8 files changed, 47 insertions(+), 65 deletions(-) diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C index e26c665c63..897e290b43 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C +++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C @@ -550,11 +550,12 @@ Foam::label Foam::polyBoundaryMesh::whichPatch(const label faceIndex) const Foam::labelHashSet Foam::polyBoundaryMesh::patchSet ( - const wordList& patchNames + const wordReList& patchNames, + const bool warnNotFound ) const { - wordList allPatchNames = names(); - labelHashSet ps(size()); + const wordList allPatchNames(this->names()); + labelHashSet ids(size()); forAll(patchNames, i) { @@ -562,20 +563,23 @@ Foam::labelHashSet Foam::polyBoundaryMesh::patchSet // of all patch names for matches labelList patchIDs = findStrings(patchNames[i], allPatchNames); - if (patchIDs.empty()) + if (patchIDs.empty() && warnNotFound) { - WarningIn("polyBoundaryMesh::patchSet(const wordList&)") - << "Cannot find any patch names matching " << patchNames[i] + WarningIn + ( + "polyBoundaryMesh::patchSet" + "(const wordReList&, const bool) const" + ) << "Cannot find any patch names matching " << patchNames[i] << endl; } forAll(patchIDs, j) { - ps.insert(patchIDs[j]); + ids.insert(patchIDs[j]); } } - return ps; + return ids; } diff --git a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H index 0e94bb89b3..39fb527368 100644 --- a/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H +++ b/src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.H @@ -38,6 +38,7 @@ SourceFiles #include "polyPatchList.H" #include "regIOobject.H" #include "labelPair.H" +#include "wordReList.H" #include "HashSet.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -166,9 +167,13 @@ public: //- Per boundary face label the patch index const labelList& patchID() const; - //- Return the set of patch IDs corresponding to the given list of names - // Wild cards are expanded. - labelHashSet patchSet(const wordList&) const; + //- Return the set of patch IDs corresponding to the given names + // By default warns if given names are not found. + labelHashSet patchSet + ( + const wordReList& patchNames, + const bool warnNotFound = true + ) const; //- Check whether all procs have all patches and in same order. Return // true if in error. diff --git a/src/fvMotionSolver/motionDiffusivity/inverseDistance/inverseDistanceDiffusivity.C b/src/fvMotionSolver/motionDiffusivity/inverseDistance/inverseDistanceDiffusivity.C index 0cc744e7dd..bbaae54007 100644 --- a/src/fvMotionSolver/motionDiffusivity/inverseDistance/inverseDistanceDiffusivity.C +++ b/src/fvMotionSolver/motionDiffusivity/inverseDistance/inverseDistanceDiffusivity.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/fvMotionSolver/motionDiffusivity/inverseDistance/inverseDistanceDiffusivity.H b/src/fvMotionSolver/motionDiffusivity/inverseDistance/inverseDistanceDiffusivity.H index 5e1025d1f7..dc88204bd6 100644 --- a/src/fvMotionSolver/motionDiffusivity/inverseDistance/inverseDistanceDiffusivity.H +++ b/src/fvMotionSolver/motionDiffusivity/inverseDistance/inverseDistanceDiffusivity.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 @@ -36,6 +36,7 @@ SourceFiles #define inverseDistanceDiffusivity_H #include "uniformDiffusivity.H" +#include "wordReList.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -43,7 +44,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class inverseDistanceDiffusivity Declaration + Class inverseDistanceDiffusivity Declaration \*---------------------------------------------------------------------------*/ class inverseDistanceDiffusivity @@ -53,9 +54,8 @@ class inverseDistanceDiffusivity // Private data //- Patches selected to base the distance on - // These can contain regular expressions and the actual patch names - // will be searched for. - wordList patchNames_; + // These can contain patch names or regular expressions to search for. + wordReList patchNames_; // Private Member Functions diff --git a/src/meshTools/cellDist/cellDistFuncs.C b/src/meshTools/cellDist/cellDistFuncs.C index 493ee6b666..123ea628d8 100644 --- a/src/meshTools/cellDist/cellDistFuncs.C +++ b/src/meshTools/cellDist/cellDistFuncs.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 @@ -28,14 +28,9 @@ License #include "wallPolyPatch.H" #include "polyBoundaryMesh.H" -namespace Foam -{ +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -defineTypeNameAndDebug(cellDistFuncs, 0); - -} +defineTypeNameAndDebug(Foam::cellDistFuncs, 0); // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // @@ -61,7 +56,6 @@ Foam::label Foam::cellDistFuncs::findIndex // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -// Construct from mesh Foam::cellDistFuncs::cellDistFuncs(const polyMesh& mesh) : mesh_(mesh) @@ -70,36 +64,12 @@ Foam::cellDistFuncs::cellDistFuncs(const polyMesh& mesh) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -// Get patch ids of named patches Foam::labelHashSet Foam::cellDistFuncs::getPatchIDs ( - const wordList& patchNames + const wordReList& patchNames ) const { - const polyBoundaryMesh& bMesh = mesh().boundaryMesh(); - - // Construct Set of patchNames for easy checking if included - HashSet patchNamesHash(patchNames.size()); - - forAll(patchNames, patchI) - { - patchNamesHash.insert(patchNames[patchI]); - } - - // Loop over all patches and check if patch name in hashset - - labelHashSet patchIDs(bMesh.size()); - - forAll(bMesh, patchI) - { - const polyPatch& patch = bMesh[patchI]; - - if (patchNamesHash.found(patch.name())) - { - patchIDs.insert(patchI); - } - } - return patchIDs; + return mesh().boundaryMesh().patchSet(patchNames, false); } @@ -252,8 +222,10 @@ Foam::label Foam::cellDistFuncs::getPointNeighbours // size of largest patch (out of supplied subset of patches) -Foam::label Foam::cellDistFuncs::maxPatchSize(const labelHashSet& patchIDs) - const +Foam::label Foam::cellDistFuncs::maxPatchSize +( + const labelHashSet& patchIDs +) const { label maxSize = 0; @@ -271,8 +243,11 @@ Foam::label Foam::cellDistFuncs::maxPatchSize(const labelHashSet& patchIDs) // sum of patch sizes (out of supplied subset of patches) -Foam::label Foam::cellDistFuncs::sumPatchSize(const labelHashSet& patchIDs) - const +Foam::label Foam::cellDistFuncs::sumPatchSize +( + const labelHashSet& patchIDs +) +const { label sum = 0; diff --git a/src/meshTools/cellDist/cellDistFuncs.H b/src/meshTools/cellDist/cellDistFuncs.H index 7392e18f2d..3ef0c5e6e8 100644 --- a/src/meshTools/cellDist/cellDistFuncs.H +++ b/src/meshTools/cellDist/cellDistFuncs.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 @@ -39,7 +39,7 @@ SourceFiles #include "scalarField.H" #include "HashSet.H" #include "Map.H" -#include "wordList.H" +#include "wordReList.H" #include "scalarField.H" #include "point.H" #include "primitivePatch.H" @@ -98,8 +98,8 @@ public: return mesh_; } - //- Get patchIDs of named patches - labelHashSet getPatchIDs(const wordList&) const; + //- Return the set of patch IDs corresponding to the given names + labelHashSet getPatchIDs(const wordReList& patchNames) const; //- Get patchIDs of/derived off certain type (e.g. 'processorPolyPatch') // Uses isA, not isType diff --git a/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.C b/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.C index 228fa5ad32..2774396e4f 100644 --- a/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.C +++ b/src/postProcessing/functionObjects/field/nearWallFields/nearWallFields.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 @@ -87,8 +87,7 @@ void Foam::nearWallFields::read(const dictionary& dict) const fvMesh& mesh = refCast(obr_); dict.lookup("fields") >> fieldSet_; - patchSet_ = - mesh.boundaryMesh().patchSet(wordList(dict.lookup("patches"))); + patchSet_ = mesh.boundaryMesh().patchSet(dict.lookup("patches")); distance_ = readScalar(dict.lookup("distance")); diff --git a/src/postProcessing/functionObjects/forces/forces/forces.C b/src/postProcessing/functionObjects/forces/forces/forces.C index 412794795b..aacc6b1947 100644 --- a/src/postProcessing/functionObjects/forces/forces/forces.C +++ b/src/postProcessing/functionObjects/forces/forces/forces.C @@ -229,8 +229,7 @@ void Foam::forces::read(const dictionary& dict) const fvMesh& mesh = refCast(obr_); - patchSet_ = - mesh.boundaryMesh().patchSet(wordList(dict.lookup("patches"))); + patchSet_ = mesh.boundaryMesh().patchSet(dict.lookup("patches")); if (directForceDensity_) { From 10f5e8080328ce7307f4f352a563311cd482e326 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 11 Feb 2011 09:21:08 +0100 Subject: [PATCH 06/57] ENH: add -make option to touchdep, toucho - restricts selection to Make/$WM_OPTIONS* subdirectories, which is useful when multiple compilers are in use --- bin/touchdep | 70 +++++++++++++++++++++++++++++++++++++++++++--------- bin/toucho | 67 ++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 113 insertions(+), 24 deletions(-) diff --git a/bin/touchdep b/bin/touchdep index cfc8cebc20..48c19081ca 100755 --- a/bin/touchdep +++ b/bin/touchdep @@ -3,7 +3,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 @@ -28,25 +28,71 @@ # Description # touch all .dep files #------------------------------------------------------------------------------ +usage() { + while [ "$#" -ge 1 ]; do echo "$1"; shift; done + cat< Date: Fri, 11 Feb 2011 11:22:29 +0000 Subject: [PATCH 07/57] ENH: simpleGeomDecomp: allow parallel distribution --- .../simpleGeomDecomp/simpleGeomDecomp.C | 174 +++++++++++++++++- .../simpleGeomDecomp/simpleGeomDecomp.H | 20 +- 2 files changed, 182 insertions(+), 12 deletions(-) diff --git a/src/parallel/decompose/decompositionMethods/simpleGeomDecomp/simpleGeomDecomp.C b/src/parallel/decompose/decompositionMethods/simpleGeomDecomp/simpleGeomDecomp.C index 9f5ff83436..4ce8706dea 100644 --- a/src/parallel/decompose/decompositionMethods/simpleGeomDecomp/simpleGeomDecomp.C +++ b/src/parallel/decompose/decompositionMethods/simpleGeomDecomp/simpleGeomDecomp.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,6 +26,7 @@ License #include "simpleGeomDecomp.H" #include "addToRunTimeSelectionTable.H" #include "SortableList.H" +#include "globalIndex.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -53,7 +54,7 @@ void Foam::simpleGeomDecomp::assignToProcessorGroup ( labelList& processorGroup, const label nProcGroup -) +) const { label jump = processorGroup.size()/nProcGroup; label jumpb = jump + 1; @@ -90,7 +91,7 @@ void Foam::simpleGeomDecomp::assignToProcessorGroup const labelList& indices, const scalarField& weights, const scalar summedWeights -) +) const { // This routine gets the sorted points. // Easiest to explain with an example. @@ -126,7 +127,10 @@ void Foam::simpleGeomDecomp::assignToProcessorGroup } -Foam::labelList Foam::simpleGeomDecomp::decompose(const pointField& points) +Foam::labelList Foam::simpleGeomDecomp::decomposeOneProc +( + const pointField& points +) const { // construct a list for the final result labelList finalDecomp(points.size()); @@ -195,11 +199,11 @@ Foam::labelList Foam::simpleGeomDecomp::decompose(const pointField& points) } -Foam::labelList Foam::simpleGeomDecomp::decompose +Foam::labelList Foam::simpleGeomDecomp::decomposeOneProc ( const pointField& points, const scalarField& weights -) +) const { // construct a list for the final result labelList finalDecomp(points.size()); @@ -300,4 +304,162 @@ Foam::simpleGeomDecomp::simpleGeomDecomp(const dictionary& decompositionDict) // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +Foam::labelList Foam::simpleGeomDecomp::decompose +( + const pointField& points +) +{ + if (!Pstream::parRun()) + { + return decomposeOneProc(points); + } + else + { + globalIndex globalNumbers(points.size()); + + // Collect all points on master + if (Pstream::master()) + { + pointField allPoints(globalNumbers.size()); + + label nTotalPoints = 0; + // Master first + SubField(allPoints, points.size()).assign(points); + nTotalPoints += points.size(); + + // Add slaves + for (int slave=1; slave + ( + allPoints, + nbrPoints.size(), + nTotalPoints + ).assign(nbrPoints); + nTotalPoints += nbrPoints.size(); + } + + // Decompose + labelList finalDecomp(decomposeOneProc(allPoints)); + + // Send back + for (int slave=1; slave + ( + finalDecomp, + globalNumbers.localSize(slave), + globalNumbers.offset(slave) + ); + } + // Get my own part + finalDecomp.setSize(points.size()); + + return finalDecomp; + } + else + { + // Send my points + { + OPstream toMaster(Pstream::scheduled, Pstream::masterNo()); + toMaster<< points; + } + + // Receive back decomposition + IPstream fromMaster(Pstream::scheduled, Pstream::masterNo()); + labelList finalDecomp(fromMaster); + + return finalDecomp; + } + } +} + + +Foam::labelList Foam::simpleGeomDecomp::decompose +( + const pointField& points, + const scalarField& weights +) +{ + if (!Pstream::parRun()) + { + return decomposeOneProc(points, weights); + } + else + { + globalIndex globalNumbers(points.size()); + + // Collect all points on master + if (Pstream::master()) + { + pointField allPoints(globalNumbers.size()); + scalarField allWeights(allPoints.size()); + + label nTotalPoints = 0; + // Master first + SubField(allPoints, points.size()).assign(points); + SubField(allWeights, points.size()).assign(weights); + nTotalPoints += points.size(); + + // Add slaves + for (int slave=1; slave + ( + allPoints, + nbrPoints.size(), + nTotalPoints + ).assign(nbrPoints); + SubField + ( + allWeights, + nbrWeights.size(), + nTotalPoints + ).assign(nbrWeights); + nTotalPoints += nbrPoints.size(); + } + + // Decompose + labelList finalDecomp(decomposeOneProc(allPoints, allWeights)); + + // Send back + for (int slave=1; slave + ( + finalDecomp, + globalNumbers.localSize(slave), + globalNumbers.offset(slave) + ); + } + // Get my own part + finalDecomp.setSize(points.size()); + + return finalDecomp; + } + else + { + // Send my points + { + OPstream toMaster(Pstream::scheduled, Pstream::masterNo()); + toMaster<< points << weights; + } + + // Receive back decomposition + IPstream fromMaster(Pstream::scheduled, Pstream::masterNo()); + labelList finalDecomp(fromMaster); + + return finalDecomp; + } + } +} + + // ************************************************************************* // diff --git a/src/parallel/decompose/decompositionMethods/simpleGeomDecomp/simpleGeomDecomp.H b/src/parallel/decompose/decompositionMethods/simpleGeomDecomp/simpleGeomDecomp.H index d14b05abde..c829f4f9bf 100644 --- a/src/parallel/decompose/decompositionMethods/simpleGeomDecomp/simpleGeomDecomp.H +++ b/src/parallel/decompose/decompositionMethods/simpleGeomDecomp/simpleGeomDecomp.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 @@ -49,7 +49,7 @@ class simpleGeomDecomp { // Private Member Functions - void assignToProcessorGroup(labelList& processorGroup, const label); + void assignToProcessorGroup(labelList&, const label) const; void assignToProcessorGroup ( @@ -58,7 +58,15 @@ class simpleGeomDecomp const labelList& indices, const scalarField& weights, const scalar summedWeights - ); + ) const; + + labelList decomposeOneProc(const pointField& points) const; + + labelList decomposeOneProc + ( + const pointField& points, + const scalarField& weights + ) const; //- Disallow default bitwise copy construct and assignment void operator=(const simpleGeomDecomp&); @@ -86,9 +94,9 @@ public: virtual bool parallelAware() const { - // simpleDecomp does not attempt to do anything across proc - // boundaries - return false; + // simpleDecomp sends all points to the master which does + // the decomposition. + return true; } virtual labelList decompose(const pointField&); From 523b88fd77e46530ca00961ca63128d11f366fda Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 11 Feb 2011 12:22:16 +0000 Subject: [PATCH 08/57] BUG: dash behaviour of set -- --- wmake/wmakePrintBuild | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/wmake/wmakePrintBuild b/wmake/wmakePrintBuild index 3812bece3e..9fe054daa4 100755 --- a/wmake/wmakePrintBuild +++ b/wmake/wmakePrintBuild @@ -98,14 +98,20 @@ done # build="$WM_PROJECT_DIR/.build" +unset oldVersion oldPackage + +# # retrieve old values from the $WM_PROJECT_DIR/.build cache, stored as # version [packager] -set -- $(tail -1 $build 2>/dev/null) - -oldVersion="$1"; shift -oldPackage="$@" -[ "${oldPackage:-none}" = none ] && unset oldPackage - +# +getOldValues() +{ + set -- $(tail -1 $build 2>/dev/null) + oldVersion="$1" + [ "$#" -gt 0 ] && shift + oldPackage="$@" + [ "${oldPackage:-none}" = none ] && unset oldPackage +} # # printTag - output the build tag @@ -148,6 +154,9 @@ else fi +# retrieve old values +getOldValues + # # update persistent build tag if possible # From 790146fbdb07048e4cd662ebc9a67d195fbce1a5 Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 11 Feb 2011 12:26:01 +0000 Subject: [PATCH 09/57] ENH: Test-syncTools.C : cannot use magSqr with point::max --- applications/test/syncTools/Test-syncTools.C | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/applications/test/syncTools/Test-syncTools.C b/applications/test/syncTools/Test-syncTools.C index 6f9d5f408a..2638f0fb67 100644 --- a/applications/test/syncTools/Test-syncTools.C +++ b/applications/test/syncTools/Test-syncTools.C @@ -210,7 +210,7 @@ void testSparseData(const polyMesh& mesh, Random& rndGen) { // Create some data. Use slightly perturbed positions. Map sparseData; - pointField fullData(mesh.nPoints(), point::max); + pointField fullData(mesh.nPoints(), point(GREAT, GREAT, GREAT)); forAll(localPoints, i) { @@ -236,7 +236,7 @@ void testSparseData(const polyMesh& mesh, Random& rndGen) mesh, fullData, minMagSqrEqOp(), - point::max + point(GREAT, GREAT, GREAT) // true // apply separation ); @@ -246,7 +246,7 @@ void testSparseData(const polyMesh& mesh, Random& rndGen) { const point& fullPt = fullData[meshPointI]; - if (fullPt != point::max) + if (fullPt != point(GREAT, GREAT, GREAT)) { const point& sparsePt = sparseData[meshPointI]; @@ -286,7 +286,7 @@ void testSparseData(const polyMesh& mesh, Random& rndGen) { // Create some data. Use slightly perturbed positions. EdgeMap sparseData; - pointField fullData(mesh.nEdges(), point::max); + pointField fullData(mesh.nEdges(), point(GREAT, GREAT, GREAT)); const edgeList& edges = allBoundary.edges(); const labelList meshEdges = allBoundary.meshEdges @@ -320,7 +320,7 @@ void testSparseData(const polyMesh& mesh, Random& rndGen) mesh, fullData, minMagSqrEqOp(), - point::max + point(GREAT, GREAT, GREAT) ); // Compare. @@ -329,7 +329,7 @@ void testSparseData(const polyMesh& mesh, Random& rndGen) { const point& fullPt = fullData[meshEdgeI]; - if (fullPt != point::max) + if (fullPt != point(GREAT, GREAT, GREAT)) { const point& sparsePt = sparseData[mesh.edges()[meshEdgeI]]; @@ -385,7 +385,7 @@ void testPointSync(const polyMesh& mesh, Random& rndGen) mesh, syncedPoints, minMagSqrEqOp(), - point::max + point(GREAT, GREAT, GREAT) ); forAll(syncedPoints, pointI) @@ -461,7 +461,7 @@ void testEdgeSync(const polyMesh& mesh, Random& rndGen) mesh, syncedMids, minMagSqrEqOp(), - point::max + point(GREAT, GREAT, GREAT) ); forAll(syncedMids, edgeI) From 85190a16b608c080b37dc2cd32f3e33cc4903802 Mon Sep 17 00:00:00 2001 From: mattijs Date: Fri, 11 Feb 2011 12:32:11 +0000 Subject: [PATCH 10/57] ENH: featureEdgeMesh : moved new stuff to extendedFeatureEdgeMesh --- .../surfaceFeatureExtract.C | 37 +- src/edgeMesh/Make/files | 3 + .../extendedFeatureEdgeMesh.C | 1028 +++++++++++++++++ .../extendedFeatureEdgeMesh.H | 377 ++++++ .../extendedFeatureEdgeMeshI.H} | 53 +- .../featureEdgeMesh/featureEdgeMesh.C | 953 +-------------- .../featureEdgeMesh/featureEdgeMesh.H | 304 +---- 7 files changed, 1504 insertions(+), 1251 deletions(-) create mode 100644 src/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.C create mode 100644 src/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.H rename src/edgeMesh/{featureEdgeMesh/featureEdgeMeshI.H => extendedFeatureEdgeMesh/extendedFeatureEdgeMeshI.H} (66%) diff --git a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C index b0d3d83ec0..6d83d18363 100644 --- a/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.C +++ b/applications/utilities/surface/surfaceFeatureExtract/surfaceFeatureExtract.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 @@ -36,6 +36,7 @@ Description #include "Time.H" #include "surfaceFeatures.H" #include "featureEdgeMesh.H" +#include "extendedFeatureEdgeMesh.H" #include "treeBoundBox.H" #include "meshTools.H" #include "OFstream.H" @@ -298,20 +299,46 @@ int main(int argc, char *argv[]) // Extracting and writing a featureEdgeMesh - Pout<< nl << "Writing featureEdgeMesh to constant/featureEdgeMesh." - << endl; - - featureEdgeMesh feMesh + extendedFeatureEdgeMesh feMesh ( newSet, runTime, surfFileName.lessExt().name() + ".featureEdgeMesh" ); + Info<< nl << "Writing extendedFeatureEdgeMesh to " << feMesh.objectPath() + << endl; + + feMesh.writeObj(surfFileName.lessExt().name()); feMesh.write(); + + // Write a featureEdgeMesh for backwards compatibility + { + featureEdgeMesh bfeMesh + ( + IOobject + ( + surfFileName.lessExt().name() + ".eMesh", // name + runTime.constant(), // instance + "triSurface", + runTime, // registry + IOobject::NO_READ, + IOobject::AUTO_WRITE, + false + ), + feMesh.points(), + feMesh.edges() + ); + + Info<< nl << "Writing featureEdgeMesh to " + << bfeMesh.objectPath() << endl; + + bfeMesh.regIOobject::write(); + } + Info<< "End\n" << endl; return 0; diff --git a/src/edgeMesh/Make/files b/src/edgeMesh/Make/files index cdad239999..52f985de8c 100644 --- a/src/edgeMesh/Make/files +++ b/src/edgeMesh/Make/files @@ -20,7 +20,10 @@ $(edgeFormats)/starcd/STARCDedgeFormatRunTime.C $(edgeFormats)/vtk/VTKedgeFormat.C $(edgeFormats)/vtk/VTKedgeFormatRunTime.C +extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.C + featureEdgeMesh/featureEdgeMesh.C + LIB = $(FOAM_LIBBIN)/libedgeMesh diff --git a/src/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.C b/src/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.C new file mode 100644 index 0000000000..c4f536e209 --- /dev/null +++ b/src/edgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.C @@ -0,0 +1,1028 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2004-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 "extendedFeatureEdgeMesh.H" +#include "triSurface.H" +#include "Random.H" +#include "Time.H" +#include "meshTools.H" +#include "linePointRef.H" +#include "ListListOps.H" +#include "OFstream.H" +#include "IFstream.H" +#include "unitConversion.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(Foam::extendedFeatureEdgeMesh, 0); + +Foam::scalar Foam::extendedFeatureEdgeMesh::cosNormalAngleTol_ = + Foam::cos(degToRad(0.1)); + + +Foam::label Foam::extendedFeatureEdgeMesh::convexStart_ = 0; + + +Foam::label Foam::extendedFeatureEdgeMesh::externalStart_ = 0; + + +Foam::label Foam::extendedFeatureEdgeMesh::nPointTypes = 4; + + +Foam::label Foam::extendedFeatureEdgeMesh::nEdgeTypes = 5; + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh(const IOobject& io) +: + regIOobject(io), + edgeMesh(pointField(0), edgeList(0)), + concaveStart_(0), + mixedStart_(0), + nonFeatureStart_(0), + internalStart_(0), + flatStart_(0), + openStart_(0), + multipleStart_(0), + normals_(0), + edgeDirections_(0), + edgeNormals_(0), + featurePointNormals_(0), + regionEdges_(0), + edgeTree_(), + edgeTreesByType_() +{ + if + ( + io.readOpt() == IOobject::MUST_READ + || io.readOpt() == IOobject::MUST_READ_IF_MODIFIED + || (io.readOpt() == IOobject::READ_IF_PRESENT && headerOk()) + ) + { + if (readOpt() == IOobject::MUST_READ_IF_MODIFIED) + { + WarningIn + ( + "extendedFeatureEdgeMesh::extendedFeatureEdgeMesh" + "(const IOobject&)" + ) << "Specified IOobject::MUST_READ_IF_MODIFIED but class" + << " does not support automatic rereading." + << endl; + } + + Istream& is = readStream(typeName); + + is >> *this + >> concaveStart_ + >> mixedStart_ + >> nonFeatureStart_ + >> internalStart_ + >> flatStart_ + >> openStart_ + >> multipleStart_ + >> normals_ + >> edgeNormals_ + >> featurePointNormals_ + >> regionEdges_; + + close(); + + { + // Calculate edgeDirections + + const edgeList& eds(edges()); + + const pointField& pts(points()); + + edgeDirections_.setSize(eds.size()); + + forAll(eds, eI) + { + edgeDirections_[eI] = eds[eI].vec(pts); + } + + edgeDirections_ /= mag(edgeDirections_); + } + } + + if (debug) + { + Pout<< "extendedFeatureEdgeMesh::extendedFeatureEdgeMesh :" + << " constructed from IOobject :" + << " points:" << points().size() + << " edges:" << edges().size() + << endl; + } +} + + +Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh +( + const IOobject& io, + const extendedFeatureEdgeMesh& fem +) +: + regIOobject(io), + edgeMesh(fem), + concaveStart_(fem.concaveStart()), + mixedStart_(fem.mixedStart()), + nonFeatureStart_(fem.nonFeatureStart()), + internalStart_(fem.internalStart()), + flatStart_(fem.flatStart()), + openStart_(fem.openStart()), + multipleStart_(fem.multipleStart()), + normals_(fem.normals()), + edgeDirections_(fem.edgeDirections()), + edgeNormals_(fem.edgeNormals()), + featurePointNormals_(fem.featurePointNormals()), + regionEdges_(fem.regionEdges()), + edgeTree_(), + edgeTreesByType_() +{} + + +Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh +( + const IOobject& io, + const Xfer& pointLst, + const Xfer& edgeLst +) +: + regIOobject(io), + edgeMesh(pointLst, edgeLst), + concaveStart_(0), + mixedStart_(0), + nonFeatureStart_(0), + internalStart_(0), + flatStart_(0), + openStart_(0), + multipleStart_(0), + normals_(0), + edgeDirections_(0), + edgeNormals_(0), + featurePointNormals_(0), + regionEdges_(0), + edgeTree_(), + edgeTreesByType_() +{} + + +Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh +( + const surfaceFeatures& sFeat, + const objectRegistry& obr, + const fileName& sFeatFileName +) +: + regIOobject + ( + IOobject + ( + sFeatFileName, + obr.time().constant(), + "extendedFeatureEdgeMesh", + obr, + IOobject::NO_READ, + IOobject::NO_WRITE + ) + ), + edgeMesh(pointField(0), edgeList(0)), + concaveStart_(-1), + mixedStart_(-1), + nonFeatureStart_(-1), + internalStart_(-1), + flatStart_(-1), + openStart_(-1), + multipleStart_(-1), + normals_(0), + edgeDirections_(0), + edgeNormals_(0), + featurePointNormals_(0), + regionEdges_(0), + edgeTree_(), + edgeTreesByType_() +{ + // Extract and reorder the data from surfaceFeatures + + // References to the surfaceFeatures data + const triSurface& surf(sFeat.surface()); + const pointField& sFeatLocalPts(surf.localPoints()); + const edgeList& sFeatEds(surf.edges()); + + // Filling the extendedFeatureEdgeMesh with the raw geometrical data. + + label nFeatEds = sFeat.featureEdges().size(); + + DynamicList tmpPts; + edgeList eds(nFeatEds); + DynamicList norms; + vectorField edgeDirections(nFeatEds); + labelListList edgeNormals(nFeatEds); + DynamicList