extendedFeatureEdgeMesh.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) 2011-2015 OpenFOAM Foundation
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 \*---------------------------------------------------------------------------*/
25 
27 #include "Time.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33  defineTypeNameAndDebug(extendedFeatureEdgeMesh, 0);
34 }
35 
36 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
37 
39 :
40  regIOobject(io),
42 {
43  if
44  (
48  )
49  {
51  {
53  << "Specified IOobject::MUST_READ_IF_MODIFIED but class"
54  << " does not support automatic rereading."
55  << endl;
56  }
57 
58  readStream(typeName) >> *this;
59  close();
60 
61  {
62  // Calculate edgeDirections
63 
64  const edgeList& eds(edges());
65 
66  const pointField& pts(points());
67 
69 
70  forAll(eds, eI)
71  {
72  edgeDirections_[eI] = eds[eI].vec(pts);
73  }
74 
75  edgeDirections_ /= (mag(edgeDirections_) + SMALL);
76  }
77  }
78 
79  if (debug)
80  {
81  Pout<< "extendedFeatureEdgeMesh::extendedFeatureEdgeMesh :"
82  << " constructed from IOobject :"
83  << " points:" << points().size()
84  << " edges:" << edges().size()
85  << endl;
86  }
87 }
88 
89 
91 (
92  const IOobject& io,
93  const extendedEdgeMesh& em
94 )
95 :
96  regIOobject(io),
98 {}
99 
100 
102 (
103  const surfaceFeatures& sFeat,
104  const objectRegistry& obr,
105  const fileName& sFeatFileName,
106  const boolList& surfBaffleRegions
107 )
108 :
110  (
111  IOobject
112  (
113  sFeatFileName,
114  obr.time().constant(),
115  "extendedFeatureEdgeMesh",
116  obr,
119  )
120  ),
121  extendedEdgeMesh(sFeat, surfBaffleRegions)
122 {}
123 
124 
126 (
127  const IOobject& io,
129  const labelList& featureEdges,
130  const labelList& regionFeatureEdges,
131  const labelList& featurePoints
132 )
133 :
134  regIOobject(io),
135  extendedEdgeMesh(surf, featureEdges, regionFeatureEdges, featurePoints)
136 {}
137 
138 
140 (
141  const IOobject& io,
142  const pointField& pts,
143  const edgeList& eds,
144  label concaveStart,
145  label mixedStart,
146  label nonFeatureStart,
147  label internalStart,
148  label flatStart,
149  label openStart,
150  label multipleStart,
151  const vectorField& normals,
152  const List<sideVolumeType>& normalVolumeTypes,
153  const vectorField& edgeDirections,
154  const labelListList& normalDirections,
155  const labelListList& edgeNormals,
156  const labelListList& featurePointNormals,
157  const labelListList& featurePointEdges,
158  const labelList& regionEdges
159 )
160 :
161  regIOobject(io),
163  (
164  pts,
165  eds,
166  concaveStart,
167  mixedStart,
168  nonFeatureStart,
169  internalStart,
170  flatStart,
171  openStart,
172  multipleStart,
173  normals,
174  normalVolumeTypes,
175  edgeDirections,
176  normalDirections,
177  edgeNormals,
178  featurePointNormals,
179  featurePointEdges,
180  regionEdges
181  )
182 {}
183 
184 
185 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
186 
188 {}
189 
190 
191 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
192 
193 
194 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
195 
197 {
198  is >> *this;
199  return !is.bad();
200 }
201 
202 
204 {
205  os << *this;
206 
207  return os.good();
208 }
209 
210 
211 
212 //bool Foam::extendedFeatureEdgeMesh::writeData(Ostream& os) const
213 //{
214 // os << "// points" << nl
215 // << points() << nl
216 // << "// edges" << nl
217 // << edges() << nl
218 // << "// concaveStart mixedStart nonFeatureStart" << nl
219 // << concaveStart_ << token::SPACE
220 // << mixedStart_ << token::SPACE
221 // << nonFeatureStart_ << nl
222 // << "// internalStart flatStart openStart multipleStart" << nl
223 // << internalStart_ << token::SPACE
224 // << flatStart_ << token::SPACE
225 // << openStart_ << token::SPACE
226 // << multipleStart_ << nl
227 // << "// normals" << nl
228 // << normals_ << nl
229 // << "// normal volume types" << nl
230 // << normalVolumeTypes_ << nl
231 // << "// normalDirections" << nl
232 // << normalDirections_ << nl
233 // << "// edgeNormals" << nl
234 // << edgeNormals_ << nl
235 // << "// featurePointNormals" << nl
236 // << featurePointNormals_ << nl
237 // << "// featurePointEdges" << nl
238 // << featurePointEdges_ << nl
239 // << "// regionEdges" << nl
240 // << regionEdges_
241 // << endl;
242 //
243 // return os.good();
244 //}
245 
246 //
247 //Foam::Istream& Foam::operator>>
248 //(
249 // Istream& is,
250 // Foam::extendedFeatureEdgeMesh::sideVolumeType& vt
251 //)
252 //{
253 // label type;
254 // is >> type;
255 //
256 // vt = static_cast<Foam::extendedFeatureEdgeMesh::sideVolumeType>(type);
257 //
258 // // Check state of Istream
259 // is.check("operator>>(Istream&, sideVolumeType&)");
260 //
261 // return is;
262 //}
263 //
264 //
265 //Foam::Ostream& Foam::operator<<
266 //(
267 // Ostream& os,
268 // const Foam::extendedFeatureEdgeMesh::sideVolumeType& vt
269 //)
270 //{
271 // os << static_cast<label>(vt);
272 //
273 // return os;
274 //}
275 //
276 
277 // ************************************************************************* //
extendedEdgeMesh()
Construct null.
const Time & time() const
Return time.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
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
A class for handling file names.
Definition: fileName.H:69
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
Description of feature edges and points.
bool good() const
Return true if next operation might succeed.
Definition: IOstream.H:333
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
virtual ~extendedFeatureEdgeMesh()
Destructor.
regIOobject(const IOobject &, const bool isTime=false)
Construct from IOobject. Optional flag for if IOobject is the.
Definition: regIOobject.C:119
const pointField & points() const
Return points.
Definition: edgeMeshI.H:39
A list of faces which address into the list of points.
Istream & readStream(const word &)
Return Istream and check object type against that given.
void close()
Close Istream.
const word & constant() const
Return constant name.
Definition: TimePaths.H:124
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
prefixOSstream Pout(cout,"Pout")
Definition: IOstreams.H:53
defineTypeNameAndDebug(combustionModel, 0)
bool bad() const
Return true if stream is corrupted.
Definition: IOstream.H:351
extendedFeatureEdgeMesh(const IOobject &)
Construct (read) given an IOobject.
void setSize(const label)
Reset size of List.
Definition: List.C:295
virtual bool writeData(Ostream &) const
WriteData function required for regIOobject write operation.
#define WarningInFunction
Report a warning using Foam::Warning.
const edgeList & edges() const
Return edges.
Definition: edgeMeshI.H:45
readOption readOpt() const
Definition: IOobject.H:304
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:60
dimensioned< scalar > mag(const dimensioned< Type > &)
bool headerOk()
Read and check header info.
Definition: IOobject.C:400
Registry of regIOobjects.
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
virtual bool readData(Istream &)
ReadData function required for regIOobject read operation.
vectorField edgeDirections_
Flat and open edges require the direction of the edge.
Holds feature edges/points of surface.
Namespace for OpenFOAM.