From 63e57ff041bee6348e4f4cacd00eb4abe3d5692d Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 3 Nov 2011 10:24:20 +0000 Subject: [PATCH 1/8] STYLE: corrected typo --- tutorials/incompressible/pisoFoam/les/motorBike/Allrun | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/incompressible/pisoFoam/les/motorBike/Allrun b/tutorials/incompressible/pisoFoam/les/motorBike/Allrun index 634e4374e3..14cc54db66 100755 --- a/tutorials/incompressible/pisoFoam/les/motorBike/Allrun +++ b/tutorials/incompressible/pisoFoam/les/motorBike/Allrun @@ -25,7 +25,7 @@ cloneParallelCase() # Do the Spalart-Allmaras steady-state case (cd motorBike && foamRunTutorials) -# Clone the steady-stae case to the LES case +# Clone the steady-state case to the LES case cloneParallelCase motorBike motorBikeLES # Do the LES case From ed963cf3d3960025a12792b6d4afe9378c56ea4b Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 3 Nov 2011 11:11:43 +0000 Subject: [PATCH 2/8] ENH: Added flag to radiation to always evaluate on first iteration --- .../radiationModel/radiationModel/radiationModel.C | 5 ++++- .../radiationModel/radiationModel/radiationModel.H | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/thermophysicalModels/radiationModels/radiationModel/radiationModel/radiationModel.C b/src/thermophysicalModels/radiationModels/radiationModel/radiationModel/radiationModel.C index 3c968483b6..7e780fe22f 100644 --- a/src/thermophysicalModels/radiationModels/radiationModel/radiationModel/radiationModel.C +++ b/src/thermophysicalModels/radiationModels/radiationModel/radiationModel/radiationModel.C @@ -61,6 +61,7 @@ Foam::radiation::radiationModel::radiationModel(const volScalarField& T) radiation_(false), coeffs_(dictionary::null), solverFreq_(0), + firstIter_(true), absorptionEmission_(NULL), scatter_(NULL) {} @@ -89,6 +90,7 @@ Foam::radiation::radiationModel::radiationModel radiation_(lookup("radiation")), coeffs_(subDict(type + "Coeffs")), solverFreq_(readLabel(lookup("solverFreq"))), + firstIter_(true), absorptionEmission_(absorptionEmissionModel::New(*this, mesh_)), scatter_(scatterModel::New(*this, mesh_)) { @@ -130,9 +132,10 @@ void Foam::radiation::radiationModel::correct() return; } - if (time_.timeIndex() % solverFreq_ == 0) + if (firstIter_ || (time_.timeIndex() % solverFreq_ == 0)) { calculate(); + firstIter_ = false; } } diff --git a/src/thermophysicalModels/radiationModels/radiationModel/radiationModel/radiationModel.H b/src/thermophysicalModels/radiationModels/radiationModel/radiationModel/radiationModel.H index 3f58438700..f33f962784 100644 --- a/src/thermophysicalModels/radiationModels/radiationModel/radiationModel/radiationModel.H +++ b/src/thermophysicalModels/radiationModels/radiationModel/radiationModel/radiationModel.H @@ -91,6 +91,9 @@ protected: // radiation solver iteration label solverFreq_; + //- Flag to enable radiation model to be evaluated on first iteration + bool firstIter_; + // References to the radiation sub-models From 2ee61c0173fa705ad257cb62cace536aa668aa5b Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 3 Nov 2011 11:14:47 +0000 Subject: [PATCH 3/8] ENH: Updated read/write flags on G, Qr and Qin fvDOM fields --- .../radiationModels/radiationModel/fvDOM/fvDOM/fvDOM.C | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/thermophysicalModels/radiationModels/radiationModel/fvDOM/fvDOM/fvDOM.C b/src/thermophysicalModels/radiationModels/radiationModel/fvDOM/fvDOM/fvDOM.C index 094524091e..35716fe2b0 100644 --- a/src/thermophysicalModels/radiationModels/radiationModel/fvDOM/fvDOM/fvDOM.C +++ b/src/thermophysicalModels/radiationModels/radiationModel/fvDOM/fvDOM/fvDOM.C @@ -63,7 +63,7 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T) "G", mesh_.time().timeName(), mesh_, - IOobject::NO_READ, + IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), mesh_, @@ -76,7 +76,7 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T) "Qr", mesh_.time().timeName(), mesh_, - IOobject::NO_READ, + IOobject::READ_IF_PRESENT, IOobject::AUTO_WRITE ), mesh_, @@ -102,8 +102,8 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T) "Qin", mesh_.time().timeName(), mesh_, - IOobject::NO_READ, - IOobject::NO_WRITE + IOobject::READ_IF_PRESENT, + IOobject::AUTO_WRITE ), mesh_, dimensionedScalar("Qin", dimMass/pow3(dimTime), 0.0) From 35410e01ea53e6e0b73c43250cc24ccc448467df Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 3 Nov 2011 11:16:36 +0000 Subject: [PATCH 4/8] STYLE: minor code formatting --- .../radiationModels/radiationModel/fvDOM/fvDOM/fvDOM.C | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/thermophysicalModels/radiationModels/radiationModel/fvDOM/fvDOM/fvDOM.C b/src/thermophysicalModels/radiationModels/radiationModel/fvDOM/fvDOM/fvDOM.C index 35716fe2b0..61f758966f 100644 --- a/src/thermophysicalModels/radiationModels/radiationModel/fvDOM/fvDOM/fvDOM.C +++ b/src/thermophysicalModels/radiationModels/radiationModel/fvDOM/fvDOM/fvDOM.C @@ -228,7 +228,6 @@ Foam::radiation::fvDOM::fvDOM(const volScalarField& T) ); i++; } - } } @@ -277,7 +276,7 @@ bool Foam::radiation::fvDOM::read() { if (radiationModel::read()) { -// Only reading solution parameters - not changing ray geometry + // Only reading solution parameters - not changing ray geometry coeffs_.readIfPresent("convergence", convergence_); coeffs_.readIfPresent("maxIter", maxIter_); From 5ac497d403a0dfcf298701f3f391172f7d0b0583 Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 3 Nov 2011 11:25:20 +0000 Subject: [PATCH 5/8] BUG: Corrected mass source in filter tutorial --- .../filter/constant/sourcesProperties | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/sourcesProperties b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/sourcesProperties index c725f62098..0bcf0c982b 100644 --- a/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/sourcesProperties +++ b/tutorials/lagrangian/porousExplicitSourceReactingParcelFoam/filter/constant/sourcesProperties @@ -32,7 +32,9 @@ massSource1 volumeMode absolute; fieldData { + rho 1e-4; // kg/s H2O 1e-4; // kg/s + p 1e-4; // kg/s } } } From 3a4d247cee6f0fa12cda13893e8b62137ee1d7e1 Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 3 Nov 2011 14:25:59 +0000 Subject: [PATCH 6/8] ENH: Updated setting/warning for applied status of field sources --- .../actuationDiskSource/actuationDiskSource.C | 20 +------ .../actuationDiskSource/actuationDiskSource.H | 11 +--- .../basicSource/basicSource/basicSource.C | 55 ++++++++++++++----- .../basicSource/basicSource/basicSource.H | 22 +++++--- .../basicSource/basicSource/basicSourceI.H | 12 ++-- .../basicSource/basicSource/basicSourceList.C | 19 ++++--- .../basicSource/basicSource/basicSourceList.H | 5 +- .../basicSource/basicSourceListTemplates.C | 29 +++++----- .../explicitSetValue/ExplicitSetValue.C | 33 +++-------- .../explicitSetValue/ExplicitSetValue.H | 10 +--- .../explicitSource/ExplicitSource.C | 35 +++--------- .../explicitSource/ExplicitSource.H | 20 ++----- .../explicitSource/ExplicitSourceI.H | 4 +- .../pressureGradientExplicitSource.C | 35 +++--------- .../pressureGradientExplicitSource.H | 11 +--- .../radialActuationDiskSource.C | 2 - .../rotorDiskSource/rotorDiskSource.C | 19 +------ .../rotorDiskSource/rotorDiskSource.H | 12 +--- 18 files changed, 135 insertions(+), 219 deletions(-) diff --git a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.C b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.C index 33f7c5ada8..68f0c2a5bf 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.C +++ b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.C @@ -80,12 +80,14 @@ Foam::actuationDiskSource::actuationDiskSource ) : basicSource(name, modelType, dict, mesh), - fieldName_(coeffs_.lookup("fieldName")), diskDir_(coeffs_.lookup("diskDir")), Cp_(readScalar(coeffs_.lookup("Cp"))), Ct_(readScalar(coeffs_.lookup("Ct"))), diskArea_(readScalar(coeffs_.lookup("diskArea"))) { + coeffs_.lookup("fieldNames") >> fieldNames_; + applied_.setSize(fieldNames_.size(), false); + Info<< " - creating actuation disk zone: " << this->name() << endl; @@ -95,20 +97,6 @@ Foam::actuationDiskSource::actuationDiskSource // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::label Foam::actuationDiskSource::applyToField -( - const word& fieldName -) const -{ - if (fieldName == fieldName_) - { - return 0; - } - - return -1; -} - - void Foam::actuationDiskSource::addSup ( fvMatrix& eqn, @@ -150,8 +138,6 @@ void Foam::actuationDiskSource::addSup ); } } - - basicSource::addSup(eqn, fieldI); } diff --git a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.H b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.H index b0e983e11e..0774425892 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.H +++ b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.H @@ -43,7 +43,7 @@ Description actuationDiskSourceCoeffs { - fieldName U; // name of field to apply source + fieldNames (U); // names of fields to apply source diskDir (-1 0 0); // disk direction Cp 0.1; // power coefficient Ct 0.5; // thrust coefficient @@ -80,9 +80,6 @@ protected: // Protected data - //- Name of field to apply source upon - word fieldName_; - //- Disk area normal vector diskDir_; @@ -146,12 +143,6 @@ public: // Member Functions - // Check - - //- Return index of field name if found in fieldNames list - virtual label applyToField(const word& fieldName) const; - - // Access //- Return Cp diff --git a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSource.C b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSource.C index 2b10f3236c..5f454974f2 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSource.C +++ b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSource.C @@ -201,7 +201,6 @@ Foam::basicSource::basicSource dict_(dict), coeffs_(dict.subDict(modelType + "Coeffs")), active_(readBool(dict_.lookup("active"))), - applied_(false), timeStart_(readScalar(dict_.lookup("timeStart"))), duration_(readScalar(dict_.lookup("duration"))), selectionMode_ @@ -209,7 +208,9 @@ Foam::basicSource::basicSource selectionModeTypeNames_.read(dict_.lookup("selectionMode")) ), cellSetName_("none"), - V_(0.0) + V_(0.0), + fieldNames_(), + applied_() { setSelection(dict_); @@ -228,7 +229,7 @@ Foam::autoPtr Foam::basicSource::New { word modelType(coeffs.lookup("type")); - Info<< "Selecting model type " << modelType << endl; + Info<< "Selecting source model type " << modelType << endl; dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTablePtr_->find(modelType); @@ -275,15 +276,43 @@ bool Foam::basicSource::isActive() } +Foam::label Foam::basicSource::applyToField(const word& fieldName) const +{ + forAll(fieldNames_, i) + { + if (fieldNames_[i] == fieldName) + { + return i; + } + } + + return -1; +} + + +void Foam::basicSource::checkApplied() const +{ + forAll(applied_, i) + { + if (!applied_[i]) + { + WarningIn("void Foam::basicSource::checkApplied() const") + << "Source " << name_ << " defined for field " + << fieldNames_[i] << " but never used" << endl; + } + } +} + + void Foam::basicSource::addSup(fvMatrix& eqn, const label fieldI) { - applied_ = true; + // do nothing } void Foam::basicSource::addSup(fvMatrix& eqn, const label fieldI) { - applied_ = true; + // do nothing } @@ -293,31 +322,31 @@ void Foam::basicSource::addSup const label fieldI ) { - applied_ = true; + // do nothing } void Foam::basicSource::addSup(fvMatrix& eqn, const label fieldI) { - applied_ = true; + // do nothing } void Foam::basicSource::addSup(fvMatrix& eqn, const label fieldI) { - applied_ = true; + // do nothing } void Foam::basicSource::setValue(fvMatrix& eqn, const label fieldI) { - applied_ = true; + // do nothing } void Foam::basicSource::setValue(fvMatrix& eqn, const label fieldI) { - applied_ = true; + // do nothing } @@ -327,7 +356,7 @@ void Foam::basicSource::setValue const label fieldI ) { - applied_ = true; + // do nothing } @@ -337,13 +366,13 @@ void Foam::basicSource::setValue const label fieldI ) { - applied_ = true; + // do nothing } void Foam::basicSource::setValue(fvMatrix& eqn, const label fieldI) { - applied_ = true; + // do nothing } diff --git a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSource.H b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSource.H index f8a74cc6de..c70a2ba267 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSource.H +++ b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSource.H @@ -97,9 +97,6 @@ protected: //- Source active flag bool active_; - //- Flag to indicate whether or not the source has been applied - bool applied_; - //- Time start scalar timeStart_; @@ -121,6 +118,12 @@ protected: //- Sum of cell volumes scalar V_; + //- Field names to apply source to - populated by derived models + wordList fieldNames_; + + //- Applied flag list - corresponds to each fieldNames_ entry + List applied_; + // Protected functions @@ -242,9 +245,6 @@ public: //- Return const access to the source active flag inline bool active() const; - //- Return const access to the applied flag - inline bool applied() const; - //- Return const access to the time start inline scalar timeStart() const; @@ -267,6 +267,9 @@ public: //- Return const access to the cell set inline const labelList& cells() const; + //- Set the applied flag to true for field index fieldI + inline void setApplied(const label fieldI); + // Edit @@ -283,10 +286,13 @@ public: // Checks //- Is the source active? - bool isActive(); + virtual bool isActive(); //- Return index of field name if found in fieldNames list - virtual label applyToField(const word& fieldName) const = 0; + virtual label applyToField(const word& fieldName) const; + + //- Check that the source has been applied + virtual void checkApplied() const; // Evaluation diff --git a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSourceI.H b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSourceI.H index 47c348e105..daf00bfc7c 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSourceI.H +++ b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSourceI.H @@ -51,12 +51,6 @@ inline bool Foam::basicSource::active() const } -inline bool Foam::basicSource::applied() const -{ - return applied_; -} - - inline Foam::scalar Foam::basicSource::timeStart() const { return timeStart_; @@ -100,6 +94,12 @@ inline const Foam::labelList& Foam::basicSource::cells() const } +inline void Foam::basicSource::setApplied(const label fieldI) +{ + applied_[fieldI] = true; +} + + inline bool& Foam::basicSource::active() { return active_; diff --git a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSourceList.C b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSourceList.C index 8b471084e3..1fe8bd12c2 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSourceList.C +++ b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSourceList.C @@ -25,6 +25,8 @@ License #include "basicSourceList.H" #include "addToRunTimeSelectionTable.H" +#include "fvMesh.H" +#include "Time.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -38,14 +40,12 @@ namespace Foam void Foam::basicSourceList::checkApplied() const { - forAll(*this, i) + if (mesh_.time().timeIndex() == checkTimeIndex_) { - const basicSource& bs = this->operator[](i); - - if (!bs.applied()) + forAll(*this, i) { - WarningIn("void Foam::basicSourceList::checkApplied() const") - << "Source " << bs.name() << " defined, but not used" << endl; + const basicSource& bs = this->operator[](i); + bs.checkApplied(); } } } @@ -60,7 +60,8 @@ Foam::basicSourceList::basicSourceList ) : PtrList(), - mesh_(mesh) + mesh_(mesh), + checkTimeIndex_(mesh_.time().startTimeIndex() + 2) { label count = 0; forAllConstIter(dictionary, dict, iter) @@ -95,6 +96,8 @@ Foam::basicSourceList::basicSourceList bool Foam::basicSourceList::read(const dictionary& dict) { + checkTimeIndex_ = mesh_.time().timeIndex() + 2; + bool allOk = true; forAll(*this, i) { @@ -111,7 +114,7 @@ bool Foam::basicSourceList::writeData(Ostream& os) const // Write list contents forAll(*this, i) { - os << nl; + os << nl; this->operator[](i).writeData(os); } diff --git a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSourceList.H b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSourceList.H index 68d848289c..59134e64c2 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSourceList.H +++ b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSourceList.H @@ -45,7 +45,7 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class basicSourceList Declaration + Class basicSourceList Declaration \*---------------------------------------------------------------------------*/ class basicSourceList @@ -59,6 +59,9 @@ private: //- Reference to the mesh database const fvMesh& mesh_; + //- Time index to check that all defined sources have been applied + label checkTimeIndex_; + // Private Member Functions diff --git a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSourceListTemplates.C b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSourceListTemplates.C index 91a03ceb70..fef93a9e95 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSourceListTemplates.C +++ b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSourceListTemplates.C @@ -23,18 +23,12 @@ License \*---------------------------------------------------------------------------*/ -#include "fvMesh.H" -#include "Time.H" - // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template void Foam::basicSourceList::apply(fvMatrix& eqn) { - if (mesh_.time().timeIndex() == mesh_.time().startTimeIndex() + 2) - { - checkApplied(); - } + checkApplied(); const word& fieldName = eqn.psi().name(); @@ -44,16 +38,21 @@ void Foam::basicSourceList::apply(fvMatrix& eqn) label fieldI = source.applyToField(fieldName); - if (source.isActive() && (fieldI != -1)) + if (fieldI != -1) { - if (debug) - { - Info<< "Applying source " << source.name() << " to field " - << fieldName << endl; - } + source.setApplied(fieldI); - source.addSup(eqn, fieldI); - source.setValue(eqn, fieldI); + if (source.isActive()) + { + if (debug) + { + Info<< "Applying source " << source.name() << " to field " + << fieldName << endl; + } + + source.addSup(eqn, fieldI); + source.setValue(eqn, fieldI); + } } } } diff --git a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/explicitSetValue/ExplicitSetValue.C b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/explicitSetValue/ExplicitSetValue.C index b21091a647..6a14cb2bff 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/explicitSetValue/ExplicitSetValue.C +++ b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/explicitSetValue/ExplicitSetValue.C @@ -33,13 +33,16 @@ License template void Foam::ExplicitSetValue::setFieldData(const dictionary& dict) { - fieldData_.setSize(dict.toc().size()); + fieldNames_.setSize(dict.toc().size()); + fieldData_.setSize(fieldNames_.size()); + + applied_.setSize(fieldNames_.size(), false); label i = 0; forAllConstIter(dictionary, dict, iter) { - fieldData_[i].first() = iter().keyword(); - dict.lookup(iter().keyword()) >> fieldData_[i].second(); + fieldNames_[i] = iter().keyword(); + dict.lookup(iter().keyword()) >> fieldData_[i]; i++; } } @@ -65,24 +68,6 @@ Foam::ExplicitSetValue::ExplicitSetValue // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -Foam::label Foam::ExplicitSetValue::applyToField -( - const word& fieldName -) const -{ - forAll(fieldData_, i) - { - if (fieldData_[i].first() == fieldName) - { - return i; - } - } - - return -1; -} - - template void Foam::ExplicitSetValue::setValue ( @@ -100,7 +85,7 @@ void Foam::ExplicitSetValue::setValue ( IOobject ( - name_ + fieldData_[fieldI].first() + "rhs", + name_ + fieldNames_[fieldI] + "rhs", eqn.psi().mesh().time().timeName(), eqn.psi().mesh(), IOobject::NO_READ, @@ -120,12 +105,10 @@ void Foam::ExplicitSetValue::setValue forAll(values, i) { - values[i] = fieldData_[fieldI].second(); + values[i] = fieldData_[fieldI]; } eqn.setValues(cells_, values); - - basicSource::setValue(eqn, fieldI); } diff --git a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/explicitSetValue/ExplicitSetValue.H b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/explicitSetValue/ExplicitSetValue.H index 7c78084fc8..58a50ea75c 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/explicitSetValue/ExplicitSetValue.H +++ b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/explicitSetValue/ExplicitSetValue.H @@ -69,10 +69,8 @@ protected: // Protected data - typedef Tuple2 fieldNameValuePair; - //- Source value per field - List fieldData_; + List fieldData_; // Protected functions @@ -101,12 +99,6 @@ public: // Member Functions - // Check - - //- Return index of field name if found in fieldNames list - virtual label applyToField(const word& fieldName) const; - - // Evaluation //- Set value on vector field diff --git a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/explicitSource/ExplicitSource.C b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/explicitSource/ExplicitSource.C index 0df1c4fabc..b95cd7ba0e 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/explicitSource/ExplicitSource.C +++ b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/explicitSource/ExplicitSource.C @@ -87,13 +87,16 @@ Foam::word Foam::ExplicitSource::volumeModeTypeToWord template void Foam::ExplicitSource::setFieldData(const dictionary& dict) { - fieldData_.setSize(dict.toc().size()); + fieldNames_.setSize(dict.toc().size()); + fieldData_.setSize(fieldNames_.size()); + + applied_.setSize(fieldNames_.size(), false); label i = 0; forAllConstIter(dictionary, dict, iter) { - fieldData_[i].first() = iter().keyword(); - dict.lookup(iter().keyword()) >> fieldData_[i].second(); + fieldNames_[i] = iter().keyword(); + dict.lookup(iter().keyword()) >> fieldData_[i]; i++; } @@ -127,24 +130,6 @@ Foam::ExplicitSource::ExplicitSource // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -Foam::label Foam::ExplicitSource::applyToField -( - const word& fieldName -) const -{ - forAll(fieldData_, i) - { - if (fieldData_[i].first() == fieldName) - { - return i; - } - } - - return -1; -} - - template void Foam::ExplicitSource::addSup ( @@ -152,7 +137,7 @@ void Foam::ExplicitSource::addSup const label fieldI ) { - if (debug) +// if (debug) { Info<< "ExplicitSource<"<< pTraits::typeName << ">::addSup for source " << name_ << endl; @@ -162,7 +147,7 @@ void Foam::ExplicitSource::addSup ( IOobject ( - name_ + fieldData_[fieldI].first() + "Sup", + name_ + fieldNames_[fieldI] + "Sup", mesh_.time().timeName(), mesh_, IOobject::NO_READ, @@ -180,12 +165,10 @@ void Foam::ExplicitSource::addSup forAll(cells_, i) { - Su[cells_[i]] = fieldData_[fieldI].second()/VDash_; + Su[cells_[i]] = fieldData_[fieldI]/VDash_; } eqn -= Su; - - basicSource::addSup(eqn, fieldI); } diff --git a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/explicitSource/ExplicitSource.H b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/explicitSource/ExplicitSource.H index 5c1d3daa2f..7248b5ef26 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/explicitSource/ExplicitSource.H +++ b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/explicitSource/ExplicitSource.H @@ -104,16 +104,14 @@ protected: // Protected data - typedef Tuple2 fieldNameValuePair; - //- Volume mode volumeModeType volumeMode_; //- Volume normalisation scalar VDash_; - //- Source value per field - List fieldData_; + //- Source field values + List fieldData_; // Protected functions @@ -148,19 +146,13 @@ public: // Member Functions - // Check - - //- Return index of field name if found in fieldNames list - virtual label applyToField(const word& fieldName) const; - - // Access //- Return const access to the volume mode inline const volumeModeType& volumeMode() const; - //- Return const access to the source field value - inline const Type& fieldData() const; + //- Return const access to the source field values + inline const List& fieldData() const; // Edit @@ -168,8 +160,8 @@ public: //- Return access to the volume mode inline volumeModeType& volumeMode(); - //- Return access to the source field value - inline Type& fieldData(); + //- Return access to the source field values + inline List& fieldData(); // Evaluation diff --git a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/explicitSource/ExplicitSourceI.H b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/explicitSource/ExplicitSourceI.H index 0cb38f2a53..14276e0197 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/explicitSource/ExplicitSourceI.H +++ b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/explicitSource/ExplicitSourceI.H @@ -36,7 +36,7 @@ Foam::ExplicitSource::volumeMode() const template -inline const Type& Foam::ExplicitSource::fieldData() const +inline const Foam::List& Foam::ExplicitSource::fieldData() const { return fieldData_; } @@ -51,7 +51,7 @@ Foam::ExplicitSource::volumeMode() template -inline Type& Foam::ExplicitSource::fieldData() +inline Foam::List& Foam::ExplicitSource::fieldData() { return fieldData_; } diff --git a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/pressureGradientExplicitSource/pressureGradientExplicitSource.C b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/pressureGradientExplicitSource/pressureGradientExplicitSource.C index 79f2751e7b..e3ff7ca50e 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/pressureGradientExplicitSource/pressureGradientExplicitSource.C +++ b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/pressureGradientExplicitSource/pressureGradientExplicitSource.C @@ -69,15 +69,12 @@ void Foam::pressureGradientExplicitSource::writeGradP() const } -void Foam::pressureGradientExplicitSource::update() +void Foam::pressureGradientExplicitSource::update(fvMatrix& eqn) { - volVectorField& U = const_cast - ( - mesh_.lookupObject(UName_) - ); + volVectorField& U = const_cast(eqn.psi()); const volScalarField& rAU = - mesh_.lookupObject("(1|A(" + UName_ + "))"); + mesh_.lookupObject("(1|A(" + U.name() + "))"); // Integrate flow variables over cell set scalar magUbarAve = 0.0; @@ -130,12 +127,14 @@ Foam::pressureGradientExplicitSource::pressureGradientExplicitSource ) : basicSource(sourceName, modelType, dict, mesh), - UName_(coeffs_.lookupOrDefault("UName", "U")), Ubar_(coeffs_.lookup("Ubar")), gradPini_(coeffs_.lookup("gradPini")), gradP_(gradPini_), flowDir_(Ubar_/mag(Ubar_)) { + coeffs_.lookup("fieldNames") >> fieldNames_; + applied_.setSize(fieldNames_.size(), false); + // Read the initial pressure gradient from file if it exists IFstream propsFile ( @@ -155,35 +154,19 @@ Foam::pressureGradientExplicitSource::pressureGradientExplicitSource // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::label Foam::pressureGradientExplicitSource::applyToField -( - const word& fieldName -) const -{ - if (fieldName == UName_) - { - return 0; - } - else - { - return -1; - } -} - - void Foam::pressureGradientExplicitSource::addSup ( fvMatrix& eqn, - const label + const label fieldI ) { - update(); + update(eqn); DimensionedField Su ( IOobject ( - name_ + UName_ + "Sup", + name_ + fieldNames_[fieldI] + "Sup", mesh_.time().timeName(), mesh_, IOobject::NO_READ, diff --git a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/pressureGradientExplicitSource/pressureGradientExplicitSource.H b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/pressureGradientExplicitSource/pressureGradientExplicitSource.H index 9c3732da49..287c1701f3 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/pressureGradientExplicitSource/pressureGradientExplicitSource.H +++ b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/pressureGradientExplicitSource/pressureGradientExplicitSource.H @@ -70,9 +70,6 @@ class pressureGradientExplicitSource { // Private data - //- Velocity field name - word UName_; - //- Average velocity vector Ubar_; @@ -92,7 +89,7 @@ class pressureGradientExplicitSource void writeGradP() const; //- Correct driving force for a constant mass flow rate - void update(); + void update(fvMatrix& eqn); //- Disallow default bitwise copy construct pressureGradientExplicitSource(const pressureGradientExplicitSource&); @@ -121,12 +118,6 @@ public: // Member Functions - // Checks - - //- Return index of field name if found in fieldNames list - virtual label applyToField(const word& fieldName) const; - - // Access //- Add explicit contribution to equation diff --git a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/radialActuationDiskSource/radialActuationDiskSource.C b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/radialActuationDiskSource/radialActuationDiskSource.C index b43c00d2a0..4a5631270a 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/radialActuationDiskSource/radialActuationDiskSource.C +++ b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/radialActuationDiskSource/radialActuationDiskSource.C @@ -102,8 +102,6 @@ void Foam::radialActuationDiskSource::addSup ); } } - - basicSource::addSup(eqn, fieldI); } diff --git a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/rotorDiskSource/rotorDiskSource.C b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/rotorDiskSource/rotorDiskSource.C index 6309f450db..02f29fcd77 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/rotorDiskSource/rotorDiskSource.C +++ b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/rotorDiskSource/rotorDiskSource.C @@ -368,7 +368,6 @@ Foam::rotorDiskSource::rotorDiskSource ) : basicSource(name, modelType, dict, mesh), - fieldName_(coeffs_.lookup("fieldName")), rhoName_("none"), omega_(0.0), nBlades_(0), @@ -398,19 +397,6 @@ Foam::rotorDiskSource::~rotorDiskSource() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -Foam::label Foam::rotorDiskSource::applyToField(const word& fieldName) const -{ - if (fieldName == fieldName_) - { - return 0; - } - else - { - return -1; - } -} - - void Foam::rotorDiskSource::addSup(fvMatrix& eqn, const label fieldI) { // add source to lhs of eqn @@ -440,8 +426,6 @@ void Foam::rotorDiskSource::addSup(fvMatrix& eqn, const label fieldI) dimForce/dimVolume/dimDensity ); } - - basicSource::addSup(eqn, fieldI); } @@ -456,6 +440,9 @@ bool Foam::rotorDiskSource::read(const dictionary& dict) { if (basicSource::read(dict)) { + coeffs_.lookup("fieldNames") >> fieldNames_; + applied_.setSize(fieldNames_.size(), false); + scalar rpm(readScalar(coeffs_.lookup("rpm"))); omega_ = rpm/60.0*mathematical::twoPi; diff --git a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/rotorDiskSource/rotorDiskSource.H b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/rotorDiskSource/rotorDiskSource.H index 4113463d4b..7565fa17ce 100644 --- a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/rotorDiskSource/rotorDiskSource.H +++ b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/rotorDiskSource/rotorDiskSource.H @@ -34,7 +34,7 @@ Description rotorDiskSourceCoeffs { - fieldName U; // name of field on which to apply source + fieldNames (U); // names of fields on which to apply source rhoName rho; // density field if compressible case nBlades 3; // number of blades tip effect 0.96; // normalised radius above which lift = 0 @@ -149,9 +149,6 @@ protected: // Protected data - //- Name of field on which to apply the source - word fieldName_; - //- Name of density field word rhoName_; @@ -263,13 +260,6 @@ public: // Member Functions - - // Checks - - //- Return index of field name if found in fieldNames list - virtual label applyToField(const word& fieldName) const; - - // Source term addition //- Source term to fvMatrix From 55b8ee3be39c17e99bdc6d9012bc0dbdad980650 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 3 Nov 2011 16:06:33 +0000 Subject: [PATCH 7/8] ENH: zone.C: added check for duplicate entry in zone --- src/OpenFOAM/meshes/polyMesh/zones/zone/zone.C | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.C b/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.C index b23165415b..9d1b6e1504 100644 --- a/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.C +++ b/src/OpenFOAM/meshes/polyMesh/zones/zone/zone.C @@ -26,6 +26,7 @@ License #include "zone.H" #include "IOstream.H" #include "demandDrivenData.H" +#include "HashSet.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -192,6 +193,9 @@ bool Foam::zone::checkDefinition(const label maxSize, const bool report) const bool hasError = false; + // To check for duplicate entries + labelHashSet elems(size()); + forAll(addr, i) { if (addr[i] < 0 || addr[i] >= maxSize) @@ -215,6 +219,18 @@ bool Foam::zone::checkDefinition(const label maxSize, const bool report) const break; } } + else if (!elems.insert(addr[i])) + { + if (report) + { + WarningIn + ( + "bool zone::checkDefinition(" + "const label maxSize, const bool report) const" + ) << "Zone " << name_ + << " contains duplicate index label " << addr[i] << endl; + } + } } return hasError; From b7da29f0821d0e19ad844630a2d0eed56d246213 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 3 Nov 2011 16:07:55 +0000 Subject: [PATCH 8/8] ENH: FacePostProcessing: handle boundary faces --- .../FacePostProcessing/FacePostProcessing.C | 31 ++++++++++++++++--- 1 file changed, 27 insertions(+), 4 deletions(-) diff --git a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FacePostProcessing/FacePostProcessing.C b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FacePostProcessing/FacePostProcessing.C index 7af50ed59f..8888cdaa33 100644 --- a/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FacePostProcessing/FacePostProcessing.C +++ b/src/lagrangian/intermediate/submodels/CloudFunctionObjects/FacePostProcessing/FacePostProcessing.C @@ -306,6 +306,7 @@ Foam::FacePostProcessing::FacePostProcessing DynamicList