FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Description
00025     Decomposition given a cell-to-processor association in a file
00026 
00027 \*---------------------------------------------------------------------------*/
00028 
00029 #include "manualDecomp.H"
00030 #include <OpenFOAM/addToRunTimeSelectionTable.H>
00031 #include <OpenFOAM/IFstream.H>
00032 #include <OpenFOAM/labelIOList.H>
00033 
00034 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00035 
00036 namespace Foam
00037 {
00038     defineTypeNameAndDebug(manualDecomp, 0);
00039 
00040     addToRunTimeSelectionTable
00041     (
00042         decompositionMethod,
00043         manualDecomp,
00044         dictionary
00045     );
00046 
00047     addToRunTimeSelectionTable
00048     (
00049         decompositionMethod,
00050         manualDecomp,
00051         dictionaryMesh
00052     );
00053 }
00054 
00055 
00056 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00057 
00058 Foam::manualDecomp::manualDecomp(const dictionary& decompositionDict)
00059 :
00060     decompositionMethod(decompositionDict)
00061 {
00062     notImplemented("manualDecomp(const dictionary&)");
00063 }
00064 
00065 
00066 Foam::manualDecomp::manualDecomp
00067 (
00068     const dictionary& decompositionDict,
00069     const polyMesh& mesh
00070 )
00071 :
00072     decompositionMethod(decompositionDict),
00073     meshPtr_(&mesh),
00074     decompDataFile_
00075     (
00076         decompositionDict.subDict(word(decompositionDict.lookup("method"))
00077       + "Coeffs").lookup("dataFile")
00078     )
00079 {}
00080 
00081 
00082 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
00083 
00084 Foam::labelList Foam::manualDecomp::decompose
00085 (
00086     const pointField& points,
00087     const scalarField& pointWeights
00088 )
00089 {
00090     const polyMesh& mesh = *meshPtr_;
00091 
00092     labelIOList finalDecomp
00093     (
00094         IOobject
00095         (
00096             decompDataFile_,
00097             mesh.facesInstance(),
00098             mesh,
00099             IOobject::MUST_READ,
00100             IOobject::AUTO_WRITE,
00101             false
00102         )
00103     );
00104 
00105     // check if the final decomposition is OK
00106 
00107     if (finalDecomp.size() != points.size())
00108     {
00109         FatalErrorIn
00110         (
00111             "manualDecomp::decompose(const pointField&, const scalarField&)"
00112         )   << "Size of decomposition list does not correspond "
00113             << "to the number of points.  Size: "
00114             << finalDecomp.size() << " Number of points: "
00115             << points.size()
00116             << ".\n" << "Manual decomposition data read from file "
00117             << decompDataFile_ << "." << endl
00118             << exit(FatalError);
00119     }
00120 
00121     if (min(finalDecomp) < 0 || max(finalDecomp) > nProcessors_ - 1)
00122     {
00123         FatalErrorIn
00124         (
00125             "manualDecomp::decompose(const pointField&, const scalarField&)"
00126         )   << "According to the decomposition, cells assigned to "
00127             << "impossible processor numbers.  Min processor = "
00128             << min(finalDecomp) << " Max processor = " << max(finalDecomp)
00129             << ".\n" << "Manual decomposition data read from file "
00130             << decompDataFile_ << "." << endl
00131             << exit(FatalError);
00132     }
00133 
00134     return finalDecomp;
00135 }
00136 
00137 
00138 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines