/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2013-2016 OpenFOAM Foundation Copyright (C) 2017-2022,2024 OpenCFD Ltd. ------------------------------------------------------------------------------- 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 "cyclicACMIPolyPatch.H" #include "SubField.H" #include "Time.H" #include "addToRunTimeSelectionTable.H" #include "primitiveMeshTools.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // namespace Foam { defineTypeNameAndDebug(cyclicACMIPolyPatch, 0); addToRunTimeSelectionTable(polyPatch, cyclicACMIPolyPatch, word); addToRunTimeSelectionTable(polyPatch, cyclicACMIPolyPatch, dictionary); } // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // bool Foam::cyclicACMIPolyPatch::updateAreas() const { const polyMesh& mesh = boundaryMesh().mesh(); bool updated = false; if (!owner()) { return updated; } // Check if underlying AMI up to date if (!mesh.upToDatePoints(AMITime_)) { // This should not happen normally since resetAMI is triggered // by any point motion. FatalErrorInFunction << "Problem : AMI is up to event:" << AMITime_.eventNo() << " mesh points are up to time " << mesh.pointsInstance() << " patch:" << this->name() << exit(FatalError); } // Check if scaling enabled (and necessary) if ( srcScalePtr_ && (updated || prevTimeIndex_ != mesh.time().timeIndex()) ) { if (debug) { Pout<< "cyclicACMIPolyPatch::updateAreas() :" << " patch:" << this->name() << " neighbPatch:" << this->neighbPatch().name() << " AMITime_:" << AMITime_.eventNo() << " uptodate:" << mesh.upToDatePoints(AMITime_) << " mesh.time().timeIndex():" << mesh.time().timeIndex() << " prevTimeIndex_:" << prevTimeIndex_ << endl; } if (createAMIFaces_) { WarningInFunction << "Topology changes and scaling currently not supported." << " Patch " << this->name() << endl; } const scalar t = mesh.time().timeOutputValue(); // Note: ideally preserve src/tgtMask before clipping to tolerance ... srcScaledMask_ = min ( scalar(1) - tolerance_, max(tolerance_, srcScalePtr_->value(t)*srcMask_) ); if (!tgtScalePtr_) { tgtScalePtr_= srcScalePtr_.clone(neighbPatch()); } tgtScaledMask_ = min ( scalar(1) - tolerance_, max(tolerance_, tgtScalePtr_->value(t)*tgtMask_) ); if (debug) { Pout<< "cyclicACMIPolyPatch::updateAreas : scaling masks" << " for " << name() << " mask " << gAverage(srcScaledMask_) << " and " << nonOverlapPatch().name() << " mask " << gAverage(srcScaledMask_) << endl; } // Calculate areas from the masks cyclicACMIPolyPatch& cpp = const_cast(*this); const cyclicACMIPolyPatch& nbrCpp = neighbPatch(); cpp.scalePatchFaceAreas(*this, srcScaledMask_, thisSf_, thisNoSf_); cpp.scalePatchFaceAreas(nbrCpp, tgtScaledMask_, nbrSf_, nbrNoSf_); prevTimeIndex_ = mesh.time().timeIndex(); AMITime_.setUpToDate(); updated = true; } return updated; } bool Foam::cyclicACMIPolyPatch::upToDate(const regIOobject& io) const { // Is io up to date with // - underlying AMI // - scaling return io.upToDate(AMITime_); } void Foam::cyclicACMIPolyPatch::setUpToDate(regIOobject& io) const { io.setUpToDate(); } void Foam::cyclicACMIPolyPatch::reportCoverage ( const word& name, const scalarField& weightSum ) const { label nUncovered = 0; label nCovered = 0; for (const scalar sum : weightSum) { if (sum < tolerance_) { ++nUncovered; } else if (sum > scalar(1) - tolerance_) { ++nCovered; } } reduce(nUncovered, sumOp