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-2018 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 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  defineTypeNameAndDebug(manualDecomp, 0);
38 
40  (
41  decompositionMethod,
42  manualDecomp,
43  dictionary
44  );
45 
47  (
48  decompositionMethod,
49  manualDecomp,
50  dictionaryRegion
51  );
52 }
53 
54 
55 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
56 
57 Foam::manualDecomp::manualDecomp(const dictionary& decompDict)
58 :
59  decompositionMethod(decompDict),
60  dataFile_
61  (
62  findCoeffsDict(typeName + "Coeffs").get<fileName>("dataFile")
63  )
64 {}
65 
66 
67 Foam::manualDecomp::manualDecomp
68 (
69  const dictionary& decompDict,
70  const word& regionName
71 )
72 :
73  decompositionMethod(decompDict, regionName),
74  dataFile_
75  (
76  findCoeffsDict(typeName + "Coeffs").get<fileName>("dataFile")
77  )
78 {}
79 
80 
81 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
82 
84 (
85  const polyMesh& mesh,
86  const pointField& points,
87  const scalarField& pointWeights
88 ) const
89 {
90  labelIOList finalDecomp
91  (
92  IOobject
93  (
94  dataFile_,
96  mesh,
99  false
100  )
101  );
102 
103  // Check if the final decomposition is OK
104  if (finalDecomp.size() != points.size())
105  {
107  << "Size of decomposition list does not correspond "
108  << "to the number of points. Size: "
109  << finalDecomp.size() << " Number of points: "
110  << points.size()
111  << ".\n" << "Manual decomposition data read from file "
112  << dataFile_ << "." << endl
113  << exit(FatalError);
114  }
115 
116  const label minVal = min(finalDecomp);
117  const label maxVal = max(finalDecomp);
118 
119  if (minVal < 0 || maxVal >= nDomains_)
120  {
122  << "According to the decomposition, cells assigned to "
123  << "impossible processor numbers. Min processor = "
124  << minVal << " Max processor = " << maxVal
125  << ".\n" << "Manual decomposition data read from file "
126  << dataFile_ << "." << endl
127  << exit(FatalError);
128  }
129 
130  return std::move(finalDecomp);
131 }
132 
133 
134 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::IOobject::AUTO_WRITE
Definition: IOobject.H:129
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::polyMesh::facesInstance
const fileName & facesInstance() const
Return the current instance directory for faces.
Definition: polyMesh.C:852
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:350
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
manualDecomp.H
Foam::polyMesh
Mesh consisting of general polyhedral cells.
Definition: polyMesh.H:77
regionName
Foam::word regionName
Definition: createNamedDynamicFvMesh.H:1
Foam::Field< vector >
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
Foam::manualDecomp::decompose
virtual labelList decompose(const polyMesh &mesh, const pointField &cc, const scalarField &cWeights) const
Return for every coordinate the wanted processor number.
Definition: manualDecomp.C:84
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::decompositionMethod
Abstract base class for domain decomposition.
Definition: decompositionMethod.H:51
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:381
Foam::List< label >
labelIOList.H
points
const pointField & points
Definition: gmvOutputHeader.H:1
Foam::IOList< label >
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::IOobject::MUST_READ
Definition: IOobject.H:120