ThirdParty: fix compilation of libccmio-2.6.1 on Mac OS X
[OpenFOAM-1.6-ext.git] / src / OpenFOAM / meshes / primitiveMesh / primitiveMesh.C
blob0db40ba9fd8e09e6f80a4f54bb99d7ec29d66faf
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright held by original author
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
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
19     for more details.
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
25 \*---------------------------------------------------------------------------*/
27 #include "primitiveMesh.H"
28 #include "demandDrivenData.H"
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 defineTypeNameAndDebug(Foam::primitiveMesh, 0);
35 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
37 Foam::primitiveMesh::primitiveMesh()
39     nPoints_(0),
40     nEdges_(-1),
41     nInternalFaces_(0),
42     nFaces_(0),
43     nCells_(0),
45     cellShapesPtr_(NULL),
46     edgesPtr_(NULL),
47     ccPtr_(NULL),
48     ecPtr_(NULL),
49     pcPtr_(NULL),
51     cfPtr_(NULL),
52     efPtr_(NULL),
53     pfPtr_(NULL),
55     cePtr_(NULL),
56     fePtr_(NULL),
57     pePtr_(NULL),
58     ppPtr_(NULL),
59     cpPtr_(NULL),
61     labels_(0),
63     cellCentresPtr_(NULL),
64     faceCentresPtr_(NULL),
65     cellVolumesPtr_(NULL),
66     faceAreasPtr_(NULL)
70 // Construct from components
71 // WARNING: ASSUMES CORRECT ORDERING OF DATA.
72 Foam::primitiveMesh::primitiveMesh
74     const label nPoints,
75     const label nInternalFaces,
76     const label nFaces,
77     const label nCells
80     nPoints_(nPoints),
81     nEdges_(-1),
82     nInternalFaces_(nInternalFaces),
83     nFaces_(nFaces),
84     nCells_(nCells),
86     cellShapesPtr_(NULL),
87     edgesPtr_(NULL),
88     ccPtr_(NULL),
89     ecPtr_(NULL),
90     pcPtr_(NULL),
92     cfPtr_(NULL),
93     efPtr_(NULL),
94     pfPtr_(NULL),
96     cePtr_(NULL),
97     fePtr_(NULL),
98     pePtr_(NULL),
99     ppPtr_(NULL),
100     cpPtr_(NULL),
102     labels_(0),
104     cellCentresPtr_(NULL),
105     faceCentresPtr_(NULL),
106     cellVolumesPtr_(NULL),
107     faceAreasPtr_(NULL)
111 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
113 Foam::primitiveMesh::~primitiveMesh()
115     clearOut();
119 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
121 void Foam::primitiveMesh::reset
123     const label nPoints,
124     const label nInternalFaces,
125     const label nFaces,
126     const label nCells
129     clearOut();
131     nPoints_ = nPoints;
132     nEdges_ = -1;
134     nInternalFaces_ = nInternalFaces;
135     nFaces_ = nFaces;
136     nCells_ = nCells;
138     if (debug)
139     {
140         Pout<< "primitiveMesh::reset : mesh reset to"
141             << " nPoints:" << nPoints_
142             << " nEdges:" << nEdges_
143             << " nInternalFaces:" << nInternalFaces_
144             << " nFaces:" << nFaces_
145             << " nCells:" << nCells_
146             << endl;
147     }
151 void Foam::primitiveMesh::reset
153     const label nPoints,
154     const label nInternalFaces,
155     const label nFaces,
156     const label nCells,
157     cellList& clst
160     reset
161     (
162         nPoints,
163         nInternalFaces,
164         nFaces,
165         nCells
166     );
168     cfPtr_ = new cellList(clst, true);
172 void Foam::primitiveMesh::reset
174     const label nPoints,
175     const label nInternalFaces,
176     const label nFaces,
177     const label nCells,
178     const Xfer<cellList>& clst
181     reset
182     (
183         nPoints,
184         nInternalFaces,
185         nFaces,
186         nCells
187     );
189     cfPtr_ = new cellList(clst);
193 Foam::tmp<Foam::scalarField> Foam::primitiveMesh::movePoints
195     const pointField& newPoints,
196     const pointField& oldPoints
199     if (newPoints.size() <  nPoints() || oldPoints.size() < nPoints())
200     {
201         FatalErrorIn
202         (
203             "primitiveMesh::movePoints(const pointField& newPoints, "
204             "const pointField& oldPoints)"
205         )   << "Cannot move points: size of given point list smaller "
206             << "than the number of active points" << nl
207             << "newPoints: " << newPoints.size()
208             << " oldPoints: " << oldPoints.size()
209             << " nPoints(): " << nPoints() << nl
210             << abort(FatalError);
211     }
213     // Create swept volumes
214     const faceList& f = faces();
216     tmp<scalarField> tsweptVols(new scalarField(f.size()));
217     scalarField& sweptVols = tsweptVols();
219     forAll(f, faceI)
220     {
221         sweptVols[faceI] = f[faceI].sweptVol(oldPoints, newPoints);
222     }
224     // Force recalculation of all geometric data with new points
225     clearGeom();
227     return tsweptVols;
231 const Foam::cellShapeList& Foam::primitiveMesh::cellShapes() const
233     if (!cellShapesPtr_)
234     {
235         calcCellShapes();
236     }
238     return *cellShapesPtr_;
242 // ************************************************************************* //