diff --git a/applications/utilities/postProcessing/wall/wallHeatFlux/createFields.H b/applications/utilities/postProcessing/wall/wallHeatFlux/createFields.H index 64eac51eaa..609d4c3776 100644 --- a/applications/utilities/postProcessing/wall/wallHeatFlux/createFields.H +++ b/applications/utilities/postProcessing/wall/wallHeatFlux/createFields.H @@ -1,6 +1,6 @@ -autoPtr thermo +autoPtr thermo ( - hCombustionThermo::New(mesh) + basicPsiThermo::New(mesh) ); const volScalarField& h = thermo->h(); diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index 7928295d99..84ff879b50 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -157,6 +157,8 @@ $(derivedFvPatchFields)/uniformFixedValue/uniformFixedValueFvPatchFields.C $(derivedFvPatchFields)/waveTransmissive/waveTransmissiveFvPatchFields.C $(derivedFvPatchFields)/uniformDensityHydrostaticPressure/uniformDensityHydrostaticPressureFvPatchScalarField.C $(derivedFvPatchFields)/swirlFlowRateInletVelocity/swirlFlowRateInletVelocityFvPatchVectorField.C +$(derivedFvPatchFields)/cylindricalInletVelocity/cylindricalInletVelocityFvPatchVectorField.C + fvsPatchFields = fields/fvsPatchFields $(fvsPatchFields)/fvsPatchField/fvsPatchFields.C @@ -354,4 +356,13 @@ fieldSources = $(general)/fieldSources $(fieldSources)/pressureGradientExplicitSource/pressureGradientExplicitSource.C $(fieldSources)/timeActivatedExplicitSource/timeActivatedExplicitSource.C +basicSource = $(general)/fieldSources/basicSource +$(basicSource)/basicSource/basicSource.C +$(basicSource)/basicSource/basicSourceIO.C +$(basicSource)/basicSource/basicSourceList.C +$(basicSource)/basicSource/IObasicSourceList.C +$(basicSource)/actuationDiskSource/actuationDiskSource.C +$(basicSource)/explicitSource/explicitSource.C + + LIB = $(FOAM_LIBBIN)/libfiniteVolume diff --git a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.C b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.C new file mode 100644 index 0000000000..a4f5773bfa --- /dev/null +++ b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.C @@ -0,0 +1,193 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*----------------------------------------------------------------------------*/ + +#include "actuationDiskSource.H" +#include "fvMesh.H" +#include "fvMatrices.H" +#include "geometricOneField.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(actuationDiskSource, 0); + addToRunTimeSelectionTable(basicSource, actuationDiskSource, dictionary); +} + + +// * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // + +void Foam::actuationDiskSource::checkData() +{ + if (magSqr(diskArea_) <= VSMALL) + { + FatalErrorIn("Foam::actuationDiskSource::checkData()") + << "diskArea is approximately zero" + << exit(FatalIOError); + } + if (Cp_ <= VSMALL || Ct_ <= VSMALL) + { + FatalErrorIn("Foam::actuationDiskSource::checkData()") + << "Cp and Ct must be greater than zero" + << exit(FatalIOError); + } + if (mag(diskDir_) < VSMALL) + { + FatalErrorIn("Foam::actuationDiskSource::checkData()") + << "disk direction vector is approximately zero" + << exit(FatalIOError); + } +} + + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::actuationDiskSource::actuationDiskSource +( + const word& name, + const dictionary& dict, + const fvMesh& mesh +) +: + basicSource(name, dict, mesh), + cellZoneID_(mesh.cellZones().findZoneID(this->cellSetName())), + dict_(dict.subDict(typeName + "Coeffs")), + diskDir_(dict_.lookup("diskDir")), + Cp_(readScalar(dict_.lookup("Cp"))), + Ct_(readScalar(dict_.lookup("Ct"))), + diskArea_(readScalar(dict_.lookup("diskArea"))) +{ + Info<< " - creating actuation disk zone: " + << this->name() << endl; + + bool foundZone = (cellZoneID_ != -1); + + reduce(foundZone, orOp()); + + if (!foundZone && Pstream::master()) + { + FatalErrorIn + ( + "Foam::actuationDiskSource::actuationDiskSource" + "(const word&, const dictionary&, const fvMesh&)" + ) << "cannot find porous cellZone " << this->name() + << exit(FatalError); + } + + checkData(); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void Foam::actuationDiskSource::addSu(fvMatrix& UEqn) +{ + if (cellZoneID_ == -1) + { + return; + } + + bool compressible = false; + if (UEqn.dimensions() == dimensionSet(1, 1, -2, 0, 0)) + { + compressible = true; + } + + const labelList& cells = mesh_.cellZones()[cellZoneID_]; + const scalarField& V = this->mesh().V(); + vectorField& Usource = UEqn.source(); + const vectorField& U = UEqn.psi(); + + if (compressible) + { + addActuationDiskAxialInertialResistance + ( + Usource, + cells, + V, + this->mesh().lookupObject("rho"), + U + ); + } + else + { + addActuationDiskAxialInertialResistance + ( + Usource, + cells, + V, + geometricOneField(), + U + ); + } +} + + +void Foam::actuationDiskSource::writeData(Ostream& os) const +{ + + os << indent << token::BEGIN_BLOCK << incrIndent << nl; + os.writeKeyword("name") << this->name() << token::END_STATEMENT << nl; + + if (dict_.found("note")) + { + os.writeKeyword("note") << string(dict_.lookup("note")) + << token::END_STATEMENT << nl; + } + + os << indent << "actuationDisk"; + + dict_.write(os); + + os << decrIndent << indent << token::END_BLOCK << endl; +} + + +bool Foam::actuationDiskSource::read(const dictionary& dict) +{ + if (basicSource::read(dict)) + { + const dictionary& sourceDict = dict.subDict(name()); + const dictionary& subDictCoeffs = + sourceDict.subDict(typeName + "Coeffs"); + subDictCoeffs.readIfPresent("diskDir", diskDir_); + subDictCoeffs.readIfPresent("Cp", Cp_); + subDictCoeffs.readIfPresent("Ct", Ct_); + subDictCoeffs.readIfPresent("diskArea", diskArea_); + + checkData(); + + return true; + } + else + { + return false; + } +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.H b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.H new file mode 100644 index 0000000000..6b21973af3 --- /dev/null +++ b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/actuationDiskSource/actuationDiskSource.H @@ -0,0 +1,215 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Class + Foam::actuationDiskSource + +Description + Actuation disk zone definition. + Constant values for momentum source for actuation disk + + T = 2*rho*A*sqr(Uo)*a*(1-a) + U1 = (1 -a)Uo + where: + A: disk area + Uo: upstream velocity + a: 1 - Cp/Ct + U1: velocity at the disk + +SourceFiles + actuationDiskSource.C + actuationDiskSourceTemplates.C + +\*---------------------------------------------------------------------------*/ + +#ifndef actuationDiskSource_H +#define actuationDiskSource_H + +#include "IOdictionary.H" +#include "coordinateSystem.H" +#include "coordinateSystems.H" +#include "wordList.H" +#include "labelList.H" +#include "DimensionedField.H" +#include "volFieldsFwd.H" +#include "fvMatricesFwd.H" +#include "basicSource.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class actuationDiskSource Declaration +\*---------------------------------------------------------------------------*/ + +class actuationDiskSource +: + public basicSource +{ + // Private data + + //- Cell zone ID + label cellZoneID_; + + //- Sub dictionary with actuationDisk information + const dictionary& dict_; + + //- Disk area normal + vector diskDir_; + + //- Power coefficient + scalar Cp_; + + //- Thrust coefficient + scalar Ct_; + + //- Disk area + scalar diskArea_; + + + // Private Member Functions + + //- Check data + void checkData(); + + //- Add resistance to the UEqn + template + void addActuationDiskAxialInertialResistance + ( + vectorField& Usource, + const labelList& cells, + const scalarField& V, + const RhoFieldType& rho, + const vectorField& U + ) const; + + //- Disallow default bitwise copy construct + actuationDiskSource(const actuationDiskSource&); + + //- Disallow default bitwise assignment + void operator=(const actuationDiskSource&); + + +public: + + //- Runtime type information + TypeName("actuationDiskSource"); + + + // Constructors + + //- Construct from components + actuationDiskSource + ( + const word& name, + const dictionary& dict, + const fvMesh& mesh + ); + + + //- Destructor + virtual ~actuationDiskSource() + {} + + + // Member Functions + + // Access + + //- cellZone number + label zoneId() const + { + return cellZoneID_; + } + + //- Return Cp + scalar Cp() const + { + return Cp_; + } + + //- Return Ct + scalar Ct() const + { + return Ct_; + } + + //- Normal disk direction + const vector& diskDir() const + { + return diskDir_; + } + + //- Disk area + scalar diskArea() const + { + return diskArea_; + } + + + // Public Functions + + //-Source term to fvMatrix + virtual void addSu(fvMatrix& UEqn); + + //-Source term to fvMatrix + virtual void addSu(fvMatrix& UEqn){} + + //- Add all explicit source + virtual void addExplicitSources(){} + + //- Add source to scalar field + virtual void addSu(DimensionedField& field){} + + //- Add source to vector field + virtual void addSu(DimensionedField& field){} + + + // I-O + + //- Write data + virtual void writeData(Ostream&) const; + + //- Read dictionary + virtual bool read(const dictionary& dict); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "actuationDiskSourceTemplates.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/actuationDiskSource/actuationDiskSourceTemplates.C b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/actuationDiskSource/actuationDiskSourceTemplates.C new file mode 100644 index 0000000000..971b8edfcd --- /dev/null +++ b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/actuationDiskSource/actuationDiskSourceTemplates.C @@ -0,0 +1,65 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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, write to the Free Software Foundation, + Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +\*----------------------------------------------------------------------------*/ + +#include "actuationDiskSource.H" +#include "volFields.H" +#include "fvMatrix.H" +#include "fvm.H" + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void Foam::actuationDiskSource::addActuationDiskAxialInertialResistance +( + vectorField& Usource, + const labelList& cells, + const scalarField& V, + const RhoFieldType& rho, + const vectorField& U +) const +{ + scalar a = 1.0 - Cp_/Ct_; + scalar totVol = 0.0; + scalarField T(cells.size()); + vector uniDiskDir = diskDir_/mag(diskDir_); + tensor E(tensor::zero); + E.xx() = uniDiskDir.x(); + E.yy() = uniDiskDir.y(); + E.zz() = uniDiskDir.z(); + vectorField U1 = (1.0 - a)*U; + forAll(cells, i) + { + totVol += V[cells[i]]; + T[i] = 2.0*rho[cells[i]]*diskArea_*mag(U1[cells[i]])*a/(1.0 - a); + } + forAll(cells, i) + { + Usource[cells[i]] += ((V[cells[i]]/totVol)*T[i]*E) & U1[cells[i]]; + } +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/IObasicSourceList.C b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/IObasicSourceList.C new file mode 100644 index 0000000000..8ce372e8ff --- /dev/null +++ b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/IObasicSourceList.C @@ -0,0 +1,65 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 "IObasicSourceList.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +Foam::IObasicSourceList::IObasicSourceList +( + const fvMesh& mesh +) +: + IOdictionary + ( + IOobject + ( + "sourcesProperties", + mesh.time().constant(), + mesh, + IOobject::MUST_READ, + IOobject::NO_WRITE + ) + ), + basicSourceList(mesh, *this) +{} + + +bool Foam::IObasicSourceList::read() +{ + if (regIOobject::read()) + { + basicSourceList::read(*this); + return true; + } + else + { + return false; + } +} + + +// ************************************************************************* // + diff --git a/src/lagrangian/dieselSpray/spraySubModels/dispersionModel/dispersionModel/newDispersionModel.C b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/IObasicSourceList.H similarity index 53% rename from src/lagrangian/dieselSpray/spraySubModels/dispersionModel/dispersionModel/newDispersionModel.C rename to src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/IObasicSourceList.H index 4c3c6664d2..d4b2c11f1c 100644 --- a/src/lagrangian/dieselSpray/spraySubModels/dispersionModel/dispersionModel/newDispersionModel.C +++ b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/IObasicSourceList.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd. + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -21,55 +21,73 @@ License You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see . +Class + Foam::IObasicSourceList + +Description + IObasicSourceList + +SourceFiles + IObasicSourceList.C + \*---------------------------------------------------------------------------*/ -#include "error.H" +#ifndef IObasicSourceList_H +#define IObasicSourceList_H -#include "dispersionModel.H" -#include "noDispersion.H" +#include "basicSourceList.H" +#include "IOdictionary.H" +#include "autoPtr.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { -// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +/*---------------------------------------------------------------------------*\ + Class IObasicSourceList Declaration +\*---------------------------------------------------------------------------*/ -autoPtr dispersionModel::New -( - const dictionary& dict, - spray& sm -) +class IObasicSourceList +: + public IOdictionary, + public basicSourceList { - word dispersionModelType - ( - dict.lookup("dispersionModel") - ); +private: - Info<< "Selecting dispersionModel " - << dispersionModelType << endl; + // Private Member Functions - dictionaryConstructorTable::iterator cstrIter = - dictionaryConstructorTablePtr_->find(dispersionModelType); + //- Disallow default bitwise copy construct + IObasicSourceList(const IObasicSourceList&); - if (cstrIter == dictionaryConstructorTablePtr_->end()) - { - FatalError - << "dispersionModel::New(const dictionary&, const spray&) : " - << endl - << " unknown dispersionModelType type " - << dispersionModelType - << ", constructor not in hash table" << endl << endl - << " Valid dispersionModel types are :" << endl; - Info<< dictionaryConstructorTablePtr_->sortedToc() << abort(FatalError); - } + //- Disallow default bitwise assignment + void operator=(const IObasicSourceList&); - return autoPtr(cstrIter()(dict, sm)); -} + +public: + + // Constructors + + //- Construct from components with list of field names + IObasicSourceList(const fvMesh& mesh); + + + //- Destructor + virtual ~IObasicSourceList() + {} + + + //- Read dictionary + virtual bool read(); +}; // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // } // End namespace Foam +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + // ************************************************************************* // diff --git a/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSource.C b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSource.C new file mode 100644 index 0000000000..a42ecd25f0 --- /dev/null +++ b/src/finiteVolume/cfdTools/general/fieldSources/basicSource/basicSource/basicSource.C @@ -0,0 +1,283 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2010-2010 OpenCFD Ltd. + \\/ 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 "basicSource.H" +#include "fvMesh.H" +#include "volFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(basicSource, 0); + defineRunTimeSelectionTable(basicSource, dictionary); +} + + +// * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * * // + +const Foam::wordList Foam::basicSource::selectionModeTypeNames_ +( + IStringStream("(points cellSet cellZone all)")() +); + + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +Foam::basicSource::selectionModeType Foam::basicSource::wordToSelectionModeType +( + const word& smtName +) const +{ + forAll(selectionModeTypeNames_, i) + { + if (smtName == selectionModeTypeNames_[i]) + { + return selectionModeType(i); + } + } + + FatalErrorIn + ( + "basicSource::selectionModeType" + "basicSource::wordToSelectionModeType" + "(" + "const word&" + ")" + ) << "Unknown selectionMode type " << smtName + << ". Valid selectionMode types are:" << nl << selectionModeTypeNames_ + << exit(FatalError); + + return selectionModeType(0); +} + + +Foam::word Foam::basicSource::selectionModeTypeToWord +( + const selectionModeType& smtType +) const +{ + if (smtType > selectionModeTypeNames_.size()) + { + return "UNKNOWN"; + } + else + { + return selectionModeTypeNames_[smtType]; + } +} + + +void Foam::basicSource::setSelection(const dictionary& dict) +{ + switch (selectionMode_) + { + case smPoints: + { + // Do nothing. It should be sorted out by derived class + break; + } + case smCellSet: + { + dict.lookup("cellSet") >> cellSetName_; + break; + } + case smCellZone: + { + dict.lookup("cellZone") >> cellSetName_; + break; + } + case smAll: + { + break; + } + default: + { + FatalErrorIn + ( + "basicSource::setSelection(const dictionary&)" + ) << "Unknown selectionMode " + << selectionModeTypeNames_[selectionMode_] + << ". Valid selectionMode types are" << selectionModeTypeNames_ + << exit(FatalError); + } + } +} + + +void Foam::basicSource::setCellSet() +{ + Info<< incrIndent << indent << "Source: " << name_ << endl; + switch (selectionMode_) + { + case smPoints: + { + break; + } + case smCellSet: + { + Info<< indent << "- selecting cells using cellSet " + << cellSetName_ << endl; + + cellSet selectedCells(mesh_, cellSetName_); + cells_ = selectedCells.toc(); + + break; + } + case smCellZone: + { + Info<< indent << "- selecting cells using cellZone " + << cellSetName_ << endl; + label zoneID = mesh_.cellZones().findZoneID(cellSetName_); + if (zoneID == -1) + { + FatalErrorIn("basicSource::setCellIds()") + << "Cannot find cellZone " << cellSetName_ << endl + << "Valid cellZones are " << mesh_.cellZones().names() + << exit(FatalError); + } + cells_ = mesh_.cellZones()[zoneID]; + + break; + } + case smAll: + { + Info<< indent << "- selecting all cells" << endl; + cells_ = identity(mesh_.nCells()); + + break; + } + default: + { + FatalErrorIn("basicSource::setCellIds()") + << "Unknown selectionMode " + << selectionModeTypeNames_[selectionMode_] + << ". Valid selectionMode types are" << selectionModeTypeNames_ + << exit(FatalError); + } + } + + // Set volume information + if (selectionMode_ != smPoints) + { + V_ = 0.0; + forAll(cells_, i) + { + V_ += mesh_.V()[cells_[i]]; + } + reduce(V_, sumOp()); + + Info<< indent << "- selected " + << returnReduce(cells_.size(), sumOp