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

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