1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
11 OpenFOAM is free software; you can redistribute it and/or modify it
12 under the terms of the GNU General Public License as published by the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
16 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 \*---------------------------------------------------------------------------*/
27 #include "fvFieldDecomposer.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
36 fvFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
38 const unallocLabelList& addressingSlice,
39 const label addressingOffset
42 directAddressing_(addressingSlice)
44 forAll (directAddressing_, i)
46 // Subtract one to align addressing.
47 directAddressing_[i] -= addressingOffset + 1;
52 fvFieldDecomposer::processorVolPatchFieldDecomposer::
53 processorVolPatchFieldDecomposer
56 const unallocLabelList& addressingSlice
59 directAddressing_(addressingSlice.size())
61 const labelList& own = mesh.faceOwner();
62 const labelList& neighb = mesh.faceNeighbour();
64 forAll (directAddressing_, i)
66 // Subtract one to align addressing.
67 label ai = mag(addressingSlice[i]) - 1;
69 if (ai < neighb.size())
71 // This is a regular face. it has been an internal face
72 // of the original mesh and now it has become a face
73 // on the parallel boundary.
74 // Give face the value of the neighbour.
76 if (addressingSlice[i] >= 0)
78 // I have the owner so use the neighbour value
79 directAddressing_[i] = neighb[ai];
83 directAddressing_[i] = own[ai];
88 // This is a face that used to be on a cyclic boundary
89 // but has now become a parallel patch face. I cannot
90 // do the interpolation properly (I would need to look
91 // up the different (face) list of data), so I will
92 // just grab the value from the owner cell
94 directAddressing_[i] = own[ai];
100 fvFieldDecomposer::processorSurfacePatchFieldDecomposer::
101 processorSurfacePatchFieldDecomposer
103 const unallocLabelList& addressingSlice
106 addressing_(addressingSlice.size()),
107 weights_(addressingSlice.size())
109 forAll (addressing_, i)
111 addressing_[i].setSize(1);
112 weights_[i].setSize(1);
114 addressing_[i][0] = mag(addressingSlice[i]) - 1;
115 weights_[i][0] = sign(addressingSlice[i]);
120 fvFieldDecomposer::fvFieldDecomposer
122 const fvMesh& completeMesh,
123 const fvMesh& procMesh,
124 const labelList& faceAddressing,
125 const labelList& cellAddressing,
126 const labelList& boundaryAddressing
129 completeMesh_(completeMesh),
131 faceAddressing_(faceAddressing),
132 cellAddressing_(cellAddressing),
133 boundaryAddressing_(boundaryAddressing),
134 patchFieldDecomposerPtrs_
136 procMesh_.boundary().size(),
137 static_cast<patchFieldDecomposer*>(NULL)
139 processorVolPatchFieldDecomposerPtrs_
141 procMesh_.boundary().size(),
142 static_cast<processorVolPatchFieldDecomposer*>(NULL)
144 processorSurfacePatchFieldDecomposerPtrs_
146 procMesh_.boundary().size(),
147 static_cast<processorSurfacePatchFieldDecomposer*>(NULL)
150 forAll (boundaryAddressing_, patchi)
152 if (boundaryAddressing_[patchi] >= 0)
154 patchFieldDecomposerPtrs_[patchi] = new patchFieldDecomposer
156 procMesh_.boundary()[patchi].patchSlice(faceAddressing_),
157 completeMesh_.boundaryMesh()
159 boundaryAddressing_[patchi]
165 processorVolPatchFieldDecomposerPtrs_[patchi] =
166 new processorVolPatchFieldDecomposer
169 procMesh_.boundary()[patchi].patchSlice(faceAddressing_)
172 processorSurfacePatchFieldDecomposerPtrs_[patchi] =
173 new processorSurfacePatchFieldDecomposer
175 static_cast<const unallocLabelList&>
177 procMesh_.boundary()[patchi].patchSlice
188 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
190 fvFieldDecomposer::~fvFieldDecomposer()
192 forAll (patchFieldDecomposerPtrs_, patchi)
194 if (patchFieldDecomposerPtrs_[patchi])
196 delete patchFieldDecomposerPtrs_[patchi];
200 forAll (processorVolPatchFieldDecomposerPtrs_, patchi)
202 if (processorVolPatchFieldDecomposerPtrs_[patchi])
204 delete processorVolPatchFieldDecomposerPtrs_[patchi];
208 forAll (processorSurfacePatchFieldDecomposerPtrs_, patchi)
210 if (processorSurfacePatchFieldDecomposerPtrs_[patchi])
212 delete processorSurfacePatchFieldDecomposerPtrs_[patchi];
218 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
220 } // End namespace Foam
222 // ************************************************************************* //