primitiveMesh.C
Go to the documentation of this file.
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.
10 
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.
15 
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.
20 
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/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "primitiveMesh.H"
27 #include "demandDrivenData.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
32 
33 
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 
37 :
38  nPoints_(0),
39  nEdges_(-1),
40  nInternalFaces_(0),
41  nFaces_(0),
42  nCells_(0),
43 
44  cellShapesPtr_(NULL),
45  edgesPtr_(NULL),
46  ccPtr_(NULL),
47  ecPtr_(NULL),
48  pcPtr_(NULL),
49 
50  cfPtr_(NULL),
51  efPtr_(NULL),
52  pfPtr_(NULL),
53 
54  cePtr_(NULL),
55  fePtr_(NULL),
56  pePtr_(NULL),
57  ppPtr_(NULL),
58  cpPtr_(NULL),
59 
60  labels_(0),
61 
62  cellCentresPtr_(NULL),
63  faceCentresPtr_(NULL),
64  cellVolumesPtr_(NULL),
65  faceAreasPtr_(NULL)
66 {}
67 
68 
69 // Construct from components
70 // WARNING: ASSUMES CORRECT ORDERING OF DATA.
72 (
73  const label nPoints,
74  const label nInternalFaces,
75  const label nFaces,
76  const label nCells
77 )
78 :
79  nPoints_(nPoints),
80  nEdges_(-1),
81  nInternalFaces_(nInternalFaces),
82  nFaces_(nFaces),
83  nCells_(nCells),
84 
85  cellShapesPtr_(NULL),
86  edgesPtr_(NULL),
87  ccPtr_(NULL),
88  ecPtr_(NULL),
89  pcPtr_(NULL),
90 
91  cfPtr_(NULL),
92  efPtr_(NULL),
93  pfPtr_(NULL),
94 
95  cePtr_(NULL),
96  fePtr_(NULL),
97  pePtr_(NULL),
98  ppPtr_(NULL),
99  cpPtr_(NULL),
100 
101  labels_(0),
102 
103  cellCentresPtr_(NULL),
104  faceCentresPtr_(NULL),
105  cellVolumesPtr_(NULL),
106  faceAreasPtr_(NULL)
107 {}
108 
109 
110 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
111 
113 {
114  clearOut();
115 }
116 
117 
118 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
119 
121 (
122  const label nPoints,
123  const label nInternalFaces,
124  const label nFaces,
125  const label nCells
126 )
127 {
128  clearOut();
129 
130  nPoints_ = nPoints;
131  nEdges_ = -1;
132 
133  nInternalFaces_ = nInternalFaces;
134  nFaces_ = nFaces;
135  nCells_ = nCells;
136 
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  }
147 }
148 
149 
151 (
152  const label nPoints,
153  const label nInternalFaces,
154  const label nFaces,
155  const label nCells,
156  cellList& clst
157 )
158 {
159  reset
160  (
161  nPoints,
162  nInternalFaces,
163  nFaces,
164  nCells
165  );
166 
167  cfPtr_ = new cellList(clst, true);
168 }
169 
170 
172 (
173  const label nPoints,
174  const label nInternalFaces,
175  const label nFaces,
176  const label nCells,
177  const Xfer<cellList>& clst
178 )
179 {
180  reset
181  (
182  nPoints,
183  nInternalFaces,
184  nFaces,
185  nCells
186  );
187 
188  cfPtr_ = new cellList(clst);
189 }
190 
191 
193 (
194  const pointField& newPoints,
195  const pointField& oldPoints
196 )
197 {
198  if (newPoints.size() < nPoints() || oldPoints.size() < nPoints())
199  {
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  }
211 
212  // Create swept volumes
213  const faceList& f = faces();
214 
215  tmp<scalarField> tsweptVols(new scalarField(f.size()));
216  scalarField& sweptVols = tsweptVols();
217 
218  forAll(f, faceI)
219  {
220  sweptVols[faceI] = f[faceI].sweptVol(oldPoints, newPoints);
221  }
222 
223  // Force recalculation of all geometric data with new points
224  clearGeom();
225 
226  return tsweptVols;
227 }
228 
229 
231 {
232  if (!cellShapesPtr_)
233  {
234  calcCellShapes();
235  }
236 
237  return *cellShapesPtr_;
238 }
239 
240 
241 // ************************************************************************* //
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:48
defineTypeNameAndDebug
defineTypeNameAndDebug(Foam::primitiveMesh, 0)
Foam::primitiveMesh::primitiveMesh
primitiveMesh()
Construct null.
Definition: primitiveMesh.C:36
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::primitiveMesh::~primitiveMesh
virtual ~primitiveMesh()
Definition: primitiveMesh.C:112
demandDrivenData.H
Template functions to aid in the implementation of demand driven data.
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::Xfer
A simple container for copying or transferring objects of type <T>.
Definition: Xfer.H:85
nPoints
label nPoints
Definition: gmvOutputHeader.H:2
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
primitiveMesh.H
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::cellList
List< cell > cellList
list of cells
Definition: cellList.H:42
Foam::FatalError
error FatalError
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::primitiveMesh::cellShapes
const cellShapeList & cellShapes() const
Return cell shapes.
Definition: primitiveMesh.C:230
Foam::Pout
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
f
labelList f(nPoints)
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::primitiveMesh::movePoints
tmp< scalarField > movePoints(const pointField &p, const pointField &oldP)
Move points, returns volumes swept by faces in motion.
Definition: primitiveMesh.C:193
Foam::primitiveMesh::reset
void reset(const label nPoints, const label nInternalFaces, const label nFaces, const label nCells)
Reset this primitiveMesh given the primitive array sizes.
Definition: primitiveMesh.C:121
FatalErrorIn
#define FatalErrorIn(functionName)
Report an error message using Foam::FatalError.
Definition: error.H:313
Foam::List::size
void size(const label)
Override size to be inconsistent with allocated storage.
Foam::primitiveMesh
Cell-face mesh analysis engine.
Definition: primitiveMesh.H:79