OpenFOAM-dev / data /src /sampling /sampledSurface /sampledThresholdCellFaces /sampledThresholdCellFaces.C
Download data/src/sampling/sampledSurface/sampledThresholdCellFaces/sampledThresholdCellFaces.C from introvoyz042/OpenFOAM-dev: direct link, hf CLI and curl.
- Browser
- Download file 7.76 kB
-
https://huggingface.co/datasets/introvoyz042/OpenFOAM-dev/resolve/main/data/src/sampling/sampledSurface/sampledThresholdCellFaces/sampledThresholdCellFaces.C
- Command line
-
hf download hf://datasets/introvoyz042/OpenFOAM-dev/data/src/sampling/sampledSurface/sampledThresholdCellFaces/sampledThresholdCellFaces.C
-
curl -L -o sampledThresholdCellFaces.C https://huggingface.co/datasets/introvoyz042/OpenFOAM-dev/resolve/main/data/src/sampling/sampledSurface/sampledThresholdCellFaces/sampledThresholdCellFaces.C
7.76 kB
| /*---------------------------------------------------------------------------*\ | |
| ========= | | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox | |
| \\ / O peration | Website: https://openfoam.org | |
| \\ / A nd | Copyright (C) 2011-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 <http://www.gnu.org/licenses/>. | |
| \*---------------------------------------------------------------------------*/ | |
| // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // | |
| namespace Foam | |
| { | |
| namespace sampledSurfaces | |
| { | |
| defineTypeNameAndDebug(thresholdCellFaces, 0); | |
| addToRunTimeSelectionTable(sampledSurface, thresholdCellFaces, word); | |
| } | |
| } | |
| // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // | |
| bool Foam::sampledSurfaces::thresholdCellFaces::updateGeometry() const | |
| { | |
| const fvMesh& fvm = static_cast<const fvMesh&>(mesh()); | |
| // no update needed | |
| if (fvm.time().timeIndex() == prevTimeIndex_) | |
| { | |
| return false; | |
| } | |
| prevTimeIndex_ = fvm.time().timeIndex(); | |
| // Optionally read volScalarField | |
| autoPtr<volScalarField> readFieldPtr_; | |
| // 1. see if field in database | |
| // 2. see if field can be read | |
| const volScalarField* cellFldPtr = nullptr; | |
| if (fvm.foundObject<volScalarField>(fieldName_)) | |
| { | |
| if (debug) | |
| { | |
| InfoInFunction<< "Lookup " << fieldName_ << endl; | |
| } | |
| cellFldPtr = &fvm.lookupObject<volScalarField>(fieldName_); | |
| } | |
| else | |
| { | |
| // Bit of a hack. Read field and store. | |
| if (debug) | |
| { | |
| InfoInFunction | |
| << "Reading " << fieldName_ | |
| << " from time " << fvm.time().name() | |
| << endl; | |
| } | |
| readFieldPtr_.reset | |
| ( | |
| new volScalarField | |
| ( | |
| IOobject | |
| ( | |
| fieldName_, | |
| fvm.time().name(), | |
| fvm, | |
| IOobject::MUST_READ, | |
| IOobject::NO_WRITE, | |
| false | |
| ), | |
| fvm | |
| ) | |
| ); | |
| cellFldPtr = readFieldPtr_.operator->(); | |
| } | |
| const volScalarField& cellFld = *cellFldPtr; | |
| Foam::thresholdCellFaces surf | |
| ( | |
| fvm, | |
| cellFld.primitiveField(), | |
| lowerThreshold_, | |
| upperThreshold_, | |
| triangulate_ | |
| ); | |
| const_cast<thresholdCellFaces&> | |
| ( | |
| *this | |
| ).MeshedSurface<face>::transfer(surf); | |
| meshCells_.transfer(surf.meshCells()); | |
| // clear derived data | |
| sampledSurface::clearGeom(); | |
| if (debug) | |
| { | |
| Pout<< "thresholdCellFaces::updateGeometry() : constructed" | |
| << nl | |
| << " field : " << fieldName_ << nl | |
| << " lowerLimit : " << lowerThreshold_ << nl | |
| << " upperLimit : " << upperThreshold_ << nl | |
| << " point : " << points().size() << nl | |
| << " faces : " << faces().size() << nl | |
| << " cut cells : " << meshCells_.size() << endl; | |
| } | |
| return true; | |
| } | |
| // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // | |
| Foam::sampledSurfaces::thresholdCellFaces::thresholdCellFaces | |
| ( | |
| const word& name, | |
| const polyMesh& mesh, | |
| const dictionary& dict | |
| ) | |
| : | |
| sampledSurface(name, mesh, dict), | |
| fieldName_(dict.lookup("field")), | |
| lowerThreshold_(dict.lookupOrDefault<scalar>("lowerLimit", -vGreat)), | |
| upperThreshold_(dict.lookupOrDefault<scalar>("upperLimit", vGreat)), | |
| triangulate_(dict.lookupOrDefault("triangulate", false)), | |
| prevTimeIndex_(-1), | |
| meshCells_(0) | |
| { | |
| if (!dict.found("lowerLimit") && !dict.found("upperLimit")) | |
| { | |
| FatalErrorInFunction | |
| << "require at least one of 'lowerLimit' or 'upperLimit'" << endl | |
| << abort(FatalError); | |
| } | |
| } | |
| // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // | |
| Foam::sampledSurfaces::thresholdCellFaces::~thresholdCellFaces() | |
| {} | |
| // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // | |
| Foam::wordList Foam::sampledSurfaces::thresholdCellFaces::fields() const | |
| { | |
| return wordList(fieldName_); | |
| } | |
| bool Foam::sampledSurfaces::thresholdCellFaces::needsUpdate() const | |
| { | |
| const fvMesh& fvm = static_cast<const fvMesh&>(mesh()); | |
| return fvm.time().timeIndex() != prevTimeIndex_; | |
| } | |
| bool Foam::sampledSurfaces::thresholdCellFaces::update() | |
| { | |
| return updateGeometry(); | |
| } | |
| FOR_ALL_FIELD_TYPES(IMPLEMENT_SAMPLE); | |
| FOR_ALL_FIELD_TYPES(IMPLEMENT_INTERPOLATE); | |
| void Foam::sampledSurfaces::thresholdCellFaces::movePoints() | |
| { | |
| prevTimeIndex_ = -1; | |
| } | |
| void Foam::sampledSurfaces::thresholdCellFaces::topoChange | |
| ( | |
| const polyTopoChangeMap& | |
| ) | |
| { | |
| prevTimeIndex_ = -1; | |
| } | |
| void Foam::sampledSurfaces::thresholdCellFaces::mapMesh | |
| ( | |
| const polyMeshMap& map | |
| ) | |
| { | |
| prevTimeIndex_ = -1; | |
| } | |
| void Foam::sampledSurfaces::thresholdCellFaces::distribute | |
| ( | |
| const polyDistributionMap& map | |
| ) | |
| { | |
| prevTimeIndex_ = -1; | |
| } | |
| void Foam::sampledSurfaces::thresholdCellFaces::print(Ostream& os) const | |
| { | |
| os << "thresholdCellFaces: " << name() << " :" | |
| << " field:" << fieldName_ | |
| << " lowerLimit:" << lowerThreshold_ | |
| << " upperLimit:" << upperThreshold_; | |
| //<< " faces:" << faces().size() // possibly no geom yet | |
| //<< " points:" << points().size(); | |
| } | |
| // ************************************************************************* // | |