OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

manualDecomp.C

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Description
00026     Decomposition given a cell-to-processor association in a file
00027 
00028 \*---------------------------------------------------------------------------*/
00029 
00030 #include "manualDecomp.H"
00031 #include "addToRunTimeSelectionTable.H"
00032 #include "IFstream.H"
00033 #include "labelIOList.H"
00034 
00035 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00036 
00037 namespace Foam
00038 {
00039     defineTypeNameAndDebug(manualDecomp, 0);
00040 
00041     addToRunTimeSelectionTable
00042     (
00043         decompositionMethod,
00044         manualDecomp,
00045         dictionary
00046     );
00047 
00048     addToRunTimeSelectionTable
00049     (
00050         decompositionMethod,
00051         manualDecomp,
00052         dictionaryMesh
00053     );
00054 }
00055 
00056 
00057 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00058 
00059 Foam::manualDecomp::manualDecomp(const dictionary& decompositionDict)
00060 :
00061     decompositionMethod(decompositionDict)
00062 {
00063     notImplemented("manualDecomp(const dictionary&)");
00064 }
00065 
00066 
00067 Foam::manualDecomp::manualDecomp
00068 (
00069     const dictionary& decompositionDict, 
00070     const polyMesh& mesh
00071 )
00072 :
00073     decompositionMethod(decompositionDict),
00074     meshPtr_(&mesh),
00075     decompDataFile_
00076     (
00077         decompositionDict.subDict(word(decompositionDict.lookup("method"))
00078       + "Coeffs").lookup("dataFile")
00079     )
00080 {}
00081 
00082 
00083 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00084 
00085 Foam::labelList Foam::manualDecomp::decompose(const pointField& points)
00086 {
00087     const polyMesh& mesh = *meshPtr_;
00088 
00089     labelIOList finalDecomp
00090     (
00091         IOobject
00092         (
00093             decompDataFile_,
00094             mesh.facesInstance(),
00095             mesh,
00096             IOobject::MUST_READ,
00097             IOobject::AUTO_WRITE,
00098             false
00099         )
00100     );
00101 
00102     // check if the final decomposition is OK
00103 
00104     if (finalDecomp.size() != points.size())
00105     {
00106         FatalErrorIn("manualDecomp::decompose(const pointField&)")
00107             << "Size of decomposition list does not correspond "
00108             << "to the number of points.  Size: "
00109             << finalDecomp.size() << " Number of points: "
00110             << points.size()
00111             << ".\n" << "Manual decomposition data read from file "
00112             << decompDataFile_ << "." << endl
00113             << exit(FatalError);
00114     }
00115 
00116     if (min(finalDecomp) < 0 || max(finalDecomp) > nProcessors_ - 1)
00117     {
00118         FatalErrorIn("labelList manualDecomp::decompose(const pointField&)")
00119             << "According to the decomposition, cells assigned to "
00120             << "impossible processor numbers.  Min processor = "
00121             << min(finalDecomp) << " Max processor = " << max(finalDecomp)
00122             << ".\n" << "Manual decomposition data read from file "
00123             << decompDataFile_ << "." << endl
00124             << exit(FatalError);
00125     }
00126 
00127     return finalDecomp;
00128 }
00129 
00130 
00131 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd