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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
29 #include "Time.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(extendedFeatureEdgeMesh, 0);
36 }
37 
38 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
39 
41 :
42  regIOobject(io),
44 {
45  if
46  (
50  )
51  {
52  // Warn for MUST_READ_IF_MODIFIED
53  warnNoRereading<extendedFeatureEdgeMesh>();
54 
55  readStream(typeName) >> *this;
56  close();
57 
58  {
59  // Calculate edgeDirections
60 
61  const edgeList& eds(edges());
62 
63  const pointField& pts(points());
64 
65  edgeDirections_.setSize(eds.size());
66 
67  forAll(eds, eI)
68  {
69  edgeDirections_[eI] = eds[eI].vec(pts);
70  }
71 
72  edgeDirections_ /= (mag(edgeDirections_) + SMALL);
73  }
74  }
75 
76  if (debug)
77  {
78  Pout<< "extendedFeatureEdgeMesh::extendedFeatureEdgeMesh :"
79  << " constructed from IOobject :"
80  << " points:" << points().size()
81  << " edges:" << edges().size()
82  << endl;
83  }
84 }
85 
86 
88 (
89  const IOobject& io,
90  const extendedEdgeMesh& em
91 )
92 :
93  regIOobject(io),
95 {}
96 
97 
99 (
100  const surfaceFeatures& sFeat,
101  const objectRegistry& obr,
102  const fileName& sFeatFileName,
103  const boolList& surfBaffleRegions
104 )
105 :
107  (
108  IOobject
109  (
110  sFeatFileName,
111  obr.time().constant(),
112  "extendedFeatureEdgeMesh",
113  obr,
116  )
117  ),
118  extendedEdgeMesh(sFeat, surfBaffleRegions)
119 {}
120 
121 
123 (
124  const IOobject& io,
126  const labelUList& featureEdges,
127  const labelUList& regionFeatureEdges,
128  const labelUList& featurePoints
129 )
130 :
131  regIOobject(io),
132  extendedEdgeMesh(surf, featureEdges, regionFeatureEdges, featurePoints)
133 {}
134 
135 
137 (
138  const IOobject& io,
139  const pointField& pts,
140  const edgeList& eds,
141  label concaveStart,
142  label mixedStart,
143  label nonFeatureStart,
144  label internalStart,
145  label flatStart,
146  label openStart,
147  label multipleStart,
148  const vectorField& normals,
149  const List<sideVolumeType>& normalVolumeTypes,
150  const vectorField& edgeDirections,
151  const labelListList& normalDirections,
152  const labelListList& edgeNormals,
153  const labelListList& featurePointNormals,
154  const labelListList& featurePointEdges,
155  const labelList& regionEdges
156 )
157 :
158  regIOobject(io),
160  (
161  pts,
162  eds,
163  concaveStart,
164  mixedStart,
165  nonFeatureStart,
166  internalStart,
167  flatStart,
168  openStart,
169  multipleStart,
170  normals,
171  normalVolumeTypes,
172  edgeDirections,
173  normalDirections,
174  edgeNormals,
175  featurePointNormals,
176  featurePointEdges,
177  regionEdges
178  )
179 {}
180 
181 
182 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
183 
185 {}
186 
187 
188 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
189 
191 {
192  is >> *this;
193  return !is.bad();
194 }
195 
196 
198 {
199  os << *this;
200  return os.good();
201 }
202 
203 
204 
205 //bool Foam::extendedFeatureEdgeMesh::writeData(Ostream& os) const
206 //{
207 // os << "// points" << nl
208 // << points() << nl
209 // << "// edges" << nl
210 // << edges() << nl
211 // << "// concaveStart mixedStart nonFeatureStart" << nl
212 // << concaveStart_ << token::SPACE
213 // << mixedStart_ << token::SPACE
214 // << nonFeatureStart_ << nl
215 // << "// internalStart flatStart openStart multipleStart" << nl
216 // << internalStart_ << token::SPACE
217 // << flatStart_ << token::SPACE
218 // << openStart_ << token::SPACE
219 // << multipleStart_ << nl
220 // << "// normals" << nl
221 // << normals_ << nl
222 // << "// normal volume types" << nl
223 // << normalVolumeTypes_ << nl
224 // << "// normalDirections" << nl
225 // << normalDirections_ << nl
226 // << "// edgeNormals" << nl
227 // << edgeNormals_ << nl
228 // << "// featurePointNormals" << nl
229 // << featurePointNormals_ << nl
230 // << "// featurePointEdges" << nl
231 // << featurePointEdges_ << nl
232 // << "// regionEdges" << nl
233 // << regionEdges_
234 // << endl;
235 //
236 // return os.good();
237 //}
238 
239 //
240 //Foam::Istream& Foam::operator>>
241 //(
242 // Istream& is,
243 // Foam::extendedFeatureEdgeMesh::sideVolumeType& vt
244 //)
245 //{
246 // label type;
247 // is >> type;
248 //
249 // vt = static_cast<Foam::extendedFeatureEdgeMesh::sideVolumeType>(type);
250 //
251 // is.check(FUNCTION_NAME);
252 // return is;
253 //}
254 //
255 //
256 //Foam::Ostream& Foam::operator<<
257 //(
258 // Ostream& os,
259 // const Foam::extendedFeatureEdgeMesh::sideVolumeType& vt
260 //)
261 //{
262 // os << static_cast<label>(vt);
263 //
264 // return os;
265 //}
266 
267 
268 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::IOobject::NO_WRITE
Definition: IOobject.H:130
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:104
Foam::extendedFeatureEdgeMesh::writeData
virtual bool writeData(Ostream &) const
WriteData function required for regIOobject write operation.
Definition: extendedFeatureEdgeMesh.C:197
Foam::fileName
A class for handling file names.
Definition: fileName.H:69
Foam::objectRegistry::time
const Time & time() const
Return time.
Definition: objectRegistry.H:186
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
Foam::Pout
prefixOSstream Pout
An Ostream wrapper for parallel output to std::cout.
extendedFeatureEdgeMesh.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
Foam::objectRegistry
Registry of regIOobjects.
Definition: objectRegistry.H:60
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:62
Foam::Field< vector >
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::extendedEdgeMesh::edgeDirections_
vectorField edgeDirections_
Flat and open edges require the direction of the edge.
Definition: extendedEdgeMesh.H:174
Foam::edgeMesh::points
const pointField & points() const
Return points.
Definition: edgeMeshI.H:99
Foam::IOobject::READ_IF_PRESENT
Definition: IOobject.H:122
Foam::surfaceFeatures
Holds feature edges/points of surface.
Definition: surfaceFeatures.H:73
Foam::edgeMesh::edges
const edgeList & edges() const
Return edges.
Definition: edgeMeshI.H:105
Foam::IOstream::bad
bool bad() const
Return true if stream is corrupted.
Definition: IOstream.H:234
Foam::extendedFeatureEdgeMesh::extendedFeatureEdgeMesh
extendedFeatureEdgeMesh(const IOobject &)
Construct (read) given an IOobject.
Definition: extendedFeatureEdgeMesh.C:40
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Time.H
Foam::extendedEdgeMesh
Description of feature edges and points.
Definition: extendedEdgeMesh.H:86
Foam::regIOobject
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:67
Foam::extendedFeatureEdgeMesh::~extendedFeatureEdgeMesh
virtual ~extendedFeatureEdgeMesh()
Destructor.
Definition: extendedFeatureEdgeMesh.C:184
Foam::regIOobject::close
void close()
Close Istream.
Definition: regIOobjectRead.C:182
Foam::List< edge >
Foam::IOobject::readOpt
readOption readOpt() const
The read option.
Definition: IOobjectI.H:141
Foam::extendedFeatureEdgeMesh::readData
virtual bool readData(Istream &)
ReadData function required for regIOobject read operation.
Definition: extendedFeatureEdgeMesh.C:190
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::UList< label >
Foam::IOobject::MUST_READ_IF_MODIFIED
Definition: IOobject.H:121
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::regIOobject::readStream
Istream & readStream(const word &, const bool valid=true)
Return Istream and check object type against that given.
Definition: regIOobjectRead.C:140
Foam::IOstream::good
bool good() const
Return true if next operation might succeed.
Definition: IOstream.H:216
Foam::TimePaths::constant
const word & constant() const
Return constant name.
Definition: TimePathsI.H:88
Foam::IOobject::NO_READ
Definition: IOobject.H:123
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::regIOobject::headerOk
bool headerOk()
Read and check header info.
Definition: regIOobject.C:449
Foam::PrimitivePatch
A list of faces which address into the list of points.
Definition: PrimitivePatch.H:90
Foam::IOobject::MUST_READ
Definition: IOobject.H:120