FreeFOAM The Cross-Platform CFD Toolkit
blockMesh.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 1991-2010 OpenCFD Ltd.
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Application
25  blockMesh
26 
27 Description
28  Mesh generator
29 
30 \*---------------------------------------------------------------------------*/
31 
32 #include "blockMesh.H"
33 
34 
35 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
36 
37 // Construct from IOdictionary
38 Foam::blockMesh::blockMesh(IOdictionary& meshDescription)
39 :
40  topologyPtr_(createTopology(meshDescription)),
41  blockOffsets_(createBlockOffsets()),
42  mergeList_(createMergeList()),
43  points_(createPoints(meshDescription)),
44  cells_(createCells()),
45  patches_(createPatches())
46 {}
47 
48 
49 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
50 
52 {
53  delete topologyPtr_;
54 }
55 
56 
57 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
58 
60 {
61  if (!topologyPtr_)
62  {
63  FatalErrorIn("blockMesh::topology() const")
64  << "topologyPtr_ not allocated"
65  << exit(FatalError);
66  }
67 
68  return *topologyPtr_;
69 }
70 
71 
73 {
74  const polyPatchList& patchTopologies = topology().boundaryMesh();
75  wordList names(patchTopologies.size());
76 
77  forAll (names, patchI)
78  {
79  names[patchI] = patchTopologies[patchI].name();
80  }
81 
82  return names;
83 }
84 
85 
87 {
88  const polyPatchList& patchTopologies = topology().boundaryMesh();
89  wordList types(patchTopologies.size());
90 
91  forAll (types, patchI)
92  {
93  types[patchI] = patchTopologies[patchI].type();
94  }
95 
96  return types;
97 }
98 
99 
101 {
102  const polyPatchList& patchTopologies = topology().boundaryMesh();
103  wordList physicalTypes(patchTopologies.size());
104 
105  forAll (physicalTypes, patchI)
106  {
107  physicalTypes[patchI] = patchTopologies[patchI].physicalType();
108  }
109 
110  return physicalTypes;
111 }
112 
113 
114 Foam::label Foam::blockMesh::numZonedBlocks() const
115 {
116  label num = 0;
117 
118  forAll(*this, blockI)
119  {
120  if (operator[](blockI).blockDef().zoneName().size())
121  {
122  num++;
123  }
124  }
125 
126  return num;
127 }
128 
129 
130 void Foam::blockMesh::writeTopology(Ostream& os) const
131 {
132  const pointField& pts = topology().points();
133 
134  forAll(pts, pI)
135  {
136  const point& pt = pts[pI];
137 
138  os << "v " << pt.x() << ' ' << pt.y() << ' ' << pt.z() << endl;
139  }
140 
141  const edgeList& edges = topology().edges();
142 
143  forAll(edges, eI)
144  {
145  const edge& e = edges[eI];
146 
147  os << "l " << e.start() + 1 << ' ' << e.end() + 1 << endl;
148  }
149 }
150 
151 // ************************ vim: set sw=4 sts=4 et: ************************ //