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