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