wallNormalInfo.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 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 
28 #include "wallNormalInfo.H"
29 
30 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
31 
32 Foam::Ostream& Foam::operator<<
33 (
34  Foam::Ostream& os,
35  const Foam::wallNormalInfo& wDist
36 )
37 {
38  if (os.format() == IOstream::ASCII)
39  {
40  os << wDist.normal();
41  }
42  else
43  {
44  os.write
45  (
46  reinterpret_cast<const char*>(&wDist.normal_),
47  sizeof(vector)
48  );
49  }
50 
51  os.check(FUNCTION_NAME);
52  return os;
53 }
54 
55 
57 {
58  if (is.format() == IOstream::ASCII)
59  {
60  is >> wDist.normal_;
61  }
62  else if (!is.checkLabelSize<>() || !is.checkScalarSize<>())
63  {
64  // Non-native label or scalar size
65  is.beginRawRead();
66 
67  readRawScalar(is, wDist.normal_.data(), vector::nComponents);
68 
69  is.endRawRead();
70  }
71  else
72  {
73  is.read
74  (
75  reinterpret_cast<char*>(&wDist.normal_),
76  sizeof(vector)
77  );
78  }
79 
80  is.check(FUNCTION_NAME);
81  return is;
82 }
83 
84 
85 // ************************************************************************* //
Foam::IOstreamOption::format
streamFormat format() const noexcept
Get the current stream format.
Definition: IOstreamOption.H:273
Foam::VectorSpace::data
Cmpt * data() noexcept
Return pointer to the first data element.
Definition: VectorSpaceI.H:198
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:228
Foam::Istream::endRawRead
virtual bool endRawRead()=0
End of low-level raw binary read.
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::IOstream::checkLabelSize
std::enable_if< std::is_integral< T >::value, bool >::type checkLabelSize() const
Definition: IOstream.H:283
Foam::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:51
Foam::Ostream::write
virtual bool write(const token &tok)=0
Write token to stream or otherwise handle it.
wallNormalInfo.H
Foam::Istream::beginRawRead
virtual bool beginRawRead()=0
Start of low-level raw binary read.
Foam::IOstream::checkScalarSize
std::enable_if< std::is_floating_point< T >::value, bool >::type checkScalarSize() const
Definition: IOstream.H:292
Foam::Vector< scalar >
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:261
Foam::wallNormalInfo
Holds information regarding nearest wall point. Used in wall refinement.
Definition: wallNormalInfo.H:65
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::Istream::read
virtual Istream & read(token &)=0
Return next token from stream.