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-2022 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 {
37 }
38 
39 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 
42 :
43  regIOobject(io),
45 {
46  if (isReadRequired() || (isReadOptional() && headerOk()))
47  {
48  // Warn for MUST_READ_IF_MODIFIED
49  warnNoRereading<extendedFeatureEdgeMesh>();
50 
51  readStream(typeName) >> *this;
52  close();
53 
54  {
55  // Calculate edgeDirections
56 
57  const edgeList& eds(edges());
58 
59  const pointField& pts(points());
60 
62 
63  forAll(eds, eI)
64  {
65  edgeDirections_[eI] = eds[eI].vec(pts);
66  }
67 
68  edgeDirections_ /= (mag(edgeDirections_) + SMALL);
69  }
70  }
71 
72  if (debug)
73  {
74  Pout<< "extendedFeatureEdgeMesh::extendedFeatureEdgeMesh :"
75  << " constructed from IOobject :"
76  << " points:" << points().size()
77  << " edges:" << edges().size()
78  << endl;
79  }
80 }
81 
82 
84 (
85  const IOobject& io,
86  const extendedEdgeMesh& em
87 )
88 :
89  regIOobject(io),
91 {}
92 
93 
95 (
96  const surfaceFeatures& sFeat,
97  const objectRegistry& obr,
98  const fileName& sFeatFileName,
99  const boolList& surfBaffleRegions
100 )
101 :
103  (
104  IOobject
105  (
106  sFeatFileName,
107  obr.time().constant(),
108  "extendedFeatureEdgeMesh",
109  obr,
110  IOobject::NO_READ,
111  IOobject::NO_WRITE
112  )
113  ),
114  extendedEdgeMesh(sFeat, surfBaffleRegions)
115 {}
116 
117 
119 (
120  const IOobject& io,
122  const labelUList& featureEdges,
123  const labelUList& regionFeatureEdges,
124  const labelUList& featurePoints
125 )
126 :
127  regIOobject(io),
128  extendedEdgeMesh(surf, featureEdges, regionFeatureEdges, featurePoints)
129 {}
130 
131 
133 (
134  const IOobject& io,
135  const pointField& pts,
136  const edgeList& eds,
137  label concaveStart,
138  label mixedStart,
139  label nonFeatureStart,
140  label internalStart,
141  label flatStart,
142  label openStart,
143  label multipleStart,
144  const vectorField& normals,
145  const List<sideVolumeType>& normalVolumeTypes,
146  const vectorField& edgeDirections,
147  const labelListList& normalDirections,
148  const labelListList& edgeNormals,
149  const labelListList& featurePointNormals,
150  const labelListList& featurePointEdges,
151  const labelList& regionEdges
152 )
153 :
154  regIOobject(io),
156  (
157  pts,
158  eds,
159  concaveStart,
160  mixedStart,
161  nonFeatureStart,
162  internalStart,
163  flatStart,
164  openStart,
165  multipleStart,
166  normals,
167  normalVolumeTypes,
168  edgeDirections,
169  normalDirections,
170  edgeNormals,
171  featurePointNormals,
172  featurePointEdges,
173  regionEdges
174  )
175 {}
176 
177 
178 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
179 
181 {
182  is >> *this;
183  return !is.bad();
184 }
185 
186 
188 {
189  os << *this;
190  return os.good();
191 }
192 
193 
194 
195 //bool Foam::extendedFeatureEdgeMesh::writeData(Ostream& os) const
196 //{
197 // os << "// points" << nl
198 // << points() << nl
199 // << "// edges" << nl
200 // << edges() << nl
201 // << "// concaveStart mixedStart nonFeatureStart" << nl
202 // << concaveStart_ << token::SPACE
203 // << mixedStart_ << token::SPACE
204 // << nonFeatureStart_ << nl
205 // << "// internalStart flatStart openStart multipleStart" << nl
206 // << internalStart_ << token::SPACE
207 // << flatStart_ << token::SPACE
208 // << openStart_ << token::SPACE
209 // << multipleStart_ << nl
210 // << "// normals" << nl
211 // << normals_ << nl
212 // << "// normal volume types" << nl
213 // << normalVolumeTypes_ << nl
214 // << "// normalDirections" << nl
215 // << normalDirections_ << nl
216 // << "// edgeNormals" << nl
217 // << edgeNormals_ << nl
218 // << "// featurePointNormals" << nl
219 // << featurePointNormals_ << nl
220 // << "// featurePointEdges" << nl
221 // << featurePointEdges_ << nl
222 // << "// regionEdges" << nl
223 // << regionEdges_
224 // << endl;
225 //
226 // return os.good();
227 //}
228 
229 //
230 //Foam::Istream& Foam::operator>>
231 //(
232 // Istream& is,
233 // Foam::extendedFeatureEdgeMesh::sideVolumeType& vt
234 //)
235 //{
236 // label type;
237 // is >> type;
238 //
239 // vt = static_cast<Foam::extendedFeatureEdgeMesh::sideVolumeType>(type);
240 //
241 // is.check(FUNCTION_NAME);
242 // return is;
243 //}
244 //
245 //
246 //Foam::Ostream& Foam::operator<<
247 //(
248 // Ostream& os,
249 // const Foam::extendedFeatureEdgeMesh::sideVolumeType& vt
250 //)
251 //{
252 // os << static_cast<label>(vt);
253 //
254 // return os;
255 //}
256 
257 
258 // ************************************************************************* //
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:116
A class for handling file names.
Definition: fileName.H:72
bool bad() const noexcept
True if stream is corrupted.
Definition: IOstream.H:305
const pointField & points() const noexcept
Return points.
Definition: edgeMeshI.H:92
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Description of feature edges and points.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:531
bool headerOk()
Read and check header info. Does not check the headerClassName.
Definition: regIOobject.C:505
bool isReadOptional() const noexcept
True if (LAZY_READ) bits are set [same as READ_IF_PRESENT].
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
A list of faces which address into the list of points.
void setSize(const label n)
Alias for resize()
Definition: List.H:316
void close()
Close Istream.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
int debug
Static debugging option.
OBJstream os(runTime.globalPath()/outputName)
defineTypeNameAndDebug(combustionModel, 0)
bool isReadRequired() const noexcept
True if (MUST_READ | READ_MODIFIED) bits are set.
virtual bool writeData(Ostream &) const
WriteData function required for regIOobject write operation.
bool good() const noexcept
True if next operation might succeed.
Definition: IOstream.H:281
const edgeList & edges() const noexcept
Return edges.
Definition: edgeMeshI.H:98
extendedFeatureEdgeMesh(const IOobject &io)
Construct (read) given an IOobject.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:66
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Registry of regIOobjects.
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
virtual bool readData(Istream &)
ReadData function required for regIOobject read operation.
vectorField edgeDirections_
Flat and open edges require the direction of the edge.
prefixOSstream Pout
OSstream wrapped stdout (std::cout) with parallel prefix.
Holds feature edges/points of surface.
Namespace for OpenFOAM.
const pointField & pts