manual.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2024 OpenFOAM Foundation
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 \*---------------------------------------------------------------------------*/
25 
26 #include "manual.H"
28 #include "IFstream.H"
29 #include "labelIOList.H"
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35 namespace decompositionMethods
36 {
38 
40  (
42  manual,
43  decomposer
44  );
45 
47  (
49  manual,
50  distributor
51  );
52 }
53 }
54 
55 
56 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
57 
59 (
60  const dictionary& decompositionDict,
61  const dictionary& methodDict
62 )
63 :
64  decompositionMethod(decompositionDict),
65  decompDataFile_(methodDict.lookup("dataFile"))
66 {}
67 
68 
69 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
70 
72 (
73  const polyMesh& mesh,
74  const pointField& points,
75  const scalarField& pointWeights
76 )
77 {
78  labelIOList finalDecomp
79  (
80  IOobject
81  (
82  decompDataFile_,
84  mesh,
87  false
88  )
89  );
90 
91  // check if the final decomposition is OK
92 
93  if (finalDecomp.size() != points.size())
94  {
96  << "Size of decomposition list does not correspond "
97  << "to the number of points. Size: "
98  << finalDecomp.size() << " Number of points: "
99  << points.size()
100  << ".\n" << "Manual decomposition data read from file "
101  << decompDataFile_ << "." << endl
102  << exit(FatalError);
103  }
104 
105  if (min(finalDecomp) < 0 || max(finalDecomp) > nProcessors_ - 1)
106  {
108  << "According to the decomposition, cells assigned to "
109  << "impossible processor numbers. Min processor = "
110  << min(finalDecomp) << " Max processor = " << max(finalDecomp)
111  << ".\n" << "Manual decomposition data read from file "
112  << decompDataFile_ << "." << endl
113  << exit(FatalError);
114  }
115 
116  return finalDecomp;
117 }
118 
119 
120 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
Abstract base class for decomposition.
Decomposition given a cell-to-processor association in a file.
Definition: manual.H:51
virtual labelList decompose(const polyMesh &mesh, const pointField &cellCentres, const scalarField &cellWeights)
Return for every coordinate the wanted processor number. Use the.
Definition: manual.C:72
manual(const dictionary &decompositionDict, const dictionary &methodDict)
Construct given the decomposition dictionary.
Definition: manual.C:59
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
Definition: dictionary.H:162
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:80
const fileName & facesInstance() const
Return the current instance directory for faces.
Definition: polyMesh.C:994
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
const pointField & points
addToRunTimeSelectionTable(decompositionMethod, metis, decomposer)
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:258
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
error FatalError