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

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