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
26 Tetrahedral point field decomposer.
28 \*---------------------------------------------------------------------------*/
30 #include "tetPointFieldDecomposer.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
40 // Calculate point addressing
41 void tetPointFieldDecomposer::calcAddressing() const
43 if (directAddressingPtr_)
47 "void tetPointFieldDecomposer::calcAddressing() const"
48 ) << "addressing already calculated"
52 // Allocate the addressing
53 directAddressingPtr_ = new labelList(processorMesh_.nPoints(), -1);
54 labelList& addr = *directAddressingPtr_;
58 // Insert point addressing
60 // Use only live points. HJ, 14/Apr/2009
61 for (label pointI = 0; pointI < processorMesh_().nPoints(); pointI++)
63 addr[nAddr] = pointAddressing_[pointI];
68 // Insert face addressing. Only for face decomposition
69 const label faceOffset = originalMesh_.faceOffset();
71 // Use only live faces. HJ, 14/Apr/2009
72 for (label faceI = 0; faceI < processorMesh_().nFaces(); faceI++)
74 // Remember to decrement the index by one (turning index)
75 addr[nAddr] = faceOffset + mag(faceAddressing_[faceI]) - 1;
80 // Insert cell addressing
81 const label cellOffset = originalMesh_.cellOffset();
83 forAll (cellAddressing_, cellI)
85 addr[nAddr] = cellOffset + cellAddressing_[cellI];
91 const labelList& tetPointFieldDecomposer::directAddressing() const
93 if (!directAddressingPtr_)
98 return *directAddressingPtr_;
102 // Calculate patch addressing
103 void tetPointFieldDecomposer::
104 tetPolyPatchFieldDecomposer::calcPatchAddressing() const
106 if (directPatchAddressingPtr_)
110 "void tetPointFieldDecomposer::"
111 "tetPolyPatchFieldDecomposer::calcPatchAddressing() const"
112 ) << "addressing already calculated"
113 << abort(FatalError);
116 // Allocate the addressing
117 directPatchAddressingPtr_ = new labelList(targetPatch().size(), -1);
118 labelList& addr = *directPatchAddressingPtr_;
121 // Go to the source patch, create a lookup list the size of all
122 // points in the mesh and then gather the points for the current
124 labelList pointLookup
125 (sourcePatch().boundaryMesh().mesh().nPoints(), -1);
127 const labelList& sourcePatchPoints = sourcePatch().meshPoints();
129 forAll (sourcePatchPoints, pointI)
131 pointLookup[sourcePatchPoints[pointI]] = pointI;
134 // Gather the information
136 const labelList& targetPatchPoints = targetPatch().meshPoints();
138 forAll (targetPatchPoints, pointI)
141 pointLookup[directAddressing_[targetPatchPoints[pointI]]];
144 if (addr.size() && min(addr) < 0)
148 "void tetPointFieldDecomposer::"
149 "tetPolyPatchFieldDecomposer::calcPatchAddressing() const"
150 ) << "error in addressing"
151 << abort(FatalError);
156 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
158 // Construct from components
159 tetPointFieldDecomposer::tetPointFieldDecomposer
161 const tetPolyMesh& originalMesh,
162 const tetPolyMesh& processorMesh,
163 const labelList& pointAddressing,
164 const labelList& faceAddressing,
165 const labelList& cellAddressing,
166 const labelList& boundaryAddressing
169 originalMesh_(originalMesh),
170 processorMesh_(processorMesh),
171 pointAddressing_(pointAddressing),
172 faceAddressing_(faceAddressing),
173 cellAddressing_(cellAddressing),
174 boundaryAddressing_(boundaryAddressing),
175 patchFieldDecompPtrs_
177 processorMesh_.boundary().size(),
178 reinterpret_cast<tetPolyPatchFieldDecomposer*>(NULL)
180 directAddressingPtr_(NULL)
182 // Set the patch field decomposers for all non-processor patch fields
183 forAll (boundaryAddressing_, patchI)
185 if (boundaryAddressing_[patchI] >= 0)
187 patchFieldDecompPtrs_[patchI] =
188 new tetPolyPatchFieldDecomposer
190 originalMesh_.boundary()[boundaryAddressing_[patchI]],
191 processorMesh_.boundary()[patchI],
195 // for processor patches the pointer stays null
200 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
202 tetPointFieldDecomposer::~tetPointFieldDecomposer()
204 forAll (patchFieldDecompPtrs_, patchI)
206 if (patchFieldDecompPtrs_[patchI] != NULL)
208 delete(patchFieldDecompPtrs_[patchI]);
209 patchFieldDecompPtrs_[patchI] = NULL;
215 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
217 } // End namespace Foam
219 // ************************************************************************* //