/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Copyright (C) 2025-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 "cloudSurfaceDistribution.H" #include "cloud.H" #include "faceSet.H" #include "functionObject.H" #include "hashedWordList.H" #include "OSspecific.H" #include "timeIOdictionary.H" #include "unintegrable.H" #include "writeFile.H" #include "addToRunTimeSelectionTable.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { namespace functionObjects { defineTypeNameAndDebug(cloudSurfaceDistribution, 0); addToRunTimeSelectionTable ( functionObject, cloudSurfaceDistribution, dictionary ); } } const Foam::NamedEnum < Foam::functionObjects::cloudSurfaceDistribution::selectionType, 3 > Foam::functionObjects::cloudSurfaceDistribution::selectionTypeNames {"faceZone", "faceSet", "patch"}; // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // Foam::wordList Foam::functionObjects::cloudSurfaceDistribution::readFields ( const dictionary& dict, const word& key, const wordList& defaultValue ) { const bool haveFields = dict.found(key + "s"); const bool haveField = dict.found(key); if (notNull(defaultValue) && !haveFields && !haveField) { return defaultValue; } if (haveFields == haveField) { FatalIOErrorInFunction(dict) << "keywords " << key << "s and " << key << " both " << (haveFields ? "" : "un") << "defined in " << "dictionary " << dict.name() << exit(FatalIOError); } if (haveFields) { return dict.lookup(key + "s"); } else { return wordList({dict.lookup(key)}); } } Foam::functionObjects::cloudSurfaceDistribution::selectionType Foam::functionObjects::cloudSurfaceDistribution::readSelectionType ( const dictionary& dict ) { // Use the "select" entry if it is there if (dict.found("select")) { return selectionTypeNames.read(dict.lookup("select")); } // If there is only one of the possible keys (i.e., "faceZone", "faceSet", // and "patch") present in the dictionary then infer the selection type // from that key const NamedEnum::namesType& keys = selectionTypeNames; label keyi = -1; forAll(keys, i) { if (!dict.found(keys[i])) continue; keyi = keyi == -1 ? i : -labelMax; } if (keyi >= 0) { return selectionTypeNames[keys[keyi]]; } // Raise an error requesting a "select" entry return selectionTypeNames.read(dict.lookup("select")); } const char* const* Foam::functionObjects::cloudSurfaceDistribution::componentNames ( const label fieldi ) const { #define FIELD_RANGE_COMPONENT_NAMES(Type, GeoField) \ if (mesh().foundObject>(fields_[fieldi])) \ { \ return pTraits::componentNames; \ } FOR_ALL_FIELD_TYPES(FIELD_RANGE_COMPONENT_NAMES, LagrangianField) FOR_ALL_FIELD_TYPES(FIELD_RANGE_COMPONENT_NAMES, LagrangianDynamicField) FOR_ALL_FIELD_TYPES(FIELD_RANGE_COMPONENT_NAMES, LagrangianInternalField) return nullptr; } void Foam::functionObjects::cloudSurfaceDistribution::readCoeffs ( const dictionary& dict, const bool props ) { // Re-read the fields const hashedWordList oldFields(fields_); fields_ = readFields(dict, "field"); // Determine if any fields are being continued bool continued = false; forAll(fields_, fieldi) { continued = continued || oldFields.found(fields_[fieldi]); } // If we are continuing then the weight fields must not have changed const wordList oldWeightFields(weightFields_); weightFields_ = readFields(dict, "weightField", wordList()); if (continued && weightFields_ != oldWeightFields) { FatalIOErrorInFunction(dict) << "Cannot change weight fields at run-time" << exit(FatalIOError); } // If we are continuing then the surface must not have changed const selectionType oldSelectionType = selectionType_; selectionType_ = readSelectionType(dict); const word oldSelectionName = selectionName_; selectionName_ = dict.lookup(selectionTypeNames[selectionType_]); if ( selectionType_ != oldSelectionType || selectionName_ != oldSelectionName ) { FatalIOErrorInFunction(dict) << "Cannot change the selected surface at run-time" << exit(FatalIOError); } // If we are continuing then the number of bins must not have changed const label oldNBins = nBins_; nBins_ = dict.lookup