manualDecomp.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-2019 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 Description
25  Decomposition given a cell-to-processor association in a file
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "manualDecomp.H"
31 #include "IFstream.H"
32 #include "labelIOList.H"
33 
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38  defineTypeNameAndDebug(manualDecomp, 0);
39 
41  (
42  decompositionMethod,
43  manualDecomp,
44  dictionary
45  );
46 }
47 
48 
49 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
50 
52 :
53  decompositionMethod(decompositionDict),
54  decompDataFile_
55  (
56  decompositionDict.optionalSubDict
57  (
58  word(decompositionDict.lookup("method")) + "Coeffs"
59  ).lookup("dataFile")
60  )
61 {}
62 
63 
64 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
65 
67 (
68  const polyMesh& mesh,
69  const pointField& points,
70  const scalarField& pointWeights
71 )
72 {
73  labelIOList finalDecomp
74  (
75  IOobject
76  (
77  decompDataFile_,
78  mesh.facesInstance(),
79  mesh,
82  false
83  )
84  );
85 
86  // check if the final decomposition is OK
87 
88  if (finalDecomp.size() != points.size())
89  {
91  << "Size of decomposition list does not correspond "
92  << "to the number of points. Size: "
93  << finalDecomp.size() << " Number of points: "
94  << points.size()
95  << ".\n" << "Manual decomposition data read from file "
96  << decompDataFile_ << "." << endl
97  << exit(FatalError);
98  }
99 
100  if (min(finalDecomp) < 0 || max(finalDecomp) > nProcessors_ - 1)
101  {
103  << "According to the decomposition, cells assigned to "
104  << "impossible processor numbers. Min processor = "
105  << min(finalDecomp) << " Max processor = " << max(finalDecomp)
106  << ".\n" << "Manual decomposition data read from file "
107  << decompDataFile_ << "." << endl
108  << exit(FatalError);
109  }
110 
111  return move(finalDecomp);
112 }
113 
114 
115 // ************************************************************************* //
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
const fileName & facesInstance() const
Return the current instance directory for faces.
Definition: polyMesh.C:808
error FatalError
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:158
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:319
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
virtual labelList decompose(const polyMesh &mesh, const pointField &cc, const scalarField &cWeights)
Return for every coordinate the wanted processor number. Use the.
Definition: manualDecomp.C:67
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
manualDecomp(const dictionary &decompositionDict)
Construct given the decomposition dictionary.
Definition: manualDecomp.C:51
Macros for easy insertion into run-time selection tables.
stressControl lookup("compactNormalStress") >> compactNormalStress
dynamicFvMesh & mesh
A class for handling words, derived from string.
Definition: word.H:59
Abstract base class for decomposition.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:74
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:92
Namespace for OpenFOAM.