diff --git a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFilmFoam/VoFSolidificationMeltingSource/VoFSolidificationMeltingSource.C b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFilmFoam/VoFSolidificationMeltingSource/VoFSolidificationMeltingSource.C index 16eff5c6f917989350b682a99e9f74e644e3344f..864ebe11b99a00bede650855ad9aeecb5c5f7028 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFilmFoam/VoFSolidificationMeltingSource/VoFSolidificationMeltingSource.C +++ b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFilmFoam/VoFSolidificationMeltingSource/VoFSolidificationMeltingSource.C @@ -144,10 +144,11 @@ Foam::fv::VoFSolidificationMeltingSource::VoFSolidificationMeltingSource ), curTimeIndex_(-1) { - fieldNames_.setSize(2); + fieldNames_.resize(2); fieldNames_[0] = "U"; fieldNames_[1] = "T"; - applied_.setSize(fieldNames_.size(), false); + + fv::option::resetApplied(); } diff --git a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFilmFoam/VoFSolidificationMeltingSource/VoFSolidificationMeltingSourceIO.C b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFilmFoam/VoFSolidificationMeltingSource/VoFSolidificationMeltingSourceIO.C index d5c7979fff6878a487f2cde6f499f4b93433bbaa..069c34d6ba1ad54896261f217b9d896d6681b3ff 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFilmFoam/VoFSolidificationMeltingSource/VoFSolidificationMeltingSourceIO.C +++ b/applications/solvers/multiphase/compressibleInterFoam/compressibleInterFilmFoam/VoFSolidificationMeltingSource/VoFSolidificationMeltingSourceIO.C @@ -41,10 +41,6 @@ bool Foam::fv::VoFSolidificationMeltingSource::read(const dictionary& dict) return true; } - else - { - return false; - } return false; } diff --git a/src/atmosphericModels/fvOptions/atmAmbientTurbSource/atmAmbientTurbSource.C b/src/atmosphericModels/fvOptions/atmAmbientTurbSource/atmAmbientTurbSource.C index 932942adc73f224238e91c5872071a70745ea97d..8f8b5e0ffca70a79cce3c42135ddda3622269cf6 100644 --- a/src/atmosphericModels/fvOptions/atmAmbientTurbSource/atmAmbientTurbSource.C +++ b/src/atmosphericModels/fvOptions/atmAmbientTurbSource/atmAmbientTurbSource.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2020 ENERCON GmbH - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -107,7 +107,7 @@ Foam::fv::atmAmbientTurbSource::atmAmbientTurbSource << abort(FatalError); } - fieldNames_.setSize(2, "undefined"); + fieldNames_.resize(2); tmp<volScalarField> tepsilon = turbPtr->epsilon(); tmp<volScalarField> tomega = turbPtr->omega(); @@ -140,7 +140,7 @@ Foam::fv::atmAmbientTurbSource::atmAmbientTurbSource fieldNames_[1] = turbPtr->k()().name(); - applied_.setSize(fieldNames_.size(), false); + fv::option::resetApplied(); Log << " Applying atmAmbientTurbSource to: " << fieldNames_[0] << " and " << fieldNames_[1] diff --git a/src/atmosphericModels/fvOptions/atmBuoyancyTurbSource/atmBuoyancyTurbSource.C b/src/atmosphericModels/fvOptions/atmBuoyancyTurbSource/atmBuoyancyTurbSource.C index 4cbbffc2d6b93af0daa9a925e82285227371bb5e..111bafe6b2ea57053e571848a66639a4f5554e5a 100644 --- a/src/atmosphericModels/fvOptions/atmBuoyancyTurbSource/atmBuoyancyTurbSource.C +++ b/src/atmosphericModels/fvOptions/atmBuoyancyTurbSource/atmBuoyancyTurbSource.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2020 ENERCON GmbH - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -198,7 +198,7 @@ Foam::fv::atmBuoyancyTurbSource::atmBuoyancyTurbSource << abort(FatalError); } - fieldNames_.setSize(2, "undefined"); + fieldNames_.resize(2); tmp<volScalarField> tepsilon = turbPtr->epsilon(); tmp<volScalarField> tomega = turbPtr->omega(); @@ -232,7 +232,7 @@ Foam::fv::atmBuoyancyTurbSource::atmBuoyancyTurbSource fieldNames_[1] = turbPtr->k()().name(); - applied_.setSize(fieldNames_.size(), false); + fv::option::resetApplied(); Log << " Applying atmBuoyancyTurbSource to: " << fieldNames_[0] << " and " << fieldNames_[1] diff --git a/src/atmosphericModels/fvOptions/atmCoriolisUSource/atmCoriolisUSource.C b/src/atmosphericModels/fvOptions/atmCoriolisUSource/atmCoriolisUSource.C index 04e6c1cf3bb6f79cda14193f1e1efec57389c734..d53653d5ad7ea00005c58a39e5a5734d55b08f71 100644 --- a/src/atmosphericModels/fvOptions/atmCoriolisUSource/atmCoriolisUSource.C +++ b/src/atmosphericModels/fvOptions/atmCoriolisUSource/atmCoriolisUSource.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2020 CENER - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -109,9 +109,9 @@ Foam::fv::atmCoriolisUSource::atmCoriolisUSource << endl; } - fieldNames_.setSize(1, "U"); + fieldNames_.resize(1, "U"); - applied_.setSize(fieldNames_.size(), false); + fv::option::resetApplied(); Log << " Applying atmCoriolisUSource to: " << fieldNames_[0] << endl; } diff --git a/src/atmosphericModels/fvOptions/atmLengthScaleTurbSource/atmLengthScaleTurbSource.C b/src/atmosphericModels/fvOptions/atmLengthScaleTurbSource/atmLengthScaleTurbSource.C index f22c8886f2b26713fa068eca44fbd0e9fdf5ccba..c45ab84f1d75fdb8e30174c842246086fb47f187 100644 --- a/src/atmosphericModels/fvOptions/atmLengthScaleTurbSource/atmLengthScaleTurbSource.C +++ b/src/atmosphericModels/fvOptions/atmLengthScaleTurbSource/atmLengthScaleTurbSource.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2020 ENERCON GmbH - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -134,7 +134,7 @@ Foam::fv::atmLengthScaleTurbSource::atmLengthScaleTurbSource << abort(FatalError); } - fieldNames_.setSize(1, "undefined"); + fieldNames_.resize(1); tmp<volScalarField> tepsilon = turbPtr->epsilon(); tmp<volScalarField> tomega = turbPtr->omega(); @@ -165,7 +165,7 @@ Foam::fv::atmLengthScaleTurbSource::atmLengthScaleTurbSource << abort(FatalError); } - applied_.setSize(fieldNames_.size(), false); + fv::option::resetApplied(); Log << " Applying atmLengthScaleTurbSource to: " << fieldNames_[0] << endl; diff --git a/src/atmosphericModels/fvOptions/atmNutSource/atmNutSource.C b/src/atmosphericModels/fvOptions/atmNutSource/atmNutSource.C index 4a558d9678107cae05f602e7c1a502fb6d10b656..b67ce2ab739e78769c1b1e8ffe523a1b95462098 100644 --- a/src/atmosphericModels/fvOptions/atmNutSource/atmNutSource.C +++ b/src/atmosphericModels/fvOptions/atmNutSource/atmNutSource.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2020 ENERCON GmbH - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -88,7 +88,7 @@ Foam::fv::atmNutSource::atmNutSource << abort(FatalError); } - fieldNames_.setSize(1, "undefined"); + fieldNames_.resize(1); const tmp<volScalarField>& tnut = turbPtr->nut(); @@ -104,7 +104,7 @@ Foam::fv::atmNutSource::atmNutSource << abort(FatalError); } - applied_.setSize(fieldNames_.size(), false); + fv::option::resetApplied(); Log << " Applying atmNutSource to: " << fieldNames_[0] << endl; } diff --git a/src/atmosphericModels/fvOptions/atmPlantCanopyTSource/atmPlantCanopyTSource.C b/src/atmosphericModels/fvOptions/atmPlantCanopyTSource/atmPlantCanopyTSource.C index ae907dc9bd93fada68810c74d794fe0e7e5085cc..5faebf5973d4a12846a8793fdf22dbeff206a828 100644 --- a/src/atmosphericModels/fvOptions/atmPlantCanopyTSource/atmPlantCanopyTSource.C +++ b/src/atmosphericModels/fvOptions/atmPlantCanopyTSource/atmPlantCanopyTSource.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2020 ENERCON GmbH - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -79,9 +79,9 @@ Foam::fv::atmPlantCanopyTSource::atmPlantCanopyTSource mesh ) { - fieldNames_.setSize(1, "T"); + fieldNames_.resize(1, "T"); - applied_.setSize(fieldNames_.size(), false); + fv::option::resetApplied(); Log << " Applying atmPlantCanopyTSource to: " << fieldNames_[0] << endl; } diff --git a/src/atmosphericModels/fvOptions/atmPlantCanopyTurbSource/atmPlantCanopyTurbSource.C b/src/atmosphericModels/fvOptions/atmPlantCanopyTurbSource/atmPlantCanopyTurbSource.C index 548b4dff83c05920ef36d7f6c5d1768b642a9fa2..b137b8ae947b089457f6eaca9cde78c8f787c5b9 100644 --- a/src/atmosphericModels/fvOptions/atmPlantCanopyTurbSource/atmPlantCanopyTurbSource.C +++ b/src/atmosphericModels/fvOptions/atmPlantCanopyTurbSource/atmPlantCanopyTurbSource.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2020 ENERCON GmbH - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -108,7 +108,7 @@ Foam::fv::atmPlantCanopyTurbSource::atmPlantCanopyTurbSource << abort(FatalError); } - fieldNames_.setSize(1, "undefined"); + fieldNames_.resize(1); tmp<volScalarField> tepsilon = turbPtr->epsilon(); tmp<volScalarField> tomega = turbPtr->omega(); @@ -138,7 +138,7 @@ Foam::fv::atmPlantCanopyTurbSource::atmPlantCanopyTurbSource << abort(FatalError); } - applied_.setSize(fieldNames_.size(), false); + fv::option::resetApplied(); Log << " Applying atmPlantCanopyTurbSource to: " << fieldNames_[0] << endl; diff --git a/src/atmosphericModels/fvOptions/atmPlantCanopyUSource/atmPlantCanopyUSource.C b/src/atmosphericModels/fvOptions/atmPlantCanopyUSource/atmPlantCanopyUSource.C index 4ad1fdc3c610a51fb7983565183121a05451ad58..cefd8f877651b0e9d5c0037b10cce70ecee320ed 100644 --- a/src/atmosphericModels/fvOptions/atmPlantCanopyUSource/atmPlantCanopyUSource.C +++ b/src/atmosphericModels/fvOptions/atmPlantCanopyUSource/atmPlantCanopyUSource.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2020 ENERCON GmbH - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -78,9 +78,9 @@ Foam::fv::atmPlantCanopyUSource::atmPlantCanopyUSource mesh ) { - fieldNames_.setSize(1, "U"); + fieldNames_.resize(1, "U"); - applied_.setSize(fieldNames_.size(), false); + fv::option::resetApplied(); Log << " Applying atmPlantCanopyUSource to: " << fieldNames_[0] << endl; } diff --git a/src/faOptions/faOption/faOption.C b/src/faOptions/faOption/faOption.C index 9f98da33fe5691a5e9ae556d20a2024ed863d34b..b043867f818328483bc3bf3367d40af4cffc2da2 100644 --- a/src/faOptions/faOption/faOption.C +++ b/src/faOptions/faOption/faOption.C @@ -40,6 +40,15 @@ namespace Foam } +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +void Foam::fa::option::resetApplied() +{ + applied_.resize(fieldNames_.size()); + applied_ = false; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::fa::option::option diff --git a/src/faOptions/faOption/faOption.H b/src/faOptions/faOption/faOption.H index c8d69e473f999b9de9a202f7fbda15599033aee5..e7bddf348fb4d9b0947a5e38ac1b1e801ae056d1 100644 --- a/src/faOptions/faOption/faOption.H +++ b/src/faOptions/faOption/faOption.H @@ -132,6 +132,13 @@ protected: //- Region name (finite-area) word regionName_; + + // Protected Member Functions + + //- Resize/reset applied flag list for all fieldNames_ entries + void resetApplied(); + + private: // Private Data diff --git a/src/faOptions/faOption/faOptionList.C b/src/faOptions/faOption/faOptionList.C index b722e457a6f91031ec4e6ca79f3b3fcd5b4ee342..2c312807e7e73706412c2b1c097d000bd831e0f6 100644 --- a/src/faOptions/faOption/faOptionList.C +++ b/src/faOptions/faOption/faOptionList.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------ License This file is part of OpenFOAM. @@ -38,33 +38,27 @@ namespace fa } -// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // const Foam::dictionary& Foam::fa::optionList::optionsDict ( const dictionary& dict -) const +) { - if (dict.found("options")) - { - return dict.subDict("options"); - } - else - { - return dict; - } + return dict.optionalSubDict("options", keyType::LITERAL); } +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + bool Foam::fa::optionList::readOptions(const dictionary& dict) { checkTimeIndex_ = mesh_.time().timeIndex() + 2; bool allOk = true; - forAll(*this, i) + for (fa::option& opt : *this) { - option& bs = this->operator[](i); - bool ok = bs.read(dict.subDict(bs.name())); + bool ok = opt.read(dict.subDict(opt.name())); allOk = (allOk && ok); } return allOk; @@ -75,10 +69,9 @@ void Foam::fa::optionList::checkApplied() const { if (mesh_.time().timeIndex() == checkTimeIndex_) { - forAll(*this, i) + for (const fa::option& opt : *this) { - const option& bs = this->operator[](i); - bs.checkApplied(); + opt.checkApplied(); } } } @@ -144,6 +137,22 @@ void Foam::fa::optionList::reset(const dictionary& dict) } +bool Foam::fa::optionList::appliesToField(const word& fieldName) const +{ + for (const fa::option& source : *this) + { + const label fieldi = source.applyToField(fieldName); + + if (fieldi != -1) + { + return true; + } + } + + return false; +} + + bool Foam::fa::optionList::read(const dictionary& dict) { return readOptions(optionsDict(dict)); @@ -153,12 +162,12 @@ bool Foam::fa::optionList::read(const dictionary& dict) bool Foam::fa::optionList::writeData(Ostream& os) const { // Write list contents - forAll(*this, i) + for (const fa::option& opt : *this) { os << nl; - this->operator[](i).writeHeader(os); - this->operator[](i).writeData(os); - this->operator[](i).writeFooter(os); + opt.writeHeader(os); + opt.writeData(os); + opt.writeFooter(os); } // Check state of IOstream diff --git a/src/faOptions/faOption/faOptionList.H b/src/faOptions/faOption/faOptionList.H index a479c9719667fea3bebc34f301462b6db50bfd72..18b3b535ab4344833855f25e5d0654ca59f9a295 100644 --- a/src/faOptions/faOption/faOptionList.H +++ b/src/faOptions/faOption/faOptionList.H @@ -83,8 +83,8 @@ protected: // Protected Member Functions - //- Return the "options" sub-dictionary if present otherwise return dict - const dictionary& optionsDict(const dictionary& dict) const; + //- Return "options" sub-dictionary (if present) or return dict + static const dictionary& optionsDict(const dictionary& dict); //- Read options dictionary bool readOptions(const dictionary& dict); @@ -117,11 +117,11 @@ public: // Constructors - //- Construct from patch - optionList(const fvPatch& p); + //- Default construct from patch + explicit optionList(const fvPatch& p); - //- Construct from mesh and dictionary - optionList(const fvPatch&, const dictionary& ); + //- Construct from patch and dictionary + optionList(const fvPatch& p, const dictionary&); //- Destructor @@ -133,6 +133,9 @@ public: //- Reset the source list void reset(const dictionary& dict); + //- Return whether there is something to apply to the field + bool appliesToField(const word& fieldName) const; + // Sources diff --git a/src/faOptions/faOption/faOptionListTemplates.C b/src/faOptions/faOption/faOptionListTemplates.C index 96a266e5a38105d20979dbfbf8f88d55b4e5c5ac..b71f49588007f30fb80ab31f06db1faafeffb6d6 100644 --- a/src/faOptions/faOption/faOptionListTemplates.C +++ b/src/faOptions/faOption/faOptionListTemplates.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------ License This file is part of OpenFOAM. @@ -44,11 +44,9 @@ Foam::tmp<Foam::faMatrix<Type>> Foam::fa::optionList::source tmp<faMatrix<Type>> tmtx(new faMatrix<Type>(field, ds)); faMatrix<Type>& mtx = tmtx.ref(); - forAll(*this, i) + for (fa::option& source : *this) { - option& source = this->operator[](i); - - label fieldi = source.applyToField(fieldName); + const label fieldi = source.applyToField(fieldName); if (fieldi != -1) { @@ -56,14 +54,24 @@ Foam::tmp<Foam::faMatrix<Type>> Foam::fa::optionList::source source.setApplied(fieldi); - if (source.isActive()) + const bool ok = source.isActive(); + + if (debug) { - if (debug) + if (ok) + { + Info<< "Apply"; + } + else { - Info<< "Applying source " << source.name() << " to field " - << fieldName << endl; + Info<< "(Inactive)"; } + Info<< " source " << source.name() + << " for field " << fieldName << endl; + } + if (ok) + { source.addSup(h, mtx, fieldi); } } @@ -127,11 +135,9 @@ Foam::tmp<Foam::faMatrix<Type>> Foam::fa::optionList::operator() tmp<faMatrix<Type>> tmtx(new faMatrix<Type>(field, ds)); faMatrix<Type>& mtx = tmtx.ref(); - forAll(*this, i) + for (fa::option& source : *this) { - option& source = this->operator[](i); - - label fieldi = source.applyToField(fieldName); + const label fieldi = source.applyToField(fieldName); if (fieldi != -1) { @@ -139,14 +145,24 @@ Foam::tmp<Foam::faMatrix<Type>> Foam::fa::optionList::operator() source.setApplied(fieldi); - if (source.isActive()) + const bool ok = source.isActive(); + + if (debug) { - if (debug) + if (ok) { - Info<< "Applying source " << source.name() << " to field " - << fieldName << endl; + Info<< "Apply"; } + else + { + Info<< "(Inactive)"; + } + Info<< " source " << source.name() + << " for field " << fieldName << endl; + } + if (ok) + { source.addSup(h, rho, mtx, fieldi); } } @@ -171,11 +187,9 @@ Foam::tmp<Foam::faMatrix<Type>> Foam::fa::optionList::operator() tmp<faMatrix<Type>> tmtx(new faMatrix<Type>(field, dsMat)); faMatrix<Type>& mtx = tmtx.ref(); - forAll(*this, i) + for (fa::option& source : *this) { - option& source = this->operator[](i); - - label fieldi = source.applyToField(field.name()); + const label fieldi = source.applyToField(field.name()); if (fieldi != -1) { @@ -183,14 +197,24 @@ Foam::tmp<Foam::faMatrix<Type>> Foam::fa::optionList::operator() source.setApplied(fieldi); - if (source.isActive()) + const bool ok = source.isActive(); + + if (debug) { - if (debug) + if (ok) + { + Info<< "Apply"; + } + else { - Info<< "Applying source " << source.name() << " to field " - << field.name() << endl; + Info<< "(Inactive)"; } + Info<< " source " << source.name() + << " for field " << field.name() << endl; + } + if (ok) + { source.addSup(rho, mtx, fieldi); } } @@ -226,11 +250,9 @@ void Foam::fa::optionList::constrain(faMatrix<Type>& eqn) { checkApplied(); - forAll(*this, i) + for (fa::option& source : *this) { - option& source = this->operator[](i); - - label fieldi = source.applyToField(eqn.psi().name()); + const label fieldi = source.applyToField(eqn.psi().name()); if (fieldi != -1) { @@ -238,14 +260,24 @@ void Foam::fa::optionList::constrain(faMatrix<Type>& eqn) source.setApplied(fieldi); - if (source.isActive()) + const bool ok = source.isActive(); + + if (debug) { - if (debug) + if (ok) + { + Info<< "Constrain"; + } + else { - Info<< "Applying constraint " << source.name() - << " to field " << eqn.psi().name() << endl; + Info<< "(Inactive constrain)"; } + Info<< " source " << source.name() + << " for field " << eqn.psi().name() << endl; + } + if (ok) + { source.constrain(eqn, fieldi); } } @@ -261,11 +293,9 @@ void Foam::fa::optionList::correct { const word& fieldName = field.name(); - forAll(*this, i) + for (fa::option& source : *this) { - option& source = this->operator[](i); - - label fieldi = source.applyToField(fieldName); + const label fieldi = source.applyToField(fieldName); if (fieldi != -1) { @@ -273,14 +303,24 @@ void Foam::fa::optionList::correct source.setApplied(fieldi); - if (source.isActive()) + const bool ok = source.isActive(); + + if (debug) { - if (debug) + if (ok) { - Info<< "Correcting source " << source.name() - << " for field " << fieldName << endl; + Info<< "Correct"; } + else + { + Info<< "(Inactive correct)"; + } + Info<< " source " << source.name() + << " for field " << fieldName << endl; + } + if (ok) + { source.correct(field); } } diff --git a/src/faOptions/faceSetOption/faceSetOption.C b/src/faOptions/faceSetOption/faceSetOption.C index 24e176e56da0fc8c7bc15396e46137342d9a7b28..04eefeb2ff3a704c91db4a78dbdb74c0346cbbe5 100644 --- a/src/faOptions/faceSetOption/faceSetOption.C +++ b/src/faOptions/faceSetOption/faceSetOption.C @@ -204,7 +204,7 @@ Foam::fa::faceSetOption::faceSetOption bool Foam::fa::faceSetOption::isActive() { - if (option::isActive() && inTimeLimits(mesh_.time().value())) + if (fa::option::isActive() && inTimeLimits(mesh_.time().value())) { // Update the face set if the mesh is changing if (mesh_.changing()) @@ -229,7 +229,7 @@ bool Foam::fa::faceSetOption::isActive() bool Foam::fa::faceSetOption::read(const dictionary& dict) { - if (option::read(dict)) + if (fa::option::read(dict)) { if (coeffs_.readIfPresent("timeStart", timeStart_)) { diff --git a/src/faOptions/sources/derived/contactHeatFluxSource/contactHeatFluxSource.C b/src/faOptions/sources/derived/contactHeatFluxSource/contactHeatFluxSource.C index e9a4133d7a9f1b67f40f3742e1880e14e474b5e9..883027340772dc66ddf7a1fd919566ad03b425d0 100644 --- a/src/faOptions/sources/derived/contactHeatFluxSource/contactHeatFluxSource.C +++ b/src/faOptions/sources/derived/contactHeatFluxSource/contactHeatFluxSource.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -78,9 +78,9 @@ Foam::fa::contactHeatFluxSource::contactHeatFluxSource contactRes_(0), curTimeIndex_(-1) { - fieldNames_.setSize(1, TName_); + fieldNames_.resize(1, TName_); - applied_.setSize(fieldNames_.size(), false); + fa::option::resetApplied(); read(dict); } diff --git a/src/faOptions/sources/derived/externalFileSource/externalFileSource.C b/src/faOptions/sources/derived/externalFileSource/externalFileSource.C index 81e93caa40eae7e80f831d807f34bacf220e1c1b..cc6da002216da1d629b42e00f4a2afb80a0463f3 100644 --- a/src/faOptions/sources/derived/externalFileSource/externalFileSource.C +++ b/src/faOptions/sources/derived/externalFileSource/externalFileSource.C @@ -83,9 +83,9 @@ Foam::fa::externalFileSource::externalFileSource ), curTimeIndex_(-1) { - fieldNames_.setSize(1, fieldName_); + fieldNames_.resize(1, fieldName_); - applied_.setSize(fieldNames_.size(), false); + fa::option::resetApplied(); read(dict); } diff --git a/src/faOptions/sources/derived/externalHeatFluxSource/externalHeatFluxSource.C b/src/faOptions/sources/derived/externalHeatFluxSource/externalHeatFluxSource.C index 22c8404e198428af53acfc82d9ebccfb070b372a..2a559f0fe70a835ee5f062cf6662f5e5aed563e0 100644 --- a/src/faOptions/sources/derived/externalHeatFluxSource/externalHeatFluxSource.C +++ b/src/faOptions/sources/derived/externalHeatFluxSource/externalHeatFluxSource.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -77,9 +77,9 @@ Foam::fa::externalHeatFluxSource::externalHeatFluxSource Ta_(), emissivity_(dict.getOrDefault<scalar>("emissivity", 0)) { - fieldNames_.setSize(1, TName_); + fieldNames_.resize(1, TName_); - applied_.setSize(fieldNames_.size(), false); + fa::option::resetApplied(); read(dict); } diff --git a/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C b/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C index a752b74eff6e023ebf017e61a149c28a141ba05b..583fd34ecd97fecb226a5c36878ed2d019c1917e 100644 --- a/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C +++ b/src/faOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -72,9 +72,9 @@ Foam::fa::jouleHeatingSource::jouleHeatingSource nIter_(1), anisotropicElectricalConductivity_(false) { - fieldNames_.setSize(1, TName_); + fieldNames_.resize(1, TName_); - applied_.setSize(fieldNames_.size(), false); + fa::option::resetApplied(); if (anisotropicElectricalConductivity_) { diff --git a/src/finiteVolume/cfdTools/general/fvOptions/fvOption.C b/src/finiteVolume/cfdTools/general/fvOptions/fvOption.C index 4614b1b8acc5e09e524e107598b20f406648883e..a3aa2f6dadd5d835bcd54b57d9804a13da56a9fd 100644 --- a/src/finiteVolume/cfdTools/general/fvOptions/fvOption.C +++ b/src/finiteVolume/cfdTools/general/fvOptions/fvOption.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. Copyright (C) 2020 PCOpt/NTUA Copyright (C) 2020 FOSS GP ------------------------------------------------------------------------------- @@ -43,6 +43,15 @@ namespace Foam } +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +void Foam::fv::option::resetApplied() +{ + applied_.resize(fieldNames_.size()); + applied_ = false; +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::fv::option::option diff --git a/src/finiteVolume/cfdTools/general/fvOptions/fvOption.H b/src/finiteVolume/cfdTools/general/fvOptions/fvOption.H index 84539964ac498733f4724d67f547b3546ecc9aef..f7a7408b84c1198010e7ef55a33d4ab073c76ee7 100644 --- a/src/finiteVolume/cfdTools/general/fvOptions/fvOption.H +++ b/src/finiteVolume/cfdTools/general/fvOptions/fvOption.H @@ -123,6 +123,12 @@ protected: bool active_; + // Protected Member Functions + + //- Resize/reset applied flag list for all fieldNames_ entries + void resetApplied(); + + public: //- Switch write log to Info diff --git a/src/finiteVolume/cfdTools/general/fvOptions/fvOptionList.C b/src/finiteVolume/cfdTools/general/fvOptions/fvOptionList.C index 2fe08194b560182ac3ab1f444adb89351243fba1..45d114ca11ea8c23a7d891fc4daa2e6f8041db3c 100644 --- a/src/finiteVolume/cfdTools/general/fvOptions/fvOptionList.C +++ b/src/finiteVolume/cfdTools/general/fvOptions/fvOptionList.C @@ -6,6 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2015 OpenFOAM Foundation + Copyright (C) 2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -39,33 +40,27 @@ namespace fv } -// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // const Foam::dictionary& Foam::fv::optionList::optionsDict ( const dictionary& dict -) const +) { - if (dict.found("options")) - { - return dict.subDict("options"); - } - else - { - return dict; - } + return dict.optionalSubDict("options", keyType::LITERAL); } +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + bool Foam::fv::optionList::readOptions(const dictionary& dict) { checkTimeIndex_ = mesh_.time().timeIndex() + 2; bool allOk = true; - forAll(*this, i) + for (fv::option& opt : *this) { - option& bs = this->operator[](i); - bool ok = bs.read(dict.subDict(bs.name())); + bool ok = opt.read(dict.subDict(opt.name())); allOk = (allOk && ok); } return allOk; @@ -76,10 +71,9 @@ void Foam::fv::optionList::checkApplied() const { if (mesh_.time().timeIndex() == checkTimeIndex_) { - forAll(*this, i) + for (const fv::option& opt : *this) { - const option& bs = this->operator[](i); - bs.checkApplied(); + opt.checkApplied(); } } } @@ -141,11 +135,9 @@ void Foam::fv::optionList::reset(const dictionary& dict) bool Foam::fv::optionList::appliesToField(const word& fieldName) const { - forAll(*this, i) + for (const fv::option& source : *this) { - const option& source = this->operator[](i); - - label fieldi = source.applyToField(fieldName); + const label fieldi = source.applyToField(fieldName); if (fieldi != -1) { @@ -166,12 +158,12 @@ bool Foam::fv::optionList::read(const dictionary& dict) bool Foam::fv::optionList::writeData(Ostream& os) const { // Write list contents - forAll(*this, i) + for (const fv::option& opt : *this) { os << nl; - this->operator[](i).writeHeader(os); - this->operator[](i).writeData(os); - this->operator[](i).writeFooter(os); + opt.writeHeader(os); + opt.writeData(os); + opt.writeFooter(os); } // Check state of IOstream diff --git a/src/finiteVolume/cfdTools/general/fvOptions/fvOptionList.H b/src/finiteVolume/cfdTools/general/fvOptions/fvOptionList.H index 1cbca46098bc8e6a50a2f3a905e3197bb4e39f26..14b8ea08c92c8c8455221093b6615882498eedd1 100644 --- a/src/finiteVolume/cfdTools/general/fvOptions/fvOptionList.H +++ b/src/finiteVolume/cfdTools/general/fvOptions/fvOptionList.H @@ -84,8 +84,8 @@ protected: // Protected Member Functions - //- Return the "options" sub-dictionary if present otherwise return dict - const dictionary& optionsDict(const dictionary& dict) const; + //- Return "options" sub-dictionary (if present) or return dict + static const dictionary& optionsDict(const dictionary& dict); //- Read options dictionary bool readOptions(const dictionary& dict); @@ -117,8 +117,8 @@ public: // Constructors - //- Construct null - optionList(const fvMesh& mesh); + //- Default construct from mesh + explicit optionList(const fvMesh& mesh); //- Construct from mesh and dictionary optionList(const fvMesh& mesh, const dictionary& dict); diff --git a/src/finiteVolume/cfdTools/general/fvOptions/fvOptionListTemplates.C b/src/finiteVolume/cfdTools/general/fvOptions/fvOptionListTemplates.C index 8e76688319ca378d1f35866d1dcff2a7d73e3367..374cc5ab25744927549534c2af6cd278de147c7e 100644 --- a/src/finiteVolume/cfdTools/general/fvOptions/fvOptionListTemplates.C +++ b/src/finiteVolume/cfdTools/general/fvOptions/fvOptionListTemplates.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2016 OpenCFD Ltd. + Copyright (C) 2016-2021 OpenCFD Ltd. Copyright (C) 2020 PCOpt/NTUA Copyright (C) 2020 FOSS GP ------------------------------------------------------------------------------- @@ -45,11 +45,9 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fv::optionList::source tmp<fvMatrix<Type>> tmtx(new fvMatrix<Type>(field, ds)); fvMatrix<Type>& mtx = tmtx.ref(); - forAll(*this, i) + for (fv::option& source : *this) { - option& source = this->operator[](i); - - label fieldi = source.applyToField(fieldName); + const label fieldi = source.applyToField(fieldName); if (fieldi != -1) { @@ -57,14 +55,24 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fv::optionList::source source.setApplied(fieldi); - if (source.isActive()) + const bool ok = source.isActive(); + + if (debug) { - if (debug) + if (ok) { - Info<< "Applying source " << source.name() << " to field " - << fieldName << endl; + Info<< "Apply"; } + else + { + Info<< "(Inactive)"; + } + Info<< " source " << source.name() + << " for field " << fieldName << endl; + } + if (ok) + { source.addSup(mtx, fieldi); } } @@ -124,11 +132,9 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fv::optionList::operator() tmp<fvMatrix<Type>> tmtx(new fvMatrix<Type>(field, ds)); fvMatrix<Type>& mtx = tmtx.ref(); - forAll(*this, i) + for (fv::option& source : *this) { - option& source = this->operator[](i); - - label fieldi = source.applyToField(fieldName); + const label fieldi = source.applyToField(fieldName); if (fieldi != -1) { @@ -136,14 +142,24 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fv::optionList::operator() source.setApplied(fieldi); - if (source.isActive()) + const bool ok = source.isActive(); + + if (debug) { - if (debug) + if (ok) + { + Info<< "Apply"; + } + else { - Info<< "Applying source " << source.name() << " to field " - << fieldName << endl; + Info<< "(Inactive)"; } + Info<< " source " << source.name() + << " for field " << fieldName << endl; + } + if (ok) + { source.addSup(rho, mtx, fieldi); } } @@ -185,11 +201,9 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fv::optionList::operator() tmp<fvMatrix<Type>> tmtx(new fvMatrix<Type>(field, ds)); fvMatrix<Type>& mtx = tmtx.ref(); - forAll(*this, i) + for (fv::option& source : *this) { - option& source = this->operator[](i); - - label fieldi = source.applyToField(fieldName); + const label fieldi = source.applyToField(fieldName); if (fieldi != -1) { @@ -197,14 +211,24 @@ Foam::tmp<Foam::fvMatrix<Type>> Foam::fv::optionList::operator() source.setApplied(fieldi); - if (source.isActive()) + const bool ok = source.isActive(); + + if (debug) { - if (debug) + if (ok) { - Info<< "Applying source " << source.name() << " to field " - << fieldName << endl; + Info<< "Apply"; } + else + { + Info<< "(Inactive)"; + } + Info<< " source " << source.name() + << " for field " << fieldName << endl; + } + if (ok) + { source.addSup(alpha, rho, mtx, fieldi); } } @@ -291,11 +315,9 @@ void Foam::fv::optionList::constrain(fvMatrix<Type>& eqn) { checkApplied(); - forAll(*this, i) + for (fv::option& source : *this) { - option& source = this->operator[](i); - - label fieldi = source.applyToField(eqn.psi().name()); + const label fieldi = source.applyToField(eqn.psi().name()); if (fieldi != -1) { @@ -303,14 +325,24 @@ void Foam::fv::optionList::constrain(fvMatrix<Type>& eqn) source.setApplied(fieldi); - if (source.isActive()) + const bool ok = source.isActive(); + + if (debug) { - if (debug) + if (ok) { - Info<< "Applying constraint " << source.name() - << " to field " << eqn.psi().name() << endl; + Info<< "Constrain"; } + else + { + Info<< "(Inactive constrain)"; + } + Info<< " source " << source.name() + << " for field " << eqn.psi().name() << endl; + } + if (ok) + { source.constrain(eqn, fieldi); } } @@ -326,11 +358,9 @@ void Foam::fv::optionList::correct { const word& fieldName = field.name(); - forAll(*this, i) + for (fv::option& source : *this) { - option& source = this->operator[](i); - - label fieldi = source.applyToField(fieldName); + const label fieldi = source.applyToField(fieldName); if (fieldi != -1) { @@ -338,14 +368,24 @@ void Foam::fv::optionList::correct source.setApplied(fieldi); - if (source.isActive()) + const bool ok = source.isActive(); + + if (debug) { - if (debug) + if (ok) + { + Info<< "Correct"; + } + else { - Info<< "Correcting source " << source.name() - << " for field " << fieldName << endl; + Info<< "(Inactive correct)"; } + Info<< " source " << source.name() + << " for field " << fieldName << endl; + } + if (ok) + { source.correct(field); } } @@ -361,25 +401,24 @@ void Foam::fv::optionList::postProcessSens const word& designVariablesName ) { - forAll(*this, i) + for (fv::option& source : *this) { - option& source = this->operator[](i); - - label fieldi = source.applyToField(fieldName); + const label fieldi = source.applyToField(fieldName); if (fieldi != -1) { addProfiling(fvopt, "fvOption::postProcessSens." + source.name()); - if (source.isActive()) + const bool ok = source.isActive(); + + if (debug && ok) { - if (debug) - { - Info<< "Post processing sensitivity from source " - << source.name() - << " for field " << fieldName << endl; - } + Info<< "Post processing sensitivity source " + << source.name() << " for field " << fieldName << endl; + } + if (ok) + { source.postProcessSens ( sensField, diff --git a/src/fvOptions/Make/files b/src/fvOptions/Make/files index da81bfc3068c131b16900180a057e5fc6e0739f9..01e2288baa989398506b1631562248105872dca3 100644 --- a/src/fvOptions/Make/files +++ b/src/fvOptions/Make/files @@ -4,7 +4,7 @@ interRegionOption/interRegionOption.C /* Sources */ generalSources=sources/general -$(generalSources)/codedSource/codedSource.C +$(generalSources)/codedSource/codedFvSources.C $(generalSources)/semiImplicitSource/semiImplicitSource.C derivedSources=sources/derived diff --git a/src/fvOptions/constraints/derived/fixedTemperatureConstraint/fixedTemperatureConstraint.C b/src/fvOptions/constraints/derived/fixedTemperatureConstraint/fixedTemperatureConstraint.C index 3bfa919f9ed68681191a3c628fccdf5d17853d08..1142b18bba3a8eb09389031deb4433be677ee323 100644 --- a/src/fvOptions/constraints/derived/fixedTemperatureConstraint/fixedTemperatureConstraint.C +++ b/src/fvOptions/constraints/derived/fixedTemperatureConstraint/fixedTemperatureConstraint.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2016 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -101,9 +101,9 @@ Foam::fv::fixedTemperatureConstraint::fixedTemperatureConstraint const auto& thermo = mesh_.lookupObject<basicThermo>(basicThermo::dictName); - fieldNames_.setSize(1, thermo.he().name()); + fieldNames_.resize(1, thermo.he().name()); - applied_.setSize(1, false); + fv::option::resetApplied(); } diff --git a/src/fvOptions/constraints/derived/velocityDampingConstraint/velocityDampingConstraint.C b/src/fvOptions/constraints/derived/velocityDampingConstraint/velocityDampingConstraint.C index a9eeea31b3592f78a7dbd9508958534d7ce56ed7..9e96727a5280c4a4714ecc292e3eca1f303af086 100644 --- a/src/fvOptions/constraints/derived/velocityDampingConstraint/velocityDampingConstraint.C +++ b/src/fvOptions/constraints/derived/velocityDampingConstraint/velocityDampingConstraint.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015 OpenFOAM Foundation - Copyright (C) 2015 OpenCFD Ltd. + Copyright (C) 2015-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -132,7 +132,7 @@ bool Foam::fv::velocityDampingConstraint::read(const dictionary& dict) fieldNames_.first() = coeffs_.getOrDefault<word>("U", "U"); } - applied_.setSize(fieldNames_.size(), false); + fv::option::resetApplied(); return true; } diff --git a/src/fvOptions/constraints/general/fixedValueConstraint/FixedValueConstraint.C b/src/fvOptions/constraints/general/fixedValueConstraint/FixedValueConstraint.C index 34ac46c490f8edf07580d9712fdcd00c560e879a..30681d5891d976afcffc2382e0c03d82f2ea50e7 100644 --- a/src/fvOptions/constraints/general/fixedValueConstraint/FixedValueConstraint.C +++ b/src/fvOptions/constraints/general/fixedValueConstraint/FixedValueConstraint.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -59,9 +59,10 @@ bool Foam::fv::FixedValueConstraint<Type>::read(const dictionary& dict) label count = fieldValuesDict.size(); - fieldNames_.setSize(count); - fieldValues_.setSize(count); - applied_.setSize(count, false); + fieldNames_.resize(count); + fieldValues_.resize(count); + + fv::option::resetApplied(); count = 0; for (const entry& dEntry : fieldValuesDict) diff --git a/src/fvOptions/corrections/limitTemperature/limitTemperature.C b/src/fvOptions/corrections/limitTemperature/limitTemperature.C index 7d07a3218871fd09714d92c2d88f02113434428c..627e69cdeb0024367f1e42a06debac67a22f682e 100644 --- a/src/fvOptions/corrections/limitTemperature/limitTemperature.C +++ b/src/fvOptions/corrections/limitTemperature/limitTemperature.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2017 OpenFOAM Foundation - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -66,9 +66,9 @@ Foam::fv::limitTemperature::limitTemperature IOobject::groupName(basicThermo::dictName, phase_) ); - fieldNames_.setSize(1, thermo.he().name()); + fieldNames_.resize(1, thermo.he().name()); - applied_.setSize(1, false); + fv::option::resetApplied(); } diff --git a/src/fvOptions/corrections/limitVelocity/limitVelocity.C b/src/fvOptions/corrections/limitVelocity/limitVelocity.C index 9ac693e5ed4a0ba4e7f9de20a9e6b50d7ffda5bc..445869598432c32096063c18290a7e9687ae91af 100644 --- a/src/fvOptions/corrections/limitVelocity/limitVelocity.C +++ b/src/fvOptions/corrections/limitVelocity/limitVelocity.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2016-2017 OpenFOAM Foundation - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -56,8 +56,8 @@ Foam::fv::limitVelocity::limitVelocity UName_(coeffs_.getOrDefault<word>("U", "U")), max_(coeffs_.get<scalar>("max")) { - fieldNames_.setSize(1, UName_); - applied_.setSize(1, false); + fieldNames_.resize(1, UName_); + fv::option::resetApplied(); } diff --git a/src/fvOptions/sources/derived/acousticDampingSource/acousticDampingSource.C b/src/fvOptions/sources/derived/acousticDampingSource/acousticDampingSource.C index 428e6026940c9ab6afef638dbbe8f76ce60be069..d9bfb7e95df697c3ff758e39c969aba1263953fc 100644 --- a/src/fvOptions/sources/derived/acousticDampingSource/acousticDampingSource.C +++ b/src/fvOptions/sources/derived/acousticDampingSource/acousticDampingSource.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2020 OpenCFD Ltd. + Copyright (C) 2016-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -182,7 +182,7 @@ bool Foam::fv::acousticDampingSource::read(const dictionary& dict) fieldNames_.first() = coeffs_.getOrDefault<word>("U", "U"); } - applied_.setSize(fieldNames_.size(), false); + fv::option::resetApplied(); coeffs_.readEntry("frequency", frequency_.value()); coeffs_.readEntry("URef", URefName_); diff --git a/src/fvOptions/sources/derived/actuationDiskSource/actuationDiskSource.C b/src/fvOptions/sources/derived/actuationDiskSource/actuationDiskSource.C index aee210098fd412e28a64e4cfee421651199cad39..4c4995e801f43e42623fcaa8127e2d0e7aab6a93 100644 --- a/src/fvOptions/sources/derived/actuationDiskSource/actuationDiskSource.C +++ b/src/fvOptions/sources/derived/actuationDiskSource/actuationDiskSource.C @@ -7,7 +7,7 @@ ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2020 ENERCON GmbH - Copyright (C) 2018-2020 OpenCFD Ltd + Copyright (C) 2018-2021 OpenCFD Ltd ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -219,9 +219,9 @@ Foam::fv::actuationDiskSource::actuationDiskSource { setMonitorCells(coeffs_); - fieldNames_.setSize(1, "U"); + fieldNames_.resize(1, "U"); - applied_.setSize(fieldNames_.size(), false); + fv::option::resetApplied(); Info<< " - creating actuation disk zone: " << this->name() << endl; diff --git a/src/fvOptions/sources/derived/buoyancyEnergy/buoyancyEnergy.C b/src/fvOptions/sources/derived/buoyancyEnergy/buoyancyEnergy.C index ee3e5d13128cd581f411c710ec085dc6aebfb0d0..92d0cb41d51d3e5ef0b403a2650d661a553d6c68 100644 --- a/src/fvOptions/sources/derived/buoyancyEnergy/buoyancyEnergy.C +++ b/src/fvOptions/sources/derived/buoyancyEnergy/buoyancyEnergy.C @@ -64,7 +64,7 @@ Foam::fv::buoyancyEnergy::buoyancyEnergy << "settings are:" << fieldNames_ << exit(FatalError); } - applied_.setSize(fieldNames_.size(), false); + fv::option::resetApplied(); } diff --git a/src/fvOptions/sources/derived/buoyancyForce/buoyancyForce.C b/src/fvOptions/sources/derived/buoyancyForce/buoyancyForce.C index 72fa97cfd4da1db22554962bd42468b0994836aa..1debb34aaed92ef073d9c14fead388b6d916ca3f 100644 --- a/src/fvOptions/sources/derived/buoyancyForce/buoyancyForce.C +++ b/src/fvOptions/sources/derived/buoyancyForce/buoyancyForce.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015-2017 OpenFOAM Foundation - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -64,7 +64,7 @@ Foam::fv::buoyancyForce::buoyancyForce << "settings are:" << fieldNames_ << exit(FatalError); } - applied_.setSize(fieldNames_.size(), false); + fv::option::resetApplied(); } diff --git a/src/fvOptions/sources/derived/buoyancyTurbSource/buoyancyTurbSource.C b/src/fvOptions/sources/derived/buoyancyTurbSource/buoyancyTurbSource.C index a262664637040c7a298be31480eee0eb8ec3858b..b2b8be4bab405b0f21332159e14193430fb95fb3 100644 --- a/src/fvOptions/sources/derived/buoyancyTurbSource/buoyancyTurbSource.C +++ b/src/fvOptions/sources/derived/buoyancyTurbSource/buoyancyTurbSource.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -178,7 +178,7 @@ Foam::fv::buoyancyTurbSource::buoyancyTurbSource << exit(FatalError); } - fieldNames_.setSize(2, "undefined"); + fieldNames_.resize(2); tmp<volScalarField> tepsilon = turbPtr->epsilon(); tmp<volScalarField> tomega = turbPtr->omega(); @@ -202,7 +202,8 @@ Foam::fv::buoyancyTurbSource::buoyancyTurbSource } fieldNames_[1] = turbPtr->k()().name(); - applied_.setSize(fieldNames_.size(), false); + + fv::option::resetApplied(); Log << " Applying buoyancyTurbSource to: " << fieldNames_[0] << " and " << fieldNames_[1] diff --git a/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C b/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C index ef9866c4340ccec5dc0244ddb8e03068ef18cb50..6f1d97e559e8089e83dfcfbceb6c1e0d39032a28 100644 --- a/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C +++ b/src/fvOptions/sources/derived/directionalPressureGradientExplicitSource/directionalPressureGradientExplicitSource.C @@ -223,7 +223,7 @@ directionalPressureGradientExplicitSource << exit(FatalError); } - applied_.setSize(fieldNames_.size(), false); + fv::option::resetApplied(); // Read the initial pressure gradient from file if it exists IFstream propsFile diff --git a/src/fvOptions/sources/derived/effectivenessHeatExchangerSource/effectivenessHeatExchangerSource.C b/src/fvOptions/sources/derived/effectivenessHeatExchangerSource/effectivenessHeatExchangerSource.C index 807a3bc67cda6daeb84af616bc263a578c18d0de..e2d9b56fd4dbdb1e2913c0c91cd7df8bf5da2f1c 100644 --- a/src/fvOptions/sources/derived/effectivenessHeatExchangerSource/effectivenessHeatExchangerSource.C +++ b/src/fvOptions/sources/derived/effectivenessHeatExchangerSource/effectivenessHeatExchangerSource.C @@ -160,9 +160,9 @@ Foam::fv::effectivenessHeatExchangerSource::effectivenessHeatExchangerSource const auto& thermo = mesh_.lookupObject<basicThermo>(basicThermo::dictName); - fieldNames_.setSize(1, thermo.he().name()); + fieldNames_.resize(1, thermo.he().name()); - applied_.setSize(1, false); + fv::option::resetApplied(); eTable_.reset(new interpolation2DTable<scalar>(coeffs_)); diff --git a/src/fvOptions/sources/derived/explicitPorositySource/explicitPorositySource.C b/src/fvOptions/sources/derived/explicitPorositySource/explicitPorositySource.C index b5ee9b738abc02f46e0f50cd02e0d972bdc9dd61..d52cd09b5f9335d503ebe044cb63d7717d5455e0 100644 --- a/src/fvOptions/sources/derived/explicitPorositySource/explicitPorositySource.C +++ b/src/fvOptions/sources/derived/explicitPorositySource/explicitPorositySource.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2012-2018 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -123,7 +123,7 @@ bool Foam::fv::explicitPorositySource::read(const dictionary& dict) fieldNames_.first() = coeffs_.getOrDefault<word>("U", "U"); } - applied_.setSize(fieldNames_.size(), false); + fv::option::resetApplied(); return true; } diff --git a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C index ff661db956b9a6e5bab3f392b9c181dffc998067..5b59cfbfc80d648b9ad1c53e01a64332f5054c1a 100644 --- a/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C +++ b/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2016-2020 OpenCFD Ltd. + Copyright (C) 2016-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -134,9 +134,9 @@ Foam::fv::jouleHeatingSource::jouleHeatingSource const auto& thermo = mesh_.lookupObject<basicThermo>(basicThermo::dictName); - fieldNames_.setSize(1, thermo.he().name()); + fieldNames_.resize(1, thermo.he().name()); - applied_.setSize(fieldNames_.size(), false); + fv::option::resetApplied(); read(dict); } diff --git a/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.C b/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.C index 00c9a8f1e12ac45b658edd96057574ba13442526..f10e8d8d9780251e802179e29384f18bf7884e90 100644 --- a/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.C +++ b/src/fvOptions/sources/derived/meanVelocityForce/meanVelocityForce.C @@ -98,7 +98,7 @@ Foam::fv::meanVelocityForce::meanVelocityForce << "settings are:" << fieldNames_ << exit(FatalError); } - applied_.setSize(fieldNames_.size(), false); + fv::option::resetApplied(); // Read the initial pressure gradient from file if it exists IFstream propsFile diff --git a/src/fvOptions/sources/derived/multiphaseStabilizedTurbulence/multiphaseStabilizedTurbulence.C b/src/fvOptions/sources/derived/multiphaseStabilizedTurbulence/multiphaseStabilizedTurbulence.C index 96a399d2be084a7bf96e7b20e185ff55432979f3..b88e7161630a9d3679781fd5c70abb7295087284 100644 --- a/src/fvOptions/sources/derived/multiphaseStabilizedTurbulence/multiphaseStabilizedTurbulence.C +++ b/src/fvOptions/sources/derived/multiphaseStabilizedTurbulence/multiphaseStabilizedTurbulence.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2019-2020 OpenCFD Ltd. + Copyright (C) 2019-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -96,7 +96,7 @@ Foam::fv::multiphaseStabilizedTurbulence::multiphaseStabilizedTurbulence ) ) { - fieldNames_.setSize(2, "undefined"); + fieldNames_.resize(2); // Note: incompressible only const auto* turbPtr = @@ -123,7 +123,7 @@ Foam::fv::multiphaseStabilizedTurbulence::multiphaseStabilizedTurbulence << exit(FatalError); } - applied_.setSize(fieldNames_.size(), false); + fv::option::resetApplied(); } diff --git a/src/fvOptions/sources/derived/phaseLimitStabilization/PhaseLimitStabilization.C b/src/fvOptions/sources/derived/phaseLimitStabilization/PhaseLimitStabilization.C index 69df18ba5ea244fed8f85241a514f207b7afd625..7d90715a32ecab858dd8bc864047818a018795f2 100644 --- a/src/fvOptions/sources/derived/phaseLimitStabilization/PhaseLimitStabilization.C +++ b/src/fvOptions/sources/derived/phaseLimitStabilization/PhaseLimitStabilization.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -47,8 +47,8 @@ Foam::fv::PhaseLimitStabilization<Type>::PhaseLimitStabilization rateName_(coeffs_.get<word>("rate")), residualAlpha_(coeffs_.get<scalar>("residualAlpha")) { - fieldNames_.setSize(1, fieldName_); - applied_.setSize(1, false); + fieldNames_.resize(1, fieldName_); + fv::option::resetApplied(); } diff --git a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C index 509b5e16953abe998e1cc8a7f635a54337161115..2094eb71700581a0436cecdb10eb4a5086a38951 100644 --- a/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C +++ b/src/fvOptions/sources/derived/rotorDiskSource/rotorDiskSource.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -548,7 +548,7 @@ bool Foam::fv::rotorDiskSource::read(const dictionary& dict) if (cellSetOption::read(dict)) { coeffs_.readEntry("fields", fieldNames_); - applied_.setSize(fieldNames_.size(), false); + fv::option::resetApplied(); // Read coordinate system/geometry invariant properties omega_ = rpmToRads(coeffs_.get<scalar>("rpm")); diff --git a/src/fvOptions/sources/derived/solidificationMeltingSource/solidificationMeltingSource.C b/src/fvOptions/sources/derived/solidificationMeltingSource/solidificationMeltingSource.C index e2d464b8c5754b6c22f986debce6f9e9c55051eb..ca9deb582714b12fc9a6a0b6680bbac693977e1f 100644 --- a/src/fvOptions/sources/derived/solidificationMeltingSource/solidificationMeltingSource.C +++ b/src/fvOptions/sources/derived/solidificationMeltingSource/solidificationMeltingSource.C @@ -192,7 +192,7 @@ Foam::fv::solidificationMeltingSource::solidificationMeltingSource curTimeIndex_(-1), deltaT_(cells_.size(), 0) { - fieldNames_.setSize(2); + fieldNames_.resize(2); fieldNames_[0] = UName_; switch (mode_) @@ -218,7 +218,7 @@ Foam::fv::solidificationMeltingSource::solidificationMeltingSource } } - applied_.setSize(fieldNames_.size(), false); + fv::option::resetApplied(); } diff --git a/src/fvOptions/sources/derived/tabulatedAccelerationSource/tabulatedAccelerationSource.C b/src/fvOptions/sources/derived/tabulatedAccelerationSource/tabulatedAccelerationSource.C index 7daf9d27a6164454cc5c7aacf17b49924ada0506..eafb5d8dc7e480fb978d109b8ae6e1a29082c923 100644 --- a/src/fvOptions/sources/derived/tabulatedAccelerationSource/tabulatedAccelerationSource.C +++ b/src/fvOptions/sources/derived/tabulatedAccelerationSource/tabulatedAccelerationSource.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2015-2016 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -59,8 +59,8 @@ Foam::fv::tabulatedAccelerationSource::tabulatedAccelerationSource UName_(coeffs_.getOrDefault<word>("U", "U")), g0_("g0", dimAcceleration, Zero) { - fieldNames_.setSize(1, UName_); - applied_.setSize(1, false); + fieldNames_.resize(1, UName_); + fv::option::resetApplied(); if (mesh.time().foundObject<uniformDimensionedVectorField>("g")) { diff --git a/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.C b/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.C index c3c4b71a794fd42ce3eb91b7e10c2104ded1d434..79673faffa84f073e87b208bcbb907fa037d1a6e 100644 --- a/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.C +++ b/src/fvOptions/sources/derived/viscousDissipation/viscousDissipation.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2017-2020 OpenCFD Ltd. + Copyright (C) 2017-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -106,7 +106,7 @@ Foam::fv::viscousDissipation::viscousDissipation if (thermoPtr) { - fieldNames_.setSize(1, thermoPtr->he().name()); + fieldNames_.resize(1, thermoPtr->he().name()); } if (fieldNames_.empty()) @@ -120,7 +120,7 @@ Foam::fv::viscousDissipation::viscousDissipation << "settings are:" << fieldNames_ << exit(FatalError); } - applied_.setSize(fieldNames_.size(), false); + fv::option::resetApplied(); } diff --git a/src/fvOptions/sources/general/codedSource/CodedSource.C b/src/fvOptions/sources/general/codedSource/CodedFvSource.C similarity index 76% rename from src/fvOptions/sources/general/codedSource/CodedSource.C rename to src/fvOptions/sources/general/codedSource/CodedFvSource.C index 07bb792d99b93a21196ead5d9369bdabf3cd1457..969cb7937424b043b56f03c1940cd3e028c8629f 100644 --- a/src/fvOptions/sources/general/codedSource/CodedSource.C +++ b/src/fvOptions/sources/general/codedSource/CodedFvSource.C @@ -26,7 +26,7 @@ License \*---------------------------------------------------------------------------*/ -#include "CodedSource.H" +#include "CodedFvSource.H" #include "fvMesh.H" #include "fvMatrices.H" #include "dynamicCode.H" @@ -52,7 +52,7 @@ Foam::string Foam::fv::CodedSource<Type>::description() const template<class Type> void Foam::fv::CodedSource<Type>::clearRedirect() const { - redirectFvOptionPtr_.reset(nullptr); + redirectOptionPtr_.reset(nullptr); } @@ -124,7 +124,7 @@ Foam::fv::CodedSource<Type>::CodedSource const fvMesh& mesh ) : - cellSetOption(name, modelType, dict, mesh) + fv::cellSetOption(name, modelType, dict, mesh) { read(dict); } @@ -133,22 +133,62 @@ Foam::fv::CodedSource<Type>::CodedSource // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template<class Type> -Foam::fv::option& Foam::fv::CodedSource<Type>::redirectFvOption() const +bool Foam::fv::CodedSource<Type>::read(const dictionary& dict) { - if (!redirectFvOptionPtr_) + codedBase::setCodeContext(coeffs_); + + if (!fv::cellSetOption::read(dict)) + { + return false; + } + + coeffs_.readEntry("fields", fieldNames_); + + fv::option::resetApplied(); + + dict.readCompat<word>("name", {{"redirectType", 1706}}, name_); + + + // Code context chunks + + auto& ctx = codedBase::codeContext(); + + ctx.readEntry("codeCorrect", codeCorrect_); + ctx.readEntry("codeAddSup", codeAddSup_); + + // ctx.readEntry("codeConstrain", codeConstrain_); + ctx.readEntry // Compatibility + ( + coeffs_.lookupEntryCompat + ( + "codeConstrain", + {{ "codeSetValue", 1812 }}, + keyType::LITERAL + ).keyword(), + codeConstrain_ + ); + + return true; +} + + +template<class Type> +Foam::fv::option& Foam::fv::CodedSource<Type>::redirectOption() const +{ + if (!redirectOptionPtr_) { dictionary constructDict(dict_); constructDict.set("type", name_); constructDict.changeKeyword(modelType_ & "Coeffs", name_ & "Coeffs"); - redirectFvOptionPtr_ = fv::option::New + redirectOptionPtr_ = fv::option::New ( name_, constructDict, mesh_ ); } - return *redirectFvOptionPtr_; + return *redirectOptionPtr_; } @@ -159,11 +199,11 @@ void Foam::fv::CodedSource<Type>::correct ) { DebugInfo - << "CodedSource<" << pTraits<Type>::typeName + << "fv::CodedSource<" << pTraits<Type>::typeName << ">::correct for source " << name_ << endl; updateLibrary(name_); - redirectFvOption().correct(field); + redirectOption().correct(field); } @@ -175,11 +215,11 @@ void Foam::fv::CodedSource<Type>::addSup ) { DebugInfo - << "CodedSource<" << pTraits<Type>::typeName + << "fv::CodedSource<" << pTraits<Type>::typeName << ">::addSup for source " << name_ << endl; updateLibrary(name_); - redirectFvOption().addSup(eqn, fieldi); + redirectOption().addSup(eqn, fieldi); } @@ -192,11 +232,11 @@ void Foam::fv::CodedSource<Type>::addSup ) { DebugInfo - << "CodedSource<" << pTraits<Type>::typeName + << "fv::CodedSource<" << pTraits<Type>::typeName << ">::addSup for source " << name_ << endl; updateLibrary(name_); - redirectFvOption().addSup(rho, eqn, fieldi); + redirectOption().addSup(rho, eqn, fieldi); } @@ -208,11 +248,11 @@ void Foam::fv::CodedSource<Type>::constrain ) { DebugInfo - << "CodedSource<" << pTraits<Type>::typeName + << "fv::CodedSource<" << pTraits<Type>::typeName << ">::constrain for source " << name_ << endl; updateLibrary(name_); - redirectFvOption().constrain(eqn, fieldi); + redirectOption().constrain(eqn, fieldi); } diff --git a/src/fvOptions/sources/general/codedSource/CodedSource.H b/src/fvOptions/sources/general/codedSource/CodedFvSource.H similarity index 91% rename from src/fvOptions/sources/general/codedSource/CodedSource.H rename to src/fvOptions/sources/general/codedSource/CodedFvSource.H index 0da0e711c7c3a3728697f40282aaa34c87676d06..2f1606df9614db77d37d3e77a33e41361570a963 100644 --- a/src/fvOptions/sources/general/codedSource/CodedSource.H +++ b/src/fvOptions/sources/general/codedSource/CodedFvSource.H @@ -58,6 +58,14 @@ Description field is the name of the field in the fields list eqn is the fvMatrix + These are in addition to the usual code entries: + \plaintable + codeInclude | include files + codeOptions | compiler line: added to EXE_INC (Make/options) + codeLibs | linker line: added to LIB_LIBS (Make/options) + localCode | c++; local static functions + \endplaintable + Usage Example usage in controlDict: \verbatim @@ -89,7 +97,7 @@ Usage heSource -= 0.1*sqr(time.value())*V; #}; - codeContrain + codeConstrain #{ Pout<< "**codeConstrain**" << endl; #}; @@ -97,14 +105,13 @@ Usage } \endverbatim - SourceFiles codedSource.C \*---------------------------------------------------------------------------*/ -#ifndef CodedSource_H -#define CodedSource_H +#ifndef fv_CodedFvSource_H +#define fv_CodedFvSource_H #include "cellSetOption.H" #include "codedBase.H" @@ -137,7 +144,7 @@ protected: string codeConstrain_; //- Underlying code - mutable autoPtr<fv::option> redirectFvOptionPtr_; + mutable autoPtr<fv::option> redirectOptionPtr_; // Protected Member Functions @@ -190,7 +197,7 @@ public: // Member Functions //- Dynamically compiled fvOption - option& redirectFvOption() const; + fv::option& redirectOption() const; // Evaluation @@ -239,8 +246,7 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #ifdef NoRepository - #include "CodedSource.C" - #include "CodedSourceIO.C" + #include "CodedFvSource.C" #endif // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/fvOptions/sources/general/codedSource/CodedSourceIO.C b/src/fvOptions/sources/general/codedSource/CodedSourceIO.C deleted file mode 100644 index 02a1232f437bc0fd32eb4736d1a4b6a15bb1fe22..0000000000000000000000000000000000000000 --- a/src/fvOptions/sources/general/codedSource/CodedSourceIO.C +++ /dev/null @@ -1,72 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | - \\ / A nd | www.openfoam.com - \\/ M anipulation | -------------------------------------------------------------------------------- - Copyright (C) 2012-2016 OpenFOAM Foundation - Copyright (C) 2019-2021 OpenCFD Ltd. -------------------------------------------------------------------------------- -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 <http://www.gnu.org/licenses/>. - -\*---------------------------------------------------------------------------*/ - -#include "CodedSource.H" - -// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // - -template<class Type> -bool Foam::fv::CodedSource<Type>::read(const dictionary& dict) -{ - codedBase::setCodeContext(coeffs_); - - if (!cellSetOption::read(dict)) - { - return false; - } - - coeffs_.readEntry("fields", fieldNames_); - applied_.resize(fieldNames_.size(), false); - - dict.readCompat<word>("name", {{"redirectType", 1706}}, name_); - - - // Code context chunks - - auto& ctx = codedBase::codeContext(); - - ctx.readEntry("codeCorrect", codeCorrect_); - ctx.readEntry("codeAddSup", codeAddSup_); - - // ctx.readEntry("codeConstrain", codeConstrain_); - ctx.readEntry // Compatibility - ( - coeffs_.lookupEntryCompat - ( - "codeConstrain", - {{ "codeSetValue", 1812 }}, - keyType::LITERAL - ).keyword(), - codeConstrain_ - ); - - return true; -} - - -// ************************************************************************* // diff --git a/src/fvOptions/sources/general/codedSource/codedSource.C b/src/fvOptions/sources/general/codedSource/codedFvSources.C similarity index 98% rename from src/fvOptions/sources/general/codedSource/codedSource.C rename to src/fvOptions/sources/general/codedSource/codedFvSources.C index 0b0a7bc1ccb5a5ebcef5fc06c9bb1a81fb1646ca..f07d55e4b16e98b4a9ea0f5d9d76c1b8ecad8106 100644 --- a/src/fvOptions/sources/general/codedSource/codedSource.C +++ b/src/fvOptions/sources/general/codedSource/codedFvSources.C @@ -26,7 +26,7 @@ License \*---------------------------------------------------------------------------*/ #include "makeFvOption.H" -#include "CodedSource.H" +#include "CodedFvSource.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/fvOptions/sources/general/semiImplicitSource/SemiImplicitSource.C b/src/fvOptions/sources/general/semiImplicitSource/SemiImplicitSource.C index 2a3739f1731a012668805d74af7494e0ce83e9b8..f6053011394303555eb55acb904fd165e741d705 100644 --- a/src/fvOptions/sources/general/semiImplicitSource/SemiImplicitSource.C +++ b/src/fvOptions/sources/general/semiImplicitSource/SemiImplicitSource.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -54,10 +54,10 @@ void Foam::fv::SemiImplicitSource<Type>::setFieldData(const dictionary& dict) label count = dict.size(); fieldNames_.resize(count); - Su_.resize(count); - Sp_.resize(count); + Su_.resize(fieldNames_.size()); + Sp_.resize(fieldNames_.size()); - applied_.resize(count, false); + fv::option::resetApplied(); count = 0; for (const entry& dEntry : dict) diff --git a/src/fvOptions/sources/interRegion/interRegionExplicitPorositySource/interRegionExplicitPorositySource.C b/src/fvOptions/sources/interRegion/interRegionExplicitPorositySource/interRegionExplicitPorositySource.C index e4b815b68b3f9985acf1af34ccb5fa0992da9f4d..4e00e9b2251340d6c53ed795c07b298a87bd8395 100644 --- a/src/fvOptions/sources/interRegion/interRegionExplicitPorositySource/interRegionExplicitPorositySource.C +++ b/src/fvOptions/sources/interRegion/interRegionExplicitPorositySource/interRegionExplicitPorositySource.C @@ -126,8 +126,8 @@ Foam::fv::interRegionExplicitPorositySource::interRegionExplicitPorositySource { if (active_) { - fieldNames_.setSize(1, UName_); - applied_.setSize(1, false); + fieldNames_.resize(1, UName_); + fv::option::resetApplied(); } } diff --git a/src/fvOptions/sources/interRegion/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModel.C b/src/fvOptions/sources/interRegion/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModel.C index 5cf4aff0360dc693ac4f2397a81a21d77a9ea359..ea1d6f4d171cb0acd3c2d9218951cd25b539cbef 100644 --- a/src/fvOptions/sources/interRegion/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModel.C +++ b/src/fvOptions/sources/interRegion/interRegionHeatTransfer/interRegionHeatTransferModel/interRegionHeatTransferModel.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2020 OpenCFD Ltd. + Copyright (C) 2020-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -147,9 +147,8 @@ Foam::fv::interRegionHeatTransferModel::interRegionHeatTransferModel if (active()) { coeffs_.readEntry("fields", fieldNames_); - applied_.setSize(fieldNames_.size(), false); - coeffs_.readEntry("semiImplicit", semiImplicit_); + fv::option::resetApplied(); } } diff --git a/src/thermophysicalModels/radiation/fvOptions/radiation/radiation.C b/src/thermophysicalModels/radiation/fvOptions/radiation/radiation.C index 93f8eb8bfde7b2567f9e88964a45e47a49fd7f69..e9f8993233e9baf5c86fdb4e381919c05e141105 100644 --- a/src/thermophysicalModels/radiation/fvOptions/radiation/radiation.C +++ b/src/thermophysicalModels/radiation/fvOptions/radiation/radiation.C @@ -57,9 +57,9 @@ Foam::fv::radiation::radiation { const auto& thermo = mesh_.lookupObject<basicThermo>(basicThermo::dictName); - fieldNames_.setSize(1); + fieldNames_.resize(1); fieldNames_[0] = thermo.he().name(); - applied_.setSize(fieldNames_.size(), false); + fv::option::resetApplied(); radiation_ = Foam::radiation::radiationModel::New(thermo.T()); } diff --git a/src/waveModels/fvOptions/multiphaseMangrovesSource/multiphaseMangrovesSource.C b/src/waveModels/fvOptions/multiphaseMangrovesSource/multiphaseMangrovesSource.C index c7cb5844d5f40ec1127d0cc65dc8dffda5e5b9a2..b0e7d64fe615b551129c3cbce6cad6beb37d3a75 100644 --- a/src/waveModels/fvOptions/multiphaseMangrovesSource/multiphaseMangrovesSource.C +++ b/src/waveModels/fvOptions/multiphaseMangrovesSource/multiphaseMangrovesSource.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017 IH-Cantabria - Copyright (C) 2017-2020 OpenCFD Ltd. + Copyright (C) 2017-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -213,8 +213,7 @@ bool Foam::fv::multiphaseMangrovesSource::read(const dictionary& dict) fieldNames_.resize(1); fieldNames_.first() = coeffs_.getOrDefault<word>("U", "U"); } - - applied_.setSize(fieldNames_.size(), false); + fv::option::resetApplied(); // Create the Mangroves models - 1 per region const dictionary& regionsDict(coeffs_.subDict("regions")); diff --git a/src/waveModels/fvOptions/multiphaseMangrovesTurbulenceModel/multiphaseMangrovesTurbulenceModel.C b/src/waveModels/fvOptions/multiphaseMangrovesTurbulenceModel/multiphaseMangrovesTurbulenceModel.C index fb754cafbc59c5ad7f17e8723cf37319b572eff7..5cda1d1da8c276fd10f5a27f01e33b79dde61b01 100644 --- a/src/waveModels/fvOptions/multiphaseMangrovesTurbulenceModel/multiphaseMangrovesTurbulenceModel.C +++ b/src/waveModels/fvOptions/multiphaseMangrovesTurbulenceModel/multiphaseMangrovesTurbulenceModel.C @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017 IH-Cantabria - Copyright (C) 2017-2018 OpenCFD Ltd. + Copyright (C) 2017-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -243,8 +243,7 @@ bool Foam::fv::multiphaseMangrovesTurbulenceModel::read(const dictionary& dict) fieldNames_[1] = "k"; } } - - applied_.setSize(fieldNames_.size(), false); + fv::option::resetApplied(); // Create the Mangroves models - 1 per region const dictionary& regionsDict(coeffs_.subDict("regions"));