Forward compatibility: flex
[foam-extend-3.2.git] / src / foam / meshes / primitiveMesh / primitiveMesh.C
blob88c451e941f276e95595514092e999a9db487739
1 /*---------------------------------------------------------------------------*\
2   =========                 |
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 -------------------------------------------------------------------------------
8 License
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/>.
24 \*---------------------------------------------------------------------------*/
26 #include "primitiveMesh.H"
27 #include "demandDrivenData.H"
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 defineTypeNameAndDebug(Foam::primitiveMesh, 0);
34 // * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //
36 Foam::primitiveMesh::primitiveMesh()
38     nPoints_(0),
39     nEdges_(-1),
40     nInternalFaces_(0),
41     nFaces_(0),
42     nCells_(0),
44     cellShapesPtr_(NULL),
45     edgesPtr_(NULL),
46     ccPtr_(NULL),
47     ecPtr_(NULL),
48     pcPtr_(NULL),
50     cfPtr_(NULL),
51     efPtr_(NULL),
52     pfPtr_(NULL),
54     cePtr_(NULL),
55     fePtr_(NULL),
56     pePtr_(NULL),
57     ppPtr_(NULL),
58     cpPtr_(NULL),
60     labels_(0),
62     cellCentresPtr_(NULL),
63     faceCentresPtr_(NULL),
64     cellVolumesPtr_(NULL),
65     faceAreasPtr_(NULL)
69 // Construct from components
70 // WARNING: ASSUMES CORRECT ORDERING OF DATA.
71 Foam::primitiveMesh::primitiveMesh
73     const label nPoints,
74     const label nInternalFaces,
75     const label nFaces,
76     const label nCells
79     nPoints_(nPoints),
80     nEdges_(-1),
81     nInternalFaces_(nInternalFaces),
82     nFaces_(nFaces),
83     nCells_(nCells),
85     cellShapesPtr_(NULL),
86     edgesPtr_(NULL),
87     ccPtr_(NULL),
88     ecPtr_(NULL),
89     pcPtr_(NULL),
91     cfPtr_(NULL),
92     efPtr_(NULL),
93     pfPtr_(NULL),
95     cePtr_(NULL),
96     fePtr_(NULL),
97     pePtr_(NULL),
98     ppPtr_(NULL),
99     cpPtr_(NULL),
101     labels_(0),
103     cellCentresPtr_(NULL),
104     faceCentresPtr_(NULL),
105     cellVolumesPtr_(NULL),
106     faceAreasPtr_(NULL)
110 // * * * * * * * * * * * * * * * * Destructor  * * * * * * * * * * * * * * * //
112 Foam::primitiveMesh::~primitiveMesh()
114     clearOut();
118 // * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //
120 void Foam::primitiveMesh::reset
122     const label nPoints,
123     const label nInternalFaces,
124     const label nFaces,
125     const label nCells
128     clearOut();
130     nPoints_ = nPoints;
131     nEdges_ = -1;
133     nInternalFaces_ = nInternalFaces;
134     nFaces_ = nFaces;
135     nCells_ = nCells;
137     if (debug)
138     {
139         Pout<< "primitiveMesh::reset : mesh reset to"
140             << " nPoints:" << nPoints_
141             << " nEdges:" << nEdges_
142             << " nInternalFaces:" << nInternalFaces_
143             << " nFaces:" << nFaces_
144             << " nCells:" << nCells_
145             << endl;
146     }
150 void Foam::primitiveMesh::reset
152     const label nPoints,
153     const label nInternalFaces,
154     const label nFaces,
155     const label nCells,
156     cellList& clst
159     reset
160     (
161         nPoints,
162         nInternalFaces,
163         nFaces,
164         nCells
165     );
167     cfPtr_ = new cellList(clst, true);
171 void Foam::primitiveMesh::reset
173     const label nPoints,
174     const label nInternalFaces,
175     const label nFaces,
176     const label nCells,
177     const Xfer<cellList>& clst
180     reset
181     (
182         nPoints,
183         nInternalFaces,
184         nFaces,
185         nCells
186     );
188     cfPtr_ = new cellList(clst);
192 Foam::tmp<Foam::scalarField> Foam::primitiveMesh::movePoints
194     const pointField& newPoints,
195     const pointField& oldPoints
198     if (newPoints.size() <  nPoints() || oldPoints.size() < nPoints())
199     {
200         FatalErrorIn
201         (
202             "primitiveMesh::movePoints(const pointField& newPoints, "
203             "const pointField& oldPoints)"
204         )   << "Cannot move points: size of given point list smaller "
205             << "than the number of active points" << nl
206             << "newPoints: " << newPoints.size()
207             << " oldPoints: " << oldPoints.size()
208             << " nPoints(): " << nPoints() << nl
209             << abort(FatalError);
210     }
212     // Create swept volumes
213     const faceList& f = faces();
215     tmp<scalarField> tsweptVols(new scalarField(f.size()));
216     scalarField& sweptVols = tsweptVols();
218     forAll(f, faceI)
219     {
220         sweptVols[faceI] = f[faceI].sweptVol(oldPoints, newPoints);
221     }
223     // Force recalculation of all geometric data with new points
224     clearGeom();
226     return tsweptVols;
230 const Foam::cellShapeList& Foam::primitiveMesh::cellShapes() const
232     if (!cellShapesPtr_)
233     {
234         calcCellShapes();
235     }
237     return *cellShapesPtr_;
241 // ************************************************************************* //