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];
67 // Insert face addressing. Only for face decomposition
68 const label faceOffset = originalMesh_.faceOffset();
70 // Use only live faces. HJ, 14/Apr/2009
71 for (label faceI = 0; faceI < processorMesh_().nFaces(); faceI++)
73 // Remember to decrement the index by one (turning index)
74 addr[nAddr] = faceOffset + mag(faceAddressing_[faceI]) - 1;
78 // Insert cell addressing
79 const label cellOffset = originalMesh_.cellOffset();
81 forAll (cellAddressing_, cellI)
83 addr[nAddr] = cellOffset + cellAddressing_[cellI];
89 const labelList& tetPointFieldDecomposer::directAddressing() const
91 if (!directAddressingPtr_)
96 return *directAddressingPtr_;
100 // Calculate patch addressing
101 void tetPointFieldDecomposer::
102 tetPolyPatchFieldDecomposer::calcPatchAddressing() const
104 if (directPatchAddressingPtr_)
108 "void tetPointFieldDecomposer::"
109 "tetPolyPatchFieldDecomposer::calcPatchAddressing() const"
110 ) << "addressing already calculated"
111 << abort(FatalError);
114 // Allocate the addressing
115 directPatchAddressingPtr_ = new labelList(targetPatch().size(), -1);
116 labelList& addr = *directPatchAddressingPtr_;
119 // Go to the source patch, create a lookup list the size of all
120 // points in the mesh and then gather the points for the current
122 labelList pointLookup
123 (sourcePatch().boundaryMesh().mesh().nPoints(), -1);
125 const labelList& sourcePatchPoints = sourcePatch().meshPoints();
127 forAll (sourcePatchPoints, pointI)
129 pointLookup[sourcePatchPoints[pointI]] = pointI;
132 // Gather the information
134 const labelList& targetPatchPoints = targetPatch().meshPoints();
136 forAll (targetPatchPoints, pointI)
139 pointLookup[directAddressing_[targetPatchPoints[pointI]]];
142 if (addr.size() && min(addr) < 0)
146 "void tetPointFieldDecomposer::"
147 "tetPolyPatchFieldDecomposer::calcPatchAddressing() const"
148 ) << "error in addressing"
149 << abort(FatalError);
154 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
156 // Construct from components
157 tetPointFieldDecomposer::tetPointFieldDecomposer
159 const tetPolyMesh& originalMesh,
160 const tetPolyMesh& processorMesh,
161 const labelList& pointAddressing,
162 const labelList& faceAddressing,
163 const labelList& cellAddressing,
164 const labelList& boundaryAddressing
167 originalMesh_(originalMesh),
168 processorMesh_(processorMesh),
169 pointAddressing_(pointAddressing),
170 faceAddressing_(faceAddressing),
171 cellAddressing_(cellAddressing),
172 boundaryAddressing_(boundaryAddressing),
173 patchFieldDecompPtrs_
175 processorMesh_.boundary().size(),
176 reinterpret_cast<tetPolyPatchFieldDecomposer*>(NULL)
178 directAddressingPtr_(NULL)
180 // Set the patch field decomposers for all non-processor patch fields
181 forAll (boundaryAddressing_, patchI)
183 if (boundaryAddressing_[patchI] >= 0)
185 patchFieldDecompPtrs_[patchI] =
186 new tetPolyPatchFieldDecomposer
188 originalMesh_.boundary()[boundaryAddressing_[patchI]],
189 processorMesh_.boundary()[patchI],
193 // for processor patches the pointer stays null
198 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
200 tetPointFieldDecomposer::~tetPointFieldDecomposer()
202 forAll (patchFieldDecompPtrs_, patchI)
204 if (patchFieldDecompPtrs_[patchI] != NULL)
206 delete(patchFieldDecompPtrs_[patchI]);
207 patchFieldDecompPtrs_[patchI] = NULL;
213 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
215 } // End namespace Foam
217 // ************************************************************************* //