/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2017-2023 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 "box.H" #include "mapDistribute.H" #include "OFstream.H" #include "meshTools.H" const Foam::label Foam::processorLODs::box::DROP = 0; const Foam::label Foam::processorLODs::box::REFINE = 1; const Foam::label Foam::processorLODs::box::FIXED = 2; const Foam::label Foam::processorLODs::box::nStartUpIter = 2; namespace Foam { namespace processorLODs { defineTypeNameAndDebug(box, 0); } } // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // void Foam::processorLODs::box::writeBoxes ( const List>& fixedBoxes, const label iter ) const { static label timeIndex = 0; OFstream os ( "processor" + Foam::name(Pstream::myProcNo()) + "_time" + Foam::name(timeIndex) + "_iter" + Foam::name(iter) + ".obj" ); ++timeIndex; label verti = 0; for (const int proci : UPstream::allProcs()) { if (proci == UPstream::myProcNo()) { continue; } for (const treeBoundBox& bb : fixedBoxes[proci]) { // Write the points const pointField pts(bb.points()); meshTools::writeOBJ(os, pts); // Write the box faces for (const face& f : treeBoundBox::faces) { os << 'f'; for (const label fpi : f) { os << ' ' << fpi + verti + 1; } os << nl; } verti += pts.size(); } } } void Foam::processorLODs::box::setRefineFlags ( const label refineIter, const label nTgtObjects, List& fixedSendElems, List>& localTgtElems, List& refineFlags, labelList& nElems ) const { PstreamBuffers pBufs; // Identify src boxes that can be refined and send to all remote procs for (const int proci : Pstream::allProcs()) { if (proci != Pstream::myProcNo() && !boxes_[proci].empty()) { UOPstream toProc(proci, pBufs); toProc << nObjectsOfType_ << boxes_[proci] << newToOld_[proci]; } } pBufs.finishedSends(); // Test each remote src bb with local tgt objects to identify which remote // src boxes can/should be refined for (const int proci : Pstream::allProcs()) { if (proci == Pstream::myProcNo() || !pBufs.recvDataCount(proci)) { continue; } // Receive the subset of changing src bound boxes for proci UIPstream fromProc(proci, pBufs); const label nObjects = readLabel(fromProc); List remoteSrcBoxes(fromProc); const List