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 The tetrahedral decomposition of the mesh based on the underlying polyMesh.
27 Uses minimal storage - the tet decomposition is provided on a cell-by-cell
30 \*---------------------------------------------------------------------------*/
32 #include "tetPolyMeshFaceDecomp.H"
33 #include "demandDrivenData.H"
34 #include "tetPolyPatchFields.H"
35 #include "tetPointFields.H"
36 #include "elementFields.H"
37 #include "tetFemMatrices.H"
38 #include "mapPolyMesh.H"
39 #include "MapTetFemFields.H"
40 #include "tetPolyMeshMapperFaceDecomp.H"
42 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
44 defineTypeNameAndDebug(Foam::tetPolyMeshFaceDecomp, 0);
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
52 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
54 void tetPolyMeshFaceDecomp::clearOut() const
59 deleteDemandDrivenData(lduPtr_);
60 maxNPointsForCell_ = -1;
62 clearOutParPointData();
65 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
67 // Construct from components
68 tetPolyMeshFaceDecomp::tetPolyMeshFaceDecomp(const polyMesh& pMesh)
70 GeoMesh<polyMesh>(pMesh),
71 tetFemSolution(pMesh),
72 boundary_(*this, pMesh.boundaryMesh()),
73 faceOffset_(mesh_.nPoints()),
74 cellOffset_(faceOffset_ + mesh_.nFaces()),
79 maxNPointsForCell_(-1),
85 Info<< "tetPolyMesh::tetPolyMesh(const polyMesh&) : "
86 << "Creating tetPolyMesh" << endl;
89 addParallelPointPatch();
93 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
95 tetPolyMeshFaceDecomp::~tetPolyMeshFaceDecomp()
99 Info<< "tetPolyMesh::~tetPolyMesh() : "
100 << "Deleting tetPolyMesh" << endl;
107 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
109 // Return number of edges in decomposition for a face
110 label tetPolyMeshFaceDecomp::nEdgesForFace(const label faceID) const
112 // It is all the edges around the circumference + the internal diags
114 // Note: compiler bug. It should be possible to do this without wrapping
115 const faceList& f = mesh_.faces();
116 return 2*f[faceID].size();
120 // Return number of edges in decomposition connected to a given point
121 label tetPolyMeshFaceDecomp::nEdgesForPoint(const label pointID) const
123 const label startFaceOwn = lduAddr().ownerStartAddr()[pointID];
124 const label endFaceOwn = lduAddr().ownerStartAddr()[pointID + 1];
126 const label startFaceNbr = lduAddr().losortStartAddr()[pointID];
127 const label endFaceNbr = lduAddr().losortStartAddr()[pointID + 1];
129 // pointID is the owner of the first lot and the neighbour of the second lot
130 return (endFaceOwn - startFaceOwn) + (endFaceNbr - startFaceNbr);
134 // Return number of edges in decomposition connected to a given point
135 labelList tetPolyMeshFaceDecomp::edgesForPoint(const label pointID) const
137 const label startFaceOwn = lduAddr().ownerStartAddr()[pointID];
138 const label endFaceOwn = lduAddr().ownerStartAddr()[pointID + 1];
140 const label startFaceNbr = lduAddr().losortStartAddr()[pointID];
141 const label endFaceNbr = lduAddr().losortStartAddr()[pointID + 1];
143 const unallocLabelList& losort = lduAddr().losortAddr();
145 // pointID is the owner of the first lot and the neighbour of the second lot
146 labelList edgeIndices(nEdgesForPoint(pointID), -1);
151 for (label edgeLabel = startFaceOwn; edgeLabel < endFaceOwn; edgeLabel++)
153 edgeIndices[i] = edgeLabel;
158 for (label edgeLabel = startFaceNbr; edgeLabel < endFaceNbr; edgeLabel++)
160 edgeIndices[i] = losort[edgeLabel];
168 void tetPolyMeshFaceDecomp::updateMesh
170 const tetPolyMeshMapperFaceDecomp& mapper
173 // It is assumed that polyMesh::morph() has already been called.
176 Info<< "void tetPolyMeshFaceDecomp::updateMesh: "
177 << "Mesh update on topological change" << endl;
180 // Clear out all data
183 // Reset face and cell offset (topology has changed)
184 faceOffset_ = mesh_.nPoints();
185 cellOffset_ = faceOffset_ + mesh_.nFaces();
187 boundary_.updateMesh();
189 // Map all the tetPointFields in the database
195 tetPolyMeshMapperFaceDecomp,
203 tetPolyMeshMapperFaceDecomp,
211 tetPolyMeshMapperFaceDecomp,
215 // Map all the element fields in the database
221 tetPolyMeshMapperFaceDecomp,
229 tetPolyMeshMapperFaceDecomp,
237 tetPolyMeshMapperFaceDecomp,
243 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
245 bool tetPolyMeshFaceDecomp::operator!=(const tetPolyMeshFaceDecomp& bm) const
251 bool tetPolyMeshFaceDecomp::operator==(const tetPolyMeshFaceDecomp& bm) const
257 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
259 } // End namespace Foam
261 // ************************************************************************* //