Forward compatibility: flex
[foam-extend-3.2.git] / applications / utilities / parallelProcessing / decomposePar / fvFieldDecomposer.C
blob03ff9cf7542ed3136d69c95924c805fc4d977966
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend 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 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 \*---------------------------------------------------------------------------*/
26 #include "fvFieldDecomposer.H"
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 namespace Foam
33 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
35 fvFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
37     const label sizeBeforeMapping,
38     const unallocLabelList& addressingSlice,
39     const label addressingOffset
42     sizeBeforeMapping_(sizeBeforeMapping),
43     directAddressing_(addressingSlice)
45     forAll (directAddressing_, i)
46     {
47         // Subtract one to align addressing.  HJ, 5/Dec/2001
48         directAddressing_[i] -= addressingOffset + 1;
49     }
53 fvFieldDecomposer::processorVolPatchFieldDecomposer::
54 processorVolPatchFieldDecomposer
56     const fvMesh& mesh,
57     const unallocLabelList& addressingSlice
60     sizeBeforeMapping_(mesh.nCells()),
61     addressing_(addressingSlice.size()),
62     weights_(addressingSlice.size())
64     const scalarField& weights = mesh.weights().internalField();
65     const labelList& own = mesh.faceOwner();
66     const labelList& neighb = mesh.faceNeighbour();
68     forAll (addressing_, i)
69     {
70         // Subtract one to align addressing.  HJ, 5/Dec/2001
71         label ai = mag(addressingSlice[i]) - 1;
73         if (ai < neighb.size())
74         {
75             // This is a regular face. it has been an internal face
76             // of the original mesh and now it has become a face
77             // on the parallel boundary
78             addressing_[i].setSize(2);
79             weights_[i].setSize(2);
81             addressing_[i][0] = own[ai];
82             addressing_[i][1] = neighb[ai];
84             weights_[i][0] = weights[ai];
85             weights_[i][1] = 1.0 - weights[ai];
86         }
87         else
88         {
89             // This is a face that used to be on a cyclic boundary
90             // but has now become a parallel patch face. I cannot
91             // do the interpolation properly (I would need to look
92             // up the different (face) list of data), so I will
93             // just grab the value from the owner cell
94             // HJ, 16/Mar/2001
95             addressing_[i].setSize(1);
96             weights_[i].setSize(1);
98             addressing_[i][0] = own[ai];
100             weights_[i][0] = 1.0;
101         }
102     }
106 fvFieldDecomposer::processorSurfacePatchFieldDecomposer::
107 processorSurfacePatchFieldDecomposer
109     label sizeBeforeMapping,
110     const unallocLabelList& addressingSlice
113     sizeBeforeMapping_(sizeBeforeMapping),
114     addressing_(addressingSlice.size()),
115     weights_(addressingSlice.size())
117     forAll (addressing_, i)
118     {
119         addressing_[i].setSize(1);
120         weights_[i].setSize(1);
122         addressing_[i][0] = mag(addressingSlice[i]) - 1;
123         weights_[i][0] = sign(addressingSlice[i]);
124     }
128 fvFieldDecomposer::fvFieldDecomposer
130     const fvMesh& completeMesh,
131     const fvMesh& procMesh,
132     const labelList& faceAddressing,
133     const labelList& cellAddressing,
134     const labelList& boundaryAddressing
137     completeMesh_(completeMesh),
138     procMesh_(procMesh),
139     faceAddressing_(faceAddressing),
140     cellAddressing_(cellAddressing),
141     boundaryAddressing_(boundaryAddressing),
142     patchFieldDecomposerPtrs_
143     (
144         procMesh_.boundary().size(),
145         static_cast<patchFieldDecomposer*>(NULL)
146     ),
147     processorVolPatchFieldDecomposerPtrs_
148     (
149         procMesh_.boundary().size(),
150         static_cast<processorVolPatchFieldDecomposer*>(NULL)
151     ),
152     processorSurfacePatchFieldDecomposerPtrs_
153     (
154         procMesh_.boundary().size(),
155         static_cast<processorSurfacePatchFieldDecomposer*>(NULL)
156     )
158     forAll (boundaryAddressing_, patchi)
159     {
160         if (boundaryAddressing_[patchi] >= 0)
161         {
162             patchFieldDecomposerPtrs_[patchi] = new patchFieldDecomposer
163             (
164                 completeMesh_.boundary()[boundaryAddressing_[patchi]].size(),
165                 procMesh_.boundary()[patchi].patchSlice(faceAddressing_),
166                 completeMesh_.boundaryMesh()
167                 [
168                     boundaryAddressing_[patchi]
169                 ].start()
170             );
171         }
172         else
173         {
174             processorVolPatchFieldDecomposerPtrs_[patchi] =
175                 new processorVolPatchFieldDecomposer
176                 (
177                     completeMesh_,
178                     procMesh_.boundary()[patchi].patchSlice(faceAddressing_)
179                 );
181             processorSurfacePatchFieldDecomposerPtrs_[patchi] =
182                 new processorSurfacePatchFieldDecomposer
183                 (
184                     procMesh_.boundary()[patchi].size(),
185                     static_cast<const unallocLabelList&>
186                     (
187                         procMesh_.boundary()[patchi].patchSlice
188                         (
189                             faceAddressing_
190                         )
191                     )
192                 );
193         }
194     }
198 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
200 fvFieldDecomposer::~fvFieldDecomposer()
202     forAll (patchFieldDecomposerPtrs_, patchi)
203     {
204         if (patchFieldDecomposerPtrs_[patchi])
205         {
206             delete patchFieldDecomposerPtrs_[patchi];
207         }
208     }
210     forAll (processorVolPatchFieldDecomposerPtrs_, patchi)
211     {
212         if (processorVolPatchFieldDecomposerPtrs_[patchi])
213         {
214             delete processorVolPatchFieldDecomposerPtrs_[patchi];
215         }
216     }
218     forAll (processorSurfacePatchFieldDecomposerPtrs_, patchi)
219     {
220         if (processorSurfacePatchFieldDecomposerPtrs_[patchi])
221         {
222             delete processorSurfacePatchFieldDecomposerPtrs_[patchi];
223         }
224     }
228 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
230 } // End namespace Foam
232 // ************************************************************************* //