Added support for compressible and multiphase momentum equations.
[OpenFOAM-1.5.x.git] / src / decompositionAgglomeration / decompositionMethods / manualDecomp / manualDecomp.C
blob9edc2006d8d5e8b8c8992864113d8fcbe12908dc
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2008 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
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 the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
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.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Description
26     Decomposition given a cell-to-processor association in a file
28 \*---------------------------------------------------------------------------*/
30 #include "manualDecomp.H"
31 #include "addToRunTimeSelectionTable.H"
32 #include "IFstream.H"
33 #include "labelIOList.H"
35 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 namespace Foam
39     defineTypeNameAndDebug(manualDecomp, 0);
41     addToRunTimeSelectionTable
42     (
43         decompositionMethod,
44         manualDecomp,
45         dictionary
46     );
48     addToRunTimeSelectionTable
49     (
50         decompositionMethod,
51         manualDecomp,
52         dictionaryMesh
53     );
57 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
59 Foam::manualDecomp::manualDecomp(const dictionary& decompositionDict)
61     decompositionMethod(decompositionDict)
63     notImplemented("manualDecomp(const dictionary&)");
67 Foam::manualDecomp::manualDecomp
69     const dictionary& decompositionDict, 
70     const polyMesh& mesh
73     decompositionMethod(decompositionDict),
74     meshPtr_(&mesh),
75     decompDataFile_
76     (
77         decompositionDict.subDict(word(decompositionDict.lookup("method"))
78       + "Coeffs").lookup("dataFile")
79     )
83 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
85 Foam::labelList Foam::manualDecomp::decompose(const pointField& points)
87     const polyMesh& mesh = *meshPtr_;
89     labelIOList finalDecomp
90     (
91         IOobject
92         (
93             decompDataFile_,
94             mesh.facesInstance(),
95             mesh,
96             IOobject::MUST_READ,
97             IOobject::AUTO_WRITE,
98             false
99         )
100     );
102     // check if the final decomposition is OK
104     if (finalDecomp.size() != points.size())
105     {
106         FatalErrorIn("manualDecomp::decompose(const pointField&)")
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             << decompDataFile_ << "." << endl
113             << exit(FatalError);
114     }
116     if (min(finalDecomp) < 0 || max(finalDecomp) > nProcessors_ - 1)
117     {
118         FatalErrorIn("labelList manualDecomp::decompose(const pointField&)")
119             << "According to the decomposition, cells assigned to "
120             << "impossible processor numbers.  Min processor = "
121             << min(finalDecomp) << " Max processor = " << max(finalDecomp)
122             << ".\n" << "Manual decomposition data read from file "
123             << decompDataFile_ << "." << endl
124             << exit(FatalError);
125     }
127     return finalDecomp;
131 // ************************************************************************* //