1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software: you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
29 Agglomerate boundary faces using the pairPatchAgglomeration algorithm.
30 It writes a map from the fine to coarse grid.
32 \*---------------------------------------------------------------------------*/
37 #include "volFields.H"
38 #include "CompactListList.H"
39 #include "unitConversion.H"
40 #include "pairPatchAgglomeration.H"
41 #include "labelListIOList.H"
42 #include "syncTools.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 int main(int argc, char *argv[])
50 #include "addRegionOption.H"
55 "name of dictionary to provide patch agglomeration controls"
57 #include "setRootCase.H"
58 #include "createTime.H"
59 #include "createNamedMesh.H"
63 args.optionLookupOrDefault<word>("dict", "faceAgglomerateDict")
66 const polyBoundaryMesh& patches = mesh.boundaryMesh();
68 labelListIOList finalAgglom
83 // Read control dictionary
84 IOdictionary agglomDict
96 bool writeAgglom = readBool(agglomDict.lookup("writeFacesAgglomeration"));
98 const polyBoundaryMesh& boundary = mesh.boundaryMesh();
100 forAll(boundary, patchId)
102 const polyPatch& pp = boundary[patchId];
104 label patchI = pp.index();
105 finalAgglom[patchI].setSize(pp.size(), 0);
109 if (agglomDict.found(pp.name()))
111 Info << "\nAgglomerating patch : " << pp.name() << endl;
112 pairPatchAgglomeration agglomObject
115 agglomDict.subDict(pp.name())
118 agglomObject.agglomerate();
120 finalAgglom[patchI] =
121 agglomObject.restrictTopBottomAddressing();
126 FatalErrorIn(args.executable())
127 << "Patch " << pp.name() << " not found in dictionary: "
128 << agglomDict.name() << exit(FatalError);
133 // Sync agglomeration across coupled patches
134 labelList nbrAgglom(mesh.nFaces() - mesh.nInternalFaces(), -1);
136 forAll(boundary, patchId)
138 const polyPatch& pp = boundary[patchId];
141 finalAgglom[patchId] = identity(pp.size());
144 nbrAgglom[pp.start() - mesh.nInternalFaces() + i] =
145 finalAgglom[patchId][i];
150 syncTools::swapBoundaryFaceList(mesh, nbrAgglom);
151 forAll(boundary, patchId)
153 const polyPatch& pp = boundary[patchId];
154 if (pp.coupled() && !refCast<const coupledPolyPatch>(pp).owner())
158 finalAgglom[patchId][i] =
159 nbrAgglom[pp.start() - mesh.nInternalFaces() + i];
168 volScalarField facesAgglomeration
172 "facesAgglomeration",
173 mesh.time().timeName(),
179 dimensionedScalar("facesAgglomeration", dimless, 0)
182 forAll(boundary, patchId)
185 fvPatchScalarField& bFacesAgglomeration =
186 facesAgglomeration.boundaryField()[patchId];
188 forAll(bFacesAgglomeration, j)
190 bFacesAgglomeration[j] = finalAgglom[patchId][j];
194 Info << "\nWriting facesAgglomeration" << endl;
195 facesAgglomeration.write();
198 Info<< "End\n" << endl;
203 // ************************************************************************* //