diff --git a/applications/solvers/multiphase/compressibleInterFoam/VoFSolidificationMeltingSource/VoFSolidificationMeltingSource.C b/applications/solvers/multiphase/compressibleInterFoam/VoFSolidificationMeltingSource/VoFSolidificationMeltingSource.C index 8e829200a4..41b0d860ec 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/VoFSolidificationMeltingSource/VoFSolidificationMeltingSource.C +++ b/applications/solvers/multiphase/compressibleInterFoam/VoFSolidificationMeltingSource/VoFSolidificationMeltingSource.C @@ -86,7 +86,7 @@ void Foam::fv::VoFSolidificationMeltingSource::update() const const volScalarField CpVoF(thermo.thermo1().Cp()); const volScalarField& alphaVoF = thermo.alpha1(); - const labelList& cells = this->cells(); + const labelList& cells = set_.cells(); forAll(cells, i) { @@ -126,13 +126,14 @@ Foam::word Foam::fv::VoFSolidificationMeltingSource::alphaSolidName() const Foam::fv::VoFSolidificationMeltingSource::VoFSolidificationMeltingSource ( - const word& sourceName, + const word& name, const word& modelType, const dictionary& dict, const fvMesh& mesh ) : - cellSetModel(sourceName, modelType, dict, mesh), + fvModel(name, modelType, dict, mesh), + set_(coeffs(), mesh), alphaSolidT_(), L_("L", dimEnergy/dimMass, NaN), relax_(NaN), @@ -218,7 +219,7 @@ void Foam::fv::VoFSolidificationMeltingSource::addSup scalarField& Sp = eqn.diag(); const scalarField& V = mesh().V(); - const labelList& cells = this->cells(); + const labelList& cells = set_.cells(); forAll(cells, i) { @@ -233,10 +234,20 @@ void Foam::fv::VoFSolidificationMeltingSource::addSup } +void Foam::fv::VoFSolidificationMeltingSource::updateMesh +( + const mapPolyMesh& mpm +) +{ + set_.updateMesh(mpm); +} + + bool Foam::fv::VoFSolidificationMeltingSource::read(const dictionary& dict) { - if (cellSetModel::read(dict)) + if (fvModel::read(dict)) { + set_.read(coeffs()); readCoeffs(); return true; } diff --git a/applications/solvers/multiphase/compressibleInterFoam/VoFSolidificationMeltingSource/VoFSolidificationMeltingSource.H b/applications/solvers/multiphase/compressibleInterFoam/VoFSolidificationMeltingSource/VoFSolidificationMeltingSource.H index a32f25d2ec..ddc52ea113 100644 --- a/applications/solvers/multiphase/compressibleInterFoam/VoFSolidificationMeltingSource/VoFSolidificationMeltingSource.H +++ b/applications/solvers/multiphase/compressibleInterFoam/VoFSolidificationMeltingSource/VoFSolidificationMeltingSource.H @@ -78,9 +78,10 @@ SourceFiles #ifndef VoFSolidificationMeltingSource_H #define VoFSolidificationMeltingSource_H +#include "fvModel.H" +#include "fvCellSet.H" #include "fvMesh.H" #include "volFields.H" -#include "cellSetModel.H" #include "Function1.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -96,10 +97,13 @@ namespace fv class VoFSolidificationMeltingSource : - public cellSetModel + public fvModel { // Private Data + //- The set of cells the fvConstraint applies to + fvCellSet set_; + //- Solid fraction as a function of temperature autoPtr> alphaSolidT_; @@ -149,7 +153,7 @@ public: //- Construct from explicit source name and mesh VoFSolidificationMeltingSource ( - const word& sourceName, + const word& name, const word& modelType, const dictionary& dict, const fvMesh& mesh @@ -190,6 +194,12 @@ public: ) const; + // Mesh motion + + //- Update for mesh changes + virtual void updateMesh(const mapPolyMesh&); + + // IO //- Read source dictionary diff --git a/etc/codeTemplates/dynamicCode/codedFvModelTemplate.C b/etc/codeTemplates/dynamicCode/codedFvModelTemplate.C index ef51a11023..c88eedc9fd 100644 --- a/etc/codeTemplates/dynamicCode/codedFvModelTemplate.C +++ b/etc/codeTemplates/dynamicCode/codedFvModelTemplate.C @@ -100,7 +100,8 @@ ${typeName}FvModel${SourceType} const fvMesh& mesh ) : - cellSetModel(name, modelType, dict, mesh) + fvModel(name, modelType, dict, mesh) + set_(coeffs(), mesh), { if (${verbose:-false}) { diff --git a/etc/codeTemplates/dynamicCode/codedFvModelTemplate.H b/etc/codeTemplates/dynamicCode/codedFvModelTemplate.H index c9307b9587..1748c3510d 100644 --- a/etc/codeTemplates/dynamicCode/codedFvModelTemplate.H +++ b/etc/codeTemplates/dynamicCode/codedFvModelTemplate.H @@ -32,7 +32,8 @@ SourceFiles #ifndef codedFvModelTemplate_H #define codedFvModelTemplate_H -#include "cellSetModel.H" +#include "fvModel.H" +#include "fvCellSet.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -48,8 +49,14 @@ namespace fv class ${typeName}FvModel${SourceType} : - public cellSetModel + public fvModel { + // Private Data + + //- The set of cells the fvConstraint applies to + fvCellSet set_; + + public: //- Information about the SHA1 of the code itself diff --git a/src/fvModels/Make/files b/src/fvModels/Make/files index 0d97561ca3..3d2f71600b 100644 --- a/src/fvModels/Make/files +++ b/src/fvModels/Make/files @@ -1,4 +1,3 @@ -cellSetModel/cellSetModel.C interRegionModel/interRegionModel.C general/codedFvModel/codedFvModel.C diff --git a/src/fvModels/cellSetModel/cellSetModel.C b/src/fvModels/cellSetModel/cellSetModel.C deleted file mode 100644 index 5b4a0bcd04..0000000000 --- a/src/fvModels/cellSetModel/cellSetModel.C +++ /dev/null @@ -1,236 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2021 OpenFOAM Foundation - \\/ M anipulation | -------------------------------------------------------------------------------- -License - This file is part of OpenFOAM. - - OpenFOAM is free software: you can redistribute it and/or modify it - under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - OpenFOAM is distributed in the hope that it will be useful, but WITHOUT - ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - for more details. - - You should have received a copy of the GNU General Public License - along with OpenFOAM. If not, see . - -\*---------------------------------------------------------------------------*/ - -#include "cellSetModel.H" -#include "volFields.H" - -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - -namespace Foam -{ - namespace fv - { - defineTypeNameAndDebug(cellSetModel, 0); - } - - template<> const char* NamedEnum - < - fv::cellSetModel::selectionModeType, - 4 - >::names[] = - { - "points", - "cellSet", - "cellZone", - "all" - }; - - const NamedEnum - fv::cellSetModel::selectionModeTypeNames_; -} - - -// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // - -void Foam::fv::cellSetModel::readCoeffs() -{ - selectionMode_ = - selectionModeTypeNames_.read(coeffs().lookup("selectionMode")); - - switch (selectionMode_) - { - case selectionModeType::points: - { - coeffs().lookup("points") >> points_; - break; - } - case selectionModeType::cellSet: - { - coeffs().lookup("cellSet") >> cellSetName_; - break; - } - case selectionModeType::cellZone: - { - coeffs().lookup("cellZone") >> cellSetName_; - break; - } - case selectionModeType::all: - { - break; - } - default: - { - FatalErrorInFunction - << "Unknown selectionMode " - << selectionModeTypeNames_[selectionMode_] - << ". Valid selectionMode types are" << selectionModeTypeNames_ - << exit(FatalError); - } - } -} - - -void Foam::fv::cellSetModel::setCellSet() -{ - Info<< incrIndent; - - switch (selectionMode_) - { - case selectionModeType::points: - { - Info<< indent << "- selecting cells using points" << endl; - - labelHashSet selectedCells; - - forAll(points_, i) - { - label celli = mesh().findCell(points_[i]); - if (celli >= 0) - { - selectedCells.insert(celli); - } - - label globalCelli = returnReduce(celli, maxOp