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/>.
25 Tetrahedral point field decomposer.
27 \*---------------------------------------------------------------------------*/
29 #include "tetPointFieldDecomposer.H"
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
39 // Calculate point addressing
40 void tetPointFieldDecomposer::calcAddressing() const
42 if (directAddressingPtr_)
46 "void tetPointFieldDecomposer::calcAddressing() const"
47 ) << "addressing already calculated"
51 // Allocate the addressing
52 directAddressingPtr_ = new labelList(processorMesh_.nPoints(), -1);
53 labelList& addr = *directAddressingPtr_;
57 // Insert point addressing
59 // Use only live points. HJ, 14/Apr/2009
60 for (label pointI = 0; pointI < processorMesh_().nPoints(); pointI++)
62 addr[nAddr] = pointAddressing_[pointI];
66 // Insert face addressing. Only for face decomposition
67 const label faceOffset = originalMesh_.faceOffset();
69 // Use only live faces. HJ, 14/Apr/2009
70 for (label faceI = 0; faceI < processorMesh_().nFaces(); faceI++)
72 // Remember to decrement the index by one (turning index)
73 addr[nAddr] = faceOffset + mag(faceAddressing_[faceI]) - 1;
77 // Insert cell addressing
78 const label cellOffset = originalMesh_.cellOffset();
80 forAll (cellAddressing_, cellI)
82 addr[nAddr] = cellOffset + cellAddressing_[cellI];
88 const labelList& tetPointFieldDecomposer::directAddressing() const
90 if (!directAddressingPtr_)
95 return *directAddressingPtr_;
99 // Calculate patch addressing
100 void tetPointFieldDecomposer::
101 tetPolyPatchFieldDecomposer::calcPatchAddressing() const
103 if (directPatchAddressingPtr_)
107 "void tetPointFieldDecomposer::"
108 "tetPolyPatchFieldDecomposer::calcPatchAddressing() const"
109 ) << "addressing already calculated"
110 << abort(FatalError);
113 // Allocate the addressing
114 directPatchAddressingPtr_ = new labelList(targetPatch().size(), -1);
115 labelList& addr = *directPatchAddressingPtr_;
118 // Go to the source patch, create a lookup list the size of all
119 // points in the mesh and then gather the points for the current
121 labelList pointLookup
122 (sourcePatch().boundaryMesh().mesh().nPoints(), -1);
124 const labelList& sourcePatchPoints = sourcePatch().meshPoints();
126 forAll (sourcePatchPoints, pointI)
128 pointLookup[sourcePatchPoints[pointI]] = pointI;
131 // Gather the information
133 const labelList& targetPatchPoints = targetPatch().meshPoints();
135 forAll (targetPatchPoints, pointI)
138 pointLookup[directAddressing_[targetPatchPoints[pointI]]];
141 if (addr.size() && min(addr) < 0)
145 "void tetPointFieldDecomposer::"
146 "tetPolyPatchFieldDecomposer::calcPatchAddressing() const"
147 ) << "error in addressing"
148 << abort(FatalError);
153 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
155 // Construct from components
156 tetPointFieldDecomposer::tetPointFieldDecomposer
158 const tetPolyMesh& originalMesh,
159 const tetPolyMesh& processorMesh,
160 const labelList& pointAddressing,
161 const labelList& faceAddressing,
162 const labelList& cellAddressing,
163 const labelList& boundaryAddressing
166 originalMesh_(originalMesh),
167 processorMesh_(processorMesh),
168 pointAddressing_(pointAddressing),
169 faceAddressing_(faceAddressing),
170 cellAddressing_(cellAddressing),
171 boundaryAddressing_(boundaryAddressing),
172 patchFieldDecompPtrs_
174 processorMesh_.boundary().size(),
175 reinterpret_cast<tetPolyPatchFieldDecomposer*>(NULL)
177 directAddressingPtr_(NULL)
179 // Set the patch field decomposers for all non-processor patch fields
180 forAll (boundaryAddressing_, patchI)
182 if (boundaryAddressing_[patchI] >= 0)
184 patchFieldDecompPtrs_[patchI] =
185 new tetPolyPatchFieldDecomposer
187 originalMesh_.boundary()[boundaryAddressing_[patchI]],
188 processorMesh_.boundary()[patchI],
192 // for processor patches the pointer stays null
197 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
199 tetPointFieldDecomposer::~tetPointFieldDecomposer()
201 forAll (patchFieldDecompPtrs_, patchI)
203 if (patchFieldDecompPtrs_[patchI] != NULL)
205 delete(patchFieldDecompPtrs_[patchI]);
206 patchFieldDecompPtrs_[patchI] = NULL;
212 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
214 } // End namespace Foam
216 // ************************************************************************* //