1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
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 "faFieldDecomposer.H"
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
36 faFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
38 const label sizeBeforeMapping,
39 const unallocLabelList& addressingSlice,
40 const label addressingOffset
43 sizeBeforeMapping_(sizeBeforeMapping),
44 directAddressing_(addressingSlice)
46 forAll (directAddressing_, i)
48 // Subtract one to align addressing.
49 // directAddressing_[i] -= addressingOffset + 1;
51 directAddressing_[i] -= addressingOffset;
56 faFieldDecomposer::processorAreaPatchFieldDecomposer::
57 processorAreaPatchFieldDecomposer
60 const unallocLabelList& addressingSlice
63 sizeBeforeMapping_(mesh.nFaces()),
64 addressing_(addressingSlice.size()),
65 weights_(addressingSlice.size())
67 const scalarField& weights = mesh.weights().internalField();
68 const labelList& own = mesh.edgeOwner();
69 const labelList& neighb = mesh.edgeNeighbour();
71 forAll (addressing_, i)
73 // Subtract one to align addressing.
74 label ai = addressingSlice[i];
75 // label ai = mag(addressingSlice[i]) - 1;
77 if (ai < neighb.size())
79 // This is a regular edge. it has been an internal edge
80 // of the original mesh and now it has become a edge
81 // on the parallel boundary
82 addressing_[i].setSize(2);
83 weights_[i].setSize(2);
85 addressing_[i][0] = own[ai];
86 addressing_[i][1] = neighb[ai];
88 weights_[i][0] = weights[ai];
89 weights_[i][1] = 1.0 - weights[ai];
93 // This is a edge that used to be on a cyclic boundary
94 // but has now become a parallel patch edge. I cannot
95 // do the interpolation properly (I would need to look
96 // up the different (edge) list of data), so I will
97 // just grab the value from the owner face
99 addressing_[i].setSize(1);
100 weights_[i].setSize(1);
102 addressing_[i][0] = own[ai];
104 weights_[i][0] = 1.0;
110 faFieldDecomposer::processorEdgePatchFieldDecomposer::
111 processorEdgePatchFieldDecomposer
113 label sizeBeforeMapping,
114 const unallocLabelList& addressingSlice
117 sizeBeforeMapping_(sizeBeforeMapping),
118 addressing_(addressingSlice.size()),
119 weights_(addressingSlice.size())
121 forAll (addressing_, i)
123 addressing_[i].setSize(1);
124 weights_[i].setSize(1);
126 addressing_[i][0] = mag(addressingSlice[i]) - 1;
127 weights_[i][0] = sign(addressingSlice[i]);
132 faFieldDecomposer::faFieldDecomposer
134 const faMesh& completeMesh,
135 const faMesh& procMesh,
136 const labelList& edgeAddressing,
137 const labelList& faceAddressing,
138 const labelList& boundaryAddressing
141 completeMesh_(completeMesh),
143 edgeAddressing_(edgeAddressing),
144 faceAddressing_(faceAddressing),
145 boundaryAddressing_(boundaryAddressing),
146 patchFieldDecomposerPtrs_
148 procMesh_.boundary().size(),
149 static_cast<patchFieldDecomposer*>(NULL)
151 processorAreaPatchFieldDecomposerPtrs_
153 procMesh_.boundary().size(),
154 static_cast<processorAreaPatchFieldDecomposer*>(NULL)
156 processorEdgePatchFieldDecomposerPtrs_
158 procMesh_.boundary().size(),
159 static_cast<processorEdgePatchFieldDecomposer*>(NULL)
162 forAll (boundaryAddressing_, patchi)
164 if (boundaryAddressing_[patchi] >= 0)
166 patchFieldDecomposerPtrs_[patchi] = new patchFieldDecomposer
168 completeMesh_.boundary()[boundaryAddressing_[patchi]].size(),
169 procMesh_.boundary()[patchi].patchSlice(edgeAddressing_),
170 // completeMesh_.boundaryMesh()
171 completeMesh_.boundary()
173 boundaryAddressing_[patchi]
179 processorAreaPatchFieldDecomposerPtrs_[patchi] =
180 new processorAreaPatchFieldDecomposer
183 procMesh_.boundary()[patchi].patchSlice(edgeAddressing_)
186 processorEdgePatchFieldDecomposerPtrs_[patchi] =
187 new processorEdgePatchFieldDecomposer
189 procMesh_.boundary()[patchi].size(),
190 static_cast<const unallocLabelList&>
192 procMesh_.boundary()[patchi].patchSlice
203 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
205 faFieldDecomposer::~faFieldDecomposer()
207 forAll (patchFieldDecomposerPtrs_, patchi)
209 if (patchFieldDecomposerPtrs_[patchi])
211 delete patchFieldDecomposerPtrs_[patchi];
215 forAll (processorAreaPatchFieldDecomposerPtrs_, patchi)
217 if (processorAreaPatchFieldDecomposerPtrs_[patchi])
219 delete processorAreaPatchFieldDecomposerPtrs_[patchi];
223 forAll (processorEdgePatchFieldDecomposerPtrs_, patchi)
225 if (processorEdgePatchFieldDecomposerPtrs_[patchi])
227 delete processorEdgePatchFieldDecomposerPtrs_[patchi];
233 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
235 } // End namespace Foam
237 // ************************************************************************* //