Loading...
Searching...
No Matches
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-2023 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
35namespace Foam
36{
39 (
43 );
44}
45
46
47// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48
50(
51 const dictionary& decompDict,
52 const word& regionName
53)
54:
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 labelList finalDecomp
73 (
75 (
77 (
78 dataFile_,
79 mesh.facesInstance(),
80 mesh.thisDb(),
84 )
85 )
86 );
87
88 // Check if the final decomposition is OK
89 if (finalDecomp.size() != points.size())
90 {
92 << "Size of decomposition list does not correspond "
93 << "to the number of points. Size: "
94 << finalDecomp.size() << " Number of points: "
95 << points.size()
96 << ".\n" << "Manual decomposition data read from file "
97 << dataFile_ << "." << endl
98 << exit(FatalError);
99 }
100
101
102 const MinMax<label> range = minMax(finalDecomp);
103
104 if (range.min() < 0 || range.max() >= nDomains_)
105 {
107 << "According to the decomposition, cells assigned to "
108 << "impossible processor numbers. Min processor = "
109 << range.min() << " Max processor = " << range.max()
110 << ".\n" << "Manual decomposition data read from file "
111 << dataFile_ << "." << endl
112 << exit(FatalError);
113 }
114
115 return finalDecomp;
116}
117
118
119// ************************************************************************* //
scalar range
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
static List< label > readContents(const IOobject &io)
@ NO_REGISTER
Do not request registration (bool: false).
@ MUST_READ
Reading required.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
A min/max value pair with additional methods. In addition to conveniently storing values,...
Definition MinMax.H:106
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
Abstract base class for domain decomposition.
label nDomains_
Number of domains for the decomposition.
decompositionMethod(const label numDomains)
Construct with specified number of domains, no coefficients or constraints.
static FOAM_NO_DANGLING_REFERENCE const dictionary & findCoeffsDict(const dictionary &dict, const word &coeffsName, int select=selectionType::DEFAULT)
Locate coeffsName dictionary or the fallback "coeffs" dictionary within an enclosing dictionary.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
A class for handling file names.
Definition fileName.H:75
Decompose based on cell-to-processor association in a file.
manualDecomp(const manualDecomp &)=delete
No copy construct.
virtual labelList decompose(const polyMesh &mesh, const pointField &cc, const scalarField &cWeights=scalarField::null()) const
Return for every coordinate the wanted processor number.
Mesh consisting of general polyhedral cells.
Definition polyMesh.H:79
A class for handling words, derived from Foam::string.
Definition word.H:66
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
dynamicFvMesh & mesh
Foam::word regionName(args.getOrDefault< word >("region", Foam::polyMesh::defaultRegion))
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
const pointField & points
Namespace for OpenFOAM.
List< label > labelList
A List of labels.
Definition List.H:62
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
MinMax< label > minMax(const labelHashSet &set)
Find the min/max values of labelHashSet.
Definition hashSets.C:54
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
vectorField pointField
pointField is a vectorField.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125