FreeFOAM The Cross-Platform CFD Toolkit
manualDecomp.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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.
15 
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
19  for more details.
20 
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/>.
23 
24 Description
25  Decomposition given a cell-to-processor association in a file
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "manualDecomp.H"
31 #include <OpenFOAM/IFstream.H>
32 #include <OpenFOAM/labelIOList.H>
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38  defineTypeNameAndDebug(manualDecomp, 0);
39 
41  (
42  decompositionMethod,
43  manualDecomp,
44  dictionary
45  );
46 
48  (
49  decompositionMethod,
50  manualDecomp,
51  dictionaryMesh
52  );
53 }
54 
55 
56 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
57 
58 Foam::manualDecomp::manualDecomp(const dictionary& decompositionDict)
59 :
60  decompositionMethod(decompositionDict)
61 {
62  notImplemented("manualDecomp(const dictionary&)");
63 }
64 
65 
66 Foam::manualDecomp::manualDecomp
67 (
68  const dictionary& decompositionDict,
69  const polyMesh& mesh
70 )
71 :
72  decompositionMethod(decompositionDict),
73  meshPtr_(&mesh),
74  decompDataFile_
75  (
76  decompositionDict.subDict(word(decompositionDict.lookup("method"))
77  + "Coeffs").lookup("dataFile")
78  )
79 {}
80 
81 
82 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
83 
85 (
86  const pointField& points,
87  const scalarField& pointWeights
88 )
89 {
90  const polyMesh& mesh = *meshPtr_;
91 
92  labelIOList finalDecomp
93  (
94  IOobject
95  (
96  decompDataFile_,
97  mesh.facesInstance(),
98  mesh,
101  false
102  )
103  );
104 
105  // check if the final decomposition is OK
106 
107  if (finalDecomp.size() != points.size())
108  {
110  (
111  "manualDecomp::decompose(const pointField&, const scalarField&)"
112  ) << "Size of decomposition list does not correspond "
113  << "to the number of points. Size: "
114  << finalDecomp.size() << " Number of points: "
115  << points.size()
116  << ".\n" << "Manual decomposition data read from file "
117  << decompDataFile_ << "." << endl
118  << exit(FatalError);
119  }
120 
121  if (min(finalDecomp) < 0 || max(finalDecomp) > nProcessors_ - 1)
122  {
124  (
125  "manualDecomp::decompose(const pointField&, const scalarField&)"
126  ) << "According to the decomposition, cells assigned to "
127  << "impossible processor numbers. Min processor = "
128  << min(finalDecomp) << " Max processor = " << max(finalDecomp)
129  << ".\n" << "Manual decomposition data read from file "
130  << decompDataFile_ << "." << endl
131  << exit(FatalError);
132  }
133 
134  return finalDecomp;
135 }
136 
137 
138 // ************************ vim: set sw=4 sts=4 et: ************************ //