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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2017-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "manualDecomp.H"
30 #include "labelIOList.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  defineTypeNameAndDebug(manualDecomp, 0);
39  (
40  decompositionMethod,
41  manualDecomp,
42  dictionary
43  );
44 }
45 
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
49 Foam::manualDecomp::manualDecomp
50 (
51  const dictionary& decompDict,
52  const word& regionName
53 )
54 :
55  decompositionMethod(decompDict, regionName),
56  dataFile_
57  (
58  findCoeffsDict(typeName + "Coeffs").get<fileName>("dataFile")
59  )
60 {}
61 
62 
63 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
64 
66 (
67  const polyMesh& mesh,
68  const pointField& points,
69  const scalarField& pointWeights
70 ) const
71 {
72  labelIOList finalDecomp
73  (
74  IOobject
75  (
76  dataFile_,
78  mesh,
81  false
82  )
83  );
84 
85  // Check if the final decomposition is OK
86  if (finalDecomp.size() != points.size())
87  {
89  << "Size of decomposition list does not correspond "
90  << "to the number of points. Size: "
91  << finalDecomp.size() << " Number of points: "
92  << points.size()
93  << ".\n" << "Manual decomposition data read from file "
94  << dataFile_ << "." << endl
95  << exit(FatalError);
96  }
97 
98  const label minVal = min(finalDecomp);
99  const label maxVal = max(finalDecomp);
100 
101  if (minVal < 0 || maxVal >= nDomains_)
102  {
104  << "According to the decomposition, cells assigned to "
105  << "impossible processor numbers. Min processor = "
106  << minVal << " Max processor = " << maxVal
107  << ".\n" << "Manual decomposition data read from file "
108  << dataFile_ << "." << endl
109  << exit(FatalError);
110  }
111 
112  return std::move(finalDecomp);
113 }
114 
115 
116 // ************************************************************************* //
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:118
A class for handling file names.
Definition: fileName.H:71
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
const fileName & facesInstance() const
Return the current instance directory for faces.
Definition: polyMesh.C:853
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:120
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:578
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:40
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:487
Macros for easy insertion into run-time selection tables.
Foam::word regionName(Foam::polyMesh::defaultRegion)
dynamicFvMesh & mesh
const pointField & points
A class for handling words, derived from Foam::string.
Definition: word.H:63
Abstract base class for domain decomposition.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:26
defineTypeNameAndDebug(combustionModel, 0)
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Automatically write from objectRegistry::writeObject()
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:73
virtual labelList decompose(const polyMesh &mesh, const pointField &cc, const scalarField &cWeights) const
Return for every coordinate the wanted processor number.
Definition: manualDecomp.C:59
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:166
Namespace for OpenFOAM.