/*---------------------------------------------------------------------------*\ ========= | \\ / 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 "UFunctionalDimensionedField.H" // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // template Foam::UFunctionalDimensionedField::UFunctionalDimensionedField ( const word& name, const word& funcName, const GeoMesh& mesh, const dimensionSet& dimensions, Field& field, const dictionary& dict ) : SlicedDimensionedField ( IOobject ( word(name, '_', funcName), mesh.time().name(), mesh.db(), IOobject::NO_READ, IOobject::NO_WRITE, false ), mesh, dimensions, field ), field_(field), funcName_(funcName), funcPtr_ ( dict.isDict(funcName) ? DimensionedFieldFunction>::New ( dict.subDict(funcName), *this ) : autoPtr>> ( nullptr ) ) { if (funcPtr_.valid()) { if (mesh.time().completeCase()) { funcPtr_->evaluate(); } } else { field_ = Field(funcName_, dimensions, dict, mesh.size()); } } template Foam::UFunctionalDimensionedField::UFunctionalDimensionedField ( const word& name, const word& funcName, const GeoMesh& mesh, const dimensionSet& dimensions, Field& field, const dictionary& dict, const Type& defaultValue ) : SlicedDimensionedField ( IOobject ( word(name, '_', funcName), mesh.time().name(), mesh.db(), IOobject::NO_READ, IOobject::NO_WRITE, false ), mesh, dimensions, field ), field_(field), funcName_(funcName), funcPtr_ ( dict.isDict(funcName) ? DimensionedFieldFunction>::New ( dict.subDict(funcName), *this ) : autoPtr>> ( nullptr ) ) { if (funcPtr_.valid()) { if (mesh.time().completeCase()) { funcPtr_->evaluate(); } } else if (dict.found(funcName)) { field_ = Field(funcName_, dimensions, dict, mesh.size()); SlicedDimensionedField::reset(field_); } else { field_ = Field(mesh.size(), defaultValue); SlicedDimensionedField::reset(field_); } } template Foam::UFunctionalDimensionedField::UFunctionalDimensionedField ( const UFunctionalDimensionedField& udff, const GeoMesh& mesh, Field& field ) : SlicedDimensionedField ( udff, mesh, udff.dimensions(), field ), field_(field), funcName_(udff.funcName_), funcPtr_ ( udff.funcPtr_.valid() ? udff.funcPtr_->clone(*this) : autoPtr>> ( nullptr ) ) {} template Foam::UFunctionalDimensionedField::UFunctionalDimensionedField ( const UFunctionalDimensionedField& udff, Field& field ) : SlicedDimensionedField ( udff, udff.mesh(), udff.dimensions(), field ), field_(field), funcName_(udff.funcName_), funcPtr_ ( udff.funcPtr_.valid() ? udff.funcPtr_->clone(*this) : autoPtr>> ( nullptr ) ) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template void Foam::UFunctionalDimensionedField::map(const bool evaluate) { SlicedDimensionedField::reset(field_); if (evaluate && funcPtr_.valid()) { funcPtr_->reset(); } } template void Foam::UFunctionalDimensionedField::reset() { SlicedDimensionedField::reset(field_); if (funcPtr_.valid()) { funcPtr_->reset(); } } template bool Foam::UFunctionalDimensionedField::update() { if (funcPtr_.valid()) { return funcPtr_->update(); } else { return false; } } template void Foam::UFunctionalDimensionedField::write(Ostream& os) const { if (funcPtr_.valid()) { funcPtr_->write(os); } } template void Foam::writeEntry ( Ostream& os, const UFunctionalDimensionedField& udff ) { if (udff.funcPtr_.valid()) { writeEntry(os, udff.funcName_, *udff.funcPtr_); } else { writeEntry(os, udff.funcName_, udff.field_); } } // ************************************************************************* //