1 /*---------------------------------------------------------------------------*\
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 -------------------------------------------------------------------------------
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 "faFieldDecomposer.H"
28 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 faFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
37 const label sizeBeforeMapping,
38 const unallocLabelList& addressingSlice,
39 const label addressingOffset
42 sizeBeforeMapping_(sizeBeforeMapping),
43 directAddressing_(addressingSlice)
45 forAll (directAddressing_, i)
47 // Subtract one to align addressing.
48 // directAddressing_[i] -= addressingOffset + 1;
50 directAddressing_[i] -= addressingOffset;
55 faFieldDecomposer::processorAreaPatchFieldDecomposer::
56 processorAreaPatchFieldDecomposer
59 const unallocLabelList& addressingSlice
62 sizeBeforeMapping_(mesh.nFaces()),
63 addressing_(addressingSlice.size()),
64 weights_(addressingSlice.size())
66 const scalarField& weights = mesh.weights().internalField();
67 const labelList& own = mesh.edgeOwner();
68 const labelList& neighb = mesh.edgeNeighbour();
70 forAll (addressing_, i)
72 // Subtract one to align addressing.
73 label ai = addressingSlice[i];
74 // label ai = mag(addressingSlice[i]) - 1;
76 if (ai < neighb.size())
78 // This is a regular edge. it has been an internal edge
79 // of the original mesh and now it has become a edge
80 // on the parallel boundary
81 addressing_[i].setSize(2);
82 weights_[i].setSize(2);
84 addressing_[i][0] = own[ai];
85 addressing_[i][1] = neighb[ai];
87 weights_[i][0] = weights[ai];
88 weights_[i][1] = 1.0 - weights[ai];
92 // This is a edge that used to be on a cyclic boundary
93 // but has now become a parallel patch edge. I cannot
94 // do the interpolation properly (I would need to look
95 // up the different (edge) list of data), so I will
96 // just grab the value from the owner face
98 addressing_[i].setSize(1);
99 weights_[i].setSize(1);
101 addressing_[i][0] = own[ai];
103 weights_[i][0] = 1.0;
109 faFieldDecomposer::processorEdgePatchFieldDecomposer::
110 processorEdgePatchFieldDecomposer
112 label sizeBeforeMapping,
113 const unallocLabelList& addressingSlice
116 sizeBeforeMapping_(sizeBeforeMapping),
117 addressing_(addressingSlice.size()),
118 weights_(addressingSlice.size())
120 forAll (addressing_, i)
122 addressing_[i].setSize(1);
123 weights_[i].setSize(1);
125 addressing_[i][0] = mag(addressingSlice[i]) - 1;
126 weights_[i][0] = sign(addressingSlice[i]);
131 faFieldDecomposer::faFieldDecomposer
133 const faMesh& completeMesh,
134 const faMesh& procMesh,
135 const labelList& edgeAddressing,
136 const labelList& faceAddressing,
137 const labelList& boundaryAddressing
140 completeMesh_(completeMesh),
142 edgeAddressing_(edgeAddressing),
143 faceAddressing_(faceAddressing),
144 boundaryAddressing_(boundaryAddressing),
145 patchFieldDecomposerPtrs_
147 procMesh_.boundary().size(),
148 static_cast<patchFieldDecomposer*>(NULL)
150 processorAreaPatchFieldDecomposerPtrs_
152 procMesh_.boundary().size(),
153 static_cast<processorAreaPatchFieldDecomposer*>(NULL)
155 processorEdgePatchFieldDecomposerPtrs_
157 procMesh_.boundary().size(),
158 static_cast<processorEdgePatchFieldDecomposer*>(NULL)
161 forAll (boundaryAddressing_, patchi)
163 if (boundaryAddressing_[patchi] >= 0)
165 patchFieldDecomposerPtrs_[patchi] = new patchFieldDecomposer
167 completeMesh_.boundary()[boundaryAddressing_[patchi]].size(),
168 procMesh_.boundary()[patchi].patchSlice(edgeAddressing_),
169 // completeMesh_.boundaryMesh()
170 completeMesh_.boundary()
172 boundaryAddressing_[patchi]
178 processorAreaPatchFieldDecomposerPtrs_[patchi] =
179 new processorAreaPatchFieldDecomposer
182 procMesh_.boundary()[patchi].patchSlice(edgeAddressing_)
185 processorEdgePatchFieldDecomposerPtrs_[patchi] =
186 new processorEdgePatchFieldDecomposer
188 procMesh_.boundary()[patchi].size(),
189 static_cast<const unallocLabelList&>
191 procMesh_.boundary()[patchi].patchSlice
202 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
204 faFieldDecomposer::~faFieldDecomposer()
206 forAll (patchFieldDecomposerPtrs_, patchi)
208 if (patchFieldDecomposerPtrs_[patchi])
210 delete patchFieldDecomposerPtrs_[patchi];
214 forAll (processorAreaPatchFieldDecomposerPtrs_, patchi)
216 if (processorAreaPatchFieldDecomposerPtrs_[patchi])
218 delete processorAreaPatchFieldDecomposerPtrs_[patchi];
222 forAll (processorEdgePatchFieldDecomposerPtrs_, patchi)
224 if (processorEdgePatchFieldDecomposerPtrs_[patchi])
226 delete processorEdgePatchFieldDecomposerPtrs_[patchi];
232 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
234 } // End namespace Foam
236 // ************************************************************************* //