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

pointFieldDecomposer.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 \*---------------------------------------------------------------------------*/
00025 
00026 #include "pointFieldDecomposer.H"
00027 
00028 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00029 
00030 namespace Foam
00031 {
00032 
00033 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00034     
00035 pointFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
00036 (
00037     const pointPatch& completeMeshPatch,
00038     const pointPatch& procMeshPatch,
00039     const labelList& directAddr
00040 )
00041 :
00042     pointPatchFieldMapperPatchRef
00043     (
00044         completeMeshPatch,
00045         procMeshPatch
00046     ),
00047     directAddressing_(procMeshPatch.size(), -1)
00048 {
00049     // Create the inverse-addressing of the patch point labels.
00050     labelList pointMap(completeMeshPatch.boundaryMesh().mesh().size(), -1);
00051 
00052     const labelList& completeMeshPatchPoints = completeMeshPatch.meshPoints();
00053 
00054     forAll (completeMeshPatchPoints, pointi)
00055     {
00056         pointMap[completeMeshPatchPoints[pointi]] = pointi;
00057     }
00058 
00059     // Use the inverse point addressing to create the addressing table for this
00060     // patch
00061     const labelList& procMeshPatchPoints = procMeshPatch.meshPoints();
00062 
00063     forAll (procMeshPatchPoints, pointi)
00064     {
00065         directAddressing_[pointi] =
00066             pointMap[directAddr[procMeshPatchPoints[pointi]]];
00067     }
00068 
00069     // Check that all the patch point addresses are set
00070     if (directAddressing_.size() && min(directAddressing_) < 0)
00071     {
00072         FatalErrorIn
00073         (
00074             "pointFieldDecomposer::patchFieldDecomposer()"
00075         )   << "Incomplete patch point addressing"
00076             << abort(FatalError);
00077     }
00078 }
00079 
00080 
00081 pointFieldDecomposer::pointFieldDecomposer
00082 (
00083     const pointMesh& completeMesh,
00084     const pointMesh& procMesh,
00085     const labelList& pointAddressing,
00086     const labelList& boundaryAddressing
00087 )
00088 :
00089     completeMesh_(completeMesh),
00090     procMesh_(procMesh),
00091     pointAddressing_(pointAddressing),
00092     boundaryAddressing_(boundaryAddressing),
00093     patchFieldDecomposerPtrs_
00094     (
00095         procMesh_.boundary().size(),
00096         static_cast<patchFieldDecomposer*>(NULL)
00097     )
00098 {
00099     forAll (boundaryAddressing_, patchi)
00100     {
00101         if (boundaryAddressing_[patchi] >= 0)
00102         {
00103             patchFieldDecomposerPtrs_[patchi] = new patchFieldDecomposer
00104             (
00105                 completeMesh_.boundary()[boundaryAddressing_[patchi]],
00106                 procMesh_.boundary()[patchi],
00107                 pointAddressing_
00108             );
00109         }
00110     }
00111 }
00112 
00113 
00114 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00115 
00116 pointFieldDecomposer::~pointFieldDecomposer()
00117 {
00118     forAll (patchFieldDecomposerPtrs_, patchi)
00119     {
00120         if (patchFieldDecomposerPtrs_[patchi])
00121         {
00122             delete patchFieldDecomposerPtrs_[patchi];
00123         }
00124     }
00125 }
00126 
00127 
00128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00129 
00130 } // End namespace Foam
00131 
00132 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines