From adcebb9e1fed5b606b71a92efbd1c32c09b49edf Mon Sep 17 00:00:00 2001 From: sergio Date: Fri, 14 Jan 2011 18:07:51 +0000 Subject: [PATCH 001/367] BUG: Numeration of rayIDs for multi region cases --- .../radiation/radiationModel/fvDOM/fvDOM/fvDOM.C | 9 ++++++--- .../fvDOM/radiativeIntensityRay/radiativeIntensityRay.C | 8 ++------ .../fvDOM/radiativeIntensityRay/radiativeIntensityRay.H | 3 ++- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C index dca6315cb7..3ef7c1b0e8 100644 --- a/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C @@ -157,7 +157,8 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T) deltaTheta, nLambda_, absorptionEmission_, - blackBody_ + blackBody_, + i ) ); i++; @@ -190,7 +191,8 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T) deltaTheta, nLambda_, absorptionEmission_, - blackBody_ + blackBody_, + i ) ); i++; @@ -220,7 +222,8 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T) deltaTheta, nLambda_, absorptionEmission_, - blackBody_ + blackBody_, + i ) ); i++; diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C b/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C index 89b8e5725c..bc9f0e85d9 100644 --- a/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C @@ -30,9 +30,6 @@ License using namespace Foam::constant; -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -Foam::label Foam::radiation::radiativeIntensityRay::rayId(0); const Foam::word Foam::radiation::radiativeIntensityRay::intensityPrefix("ILambda"); @@ -50,7 +47,8 @@ Foam::radiation::radiativeIntensityRay::radiativeIntensityRay const scalar deltaTheta, const label nLambda, const absorptionEmissionModel& absorptionEmission, - const blackBodyEmission& blackBody + const blackBodyEmission& blackBody, + const label rayId ) : dom_(dom), @@ -167,7 +165,6 @@ Foam::radiation::radiativeIntensityRay::radiativeIntensityRay ); } } - rayId++; } @@ -182,7 +179,6 @@ Foam::radiation::radiativeIntensityRay::~radiativeIntensityRay() Foam::scalar Foam::radiation::radiativeIntensityRay::correct() { // reset boundary heat flux to zero - //Qr_ = dimensionedScalar("zero", dimMass/pow3(dimTime), 0.0); Qr_.boundaryField() = 0.0; scalar maxResidual = -GREAT; diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.H b/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.H index a795052305..4c1d3bf31d 100644 --- a/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.H +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.H @@ -130,7 +130,8 @@ public: const scalar deltaTheta, const label lambda, const absorptionEmissionModel& absEmmModel_, - const blackBodyEmission& blackBody + const blackBodyEmission& blackBody, + const label rayId ); From 66ef07aee8b39f46e41ca07b277af049b4749d67 Mon Sep 17 00:00:00 2001 From: sergio Date: Fri, 14 Jan 2011 18:09:47 +0000 Subject: [PATCH 002/367] STY: modification date --- .../radiation/radiationModel/fvDOM/fvDOM/fvDOM.C | 2 +- .../fvDOM/radiativeIntensityRay/radiativeIntensityRay.C | 2 +- .../fvDOM/radiativeIntensityRay/radiativeIntensityRay.H | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C index 3ef7c1b0e8..cda5e495a0 100644 --- a/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/fvDOM/fvDOM.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C b/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C index bc9f0e85d9..4edf09663f 100644 --- a/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.H b/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.H index 4c1d3bf31d..a7a95648d4 100644 --- a/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.H +++ b/src/thermophysicalModels/radiation/radiationModel/fvDOM/radiativeIntensityRay/radiativeIntensityRay.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2008-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License From 129695a9505a6c088fc918faa2b7e39d51e9dbaf Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 19 Jan 2011 14:29:56 +0100 Subject: [PATCH 003/367] STYLE: adjust executable names for some tests --- applications/test/Distribution/Make/files | 2 +- .../Distribution/{DistributionTest.C => Test-Distribution.C} | 2 +- applications/test/HashTable2/Make/files | 4 ++-- .../test/HashTable2/{hashTableTest2.C => Test-HashTable2.C} | 3 ++- applications/test/HashTable3/Make/files | 4 ++-- .../test/HashTable3/{hashTableTest3.C => Test-HashTable3.C} | 3 +-- applications/test/NamedEnum/Make/files | 2 +- applications/test/dimensionedType/Make/files | 2 +- applications/test/pTraits/Make/files | 2 +- applications/test/simpleMatrix/Make/files | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-) rename applications/test/Distribution/{DistributionTest.C => Test-Distribution.C} (99%) rename applications/test/HashTable2/{hashTableTest2.C => Test-HashTable2.C} (95%) rename applications/test/HashTable3/{hashTableTest3.C => Test-HashTable3.C} (97%) diff --git a/applications/test/Distribution/Make/files b/applications/test/Distribution/Make/files index 3585a60fc1..3b3486c124 100644 --- a/applications/test/Distribution/Make/files +++ b/applications/test/Distribution/Make/files @@ -1,3 +1,3 @@ -DistributionTest.C +Test-Distribution.C EXE = $(FOAM_USER_APPBIN)/Test-DistributionTest diff --git a/applications/test/Distribution/DistributionTest.C b/applications/test/Distribution/Test-Distribution.C similarity index 99% rename from applications/test/Distribution/DistributionTest.C rename to applications/test/Distribution/Test-Distribution.C index f6da957fb9..8f84237019 100644 --- a/applications/test/Distribution/DistributionTest.C +++ b/applications/test/Distribution/Test-Distribution.C @@ -22,7 +22,7 @@ License along with OpenFOAM. If not, see . Application - DistributionTest + Test-Distribution Description Test the Distribution class diff --git a/applications/test/HashTable2/Make/files b/applications/test/HashTable2/Make/files index 2bf9c9217d..e5bc377b8b 100644 --- a/applications/test/HashTable2/Make/files +++ b/applications/test/HashTable2/Make/files @@ -1,3 +1,3 @@ -hashTableTest2.C +Test-HashTable2.C -EXE = $(FOAM_USER_APPBIN)/hashTableTest2 +EXE = $(FOAM_USER_APPBIN)/Test-HashTable2 diff --git a/applications/test/HashTable2/hashTableTest2.C b/applications/test/HashTable2/Test-HashTable2.C similarity index 95% rename from applications/test/HashTable2/hashTableTest2.C rename to applications/test/HashTable2/Test-HashTable2.C index f1bfd70c04..468c3960a0 100644 --- a/applications/test/HashTable2/hashTableTest2.C +++ b/applications/test/HashTable2/Test-HashTable2.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,6 +22,7 @@ License along with OpenFOAM. If not, see . Description + Miscellaneous tests for HashTable \*---------------------------------------------------------------------------*/ diff --git a/applications/test/HashTable3/Make/files b/applications/test/HashTable3/Make/files index e8ec193ffa..67aef16a29 100644 --- a/applications/test/HashTable3/Make/files +++ b/applications/test/HashTable3/Make/files @@ -1,3 +1,3 @@ -hashTableTest3.C +Test-HashTable3.C -EXE = $(FOAM_USER_APPBIN)/hashTableTest3 +EXE = $(FOAM_USER_APPBIN)/Test-HashTable3 diff --git a/applications/test/HashTable3/hashTableTest3.C b/applications/test/HashTable3/Test-HashTable3.C similarity index 97% rename from applications/test/HashTable3/hashTableTest3.C rename to applications/test/HashTable3/Test-HashTable3.C index e295b861da..8931084ef2 100644 --- a/applications/test/HashTable3/hashTableTest3.C +++ b/applications/test/HashTable3/Test-HashTable3.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 @@ -22,7 +22,6 @@ License along with OpenFOAM. If not, see . Description - Test speeds for some HashTable operations \*---------------------------------------------------------------------------*/ diff --git a/applications/test/NamedEnum/Make/files b/applications/test/NamedEnum/Make/files index e861aaa1b2..755b72ba5e 100644 --- a/applications/test/NamedEnum/Make/files +++ b/applications/test/NamedEnum/Make/files @@ -1,3 +1,3 @@ Test-namedEnum.C -EXE = $(FOAM_USER_APPBIN)/NamedEnum +EXE = $(FOAM_USER_APPBIN)/Test-NamedEnum diff --git a/applications/test/dimensionedType/Make/files b/applications/test/dimensionedType/Make/files index 36a682e281..38f7d4ee8d 100644 --- a/applications/test/dimensionedType/Make/files +++ b/applications/test/dimensionedType/Make/files @@ -1,3 +1,3 @@ Test-dimensionedType.C -EXE = $(FOAM_USER_APPBIN)/dimensionedType +EXE = $(FOAM_USER_APPBIN)/Test-dimensionedType diff --git a/applications/test/pTraits/Make/files b/applications/test/pTraits/Make/files index 7cebcf09d9..268e879af2 100644 --- a/applications/test/pTraits/Make/files +++ b/applications/test/pTraits/Make/files @@ -1,2 +1,2 @@ Test-pTraits.C -EXE = $(FOAM_USER_APPBIN)/pTraits +EXE = $(FOAM_USER_APPBIN)/Test-pTraits diff --git a/applications/test/simpleMatrix/Make/files b/applications/test/simpleMatrix/Make/files index 2b80bbe4f7..804d3ecefe 100644 --- a/applications/test/simpleMatrix/Make/files +++ b/applications/test/simpleMatrix/Make/files @@ -1,3 +1,3 @@ Test-simpleMatrix.C -EXE = $(FOAM_USER_APPBIN)/simpleMatrix +EXE = $(FOAM_USER_APPBIN)/Test-simpleMatrix From fe8545958a06602aaa67aa854a8a375b611c79cd Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 24 Jan 2011 17:32:54 +0000 Subject: [PATCH 004/367] ENH: mapDistribute: extra printing --- .../meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C index 54d8690dee..25e7727c8e 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistribute.C @@ -222,7 +222,7 @@ void Foam::mapDistribute::printLayout(Ostream& os) const localSize = maxIndex[Pstream::myProcNo()]+1; } - os << "Layout:" << endl + os << "Layout: (constructSize:" << constructSize_ << ")" << endl << "local (processor " << Pstream::myProcNo() << "):" << endl << " start : 0" << endl << " size : " << localSize << endl; From 0ecf34e2f2640951fa533008fdf65ff4769bbbb1 Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 24 Jan 2011 17:33:19 +0000 Subject: [PATCH 005/367] BUG: volPointInterpolate.C: incorrect index --- .../interpolation/volPointInterpolation/volPointInterpolate.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C b/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C index d2841c9c54..5e7194dca8 100644 --- a/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C +++ b/src/finiteVolume/interpolation/volPointInterpolation/volPointInterpolate.C @@ -120,7 +120,7 @@ void volPointInterpolation::pushUntransformedData const labelList& slavePoints = slaves[i]; // Copy master data to slave slots - forAll(slaves, j) + forAll(slavePoints, j) { elems[slavePoints[j]] = elems[i]; } From be54c0266867ed70f58ff72a4e608f8d92f56caf Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 24 Jan 2011 17:34:01 +0000 Subject: [PATCH 006/367] STYLE: twoPhaseMixture: corrected comment --- .../incompressibleTwoPhaseMixture/twoPhaseMixture.H | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/transportModels/incompressible/incompressibleTwoPhaseMixture/twoPhaseMixture.H b/src/transportModels/incompressible/incompressibleTwoPhaseMixture/twoPhaseMixture.H index 13a7c47f88..732225f5e6 100644 --- a/src/transportModels/incompressible/incompressibleTwoPhaseMixture/twoPhaseMixture.H +++ b/src/transportModels/incompressible/incompressibleTwoPhaseMixture/twoPhaseMixture.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -146,7 +146,7 @@ public: return nu_; } - //- Return the face-interpolated dynamic laminar viscosity + //- Return the face-interpolated kinematic laminar viscosity tmp nuf() const; //- Correct the laminar viscosity From daf429d879bb0e40a1b6525d6fc393ad370b2de2 Mon Sep 17 00:00:00 2001 From: mattijs Date: Mon, 24 Jan 2011 17:59:00 +0000 Subject: [PATCH 007/367] BUG: mapDistributeTemplates.C : truncating before transformation applied --- .../mapPolyMesh/mapDistribute/mapDistributeTemplates.C | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C index 68e6cb7acb..f72b83dd45 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/mapDistributeTemplates.C @@ -966,8 +966,6 @@ void Foam::mapDistribute::reverseDistribute const bool dummyTransform ) const { - fld.setSize(constructSize); - if (dummyTransform) { applyDummyInverseTransforms(fld); @@ -1024,8 +1022,6 @@ void Foam::mapDistribute::reverseDistribute const bool dummyTransform ) const { - fld.setSize(constructSize); - if (dummyTransform) { applyDummyInverseTransforms(fld); From 4877156db8d43db2e0e8e30fd8bcf05f1fb76be1 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 25 Jan 2011 12:16:52 +0000 Subject: [PATCH 008/367] COMP: Allwmake : allow build-type argument to pass through into wmake --- src/Pstream/Allwmake | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Pstream/Allwmake b/src/Pstream/Allwmake index cc3329e384..ec3b07a859 100755 --- a/src/Pstream/Allwmake +++ b/src/Pstream/Allwmake @@ -2,7 +2,10 @@ cd ${0%/*} || exit 1 # run from this directory set -x -wmake libso dummy +makeOption=libso +[ $# -ge 1 ] && makeOption=$1 + +wmake $makeOption dummy case "$WM_MPLIB" in *MPI*) @@ -11,7 +14,7 @@ case "$WM_MPLIB" in echo "Note: ignore spurious warnings about missing mpicxx.h headers" set -x # force compilation into qualified directory - WM_OPTIONS=${WM_OPTIONS}$WM_MPLIB wmake libso mpi + WM_OPTIONS=${WM_OPTIONS}$WM_MPLIB wmake $makeOption mpi ;; #GAMMA) From 0124a3149b103a95f46506731e2fafacdd9c1be2 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 26 Jan 2011 11:08:16 +0100 Subject: [PATCH 009/367] COMP: avoid ambiguous construct from tmp --- src/turbulenceModels/compressible/LES/Smagorinsky/Smagorinsky.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/turbulenceModels/compressible/LES/Smagorinsky/Smagorinsky.C b/src/turbulenceModels/compressible/LES/Smagorinsky/Smagorinsky.C index 5196377197..12dae220d8 100644 --- a/src/turbulenceModels/compressible/LES/Smagorinsky/Smagorinsky.C +++ b/src/turbulenceModels/compressible/LES/Smagorinsky/Smagorinsky.C @@ -51,7 +51,7 @@ void Smagorinsky::updateSubGridScaleFields(const volTensorField& gradU) volScalarField b((2.0/3.0)*tr(D)); volScalarField c(2*ck_*delta()*(dev(D) && D)); - volScalarField k = sqr((-b + sqrt(sqr(b) + 4*a*c))/(2*a)); + volScalarField k(sqr((-b + sqrt(sqr(b) + 4*a*c))/(2*a))); muSgs_ = ck_*rho()*delta()*sqrt(k); muSgs_.correctBoundaryConditions(); From 232c13eef06905fc8f480c392a73d218a31bbad5 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 26 Jan 2011 11:11:48 +0100 Subject: [PATCH 010/367] BUG: update OpenFOAM version strings failed with compiler switch - now remove all generated files for all platforms when the version changes --- src/Allwmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Allwmake b/src/Allwmake index f3c4420474..53e6093053 100755 --- a/src/Allwmake +++ b/src/Allwmake @@ -17,13 +17,13 @@ wmakeCheckPwd "$WM_PROJECT_DIR/src" || { set -x # update OpenFOAM version strings if required -wmakePrintBuild -check || /bin/rm -f OpenFOAM/Make/$WM_OPTIONS/global.? 2>/dev/null +wmakePrintBuild -check || /bin/rm -f OpenFOAM/Make/*/global.? 2>/dev/null wmakeLnInclude OpenFOAM -wmakeLnInclude OSspecific/$WM_OSTYPE +wmakeLnInclude OSspecific/${WM_OSTYPE:-POSIX} Pstream/Allwmake -OSspecific/$WM_OSTYPE/Allwmake +OSspecific/${WM_OSTYPE:-POSIX}/Allwmake wmake libso OpenFOAM wmake libso fileFormats From e1fd499c30dd53ec8ba3b9706d26cdcbb04a5bdb Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 26 Jan 2011 12:15:46 +0000 Subject: [PATCH 011/367] ENH: sampledTriSurfaceMesh : only sample non-coupled faces --- .../sampledTriSurfaceMesh.C | 64 ++++++++++++++++++- .../sampledTriSurfaceMesh.H | 37 +++++++++-- 2 files changed, 95 insertions(+), 6 deletions(-) diff --git a/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C b/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C index 859db2f9af..3e3d56c6ed 100644 --- a/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C +++ b/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.C @@ -76,6 +76,63 @@ namespace Foam } +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +const Foam::indexedOctree& +Foam::sampledTriSurfaceMesh::nonCoupledboundaryTree() const +{ + // Variant of meshSearch::boundaryTree() that only does non-coupled + // boundary faces. + + if (!boundaryTreePtr_.valid()) + { + // all non-coupled boundary faces (not just walls) + const polyBoundaryMesh& patches = mesh().boundaryMesh(); + + labelList bndFaces(mesh().nFaces()-mesh().nInternalFaces()); + label bndI = 0; + forAll(patches, patchI) + { + const polyPatch& pp = patches[patchI]; + if (!pp.coupled()) + { + forAll(pp, i) + { + bndFaces[bndI++] = pp.start()+i; + } + } + } + bndFaces.setSize(bndI); + + + treeBoundBox overallBb(mesh().points()); + Random rndGen(123456); + overallBb = overallBb.extend(rndGen, 1E-4); + overallBb.min() -= point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + overallBb.max() += point(ROOTVSMALL, ROOTVSMALL, ROOTVSMALL); + + boundaryTreePtr_.reset + ( + new indexedOctree + ( + treeDataFace // all information needed to search faces + ( + false, // do not cache bb + mesh(), + bndFaces // boundary faces only + ), + overallBb, // overall search domain + 8, // maxLevel + 10, // leafsize + 3.0 // duplicity + ) + ); + } + + return boundaryTreePtr_(); +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::sampledTriSurfaceMesh::sampledTriSurfaceMesh @@ -159,6 +216,8 @@ bool Foam::sampledTriSurfaceMesh::expire() sampledSurface::clearGeom(); MeshStorage::clear(); + + boundaryTreePtr_.clear(); sampleElements_.clear(); samplePoints_.clear(); @@ -224,7 +283,10 @@ bool Foam::sampledTriSurfaceMesh::update() { // Search for nearest boundaryFace - const indexedOctree& bTree = meshSearcher.boundaryTree(); + ////- Search on all (including coupled) boundary faces + //const indexedOctree& bTree = meshSearcher.boundaryTree() + //- Search on all non-coupled boundary faces + const indexedOctree& bTree = nonCoupledboundaryTree(); forAll(fc, triI) { diff --git a/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.H b/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.H index 20426e576b..c54bf28dc0 100644 --- a/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.H +++ b/src/sampling/sampledSurface/sampledTriSurfaceMesh/sampledTriSurfaceMesh.H @@ -28,12 +28,31 @@ Description A sampledSurface from a triSurfaceMesh. It samples on the points/triangles of the triSurface. - It samples using the cell nearest to the triangle centre so does - not check the cell the centre is actually in ... + - it either samples cells or (non-coupled) boundary faces - In parallel every processor just operates on the part of the surface - where the face centres are inside the mesh. It is then up to the - caller to stitch the partial surfaces together. + - 4 different modes: + - source=cells, interpolate=false: + finds per triangle centre the nearest cell centre and uses its value + - source=cells, interpolate=true + finds per triangle centre the nearest cell centre. + Per surface point checks if this nearest cell is the one containing + point; otherwise projects the point onto the nearest point on + the boundary of the cell (to make sure interpolateCellPoint + gets a valid location) + + - source=boundaryFaces, interpolate=false: + finds per triangle centre the nearest point on the boundary + (uncoupled faces only) and uses the value (or 0 if the nearest + is on an empty boundary) + - source=boundaryFaces, interpolate=true: + finds per triangle centre the nearest point on the boundary + (uncoupled faces only). + Per surface point projects the point onto this boundary face + (to make sure interpolateCellPoint gets a valid location) + + - since it finds a nearest per triangle each triangle is guaranteed + to be on one processor only. So after stitching (by sampledSurfaces) + the original surface should be complete. SourceFiles sampledTriSurfaceMesh.C @@ -52,6 +71,8 @@ SourceFiles namespace Foam { +class treeDataFace; + /*---------------------------------------------------------------------------*\ Class sampledTriSurfaceMesh Declaration \*---------------------------------------------------------------------------*/ @@ -88,6 +109,9 @@ private: //- Track if the surface needs an update mutable bool needsUpdate_; + //- Search tree for all non-coupled boundary faces + mutable autoPtr > boundaryTreePtr_; + //- From local surface triangle to mesh cell/face. labelList sampleElements_; @@ -97,6 +121,9 @@ private: // Private Member Functions + //- Get tree of all non-coupled boundary faces + const indexedOctree& nonCoupledboundaryTree() const; + //- sample field on faces template tmp > sampleField From 51df389de63052d27766682bb5cf53b18b964082 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 26 Jan 2011 13:36:37 +0100 Subject: [PATCH 012/367] ENH: rework surface writers as non-templated classes - easier (more logical) when adding a new writer ENH: add surface field writer for 'starcd' format - creates *.usr files, which can be read in proSTAR with the 'getuser' command, but which can also be parsed directly since the format is extremely primitive --- src/sampling/Make/files | 16 +- .../sampledSurfaces/sampledSurfaces.C | 17 +- .../sampledSurfaces/sampledSurfaces.H | 45 +- .../sampledSurfacesTemplates.C | 21 +- .../writers/dx/dxSurfaceWriter.C | 141 +++-- .../writers/dx/dxSurfaceWriter.H | 103 +++- .../writers/dx/dxSurfaceWriterRunTime.C | 43 -- .../writers/ensight/ensightSurfaceWriter.C | 200 ++++--- .../writers/ensight/ensightSurfaceWriter.H | 119 +++- .../ensight/ensightSurfaceWriterRunTime.C | 44 -- .../writers/foamFile/foamFileSurfaceWriter.C | 127 ++-- .../writers/foamFile/foamFileSurfaceWriter.H | 105 +++- .../foamFile/foamFileSurfaceWriterRunTime.C | 44 -- .../writers/makeSurfaceWriterMethods.H | 92 +++ .../writers/null/nullSurfaceWriter.C | 63 -- .../writers/null/nullSurfaceWriter.H | 103 ---- .../writers/null/nullSurfaceWriterRunTime.C | 44 -- .../writers/proxy/proxySurfaceWriter.C | 34 +- .../writers/proxy/proxySurfaceWriter.H | 38 +- .../writers/proxy/proxySurfaceWriterRunTime.C | 45 -- .../writers/raw/rawSurfaceWriter.C | 540 ++++++++---------- .../writers/raw/rawSurfaceWriter.H | 158 ++--- .../writers/raw/rawSurfaceWriterRunTime.C | 44 -- .../writers/starcd/starcdSurfaceWriter.C | 172 ++++++ .../writers/starcd/starcdSurfaceWriter.H | 181 ++++++ .../sampledSurface/writers/surfaceWriter.C | 60 +- .../sampledSurface/writers/surfaceWriter.H | 98 +++- .../sampledSurface/writers/surfaceWriters.C | 50 -- .../sampledSurface/writers/surfaceWriters.H | 76 --- .../writers/vtk/vtkSurfaceWriter.C | 167 +++--- .../writers/vtk/vtkSurfaceWriter.H | 103 +++- .../writers/vtk/vtkSurfaceWriterRunTime.C | 44 -- 32 files changed, 1594 insertions(+), 1543 deletions(-) delete mode 100644 src/sampling/sampledSurface/writers/dx/dxSurfaceWriterRunTime.C delete mode 100644 src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriterRunTime.C delete mode 100644 src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriterRunTime.C create mode 100644 src/sampling/sampledSurface/writers/makeSurfaceWriterMethods.H delete mode 100644 src/sampling/sampledSurface/writers/null/nullSurfaceWriter.C delete mode 100644 src/sampling/sampledSurface/writers/null/nullSurfaceWriter.H delete mode 100644 src/sampling/sampledSurface/writers/null/nullSurfaceWriterRunTime.C delete mode 100644 src/sampling/sampledSurface/writers/proxy/proxySurfaceWriterRunTime.C delete mode 100644 src/sampling/sampledSurface/writers/raw/rawSurfaceWriterRunTime.C create mode 100644 src/sampling/sampledSurface/writers/starcd/starcdSurfaceWriter.C create mode 100644 src/sampling/sampledSurface/writers/starcd/starcdSurfaceWriter.H delete mode 100644 src/sampling/sampledSurface/writers/surfaceWriters.C delete mode 100644 src/sampling/sampledSurface/writers/surfaceWriters.H delete mode 100644 src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriterRunTime.C diff --git a/src/sampling/Make/files b/src/sampling/Make/files index 3c61e371b6..c9b26376d0 100644 --- a/src/sampling/Make/files +++ b/src/sampling/Make/files @@ -46,14 +46,14 @@ sampledSurface/thresholdCellFaces/sampledThresholdCellFaces.C surfWriters = sampledSurface/writers -$(surfWriters)/surfaceWriters.C -$(surfWriters)/dx/dxSurfaceWriterRunTime.C -$(surfWriters)/ensight/ensightSurfaceWriterRunTime.C -$(surfWriters)/foamFile/foamFileSurfaceWriterRunTime.C -$(surfWriters)/null/nullSurfaceWriterRunTime.C -$(surfWriters)/proxy/proxySurfaceWriterRunTime.C -$(surfWriters)/raw/rawSurfaceWriterRunTime.C -$(surfWriters)/vtk/vtkSurfaceWriterRunTime.C +$(surfWriters)/surfaceWriter.C +$(surfWriters)/dx/dxSurfaceWriter.C +$(surfWriters)/ensight/ensightSurfaceWriter.C +$(surfWriters)/foamFile/foamFileSurfaceWriter.C +$(surfWriters)/proxy/proxySurfaceWriter.C +$(surfWriters)/raw/rawSurfaceWriter.C +$(surfWriters)/starcd/starcdSurfaceWriter.C +$(surfWriters)/vtk/vtkSurfaceWriter.C graphField/writePatchGraph.C graphField/writeCellGraph.C diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C index 06b3278489..e44e1f8a46 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.C +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.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 @@ -83,7 +83,7 @@ void Foam::sampledSurfaces::writeGeometry() const { if (Pstream::master() && mergeList_[surfI].faces.size()) { - genericFormatter_->write + formatter_->write ( outputDir, s.name(), @@ -94,7 +94,7 @@ void Foam::sampledSurfaces::writeGeometry() const } else if (s.faces().size()) { - genericFormatter_->write + formatter_->write ( outputDir, s.name(), @@ -123,9 +123,8 @@ Foam::sampledSurfaces::sampledSurfaces outputPath_(fileName::null), fieldSelection_(), interpolationScheme_(word::null), - writeFormat_(word::null), mergeList_(), - genericFormatter_(NULL), + formatter_(NULL), scalarFields_(), vectorFields_(), sphericalTensorFields_(), @@ -201,7 +200,7 @@ void Foam::sampledSurfaces::write() // write geometry first if required, // or when no fields would otherwise be written - if (nFields == 0 || genericFormatter_->separateFiles()) + if (nFields == 0 || formatter_->separateGeometry()) { writeGeometry(); } @@ -221,11 +220,11 @@ void Foam::sampledSurfaces::read(const dictionary& dict) clearFieldGroups(); dict.lookup("interpolationScheme") >> interpolationScheme_; - dict.lookup("surfaceFormat") >> writeFormat_; - // define the generic (geometry) writer - genericFormatter_ = surfaceWriter::New(writeFormat_); + word writeFormat(dict.lookup("surfaceFormat")); + // define the surface formatter + formatter_ = surfaceWriter::New(writeFormat); PtrList newList ( diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H index 0c2084507a..4293cf9e62 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.H +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfaces.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 @@ -68,36 +68,11 @@ class sampledSurfaces { public: - //- The surface formatter - autoPtr< surfaceWriter > formatter; - //- Construct null fieldGroup() : - DynamicList(0), - formatter(NULL) + DynamicList(0) {} - - //- Construct for a particular surface format - fieldGroup(const word& writeFormat) - : - DynamicList(0), - formatter(surfaceWriter::New(writeFormat)) - {} - - //- Reset format and field list - void clear() - { - DynamicList::clear(); - formatter.clear(); - } - - //- Assign a new formatter - void operator=(const word& writeFormat) - { - formatter = surfaceWriter::New(writeFormat); - } - }; @@ -151,10 +126,6 @@ class sampledSurfaces //- Interpolation scheme to use word interpolationScheme_; - //- Output format to use - word writeFormat_; - - // surfaces //- Information for merging surfaces @@ -163,8 +134,8 @@ class sampledSurfaces // Calculated - //- Generic surface formatter - autoPtr< surfaceWriter > genericFormatter_; + //- Surface formatter + autoPtr formatter_; //- Categorized scalar/vector/tensor fields fieldGroup scalarFields_; @@ -190,14 +161,10 @@ class sampledSurfaces //- Sample and write a particular volume field template - void sampleAndWrite - ( - const GeometricField&, - const surfaceWriter& formatter - ); + void sampleAndWrite(const GeometricField&); //- Sample and write all the fields of the given type - template + template void sampleAndWrite(fieldGroup&); //- Disallow default bitwise copy construct and assignment diff --git a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C index 578212ba3f..1351821419 100644 --- a/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C +++ b/src/sampling/sampledSurface/sampledSurfaces/sampledSurfacesTemplates.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -32,8 +32,7 @@ License template void Foam::sampledSurfaces::sampleAndWrite ( - const GeometricField& vField, - const surfaceWriter& formatter + const GeometricField& vField ) { // interpolator for this field @@ -96,7 +95,7 @@ void Foam::sampledSurfaces::sampleAndWrite // skip surface without faces (eg, a failed cut-plane) if (mergeList_[surfI].faces.size()) { - formatter.write + formatter_->write ( outputDir, s.name(), @@ -115,7 +114,7 @@ void Foam::sampledSurfaces::sampleAndWrite // skip surface without faces (eg, a failed cut-plane) if (s.faces().size()) { - formatter.write + formatter_->write ( outputDir, s.name(), @@ -139,12 +138,6 @@ void Foam::sampledSurfaces::sampleAndWrite { if (fields.size()) { - // create or use existing surfaceWriter - if (fields.formatter.empty()) - { - fields.formatter = surfaceWriter::New(writeFormat_); - } - forAll(fields, fieldI) { if (Pstream::master() && verbose_) @@ -168,8 +161,7 @@ void Foam::sampledSurfaces::sampleAndWrite false ), mesh_ - ), - fields.formatter() + ) ); } else @@ -190,8 +182,7 @@ void Foam::sampledSurfaces::sampleAndWrite > ( fields[fieldI] - ), - fields.formatter() + ) ); } } diff --git a/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.C b/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.C index 6bdb3e63e9..3d477daf9a 100644 --- a/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.C +++ b/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.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,10 +28,19 @@ License #include "OFstream.H" #include "OSspecific.H" +#include "makeSurfaceWriterMethods.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + makeSurfaceWriterType(dxSurfaceWriter); +} + + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -template -void Foam::dxSurfaceWriter::writeGeometry +void Foam::dxSurfaceWriter::writeGeometry ( Ostream& os, const pointField& points, @@ -54,7 +63,6 @@ void Foam::dxSurfaceWriter::writeGeometry os << nl; // Write triangles - os << "# The irregular connections (triangles)" << nl << "object 2 class array type int rank 1 shape 3 items " << faces.size() << " data follows" << nl; @@ -80,17 +88,41 @@ void Foam::dxSurfaceWriter::writeGeometry } +void Foam::dxSurfaceWriter::writeTrailer(Ostream& os, const bool isNodeValues) +{ + if (isNodeValues) + { + os << nl << "attribute \"dep\" string \"positions\"" + << nl << nl; + } + else + { + os << nl << "attribute \"dep\" string \"connections\"" + << nl << nl; + } + + os << "# the field, with three components: \"positions\"," + << " \"connections\", and \"data\"" << nl + << "object \"irregular positions irregular " + << "connections\" class field" + << nl + << "component \"positions\" value 1" << nl + << "component \"connections\" value 2" << nl + << "component \"data\" value 3" << nl; + + os << "end" << endl; +} + + namespace Foam { - // Write scalarField in DX format template<> - void Foam::dxSurfaceWriter::writeData + void Foam::dxSurfaceWriter::writeData ( Ostream& os, const Field& values ) { - // Write data os << "object 3 class array type float rank 0 items " << values.size() << " data follows" << nl; @@ -101,15 +133,13 @@ namespace Foam } - // Write vectorField in DX format template<> - void Foam::dxSurfaceWriter::writeData + void Foam::dxSurfaceWriter::writeData ( Ostream& os, const Field& values ) { - // Write data os << "object 3 class array type float rank 1 shape 3 items " << values.size() << " data follows" << nl; @@ -122,15 +152,13 @@ namespace Foam } - // Write sphericalTensorField in DX format template<> - void Foam::dxSurfaceWriter::writeData + void Foam::dxSurfaceWriter::writeData ( Ostream& os, const Field& values ) { - // Write data os << "object 3 class array type float rank 0 items " << values.size() << " data follows" << nl; @@ -141,15 +169,13 @@ namespace Foam } - // Write symmTensorField in DX format template<> - void Foam::dxSurfaceWriter::writeData + void Foam::dxSurfaceWriter::writeData ( Ostream& os, const Field& values ) { - // Write data os << "object 3 class array type float rank 2 shape 3 items " << values.size() << " data follows" << nl; @@ -165,15 +191,14 @@ namespace Foam } - // Write tensorField in DX format + // Write Field in DX format template<> - void Foam::dxSurfaceWriter::writeData + inline void Foam::dxSurfaceWriter::writeData ( Ostream& os, const Field& values ) { - // Write data os << "object 3 class array type float rank 2 shape 3 items " << values.size() << " data follows" << nl; @@ -189,15 +214,15 @@ namespace Foam } } -// Write tensorField in DX format + +// arbitrary field template -void Foam::dxSurfaceWriter::writeData +inline void Foam::dxSurfaceWriter::writeData ( Ostream& os, const Field& values ) { - // Write data os << "object 3 class array type float rank 0 items " << values.size() << " data follows" << nl; @@ -208,41 +233,8 @@ void Foam::dxSurfaceWriter::writeData } -// Write trailer in DX format template -void Foam::dxSurfaceWriter::writeTrailer(Ostream& os) -{ - os << "# the field, with three components: \"positions\"," - << " \"connections\", and \"data\"" << nl - << "object \"irregular positions irregular " - << "connections\" class field" - << nl - << "component \"positions\" value 1" << nl - << "component \"connections\" value 2" << nl - << "component \"data\" value 3" << nl; -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -template -Foam::dxSurfaceWriter::dxSurfaceWriter() -: - surfaceWriter() -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -template -Foam::dxSurfaceWriter::~dxSurfaceWriter() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -void Foam::dxSurfaceWriter::write +void Foam::dxSurfaceWriter::writeTemplate ( const fileName& outputDir, const fileName& surfaceName, @@ -270,24 +262,29 @@ void Foam::dxSurfaceWriter::write } writeGeometry(os, points, faces); - writeData(os, values); - - if (isNodeValues) - { - os << nl << "attribute \"dep\" string \"positions\"" - << nl << nl; - } - else - { - os << nl << "attribute \"dep\" string \"connections\"" - << nl << nl; - } - - writeTrailer(os); - - os << "end" << nl; + writeTrailer(os, isNodeValues); } +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::dxSurfaceWriter::dxSurfaceWriter() +: + surfaceWriter() +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::dxSurfaceWriter::~dxSurfaceWriter() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +// create write methods +defineSurfaceWriterWriteFields(Foam::dxSurfaceWriter); + + // ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.H b/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.H index feccf33be1..e4e3af67e6 100644 --- a/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/dx/dxSurfaceWriter.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,6 +25,7 @@ Class Foam::dxSurfaceWriter Description + A surfaceWriter for OpenDX format. SourceFiles dxSurfaceWriter.C @@ -42,22 +43,36 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class dxSurfaceWriter Declaration + Class dxSurfaceWriter Declaration \*---------------------------------------------------------------------------*/ -template class dxSurfaceWriter : - public surfaceWriter + public surfaceWriter { // Private Member Functions static void writeGeometry(Ostream&, const pointField&, const faceList&); + static void writeTrailer(Ostream&, const bool isNodeValues); - static void writeData(Ostream&, const Field& values); + template + static void writeData(Ostream&, const Field&); + + //- Templated write operation + template + void writeTemplate + ( + const fileName& outputDir, + const fileName& surfaceName, + const pointField& points, + const faceList& faces, + const word& fieldName, + const Field& values, + const bool isNodeValues, + const bool verbose + ) const; - static void writeTrailer(Ostream&); public: @@ -77,20 +92,76 @@ public: // Member Functions - // Write - - //- Writes single surface to file. + //- Write scalarField for a single surface to file. + // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, - const fileName& surfaceName, + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, - const word& fieldName, - const Field& values, + const word& fieldName, // name of field + const Field& values, const bool isNodeValues, const bool verbose = false ) const; + + //- Write vectorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write sphericalTensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write symmTensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write tensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + }; @@ -100,12 +171,6 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#ifdef NoRepository -# include "dxSurfaceWriter.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/dx/dxSurfaceWriterRunTime.C b/src/sampling/sampledSurface/writers/dx/dxSurfaceWriterRunTime.C deleted file mode 100644 index a53ba0f34f..0000000000 --- a/src/sampling/sampledSurface/writers/dx/dxSurfaceWriterRunTime.C +++ /dev/null @@ -1,43 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 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 "dxSurfaceWriter.H" -#include "surfaceWriters.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -makeSurfaceWriters(dxSurfaceWriter); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.C b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.C index cde2d597a8..d705525ebc 100644 --- a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.C +++ b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.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 @@ -31,6 +31,16 @@ License #include "ensightGeoFile.H" #include "ensightPartNonMeshFaces.H" +#include "makeSurfaceWriterMethods.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + makeSurfaceWriterType(ensightSurfaceWriter); +} + + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // namespace Foam @@ -38,30 +48,15 @@ namespace Foam // Write scalarField in ensight format template<> - void Foam::ensightSurfaceWriter::writeData + inline void Foam::ensightSurfaceWriter::writeData ( Ostream& os, - const Field& values + const Field& values ) { forAll(values, i) { - os << values[i] << nl; - } - } - - - // Write booField in ensight format - template<> - void Foam::ensightSurfaceWriter::writeData - ( - Ostream& os, - const Field& values - ) - { - forAll(values, i) - { - os << values[i] << nl; + os << values[i] << nl; } } } @@ -69,96 +64,25 @@ namespace Foam // Write generic field in ensight format template -void Foam::ensightSurfaceWriter::writeData +inline void Foam::ensightSurfaceWriter::writeData ( Ostream& os, const Field& values ) { - for (direction cmpt = 0; cmpt < vector::nComponents; cmpt++) + for (direction cmpt = 0; cmpt < vector::nComponents; ++cmpt) { scalarField v(values.component(cmpt)); forAll(v, i) { - os << v[i] << nl; + os << v[i] << nl; } } } -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -// Construct from components template -Foam::ensightSurfaceWriter::ensightSurfaceWriter() -: - surfaceWriter() -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -template -Foam::ensightSurfaceWriter::~ensightSurfaceWriter() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -void Foam::ensightSurfaceWriter::write -( - const fileName& outputDir, - const fileName& surfaceName, - const pointField& points, - const faceList& faces, - const bool verbose -) const -{ - if (!isDir(outputDir)) - { - mkDir(outputDir); - } - - //const scalar timeValue = Foam::name(this->mesh().time().timeValue()); - const scalar timeValue = 0.0; - - - OFstream caseStr(outputDir/surfaceName + ".case"); - ensightGeoFile geomStr - ( - outputDir/surfaceName + ".000.mesh", - IOstream::ASCII - ); - - if (verbose) - { - Info<< "Writing case file to " << caseStr.name() << endl; - } - - caseStr - << "FORMAT" << nl - << "type: ensight gold" << nl - << nl - << "GEOMETRY" << nl - << "model: 1 " << geomStr.name().name() << nl - << nl - << "TIME" << nl - << "time set: 1" << nl - << "number of steps: 1" << nl - << "filename start number: 0" << nl - << "filename increment: 1" << nl - << "time values:" << nl - << timeValue << nl - << nl; - - ensightPartNonMeshFaces faceWriter(0, geomStr.name().name(), faces, points); - faceWriter.writeGeometry(geomStr); -} - - -template -void Foam::ensightSurfaceWriter::write +void Foam::ensightSurfaceWriter::writeTemplate ( const fileName& outputDir, const fileName& surfaceName, @@ -175,10 +99,9 @@ void Foam::ensightSurfaceWriter::write mkDir(outputDir/fieldName); } - //const scalar timeValue = Foam::name(this->mesh().time().timeValue()); + // const scalar timeValue = Foam::name(this->mesh().time().timeValue()); const scalar timeValue = 0.0; - OFstream caseStr(outputDir/fieldName/surfaceName + ".case"); ensightGeoFile geomStr ( @@ -230,8 +153,8 @@ void Foam::ensightSurfaceWriter::write << timeValue << nl << nl; - ensightPartNonMeshFaces faceWriter(0, geomStr.name().name(), faces, points); - faceWriter.writeGeometry(geomStr); + ensightPartNonMeshFaces ensPart(0, geomStr.name().name(), faces, points); + geomStr << ensPart; // Write field fieldStr @@ -246,19 +169,19 @@ void Foam::ensightSurfaceWriter::write } else { - //faceWriter.writeField(fieldStr, values); - forAll(faceWriter.elementTypes(), elemI) + // ensPart.writeField(fieldStr, values); + forAll(ensPart.elementTypes(), elemI) { - if (faceWriter.elemLists()[elemI].size()) + if (ensPart.elemLists()[elemI].size()) { - fieldStr.writeKeyword(faceWriter.elementTypes()[elemI]); + fieldStr.writeKeyword(ensPart.elementTypes()[elemI]); writeData ( fieldStr, Field ( values, - faceWriter.elemLists()[elemI] + ensPart.elemLists()[elemI] ) ); } @@ -267,4 +190,75 @@ void Foam::ensightSurfaceWriter::write } +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::ensightSurfaceWriter::ensightSurfaceWriter() +: + surfaceWriter() +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::ensightSurfaceWriter::~ensightSurfaceWriter() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::ensightSurfaceWriter::write +( + const fileName& outputDir, + const fileName& surfaceName, + const pointField& points, + const faceList& faces, + const bool verbose +) const +{ + if (!isDir(outputDir)) + { + mkDir(outputDir); + } + + //const scalar timeValue = Foam::name(this->mesh().time().timeValue()); + const scalar timeValue = 0.0; + + + OFstream caseStr(outputDir/surfaceName + ".case"); + ensightGeoFile geomStr + ( + outputDir/surfaceName + ".000.mesh", + IOstream::ASCII + ); + + if (verbose) + { + Info<< "Writing case file to " << caseStr.name() << endl; + } + + caseStr + << "FORMAT" << nl + << "type: ensight gold" << nl + << nl + << "GEOMETRY" << nl + << "model: 1 " << geomStr.name().name() << nl + << nl + << "TIME" << nl + << "time set: 1" << nl + << "number of steps: 1" << nl + << "filename start number: 0" << nl + << "filename increment: 1" << nl + << "time values:" << nl + << timeValue << nl + << nl; + + ensightPartNonMeshFaces ensPart(0, geomStr.name().name(), faces, points); + geomStr << ensPart; +} + + +// create write methods +defineSurfaceWriterWriteFields(Foam::ensightSurfaceWriter); + + // ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.H b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.H index d2f01c6479..4d2bf47b90 100644 --- a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.H @@ -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 @@ -25,6 +25,7 @@ Class Foam::ensightSurfaceWriter Description + A surfaceWriter for Ensight format. SourceFiles ensightSurfaceWriter.C @@ -41,29 +42,41 @@ SourceFiles namespace Foam { -class ensightGeoFile; - /*---------------------------------------------------------------------------*\ Class ensightSurfaceWriter Declaration \*---------------------------------------------------------------------------*/ -template class ensightSurfaceWriter : - public surfaceWriter + public surfaceWriter { // Private data - fileName caseFileName_; - fileName surfaceName_; - fileName geomName_; - DynamicList varNames_; - DynamicList varFileNames_; +// fileName caseFileName_; +// fileName surfaceName_; +// fileName geomName_; +// DynamicList varNames_; +// DynamicList varFileNames_; // Private Member Functions - static void writeData(Ostream&, const Field& values); + template + static inline void writeData(Ostream&, const Field&); + + //- Templated write operation + template + void writeTemplate + ( + const fileName& outputDir, + const fileName& surfaceName, + const pointField& points, + const faceList& faces, + const word& fieldName, + const Field& values, + const bool isNodeValues, + const bool verbose + ) const; public: @@ -84,9 +97,15 @@ public: // Member Functions - // Write + //- True if the surface format supports geometry in a separate file. + // False if geometry and field must be in a single file + virtual bool separateGeometry() + { + return true; + } - //- Write geometry to file. + + //- Write single surface geometry to file. virtual void write ( const fileName& outputDir, @@ -97,18 +116,76 @@ public: ) const; - //- Writes single surface to file. + //- Write scalarField for a single surface to file. + // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, - const fileName& surfaceName, + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, - const word& fieldName, - const Field& values, + const word& fieldName, // name of field + const Field& values, const bool isNodeValues, const bool verbose = false ) const; + + //- Write vectorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write sphericalTensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write symmTensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write tensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + }; @@ -118,12 +195,6 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#ifdef NoRepository -# include "ensightSurfaceWriter.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriterRunTime.C b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriterRunTime.C deleted file mode 100644 index 8355a6d991..0000000000 --- a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriterRunTime.C +++ /dev/null @@ -1,44 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2010-2010 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 "ensightSurfaceWriter.H" -#include "surfaceWriters.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -makeSurfaceWriterType(ensightSurfaceWriter, bool); -makeSurfaceWriters(ensightSurfaceWriter); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.C b/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.C index 747a79f39a..06005b5c0a 100644 --- a/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.C +++ b/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.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) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -28,67 +28,20 @@ License #include "OFstream.H" #include "OSspecific.H" -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +#include "makeSurfaceWriterMethods.H" -template -Foam::foamFileSurfaceWriter::foamFileSurfaceWriter() -: - surfaceWriter() -{} +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -template -Foam::foamFileSurfaceWriter::~foamFileSurfaceWriter() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -void Foam::foamFileSurfaceWriter::write -( - const fileName& outputDir, - const fileName& surfaceName, - const pointField& points, - const faceList& faces, - const bool verbose -) const +namespace Foam { - fileName surfaceDir(outputDir/surfaceName); - - if (!isDir(surfaceDir)) - { - mkDir(surfaceDir); - } - - if (verbose) - { - Info<< "Writing geometry to " << surfaceDir << endl; - } - - // Points - OFstream(surfaceDir/"points")() << points; - - // Faces - OFstream(surfaceDir/"faces")() << faces; - - // Face centers. Not really necessary but very handy when reusing as inputs - // for e.g. timeVaryingMapped bc. - pointField faceCentres(faces.size(),point::zero); - - forAll (faces, faceI) - { - faceCentres[faceI] = faces[faceI].centre(points); - } - - OFstream(surfaceDir/"faceCentres")() << faceCentres; + makeSurfaceWriterType(foamFileSurfaceWriter); } +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + template -void Foam::foamFileSurfaceWriter::write +void Foam::foamFileSurfaceWriter::writeTemplate ( const fileName& outputDir, const fileName& surfaceName, @@ -113,7 +66,6 @@ void Foam::foamFileSurfaceWriter::write } // geometry should already have been written - // Values to separate directory (e.g. "scalarField/p") fileName foamName(pTraits::typeName); @@ -125,8 +77,69 @@ void Foam::foamFileSurfaceWriter::write } // values - OFstream(valuesDir/fieldName)() << values; + OFstream(valuesDir/fieldName)() << values; } +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::foamFileSurfaceWriter::foamFileSurfaceWriter() +: + surfaceWriter() +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::foamFileSurfaceWriter::~foamFileSurfaceWriter() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::foamFileSurfaceWriter::write +( + const fileName& outputDir, + const fileName& surfaceName, + const pointField& points, + const faceList& faces, + const bool verbose +) const +{ + fileName surfaceDir(outputDir/surfaceName); + + if (!isDir(surfaceDir)) + { + mkDir(surfaceDir); + } + + if (verbose) + { + Info<< "Writing geometry to " << surfaceDir << endl; + } + + + // Points + OFstream(surfaceDir/"points")() << points; + + // Faces + OFstream(surfaceDir/"faces")() << faces; + + // Face centers. Not really necessary but very handy when reusing as inputs + // for e.g. timeVaryingMapped bc. + pointField faceCentres(faces.size(),point::zero); + + forAll(faces, faceI) + { + faceCentres[faceI] = faces[faceI].centre(points); + } + + OFstream(surfaceDir/"faceCentres")() << faceCentres; +} + + +// create write methods +defineSurfaceWriterWriteFields(Foam::foamFileSurfaceWriter); + + // ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.H b/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.H index 0076abdc88..ce19c21455 100644 --- a/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriter.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) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -43,14 +43,29 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class foamFileSurfaceWriter Declaration + Class foamFileSurfaceWriter Declaration \*---------------------------------------------------------------------------*/ -template class foamFileSurfaceWriter : - public surfaceWriter + public surfaceWriter { + // Private Member Functions + + //- Templated write operation + template + void writeTemplate + ( + const fileName& outputDir, + const fileName& surfaceName, + const pointField& points, + const faceList& faces, + const word& fieldName, + const Field& values, + const bool isNodeValues, + const bool verbose + ) const; + public: @@ -70,13 +85,14 @@ public: // Member Functions - //- Return true if the surface format supports separate files - virtual bool separateFiles() + //- True if the surface format supports geometry in a separate file. + // False if geometry and field must be in a single file + virtual bool separateGeometry() { return true; } - //- Write geometry to file. + //- Write single surface geometry to file. virtual void write ( const fileName& outputDir, @@ -86,18 +102,77 @@ public: const bool verbose = false ) const; - //- Writes single surface to file. + + //- Write scalarField for a single surface to file. + // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, - const fileName& surfaceName, + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, - const word& fieldName, - const Field& values, + const word& fieldName, // name of field + const Field& values, const bool isNodeValues, const bool verbose = false ) const; + + //- Write vectorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write sphericalTensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write symmTensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write tensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + }; @@ -107,12 +182,6 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#ifdef NoRepository -# include "foamFileSurfaceWriter.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriterRunTime.C b/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriterRunTime.C deleted file mode 100644 index c8a40e736c..0000000000 --- a/src/sampling/sampledSurface/writers/foamFile/foamFileSurfaceWriterRunTime.C +++ /dev/null @@ -1,44 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 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 "foamFileSurfaceWriter.H" -#include "surfaceWriters.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -makeSurfaceWriterType(foamFileSurfaceWriter, bool); -makeSurfaceWriters(foamFileSurfaceWriter); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/makeSurfaceWriterMethods.H b/src/sampling/sampledSurface/writers/makeSurfaceWriterMethods.H new file mode 100644 index 0000000000..b748a32c6c --- /dev/null +++ b/src/sampling/sampledSurface/writers/makeSurfaceWriterMethods.H @@ -0,0 +1,92 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 . + +InClass + Foam::makeSurfaceWriterMethods + +Description + Convenience macros for instantiating writer methods for surfaceWriter + classes. + +\*---------------------------------------------------------------------------*/ + +#ifndef makeSurfaceWriterMethods_H +#define makeSurfaceWriterMethods_H + +#include "surfaceWriter.H" +#include "addToRunTimeSelectionTable.H" + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#define makeSurfaceWriterType(ThisClass) \ + defineTypeNameAndDebug(ThisClass, 0); \ + addToRunTimeSelectionTable(surfaceWriter, ThisClass, word) + + +#define defineSurfaceWriterWriteField(ThisClass, FieldType) \ + void ThisClass::write \ + ( \ + const fileName& outputDir, \ + const fileName& surfaceName, \ + const pointField& points, \ + const faceList& faces, \ + const word& fieldName, \ + const Field& values, \ + const bool isNodeValues, \ + const bool verbose \ + ) const \ + { \ + writeTemplate \ + ( \ + outputDir, \ + surfaceName, \ + points, \ + faces, \ + fieldName, \ + values, \ + isNodeValues, \ + verbose \ + ); \ + } + + +#define defineSurfaceWriterWriteFields(ThisClass) \ + defineSurfaceWriterWriteField(ThisClass, scalar); \ + defineSurfaceWriterWriteField(ThisClass, vector); \ + defineSurfaceWriterWriteField(ThisClass, sphericalTensor); \ + defineSurfaceWriterWriteField(ThisClass, symmTensor); \ + defineSurfaceWriterWriteField(ThisClass, tensor) + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/null/nullSurfaceWriter.C b/src/sampling/sampledSurface/writers/null/nullSurfaceWriter.C deleted file mode 100644 index 85d4fcbb62..0000000000 --- a/src/sampling/sampledSurface/writers/null/nullSurfaceWriter.C +++ /dev/null @@ -1,63 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 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 "nullSurfaceWriter.H" - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -template -Foam::nullSurfaceWriter::nullSurfaceWriter() -: - surfaceWriter() -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -template -Foam::nullSurfaceWriter::~nullSurfaceWriter() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -void Foam::nullSurfaceWriter::write -( - const fileName& outputDir, - const fileName& surfaceName, - const pointField& points, - const faceList& faces, - const word& fieldName, - const Field& values, - const bool isNodeValues, - const bool verbose -) const -{} - - -// ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/null/nullSurfaceWriter.H b/src/sampling/sampledSurface/writers/null/nullSurfaceWriter.H deleted file mode 100644 index aef12a76ce..0000000000 --- a/src/sampling/sampledSurface/writers/null/nullSurfaceWriter.H +++ /dev/null @@ -1,103 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Class - Foam::nullSurfaceWriter - -Description - -SourceFiles - nullSurfaceWriter.C - -\*---------------------------------------------------------------------------*/ - -#ifndef nullSurfaceWriter_H -#define nullSurfaceWriter_H - -#include "surfaceWriter.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class nullSurfaceWriter Declaration -\*---------------------------------------------------------------------------*/ - -template -class nullSurfaceWriter -: - public surfaceWriter -{ - -public: - - //- Runtime type information - TypeName("null"); - - - // Constructors - - //- Construct null - nullSurfaceWriter(); - - - //- Destructor - virtual ~nullSurfaceWriter(); - - - // Member Functions - - // Write - - //- Writes single surface to file. - virtual void write - ( - const fileName& outputDir, - const fileName& surfaceName, - const pointField& points, - const faceList& faces, - const word& fieldName, - const Field& values, - const bool isNodeValues, - const bool verbose = false - ) const; -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#ifdef NoRepository -# include "nullSurfaceWriter.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/null/nullSurfaceWriterRunTime.C b/src/sampling/sampledSurface/writers/null/nullSurfaceWriterRunTime.C deleted file mode 100644 index c9fd6af9d9..0000000000 --- a/src/sampling/sampledSurface/writers/null/nullSurfaceWriterRunTime.C +++ /dev/null @@ -1,44 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 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 "nullSurfaceWriter.H" -#include "surfaceWriters.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -makeSurfaceWriterType(nullSurfaceWriter, bool); -makeSurfaceWriters(nullSurfaceWriter); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/proxy/proxySurfaceWriter.C b/src/sampling/sampledSurface/writers/proxy/proxySurfaceWriter.C index 11990cfd83..d598754b38 100644 --- a/src/sampling/sampledSurface/writers/proxy/proxySurfaceWriter.C +++ b/src/sampling/sampledSurface/writers/proxy/proxySurfaceWriter.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) 2009-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,27 +29,34 @@ License #include "OFstream.H" #include "OSspecific.H" +#include "makeSurfaceWriterMethods.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(proxySurfaceWriter, 0); +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template -Foam::proxySurfaceWriter::proxySurfaceWriter(const word& ext) +Foam::proxySurfaceWriter::proxySurfaceWriter(const word& ext) : - surfaceWriter(), + surfaceWriter(), ext_(ext) {} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -template -Foam::proxySurfaceWriter::~proxySurfaceWriter() +Foam::proxySurfaceWriter::~proxySurfaceWriter() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -void Foam::proxySurfaceWriter::write +void Foam::proxySurfaceWriter::write ( const fileName& outputDir, const fileName& surfaceName, @@ -69,19 +76,14 @@ void Foam::proxySurfaceWriter::write mkDir(outputDir); } - fileName fName(outputDir/surfaceName + "." + ext_); + fileName outName(outputDir/surfaceName + "." + ext_); if (verbose) { - Info<< "Writing geometry to " << fName << endl; + Info<< "Writing geometry to " << outName << endl; } - MeshedSurfaceProxy - ( - points, - faces - ).write(fName); - + MeshedSurfaceProxy(points, faces).write(outName); } diff --git a/src/sampling/sampledSurface/writers/proxy/proxySurfaceWriter.H b/src/sampling/sampledSurface/writers/proxy/proxySurfaceWriter.H index 2cbc6c30ac..ad134b7b6e 100644 --- a/src/sampling/sampledSurface/writers/proxy/proxySurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/proxy/proxySurfaceWriter.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) 2009-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,6 +25,8 @@ Class Foam::proxySurfaceWriter Description + A surfaceWriter that writes the geometry via the MeshedSurfaceProxy, but + which does not support any fields. SourceFiles proxySurfaceWriter.C @@ -42,13 +44,12 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class proxySurfaceWriter Declaration + Class proxySurfaceWriter Declaration \*---------------------------------------------------------------------------*/ -template class proxySurfaceWriter : - public surfaceWriter + public surfaceWriter { // Private data @@ -74,15 +75,16 @@ public: // Member Functions - //- Always write separate geometry file - virtual bool separateFiles() + + //- True if the surface format supports geometry in a separate file. + // False if geometry and field must be in a single file + virtual bool separateGeometry() { return true; } - // Write - //- Write geometry to file. + //- Write single surface geometry to file. virtual void write ( const fileName& outputDir, @@ -92,20 +94,6 @@ public: const bool verbose = false ) const; - - //- Writes single surface to file. - virtual void write - ( - const fileName& outputDir, - const fileName& surfaceName, - const pointField& points, - const faceList& faces, - const word& fieldName, - const Field& values, - const bool isNodeValues, - const bool verbose = false - ) const - {} }; @@ -115,12 +103,6 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#ifdef NoRepository -# include "proxySurfaceWriter.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/proxy/proxySurfaceWriterRunTime.C b/src/sampling/sampledSurface/writers/proxy/proxySurfaceWriterRunTime.C deleted file mode 100644 index 508b41c1b6..0000000000 --- a/src/sampling/sampledSurface/writers/proxy/proxySurfaceWriterRunTime.C +++ /dev/null @@ -1,45 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 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 "proxySurfaceWriter.H" -#include "surfaceWriters.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -// create type names, but do not register with run-time tables -makeTypeSurfaceWritersTypeName(proxySurfaceWriter, bool); -makeSurfaceWritersTypeName(proxySurfaceWriter); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.C b/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.C index 46b8a188ec..90e42c0c07 100644 --- a/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.C +++ b/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.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) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,334 +29,187 @@ License #include "OSspecific.H" #include "IOmanip.H" +#include "makeSurfaceWriterMethods.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + makeSurfaceWriterType(rawSurfaceWriter); +} + + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -template -void Foam::rawSurfaceWriter::writeGeometry +inline void Foam::rawSurfaceWriter::writeLocation ( + Ostream& os, const pointField& points, - const label pointI, - Ostream& os + const label pointI ) { const point& pt = points[pointI]; - - os << pt.x() << ' ' << pt.y() << ' ' << pt.z() << ' '; + os << pt.x() << ' ' << pt.y() << ' ' << pt.z() << ' '; } -template -void Foam::rawSurfaceWriter::writeGeometry +inline void Foam::rawSurfaceWriter::writeLocation ( + Ostream& os, const pointField& points, const faceList& faces, - const label faceI, - Ostream& os + const label faceI ) { const point& ct = faces[faceI].centre(points); - - os << ct.x() << ' ' << ct.y() << ' ' << ct.z() << ' '; -} - - -// Write scalarField in raw format -template -void Foam::rawSurfaceWriter::writeData -( - const word& fieldName, - const pointField& points, - const faceList& faces, - const scalarField& values, - const bool isNodeValues, - Ostream& os -) -{ - // header - os << "# x y z " << fieldName << endl; - - // Write data - if (isNodeValues) - { - forAll(values, elemI) - { - writeGeometry(points, elemI, os); - os << values[elemI] << nl; - } - } - else - { - forAll(values, elemI) - { - writeGeometry(points, faces, elemI, os); - os << values[elemI] << nl; - } - } - - os << nl; -} - - -// Write vectorField in raw format -template -void Foam::rawSurfaceWriter::writeData -( - const word& fieldName, - const pointField& points, - const faceList& faces, - const vectorField& values, - const bool isNodeValues, - Ostream& os -) -{ - // header - os << "# x y z " - << fieldName << "_x " - << fieldName << "_y " - << fieldName << "_z " - << endl; - - // Write data - if (isNodeValues) - { - forAll(values, elemI) - { - writeGeometry(points, elemI, os); - - const vector& v = values[elemI]; - os << v[0] << ' ' << v[1] << ' ' << v[2] << nl; - } - } - else - { - forAll(values, elemI) - { - writeGeometry(points, faces, elemI, os); - - const vector& v = values[elemI]; - os << v[0] << ' ' << v[1] << ' ' << v[2] << nl; - } - } - -} - - -// Write sphericalTensorField in raw format -template -void Foam::rawSurfaceWriter::writeData -( - const word& fieldName, - const pointField& points, - const faceList& faces, - const sphericalTensorField& values, - const bool isNodeValues, - Ostream& os -) -{ - // header - os << "# ii "; - os << fieldName << "_ii" << endl; - - // Write data - if (isNodeValues) - { - forAll(values, elemI) - { - writeGeometry(points, elemI, os); - - const sphericalTensor& v = values[elemI]; - os << v[0] << nl; - } - } - else - { - forAll(values, elemI) - { - writeGeometry(points, faces, elemI, os); - - const sphericalTensor& v = values[elemI]; - os << v[0] << nl; - } - } -} - - -// Write symmTensorField in raw format -template -void Foam::rawSurfaceWriter::writeData -( - const word& fieldName, - const pointField& points, - const faceList& faces, - const symmTensorField& values, - const bool isNodeValues, - Ostream& os -) -{ - // header - os << "# xx xy xz yy yz "; - for (int i=0; i<6; i++) - { - os << fieldName << "_" << i << " "; - } - os << endl; - - // Write data - if (isNodeValues) - { - forAll(values, elemI) - { - writeGeometry(points, elemI, os); - - const symmTensor& v = values[elemI]; - - os << v[0] << ' ' << v[1] << ' ' << v[2] << ' ' - << v[3] << ' ' << v[4] << ' ' << v[5] << nl; - } - } - else - { - forAll(values, elemI) - { - writeGeometry(points, faces, elemI, os); - - const symmTensor& v = values[elemI]; - - os << v[0] << ' ' << v[1] << ' ' << v[2] << ' ' - << v[3] << ' ' << v[4] << ' ' << v[5] << nl; - } - } -} - - -// Write tensorField in raw format -template -void Foam::rawSurfaceWriter::writeData -( - const word& fieldName, - const pointField& points, - const faceList& faces, - const tensorField& values, - const bool isNodeValues, - Ostream& os -) -{ - // header - os << "# xx xy xz yx yy yz zx zy zz"; - for (int i=0; i<9; ++i) - { - os << fieldName << "_" << i << " "; - } - os << endl; - - // Write data - if (isNodeValues) - { - forAll(values, elemI) - { - writeGeometry(points, elemI, os); - - const tensor& v = values[elemI]; - os << v[0] << ' ' << v[1] << ' ' << v[2] << ' ' - << v[3] << ' ' << v[4] << ' ' << v[5] << ' ' - << v[6] << ' ' << v[7] << ' ' << v[8] << nl; - } - } - else - { - forAll(values, elemI) - { - writeGeometry(points, faces, elemI, os); - - const tensor& v = values[elemI]; - os << v[0] << ' ' << v[1] << ' ' << v[2] << ' ' - << v[3] << ' ' << v[4] << ' ' << v[5] << ' ' - << v[6] << ' ' << v[7] << ' ' << v[8] << nl; - } - } -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -template -Foam::rawSurfaceWriter::rawSurfaceWriter() -: - surfaceWriter() -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -template -Foam::rawSurfaceWriter::~rawSurfaceWriter() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -void Foam::rawSurfaceWriter::write -( - const fileName& outputDir, - const fileName& surfaceName, - const pointField& points, - const faceList& faces, - const bool verbose -) const -{ - if (!isDir(outputDir)) - { - mkDir(outputDir); - } - - OFstream os - ( - outputDir/surfaceName + ".raw" - ); - - if (verbose) - { - Info<< "Writing geometry to " << os.name() << endl; - } - - - // header - os << "# geometry NO_DATA " << faces.size() << nl - << "# x y z" << endl; - - // Write faces - forAll(faces, elemI) - { - writeGeometry(points, faces, elemI, os); - os << nl; - } - - os << nl; + os << ct.x() << ' ' << ct.y() << ' ' << ct.z() << ' '; } namespace Foam { - // bool fields aren't supported template<> - void Foam::rawSurfaceWriter::write + void Foam::rawSurfaceWriter::writeHeader ( - const fileName& outputDir, - const fileName& surfaceName, - const pointField& points, - const faceList& faces, + Ostream& os, const word& fieldName, - const Field& values, - const bool isNodeValues, - const bool verbose - ) const - {} + const Field& values + ) + { + os << values.size() << nl + << "# x y z " << fieldName << nl; + } + + + template<> + void Foam::rawSurfaceWriter::writeHeader + ( + Ostream& os, + const word& fieldName, + const Field& values + ) + { + os << values.size() << nl + << "# x y z " + << fieldName << "_x " + << fieldName << "_y " + << fieldName << "_z " + << endl; + } + + + template<> + void Foam::rawSurfaceWriter::writeHeader + ( + Ostream& os, + const word& fieldName, + const Field& values + ) + { + os << values.size() << nl + << "# ii " + << fieldName << "_ii" << nl; + } + + + template<> + void Foam::rawSurfaceWriter::writeHeader + ( + Ostream& os, + const word& fieldName, + const Field& values + ) + { + os << values.size() << nl + << "# xx xy xz yy yz "; + for (int i=0; i<6; ++i) + { + os << fieldName << "_" << i << " "; + } + os << endl; + } + + + template<> + void Foam::rawSurfaceWriter::writeHeader + ( + Ostream& os, + const word& fieldName, + const Field& values + ) + { + os << values.size() << nl + << "# xx xy xz yx yy yz zx zy zz"; + for (int i=0; i<9; ++i) + { + os << fieldName << "_" << i << " "; + } + os << nl; + } + + + template<> + inline void Foam::rawSurfaceWriter::writeData + ( + Ostream& os, + const scalar& v + ) + { + os << v << nl; + } + + + template<> + inline void Foam::rawSurfaceWriter::writeData + ( + Ostream& os, + const vector& v + ) + { + os << v[0] << ' ' << v[1] << ' ' << v[2] << nl; + } + + + template<> + inline void Foam::rawSurfaceWriter::writeData + ( + Ostream& os, + const sphericalTensor& v + ) + { + os << v[0] << nl; + } + + + template<> + inline void Foam::rawSurfaceWriter::writeData + ( + Ostream& os, + const symmTensor& v + ) + { + os << v[0] << ' ' << v[1] << ' ' << v[2] << ' ' + << v[3] << ' ' << v[4] << ' ' << v[5] << nl; + } + + + template<> + inline void Foam::rawSurfaceWriter::writeData + ( + Ostream& os, + const tensor& v + ) + { + os << v[0] << ' ' << v[1] << ' ' << v[2] << ' ' + << v[3] << ' ' << v[4] << ' ' << v[5] << ' ' + << v[6] << ' ' << v[7] << ' ' << v[8] << nl; + } + } template -void Foam::rawSurfaceWriter::write +void Foam::rawSurfaceWriter::writeTemplate ( const fileName& outputDir, const fileName& surfaceName, @@ -373,17 +226,13 @@ void Foam::rawSurfaceWriter::write mkDir(outputDir); } - OFstream os - ( - outputDir/fieldName + '_' + surfaceName + ".raw" - ); + OFstream os(outputDir/fieldName + '_' + surfaceName + ".raw"); if (verbose) { Info<< "Writing field " << fieldName << " to " << os.name() << endl; } - // header os << "# " << fieldName; if (isNodeValues) @@ -395,10 +244,85 @@ void Foam::rawSurfaceWriter::write os << " FACE_DATA "; } - os << values.size() << nl; + // header + writeHeader(os, fieldName, values); - writeData(fieldName, points, faces, values, isNodeValues, os); + // values + if (isNodeValues) + { + forAll(values, elemI) + { + writeLocation(os, points, elemI); + writeData(os, values[elemI]); + } + } + else + { + forAll(values, elemI) + { + writeLocation(os, points, faces, elemI); + writeData(os, values[elemI]); + } + } } + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::rawSurfaceWriter::rawSurfaceWriter() +: + surfaceWriter() +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::rawSurfaceWriter::~rawSurfaceWriter() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::rawSurfaceWriter::write +( + const fileName& outputDir, + const fileName& surfaceName, + const pointField& points, + const faceList& faces, + const bool verbose +) const +{ + if (!isDir(outputDir)) + { + mkDir(outputDir); + } + + OFstream os(outputDir/surfaceName + ".raw"); + + if (verbose) + { + Info<< "Writing geometry to " << os.name() << endl; + } + + + // header + os << "# geometry NO_DATA " << faces.size() << nl + << "# x y z" << nl; + + // Write faces centres + forAll(faces, elemI) + { + writeLocation(os, points, faces, elemI); + os << nl; + } + + os << nl; +} + + +// create write methods +defineSurfaceWriterWriteFields(Foam::rawSurfaceWriter); + + // ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.H b/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.H index 771824bd89..5ec4d1ac30 100644 --- a/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/raw/rawSurfaceWriter.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) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,6 +25,7 @@ Class Foam::rawSurfaceWriter Description + A surfaceWriter for raw output. SourceFiles rawSurfaceWriter.C @@ -36,86 +37,62 @@ SourceFiles #include "surfaceWriter.H" + // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { /*---------------------------------------------------------------------------*\ - Class raw Declaration + Class rawSurfaceWriter Declaration \*---------------------------------------------------------------------------*/ -template class rawSurfaceWriter : - public surfaceWriter + public surfaceWriter { // Private Member Functions - static void writeGeometry + static inline void writeLocation ( - const pointField& points, - const label pointI, - Ostream& os + Ostream&, + const pointField&, + const label pointI ); - static void writeGeometry + static inline void writeLocation ( - const pointField& points, - const faceList& faces, - const label faceI, - Ostream& os + Ostream&, + const pointField&, + const faceList&, + const label faceI ); - static void writeData + template + static void writeHeader ( + Ostream&, const word& fieldName, - const pointField& points, - const faceList& faces, - const scalarField& values, - const bool isNodeValues, - Ostream& os + const Field& ); - static void writeData - ( - const word& fieldName, - const pointField& points, - const faceList& faces, - const vectorField& values, - const bool isNodeValues, - Ostream& os - ); + template + static inline void writeData(Ostream&, const Type&); - static void writeData - ( - const word& fieldName, - const pointField& points, - const faceList& faces, - const sphericalTensorField& values, - const bool isNodeValues, - Ostream& os - ); - static void writeData + //- Templated write operation + template + void writeTemplate ( - const word& fieldName, + const fileName& outputDir, + const fileName& surfaceName, const pointField& points, const faceList& faces, - const symmTensorField& values, - const bool isNodeValues, - Ostream& os - ); - - static void writeData - ( const word& fieldName, - const pointField& points, - const faceList& faces, - const tensorField& values, + const Field& values, const bool isNodeValues, - Ostream& os - ); + const bool verbose + ) const; public: @@ -136,9 +113,7 @@ public: // Member Functions - // Write - - //- Write geometry to file. + //- Write single surface geometry to file. virtual void write ( const fileName& outputDir, @@ -148,18 +123,77 @@ public: const bool verbose = false ) const; - //- Writes single surface to file. + + //- Write scalarField for a single surface to file. + // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, - const fileName& surfaceName, + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, - const word& fieldName, - const Field& values, + const word& fieldName, // name of field + const Field& values, const bool isNodeValues, const bool verbose = false ) const; + + //- Write vectorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write sphericalTensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write symmTensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write tensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + }; @@ -169,12 +203,6 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#ifdef NoRepository -# include "rawSurfaceWriter.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/raw/rawSurfaceWriterRunTime.C b/src/sampling/sampledSurface/writers/raw/rawSurfaceWriterRunTime.C deleted file mode 100644 index d6a1a89cc9..0000000000 --- a/src/sampling/sampledSurface/writers/raw/rawSurfaceWriterRunTime.C +++ /dev/null @@ -1,44 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 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 "rawSurfaceWriter.H" -#include "surfaceWriters.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -makeSurfaceWriterType(rawSurfaceWriter, bool); -makeSurfaceWriters(rawSurfaceWriter); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/starcd/starcdSurfaceWriter.C b/src/sampling/sampledSurface/writers/starcd/starcdSurfaceWriter.C new file mode 100644 index 0000000000..5ab7290218 --- /dev/null +++ b/src/sampling/sampledSurface/writers/starcd/starcdSurfaceWriter.C @@ -0,0 +1,172 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / 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 "starcdSurfaceWriter.H" + +#include "MeshedSurfaceProxy.H" +#include "OFstream.H" +#include "OSspecific.H" + +#include "makeSurfaceWriterMethods.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + makeSurfaceWriterType(starcdSurfaceWriter); +} + + +// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +namespace Foam +{ + template<> + inline void Foam::starcdSurfaceWriter::writeData + ( + Ostream& os, + const scalar& v + ) + { + os << v << nl; + } + + + template<> + inline void Foam::starcdSurfaceWriter::writeData + ( + Ostream& os, + const vector& v + ) + { + os << v[0] << ' ' << v[1] << ' ' << v[2] << nl; + } + + + template<> + inline void Foam::starcdSurfaceWriter::writeData + ( + Ostream& os, + const sphericalTensor& v + ) + { + os << v[0] << nl; + } + +} + + +template +inline void Foam::starcdSurfaceWriter::writeData +( + Ostream& os, + const Type& v +) +{} + + +template +void Foam::starcdSurfaceWriter::writeTemplate +( + const fileName& outputDir, + const fileName& surfaceName, + const pointField& points, + const faceList& faces, + const word& fieldName, + const Field& values, + const bool isNodeValues, + const bool verbose +) const +{ + if (!isDir(outputDir)) + { + mkDir(outputDir); + } + + OFstream os(outputDir/fieldName + '_' + surfaceName + ".usr"); + + if (verbose) + { + Info<< "Writing field " << fieldName << " to " << os.name() << endl; + } + + // no header, just write values + forAll(values, elemI) + { + os << elemI+1 << ' '; + writeData(os, values[elemI]); + } +} + + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::starcdSurfaceWriter::starcdSurfaceWriter() +: + surfaceWriter() +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::starcdSurfaceWriter::~starcdSurfaceWriter() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::starcdSurfaceWriter::write +( + const fileName& outputDir, + const fileName& surfaceName, + const pointField& points, + const faceList& faces, + const bool verbose +) const +{ + if (!isDir(outputDir)) + { + mkDir(outputDir); + } + + fileName outName(outputDir/surfaceName + ".inp"); + + if (verbose) + { + Info<< "Writing geometry to " << outName << endl; + } + + MeshedSurfaceProxy(points, faces).write(outName); +} + + +// create write methods +defineSurfaceWriterWriteField(Foam::starcdSurfaceWriter, scalar); +defineSurfaceWriterWriteField(Foam::starcdSurfaceWriter, vector); +defineSurfaceWriterWriteField(Foam::starcdSurfaceWriter, sphericalTensor); + + +// ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/starcd/starcdSurfaceWriter.H b/src/sampling/sampledSurface/writers/starcd/starcdSurfaceWriter.H new file mode 100644 index 0000000000..bf0a0eb824 --- /dev/null +++ b/src/sampling/sampledSurface/writers/starcd/starcdSurfaceWriter.H @@ -0,0 +1,181 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2008-2011 OpenCFD Ltd. + \\/ M anipulation | +------------------------------------------------------------------------------- +License + This file is part of OpenFOAM. + + OpenFOAM is free software: you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + OpenFOAM is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + for more details. + + You should have received a copy of the GNU General Public License + along with OpenFOAM. If not, see . + +Class + Foam::starcdSurfaceWriter + +Description + A surfaceWriter for STARCD files. + + The geometry is written via the MeshedSurfaceProxy, the fields + are written in a trivial ASCII format with ID and VALUE as + so-called user data. These @c .usr files can be read into proSTAR + with these types of commands. For element data: + @verbatim + getuser FILENAME.usr cell scalar free + getuser FILENAME.usr cell vector free + @endverbatim + and for vertex data: + @verbatim + getuser FILENAME.usr vertex scalar free + getuser FILENAME.usr vertex vector free + @endverbatim + +Note + Only scalar and vector fields are supported directly. + A sphericalTensor is written as a scalar. + Other field types are not written. + +SourceFiles + starcdSurfaceWriter.C + +\*---------------------------------------------------------------------------*/ + +#ifndef starcdSurfaceWriter_H +#define starcdSurfaceWriter_H + +#include "surfaceWriter.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class starcdSurfaceWriter Declaration +\*---------------------------------------------------------------------------*/ + +class starcdSurfaceWriter +: + public surfaceWriter +{ + // Private Member Functions + + template + static inline void writeData(Ostream&, const Type&); + + + //- Templated write operation + template + void writeTemplate + ( + const fileName& outputDir, + const fileName& surfaceName, + const pointField& points, + const faceList& faces, + const word& fieldName, + const Field& values, + const bool isNodeValues, + const bool verbose + ) const; + + +public: + + //- Runtime type information + TypeName("starcd"); + + + // Constructors + + //- Construct null + starcdSurfaceWriter(); + + + //- Destructor + virtual ~starcdSurfaceWriter(); + + + // Member Functions + + //- True if the surface format supports geometry in a separate file. + // False if geometry and field must be in a single file + virtual bool separateGeometry() + { + return true; + } + + //- Write single surface geometry to file. + virtual void write + ( + const fileName& outputDir, + const fileName& surfaceName, + const pointField& points, + const faceList& faces, + const bool verbose = false + ) const; + + //- Write scalarField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write vectorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write sphericalTensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/surfaceWriter.C b/src/sampling/sampledSurface/writers/surfaceWriter.C index d4ebc9c222..0f52c6f4aa 100644 --- a/src/sampling/sampledSurface/writers/surfaceWriter.C +++ b/src/sampling/sampledSurface/writers/surfaceWriter.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,47 +26,43 @@ License #include "surfaceWriter.H" #include "MeshedSurfaceProxy.H" -#include "nullSurfaceWriter.H" #include "proxySurfaceWriter.H" #include "HashTable.H" #include "word.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -template -Foam::autoPtr< Foam::surfaceWriter > -Foam::surfaceWriter::New(const word& writeType) +namespace Foam { - typename wordConstructorTable::iterator cstrIter = + defineTypeNameAndDebug(surfaceWriter, 0); + defineRunTimeSelectionTable(surfaceWriter, word); + addNamedToRunTimeSelectionTable + ( + surfaceWriter, + surfaceWriter, + word, + null + ); +} + + +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +Foam::autoPtr +Foam::surfaceWriter::New(const word& writeType) +{ + wordConstructorTable::iterator cstrIter = wordConstructorTablePtr_->find(writeType); if (cstrIter == wordConstructorTablePtr_->end()) { - // not supported for this data type, but it generally does work - // (it handles the 'bool' specialization - ie, geometry write) - if - ( - Foam::surfaceWriter::wordConstructorTablePtr_->found - ( - writeType - ) - ) - { - // use 'null' handler instead - return autoPtr< surfaceWriter > - ( - new nullSurfaceWriter() - ); - } - else if (MeshedSurfaceProxy::canWriteType(writeType)) + if (MeshedSurfaceProxy::canWriteType(writeType)) { // generally unknown, but can be written via MeshedSurfaceProxy // use 'proxy' handler instead - return autoPtr< surfaceWriter > - ( - new proxySurfaceWriter(writeType) - ); + return autoPtr(new proxySurfaceWriter(writeType)); } if (cstrIter == wordConstructorTablePtr_->end()) @@ -83,24 +79,20 @@ Foam::surfaceWriter::New(const word& writeType) } } - return autoPtr< surfaceWriter >(cstrIter()()); + return autoPtr(cstrIter()()); } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template -Foam::surfaceWriter::surfaceWriter() +Foam::surfaceWriter::surfaceWriter() {} // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -template -Foam::surfaceWriter::~surfaceWriter() +Foam::surfaceWriter::~surfaceWriter() {} -// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // - // ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/surfaceWriter.H b/src/sampling/sampledSurface/writers/surfaceWriter.H index d17db7a3f3..1057a187bd 100644 --- a/src/sampling/sampledSurface/writers/surfaceWriter.H +++ b/src/sampling/sampledSurface/writers/surfaceWriter.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -34,7 +34,7 @@ SourceFiles #ifndef surfaceWriter_H #define surfaceWriter_H -#include "Field.H" +#include "volFields.H" #include "typeInfo.H" #include "autoPtr.H" #include "pointField.H" @@ -48,22 +48,12 @@ SourceFiles namespace Foam { -// Forward declaration of friend functions and operators - -template class surfaceWriter; -template class nullSurfaceWriter; -template class proxySurfaceWriter; - /*---------------------------------------------------------------------------*\ Class surfaceWriter Declaration \*---------------------------------------------------------------------------*/ -template class surfaceWriter { - //- friendship between writer data types - template friend class surfaceWriter; - public: //- Runtime type information @@ -99,14 +89,15 @@ public: // Member Functions - //- Return true if the surface format supports separate files - virtual bool separateFiles() + //- True if the surface format supports geometry in a separate file. + // False if geometry and field must be in a single file + virtual bool separateGeometry() { return false; } - //- Writes single surface geometry to file. + //- Write single surface geometry to file. virtual void write ( const fileName& outputDir, // //surface/TIME @@ -118,8 +109,8 @@ public: {} - //- Writes single surface to file. Either one value per vertex or - // one value per face (isNodeValues = false) + //- Write scalarField for a single surface to file. + // One value per face or vertex (isNodeValues = true) virtual void write ( const fileName& outputDir, // //surface/TIME @@ -127,10 +118,73 @@ public: const pointField& points, const faceList& faces, const word& fieldName, // name of field - const Field& values, + const Field& values, const bool isNodeValues, const bool verbose = false - ) const = 0; + ) const + {} + + //- Write vectorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const + {} + + //- Write sphericalTensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const + {} + + //- Write symmTensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const + {} + + //- Write tensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const + {} + + }; @@ -140,12 +194,6 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#ifdef NoRepository -# include "surfaceWriter.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/surfaceWriters.C b/src/sampling/sampledSurface/writers/surfaceWriters.C deleted file mode 100644 index 5a677c793e..0000000000 --- a/src/sampling/sampledSurface/writers/surfaceWriters.C +++ /dev/null @@ -1,50 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 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 "surfaceWriters.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -#define defineSurfaceWriterType(dataType) \ - defineNamedTemplateTypeNameAndDebug(surfaceWriter< dataType >, 0); \ - defineTemplatedRunTimeSelectionTable(surfaceWriter, word, dataType) - -defineSurfaceWriterType(bool); - -defineSurfaceWriterType(scalar); -defineSurfaceWriterType(vector); -defineSurfaceWriterType(sphericalTensor); -defineSurfaceWriterType(symmTensor); -defineSurfaceWriterType(tensor); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/surfaceWriters.H b/src/sampling/sampledSurface/writers/surfaceWriters.H deleted file mode 100644 index 0369d2e993..0000000000 --- a/src/sampling/sampledSurface/writers/surfaceWriters.H +++ /dev/null @@ -1,76 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 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 . - -InClass - Foam::surfaceWriters - -Description - -\*---------------------------------------------------------------------------*/ - -#ifndef surfaceWriters_H -#define surfaceWriters_H - -#include "surfaceWriter.H" -#include "fieldTypes.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// Only used internally -#define makeTypeSurfaceWritersTypeName(typeWriter, dataType) \ - \ - defineNamedTemplateTypeNameAndDebug(typeWriter< dataType >, 0) - -// Sometimes used externally -#define makeSurfaceWritersTypeName(typeWriter) \ - \ - makeTypeSurfaceWritersTypeName(typeWriter, scalar); \ - makeTypeSurfaceWritersTypeName(typeWriter, vector); \ - makeTypeSurfaceWritersTypeName(typeWriter, sphericalTensor); \ - makeTypeSurfaceWritersTypeName(typeWriter, symmTensor); \ - makeTypeSurfaceWritersTypeName(typeWriter, tensor) - -// Define type info for single dataType template instantiation (eg, vector) -#define makeSurfaceWriterType(typeWriter, dataType) \ - \ - defineNamedTemplateTypeNameAndDebug(typeWriter< dataType >, 0); \ - addTemplatedToRunTimeSelectionTable \ - ( \ - surfaceWriter, typeWriter, dataType, word \ - ) - - -// Define type info for scalar, vector etc. instantiations -#define makeSurfaceWriters(typeWriter) \ - \ - makeSurfaceWriterType(typeWriter, scalar); \ - makeSurfaceWriterType(typeWriter, vector); \ - makeSurfaceWriterType(typeWriter, sphericalTensor); \ - makeSurfaceWriterType(typeWriter, symmTensor); \ - makeSurfaceWriterType(typeWriter, tensor) - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.C b/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.C index 085dbd67d0..2f333a9515 100644 --- a/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.C +++ b/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.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) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -28,10 +28,19 @@ License #include "OFstream.H" #include "OSspecific.H" +#include "makeSurfaceWriterMethods.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + makeSurfaceWriterType(vtkSurfaceWriter); +} + + // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -template -void Foam::vtkSurfaceWriter::writeGeometry +void Foam::vtkSurfaceWriter::writeGeometry ( Ostream& os, const pointField& points, @@ -71,12 +80,12 @@ void Foam::vtkSurfaceWriter::writeGeometry { const face& f = faces[faceI]; - os << f.size(); + os << f.size(); forAll(f, fp) { - os << ' ' << f[fp]; + os << ' ' << f[fp]; } - os << nl; + os << nl; } } @@ -84,15 +93,14 @@ void Foam::vtkSurfaceWriter::writeGeometry namespace Foam { - // Write scalarField in vtk format template<> - void Foam::vtkSurfaceWriter::writeData + void Foam::vtkSurfaceWriter::writeData ( Ostream& os, - const Field& values + const Field& values ) { - os << "1 " << values.size() << " float" << nl; + os << "1 " << values.size() << " float" << nl; forAll(values, elemI) { @@ -100,29 +108,28 @@ namespace Foam { if (elemI % 10) { - os << ' '; + os << ' '; } else { - os << nl; + os << nl; } } - const scalar v = values[elemI]; - os << float(v); + os << float(values[elemI]); } - os << nl; + os << nl; } - // Write vectorField in vtk format + template<> - void Foam::vtkSurfaceWriter::writeData + void Foam::vtkSurfaceWriter::writeData ( Ostream& os, - const Field& values + const Field& values ) { - os << "3 " << values.size() << " float" << nl; + os << "3 " << values.size() << " float" << nl; forAll(values, elemI) { @@ -133,33 +140,31 @@ namespace Foam } - // Write sphericalTensorField in vtk format template<> - void Foam::vtkSurfaceWriter::writeData + void Foam::vtkSurfaceWriter::writeData ( Ostream& os, const Field& values ) { - os << "1 " << values.size() << " float" << nl; + os << "1 " << values.size() << " float" << nl; forAll(values, elemI) { const sphericalTensor& v = values[elemI]; - os << float(v[0]) << nl; + os << float(v[0]) << nl; } } - // Write symmTensorField in vtk format template<> - void Foam::vtkSurfaceWriter::writeData + void Foam::vtkSurfaceWriter::writeData ( Ostream& os, const Field& values ) { - os << "6 " << values.size() << " float" << nl; + os << "6 " << values.size() << " float" << nl; forAll(values, elemI) { @@ -172,15 +177,14 @@ namespace Foam } - // Write tensorField in vtk format template<> - void Foam::vtkSurfaceWriter::writeData + void Foam::vtkSurfaceWriter::writeData ( Ostream& os, const Field& values ) { - os << "9 " << values.size() << " float" << nl; + os << "9 " << values.size() << " float" << nl; forAll(values, elemI) { @@ -197,69 +201,23 @@ namespace Foam // Write generic field in vtk format template -void Foam::vtkSurfaceWriter::writeData +void Foam::vtkSurfaceWriter::writeData ( Ostream& os, const Field& values ) { - os << "1 " << values.size() << " float" << nl; + os << "1 " << values.size() << " float" << nl; forAll(values, elemI) { - os << float(0) << nl; + os << float(0) << nl; } } -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -// Construct from components template -Foam::vtkSurfaceWriter::vtkSurfaceWriter() -: - surfaceWriter() -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -template -Foam::vtkSurfaceWriter::~vtkSurfaceWriter() -{} - - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template -void Foam::vtkSurfaceWriter::write -( - const fileName& outputDir, - const fileName& surfaceName, - const pointField& points, - const faceList& faces, - const bool verbose -) const -{ - if (!isDir(outputDir)) - { - mkDir(outputDir); - } - - fileName fName(outputDir/surfaceName + ".vtk"); - - if (verbose) - { - Info<< "Writing geometry to " << fName << endl; - } - - OFstream os(fName); - writeGeometry(os, points, faces); -} - - -template -void Foam::vtkSurfaceWriter::write +void Foam::vtkSurfaceWriter::writeTemplate ( const fileName& outputDir, const fileName& surfaceName, @@ -276,10 +234,7 @@ void Foam::vtkSurfaceWriter::write mkDir(outputDir); } - OFstream os - ( - outputDir/fieldName + '_' + surfaceName + ".vtk" - ); + OFstream os(outputDir/fieldName + '_' + surfaceName + ".vtk"); if (verbose) { @@ -304,8 +259,52 @@ void Foam::vtkSurfaceWriter::write // Write data writeData(os, values); - } +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::vtkSurfaceWriter::vtkSurfaceWriter() +: + surfaceWriter() +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +Foam::vtkSurfaceWriter::~vtkSurfaceWriter() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::vtkSurfaceWriter::write +( + const fileName& outputDir, + const fileName& surfaceName, + const pointField& points, + const faceList& faces, + const bool verbose +) const +{ + if (!isDir(outputDir)) + { + mkDir(outputDir); + } + + OFstream os(outputDir/surfaceName + ".vtk"); + + if (verbose) + { + Info<< "Writing geometry to " << os.name() << endl; + } + + writeGeometry(os, points, faces); +} + + +// create write methods +defineSurfaceWriterWriteFields(Foam::vtkSurfaceWriter); + + // ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.H b/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.H index bc13be23c2..322159094b 100644 --- a/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.H +++ b/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriter.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) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -25,6 +25,7 @@ Class Foam::vtkSurfaceWriter Description + A surfaceWriter for VTK legacy format. SourceFiles vtkSurfaceWriter.C @@ -42,21 +43,35 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class vtkSurfaceWriter Declaration + Class vtkSurfaceWriter Declaration \*---------------------------------------------------------------------------*/ -template class vtkSurfaceWriter : - public surfaceWriter + public surfaceWriter { // Private Member Functions static void writeGeometry(Ostream&, const pointField&, const faceList&); - static void writeData(Ostream&, const Field& values); + template + static void writeData(Ostream&, const Field&); + //- Templated write operation + template + void writeTemplate + ( + const fileName& outputDir, + const fileName& surfaceName, + const pointField& points, + const faceList& faces, + const word& fieldName, + const Field& values, + const bool isNodeValues, + const bool verbose + ) const; + public: //- Runtime type information @@ -75,9 +90,7 @@ public: // Member Functions - // Write - - //- Write geometry to file. + //- Write single surface geometry to file. virtual void write ( const fileName& outputDir, @@ -88,18 +101,76 @@ public: ) const; - //- Writes single surface to file. + //- Write scalarField for a single surface to file. + // One value per face or vertex (isNodeValues = true) virtual void write ( - const fileName& outputDir, - const fileName& surfaceName, + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface const pointField& points, const faceList& faces, - const word& fieldName, - const Field& values, + const word& fieldName, // name of field + const Field& values, const bool isNodeValues, const bool verbose = false ) const; + + //- Write vectorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write sphericalTensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write symmTensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + + //- Write tensorField for a single surface to file. + // One value per face or vertex (isNodeValues = true) + virtual void write + ( + const fileName& outputDir, // //surface/TIME + const fileName& surfaceName, // name of surface + const pointField& points, + const faceList& faces, + const word& fieldName, // name of field + const Field& values, + const bool isNodeValues, + const bool verbose = false + ) const; + }; @@ -109,12 +180,6 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -#ifdef NoRepository -# include "vtkSurfaceWriter.C" -#endif - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - #endif // ************************************************************************* // diff --git a/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriterRunTime.C b/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriterRunTime.C deleted file mode 100644 index 1901acfef6..0000000000 --- a/src/sampling/sampledSurface/writers/vtk/vtkSurfaceWriterRunTime.C +++ /dev/null @@ -1,44 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 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 "vtkSurfaceWriter.H" -#include "surfaceWriters.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -makeSurfaceWriterType(vtkSurfaceWriter, bool); -makeSurfaceWriters(vtkSurfaceWriter); - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// ************************************************************************* // From 0498967cc6a42ef77d2cd55d64bdfa8a4a5ccd6c Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Wed, 26 Jan 2011 13:45:17 +0100 Subject: [PATCH 013/367] ENH: only use point/face/mesh references where needed in ensightPart* - add points/faces constructor to ensightPartFaces with optional contiguousPoints flag. - Remove the now redundantensightPartNonMeshFaces class. --- src/conversion/Make/files | 1 - src/conversion/ensight/file/ensightFile.C | 2 +- src/conversion/ensight/file/ensightFile.H | 2 +- src/conversion/ensight/file/ensightGeoFile.C | 2 +- src/conversion/ensight/file/ensightGeoFile.H | 2 +- src/conversion/ensight/part/ensightPart.C | 51 ++----- src/conversion/ensight/part/ensightPart.H | 53 +++---- .../ensight/part/ensightPartCells.C | 139 ++++++------------ .../ensight/part/ensightPartCells.H | 53 ++++--- .../ensight/part/ensightPartFaces.C | 88 +++++++---- .../ensight/part/ensightPartFaces.H | 82 +++++++---- src/conversion/ensight/part/ensightPartIO.C | 40 ++++- .../ensight/part/ensightPartNonMeshFaces.C | 122 --------------- .../ensight/part/ensightPartNonMeshFaces.H | 131 ----------------- ...{ensightPartI.H => ensightPartTemplates.C} | 10 +- src/conversion/ensight/part/ensightParts.C | 75 ++++------ src/conversion/ensight/part/ensightParts.H | 15 +- ...nsightPartsI.H => ensightPartsTemplates.C} | 4 +- .../writers/ensight/ensightSurfaceWriter.C | 7 +- 19 files changed, 317 insertions(+), 562 deletions(-) delete mode 100644 src/conversion/ensight/part/ensightPartNonMeshFaces.C delete mode 100644 src/conversion/ensight/part/ensightPartNonMeshFaces.H rename src/conversion/ensight/part/{ensightPartI.H => ensightPartTemplates.C} (90%) rename src/conversion/ensight/part/{ensightPartsI.H => ensightPartsTemplates.C} (96%) diff --git a/src/conversion/Make/files b/src/conversion/Make/files index 563d177682..7c5a0aa91c 100644 --- a/src/conversion/Make/files +++ b/src/conversion/Make/files @@ -4,7 +4,6 @@ ensight/part/ensightPart.C ensight/part/ensightPartIO.C ensight/part/ensightPartCells.C ensight/part/ensightPartFaces.C -ensight/part/ensightPartNonMeshFaces.C ensight/part/ensightParts.C meshTables/boundaryRegion.C diff --git a/src/conversion/ensight/file/ensightFile.C b/src/conversion/ensight/file/ensightFile.C index e5f1b18f9c..23ae7a1e37 100644 --- a/src/conversion/ensight/file/ensightFile.C +++ b/src/conversion/ensight/file/ensightFile.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) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/conversion/ensight/file/ensightFile.H b/src/conversion/ensight/file/ensightFile.H index 46e10ce61f..59b28ebb9e 100644 --- a/src/conversion/ensight/file/ensightFile.H +++ b/src/conversion/ensight/file/ensightFile.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) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/conversion/ensight/file/ensightGeoFile.C b/src/conversion/ensight/file/ensightGeoFile.C index f7a7adceb8..dffcd07891 100644 --- a/src/conversion/ensight/file/ensightGeoFile.C +++ b/src/conversion/ensight/file/ensightGeoFile.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) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/conversion/ensight/file/ensightGeoFile.H b/src/conversion/ensight/file/ensightGeoFile.H index 7b59b111a9..eae4a0b4d5 100644 --- a/src/conversion/ensight/file/ensightGeoFile.H +++ b/src/conversion/ensight/file/ensightGeoFile.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) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License diff --git a/src/conversion/ensight/part/ensightPart.C b/src/conversion/ensight/part/ensightPart.C index 4c071a4220..d87eb239bb 100644 --- a/src/conversion/ensight/part/ensightPart.C +++ b/src/conversion/ensight/part/ensightPart.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) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,21 +24,22 @@ License \*----------------------------------------------------------------------------*/ #include "ensightPart.H" -#include "addToRunTimeSelectionTable.H" #include "dictionary.H" #include "ListOps.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { - defineTypeNameAndDebug(ensightPart, 0); - defineTemplateTypeNameAndDebug(IOPtrList, 0); - defineRunTimeSelectionTable(ensightPart, istream); + defineTypeNameAndDebug(ensightPart, 0); + defineTemplateTypeNameAndDebug(IOPtrList, 0); + defineRunTimeSelectionTable(ensightPart, istream); } -Foam::List Foam::ensightPart::elemTypes_(0); +const Foam::List Foam::ensightPart::elemTypes_(0); -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // bool Foam::ensightPart::isFieldDefined(const List& field) const { @@ -72,7 +73,7 @@ Foam::ensightPart::ensightPart size_(0), isCellData_(true), matId_(0), - meshPtr_(0) + points_(pointField::null()) {} @@ -89,7 +90,7 @@ Foam::ensightPart::ensightPart size_(0), isCellData_(true), matId_(0), - meshPtr_(0) + points_(pointField::null()) {} @@ -97,7 +98,7 @@ Foam::ensightPart::ensightPart ( label partNumber, const string& partDescription, - const polyMesh& pMesh + const pointField& points ) : number_(partNumber), @@ -107,7 +108,7 @@ Foam::ensightPart::ensightPart size_(0), isCellData_(true), matId_(0), - meshPtr_(&pMesh) + points_(points) {} @@ -120,7 +121,7 @@ Foam::ensightPart::ensightPart(const ensightPart& part) size_(part.size_), isCellData_(part.isCellData_), matId_(part.matId_), - meshPtr_(part.meshPtr_) + points_(part.points_) {} @@ -158,31 +159,7 @@ Foam::ensightPart::~ensightPart() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::ensightPart::reconstruct(Istream& is) -{ - dictionary dict(is); - dict.lookup("id") >> number_; - dict.lookup("name") >> name_; - dict.readIfPresent("offset", offset_); - - // populate elemLists_ - elemLists_.setSize(elementTypes().size()); - - forAll(elementTypes(), elemI) - { - word key(elementTypes()[elemI]); - - elemLists_[elemI].clear(); - dict.readIfPresent(key, elemLists_[elemI]); - - size_ += elemLists_[elemI].size(); - } - - is.check("ensightPart::reconstruct(Istream&)"); -} - - -void Foam::ensightPart::renumber(labelList const& origId) +void Foam::ensightPart::renumber(const labelList& origId) { // transform to global values first if (offset_) diff --git a/src/conversion/ensight/part/ensightPart.H b/src/conversion/ensight/part/ensightPart.H index b335ef8632..b2074f55b9 100644 --- a/src/conversion/ensight/part/ensightPart.H +++ b/src/conversion/ensight/part/ensightPart.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) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -30,7 +30,7 @@ Description SourceFiles ensightPart.C ensightPartIO.C - ensightPartI.H + ensightPartTemplates.C \*---------------------------------------------------------------------------*/ @@ -52,7 +52,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class ensightPart Declaration + Class ensightPart Declaration \*---------------------------------------------------------------------------*/ class ensightPart @@ -60,7 +60,7 @@ class ensightPart // Private data // Static data members - static List elemTypes_; + static const List elemTypes_; protected: @@ -88,8 +88,8 @@ protected: //- material id (numeric) label matId_; - //- mesh reference used - const polyMesh* meshPtr_; + //- pointField referenced + const pointField& points_; // Protected Classes @@ -104,25 +104,27 @@ protected: //- map global to local indices labelList list; - // null constructor + //- null constructor localPoints() : nPoints(0), list(0) {} - // construct for mesh points - localPoints(const polyMesh& pMesh) + //- construct for mesh points + localPoints(const pointField& pts) : nPoints(0), - list(pMesh.points().size(), -1) + list(pts.size(), -1) {} }; // Protected Member Functions - //- reconstruct contents from Istream + //- Reconstruct part characteristics (eg, element types) from Istream + // A part reconstructed in this manner can be used when writing fields, + // but cannot be used to write a new geometry void reconstruct(Istream&); //- check for fully defined fields @@ -170,12 +172,12 @@ public: //- Construct empty part with number and description ensightPart(label partNumber, const string& partDescription); - //- Construct empty part with number and description + //- Construct part with number, description and points reference ensightPart ( label partNumber, const string& partDescription, - const polyMesh& pMesh + const pointField& points ); //- Construct as copy @@ -202,8 +204,9 @@ public: return autoPtr(new ensightPart(*this)); }; - //- Construct on freestore from Istream - static autoPtr New(Istream& is); + //- Reconstruct part characteristics on freestore from Istream + // @sa reconstruct + static autoPtr New(Istream&); //- Destructor @@ -212,7 +215,7 @@ public: // Static members - virtual List const& elementTypes() const + virtual const List& elementTypes() const { return elemTypes_; } @@ -256,12 +259,13 @@ public: return matId_; } - //- non-const access + //- non-const access to part name or description void name(const string& value) { name_ = value; } + //- non-const access to material id void materialId(const label value) { matId_ = value; @@ -283,7 +287,7 @@ public: // Edit //- renumber elements - void renumber(labelList const&); + void renumber(const labelList&); //- write summary information about the object bool writeSummary(Ostream&) const; @@ -296,7 +300,7 @@ public: {} //- Helper: write geometry given the pointField - void writeGeometry(ensightGeoFile&, const pointField& points) const; + void writeGeometry(ensightGeoFile&, const pointField&) const; //- write scalar field void writeScalarField @@ -316,7 +320,7 @@ public: //- write generalized field components - template + template void writeField ( ensightFile&, @@ -339,11 +343,8 @@ public: friend Ostream& operator<<(Ostream&, const ensightPart&); //- write geometry - friend ensightGeoFile& operator<< - ( - ensightGeoFile&, - const ensightPart& - ); + friend ensightGeoFile& operator<<(ensightGeoFile&, const ensightPart&); + }; @@ -354,7 +355,7 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #ifdef NoRepository -# include "ensightPartI.H" +# include "ensightPartTemplates.C" #endif // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/conversion/ensight/part/ensightPartCells.C b/src/conversion/ensight/part/ensightPartCells.C index d00e9b6f4b..8bd8465c41 100644 --- a/src/conversion/ensight/part/ensightPartCells.C +++ b/src/conversion/ensight/part/ensightPartCells.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) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,22 +24,21 @@ License \*----------------------------------------------------------------------------*/ #include "ensightPartCells.H" -#include "addToRunTimeSelectionTable.H" #include "IOstream.H" #include "IStringStream.H" #include "dictionary.H" #include "cellModeller.H" - +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { - defineTypeNameAndDebug(ensightPartCells, 0); - addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream); + defineTypeNameAndDebug(ensightPartCells, 0); + addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream); } -Foam::List Foam::ensightPartCells::elemTypes_ +const Foam::List Foam::ensightPartCells::elemTypes_ ( IStringStream ( @@ -50,7 +49,11 @@ Foam::List Foam::ensightPartCells::elemTypes_ // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -void Foam::ensightPartCells::classify(const labelList& idList) +void Foam::ensightPartCells::classify +( + const polyMesh& mesh, + const labelList& idList +) { // References to cell shape models const cellModel& tet = *(cellModeller::lookup("tet")); @@ -58,7 +61,6 @@ void Foam::ensightPartCells::classify(const labelList& idList) const cellModel& prism = *(cellModeller::lookup("prism")); const cellModel& hex = *(cellModeller::lookup("hex")); - const polyMesh& mesh = *meshPtr_; const cellShapeList& cellShapes = mesh.cellShapes(); offset_ = 0; @@ -78,13 +80,6 @@ void Foam::ensightPartCells::classify(const labelList& idList) label nHex = 0; label nPoly = 0; - - // TODO: allow tet-decomposition of polyhedral cells -#if 0 - label nTetDecomp = 0; - label nPyrDecomp = 0; -#endif - for (label listI = 0; listI < size_; ++listI) { label cellId = listI; @@ -115,26 +110,6 @@ void Foam::ensightPartCells::classify(const labelList& idList) else { nPoly++; - - // TODO: allow tet-decomposition of polyhedral cells -#if 0 - const cell& cFaces = mesh.cells()[cellI]; - - forAll(cFaces, cFaceI) - { - const face& f = mesh.faces()[cFaces[cFaceI]]; - - label nQuads = 0; - label nTris = 0; - f.nTrianglesQuads(mesh.points(), nTris, nQuads); - - nTetDecomp += nTris; - nPyrDecomp += nQuads; - } - - nAddCells--; - nAddPoints++; -#endif } } @@ -183,29 +158,6 @@ void Foam::ensightPartCells::classify(const labelList& idList) else { polyCells[nPoly++] = cellId; - - // TODO: allow tet-decomposition of polyhedral cells -#if 0 - // Mapping from additional point to cell - addPointCellLabels_[api] = cellId; - - const cell& cFaces = mesh.cells()[cellId]; - - forAll(cFaces, cFaceI) - { - const face& f = mesh.faces()[cFaces[cFaceI]]; - - label nQuads = 0; - label nTris = 0; - f.nTrianglesQuads(mesh.points(), nTris, nQuads); - - nTetDecomp += nTris; - nPyrDecomp += nQuads; - } - - nAddCells--; - nAddPoints++; -#endif } } @@ -213,11 +165,11 @@ void Foam::ensightPartCells::classify(const labelList& idList) // MUST match with elementTypes elemLists_.setSize(elementTypes().size()); - elemLists_[tetra4Elements].transfer( tetCells ); - elemLists_[pyramid5Elements].transfer( pyramidCells ); - elemLists_[penta6Elements].transfer( prismCells ); - elemLists_[hexa8Elements].transfer( hexCells ); - elemLists_[nfacedElements].transfer( polyCells ); + elemLists_[tetra4Elements].transfer(tetCells); + elemLists_[pyramid5Elements].transfer(pyramidCells); + elemLists_[penta6Elements].transfer(prismCells); + elemLists_[hexa8Elements].transfer(hexCells); + elemLists_[nfacedElements].transfer(polyCells); } @@ -229,57 +181,63 @@ Foam::ensightPartCells::ensightPartCells const string& partDescription ) : - ensightPart(partNumber, partDescription) + ensightPart(partNumber, partDescription), + mesh_(*reinterpret_cast(0)) {} Foam::ensightPartCells::ensightPartCells ( label partNumber, - const polyMesh& pMesh + const polyMesh& mesh ) : - ensightPart(partNumber, "cells", pMesh) + ensightPart(partNumber, "cells", mesh.points()), + mesh_(mesh) { - classify(); + classify(mesh); } Foam::ensightPartCells::ensightPartCells ( label partNumber, - const polyMesh& pMesh, + const polyMesh& mesh, const labelList& idList ) : - ensightPart(partNumber, "cells", pMesh) + ensightPart(partNumber, "cells", mesh.points()), + mesh_(mesh) { - classify(idList); + classify(mesh, idList); } Foam::ensightPartCells::ensightPartCells ( label partNumber, - const polyMesh& pMesh, + const polyMesh& mesh, const cellZone& cZone ) : - ensightPart(partNumber, cZone.name(), pMesh) + ensightPart(partNumber, cZone.name(), mesh.points()), + mesh_(mesh) { - classify(cZone); + classify(mesh, cZone); } Foam::ensightPartCells::ensightPartCells(const ensightPartCells& part) : - ensightPart(part) + ensightPart(part), + mesh_(part.mesh_) {} Foam::ensightPartCells::ensightPartCells(Istream& is) : - ensightPart() + ensightPart(), + mesh_(*reinterpret_cast(0)) { reconstruct(is); } @@ -295,9 +253,7 @@ Foam::ensightPartCells::~ensightPartCells() Foam::ensightPart::localPoints Foam::ensightPartCells::calcLocalPoints() const { - const polyMesh& mesh = *meshPtr_; - - localPoints ptList(mesh); + localPoints ptList(points_); labelList& usedPoints = ptList.list; label nPoints = 0; @@ -309,11 +265,11 @@ Foam::ensightPart::localPoints Foam::ensightPartCells::calcLocalPoints() const forAll(idList, i) { label id = idList[i] + offset_; - const labelList& cFaces = mesh.cells()[id]; + const labelList& cFaces = mesh_.cells()[id]; forAll(cFaces, cFaceI) { - const face& f = mesh.faces()[cFaces[cFaceI]]; + const face& f = mesh_.faces()[cFaces[cFaceI]]; forAll(f, fp) { @@ -353,20 +309,18 @@ void Foam::ensightPartCells::writeConnectivity os.write(idList.size()); os.newline(); - const polyMesh& mesh = *meshPtr_; - // write polyhedral if (key == "nfaced") { - const faceList& meshFaces = mesh.faces(); + const faceList& meshFaces = mesh_.faces(); // write the number of faces per element forAll(idList, i) { label id = idList[i] + offset_; - const labelList& cFace = mesh.cells()[id]; + const labelList& cFace = mesh_.cells()[id]; - os.write( cFace.size() ); + os.write(cFace.size()); os.newline(); } @@ -374,13 +328,13 @@ void Foam::ensightPartCells::writeConnectivity forAll(idList, i) { label id = idList[i] + offset_; - const labelList& cFace = mesh.cells()[id]; + const labelList& cFace = mesh_.cells()[id]; forAll(cFace, faceI) { const face& cf = meshFaces[cFace[faceI]]; - os.write( cf.size() ); + os.write(cf.size()); os.newline(); } } @@ -389,7 +343,7 @@ void Foam::ensightPartCells::writeConnectivity forAll(idList, i) { label id = idList[i] + offset_; - const labelList& cFace = mesh.cells()[id]; + const labelList& cFace = mesh_.cells()[id]; forAll(cFace, faceI) { @@ -399,7 +353,7 @@ void Foam::ensightPartCells::writeConnectivity { // convert global -> local index // (note: Ensight indices start with 1) - os.write( pointMap[cf[ptI]] + 1); + os.write(pointMap[cf[ptI]] + 1); } os.newline(); } @@ -408,7 +362,7 @@ void Foam::ensightPartCells::writeConnectivity else { // write primitive - const cellShapeList& cellShapes = mesh.cellShapes(); + const cellShapeList& cellShapes = mesh_.cellShapes(); forAll(idList, i) { @@ -419,7 +373,7 @@ void Foam::ensightPartCells::writeConnectivity // (note: Ensight indices start with 1) forAll(cellPoints, ptI) { - os.write( pointMap[cellPoints[ptI]] + 1 ); + os.write(pointMap[cellPoints[ptI]] + 1); } os.newline(); } @@ -429,8 +383,7 @@ void Foam::ensightPartCells::writeConnectivity void Foam::ensightPartCells::writeGeometry(ensightGeoFile& os) const { - const polyMesh& mesh = *meshPtr_; - ensightPart::writeGeometry(os, mesh.points()); + ensightPart::writeGeometry(os, points_); } diff --git a/src/conversion/ensight/part/ensightPartCells.H b/src/conversion/ensight/part/ensightPartCells.H index 82b0f80d89..bf6bf951a7 100644 --- a/src/conversion/ensight/part/ensightPartCells.H +++ b/src/conversion/ensight/part/ensightPartCells.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) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -56,8 +56,12 @@ class ensightPartCells //- Disallow default bitwise assignment void operator=(const ensightPartCells&); - //- classify the cell types - void classify(const labelList& idLabels = labelList::null()); + //- Classify the cell types, set elemLists. + void classify + ( + const polyMesh&, + const labelList& idLabels = labelList::null() + ); //- track points used virtual localPoints calcLocalPoints() const; @@ -74,24 +78,29 @@ class ensightPartCells const labelList& pointMap ) const; - //- write geometry - virtual void writeGeometry(ensightGeoFile& os) const; - protected: - //- addressable Ensight element types - enum elemType - { - tetra4Elements, - pyramid5Elements, - penta6Elements, - hexa8Elements, - nfacedElements - }; + //- addressable ensight element types + enum elemType + { + tetra4Elements, + pyramid5Elements, + penta6Elements, + hexa8Elements, + nfacedElements + }; + // Static data members - static List elemTypes_; + + static const List elemTypes_; + + + // Protected data + + //- mesh referenced + const polyMesh& mesh_; public: @@ -126,10 +135,13 @@ public: //- Construct as copy ensightPartCells(const ensightPartCells&); - //- Construct from Istream + //- Reconstruct part characteristics (eg, element types) from Istream + // A part reconstructed in this manner can be used when writing fields, + // but cannot be used to write a new geometry + // @sa Foam::ensightPart::reconstruct ensightPartCells(Istream&); - //- Construct on freestore from Istream + //- Reconstruct part characteristics on freestore from Istream static autoPtr New(Istream& is) { return autoPtr(new ensightPartCells(is)); @@ -142,8 +154,11 @@ public: // Member Functions + //- write geometry + virtual void writeGeometry(ensightGeoFile&) const; + //- static listing of the element types - virtual List const& elementTypes() const + virtual const List& elementTypes() const { return elemTypes_; } diff --git a/src/conversion/ensight/part/ensightPartFaces.C b/src/conversion/ensight/part/ensightPartFaces.C index 46169cd90f..250be573c6 100644 --- a/src/conversion/ensight/part/ensightPartFaces.C +++ b/src/conversion/ensight/part/ensightPartFaces.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) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,21 +24,21 @@ License \*----------------------------------------------------------------------------*/ #include "ensightPartFaces.H" -#include "addToRunTimeSelectionTable.H" #include "IOstreams.H" #include "IStringStream.H" #include "dictionary.H" +#include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { - defineTypeNameAndDebug(ensightPartFaces, 0); - addToRunTimeSelectionTable(ensightPart, ensightPartFaces, istream); + defineTypeNameAndDebug(ensightPartFaces, 0); + addToRunTimeSelectionTable(ensightPart, ensightPartFaces, istream); } -Foam::List Foam::ensightPartFaces::elemTypes_ +const Foam::List Foam::ensightPartFaces::elemTypes_ ( IStringStream ( @@ -49,7 +49,7 @@ Foam::List Foam::ensightPartFaces::elemTypes_ // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -void Foam::ensightPartFaces::binShapes(const faceList& faces) +void Foam::ensightPartFaces::classify(const faceList& faces) { // count the shapes label nTri = 0; @@ -107,9 +107,9 @@ void Foam::ensightPartFaces::binShapes(const faceList& faces) // MUST match with elementTypes elemLists_.setSize(elementTypes().size()); - elemLists_[tria3Elements].transfer( triCells ); - elemLists_[quad4Elements].transfer( quadCells ); - elemLists_[nsidedElements].transfer( polygonCells ); + elemLists_[tria3Elements].transfer(triCells); + elemLists_[quad4Elements].transfer(quadCells); + elemLists_[nsidedElements].transfer(polygonCells); size_ = faces.size(); } @@ -123,7 +123,9 @@ Foam::ensightPartFaces::ensightPartFaces const string& partDescription ) : - ensightPart(partNumber, partDescription) + ensightPart(partNumber, partDescription), + faces_(faceList::null()), + contiguousPoints_(false) { isCellData_ = false; offset_ = 0; @@ -134,29 +136,57 @@ Foam::ensightPartFaces::ensightPartFaces Foam::ensightPartFaces::ensightPartFaces ( label partNumber, - const polyMesh& pMesh, - const polyPatch& pPatch + const string& partDescription, + const pointField& points, + const faceList& faces, + const bool contiguousPoints ) : - ensightPart(partNumber, pPatch.name(), pMesh) + ensightPart(partNumber, partDescription, points), + faces_(faces), + contiguousPoints_(contiguousPoints) { isCellData_ = false; - offset_ = pPatch.start(); + offset_ = 0; + size_ = 0; - // count the shapes - binShapes(pPatch); + // classify the face shapes + classify(faces); +} + + +Foam::ensightPartFaces::ensightPartFaces +( + label partNumber, + const polyMesh& mesh, + const polyPatch& patch +) +: + ensightPart(partNumber, patch.name(), mesh.points()), + faces_(mesh.faces()), + contiguousPoints_(false) +{ + isCellData_ = false; + offset_ = patch.start(); + + // classify the face shapes + classify(patch); } Foam::ensightPartFaces::ensightPartFaces(const ensightPartFaces& part) : - ensightPart(part) + ensightPart(part), + faces_(part.faces_), + contiguousPoints_(part.contiguousPoints_) {} Foam::ensightPartFaces::ensightPartFaces(Istream& is) : - ensightPart() + ensightPart(), + faces_(faceList::null()), + contiguousPoints_(false) { isCellData_ = false; reconstruct(is); @@ -173,9 +203,15 @@ Foam::ensightPartFaces::~ensightPartFaces() Foam::ensightPart::localPoints Foam::ensightPartFaces::calcLocalPoints() const { - const polyMesh& mesh = *meshPtr_; + if (contiguousPoints_) + { + localPoints ptList; + ptList.list = identity(points_.size()); + ptList.nPoints = points_.size(); + return ptList; + } - localPoints ptList(mesh); + localPoints ptList(points_); labelList& usedPoints = ptList.list; label nPoints = 0; @@ -187,7 +223,7 @@ Foam::ensightPart::localPoints Foam::ensightPartFaces::calcLocalPoints() const forAll(idList, i) { label id = idList[i] + offset_; - const face& f = mesh.faces()[id]; + const face& f = faces_[id]; forAll(f, fp) { @@ -236,7 +272,7 @@ void Foam::ensightPartFaces::writeConnectivity label id = idList[i] + offset_; const face& f = faces[id]; - os.write( f.size() ); + os.write(f.size()); os.newline(); } } @@ -251,7 +287,7 @@ void Foam::ensightPartFaces::writeConnectivity // (note: Ensight indices start with 1) forAll(f, fp) { - os.write( pointMap[f[fp]] + 1 ); + os.write(pointMap[f[fp]] + 1); } os.newline(); } @@ -270,7 +306,7 @@ void Foam::ensightPartFaces::writeConnectivity ( os, key, - meshPtr_->faces(), + faces_, idList, pointMap ); @@ -279,9 +315,7 @@ void Foam::ensightPartFaces::writeConnectivity void Foam::ensightPartFaces::writeGeometry(ensightGeoFile& os) const { - const polyMesh& mesh = *meshPtr_; - const pointField& points = mesh.points(); - ensightPart::writeGeometry(os, points); + ensightPart::writeGeometry(os, points_); } diff --git a/src/conversion/ensight/part/ensightPartFaces.H b/src/conversion/ensight/part/ensightPartFaces.H index 3871300b5c..78d5cf6d16 100644 --- a/src/conversion/ensight/part/ensightPartFaces.H +++ b/src/conversion/ensight/part/ensightPartFaces.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) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -61,41 +61,52 @@ class ensightPartFaces //- element connectivity virtual void writeConnectivity ( - ensightGeoFile& os, + ensightGeoFile&, const word& key, const labelList& idList, const labelList& pointMap ) const; - //- write geometry - virtual void writeGeometry(ensightGeoFile& os) const; - protected: - //- addressable ensight element types - enum elemType - { - tria3Elements, - quad4Elements, - nsidedElements - }; + //- addressable ensight element types + enum elemType + { + tria3Elements, + quad4Elements, + nsidedElements + }; + // Static data members - static List elemTypes_; - //- Divide the shapes, set elemLists. - void binShapes(const faceList& faces); + static const List elemTypes_; - //- Helper: write connectivity - void writeConnectivity - ( - ensightGeoFile& os, - const word& key, - const faceList& faces, - const labelList& idList, - const labelList& pointMap - ) const; + + // Protected data + + //- faces referenced + const faceList& faces_; + + //- Can skip local point renumbering when points are contiguous + const bool contiguousPoints_; + + + // Protected Member Functions + + //- Classify the face shapes, set elemLists. + void classify(const faceList&); + + //- Helper: write connectivity + void writeConnectivity + ( + ensightGeoFile&, + const word& key, + const faceList&, + const labelList& idList, + const labelList& pointMap + ) const; public: @@ -108,6 +119,17 @@ public: //- Construct empty part with number and description ensightPartFaces(label partNumber, const string& partDescription); + //- Construct part with number, description, points and faces + // Can skip local point renumbering when points are contiguous + ensightPartFaces + ( + label partNumber, + const string& partDescription, + const pointField&, + const faceList&, + const bool contiguousPoints = false + ); + //- Construct from polyMesh and polyPatch ensightPartFaces ( @@ -119,10 +141,13 @@ public: //- Construct as copy ensightPartFaces(const ensightPartFaces&); - //- Construct from Istream + //- Reconstruct part characteristics (eg, element types) from Istream + // A part reconstructed in this manner can be used when writing fields, + // but cannot be used to write a new geometry + // @sa Foam::ensightPart::reconstruct ensightPartFaces(Istream&); - //- Construct on freestore from Istream + //- Reconstruct part characteristics on freestore from Istream static autoPtr New(Istream& is) { return autoPtr(new ensightPartFaces(is)); @@ -135,8 +160,11 @@ public: // Member Functions + //- write geometry + virtual void writeGeometry(ensightGeoFile&) const; + //- static listing of the element types - virtual List const& elementTypes() const + virtual const List& elementTypes() const { return elemTypes_; } diff --git a/src/conversion/ensight/part/ensightPartIO.C b/src/conversion/ensight/part/ensightPartIO.C index ac903bdf99..7760b7b07f 100644 --- a/src/conversion/ensight/part/ensightPartIO.C +++ b/src/conversion/ensight/part/ensightPartIO.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) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -77,6 +77,32 @@ void Foam::ensightPart::writeFieldList // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +void Foam::ensightPart::reconstruct(Istream& is) +{ + dictionary dict(is); + dict.lookup("id") >> number_; + dict.lookup("name") >> name_; + + offset_ = 0; + dict.readIfPresent("offset", offset_); + + // populate elemLists_ + elemLists_.setSize(elementTypes().size()); + + forAll(elementTypes(), elemI) + { + word key(elementTypes()[elemI]); + + elemLists_[elemI].clear(); + dict.readIfPresent(key, elemLists_[elemI]); + + size_ += elemLists_[elemI].size(); + } + + is.check("ensightPart::reconstruct(Istream&)"); +} + + bool Foam::ensightPart::writeSummary(Ostream& os) const { os << indent << type() << nl @@ -88,7 +114,7 @@ bool Foam::ensightPart::writeSummary(Ostream& os) const os.writeKeyword("offset") << offset() << token::END_STATEMENT << nl; os.writeKeyword("size") << size() << token::END_STATEMENT << nl; - os << decrIndent << indent << token::END_BLOCK << nl << endl; + os << decrIndent << indent << token::END_BLOCK << nl << endl; return true; } @@ -112,7 +138,7 @@ bool Foam::ensightPart::writeData(Ostream& os) const } } - os << decrIndent << indent << token::END_BLOCK << nl << endl; + os << decrIndent << indent << token::END_BLOCK << nl << endl; return true; } @@ -136,13 +162,13 @@ void Foam::ensightPart::writeGeometry os.write(ptList.nPoints); os.newline(); - for (direction cmpt=0; cmpt < vector::nComponents; cmpt++) + for (direction cmpt=0; cmpt < point::nComponents; ++cmpt) { forAll(pointMap, ptI) { if (pointMap[ptI] > -1) { - os.write( points[ptI].component(cmpt) ); + os.write(points[ptI].component(cmpt)); os.newline(); } } @@ -182,7 +208,7 @@ void Foam::ensightPart::writeScalarField if (idList.size()) { - os.writeKeyword( elementTypes()[elemI] ); + os.writeKeyword(elementTypes()[elemI]); writeFieldList(os, field, idList); } } @@ -208,7 +234,7 @@ void Foam::ensightPart::writeVectorField if (idList.size()) { - os.writeKeyword( elementTypes()[elemI] ); + os.writeKeyword(elementTypes()[elemI]); writeFieldList(os, field0, idList); writeFieldList(os, field1, idList); writeFieldList(os, field2, idList); diff --git a/src/conversion/ensight/part/ensightPartNonMeshFaces.C b/src/conversion/ensight/part/ensightPartNonMeshFaces.C deleted file mode 100644 index e991844bf0..0000000000 --- a/src/conversion/ensight/part/ensightPartNonMeshFaces.C +++ /dev/null @@ -1,122 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 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 "ensightPartNonMeshFaces.H" -#include "addToRunTimeSelectionTable.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - defineTypeNameAndDebug(ensightPartNonMeshFaces, 0); - addToRunTimeSelectionTable(ensightPart, ensightPartNonMeshFaces, istream); -} - - -// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // - -Foam::ensightPart::localPoints -Foam::ensightPartNonMeshFaces::calcLocalPoints() const -{ - localPoints ptList; - ptList.list = identity(points_.size()); - ptList.nPoints = points_.size(); - return ptList; -} - - -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // - -Foam::ensightPartNonMeshFaces::ensightPartNonMeshFaces -( - label partNumber, - const string& partDescription, - const faceList& faces, - const pointField& points -) -: - ensightPartFaces(partNumber, partDescription), - faces_(faces), - points_(points) -{ - binShapes(faces); -} - - -//- Construct as copy -Foam::ensightPartNonMeshFaces::ensightPartNonMeshFaces -( - const ensightPartNonMeshFaces& part -) -: - ensightPartFaces(part), - faces_(part.faces_), - points_(part.points_) -{} - - -//- Construct from Istream -Foam::ensightPartNonMeshFaces::ensightPartNonMeshFaces(Istream& is) -: - ensightPartFaces(is), - faces_(is), - points_(is) -{} - - -// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // - -Foam::ensightPartNonMeshFaces::~ensightPartNonMeshFaces() -{} - - -// * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // - -void Foam::ensightPartNonMeshFaces::writeConnectivity -( - ensightGeoFile& os, - const word& key, - const labelList& idList, - const labelList& pointMap -) const -{ - ensightPartFaces::writeConnectivity - ( - os, - key, - faces_, - idList, - pointMap - ); -} - - -void Foam::ensightPartNonMeshFaces::writeGeometry(ensightGeoFile& os) const -{ - ensightPart::writeGeometry(os, points_); -} - - -// ************************************************************************* // diff --git a/src/conversion/ensight/part/ensightPartNonMeshFaces.H b/src/conversion/ensight/part/ensightPartNonMeshFaces.H deleted file mode 100644 index ab7f4a782a..0000000000 --- a/src/conversion/ensight/part/ensightPartNonMeshFaces.H +++ /dev/null @@ -1,131 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -Class - Foam::ensightPartNonMeshFaces - -Description - An implementation of ensightPart to work on self-contained faces and points - (without a mesh). - -SourceFiles - ensightPartNonMeshFaces.C - -\*---------------------------------------------------------------------------*/ - -#ifndef ensightPartNonMeshFaces_H -#define ensightPartNonMeshFaces_H - -#include "ensightPartFaces.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ - -/*---------------------------------------------------------------------------*\ - Class ensightPartNonMeshFaces Declaration -\*---------------------------------------------------------------------------*/ - -class ensightPartNonMeshFaces -: - public ensightPartFaces -{ - // Private data - - //- faces (reference) - const faceList& faces_; - - //- points (reference) - const pointField& points_; - - - // Private Member Functions - - //- Disallow default bitwise assignment - void operator=(const ensightPartNonMeshFaces&); - - //- track points used - virtual localPoints calcLocalPoints() const; - -public: - - //- Runtime type information - TypeName("ensightNonMeshFaces"); - - // Constructors - - //- Construct from faces and points - ensightPartNonMeshFaces - ( - label partNumber, - const string& partDescription, - const faceList& faces, - const pointField& points - ); - - //- Construct as copy - ensightPartNonMeshFaces(const ensightPartNonMeshFaces& part); - - //- Construct from Istream - ensightPartNonMeshFaces(Istream& is); - - //- Construct on freestore from Istream - static autoPtr New(Istream& is) - { - return autoPtr - ( - new ensightPartNonMeshFaces(is) - ); - } - - - //- Destructor - virtual ~ensightPartNonMeshFaces(); - - - // Member Functions - - //- element connectivity - virtual void writeConnectivity - ( - ensightGeoFile& os, - const word& key, - const labelList& idList, - const labelList& pointMap - ) const; - - virtual void writeGeometry(ensightGeoFile& os) const; - -}; - - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -} // End namespace Foam - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -#endif - -// ************************************************************************* // diff --git a/src/conversion/ensight/part/ensightPartI.H b/src/conversion/ensight/part/ensightPartTemplates.C similarity index 90% rename from src/conversion/ensight/part/ensightPartI.H rename to src/conversion/ensight/part/ensightPartTemplates.C index 9286273276..5bb80f9622 100644 --- a/src/conversion/ensight/part/ensightPartI.H +++ b/src/conversion/ensight/part/ensightPartTemplates.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) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -30,14 +30,14 @@ Description // * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * // -template +template void Foam::ensightPart::writeField ( ensightFile& os, const Field& field ) const { - if (size() && field.size()) + if (this->size() && field.size()) { writeHeader(os); @@ -47,13 +47,13 @@ void Foam::ensightPart::writeField if (idList.size()) { - os.writeKeyword( elementTypes()[elemI] ); + os.writeKeyword(elementTypes()[elemI]); for ( direction cmpt=0; cmpt < pTraits::nComponents; - cmpt++ + ++cmpt ) { writeFieldList(os, field.component(cmpt), idList); diff --git a/src/conversion/ensight/part/ensightParts.C b/src/conversion/ensight/part/ensightParts.C index 76179b4a11..658f41b74c 100644 --- a/src/conversion/ensight/part/ensightParts.C +++ b/src/conversion/ensight/part/ensightParts.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) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -27,11 +27,11 @@ License // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -Foam::ensightParts::ensightParts(const polyMesh& pMesh) +Foam::ensightParts::ensightParts(const polyMesh& mesh) : partsList_() { - recalculate(pMesh); + recalculate(mesh); } @@ -52,15 +52,15 @@ Foam::ensightParts::~ensightParts() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -void Foam::ensightParts::recalculate(const polyMesh& pMesh) +void Foam::ensightParts::recalculate(const polyMesh& mesh) { partsList_.clear(); // extra space for unzoned cells label nPart = ( - pMesh.cellZones().size() - + pMesh.boundaryMesh().size() + mesh.cellZones().size() + + mesh.boundaryMesh().size() + 1 ); @@ -70,9 +70,9 @@ void Foam::ensightParts::recalculate(const polyMesh& pMesh) label nZoneCells = 0; // do cell zones - forAll(pMesh.cellZones(), zoneI) + forAll(mesh.cellZones(), zoneI) { - const cellZone& cZone = pMesh.cellZones()[zoneI]; + const cellZone& cZone = mesh.cellZones()[zoneI]; nZoneCells += cZone.size(); if (cZone.size()) @@ -80,12 +80,7 @@ void Foam::ensightParts::recalculate(const polyMesh& pMesh) partsList_.set ( nPart, - new ensightPartCells - ( - nPart, - pMesh, - cZone - ) + new ensightPartCells(nPart, mesh, cZone) ); nPart++; @@ -100,23 +95,19 @@ void Foam::ensightParts::recalculate(const polyMesh& pMesh) partsList_.set ( nPart, - new ensightPartCells - ( - nPart, - pMesh - ) + new ensightPartCells(nPart, mesh) ); nPart++; } - else if (pMesh.nCells() > nZoneCells) + else if (mesh.nCells() > nZoneCells) { // determine which cells are not in a cellZone - labelList unzoned(pMesh.nCells(), -1); + labelList unzoned(mesh.nCells(), -1); - forAll(pMesh.cellZones(), zoneI) + forAll(mesh.cellZones(), zoneI) { - const labelList& idList = pMesh.cellZones()[zoneI]; + const labelList& idList = mesh.cellZones()[zoneI]; forAll(idList, i) { @@ -140,12 +131,7 @@ void Foam::ensightParts::recalculate(const polyMesh& pMesh) partsList_.set ( nPart, - new ensightPartCells - ( - nPart, - pMesh, - unzoned - ) + new ensightPartCells(nPart, mesh, unzoned) ); nPart++; @@ -154,20 +140,15 @@ void Foam::ensightParts::recalculate(const polyMesh& pMesh) // do boundaries, skipping empty and processor patches - forAll(pMesh.boundaryMesh(), patchI) + forAll(mesh.boundaryMesh(), patchI) { - const polyPatch& pPatch = pMesh.boundaryMesh()[patchI]; - if (pPatch.size() && !isA(pPatch)) + const polyPatch& patch = mesh.boundaryMesh()[patchI]; + if (patch.size() && !isA(patch)) { partsList_.set ( nPart, - new ensightPartFaces - ( - nPart, - pMesh, - pPatch - ) + new ensightPartFaces(nPart, mesh, patch) ); nPart++; @@ -199,7 +180,7 @@ void Foam::ensightParts::renumber } -void Foam::ensightParts::writeGeometry( ensightGeoFile& os) const +void Foam::ensightParts::writeGeometry(ensightGeoFile& os) const { // with some feedback Info<< "write geometry part:" << nl << flush; @@ -225,23 +206,21 @@ bool Foam::ensightParts::writeSummary(Ostream& os) const void Foam::ensightParts::writeData(Ostream& os) const { - // Write size of list - os << nl << partsList_.size(); - - // Write beginning of contents - os << nl << token::BEGIN_LIST; + // Begin write list + os << nl << partsList_.size() + << nl << token::BEGIN_LIST; // Write list contents forAll(partsList_, i) { - os << nl << partsList_[i]; + os << nl << partsList_[i]; } - // Write end of contents - os << nl << token::END_LIST << nl; + // End write list + os << nl << token::END_LIST << nl; // Check state of IOstream - os.check("Ostream& operator<<(Ostream&, const PtrList&)"); + os.check("ensightParts::writeData(Ostream&)"); } diff --git a/src/conversion/ensight/part/ensightParts.H b/src/conversion/ensight/part/ensightParts.H index 3d620192b5..7ef4094259 100644 --- a/src/conversion/ensight/part/ensightParts.H +++ b/src/conversion/ensight/part/ensightParts.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) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,7 +29,7 @@ Description SourceFiles ensightParts.C - ensightPartsI.H + ensightPartsTemplates.C \*---------------------------------------------------------------------------*/ @@ -128,7 +128,7 @@ public: //- write generalized field components - template + template void writeField ( ensightFile&, @@ -138,11 +138,8 @@ public: // Friend Operators - friend ensightGeoFile& operator<< - ( - ensightGeoFile&, - const ensightParts& - ); + //- write geometry + friend ensightGeoFile& operator<<(ensightGeoFile&, const ensightParts&); }; @@ -153,7 +150,7 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #ifdef NoRepository -# include "ensightPartsI.H" +# include "ensightPartsTemplates.C" #endif #endif diff --git a/src/conversion/ensight/part/ensightPartsI.H b/src/conversion/ensight/part/ensightPartsTemplates.C similarity index 96% rename from src/conversion/ensight/part/ensightPartsI.H rename to src/conversion/ensight/part/ensightPartsTemplates.C index c4848faf2a..5eb8a7aec8 100644 --- a/src/conversion/ensight/part/ensightPartsI.H +++ b/src/conversion/ensight/part/ensightPartsTemplates.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) 2008-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -30,7 +30,7 @@ Description // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -template +template void Foam::ensightParts::writeField ( ensightFile& os, diff --git a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.C b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.C index d705525ebc..641e6a19b2 100644 --- a/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.C +++ b/src/sampling/sampledSurface/writers/ensight/ensightSurfaceWriter.C @@ -28,8 +28,7 @@ License #include "OFstream.H" #include "OSspecific.H" #include "IOmanip.H" -#include "ensightGeoFile.H" -#include "ensightPartNonMeshFaces.H" +#include "ensightPartFaces.H" #include "makeSurfaceWriterMethods.H" @@ -153,7 +152,7 @@ void Foam::ensightSurfaceWriter::writeTemplate << timeValue << nl << nl; - ensightPartNonMeshFaces ensPart(0, geomStr.name().name(), faces, points); + ensightPartFaces ensPart(0, geomStr.name().name(), points, faces, true); geomStr << ensPart; // Write field @@ -252,7 +251,7 @@ void Foam::ensightSurfaceWriter::write << timeValue << nl << nl; - ensightPartNonMeshFaces ensPart(0, geomStr.name().name(), faces, points); + ensightPartFaces ensPart(0, geomStr.name().name(), points, faces, true); geomStr << ensPart; } From 2c9433dced8e339dca30179911d2668dfd5ea891 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 26 Jan 2011 16:49:55 +0000 Subject: [PATCH 014/367] ENH: Updated IOobject flag after change in mesh construction --- applications/solvers/combustion/chemFoam/createSingleCellMesh.H | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/applications/solvers/combustion/chemFoam/createSingleCellMesh.H b/applications/solvers/combustion/chemFoam/createSingleCellMesh.H index e9f0272772..71ee8d60f6 100644 --- a/applications/solvers/combustion/chemFoam/createSingleCellMesh.H +++ b/applications/solvers/combustion/chemFoam/createSingleCellMesh.H @@ -23,7 +23,7 @@ fvMesh mesh fvMesh::defaultRegion, runTime.timeName(), runTime, - IOobject::NO_READ + IOobject::MUST_READ ), xferMove >(points), faces.xfer(), From ac3335be533a0a76d9acaca4a28e7f303eccea73 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 26 Jan 2011 16:50:16 +0000 Subject: [PATCH 015/367] STYLE: Added suppressSolverInfo flag to chemFoam tutorial case --- tutorials/combustion/chemFoam/h2/system/controlDict | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tutorials/combustion/chemFoam/h2/system/controlDict b/tutorials/combustion/chemFoam/h2/system/controlDict index 6d9df8d24f..f56ce79ba6 100644 --- a/tutorials/combustion/chemFoam/h2/system/controlDict +++ b/tutorials/combustion/chemFoam/h2/system/controlDict @@ -47,5 +47,7 @@ timePrecision 6; runTimeModifiable yes; +suppressSolverInfo yes; + // ************************************************************************* // From 8ee6502188493999e13ac1331d3f0519f4aee746 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 26 Jan 2011 16:57:31 +0000 Subject: [PATCH 016/367] STYLE: TimeIO : extraneous include file --- src/OpenFOAM/db/Time/TimeIO.C | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/OpenFOAM/db/Time/TimeIO.C b/src/OpenFOAM/db/Time/TimeIO.C index 8bcb95df9a..da542524b7 100644 --- a/src/OpenFOAM/db/Time/TimeIO.C +++ b/src/OpenFOAM/db/Time/TimeIO.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2004-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2004-2011 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -24,7 +24,7 @@ License \*---------------------------------------------------------------------------*/ #include "Time.H" -#include "PstreamReduceOps.H" +#include "Pstream.H" // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // From e260d68e9c8f2ae0f866ffb5d050642a3514953d Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 26 Jan 2011 16:57:44 +0000 Subject: [PATCH 017/367] ENH: Updated chemi.inp tutorial file --- tutorials/combustion/chemFoam/gri/chemkin/chem.inp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tutorials/combustion/chemFoam/gri/chemkin/chem.inp b/tutorials/combustion/chemFoam/gri/chemkin/chem.inp index 6c9e031c4c..ee978cd8a2 100644 --- a/tutorials/combustion/chemFoam/gri/chemkin/chem.inp +++ b/tutorials/combustion/chemFoam/gri/chemkin/chem.inp @@ -7,9 +7,9 @@ ELEMENTS O H C N AR END SPECIES -CH CH2O CH3O H O2 H2 O OH H2O HO2 H2O2 +CH4 CH2O CH3O H O2 H2 O OH H2O HO2 H2O2 C CH CH2 CH2(S) CH3 CO CO2 -HCO CH2OH CH3OH C2H C2H2 C2H3 +HCO CH2OH CH3OH C2H C2H2 C2H3 C2H4 C2H5 C2H6 HCCO CH2CO HCCOH N NH NH2 NH3 NNH NO NO2 N2O HNO CN HCN H2CN HCNN HCNO HOCN HNCO NCO N2 @@ -307,7 +307,7 @@ HO2+C3H7<=>O2+C3H8 2.550E+10 0.255 -943.00 HO2+C3H7=>OH+C2H5+CH2O 2.410E+13 .000 .00 CH3+C3H7<=>2C2H5 1.927E+13 -0.320 .00 ! -! + M Reactions +! + M Reactions ! 2O+M<=>O2+M 1.200E+17 -1.000 .00 H2/2.40/ H2O/15.40/ CH4/ 2.00/ CO/ 1.75/ CO2/3.60/ C2H6/ 3.00/ AR/0.83/ From c9d6212006ecac078a9eb7845f82d8926929f5bf Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 26 Jan 2011 16:59:13 +0000 Subject: [PATCH 018/367] ENH: Allwmake : allow easy building of static libraries --- src/Allwmake | 63 ++++++++++---------- src/Pstream/Allwmake | 2 +- src/conversion/Allwmake | 5 +- src/dummyThirdParty/Allwmake | 11 ++-- src/fvAgglomerationMethods/Allwmake | 5 +- src/lagrangian/Allwmake | 17 +++--- src/lagrangian/molecularDynamics/Allwmake | 9 ++- src/mesh/Allwmake | 7 ++- src/parallel/Allwmake | 9 ++- src/parallel/decompose/Allwmake | 9 ++- src/parallel/reconstruct/Allwmake | 5 +- src/postProcessing/Allwmake | 9 ++- src/postProcessing/functionObjects/Allwmake | 15 +++-- src/thermophysicalModels/Allwmake | 37 ++++++------ src/transportModels/Allwmake | 11 ++-- src/turbulenceModels/Allwmake | 6 +- src/turbulenceModels/LES/Allwmake | 7 ++- src/turbulenceModels/compressible/Allwmake | 9 ++- src/turbulenceModels/incompressible/Allwmake | 9 ++- 19 files changed, 148 insertions(+), 97 deletions(-) diff --git a/src/Allwmake b/src/Allwmake index f3c4420474..4dbc726a21 100755 --- a/src/Allwmake +++ b/src/Allwmake @@ -1,6 +1,9 @@ #!/bin/sh cd ${0%/*} || exit 1 # run from this directory +makeOption=libso +[ $# -ge 1 ] && makeOption=$1 + wmakeCheckPwd "$WM_PROJECT_DIR/src" || { echo "Error: Current directory is not \$WM_PROJECT_DIR/src" echo " The environment variables are inconsistent with the installation." @@ -21,53 +24,53 @@ wmakePrintBuild -check || /bin/rm -f OpenFOAM/Make/$WM_OPTIONS/global.? 2>/dev/n wmakeLnInclude OpenFOAM wmakeLnInclude OSspecific/$WM_OSTYPE -Pstream/Allwmake +Pstream/Allwmake $* OSspecific/$WM_OSTYPE/Allwmake -wmake libso OpenFOAM +wmake $makeOption OpenFOAM -wmake libso fileFormats -wmake libso triSurface -wmake libso meshTools -wmake libso edgeMesh -wmake libso surfMesh +wmake $makeOption fileFormats +wmake $makeOption triSurface +wmake $makeOption meshTools +wmake $makeOption edgeMesh +wmake $makeOption surfMesh # Decomposition methods needed by dummyThirdParty parallel/decompose/AllwmakeLnInclude # dummyThirdParty (dummy metisDecomp, scotchDecomp etc) needed by e.g. meshTools -dummyThirdParty/Allwmake +dummyThirdParty/Allwmake $* -wmake libso lagrangian/basic -wmake libso finiteVolume -wmake libso genericPatchFields +wmake $makeOption lagrangian/basic +wmake $makeOption finiteVolume +wmake $makeOption genericPatchFields # Build the proper scotchDecomp, metisDecomp etc. -parallel/Allwmake +parallel/Allwmake $* -wmake libso conversion +wmake $makeOption conversion -wmake libso sampling +wmake $makeOption sampling -wmake libso dynamicMesh -wmake libso dynamicFvMesh -wmake libso topoChangerFvMesh +wmake $makeOption dynamicMesh +wmake $makeOption dynamicFvMesh +wmake $makeOption topoChangerFvMesh -wmake libso ODE -wmake libso randomProcesses +wmake $makeOption ODE +wmake $makeOption randomProcesses -thermophysicalModels/Allwmake -transportModels/Allwmake -turbulenceModels/Allwmake -wmake libso surfaceFilmModels -lagrangian/Allwmake -postProcessing/Allwmake -mesh/Allwmake +thermophysicalModels/Allwmake $* +transportModels/Allwmake $* +turbulenceModels/Allwmake $* +wmake $makeOption surfaceFilmModels +lagrangian/Allwmake $* +postProcessing/Allwmake $* +mesh/Allwmake $* -wmake libso errorEstimation +wmake $makeOption errorEstimation -fvAgglomerationMethods/Allwmake +fvAgglomerationMethods/Allwmake $* -wmake libso fvMotionSolver -wmake libso engine +wmake $makeOption fvMotionSolver +wmake $makeOption engine # ----------------------------------------------------------------- end-of-file diff --git a/src/Pstream/Allwmake b/src/Pstream/Allwmake index ec3b07a859..7a2f2cd308 100755 --- a/src/Pstream/Allwmake +++ b/src/Pstream/Allwmake @@ -18,7 +18,7 @@ case "$WM_MPLIB" in ;; #GAMMA) -# wmake libso gamma +# wmake $makeOption gamma # ;; esac diff --git a/src/conversion/Allwmake b/src/conversion/Allwmake index a7168eeab1..cf1e61d47d 100755 --- a/src/conversion/Allwmake +++ b/src/conversion/Allwmake @@ -2,6 +2,9 @@ cd ${0%/*} || exit 1 # run from this directory set -x -wmake libso +makeOption=libso +[ $# -ge 1 ] && makeOption=$1 + +wmake $makeOption # ----------------------------------------------------------------- end-of-file diff --git a/src/dummyThirdParty/Allwmake b/src/dummyThirdParty/Allwmake index c584d92194..afd49cd5d9 100755 --- a/src/dummyThirdParty/Allwmake +++ b/src/dummyThirdParty/Allwmake @@ -2,10 +2,13 @@ cd ${0%/*} || exit 1 # run from this directory set -x -wmake libso scotchDecomp -wmake libso ptscotchDecomp -wmake libso metisDecomp -wmake libso MGridGen +makeOption=libso +[ $# -ge 1 ] && makeOption=$1 + +wmake $makeOption scotchDecomp +wmake $makeOption ptscotchDecomp +wmake $makeOption metisDecomp +wmake $makeOption MGridGen # ----------------------------------------------------------------- end-of-file diff --git a/src/fvAgglomerationMethods/Allwmake b/src/fvAgglomerationMethods/Allwmake index 17118db818..27f2fea53a 100755 --- a/src/fvAgglomerationMethods/Allwmake +++ b/src/fvAgglomerationMethods/Allwmake @@ -2,6 +2,9 @@ cd ${0%/*} || exit 1 # run from this directory set -x -wmake libso MGridGenGamgAgglomeration +makeOption=libso +[ $# -ge 1 ] && makeOption=$1 + +wmake $makeOption MGridGenGamgAgglomeration # ----------------------------------------------------------------- end-of-file diff --git a/src/lagrangian/Allwmake b/src/lagrangian/Allwmake index 92993c516f..26fd814f63 100755 --- a/src/lagrangian/Allwmake +++ b/src/lagrangian/Allwmake @@ -2,13 +2,16 @@ cd ${0%/*} || exit 1 # run from this directory set -x -wmake libso basic -wmake libso solidParticle -wmake libso intermediate -wmake libso dieselSpray -wmake libso dsmc -wmake libso coalCombustion +makeOption=libso +[ $# -ge 1 ] && makeOption=$1 -molecularDynamics/Allwmake +wmake $makeOption basic +wmake $makeOption solidParticle +wmake $makeOption intermediate +wmake $makeOption dieselSpray +wmake $makeOption dsmc +wmake $makeOption coalCombustion + +molecularDynamics/Allwmake $* # ----------------------------------------------------------------- end-of-file diff --git a/src/lagrangian/molecularDynamics/Allwmake b/src/lagrangian/molecularDynamics/Allwmake index 3f5d397e72..131ec5d458 100755 --- a/src/lagrangian/molecularDynamics/Allwmake +++ b/src/lagrangian/molecularDynamics/Allwmake @@ -2,8 +2,11 @@ cd ${0%/*} || exit 1 # run from this directory set -x -wmake libso potential -wmake libso molecularMeasurements -wmake libso molecule +makeOption=libso +[ $# -ge 1 ] && makeOption=$1 + +wmake $makeOption potential +wmake $makeOption molecularMeasurements +wmake $makeOption molecule # ----------------------------------------------------------------- end-of-file diff --git a/src/mesh/Allwmake b/src/mesh/Allwmake index f967335db3..57df2d57bf 100755 --- a/src/mesh/Allwmake +++ b/src/mesh/Allwmake @@ -2,7 +2,10 @@ cd ${0%/*} || exit 1 # run from this directory set -x -wmake libso autoMesh -wmake libso blockMesh +makeOption=libso +[ $# -ge 1 ] && makeOption=$1 + +wmake $makeOption autoMesh +wmake $makeOption blockMesh # ----------------------------------------------------------------- end-of-file diff --git a/src/parallel/Allwmake b/src/parallel/Allwmake index 08ca4923f2..92d80e20a8 100755 --- a/src/parallel/Allwmake +++ b/src/parallel/Allwmake @@ -2,9 +2,12 @@ cd ${0%/*} || exit 1 # run from this directory set -x -decompose/Allwmake -reconstruct/Allwmake -wmake libso distributed +makeOption=libso +[ $# -ge 1 ] && makeOption=$1 + +decompose/Allwmake $* +reconstruct/Allwmake $* +wmake $makeOption distributed # ----------------------------------------------------------------- end-of-file diff --git a/src/parallel/decompose/Allwmake b/src/parallel/decompose/Allwmake index 51c23325cc..93835f6a24 100755 --- a/src/parallel/decompose/Allwmake +++ b/src/parallel/decompose/Allwmake @@ -1,6 +1,9 @@ #!/bin/sh cd ${0%/*} || exit 1 # run from this directory +makeOption=libso +[ $# -ge 1 ] && makeOption=$1 + # get SCOTCH_VERSION, SCOTCH_ARCH_PATH settings=`$WM_PROJECT_DIR/bin/foamEtcFile apps/scotch/bashrc` if [ -f "$settings" ] @@ -16,17 +19,17 @@ set -x wmakeLnInclude decompositionMethods -wmake libso scotchDecomp +wmake $makeOption scotchDecomp if [ -d "$FOAM_LIBBIN/$FOAM_MPI" ] then ( WM_OPTIONS=${WM_OPTIONS}$WM_MPLIB - wmake libso ptscotchDecomp + wmake $makeOption ptscotchDecomp ) fi -wmake libso decompositionMethods +wmake $makeOption decompositionMethods # ----------------------------------------------------------------- end-of-file diff --git a/src/parallel/reconstruct/Allwmake b/src/parallel/reconstruct/Allwmake index c4badc5067..453d88f50b 100755 --- a/src/parallel/reconstruct/Allwmake +++ b/src/parallel/reconstruct/Allwmake @@ -2,7 +2,10 @@ cd ${0%/*} || exit 1 # run from this directory set -x -wmake libso reconstruct +makeOption=libso +[ $# -ge 1 ] && makeOption=$1 + +wmake $makeOption reconstruct # ----------------------------------------------------------------- end-of-file diff --git a/src/postProcessing/Allwmake b/src/postProcessing/Allwmake index 169c9c833f..d543c26fe1 100755 --- a/src/postProcessing/Allwmake +++ b/src/postProcessing/Allwmake @@ -2,9 +2,12 @@ cd ${0%/*} || exit 1 # run from this directory set -x -wmake libo postCalc -wmake libso foamCalcFunctions +makeOption=libso +[ $# -ge 1 ] && makeOption=$1 -functionObjects/Allwmake +wmake libo postCalc +wmake $makeOption foamCalcFunctions + +functionObjects/Allwmake $* # ----------------------------------------------------------------- end-of-file diff --git a/src/postProcessing/functionObjects/Allwmake b/src/postProcessing/functionObjects/Allwmake index d8cbe09eb9..14bdd330e1 100755 --- a/src/postProcessing/functionObjects/Allwmake +++ b/src/postProcessing/functionObjects/Allwmake @@ -2,11 +2,14 @@ cd ${0%/*} || exit 1 # run from this directory set -x -wmake libso field -wmake libso forces -wmake libso IO -wmake libso utilities -wmake libso jobControl -wmake libso systemCall +makeOption=libso +[ $# -ge 1 ] && makeOption=$1 + +wmake $makeOption field +wmake $makeOption forces +wmake $makeOption IO +wmake $makeOption utilities +wmake $makeOption jobControl +wmake $makeOption systemCall # ----------------------------------------------------------------- end-of-file diff --git a/src/thermophysicalModels/Allwmake b/src/thermophysicalModels/Allwmake index 7b1b586b56..e622e3c15b 100755 --- a/src/thermophysicalModels/Allwmake +++ b/src/thermophysicalModels/Allwmake @@ -2,27 +2,30 @@ cd ${0%/*} || exit 1 # run from this directory set -x -wmake libso specie -wmake libso solid -wmake libso thermophysicalFunctions -wmake libso liquids -wmake libso liquidMixture -wmake libso pointSolids -wmake libso pointSolidMixture +makeOption=libso +[ $# -ge 1 ] && makeOption=$1 -wmake libso basic -wmake libso reactionThermo -wmake libso laminarFlameSpeed -wmake libso chemistryModel -wmake libso pdfs -wmake libso radiation -wmake libso barotropicCompressibilityModel -wmake libso thermalPorousZone +wmake $makeOption specie +wmake $makeOption solid +wmake $makeOption thermophysicalFunctions +wmake $makeOption liquids +wmake $makeOption liquidMixture +wmake $makeOption pointSolids +wmake $makeOption pointSolidMixture -wmake libso SLGThermo +wmake $makeOption basic +wmake $makeOption reactionThermo +wmake $makeOption laminarFlameSpeed +wmake $makeOption chemistryModel +wmake $makeOption pdfs +wmake $makeOption radiation +wmake $makeOption barotropicCompressibilityModel +wmake $makeOption thermalPorousZone + +wmake $makeOption SLGThermo # Should be combined with solids&solidMixture -wmake libso basicSolidThermo +wmake $makeOption basicSolidThermo # ----------------------------------------------------------------- end-of-file diff --git a/src/transportModels/Allwmake b/src/transportModels/Allwmake index 138f265357..703920418d 100755 --- a/src/transportModels/Allwmake +++ b/src/transportModels/Allwmake @@ -2,9 +2,12 @@ cd ${0%/*} || exit 1 # run from this directory set -x -wmake libso incompressible -wmake libso interfaceProperties -wmake libso twoPhaseInterfaceProperties -# wmake libso compressible +makeOption=libso +[ $# -ge 1 ] && makeOption=$1 + +wmake $makeOption incompressible +wmake $makeOption interfaceProperties +wmake $makeOption twoPhaseInterfaceProperties +# wmake $makeOption compressible # ----------------------------------------------------------------- end-of-file diff --git a/src/turbulenceModels/Allwmake b/src/turbulenceModels/Allwmake index 80dc9dc1ee..e78f0c30dd 100755 --- a/src/turbulenceModels/Allwmake +++ b/src/turbulenceModels/Allwmake @@ -2,8 +2,8 @@ cd ${0%/*} || exit 1 # run from this directory set -x -LES/Allwmake -incompressible/Allwmake -compressible/Allwmake +LES/Allwmake $* +incompressible/Allwmake $* +compressible/Allwmake $* # ----------------------------------------------------------------- end-of-file diff --git a/src/turbulenceModels/LES/Allwmake b/src/turbulenceModels/LES/Allwmake index 00f3bf3ada..107251b422 100755 --- a/src/turbulenceModels/LES/Allwmake +++ b/src/turbulenceModels/LES/Allwmake @@ -2,9 +2,12 @@ cd ${0%/*} || exit 1 # run from this directory set -x +makeOption=libso +[ $# -ge 1 ] && makeOption=$1 + wmakeLnInclude ../incompressible/LES -wmake libso LESfilters -wmake libso LESdeltas +wmake $makeOption LESfilters +wmake $makeOption LESdeltas # ----------------------------------------------------------------- end-of-file diff --git a/src/turbulenceModels/compressible/Allwmake b/src/turbulenceModels/compressible/Allwmake index ddff417018..a16b5f9c81 100755 --- a/src/turbulenceModels/compressible/Allwmake +++ b/src/turbulenceModels/compressible/Allwmake @@ -2,8 +2,11 @@ cd ${0%/*} || exit 1 # run from this directory set -x -wmake libso turbulenceModel -wmake libso RAS -wmake libso LES +makeOption=libso +[ $# -ge 1 ] && makeOption=$1 + +wmake $makeOption turbulenceModel +wmake $makeOption RAS +wmake $makeOption LES # ----------------------------------------------------------------- end-of-file diff --git a/src/turbulenceModels/incompressible/Allwmake b/src/turbulenceModels/incompressible/Allwmake index ddff417018..a16b5f9c81 100755 --- a/src/turbulenceModels/incompressible/Allwmake +++ b/src/turbulenceModels/incompressible/Allwmake @@ -2,8 +2,11 @@ cd ${0%/*} || exit 1 # run from this directory set -x -wmake libso turbulenceModel -wmake libso RAS -wmake libso LES +makeOption=libso +[ $# -ge 1 ] && makeOption=$1 + +wmake $makeOption turbulenceModel +wmake $makeOption RAS +wmake $makeOption LES # ----------------------------------------------------------------- end-of-file From 07e356574d2b056e519839a72c63d0d38bc52fd2 Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 27 Jan 2011 13:01:19 +0000 Subject: [PATCH 019/367] STLE: tweaks to createGraph tutorial scripts --- .../combustion/chemFoam/gri/validation/createGraph | 11 ++++++----- .../combustion/chemFoam/h2/validation/createGraph | 11 ++++++----- .../chemFoam/ic8h18/validation/createGraph | 11 ++++++----- .../chemFoam/nc7h16/validation/createGraph | 13 +++++++------ 4 files changed, 25 insertions(+), 21 deletions(-) diff --git a/tutorials/combustion/chemFoam/gri/validation/createGraph b/tutorials/combustion/chemFoam/gri/validation/createGraph index 7f16367984..3cf8188623 100755 --- a/tutorials/combustion/chemFoam/gri/validation/createGraph +++ b/tutorials/combustion/chemFoam/gri/validation/createGraph @@ -1,16 +1,17 @@ #!/bin/sh gnuplot< Date: Thu, 27 Jan 2011 16:22:32 +0100 Subject: [PATCH 020/367] STYLE: set makeOption before 'set -x' (cleaner output) in Allwmake --- src/Allwmake | 4 +--- src/Pstream/Allwmake | 5 ++--- src/conversion/Allwmake | 4 +--- src/dummyThirdParty/Allwmake | 4 +--- src/fvAgglomerationMethods/Allwmake | 4 +--- src/lagrangian/Allwmake | 4 +--- src/lagrangian/molecularDynamics/Allwmake | 4 +--- src/mesh/Allwmake | 4 +--- src/parallel/Allwmake | 4 +--- src/parallel/decompose/Allwmake | 4 +--- src/parallel/reconstruct/Allwmake | 5 +---- src/postProcessing/Allwmake | 4 +--- src/postProcessing/functionObjects/Allwmake | 4 +--- src/thermophysicalModels/Allwmake | 4 +--- src/transportModels/Allwmake | 4 +--- src/turbulenceModels/LES/Allwmake | 4 +--- src/turbulenceModels/compressible/Allwmake | 4 +--- src/turbulenceModels/incompressible/Allwmake | 4 +--- 18 files changed, 19 insertions(+), 55 deletions(-) diff --git a/src/Allwmake b/src/Allwmake index c2815e58c8..00bbf8e5e6 100755 --- a/src/Allwmake +++ b/src/Allwmake @@ -1,8 +1,6 @@ #!/bin/sh cd ${0%/*} || exit 1 # run from this directory - -makeOption=libso -[ $# -ge 1 ] && makeOption=$1 +[ $# -ge 1 ] && makeOption=$1 || makeOption=libso wmakeCheckPwd "$WM_PROJECT_DIR/src" || { echo "Error: Current directory is not \$WM_PROJECT_DIR/src" diff --git a/src/Pstream/Allwmake b/src/Pstream/Allwmake index 7a2f2cd308..742d3d4478 100755 --- a/src/Pstream/Allwmake +++ b/src/Pstream/Allwmake @@ -1,10 +1,8 @@ #!/bin/sh cd ${0%/*} || exit 1 # run from this directory +[ $# -ge 1 ] && makeOption=$1 || makeOption=libso set -x -makeOption=libso -[ $# -ge 1 ] && makeOption=$1 - wmake $makeOption dummy case "$WM_MPLIB" in @@ -12,6 +10,7 @@ case "$WM_MPLIB" in set +x echo echo "Note: ignore spurious warnings about missing mpicxx.h headers" + echo set -x # force compilation into qualified directory WM_OPTIONS=${WM_OPTIONS}$WM_MPLIB wmake $makeOption mpi diff --git a/src/conversion/Allwmake b/src/conversion/Allwmake index cf1e61d47d..444d3f6549 100755 --- a/src/conversion/Allwmake +++ b/src/conversion/Allwmake @@ -1,10 +1,8 @@ #!/bin/sh cd ${0%/*} || exit 1 # run from this directory +[ $# -ge 1 ] && makeOption=$1 || makeOption=libso set -x -makeOption=libso -[ $# -ge 1 ] && makeOption=$1 - wmake $makeOption # ----------------------------------------------------------------- end-of-file diff --git a/src/dummyThirdParty/Allwmake b/src/dummyThirdParty/Allwmake index afd49cd5d9..5076d8d2b7 100755 --- a/src/dummyThirdParty/Allwmake +++ b/src/dummyThirdParty/Allwmake @@ -1,10 +1,8 @@ #!/bin/sh cd ${0%/*} || exit 1 # run from this directory +[ $# -ge 1 ] && makeOption=$1 || makeOption=libso set -x -makeOption=libso -[ $# -ge 1 ] && makeOption=$1 - wmake $makeOption scotchDecomp wmake $makeOption ptscotchDecomp wmake $makeOption metisDecomp diff --git a/src/fvAgglomerationMethods/Allwmake b/src/fvAgglomerationMethods/Allwmake index 27f2fea53a..fcccbcbe9a 100755 --- a/src/fvAgglomerationMethods/Allwmake +++ b/src/fvAgglomerationMethods/Allwmake @@ -1,10 +1,8 @@ #!/bin/sh cd ${0%/*} || exit 1 # run from this directory +[ $# -ge 1 ] && makeOption=$1 || makeOption=libso set -x -makeOption=libso -[ $# -ge 1 ] && makeOption=$1 - wmake $makeOption MGridGenGamgAgglomeration # ----------------------------------------------------------------- end-of-file diff --git a/src/lagrangian/Allwmake b/src/lagrangian/Allwmake index 26fd814f63..e04d7480fb 100755 --- a/src/lagrangian/Allwmake +++ b/src/lagrangian/Allwmake @@ -1,10 +1,8 @@ #!/bin/sh cd ${0%/*} || exit 1 # run from this directory +[ $# -ge 1 ] && makeOption=$1 || makeOption=libso set -x -makeOption=libso -[ $# -ge 1 ] && makeOption=$1 - wmake $makeOption basic wmake $makeOption solidParticle wmake $makeOption intermediate diff --git a/src/lagrangian/molecularDynamics/Allwmake b/src/lagrangian/molecularDynamics/Allwmake index 131ec5d458..60b24dea4d 100755 --- a/src/lagrangian/molecularDynamics/Allwmake +++ b/src/lagrangian/molecularDynamics/Allwmake @@ -1,10 +1,8 @@ #!/bin/sh cd ${0%/*} || exit 1 # run from this directory +[ $# -ge 1 ] && makeOption=$1 || makeOption=libso set -x -makeOption=libso -[ $# -ge 1 ] && makeOption=$1 - wmake $makeOption potential wmake $makeOption molecularMeasurements wmake $makeOption molecule diff --git a/src/mesh/Allwmake b/src/mesh/Allwmake index 57df2d57bf..f980e0e73f 100755 --- a/src/mesh/Allwmake +++ b/src/mesh/Allwmake @@ -1,10 +1,8 @@ #!/bin/sh cd ${0%/*} || exit 1 # run from this directory +[ $# -ge 1 ] && makeOption=$1 || makeOption=libso set -x -makeOption=libso -[ $# -ge 1 ] && makeOption=$1 - wmake $makeOption autoMesh wmake $makeOption blockMesh diff --git a/src/parallel/Allwmake b/src/parallel/Allwmake index 92d80e20a8..d3600e13b1 100755 --- a/src/parallel/Allwmake +++ b/src/parallel/Allwmake @@ -1,10 +1,8 @@ #!/bin/sh cd ${0%/*} || exit 1 # run from this directory +[ $# -ge 1 ] && makeOption=$1 || makeOption=libso set -x -makeOption=libso -[ $# -ge 1 ] && makeOption=$1 - decompose/Allwmake $* reconstruct/Allwmake $* wmake $makeOption distributed diff --git a/src/parallel/decompose/Allwmake b/src/parallel/decompose/Allwmake index 93835f6a24..3848e66478 100755 --- a/src/parallel/decompose/Allwmake +++ b/src/parallel/decompose/Allwmake @@ -1,8 +1,6 @@ #!/bin/sh cd ${0%/*} || exit 1 # run from this directory - -makeOption=libso -[ $# -ge 1 ] && makeOption=$1 +[ $# -ge 1 ] && makeOption=$1 || makeOption=libso # get SCOTCH_VERSION, SCOTCH_ARCH_PATH settings=`$WM_PROJECT_DIR/bin/foamEtcFile apps/scotch/bashrc` diff --git a/src/parallel/reconstruct/Allwmake b/src/parallel/reconstruct/Allwmake index 453d88f50b..3d651d5a00 100755 --- a/src/parallel/reconstruct/Allwmake +++ b/src/parallel/reconstruct/Allwmake @@ -1,11 +1,8 @@ #!/bin/sh cd ${0%/*} || exit 1 # run from this directory +[ $# -ge 1 ] && makeOption=$1 || makeOption=libso set -x -makeOption=libso -[ $# -ge 1 ] && makeOption=$1 - wmake $makeOption reconstruct - # ----------------------------------------------------------------- end-of-file diff --git a/src/postProcessing/Allwmake b/src/postProcessing/Allwmake index d543c26fe1..5a1caf1660 100755 --- a/src/postProcessing/Allwmake +++ b/src/postProcessing/Allwmake @@ -1,10 +1,8 @@ #!/bin/sh cd ${0%/*} || exit 1 # run from this directory +[ $# -ge 1 ] && makeOption=$1 || makeOption=libso set -x -makeOption=libso -[ $# -ge 1 ] && makeOption=$1 - wmake libo postCalc wmake $makeOption foamCalcFunctions diff --git a/src/postProcessing/functionObjects/Allwmake b/src/postProcessing/functionObjects/Allwmake index 14bdd330e1..9ae9bd3dca 100755 --- a/src/postProcessing/functionObjects/Allwmake +++ b/src/postProcessing/functionObjects/Allwmake @@ -1,10 +1,8 @@ #!/bin/sh cd ${0%/*} || exit 1 # run from this directory +[ $# -ge 1 ] && makeOption=$1 || makeOption=libso set -x -makeOption=libso -[ $# -ge 1 ] && makeOption=$1 - wmake $makeOption field wmake $makeOption forces wmake $makeOption IO diff --git a/src/thermophysicalModels/Allwmake b/src/thermophysicalModels/Allwmake index e622e3c15b..0695c1fba4 100755 --- a/src/thermophysicalModels/Allwmake +++ b/src/thermophysicalModels/Allwmake @@ -1,10 +1,8 @@ #!/bin/sh cd ${0%/*} || exit 1 # run from this directory +[ $# -ge 1 ] && makeOption=$1 || makeOption=libso set -x -makeOption=libso -[ $# -ge 1 ] && makeOption=$1 - wmake $makeOption specie wmake $makeOption solid wmake $makeOption thermophysicalFunctions diff --git a/src/transportModels/Allwmake b/src/transportModels/Allwmake index 703920418d..f0eba94263 100755 --- a/src/transportModels/Allwmake +++ b/src/transportModels/Allwmake @@ -1,10 +1,8 @@ #!/bin/sh cd ${0%/*} || exit 1 # run from this directory +[ $# -ge 1 ] && makeOption=$1 || makeOption=libso set -x -makeOption=libso -[ $# -ge 1 ] && makeOption=$1 - wmake $makeOption incompressible wmake $makeOption interfaceProperties wmake $makeOption twoPhaseInterfaceProperties diff --git a/src/turbulenceModels/LES/Allwmake b/src/turbulenceModels/LES/Allwmake index 107251b422..d24309692e 100755 --- a/src/turbulenceModels/LES/Allwmake +++ b/src/turbulenceModels/LES/Allwmake @@ -1,10 +1,8 @@ #!/bin/sh cd ${0%/*} || exit 1 # run from this directory +[ $# -ge 1 ] && makeOption=$1 || makeOption=libso set -x -makeOption=libso -[ $# -ge 1 ] && makeOption=$1 - wmakeLnInclude ../incompressible/LES wmake $makeOption LESfilters diff --git a/src/turbulenceModels/compressible/Allwmake b/src/turbulenceModels/compressible/Allwmake index a16b5f9c81..60605f926d 100755 --- a/src/turbulenceModels/compressible/Allwmake +++ b/src/turbulenceModels/compressible/Allwmake @@ -1,10 +1,8 @@ #!/bin/sh cd ${0%/*} || exit 1 # run from this directory +[ $# -ge 1 ] && makeOption=$1 || makeOption=libso set -x -makeOption=libso -[ $# -ge 1 ] && makeOption=$1 - wmake $makeOption turbulenceModel wmake $makeOption RAS wmake $makeOption LES diff --git a/src/turbulenceModels/incompressible/Allwmake b/src/turbulenceModels/incompressible/Allwmake index a16b5f9c81..60605f926d 100755 --- a/src/turbulenceModels/incompressible/Allwmake +++ b/src/turbulenceModels/incompressible/Allwmake @@ -1,10 +1,8 @@ #!/bin/sh cd ${0%/*} || exit 1 # run from this directory +[ $# -ge 1 ] && makeOption=$1 || makeOption=libso set -x -makeOption=libso -[ $# -ge 1 ] && makeOption=$1 - wmake $makeOption turbulenceModel wmake $makeOption RAS wmake $makeOption LES From d93f3195e69492d854b7a29689d007277e5f166a Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Thu, 27 Jan 2011 16:41:53 +0100 Subject: [PATCH 021/367] STYLE: use 1-col alphabetical output in reworked doxygen output - avoids overflows in a fixed width boxes --- doc/doxygen/Allwmake | 8 ++++++++ doc/doxygen/Doxyfile | 2 +- doc/doxygen/_Footer | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/doc/doxygen/Allwmake b/doc/doxygen/Allwmake index a34eb3fd7e..fbc20d93fd 100755 --- a/doc/doxygen/Allwmake +++ b/doc/doxygen/Allwmake @@ -1,5 +1,13 @@ #!/bin/sh cd ${0%/*} || exit 1 # run from this directory + +[ -d "$WM_PROJECT_DIR" ] || { + echo "Error: WM_PROJECT_DIR directory does not exist" + echo " Check the OpenFOAM entries in your dot-files and source them." + echo " WM_PROJECT_DIR=$WM_PROJECT_DIR" + exit 1 +} + set -x rm -rf latex man diff --git a/doc/doxygen/Doxyfile b/doc/doxygen/Doxyfile index 51a8ae2b50..a1c4e6a5fc 100644 --- a/doc/doxygen/Doxyfile +++ b/doc/doxygen/Doxyfile @@ -760,7 +760,7 @@ ALPHABETICAL_INDEX = YES # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) -COLS_IN_ALPHA_INDEX = 4 +COLS_IN_ALPHA_INDEX = 1 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. diff --git a/doc/doxygen/_Footer b/doc/doxygen/_Footer index 11d8da9cb5..f68739e803 100644 --- a/doc/doxygen/_Footer +++ b/doc/doxygen/_Footer @@ -2,7 +2,7 @@