/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Copyright (C) 2026 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 "Zonal_DimensionedFvPatchFieldFunction.H" #include "DimensionedField.H" #include "zoneGenerator.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template Foam::DimensionedFieldFunctions::Zonal:: Zonal ( const dictionary& dict, DimensionedFieldType& field ) : DimensionedFieldFunction(dict, field), value_(dict.lookup("defaultValue", this->field_.dimensions())), zonesDict_(dict.subDict("zones")) { evaluate(); } template Foam::DimensionedFieldFunctions::Zonal:: Zonal ( const Zonal& dff, DimensionedFieldType& field ) : DimensionedFieldFunction(dff, field), value_(dff.value_), zonesDict_(dff.zonesDict_) {} template Foam::autoPtr> Foam::DimensionedFieldFunctions::Zonal::clone ( DimensionedFieldType& field ) const { return autoPtr> ( new Zonal(*this, field) ); } // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template void Foam::DimensionedFieldFunctions::Zonal::evaluate() { DimensionedFieldType& field = this->field_; const fvMesh& mesh(field.mesh()()); field.primitiveFieldRef() = value_; forAllConstIter(dictionary, zonesDict_, iter) { const dictionary& zoneDict = iter().dict(); autoPtr zg ( zoneGenerator::New ( iter().keyword(), zoneType(), mesh, zoneDict ) ); const zoneSet zs(zg->generate()); if (zs.valid()) { const labelList& selected = zs.zone(); const Type value ( zoneDict.lookup("value", field.dimensions()) ); if (&selected == &labelList::null()) { field.primitiveFieldRef() = value; } else { forAll(selected, i) { const label patchi = mesh.poly().boundary().whichPatch(selected[i]); if (patchi == field.mesh().index()) { field[selected[i] - field.mesh().start()] = value; } } } } } } template void Foam::DimensionedFieldFunctions::Zonal::write ( Ostream& os ) const { writeEntry(os, "defaultValue", this->field_.dimensions(), value_); writeEntry(os, "zones", zonesDict_); } // ************************************************************************* //