From 0d8fff3a5f31df3e1f7ab91d0652cda3a04dbf32 Mon Sep 17 00:00:00 2001 From: mattijs Date: Sat, 17 Aug 2013 05:28:31 +0100 Subject: [PATCH 01/34] ENH: codeStream: function in dictionary context --- .../functionEntries/codeStream/codeStream.C | 40 +++++++++++++++++++ .../functionEntries/codeStream/codeStream.H | 6 ++- 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C index 66065c4528..1c774c352b 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C +++ b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.C @@ -39,6 +39,14 @@ namespace functionEntries { defineTypeNameAndDebug(codeStream, 0); + addToMemberFunctionSelectionTable + ( + functionEntry, + codeStream, + execute, + dictionaryIstream + ); + addToMemberFunctionSelectionTable ( functionEntry, @@ -364,6 +372,38 @@ bool Foam::functionEntries::codeStream::execute IStringStream resultStream(os.str()); entry.read(parentDict, resultStream); + return true; +} + + +bool Foam::functionEntries::codeStream::execute +( + dictionary& parentDict, + Istream& is +) +{ + Info<< "Using #codeStream at line " << is.lineNumber() + << " in file " << parentDict.name() << endl; + + dynamicCode::checkSecurity + ( + "functionEntries::codeStream::execute(..)", + parentDict + ); + + // get code dictionary + // must reference parent for stringOps::expand to work nicely + dictionary codeDict("#codeStream", parentDict, is); + + streamingFunctionType function = getFunction(parentDict, codeDict); + + // use function to write stream + OStringStream os(is.format()); + (*function)(os, parentDict); + + // get the entry from this stream + IStringStream resultStream(os.str()); + parentDict.read(resultStream); return true; } diff --git a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.H b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.H index b8baa0183c..1dc2b57c87 100644 --- a/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.H +++ b/src/OpenFOAM/db/dictionary/functionEntries/codeStream/codeStream.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -160,6 +160,10 @@ public: // Member Functions + //- Execute the functionEntry in a sub-dict context + static bool execute(dictionary& parentDict, Istream&); + + //- Execute the functionEntry in a primitiveEntry context static bool execute ( const dictionary& parentDict, From 331368b308b007d584ec564f4426564fa51187b2 Mon Sep 17 00:00:00 2001 From: mattijs Date: Sat, 17 Aug 2013 05:36:14 +0100 Subject: [PATCH 02/34] STYLE: topoSet: unused code --- src/meshTools/sets/topoSets/topoSet.C | 23 ----------------------- 1 file changed, 23 deletions(-) diff --git a/src/meshTools/sets/topoSets/topoSet.C b/src/meshTools/sets/topoSets/topoSet.C index 37fe9a0595..691339102a 100644 --- a/src/meshTools/sets/topoSets/topoSet.C +++ b/src/meshTools/sets/topoSets/topoSet.C @@ -472,7 +472,6 @@ void Foam::topoSet::invert(const label maxLen) insert(cellI); } } - } @@ -550,20 +549,6 @@ void Foam::topoSet::writeDebug(Ostream& os, const label maxLen) const } -//void Foam::topoSet::writeDebug -//( -// Ostream&, -// const primitiveMesh&, -// const label -//) const -//{ -// notImplemented -// ( -// "topoSet::writeDebug(Ostream&, const primitiveMesh&, const label)" -// ); -//} - - bool Foam::topoSet::writeData(Ostream& os) const { return (os << *this).good(); @@ -576,14 +561,6 @@ void Foam::topoSet::updateMesh(const mapPolyMesh&) } -////- Return max index+1. -//label topoSet::maxSize(const polyMesh&) const -//{ -// notImplemented("topoSet::maxSize(const polyMesh&)"); -// -// return -1; -//} - // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // void Foam::topoSet::operator=(const topoSet& rhs) From 00e73a488b3de2b31bc6204802a3946e1e9af54e Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 20 Aug 2013 09:50:05 +0100 Subject: [PATCH 03/34] BUG: CSV data entry - corrected writing - mantis #971 --- .../primitives/functions/DataEntry/CSV/CSVIO.C | 11 ++++++----- tutorials/incompressible/icoFoam/cavity/0/U | 13 +++++++++++-- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSVIO.C b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSVIO.C index 1dd395cee0..778de9a92f 100644 --- a/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSVIO.C +++ b/src/OpenFOAM/primitives/functions/DataEntry/CSV/CSVIO.C @@ -50,10 +50,7 @@ Foam::Ostream& Foam::operator<< } // Check state of Ostream - os.check - ( - "Ostream& operator<<(Ostream&, const CSV&)" - ); + os.check("Ostream& operator<<(Ostream&, const CSV&)"); return os; } @@ -83,11 +80,15 @@ void Foam::CSV::writeData(Ostream& os) const os << componentColumns_; os.format(IOstream::BINARY); } + else + { + os << componentColumns_; + } os << token::END_STATEMENT << nl; os.writeKeyword("separator") << string(separator_) << token::END_STATEMENT << nl; - os.writeKeyword("mergeSeparators") << string(mergeSeparators_) + os.writeKeyword("mergeSeparators") << mergeSeparators_ << token::END_STATEMENT << nl; os.writeKeyword("fileName") << fName_ << token::END_STATEMENT << nl; os << decrIndent << indent << token::END_BLOCK << endl; diff --git a/tutorials/incompressible/icoFoam/cavity/0/U b/tutorials/incompressible/icoFoam/cavity/0/U index 711702f987..21b0d542ec 100644 --- a/tutorials/incompressible/icoFoam/cavity/0/U +++ b/tutorials/incompressible/icoFoam/cavity/0/U @@ -22,8 +22,17 @@ boundaryField { movingWall { - type fixedValue; - value uniform (1 0 0); + type uniformFixedValue; + uniformValue csvFile; + csvFileCoeffs + { + nHeaderLine 1; + refColumn 0; + componentColumns (1 2 3); + mergeSeparators no; + fileName "$FOAM_CASE/csvData"; + separator " "; + } } fixedWalls From 0c06f77fa0625c4c8ff390f0f948ef16ad0e3bbd Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 20 Aug 2013 15:08:30 +0100 Subject: [PATCH 04/34] STYLE: Minor code formatting --- .../HeatTransferModel/HeatTransferModel/HeatTransferModel.C | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/HeatTransferModel/HeatTransferModel.C b/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/HeatTransferModel/HeatTransferModel.C index abfdc581ac..870dc31ffc 100644 --- a/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/HeatTransferModel/HeatTransferModel.C +++ b/src/lagrangian/intermediate/submodels/Thermodynamic/HeatTransferModel/HeatTransferModel/HeatTransferModel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -59,7 +59,6 @@ Foam::HeatTransferModel::HeatTransferModel {} - // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // template From 77d47e9125037430ca82873b3896d07897ee2120 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 20 Aug 2013 16:01:18 +0100 Subject: [PATCH 05/34] ENH: surfaceToCell: use surface orientation --- .../advanced/autoRefineMesh/autoRefineMesh.C | 7 +-- .../mesh/manipulation/topoSet/topoSetDict | 3 ++ .../cellSources/surfaceToCell/surfaceToCell.C | 52 +++++++++++++++++-- .../cellSources/surfaceToCell/surfaceToCell.H | 26 ++++++---- 4 files changed, 72 insertions(+), 16 deletions(-) diff --git a/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMesh.C b/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMesh.C index 44a02e234a..2a958b3a3c 100644 --- a/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMesh.C +++ b/applications/utilities/mesh/advanced/autoRefineMesh/autoRefineMesh.C @@ -269,9 +269,10 @@ void selectCurvatureCells querySurf.surface(), querySurf, pointField(1, mesh.cellCentres()[0]), - false, - false, - false, + false, // includeCut + false, // includeInside + false, // includeOutside + false, // geometricOnly nearDist, curvature ); diff --git a/applications/utilities/mesh/manipulation/topoSet/topoSetDict b/applications/utilities/mesh/manipulation/topoSet/topoSetDict index 11dccf942b..9dee4d1df9 100644 --- a/applications/utilities/mesh/manipulation/topoSet/topoSetDict +++ b/applications/utilities/mesh/manipulation/topoSet/topoSetDict @@ -143,6 +143,9 @@ FoamFile // sourceInfo // { // file "www.avl.com-geometry.stl"; +// useSurfaceOrientation false; // use closed surface inside/outside +// // test (ignores includeCut, +// // outsidePoints) // outsidePoints ((-99 -99 -59)); // definition of outside // includeCut false; // cells cut by surface // includeInside false; // cells not on outside of surf diff --git a/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.C b/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.C index ff37610fad..f4a0009028 100644 --- a/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.C +++ b/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.C @@ -157,7 +157,30 @@ void Foam::surfaceToCell::combine(topoSet& set, const bool add) const { cpuTime timer; - if (includeCut_ || includeInside_ || includeOutside_) + + if (useSurfaceOrientation_ && (includeInside_ || includeOutside_)) + { + const meshSearch queryMesh(mesh_); + + //- Calculate for each searchPoint inside/outside status. + boolList isInside(querySurf().calcInside(mesh_.cellCentres())); + + Info<< " Marked inside/outside using surface orientation in = " + << timer.cpuTimeIncrement() << " s" << endl << endl; + + forAll(isInside, cellI) + { + if (isInside[cellI] && includeInside_) + { + addOrDelete(set, cellI, add); + } + else if (!isInside[cellI] && includeOutside_) + { + addOrDelete(set, cellI, add); + } + } + } + else if (includeCut_ || includeInside_ || includeOutside_) { // // Cut cells with surface and classify cells @@ -166,7 +189,7 @@ void Foam::surfaceToCell::combine(topoSet& set, const bool add) const // Construct search engine on mesh - meshSearch queryMesh(mesh_); + const meshSearch queryMesh(mesh_); // Check all 'outside' points @@ -196,10 +219,10 @@ void Foam::surfaceToCell::combine(topoSet& set, const bool add) const ); - Info<< " Marked inside/outside in = " + Info<< " Marked inside/outside using surface intersection in = " << timer.cpuTimeIncrement() << " s" << endl << endl; - + //- Add/remove cells using set forAll(cellType, cellI) { label cType = cellType[cellI]; @@ -326,6 +349,18 @@ void Foam::surfaceToCell::checkSettings() const << " or set curvature to a value -1 .. 1." << exit(FatalError); } + + if (useSurfaceOrientation_ && includeCut_) + { + FatalErrorIn + ( + "surfaceToCell:checkSettings()" + ) << "Illegal include cell specification." + << " You cannot specify both 'useSurfaceOrientation'" + << " and 'includeCut'" + << " since 'includeCut' specifies a topological split" + << exit(FatalError); + } } @@ -340,6 +375,7 @@ Foam::surfaceToCell::surfaceToCell const bool includeCut, const bool includeInside, const bool includeOutside, + const bool useSurfaceOrientation, const scalar nearDist, const scalar curvature ) @@ -350,6 +386,7 @@ Foam::surfaceToCell::surfaceToCell includeCut_(includeCut), includeInside_(includeInside), includeOutside_(includeOutside), + useSurfaceOrientation_(useSurfaceOrientation), nearDist_(nearDist), curvature_(curvature), surfPtr_(new triSurface(surfName_)), @@ -371,6 +408,7 @@ Foam::surfaceToCell::surfaceToCell const bool includeCut, const bool includeInside, const bool includeOutside, + const bool useSurfaceOrientation, const scalar nearDist, const scalar curvature ) @@ -381,6 +419,7 @@ Foam::surfaceToCell::surfaceToCell includeCut_(includeCut), includeInside_(includeInside), includeOutside_(includeOutside), + useSurfaceOrientation_(useSurfaceOrientation), nearDist_(nearDist), curvature_(curvature), surfPtr_(&surf), @@ -404,6 +443,10 @@ Foam::surfaceToCell::surfaceToCell includeCut_(readBool(dict.lookup("includeCut"))), includeInside_(readBool(dict.lookup("includeInside"))), includeOutside_(readBool(dict.lookup("includeOutside"))), + useSurfaceOrientation_ + ( + dict.lookupOrDefault("useSurfaceOrientation", false) + ), nearDist_(readScalar(dict.lookup("nearDistance"))), curvature_(readScalar(dict.lookup("curvature"))), surfPtr_(new triSurface(surfName_)), @@ -427,6 +470,7 @@ Foam::surfaceToCell::surfaceToCell includeCut_(readBool(checkIs(is))), includeInside_(readBool(checkIs(is))), includeOutside_(readBool(checkIs(is))), + useSurfaceOrientation_(false), nearDist_(readScalar(checkIs(is))), curvature_(readScalar(checkIs(is))), surfPtr_(new triSurface(surfName_)), diff --git a/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.H b/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.H index cfaf80dd30..931f412a2a 100644 --- a/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.H +++ b/src/meshTools/sets/cellSources/surfaceToCell/surfaceToCell.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,6 +29,8 @@ Description Selects: - all cells inside/outside/cut by surface + - all cells inside/outside surface ('useSurfaceOrientation', requires closed + surface) - cells with centre nearer than XXX to surface - cells with centre nearer than XXX to surface \b and with normal at nearest point to centre and cell-corners differing by @@ -67,27 +69,31 @@ class surfaceToCell static addToUsageTable usage_; //- Name of surface file - fileName surfName_; + const fileName surfName_; //- Points which are outside - pointField outsidePoints_; + const pointField outsidePoints_; //- Include cut cells - bool includeCut_; + const bool includeCut_; //- Include inside cells - bool includeInside_; + const bool includeInside_; //- Include outside cells - bool includeOutside_; + const bool includeOutside_; + + //- Determine inside/outside purely using geometric test + // (does not allow includeCut) + const bool useSurfaceOrientation_; //- if > 0 : include cells with distance from cellCentre to surface // less than nearDist. - scalar nearDist_; + const scalar nearDist_; //- if > -1 : include cells with normals at nearest surface points // varying more than curvature_. - scalar curvature_; + const scalar curvature_; //- triSurface to search on. On pointer since can be external. const triSurface* surfPtr_; @@ -97,7 +103,7 @@ class surfaceToCell //- whether I allocated above surface ptrs or whether they are // external. - bool IOwnPtrs_; + const bool IOwnPtrs_; // Private Member Functions @@ -155,6 +161,7 @@ public: const bool includeCut, const bool includeInside, const bool includeOutside, + const bool useSurfaceOrientation, const scalar nearDist, const scalar curvature ); @@ -170,6 +177,7 @@ public: const bool includeCut, const bool includeInside, const bool includeOutside, + const bool useSurfaceOrientation, const scalar nearDist, const scalar curvature ); From 664a431886eba3eed9f575e51ff046642217732a Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 22 Aug 2013 16:36:35 +0100 Subject: [PATCH 06/34] BUG: changeDictionaryDict - always write boundary file uncompressed --- .../preProcessing/changeDictionary/changeDictionary.C | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/applications/utilities/preProcessing/changeDictionary/changeDictionary.C b/applications/utilities/preProcessing/changeDictionary/changeDictionary.C index a53a6142cf..a6b18b6114 100644 --- a/applications/utilities/preProcessing/changeDictionary/changeDictionary.C +++ b/applications/utilities/preProcessing/changeDictionary/changeDictionary.C @@ -602,8 +602,13 @@ int main(int argc, char *argv[]) dictList.set(sz++, iter().clone()); } - Info<< "Writing modified fieldDict " << fieldName << endl; - dictList.write(); + Info<< "Writing modified " << fieldName << endl; + dictList.writeObject + ( + runTime.writeFormat(), + runTime.writeFormat(), + IOstream::UNCOMPRESSED + ); } else { From f8b0192a4a5e1bdfdd9a42002213a73610eafb75 Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 23 Aug 2013 09:48:25 +0100 Subject: [PATCH 07/34] ENH: kinematic film - updated output for film thickness extrema --- .../kinematicSingleLayer/kinematicSingleLayer.C | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C b/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C index 2f99a1872d..50d1c7c1ef 100644 --- a/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C +++ b/src/regionModels/surfaceFilmModels/kinematicSingleLayer/kinematicSingleLayer.C @@ -1049,6 +1049,7 @@ void kinematicSingleLayer::info() const { Info<< "\nSurface film: " << type() << endl; + const scalarField& deltaInternal = delta_.internalField(); const vectorField& Uinternal = U_.internalField(); Info<< indent << "added mass = " @@ -1057,8 +1058,8 @@ void kinematicSingleLayer::info() const << gSum((deltaRho_*magSf())()) << nl << indent << "min/max(mag(U)) = " << gMin(mag(Uinternal)) << ", " << gMax(mag(Uinternal)) << nl - << indent << "min/max(delta) = " << min(delta_).value() << ", " - << max(delta_).value() << nl + << indent << "min/max(delta) = " << gMin(deltaInternal) << ", " + << gMax(deltaInternal) << nl << indent << "coverage = " << gSum(alpha_.internalField()*magSf())/gSum(magSf()) << nl; From b36637443a37aecda36375ef933648cad4340dd7 Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 23 Aug 2013 10:47:56 +0100 Subject: [PATCH 08/34] ENH: Updated particle collector cloud function object output --- .../ParticleCollector/ParticleCollector.C | 42 ++++++++++--------- 1 file changed, 23 insertions(+), 19 deletions(-) diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleCollector/ParticleCollector.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleCollector/ParticleCollector.C index 68d19890dd..a8003d43be 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleCollector/ParticleCollector.C +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/ParticleCollector/ParticleCollector.C @@ -64,31 +64,40 @@ void Foam::ParticleCollector::makeLogFile outputFilePtr_() << "# Source : " << type() << nl + << "# Bins : " << faces.size() << nl << "# Total area : " << sum(area) << nl; - outputFilePtr_() << "# Geometry :" << nl; + outputFilePtr_() + << "# Geometry :" << nl + << '#' + << tab << "Bin" + << tab << "(Centre_x Centre_y Centre_z)" + << tab << "Area" + << nl; + forAll(faces, i) { - word id = Foam::name(i); - outputFilePtr_() - << '#' << tab << "point[" << id << "] = " - << faces[i].centre(points) << nl; + << '#' + << tab << i + << tab << faces[i].centre(points) + << tab << area[i] + << nl; } - outputFilePtr_()<< '#' << nl << "# Time"; + outputFilePtr_() + << '#' << nl + << "# Output format:" << nl; forAll(faces, i) { word id = Foam::name(i); - - if (i != 0) - { - outputFilePtr_() << "#"; - } + word binId = "bin_" + id; outputFilePtr_() - << tab << "area[" << id << "]" + << '#' + << tab << "Time" + << tab << binId << tab << "mass[" << id << "]" << tab << "massFlowRate[" << id << "]" << endl; @@ -406,12 +415,6 @@ void Foam::ParticleCollector::write() Info<< type() << " output:" << nl; - if (outputFilePtr_.valid()) - { - outputFilePtr_() << time.timeName(); - } - - Field faceMassTotal(mass_.size(), 0.0); this->getModelProperty("massTotal", faceMassTotal); @@ -439,7 +442,8 @@ void Foam::ParticleCollector::write() if (outputFilePtr_.valid()) { outputFilePtr_() - << tab << area_[faceI] + << time.timeName() + << tab << faceI << tab << faceMassTotal[faceI] << tab << faceMassFlowRate[faceI] << endl; From d021166d87182b52668a4e3c5c489202e07bb500 Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 23 Aug 2013 10:56:34 +0100 Subject: [PATCH 09/34] ENH: Tutorial update --- .../reactingParcelFoam/filter/constant/reactingCloud1Properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/lagrangian/reactingParcelFoam/filter/constant/reactingCloud1Properties b/tutorials/lagrangian/reactingParcelFoam/filter/constant/reactingCloud1Properties index 94ede2729a..2ba702faa8 100644 --- a/tutorials/lagrangian/reactingParcelFoam/filter/constant/reactingCloud1Properties +++ b/tutorials/lagrangian/reactingParcelFoam/filter/constant/reactingCloud1Properties @@ -41,7 +41,7 @@ solution thermo:mu cell; T cell; Cp cell; - kapppa cell; + kappa cell; p cell; } From 6adba987a2cff3f54f8d5d9eac299ab3a1214876 Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 23 Aug 2013 13:38:33 +0100 Subject: [PATCH 10/34] ENH: Updated cloud for topology change in parallel --- .../clouds/Templates/KinematicCloud/KinematicCloud.C | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C index acf9e8c235..7cab777680 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloud.C @@ -652,7 +652,11 @@ void Foam::KinematicCloud::scaleSources() template void Foam::KinematicCloud::preEvolve() { - Info<< "\nSolving cloud " << this->name() << endl; + // force calculaion of mesh dimensions - needed for parallel runs + // with topology change due to lazy evaluation of valid mesh dimensions + label nGeometricD = mesh_.nGeometricD(); + + Info<< "\nSolving " << nGeometricD << "-D cloud " << this->name() << endl; this->dispersion().cacheFields(true); forces_.cacheFields(true); From 7c3d2ec15eaf88998cbf61ac014617029f8f0018 Mon Sep 17 00:00:00 2001 From: andy Date: Fri, 23 Aug 2013 14:19:32 +0100 Subject: [PATCH 11/34] ENH: Updated R utility to include compressible cases --- .../postProcessing/turbulence/R/Make/options | 18 ++- .../utilities/postProcessing/turbulence/R/R.C | 141 +++++++++++++++--- .../turbulence/R/createFields.H | 22 --- 3 files changed, 135 insertions(+), 46 deletions(-) delete mode 100644 applications/utilities/postProcessing/turbulence/R/createFields.H diff --git a/applications/utilities/postProcessing/turbulence/R/Make/options b/applications/utilities/postProcessing/turbulence/R/Make/options index a136b16661..27b70cae0a 100644 --- a/applications/utilities/postProcessing/turbulence/R/Make/options +++ b/applications/utilities/postProcessing/turbulence/R/Make/options @@ -1,13 +1,19 @@ EXE_INC = \ - -I$(LIB_SRC)/postProcessing/postCalc \ - -I$(LIB_SRC)/turbulenceModels \ - -I$(LIB_SRC)/turbulenceModels/incompressible/RAS/RASModel \ + -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/transportModels \ + -I$(LIB_SRC)/turbulenceModels \ + -I$(LIB_SRC)/turbulenceModels/compressible/RAS/derivedFvPatchFields/wallFunctions/mutWallFunctions \ + -I$(LIB_SRC)/turbulenceModels/incompressible/RAS/derivedFvPatchFields/wallFunctions/nutWallFunctions \ + -I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude EXE_LIBS = \ - $(FOAM_LIBBIN)/postCalc.o \ - -lincompressibleRASModels \ -lincompressibleTransportModels \ + -lincompressibleRASModels \ + -lfluidThermophysicalModels \ + -lspecie \ + -lcompressibleRASModels \ -lfiniteVolume \ - -lgenericPatchFields + -lgenericPatchFields \ + -lmeshTools \ + -lsampling diff --git a/applications/utilities/postProcessing/turbulence/R/R.C b/applications/utilities/postProcessing/turbulence/R/R.C index b96bb03947..708cda7214 100644 --- a/applications/utilities/postProcessing/turbulence/R/R.C +++ b/applications/utilities/postProcessing/turbulence/R/R.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,35 +29,140 @@ Description \*---------------------------------------------------------------------------*/ -#include "calc.H" #include "fvCFD.H" #include "incompressible/singlePhaseTransportModel/singlePhaseTransportModel.H" -#include "RASModel.H" +#include "incompressible/turbulenceModel/turbulenceModel.H" + +#include "fluidThermo.H" +#include "compressible/turbulenceModel/turbulenceModel.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -void Foam::calc(const argList& args, const Time& runTime, const fvMesh& mesh) +void calcIncompressibleR +( + const fvMesh& mesh, + const Time& runTime, + const volVectorField& U +) { - #include "createFields.H" + #include "createPhi.H" - Info<< "\nCalculating the Reynolds Stress R\n" << endl; + singlePhaseTransportModel laminarTransport(U, phi); - volSymmTensorField R + autoPtr model ( - IOobject - ( - "R", - runTime.timeName(), - mesh, - IOobject::NO_READ, - IOobject::AUTO_WRITE - ), - RASModel->R() + incompressible::turbulenceModel::New(U, phi, laminarTransport) ); - R.write(); + Info<< "Writing R field" << nl << endl; - Info<< "End" << endl; + model->R()().write(); +} + + +void calcCompressibleR +( + const fvMesh& mesh, + const Time& runTime, + const volVectorField& U +) +{ + IOobject rhoHeader + ( + "rho", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if (!rhoHeader.headerOk()) + { + Info<< " no " << rhoHeader.name() <<" field" << endl; + return; + } + + Info<< "Reading field rho\n" << endl; + volScalarField rho(rhoHeader, mesh); + + #include "compressibleCreatePhi.H" + + autoPtr pThermo(fluidThermo::New(mesh)); + fluidThermo& thermo = pThermo(); + + autoPtr model + ( + compressible::turbulenceModel::New + ( + rho, + U, + phi, + thermo + ) + ); + + Info<< "Writing R field" << nl << endl; + + model->R()().write(); +} + + +int main(int argc, char *argv[]) +{ + timeSelector::addOptions(); + + #include "addRegionOption.H" + + argList::addBoolOption + ( + "compressible", + "calculate compressible R" + ); + + #include "setRootCase.H" + #include "createTime.H" + instantList timeDirs = timeSelector::select0(runTime, args); + #include "createNamedMesh.H" + + const bool compressible = args.optionFound("compressible"); + + forAll(timeDirs, timeI) + { + runTime.setTime(timeDirs[timeI], timeI); + Info<< "Time = " << runTime.timeName() << endl; + + IOobject UHeader + ( + "U", + runTime.timeName(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ); + + if (UHeader.headerOk()) + { + Info<< "Reading field " << UHeader.name() << nl << endl; + volVectorField U(UHeader, mesh); + + if (compressible) + { + calcCompressibleR(mesh, runTime, U); + } + else + { + calcIncompressibleR(mesh, runTime, U); + } + } + else + { + Info<< " no " << UHeader.name() << " field" << endl; + } + } + + Info<< "End\n" << endl; + + return 0; } diff --git a/applications/utilities/postProcessing/turbulence/R/createFields.H b/applications/utilities/postProcessing/turbulence/R/createFields.H deleted file mode 100644 index 7c07f44f8b..0000000000 --- a/applications/utilities/postProcessing/turbulence/R/createFields.H +++ /dev/null @@ -1,22 +0,0 @@ - Info<< "Reading field U\n" << endl; - volVectorField U - ( - IOobject - ( - "U", - runTime.timeName(), - mesh, - IOobject::MUST_READ, - IOobject::AUTO_WRITE - ), - mesh - ); - - #include "createPhi.H" - - singlePhaseTransportModel laminarTransport(U, phi); - - autoPtr RASModel - ( - incompressible::RASModel::New(U, phi, laminarTransport) - ); From 2cc2770530d4f11b33bb2bfb0d2ddffa83933b7e Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 23 Aug 2013 16:20:42 +0100 Subject: [PATCH 12/34] multiphaseEulerFoam: Avoid cyclic linkage dependency --- .../multiphase/multiphaseEulerFoam/multiphaseSystem/Make/options | 1 - 1 file changed, 1 deletion(-) diff --git a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/Make/options b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/Make/options index ce7e7a2d85..68bcd9ef06 100644 --- a/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/Make/options +++ b/applications/solvers/multiphase/multiphaseEulerFoam/multiphaseSystem/Make/options @@ -10,5 +10,4 @@ EXE_INC = \ LIB_LIBS = \ -linterfaceProperties \ -lincompressibleTransportModels \ - -lcompressibleMultiphaseEulerianInterfacialModels \ -lfiniteVolume From 2f04e9754b683472baac761ace02d111a4f69eef Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 27 Aug 2013 11:22:27 +0100 Subject: [PATCH 13/34] ENH: Updated error messages --- .../StandardWallInteraction/StandardWallInteraction.C | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/StandardWallInteraction/StandardWallInteraction.C b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/StandardWallInteraction/StandardWallInteraction.C index d9b38daccf..fa86f67ca9 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/StandardWallInteraction/StandardWallInteraction.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/PatchInteractionModel/StandardWallInteraction/StandardWallInteraction.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -57,7 +57,7 @@ Foam::StandardWallInteraction::StandardWallInteraction "StandardWallInteraction::StandardWallInteraction" "(" "const dictionary&, " - "CloudType& cloud" + "CloudType&" ")" ) << "Unknown interaction result type " << interactionTypeName @@ -174,10 +174,11 @@ bool Foam::StandardWallInteraction::correct ( "bool StandardWallInteraction::correct" "(" + "typename CloudType::parcelType&, " "const polyPatch&, " - "const label, " - "bool&, " - "vector&" + "bool& keepParticle, " + "const scalar, " + "const tetIndices&" ") const" ) << "Unknown interaction type " << this->interactionTypeToWord(interactionType_) From 6a1b56732771973dfd1ee7ef7b8551959c59eeb7 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 27 Aug 2013 18:11:13 +0100 Subject: [PATCH 14/34] ENH: Cloud tracking - handle case where tracking stalls due to stepFraction --- src/lagrangian/basic/particle/particle.C | 4 ++- src/lagrangian/basic/particle/particle.H | 3 ++ .../KinematicParcel/KinematicParcel.C | 30 ++++++++++++++----- 3 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/lagrangian/basic/particle/particle.C b/src/lagrangian/basic/particle/particle.C index 8ffb988d45..c71559d042 100644 --- a/src/lagrangian/basic/particle/particle.C +++ b/src/lagrangian/basic/particle/particle.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -34,6 +34,8 @@ const Foam::scalar Foam::particle::trackingCorrectionTol = 1e-5; const Foam::scalar Foam::particle::lambdaDistanceToleranceCoeff = 1e3*SMALL; +const Foam::scalar Foam::particle::minStepFractionTol = 1e5*SMALL; + namespace Foam { defineTypeNameAndDebug(particle, 0); diff --git a/src/lagrangian/basic/particle/particle.H b/src/lagrangian/basic/particle/particle.H index 15742cacc9..0275cc5fd1 100644 --- a/src/lagrangian/basic/particle/particle.H +++ b/src/lagrangian/basic/particle/particle.H @@ -307,6 +307,9 @@ public: // for the denominator and numerator of lambda static const scalar lambdaDistanceToleranceCoeff; + //- Minimum stepFraction tolerance + static const scalar minStepFractionTol; + // Constructors diff --git a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C index 8cf9317c86..10bd38d62e 100644 --- a/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C +++ b/src/lagrangian/intermediate/parcels/Templates/KinematicParcel/KinematicParcel.C @@ -271,6 +271,8 @@ bool Foam::KinematicParcel::move scalar tEnd = (1.0 - p.stepFraction())*trackTime; const scalar dtMax = tEnd; + bool moving = true; + while (td.keepParticle && !td.switchProcessor && tEnd > ROOTVSMALL) { // Apply correction to position for reduced-D cases @@ -281,22 +283,36 @@ bool Foam::KinematicParcel::move // Set the Lagrangian time-step scalar dt = min(dtMax, tEnd); - // Remember which cell the parcel is in since this will change if - // a face is hit + // Cache the parcel current cell as this will change if a face is hit const label cellI = p.cell(); const scalar magU = mag(U_); - if (p.active() && magU > ROOTVSMALL) + if (p.active()) { const scalar d = dt*magU; const scalar dCorr = min(d, maxCo*cbrt(V[cellI])); - dt *= - dCorr/d - *p.trackToFace(p.position() + dCorr*U_/magU, td); + dt *= dCorr/d; + + if (moving && (magU > ROOTVSMALL)) + { + dt *= p.trackToFace(p.position() + dCorr*U_/magU, td); + } } tEnd -= dt; - p.stepFraction() = 1.0 - tEnd/trackTime; + + scalar newStepFraction = 1.0 - tEnd/trackTime; + + if + ( + mag(p.stepFraction() - newStepFraction) + < particle::minStepFractionTol + ) + { + moving = false; + } + + p.stepFraction() = newStepFraction; // Avoid problems with extremely small timesteps if (dt > ROOTVSMALL) From d62efed988908822280370de0fb4b68a58ed6a31 Mon Sep 17 00:00:00 2001 From: andy Date: Tue, 27 Aug 2013 18:11:35 +0100 Subject: [PATCH 15/34] ENH: CollidingParcel - refactored to remove code duplication --- .../CollidingParcel/CollidingParcel.C | 72 +------------------ 1 file changed, 1 insertion(+), 71 deletions(-) diff --git a/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcel.C b/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcel.C index f04ac77a15..f422f7ea37 100644 --- a/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcel.C +++ b/src/lagrangian/intermediate/parcels/Templates/CollidingParcel/CollidingParcel.C @@ -69,13 +69,6 @@ bool Foam::CollidingParcel::move typename TrackData::cloudType::parcelType& p = static_cast(*this); - td.switchProcessor = false; - td.keepParticle = true; - - const polyMesh& mesh = td.cloud().pMesh(); - const polyBoundaryMesh& pbMesh = mesh.boundaryMesh(); - const scalarField& V = mesh.cellVolumes(); - switch (td.part()) { case TrackData::tpVelocityHalfStep: @@ -92,70 +85,7 @@ bool Foam::CollidingParcel::move case TrackData::tpLinearTrack: { - scalar tEnd = (1.0 - p.stepFraction())*trackTime; - const scalar dtMax = tEnd; - - while (td.keepParticle && !td.switchProcessor && tEnd > ROOTVSMALL) - { - // Apply correction to position for reduced-D cases - meshTools::constrainToMeshCentre(mesh, p.position()); - - const point start(p.position()); - - // Set the Lagrangian time-step - scalar dt = min(dtMax, tEnd); - - // Remember which cell the parcel is in since this - // will change if a face is hit - const label cellI = p.cell(); - - const scalar magU = mag(p.U()); - if (p.active() && magU > ROOTVSMALL) - { - const scalar d = dt*magU; - const scalar maxCo = td.cloud().solution().maxCo(); - const scalar dCorr = min(d, maxCo*cbrt(V[cellI])); - dt *= - dCorr/d - *p.trackToFace(p.position() + dCorr*p.U()/magU, td); - } - - tEnd -= dt; - p.stepFraction() = 1.0 - tEnd/trackTime; - - // Avoid problems with extremely small timesteps - if (dt > ROOTVSMALL) - { - // Update cell based properties - p.setCellValues(td, dt, cellI); - - if (td.cloud().solution().cellValueSourceCorrection()) - { - p.cellValueSourceCorrection(td, dt, cellI); - } - - p.calc(td, dt, cellI); - } - - if (p.onBoundary() && td.keepParticle) - { - if (isA(pbMesh[p.patch(p.face())])) - { - td.switchProcessor = true; - } - } - - p.age() += dt; - - td.cloud().functions().postMove - ( - p, - cellI, - dt, - start, - td.keepParticle - ); - } + ParcelType::move(td, trackTime); break; } From 14a309d4c29f01fcc95c778d7531a8e5e550bd37 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 28 Aug 2013 09:16:31 +0100 Subject: [PATCH 16/34] ENH: cloudSolution - maxCo available for both steady state and transient --- .../Templates/KinematicCloud/cloudSolution/cloudSolution.C | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/cloudSolution/cloudSolution.C b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/cloudSolution/cloudSolution.C index fd7bf31706..c2bea38236 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/cloudSolution/cloudSolution.C +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/cloudSolution/cloudSolution.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -110,11 +110,11 @@ void Foam::cloudSolution::read() dict_.lookup("transient") >> transient_; dict_.lookup("coupled") >> coupled_; dict_.lookup("cellValueSourceCorrection") >> cellValueSourceCorrection_; + dict_.lookup("maxCo") >> maxCo_; if (steadyState()) { dict_.lookup("calcFrequency") >> calcFrequency_; - dict_.lookup("maxCo") >> maxCo_; dict_.lookup("maxTrackTime") >> maxTrackTime_; if (coupled_) From df2273f0c46b8f4fe0279fcd4888c079ea0d1842 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 28 Aug 2013 10:28:10 +0100 Subject: [PATCH 17/34] ENH: Refactored code --- .../reactingParcelFilmFoam/reactingParcelFilmFoam.C | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/applications/solvers/lagrangian/reactingParcelFilmFoam/reactingParcelFilmFoam.C b/applications/solvers/lagrangian/reactingParcelFilmFoam/reactingParcelFilmFoam.C index 65cfcb4516..4067c125eb 100644 --- a/applications/solvers/lagrangian/reactingParcelFilmFoam/reactingParcelFilmFoam.C +++ b/applications/solvers/lagrangian/reactingParcelFilmFoam/reactingParcelFilmFoam.C @@ -104,13 +104,9 @@ int main(int argc, char *argv[]) } rho = thermo.rho(); + } - runTime.write(); - } - else - { - runTime.write(); - } + runTime.write(); Info<< "ExecutionTime = " << runTime.elapsedCpuTime() << " s" << " ClockTime = " << runTime.elapsedClockTime() << " s" From d7f67c78b1a35b15680e2a6b218ebf6cbf9c7ade Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 28 Aug 2013 10:44:09 +0100 Subject: [PATCH 18/34] ENH: Tutorial update --- .../les/oppositeBurningPanels/constant/reactingCloud1Properties | 1 + .../les/smallPoolFire2D/constant/reactingCloud1Properties | 1 + .../les/smallPoolFire3D/constant/reactingCloud1Properties | 1 + .../simplifiedSiwek/constant/coalCloud1Properties | 1 + .../simplifiedSiwek/constant/limestoneCloud1Properties | 1 + .../hopper/hopperEmptying/constant/kinematicCloudProperties | 1 + .../hopper/hopperInitialState/constant/kinematicCloudProperties | 1 + .../cylinder/constant/reactingCloud1Properties | 1 + .../hotBoxes/constant/reactingCloud1Properties | 1 + .../splashPanel/constant/reactingCloud1Properties | 1 + .../reactingParcelFoam/filter/constant/reactingCloud1Properties | 1 + .../parcelInBox/constant/reactingCloud1Properties | 1 + .../verticalChannel/constant/reactingCloud1Properties | 1 + .../sprayFoam/aachenBomb/constant/sprayCloudProperties | 1 + 14 files changed, 14 insertions(+) diff --git a/tutorials/combustion/fireFoam/les/oppositeBurningPanels/constant/reactingCloud1Properties b/tutorials/combustion/fireFoam/les/oppositeBurningPanels/constant/reactingCloud1Properties index 5408eb7928..9228607e91 100644 --- a/tutorials/combustion/fireFoam/les/oppositeBurningPanels/constant/reactingCloud1Properties +++ b/tutorials/combustion/fireFoam/les/oppositeBurningPanels/constant/reactingCloud1Properties @@ -21,6 +21,7 @@ solution coupled yes; transient yes; cellValueSourceCorrection yes; + maxCo 0.3; sourceTerms { diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/reactingCloud1Properties b/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/reactingCloud1Properties index 5408eb7928..9228607e91 100644 --- a/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/reactingCloud1Properties +++ b/tutorials/combustion/fireFoam/les/smallPoolFire2D/constant/reactingCloud1Properties @@ -21,6 +21,7 @@ solution coupled yes; transient yes; cellValueSourceCorrection yes; + maxCo 0.3; sourceTerms { diff --git a/tutorials/combustion/fireFoam/les/smallPoolFire3D/constant/reactingCloud1Properties b/tutorials/combustion/fireFoam/les/smallPoolFire3D/constant/reactingCloud1Properties index 5408eb7928..9228607e91 100644 --- a/tutorials/combustion/fireFoam/les/smallPoolFire3D/constant/reactingCloud1Properties +++ b/tutorials/combustion/fireFoam/les/smallPoolFire3D/constant/reactingCloud1Properties @@ -21,6 +21,7 @@ solution coupled yes; transient yes; cellValueSourceCorrection yes; + maxCo 0.3; sourceTerms { diff --git a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/coalCloud1Properties b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/coalCloud1Properties index 7c71c8971e..e164395342 100644 --- a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/coalCloud1Properties +++ b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/coalCloud1Properties @@ -21,6 +21,7 @@ solution transient yes; coupled true; cellValueSourceCorrection on; + maxCo 0.3; sourceTerms { diff --git a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/limestoneCloud1Properties b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/limestoneCloud1Properties index 4b5b5393e4..36b287137d 100644 --- a/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/limestoneCloud1Properties +++ b/tutorials/lagrangian/coalChemistryFoam/simplifiedSiwek/constant/limestoneCloud1Properties @@ -21,6 +21,7 @@ solution coupled true; transient yes; cellValueSourceCorrection on; + maxCo 0.3; sourceTerms { diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/hopperEmptying/constant/kinematicCloudProperties b/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/hopperEmptying/constant/kinematicCloudProperties index 06571ffdd1..150adb2953 100644 --- a/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/hopperEmptying/constant/kinematicCloudProperties +++ b/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/hopperEmptying/constant/kinematicCloudProperties @@ -21,6 +21,7 @@ solution coupled false; transient yes; cellValueSourceCorrection off; + maxCo 0.3; sourceTerms { diff --git a/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/hopperInitialState/constant/kinematicCloudProperties b/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/hopperInitialState/constant/kinematicCloudProperties index 874c386653..2fa48b6da0 100644 --- a/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/hopperInitialState/constant/kinematicCloudProperties +++ b/tutorials/lagrangian/icoUncoupledKinematicParcelFoam/hopper/hopperInitialState/constant/kinematicCloudProperties @@ -21,6 +21,7 @@ solution coupled false; transient yes; cellValueSourceCorrection off; + maxCo 0.3; interpolationSchemes { diff --git a/tutorials/lagrangian/reactingParcelFilmFoam/cylinder/constant/reactingCloud1Properties b/tutorials/lagrangian/reactingParcelFilmFoam/cylinder/constant/reactingCloud1Properties index c96b27a4b4..6e01c75332 100644 --- a/tutorials/lagrangian/reactingParcelFilmFoam/cylinder/constant/reactingCloud1Properties +++ b/tutorials/lagrangian/reactingParcelFilmFoam/cylinder/constant/reactingCloud1Properties @@ -21,6 +21,7 @@ solution coupled no; transient yes; cellValueSourceCorrection no; + maxCo 0.3; sourceTerms { diff --git a/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/constant/reactingCloud1Properties b/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/constant/reactingCloud1Properties index e6afd3b55d..4e8221412f 100644 --- a/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/constant/reactingCloud1Properties +++ b/tutorials/lagrangian/reactingParcelFilmFoam/hotBoxes/constant/reactingCloud1Properties @@ -21,6 +21,7 @@ solution coupled yes; transient yes; cellValueSourceCorrection yes; + maxCo 0.3; sourceTerms { diff --git a/tutorials/lagrangian/reactingParcelFilmFoam/splashPanel/constant/reactingCloud1Properties b/tutorials/lagrangian/reactingParcelFilmFoam/splashPanel/constant/reactingCloud1Properties index 5652c17be9..e38561ee8f 100644 --- a/tutorials/lagrangian/reactingParcelFilmFoam/splashPanel/constant/reactingCloud1Properties +++ b/tutorials/lagrangian/reactingParcelFilmFoam/splashPanel/constant/reactingCloud1Properties @@ -21,6 +21,7 @@ solution coupled no; transient yes; cellValueSourceCorrection no; + maxCo 0.3; sourceTerms { diff --git a/tutorials/lagrangian/reactingParcelFoam/filter/constant/reactingCloud1Properties b/tutorials/lagrangian/reactingParcelFoam/filter/constant/reactingCloud1Properties index 2ba702faa8..2eba294927 100644 --- a/tutorials/lagrangian/reactingParcelFoam/filter/constant/reactingCloud1Properties +++ b/tutorials/lagrangian/reactingParcelFoam/filter/constant/reactingCloud1Properties @@ -21,6 +21,7 @@ solution coupled true; transient yes; cellValueSourceCorrection on; + maxCo 0.3; sourceTerms { diff --git a/tutorials/lagrangian/reactingParcelFoam/parcelInBox/constant/reactingCloud1Properties b/tutorials/lagrangian/reactingParcelFoam/parcelInBox/constant/reactingCloud1Properties index 41fe1084d4..1ce6679e09 100644 --- a/tutorials/lagrangian/reactingParcelFoam/parcelInBox/constant/reactingCloud1Properties +++ b/tutorials/lagrangian/reactingParcelFoam/parcelInBox/constant/reactingCloud1Properties @@ -21,6 +21,7 @@ solution coupled false; transient yes; cellValueSourceCorrection off; + maxCo 0.3; sourceTerms { diff --git a/tutorials/lagrangian/reactingParcelFoam/verticalChannel/constant/reactingCloud1Properties b/tutorials/lagrangian/reactingParcelFoam/verticalChannel/constant/reactingCloud1Properties index 70524de8a8..c6e386958c 100644 --- a/tutorials/lagrangian/reactingParcelFoam/verticalChannel/constant/reactingCloud1Properties +++ b/tutorials/lagrangian/reactingParcelFoam/verticalChannel/constant/reactingCloud1Properties @@ -21,6 +21,7 @@ solution coupled true; transient yes; cellValueSourceCorrection on; + maxCo 0.3; sourceTerms { diff --git a/tutorials/lagrangian/sprayFoam/aachenBomb/constant/sprayCloudProperties b/tutorials/lagrangian/sprayFoam/aachenBomb/constant/sprayCloudProperties index b0989cc8b9..4d9cfe2711 100644 --- a/tutorials/lagrangian/sprayFoam/aachenBomb/constant/sprayCloudProperties +++ b/tutorials/lagrangian/sprayFoam/aachenBomb/constant/sprayCloudProperties @@ -21,6 +21,7 @@ solution coupled true; transient yes; cellValueSourceCorrection on; + maxCo 0.3; sourceTerms { From 94c4d37f63c8f3a5efd16957d028e66af5ccbfeb Mon Sep 17 00:00:00 2001 From: laurence Date: Wed, 28 Aug 2013 12:55:22 +0100 Subject: [PATCH 19/34] ENH: foamyHexMesh: check for intersection in inside/outside test --- .../conformationSurfaces.C | 64 ++++++++----------- 1 file changed, 26 insertions(+), 38 deletions(-) diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C index 20a8b278eb..0360cf0d83 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformationSurfaces/conformationSurfaces.C @@ -670,6 +670,32 @@ Foam::Field Foam::conformationSurfaces::wellInOutSide continue; } + const searchableSurface& surface(allGeometry_[surfaces_[s]]); + + if (!surface.hasVolumeType()) + { + pointField sample(1, samplePts[i]); + scalarField nearestDistSqr(1, GREAT); + List info; + + surface.findNearest(sample, nearestDistSqr, info); + + vector hitDir = info[0].rawPoint() - samplePts[i]; + hitDir /= mag(hitDir) + SMALL; + + if + ( + findSurfaceAnyIntersection + ( + samplePts[i], + info[0].rawPoint() - 1e-3*mag(hitDir)*(hitDir) + ) + ) + { + continue; + } + } + if (surfaceVolumeTests[s][i] == volumeType::OUTSIDE) { if @@ -694,44 +720,6 @@ Foam::Field Foam::conformationSurfaces::wellInOutSide break; } } -// else -// { -// // Surface volume type is unknown -// Info<< "UNKNOWN" << endl; -// // Get nearest face normal -// -// pointField sample(1, samplePts[i]); -// scalarField nearestDistSqr(1, GREAT); -// List info; -// vectorField norms(1); -// -// surface.findNearest(sample, nearestDistSqr, info); -// surface.getNormal(info, norms); -// -// vector fN = norms[0]; -// fN /= mag(fN); -// -// vector hitDir = info[0].rawPoint() - samplePts[i]; -// hitDir /= mag(hitDir); -// -// if ((fN & hitDir) < 0) -// { -// // Point is OUTSIDE -// -// if -// ( -// normalVolumeTypes_[regionI] -// == extendedFeatureEdgeMesh::OUTSIDE -// ) -// { -// } -// else -// { -// insidePoint[i] = false; -// break; -// } -// } -// } } } From d185f8b9fe56dbf96c4cc560e0b6bb3ed40e02b9 Mon Sep 17 00:00:00 2001 From: Sergio Ferraris Date: Thu, 29 Aug 2013 11:05:27 +0100 Subject: [PATCH 20/34] ENH: Adding useChemistrySolver in reactingOneDim solid region to avoid using chemistry solvers in reacting solids Adding non const access function to chemistryModel.H for combustion models that calculates RR externally Removing EulerImplicit from options in solidReactions. BUG: Correcting function used by sequential solver in pyrolysisChemistryModel.C --- .../reactingOneDim/reactingOneDim.C | 26 ++++++++++---- .../reactingOneDim/reactingOneDim.H | 3 ++ .../basicChemistryModel/basicChemistryModel.H | 8 ++++- .../chemistryModel/chemistryModel.H | 6 ++++ .../chemistryModel/chemistryModelI.H | 12 ++++++- .../basicSolidChemistryModel.C | 31 +++++++++++++++++ .../basicSolidChemistryModel.H | 9 +++++ .../pyrolysisChemistryModel.C | 34 +++++++------------ .../pyrolysisChemistryModel.H | 13 ++++--- .../solidChemistryModel/solidChemistryModel.H | 22 ++++++------ .../solidChemistryModelI.H | 14 +------- .../makeSolidChemistrySolverType.H | 14 ++------ .../solidThermo/solidThermo/makeSolidThermo.H | 2 +- 13 files changed, 122 insertions(+), 72 deletions(-) diff --git a/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.C b/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.C index 10c8a4b4ac..6fa334158a 100644 --- a/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.C +++ b/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.C @@ -61,6 +61,9 @@ void reactingOneDim::readReactingOneDimControls() coeffs().lookup("gasHSource") >> gasHSource_; coeffs().lookup("QrHSource") >> QrHSource_; + useChemistrySolvers_ = + coeffs().lookupOrDefault("useChemistrySolvers", true); + } @@ -462,7 +465,8 @@ reactingOneDim::reactingOneDim(const word& modelType, const fvMesh& mesh) totalGasMassFlux_(0.0), totalHeatRR_(dimensionedScalar("zero", dimEnergy/dimTime, 0.0)), gasHSource_(false), - QrHSource_(false) + QrHSource_(false), + useChemistrySolvers_(true) { if (active_) { @@ -560,7 +564,8 @@ reactingOneDim::reactingOneDim totalGasMassFlux_(0.0), totalHeatRR_(dimensionedScalar("zero", dimEnergy/dimTime, 0.0)), gasHSource_(false), - QrHSource_(false) + QrHSource_(false), + useChemistrySolvers_(true) { if (active_) { @@ -681,11 +686,18 @@ void reactingOneDim::evolveRegion() { Info<< "\nEvolving pyrolysis in region: " << regionMesh().name() << endl; - solidChemistry_->solve - ( - time().value() - time().deltaTValue(), - time().deltaTValue() - ); + if (useChemistrySolvers_) + { + solidChemistry_->solve + ( + time().value() - time().deltaTValue(), + time().deltaTValue() + ); + } + else + { + solidChemistry_->calculate(); + } solveContinuity(); diff --git a/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.H b/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.H index 4a92fd6967..a5950a9804 100644 --- a/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.H +++ b/src/regionModels/pyrolysisModels/reactingOneDim/reactingOneDim.H @@ -154,6 +154,9 @@ protected: //- Add in depth radiation source term bool QrHSource_; + //- Use chemistry solvers (ode or sequential) + bool useChemistrySolvers_; + // Protected member functions diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModel.H b/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModel.H index 67704bb9df..75ea14eb67 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModel.H +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/basicChemistryModel/basicChemistryModel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -140,6 +140,12 @@ public: const label i ) const = 0; + //- Return access to chemical source terms [kg/m3/s] + virtual DimensionedField& RR + ( + const label i + ) = 0; + // Chemistry solution diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/chemistryModel/chemistryModel.H b/src/thermophysicalModels/chemistryModel/chemistryModel/chemistryModel/chemistryModel.H index 7b3d1c663a..475fc7c8fd 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/chemistryModel/chemistryModel.H +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/chemistryModel/chemistryModel.H @@ -211,6 +211,12 @@ public: const label i ) const; + //- Return non const access to chemical source terms [kg/m3/s] + virtual DimensionedField& RR + ( + const label i + ); + //- Solve the reaction system for the given start time and time // step and return the characteristic time virtual scalar solve(const scalar t0, const scalar deltaT); diff --git a/src/thermophysicalModels/chemistryModel/chemistryModel/chemistryModel/chemistryModelI.H b/src/thermophysicalModels/chemistryModel/chemistryModel/chemistryModel/chemistryModelI.H index d128443fe9..c009a11e46 100644 --- a/src/thermophysicalModels/chemistryModel/chemistryModel/chemistryModel/chemistryModelI.H +++ b/src/thermophysicalModels/chemistryModel/chemistryModel/chemistryModel/chemistryModelI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -78,5 +78,15 @@ Foam::chemistryModel::RR return RR_[i]; } +template +Foam::DimensionedField& +Foam::chemistryModel::RR +( + const label i +) +{ + return RR_[i]; +} + // ************************************************************************* // diff --git a/src/thermophysicalModels/solidChemistryModel/basicSolidChemistryModel/basicSolidChemistryModel.C b/src/thermophysicalModels/solidChemistryModel/basicSolidChemistryModel/basicSolidChemistryModel.C index cfff71b9ed..f94db5946b 100644 --- a/src/thermophysicalModels/solidChemistryModel/basicSolidChemistryModel/basicSolidChemistryModel.C +++ b/src/thermophysicalModels/solidChemistryModel/basicSolidChemistryModel/basicSolidChemistryModel.C @@ -53,4 +53,35 @@ Foam::basicSolidChemistryModel::~basicSolidChemistryModel() {} +const Foam::DimensionedField& +Foam::basicSolidChemistryModel::RR(const label i) const +{ + notImplemented + ( + "const Foam::DimensionedField&" + "basicSolidChemistryModel::RR(const label)" + ); + return (DimensionedField::null()); +} + + +Foam::DimensionedField& +Foam::basicSolidChemistryModel::RR(const label i) +{ + notImplemented + ( + "Foam::DimensionedField&" + "basicSolidChemistryModel::RR(const label)" + ); + + return dynamic_cast&> + ( + const_cast& > + ( + DimensionedField::null() + ) + ); +} + + // ************************************************************************* // diff --git a/src/thermophysicalModels/solidChemistryModel/basicSolidChemistryModel/basicSolidChemistryModel.H b/src/thermophysicalModels/solidChemistryModel/basicSolidChemistryModel/basicSolidChemistryModel.H index 2134bffca1..50d6a2e96b 100644 --- a/src/thermophysicalModels/solidChemistryModel/basicSolidChemistryModel/basicSolidChemistryModel.H +++ b/src/thermophysicalModels/solidChemistryModel/basicSolidChemistryModel/basicSolidChemistryModel.H @@ -149,6 +149,15 @@ public: //- Calculates the reaction rates virtual void calculate() = 0; + + //- Return const access to the total source terms + virtual const DimensionedField& RR + ( + const label i + ) const; + + //- Return non-const access to the total source terms + virtual DimensionedField& RR(const label i); }; diff --git a/src/thermophysicalModels/solidChemistryModel/pyrolysisChemistryModel/pyrolysisChemistryModel.C b/src/thermophysicalModels/solidChemistryModel/pyrolysisChemistryModel/pyrolysisChemistryModel.C index e301a1b85e..4962bf716b 100644 --- a/src/thermophysicalModels/solidChemistryModel/pyrolysisChemistryModel/pyrolysisChemistryModel.C +++ b/src/thermophysicalModels/solidChemistryModel/pyrolysisChemistryModel/pyrolysisChemistryModel.C @@ -535,14 +535,21 @@ updateConcsInReactionI c[si] = max(0.0, c[si]); } + scalar sr = 0.0; forAll(R.rhs(), s) { label si = R.rhs()[s].index; const scalar rhoR = this->solidThermo_[si].rho(p, T); - const scalar sr = rhoR/rhoL; + sr = rhoR/rhoL; c[si] += dt*sr*omeg; c[si] = max(0.0, c[si]); } + + forAll(R.grhs(), g) + { + label gi = R.grhs()[g].index; + c[gi + this->nSolids_] += (1.0 - sr)*omeg*dt; + } } @@ -561,24 +568,11 @@ updateRRInReactionI simpleMatrix& RR ) const { - const Reaction& R = this->reactions_[index]; - scalar rhoL = 0.0; - forAll(R.lhs(), s) - { - label si = R.lhs()[s].index; - rhoL = this->solidThermo_[si].rho(p, T); - RR[si][rRef] -= pr*corr; - RR[si][lRef] += pf*corr; - } - - forAll(R.rhs(), s) - { - label si = R.rhs()[s].index; - const scalar rhoR = this->solidThermo_[si].rho(p, T); - const scalar sr = rhoR/rhoL; - RR[si][lRef] -= sr*pf*corr; - RR[si][rRef] += sr*pr*corr; - } + notImplemented + ( + "void Foam::pyrolysisChemistryModel::" + "updateRRInReactionI" + ); } @@ -666,7 +660,6 @@ Foam::pyrolysisChemistryModel::solve scalar newCp = 0.0; scalar newhi = 0.0; - scalar invRho = 0.0; scalarList dcdt = (c - c0)/dt; for (label i=0; inSolids_; i++) @@ -675,7 +668,6 @@ Foam::pyrolysisChemistryModel::solve scalar Yi = c[i]/cTot; newCp += Yi*this->solidThermo_[i].Cp(pi, Ti); newhi -= dYi*this->solidThermo_[i].Hc(); - invRho += Yi/this->solidThermo_[i].rho(pi, Ti); } scalar dTi = (newhi/newCp)*dt; diff --git a/src/thermophysicalModels/solidChemistryModel/pyrolysisChemistryModel/pyrolysisChemistryModel.H b/src/thermophysicalModels/solidChemistryModel/pyrolysisChemistryModel/pyrolysisChemistryModel.H index 2d4a11cc90..7ae76c5233 100644 --- a/src/thermophysicalModels/solidChemistryModel/pyrolysisChemistryModel/pyrolysisChemistryModel.H +++ b/src/thermophysicalModels/solidChemistryModel/pyrolysisChemistryModel/pyrolysisChemistryModel.H @@ -137,8 +137,9 @@ public: const bool updateC0 = false ) const; - //- Return the reaction rate for reaction r and the reference - // species and charateristic times + //- Return the reaction rate for reaction r + // NOTE: Currently does not calculate reference specie and + // characteristic times (pf, cf,l Ref, etc.) virtual scalar omega ( const Reaction& r, @@ -153,8 +154,10 @@ public: label& rRef ) const; - //- Return the reaction rate for iReaction and the reference - // species and charateristic times + + //- Return the reaction rate for iReaction + // NOTE: Currently does not calculate reference specie and + // characteristic times (pf, cf,l Ref, etc.) virtual scalar omegaI ( label iReaction, @@ -169,6 +172,7 @@ public: label& rRef ) const; + //- Calculates the reaction rates virtual void calculate(); @@ -186,6 +190,7 @@ public: //- Update matrix RR for reaction i. Used by EulerImplicit + // (Not implemented) virtual void updateRRInReactionI ( const label i, diff --git a/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModel.H b/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModel.H index 03076d79ce..bf67f1ca4d 100644 --- a/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModel.H +++ b/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModel.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -65,6 +65,9 @@ class solidChemistryModel { // Private Member Functions + //- Disallow copy constructor + solidChemistryModel(const solidChemistryModel&); + //- Disallow default bitwise assignment void operator=(const solidChemistryModel&); @@ -151,6 +154,7 @@ public: label& rRef ) const = 0; + //- Return the reaction rate for iReaction and the reference // species and charateristic times virtual scalar omegaI @@ -167,6 +171,10 @@ public: label& rRef ) const = 0; + //- Calculates the reaction rates + virtual void calculate() = 0; + + //- Update concentrations in reaction i given dt and reaction rate // omega used by sequential solver virtual void updateConcsInReactionI @@ -194,11 +202,8 @@ public: simpleMatrix& RR ) const = 0; - //- Calculates the reaction rates - virtual void calculate() = 0; - - // Chemistry model functions + // Solid Chemistry model functions //- Return const access to the chemical source terms for solids inline const DimensionedField& RRs @@ -209,13 +214,6 @@ public: //- Return total solid source term inline tmp > RRs() const; - //- Return const access to the total source terms - inline const DimensionedField& RR - ( - const label i - ) const; - - //- Solve the reaction system for the given start time and time // step and return the characteristic time virtual scalar solve(const scalar t0, const scalar deltaT) = 0; diff --git a/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModelI.H b/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModelI.H index 92b461e11e..f2d0dad79a 100644 --- a/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModelI.H +++ b/src/thermophysicalModels/solidChemistryModel/solidChemistryModel/solidChemistryModelI.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2013-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -95,16 +95,4 @@ Foam::solidChemistryModel::RRs() const } -template -inline const Foam::DimensionedField& -Foam::solidChemistryModel::RR -( - const label i -) const -{ - notImplemented("solidChemistryModel::RR(const label)"); - return (DimensionedField::null()); -} - - // ************************************************************************* // diff --git a/src/thermophysicalModels/solidChemistryModel/solidChemistrySolver/makeSolidChemistrySolverType.H b/src/thermophysicalModels/solidChemistryModel/solidChemistrySolver/makeSolidChemistrySolverType.H index 12f842a054..447020e2f7 100644 --- a/src/thermophysicalModels/solidChemistryModel/solidChemistrySolver/makeSolidChemistrySolverType.H +++ b/src/thermophysicalModels/solidChemistryModel/solidChemistrySolver/makeSolidChemistrySolverType.H @@ -52,9 +52,8 @@ namespace Foam defineTemplateTypeNameAndDebugWithName \ ( \ SS##Schem##Comp##SThermo##GThermo, \ - (#SS"<" + word(Schem::typeName_()) \ - + "<"#Comp"," + SThermo::typeName() \ - + "," + GThermo::typeName() + ">>").c_str(), \ + (#SS"<"#Schem"<"#Comp"," + SThermo::typeName() + "," \ + + GThermo::typeName() + ">>").c_str(), \ 0 \ ); \ \ @@ -77,14 +76,6 @@ namespace Foam GThermo \ ); \ \ - makeSolidChemistrySolverType \ - ( \ - EulerImplicit, \ - SolidChem, \ - Comp, \ - SThermo, \ - GThermo \ - ); \ \ makeSolidChemistrySolverType \ ( \ @@ -104,7 +95,6 @@ namespace Foam GThermo \ ); - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam diff --git a/src/thermophysicalModels/solidThermo/solidThermo/makeSolidThermo.H b/src/thermophysicalModels/solidThermo/solidThermo/makeSolidThermo.H index 5193a4b9de..07b6ffb050 100644 --- a/src/thermophysicalModels/solidThermo/solidThermo/makeSolidThermo.H +++ b/src/thermophysicalModels/solidThermo/solidThermo/makeSolidThermo.H @@ -30,7 +30,7 @@ Description \*---------------------------------------------------------------------------*/ #ifndef makeSolidThermo_H -#define makesolidThermo_H +#define makeSolidThermo_H #include "addToRunTimeSelectionTable.H" From 7531ccba9be86308a9e69a84b784bad8737591be Mon Sep 17 00:00:00 2001 From: laurence Date: Thu, 29 Aug 2013 15:32:43 +0100 Subject: [PATCH 21/34] ENH: foamyHexMesh: add rayShooting initial points method --- .../conformalVoronoiMesh/Make/files | 1 + .../conformalVoronoiMesh.C | 2 +- .../rayShooting/rayShooting.C | 218 ++++++++++++++++++ .../rayShooting/rayShooting.H | 105 +++++++++ 4 files changed, 325 insertions(+), 1 deletion(-) create mode 100644 applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.C create mode 100644 applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.H diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/Make/files b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/Make/files index e42c52451f..bc4a363517 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/Make/files +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/Make/files @@ -64,6 +64,7 @@ initialPointsMethod/bodyCentredCubic/bodyCentredCubic.C initialPointsMethod/faceCentredCubic/faceCentredCubic.C initialPointsMethod/pointFile/pointFile.C initialPointsMethod/autoDensity/autoDensity.C +initialPointsMethod/rayShooting/rayShooting.C relaxationModel/relaxationModel/relaxationModel.C relaxationModel/adaptiveLinear/adaptiveLinear.C diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C index 6f137249c1..e580febdd8 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/conformalVoronoiMesh/conformalVoronoiMesh.C @@ -1249,7 +1249,7 @@ void Foam::conformalVoronoiMesh::move() if ( ( - (vA->internalPoint() && vB->internalPoint()) + (vA->internalPoint() || vB->internalPoint()) && (!vA->referred() || !vB->referred()) // || // ( diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.C new file mode 100644 index 0000000000..c4beb20b8e --- /dev/null +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.C @@ -0,0 +1,218 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ 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 "rayShooting.H" +#include "addToRunTimeSelectionTable.H" +#include "triSurfaceMesh.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +defineTypeNameAndDebug(rayShooting, 0); +addToRunTimeSelectionTable(initialPointsMethod, rayShooting, dictionary); + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +rayShooting::rayShooting +( + const dictionary& initialPointsDict, + const Time& runTime, + Random& rndGen, + const conformationSurfaces& geometryToConformTo, + const cellShapeControl& cellShapeControls, + const autoPtr& decomposition +) +: + initialPointsMethod + ( + typeName, + initialPointsDict, + runTime, + rndGen, + geometryToConformTo, + cellShapeControls, + decomposition + ), + maxRayLength_(readScalar(detailsDict().lookup("maxRayLength"))), + randomiseInitialGrid_(detailsDict().lookup("randomiseInitialGrid")), + randomPerturbationCoeff_ + ( + readScalar(detailsDict().lookup("randomPerturbationCoeff")) + ) +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +List rayShooting::initialPoints() const +{ + // Loop over surface faces + const searchableSurfaces& surfaces = geometryToConformTo().geometry(); + const labelList& surfacesToConformTo = geometryToConformTo().surfaces(); + + // Initialise points list + label initialPointsSize = 0; + forAll(surfaces, surfI) + { + initialPointsSize += surfaces[surfI].size(); + } + + DynamicList initialPoints(initialPointsSize); + + forAll(surfacesToConformTo, surfI) + { + const searchableSurface& s = surfaces[surfacesToConformTo[surfI]]; + + tmp faceCentresTmp(s.coordinates()); + const pointField& faceCentres = faceCentresTmp(); + + Info<< " Shoot rays from " << s.name() << nl + << " nRays = " << faceCentres.size() << endl; + + + forAll(faceCentres, fcI) + { + const Foam::point& fC = faceCentres[fcI]; + + if + ( + Pstream::parRun() + && !decomposition().positionOnThisProcessor(fC) + ) + { + continue; + } + + const scalar pert = + randomPerturbationCoeff_ + *cellShapeControls().cellSize(fC); + + pointIndexHit surfHitStart; + label hitSurfaceStart; + + // Face centres should be on the surface so search distance can be + // small + geometryToConformTo().findSurfaceNearest + ( + fC, + sqr(SMALL), + surfHitStart, + hitSurfaceStart + ); + + vectorField normStart(1, vector::min); + geometryToConformTo().getNormal + ( + hitSurfaceStart, + List(1, surfHitStart), + normStart + ); + + pointIndexHit surfHitEnd; + label hitSurfaceEnd; + + geometryToConformTo().findSurfaceNearestIntersection + ( + fC - normStart[0]*SMALL, + fC - normStart[0]*maxRayLength_, + surfHitEnd, + hitSurfaceEnd + ); + + vectorField normEnd(1, vector::min); + geometryToConformTo().getNormal + ( + hitSurfaceEnd, + List(1, surfHitEnd), + normEnd + ); + + if + ( + surfHitEnd.hit() + && ((normStart[0] & normEnd[0]) < 0) + ) + { + line l(fC, surfHitEnd.hitPoint()); + + if (Pstream::parRun()) + { + // Clip the line in parallel + pointIndexHit procIntersection = + decomposition().findLine + ( + l.start() + l.vec()*SMALL, + l.end() - l.vec()*maxRayLength_ + ); + + if (procIntersection.hit()) + { + l = + line + ( + l.start(), + procIntersection.hitPoint() + ); + } + } + + Foam::point midPoint(l.centre()); + + const scalar minDistFromSurfaceSqr = + minimumSurfaceDistanceCoeffSqr_ + *sqr(cellShapeControls().cellSize(midPoint)); + + if + ( + magSqr(midPoint - l.start()) > minDistFromSurfaceSqr + && magSqr(midPoint - l.end()) > minDistFromSurfaceSqr + ) + { + if (randomiseInitialGrid_) + { + midPoint.x() += pert*(rndGen().scalar01() - 0.5); + midPoint.y() += pert*(rndGen().scalar01() - 0.5); + midPoint.z() += pert*(rndGen().scalar01() - 0.5); + } + + initialPoints.append(toPoint(midPoint)); + } + } + } + } + + return initialPoints.shrink(); +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.H b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.H new file mode 100644 index 0000000000..c199a31e0a --- /dev/null +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.H @@ -0,0 +1,105 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ 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::rayShooting + +Description + +SourceFiles + rayShooting.C + +\*---------------------------------------------------------------------------*/ + +#ifndef rayShooting_H +#define rayShooting_H + +#include "initialPointsMethod.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class rayShooting Declaration +\*---------------------------------------------------------------------------*/ + +class rayShooting +: + public initialPointsMethod +{ + +private: + + // Private data + + const scalar maxRayLength_; + + //- Should the initial positions be randomised + Switch randomiseInitialGrid_; + + //- Randomise the initial positions by fraction of the initialCellSize_ + scalar randomPerturbationCoeff_; + + +public: + + //- Runtime type information + TypeName("rayShooting"); + + // Constructors + + //- Construct from components + rayShooting + ( + const dictionary& initialPointsDict, + const Time& runTime, + Random& rndGen, + const conformationSurfaces& geometryToConformTo, + const cellShapeControl& cellShapeControls, + const autoPtr& decomposition + ); + + + //- Destructor + virtual ~rayShooting() + {} + + + // Member Functions + + //- Return the initial points for the conformalVoronoiMesh + virtual List initialPoints() const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // From 8dda57ddbfb9dbccafa9494be3a37d92bbd1e066 Mon Sep 17 00:00:00 2001 From: laurence Date: Thu, 29 Aug 2013 16:00:04 +0100 Subject: [PATCH 22/34] ENH: foamyHexMesh: correct rayShooting point addition on intersection --- .../rayShooting/rayShooting.C | 103 +++++++++--------- 1 file changed, 51 insertions(+), 52 deletions(-) diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.C index c4beb20b8e..e0be01bcac 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.C @@ -121,7 +121,7 @@ List rayShooting::initialPoints() const geometryToConformTo().findSurfaceNearest ( fC, - sqr(SMALL), + sqr(pert), surfHitStart, hitSurfaceStart ); @@ -145,63 +145,62 @@ List rayShooting::initialPoints() const hitSurfaceEnd ); - vectorField normEnd(1, vector::min); - geometryToConformTo().getNormal - ( - hitSurfaceEnd, - List(1, surfHitEnd), - normEnd - ); - - if - ( - surfHitEnd.hit() - && ((normStart[0] & normEnd[0]) < 0) - ) + if (surfHitEnd.hit()) { - line l(fC, surfHitEnd.hitPoint()); - - if (Pstream::parRun()) - { - // Clip the line in parallel - pointIndexHit procIntersection = - decomposition().findLine - ( - l.start() + l.vec()*SMALL, - l.end() - l.vec()*maxRayLength_ - ); - - if (procIntersection.hit()) - { - l = - line - ( - l.start(), - procIntersection.hitPoint() - ); - } - } - - Foam::point midPoint(l.centre()); - - const scalar minDistFromSurfaceSqr = - minimumSurfaceDistanceCoeffSqr_ - *sqr(cellShapeControls().cellSize(midPoint)); - - if + vectorField normEnd(1, vector::min); + geometryToConformTo().getNormal ( - magSqr(midPoint - l.start()) > minDistFromSurfaceSqr - && magSqr(midPoint - l.end()) > minDistFromSurfaceSqr - ) + hitSurfaceEnd, + List(1, surfHitEnd), + normEnd + ); + + if ((normStart[0] & normEnd[0]) < 0) { - if (randomiseInitialGrid_) + line l(fC, surfHitEnd.hitPoint()); + + if (Pstream::parRun()) { - midPoint.x() += pert*(rndGen().scalar01() - 0.5); - midPoint.y() += pert*(rndGen().scalar01() - 0.5); - midPoint.z() += pert*(rndGen().scalar01() - 0.5); + // Clip the line in parallel + pointIndexHit procIntersection = + decomposition().findLine + ( + l.start() + l.vec()*SMALL, + l.end() - l.vec()*maxRayLength_ + ); + + if (procIntersection.hit()) + { + l = + line + ( + l.start(), + procIntersection.hitPoint() + ); + } } - initialPoints.append(toPoint(midPoint)); + Foam::point midPoint(l.centre()); + + const scalar minDistFromSurfaceSqr = + minimumSurfaceDistanceCoeffSqr_ + *sqr(cellShapeControls().cellSize(midPoint)); + + if + ( + magSqr(midPoint - l.start()) > minDistFromSurfaceSqr + && magSqr(midPoint - l.end()) > minDistFromSurfaceSqr + ) + { + if (randomiseInitialGrid_) + { + midPoint.x() += pert*(rndGen().scalar01() - 0.5); + midPoint.y() += pert*(rndGen().scalar01() - 0.5); + midPoint.z() += pert*(rndGen().scalar01() - 0.5); + } + + initialPoints.append(toPoint(midPoint)); + } } } } From 20a8649a0094f4377f767829c1e33a263a205437 Mon Sep 17 00:00:00 2001 From: laurence Date: Thu, 29 Aug 2013 16:04:24 +0100 Subject: [PATCH 23/34] ENH: foamyHexMesh: calc maxRayLength from bounds of surface --- .../initialPointsMethod/rayShooting/rayShooting.C | 7 ++++--- .../initialPointsMethod/rayShooting/rayShooting.H | 2 -- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.C index e0be01bcac..880871165e 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.C @@ -59,7 +59,6 @@ rayShooting::rayShooting cellShapeControls, decomposition ), - maxRayLength_(readScalar(detailsDict().lookup("maxRayLength"))), randomiseInitialGrid_(detailsDict().lookup("randomiseInitialGrid")), randomPerturbationCoeff_ ( @@ -76,6 +75,8 @@ List rayShooting::initialPoints() const const searchableSurfaces& surfaces = geometryToConformTo().geometry(); const labelList& surfacesToConformTo = geometryToConformTo().surfaces(); + const scalar maxRayLength = surfaces.bounds().mag(); + // Initialise points list label initialPointsSize = 0; forAll(surfaces, surfI) @@ -140,7 +141,7 @@ List rayShooting::initialPoints() const geometryToConformTo().findSurfaceNearestIntersection ( fC - normStart[0]*SMALL, - fC - normStart[0]*maxRayLength_, + fC - normStart[0]*maxRayLength, surfHitEnd, hitSurfaceEnd ); @@ -166,7 +167,7 @@ List rayShooting::initialPoints() const decomposition().findLine ( l.start() + l.vec()*SMALL, - l.end() - l.vec()*maxRayLength_ + l.end() - l.vec()*maxRayLength ); if (procIntersection.hit()) diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.H b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.H index c199a31e0a..e66df62b7c 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.H +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.H @@ -54,8 +54,6 @@ private: // Private data - const scalar maxRayLength_; - //- Should the initial positions be randomised Switch randomiseInitialGrid_; From 067c80b0d73042f6ec7629c1e561cfbe3bcc6dbd Mon Sep 17 00:00:00 2001 From: laurence Date: Thu, 29 Aug 2013 16:34:39 +0100 Subject: [PATCH 24/34] ENH: foamyHexMesh: correct proc boundary intersection in ray shooting --- .../rayShooting/rayShooting.C | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.C b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.C index 880871165e..ebecad88e1 100644 --- a/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.C +++ b/applications/utilities/mesh/generation/foamyHexMesh/conformalVoronoiMesh/initialPointsMethod/rayShooting/rayShooting.C @@ -140,7 +140,7 @@ List rayShooting::initialPoints() const geometryToConformTo().findSurfaceNearestIntersection ( - fC - normStart[0]*SMALL, + fC - normStart[0]*pert, fC - normStart[0]*maxRayLength, surfHitEnd, hitSurfaceEnd @@ -166,8 +166,8 @@ List rayShooting::initialPoints() const pointIndexHit procIntersection = decomposition().findLine ( - l.start() + l.vec()*SMALL, - l.end() - l.vec()*maxRayLength + l.start(), + l.end() ); if (procIntersection.hit()) @@ -187,19 +187,19 @@ List rayShooting::initialPoints() const minimumSurfaceDistanceCoeffSqr_ *sqr(cellShapeControls().cellSize(midPoint)); + if (randomiseInitialGrid_) + { + midPoint.x() += pert*(rndGen().scalar01() - 0.5); + midPoint.y() += pert*(rndGen().scalar01() - 0.5); + midPoint.z() += pert*(rndGen().scalar01() - 0.5); + } + if ( magSqr(midPoint - l.start()) > minDistFromSurfaceSqr && magSqr(midPoint - l.end()) > minDistFromSurfaceSqr ) { - if (randomiseInitialGrid_) - { - midPoint.x() += pert*(rndGen().scalar01() - 0.5); - midPoint.y() += pert*(rndGen().scalar01() - 0.5); - midPoint.z() += pert*(rndGen().scalar01() - 0.5); - } - initialPoints.append(toPoint(midPoint)); } } From 668cd823b5c302ab70b6fe3afc9f86580cb812d2 Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 29 Aug 2013 17:24:30 +0100 Subject: [PATCH 25/34] BUG: corrected steadyParticleTracks utility --- .../steadyParticleTracks.C | 42 ++++++++---- .../steadyParticleTracksTemplates.C | 66 ++++++++++++------- .../steadyParticleTracksTemplates.H | 4 +- 3 files changed, 73 insertions(+), 39 deletions(-) diff --git a/applications/utilities/postProcessing/lagrangian/steadyParticleTracks/steadyParticleTracks.C b/applications/utilities/postProcessing/lagrangian/steadyParticleTracks/steadyParticleTracks.C index 5a6fad75a6..4d2ab943ac 100644 --- a/applications/utilities/postProcessing/lagrangian/steadyParticleTracks/steadyParticleTracks.C +++ b/applications/utilities/postProcessing/lagrangian/steadyParticleTracks/steadyParticleTracks.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -184,6 +184,7 @@ int main(int argc, char *argv[]) } } + if (nTracks == 0) { Info<< "\n No track data" << endl; @@ -202,11 +203,13 @@ int main(int argc, char *argv[]) // particle "age" property used to sort the tracks List > agePerTrack(nTracks); + List > particleMap(nTracks); forAll(trackLengths, i) { const label length = trackLengths[i]; agePerTrack[i].setSize(length); + particleMap[i].setSize(length); } // store the particle age per track @@ -228,6 +231,7 @@ int main(int argc, char *argv[]) const label trackI = particleToTrack[i]; const label sampleI = trackSamples[trackI]; agePerTrack[trackI][sampleI] = age[i]; + particleMap[trackI][sampleI] = i; trackSamples[trackI]++; } tage.clear(); @@ -251,21 +255,30 @@ int main(int argc, char *argv[]) Info<< "\n Writing points" << endl; { - label offset = 0; forAll(agePerTrack, i) { agePerTrack[i].sort(); + const labelList& ids = agePerTrack[i].indices(); + labelList& particleIds = particleMap[i]; + + { + // update addressing + List