From 27ab6fcf946537acd8b811c3af9436cfda866fb1 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 14 Jun 2011 10:52:48 +0100 Subject: [PATCH 1/4] ENH: RADModel.C: clip log input --- src/turbulenceModels/compressible/RAS/RASModel/RASModel.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/turbulenceModels/compressible/RAS/RASModel/RASModel.C b/src/turbulenceModels/compressible/RAS/RASModel/RASModel.C index 6c997ec5b5..b08a8941d9 100644 --- a/src/turbulenceModels/compressible/RAS/RASModel/RASModel.C +++ b/src/turbulenceModels/compressible/RAS/RASModel/RASModel.C @@ -165,7 +165,7 @@ scalar RASModel::yPlusLam(const scalar kappa, const scalar E) const for (int i=0; i<10; i++) { - ypl = log(E*ypl)/kappa; + ypl = log(max(E*ypl, 1))/kappa; } return ypl; From f2090ca372f7375ff030c0f6c6d9bae0460751e3 Mon Sep 17 00:00:00 2001 From: mattijs Date: Tue, 14 Jun 2011 23:18:06 +0100 Subject: [PATCH 2/4] ENH: RASModel.C: clip log input --- src/turbulenceModels/compressible/RAS/RASModel/RASModel.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/turbulenceModels/compressible/RAS/RASModel/RASModel.C b/src/turbulenceModels/compressible/RAS/RASModel/RASModel.C index b08a8941d9..07f7cd01b1 100644 --- a/src/turbulenceModels/compressible/RAS/RASModel/RASModel.C +++ b/src/turbulenceModels/compressible/RAS/RASModel/RASModel.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 From 7517f6f9b2462657d6440be3c813bfd7eb02b1d3 Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 15 Jun 2011 11:06:13 +0100 Subject: [PATCH 3/4] BUG: explicitSource: work on matrix, not matrix.source() level --- .../actuationDiskSource/actuationDiskSource.C | 30 +--- .../actuationDiskSource/actuationDiskSource.H | 22 +-- .../basicSource/basicSource/basicSource.C | 121 +++++++------- .../basicSource/basicSource/basicSource.H | 45 +----- .../basicSource/basicSource/basicSourceI.H | 33 +--- .../basicSource/basicSource/basicSourceIO.C | 28 ++-- .../basicSource/basicSource/basicSourceList.C | 53 +------ .../basicSource/basicSource/basicSourceList.H | 11 +- .../explicitSource/explicitSource.C | 150 ++---------------- .../explicitSource/explicitSource.H | 99 ++---------- .../explicitSource/explicitSourceI.H | 2 + .../explicitSource/explicitSourceIO.C | 4 +- .../explicitSource/explicitSourceTemplates.C | 39 ++++- .../turbineSiting/constant/sourcesProperties | 4 +- 14 files changed, 154 insertions(+), 487 deletions(-) diff --git a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.C b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.C index a4f5773bfa..d2b6b6ba2a 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.C +++ b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.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 @@ -41,7 +41,7 @@ namespace Foam // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -void Foam::actuationDiskSource::checkData() +void Foam::actuationDiskSource::checkData() const { if (magSqr(diskArea_) <= VSMALL) { @@ -74,7 +74,6 @@ Foam::actuationDiskSource::actuationDiskSource ) : basicSource(name, dict, mesh), - cellZoneID_(mesh.cellZones().findZoneID(this->cellSetName())), dict_(dict.subDict(typeName + "Coeffs")), diskDir_(dict_.lookup("diskDir")), Cp_(readScalar(dict_.lookup("Cp"))), @@ -84,20 +83,6 @@ Foam::actuationDiskSource::actuationDiskSource Info<< " - creating actuation disk zone: " << this->name() << endl; - bool foundZone = (cellZoneID_ != -1); - - reduce(foundZone, orOp()); - - if (!foundZone && Pstream::master()) - { - FatalErrorIn - ( - "Foam::actuationDiskSource::actuationDiskSource" - "(const word&, const dictionary&, const fvMesh&)" - ) << "cannot find porous cellZone " << this->name() - << exit(FatalError); - } - checkData(); } @@ -106,18 +91,12 @@ Foam::actuationDiskSource::actuationDiskSource void Foam::actuationDiskSource::addSu(fvMatrix& UEqn) { - if (cellZoneID_ == -1) - { - return; - } - bool compressible = false; if (UEqn.dimensions() == dimensionSet(1, 1, -2, 0, 0)) { compressible = true; } - const labelList& cells = mesh_.cellZones()[cellZoneID_]; const scalarField& V = this->mesh().V(); vectorField& Usource = UEqn.source(); const vectorField& U = UEqn.psi(); @@ -127,7 +106,7 @@ void Foam::actuationDiskSource::addSu(fvMatrix& UEqn) addActuationDiskAxialInertialResistance ( Usource, - cells, + cells_, V, this->mesh().lookupObject("rho"), U @@ -138,7 +117,7 @@ void Foam::actuationDiskSource::addSu(fvMatrix& UEqn) addActuationDiskAxialInertialResistance ( Usource, - cells, + cells_, V, geometricOneField(), U @@ -149,7 +128,6 @@ void Foam::actuationDiskSource::addSu(fvMatrix& UEqn) void Foam::actuationDiskSource::writeData(Ostream& os) const { - os << indent << token::BEGIN_BLOCK << incrIndent << nl; os.writeKeyword("name") << this->name() << token::END_STATEMENT << nl; diff --git a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.H b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.H index 6b21973af3..9646a9641f 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.H +++ b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.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 @@ -71,9 +71,6 @@ class actuationDiskSource { // Private data - //- Cell zone ID - label cellZoneID_; - //- Sub dictionary with actuationDisk information const dictionary& dict_; @@ -93,7 +90,7 @@ class actuationDiskSource // Private Member Functions //- Check data - void checkData(); + void checkData() const; //- Add resistance to the UEqn template @@ -139,12 +136,6 @@ public: // Access - //- cellZone number - label zoneId() const - { - return cellZoneID_; - } - //- Return Cp scalar Cp() const { @@ -178,15 +169,6 @@ public: //-Source term to fvMatrix virtual void addSu(fvMatrix& UEqn){} - //- Add all explicit source - virtual void addExplicitSources(){} - - //- Add source to scalar field - virtual void addSu(DimensionedField& field){} - - //- Add source to vector field - virtual void addSu(DimensionedField& field){} - // I-O diff --git a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSource.C b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSource.C index a42ecd25f0..40f013b2d5 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSource.C +++ b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSource.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 @@ -39,65 +39,32 @@ namespace Foam // * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * // -const Foam::wordList Foam::basicSource::selectionModeTypeNames_ -( - IStringStream("(points cellSet cellZone all)")() -); +template<> const char* Foam::NamedEnum +< + Foam::basicSource::selectionModeType, + 4 +>::names[] = +{ + "points", + "cellSet", + "cellZone", + "all" +}; + + +const Foam::NamedEnum + Foam::basicSource::selectionModeTypeNames_; // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -Foam::basicSource::selectionModeType Foam::basicSource::wordToSelectionModeType -( - const word& smtName -) const -{ - forAll(selectionModeTypeNames_, i) - { - if (smtName == selectionModeTypeNames_[i]) - { - return selectionModeType(i); - } - } - - FatalErrorIn - ( - "basicSource::selectionModeType" - "basicSource::wordToSelectionModeType" - "(" - "const word&" - ")" - ) << "Unknown selectionMode type " << smtName - << ". Valid selectionMode types are:" << nl << selectionModeTypeNames_ - << exit(FatalError); - - return selectionModeType(0); -} - - -Foam::word Foam::basicSource::selectionModeTypeToWord -( - const selectionModeType& smtType -) const -{ - if (smtType > selectionModeTypeNames_.size()) - { - return "UNKNOWN"; - } - else - { - return selectionModeTypeNames_[smtType]; - } -} - - void Foam::basicSource::setSelection(const dictionary& dict) { switch (selectionMode_) { case smPoints: { - // Do nothing. It should be sorted out by derived class + dict.lookup("points") >> points_; break; } case smCellSet: @@ -135,6 +102,29 @@ void Foam::basicSource::setCellSet() { case smPoints: { + Info<< indent << "- selecting cells using points" << endl; + + labelHashSet selectedCells; + + forAll(points_, i) + { + label cellI = mesh_.findCell(points_[i]); + if (cellI >= 0) + { + selectedCells.insert(cellI); + } + + label globalCellI = returnReduce(cellI, maxOp