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

fvFieldDecomposer.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 "fvFieldDecomposer.H"
00028 
00029 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00030 
00031 namespace Foam
00032 {
00033 
00034 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
00035 
00036 fvFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
00037 (
00038     const unallocLabelList& addressingSlice,
00039     const label addressingOffset
00040 )
00041 :
00042     directAddressing_(addressingSlice)
00043 {
00044     forAll (directAddressing_, i)
00045     {
00046         // Subtract one to align addressing.  
00047         directAddressing_[i] -= addressingOffset + 1;
00048     }
00049 }
00050 
00051 
00052 fvFieldDecomposer::processorVolPatchFieldDecomposer::
00053 processorVolPatchFieldDecomposer
00054 (
00055     const fvMesh& mesh,
00056     const unallocLabelList& addressingSlice
00057 )
00058 :
00059     directAddressing_(addressingSlice.size())
00060 {
00061     const labelList& own = mesh.faceOwner();
00062     const labelList& neighb = mesh.faceNeighbour();
00063 
00064     forAll (directAddressing_, i)
00065     {
00066         // Subtract one to align addressing.  
00067         label ai = mag(addressingSlice[i]) - 1;
00068 
00069         if (ai < neighb.size())
00070         {
00071             // This is a regular face. it has been an internal face
00072             // of the original mesh and now it has become a face
00073             // on the parallel boundary.
00074             // Give face the value of the neighbour.
00075 
00076             if (addressingSlice[i] >= 0)
00077             {
00078                 // I have the owner so use the neighbour value
00079                 directAddressing_[i] = neighb[ai];
00080             }
00081             else
00082             {
00083                 directAddressing_[i] = own[ai];
00084             }
00085         }
00086         else
00087         {
00088             // This is a face that used to be on a cyclic boundary
00089             // but has now become a parallel patch face. I cannot
00090             // do the interpolation properly (I would need to look
00091             // up the different (face) list of data), so I will
00092             // just grab the value from the owner cell
00093 
00094             directAddressing_[i] = own[ai];
00095         }
00096     }
00097 }
00098 
00099 
00100 fvFieldDecomposer::processorSurfacePatchFieldDecomposer::
00101 processorSurfacePatchFieldDecomposer
00102 (
00103     const unallocLabelList& addressingSlice
00104 )
00105 :
00106     addressing_(addressingSlice.size()),
00107     weights_(addressingSlice.size())
00108 {
00109     forAll (addressing_, i)
00110     {
00111         addressing_[i].setSize(1);
00112         weights_[i].setSize(1);
00113 
00114         addressing_[i][0] = mag(addressingSlice[i]) - 1;
00115         weights_[i][0] = sign(addressingSlice[i]);
00116     }
00117 }
00118 
00119 
00120 fvFieldDecomposer::fvFieldDecomposer
00121 (
00122     const fvMesh& completeMesh,
00123     const fvMesh& procMesh,
00124     const labelList& faceAddressing,
00125     const labelList& cellAddressing,
00126     const labelList& boundaryAddressing
00127 )
00128 :
00129     completeMesh_(completeMesh),
00130     procMesh_(procMesh),
00131     faceAddressing_(faceAddressing),
00132     cellAddressing_(cellAddressing),
00133     boundaryAddressing_(boundaryAddressing),
00134     patchFieldDecomposerPtrs_
00135     (
00136         procMesh_.boundary().size(),
00137         static_cast<patchFieldDecomposer*>(NULL)
00138     ),
00139     processorVolPatchFieldDecomposerPtrs_
00140     (
00141         procMesh_.boundary().size(),
00142         static_cast<processorVolPatchFieldDecomposer*>(NULL)
00143     ),
00144     processorSurfacePatchFieldDecomposerPtrs_
00145     (
00146         procMesh_.boundary().size(),
00147         static_cast<processorSurfacePatchFieldDecomposer*>(NULL)
00148     )
00149 {
00150     forAll (boundaryAddressing_, patchi)
00151     {
00152         if (boundaryAddressing_[patchi] >= 0)
00153         {
00154             patchFieldDecomposerPtrs_[patchi] = new patchFieldDecomposer
00155             (
00156                 procMesh_.boundary()[patchi].patchSlice(faceAddressing_),
00157                 completeMesh_.boundaryMesh()
00158                 [
00159                     boundaryAddressing_[patchi]
00160                 ].start()
00161             );
00162         }
00163         else
00164         {
00165             processorVolPatchFieldDecomposerPtrs_[patchi] = 
00166                 new processorVolPatchFieldDecomposer
00167                 (
00168                     completeMesh_,
00169                     procMesh_.boundary()[patchi].patchSlice(faceAddressing_)
00170                 );
00171 
00172             processorSurfacePatchFieldDecomposerPtrs_[patchi] = 
00173                 new processorSurfacePatchFieldDecomposer
00174                 (
00175                     static_cast<const unallocLabelList&>
00176                     (
00177                         procMesh_.boundary()[patchi].patchSlice
00178                         (
00179                             faceAddressing_
00180                         )
00181                     )
00182                 );
00183         }
00184     }
00185 }
00186 
00187 
00188 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
00189 
00190 fvFieldDecomposer::~fvFieldDecomposer()
00191 {
00192     forAll (patchFieldDecomposerPtrs_, patchi)
00193     {
00194         if (patchFieldDecomposerPtrs_[patchi])
00195         {
00196             delete patchFieldDecomposerPtrs_[patchi];
00197         }
00198     }
00199 
00200     forAll (processorVolPatchFieldDecomposerPtrs_, patchi)
00201     {
00202         if (processorVolPatchFieldDecomposerPtrs_[patchi])
00203         {
00204             delete processorVolPatchFieldDecomposerPtrs_[patchi];
00205         }
00206     }
00207 
00208     forAll (processorSurfacePatchFieldDecomposerPtrs_, patchi)
00209     {
00210         if (processorSurfacePatchFieldDecomposerPtrs_[patchi])
00211         {
00212             delete processorSurfacePatchFieldDecomposerPtrs_[patchi];
00213         }
00214     }
00215 }
00216 
00217 
00218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00219 
00220 } // End namespace Foam
00221 
00222 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd