diff --git a/applications/utilities/preProcessing/mapFieldsPar/mapFieldsPar.C b/applications/utilities/preProcessing/mapFieldsPar/mapFieldsPar.C index 1d021b5280..194b08242c 100644 --- a/applications/utilities/preProcessing/mapFieldsPar/mapFieldsPar.C +++ b/applications/utilities/preProcessing/mapFieldsPar/mapFieldsPar.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation - \\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. + \\/ M anipulation | Copyright (C) 2015-2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -46,6 +46,7 @@ void mapConsistentMesh const fvMesh& meshTarget, const word& mapMethod, const word& AMIMapMethod, + const word& procMapMethod, const bool subtract, const wordHashSet& selectedFields, const bool noLagrangian @@ -54,7 +55,14 @@ void mapConsistentMesh Info<< nl << "Consistently creating and mapping fields for time " << meshSource.time().timeName() << nl << endl; - meshToMesh interp(meshSource, meshTarget, mapMethod, AMIMapMethod); + meshToMesh interp + ( + meshSource, + meshTarget, + mapMethod, + AMIMapMethod, + meshToMesh::procMapMethodNames_[procMapMethod] + ); if (subtract) { @@ -85,6 +93,7 @@ void mapSubMesh const wordList& cuttingPatches, const word& mapMethod, const word& AMIMapMethod, + const word& procMapMethod, const bool subtract, const wordHashSet& selectedFields, const bool noLagrangian @@ -100,7 +109,8 @@ void mapSubMesh mapMethod, AMIMapMethod, patchMap, - cuttingPatches + cuttingPatches, + meshToMesh::procMapMethodNames_[procMapMethod] ); if (subtract) @@ -171,6 +181,12 @@ int main(int argc, char *argv[]) "word", "specify the patch mapping method (direct|mapNearest|faceAreaWeight)" ); + argList::addOption + ( + "procMapMethod", + "word", + "specify the processor distribution map method (AABB|LOD)" + ); argList::addBoolOption ( "subtract", @@ -217,7 +233,7 @@ int main(int argc, char *argv[]) word mapMethod = meshToMesh::interpolationMethodNames_ [ - meshToMesh::imCellVolumeWeight + meshToMesh::interpolationMethod::imCellVolumeWeight ]; if (args.readIfPresent("mapMethod", mapMethod)) @@ -225,7 +241,6 @@ int main(int argc, char *argv[]) Info<< "Mapping method: " << mapMethod << endl; } - word patchMapMethod; if (meshToMesh::interpolationMethodNames_.found(mapMethod)) { @@ -233,12 +248,25 @@ int main(int argc, char *argv[]) meshToMesh::interpolationMethod method = meshToMesh::interpolationMethodNames_[mapMethod]; - patchMapMethod = AMIPatchToPatchInterpolation::interpolationMethodNames_ - [ - meshToMesh::interpolationMethodAMI(method) - ]; + patchMapMethod = + AMIPatchToPatchInterpolation::interpolationMethodNames_ + [ + meshToMesh::interpolationMethodAMI(method) + ]; } + word procMapMethod = + meshToMesh::procMapMethodNames_ + [ + meshToMesh::procMapMethod::pmAABB + ]; + + if (args.readIfPresent("procMapMethod", procMapMethod)) + { + Info<< "Processor map method: " << procMapMethod << endl; + } + + // Optionally override if (args.readIfPresent("patchMapMethod", patchMapMethod)) { @@ -325,6 +353,7 @@ int main(int argc, char *argv[]) meshTarget, mapMethod, patchMapMethod, + procMapMethod, subtract, selectedFields, noLagrangian @@ -340,12 +369,15 @@ int main(int argc, char *argv[]) cuttingPatches, mapMethod, patchMapMethod, + procMapMethod, subtract, selectedFields, noLagrangian ); } + runTimeSource.printExecutionTime(Info); + Info<< "\nEnd\n" << endl; return 0; diff --git a/src/fvOptions/interRegionOption/interRegionOption.C b/src/fvOptions/interRegionOption/interRegionOption.C index 32a3f88564..bf81ccf383 100644 --- a/src/fvOptions/interRegionOption/interRegionOption.C +++ b/src/fvOptions/interRegionOption/interRegionOption.C @@ -3,7 +3,7 @@ \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation - \\/ M anipulation | + \\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -65,10 +65,17 @@ void Foam::fv::interRegionOption::setMapper() ( mesh_, nbrMesh, - meshToMesh::interpolationMethodNames_.lookup + meshToMesh::interpolationMethodNames_.lookupOrDefault ( "interpolationMethod", - coeffs_ + coeffs_, + meshToMesh::interpolationMethod::imCellVolumeWeight + ), + meshToMesh::procMapMethodNames_.lookupOrDefault + ( + "procMapMethod", + coeffs_, + meshToMesh::procMapMethod::pmAABB ), false // not interpolating patches ) diff --git a/src/meshTools/Make/files b/src/meshTools/Make/files index 45f839d1a0..56dc286f3a 100644 --- a/src/meshTools/Make/files +++ b/src/meshTools/Make/files @@ -231,6 +231,11 @@ triSurface/triSurfaceTools/pointToPointPlanarInterpolation.C twoDPointCorrector/twoDPointCorrector.C +processorLOD/processorLOD/processorLOD.C +processorLOD/box/box.C +processorLOD/cellBox/cellBox.C +processorLOD/faceBox/faceBox.C + AMI=AMIInterpolation $(AMI)/AMIInterpolation/AMIInterpolationName.C $(AMI)/AMIInterpolation/AMIPatchToPatchInterpolation.C diff --git a/src/meshTools/processorLOD/box/box.C b/src/meshTools/processorLOD/box/box.C new file mode 100644 index 0000000000..f176ab0fd0 --- /dev/null +++ b/src/meshTools/processorLOD/box/box.C @@ -0,0 +1,635 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2017 OpenCFD Ltd. + \\/ 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 "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 time = 0; + + OFstream os + ( + "processor" + Foam::name(Pstream::myProcNo()) + + "_time" + Foam::name(time) + + "_iter" + Foam::name(iter) + ".obj" + ); + + label verti = 0; + for (label proci = 0; proci < Pstream::nProcs(); ++proci) + { + if (proci == Pstream::myProcNo()) + { + continue; + } + + const DynamicList& procBoxes = fixedBoxes[proci]; + forAll(procBoxes, boxi) + { + const treeBoundBox& bb = procBoxes[boxi]; + + // Write the points + const pointField pts(bb.points()); + for (const point& p : pts) + { + meshTools::writeOBJ(os, p); + } + + // Write the box faces + for (const face& f : bb.faces) + { + os << 'f'; + for (const label fpi : f) + { + os << ' ' << fpi + verti + 1; + } + os << nl; + } + verti += pts.size(); + } + } + + ++time; +} + + +void Foam::processorLODs::box::setRefineFlags +( + const label refineIter, + const label nTgtObjects, + List& fixedSendElems, + List>& localTgtElems, + List& refineFlags, + labelList& nElems +) const +{ + PstreamBuffers pBufs(Pstream::commsTypes::nonBlocking); + + // Identify src boxes that can be refined and send to all remote procs + for (label proci = 0; proci < Pstream::nProcs(); ++proci) + { + if (proci != Pstream::myProcNo()) + { + 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 (label proci = 0; proci < Pstream::nProcs(); ++proci) + { + if (proci == Pstream::myProcNo()) + { + // Not refining boxes I send to myself - will be sending all local + // elements + 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