/*---------------------------------------------------------------------------*\ ========= | \\ / 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. ------------------------------------------------------------------------------- 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 . InClass decompositionMethod \*---------------------------------------------------------------------------*/ #include "decompositionMethod.H" #include "globalIndex.H" #include "syncTools.H" #include "Tuple2.H" #include "faceSet.H" #include "regionSplit.H" #include "localPointRegion.H" #include "minData.H" #include "FaceCellWave.H" #include "preserveBafflesConstraint.H" #include "preservePatchesConstraint.H" #include "preserveFaceZonesConstraint.H" #include "singleProcessorFaceSetsConstraint.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // namespace Foam { defineTypeNameAndDebug(decompositionMethod, 0); defineRunTimeSelectionTable(decompositionMethod, dictionary); } // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::decompositionMethod::decompositionMethod ( const dictionary& decompositionDict ) : decompositionDict_(decompositionDict), nProcessors_ ( readLabel(decompositionDict.lookup("numberOfSubdomains")) ) { // Read any constraints wordList constraintTypes_; if (decompositionDict_.found("constraints")) { //PtrList constraintsList //( // decompositionDict_.lookup("constraints") //); //forAll(constraintsList, i) //{ // const dictionary& dict = constraintsList[i]; const dictionary& constraintsList = decompositionDict_.subDict ( "constraints" ); forAllConstIter(dictionary, constraintsList, iter) { const dictionary& dict = iter().dict(); constraintTypes_.append(dict.lookup("type")); constraints_.append ( decompositionConstraint::New ( dict, constraintTypes_.last() ) ); } } // Backwards compatibility if ( decompositionDict_.found("preserveBaffles") && findIndex ( constraintTypes_, decompositionConstraints::preserveBafflesConstraint::typeName ) == -1 ) { constraints_.append ( new decompositionConstraints::preserveBafflesConstraint() ); } if ( decompositionDict_.found("preservePatches") && findIndex ( constraintTypes_, decompositionConstraints::preservePatchesConstraint::typeName ) == -1 ) { const wordReList pNames(decompositionDict_.lookup("preservePatches")); constraints_.append ( new decompositionConstraints::preservePatchesConstraint(pNames) ); } if ( decompositionDict_.found("preserveFaceZones") && findIndex ( constraintTypes_, decompositionConstraints::preserveFaceZonesConstraint::typeName ) == -1 ) { const wordReList zNames(decompositionDict_.lookup("preserveFaceZones")); constraints_.append ( new decompositionConstraints::preserveFaceZonesConstraint(zNames) ); } if ( decompositionDict_.found("singleProcessorFaceSets") && findIndex ( constraintTypes_, decompositionConstraints::preserveFaceZonesConstraint::typeName ) == -1 ) { const List> zNameAndProcs ( decompositionDict_.lookup("singleProcessorFaceSets") ); constraints_.append ( new decompositionConstraints::singleProcessorFaceSetsConstraint ( zNameAndProcs ) ); } } // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // Foam::autoPtr Foam::decompositionMethod::New ( const dictionary& decompositionDict ) { word methodType(decompositionDict.lookup("method")); Info<< "Selecting decompositionMethod " << methodType << endl; dictionaryConstructorTable::iterator cstrIter = dictionaryConstructorTablePtr_->find(methodType); if (!cstrIter.found()) { FatalErrorInFunction << "Unknown decompositionMethod " << methodType << nl << nl << "Valid decompositionMethods are : " << endl << dictionaryConstructorTablePtr_->sortedToc() << exit(FatalError); } return autoPtr(cstrIter()(decompositionDict)); } Foam::labelList Foam::decompositionMethod::decompose ( const polyMesh& mesh, const pointField& points ) { scalarField weights(points.size(), 1.0); return decompose(mesh, points, weights); } Foam::labelList Foam::decompositionMethod::decompose ( const polyMesh& mesh, const labelList& fineToCoarse, const pointField& coarsePoints, const scalarField& coarseWeights ) { CompactListList