refineCell.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2021 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 
26 #include "refineCell.H"
27 #include "error.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
32 :
33  cellNo_(-1),
34  direction_(Zero)
35 {}
36 
37 
39 :
40  cellNo_(celli),
41  direction_(direction)
42 {
43  scalar magDir = mag(direction_);
44 
45  if (magDir < small)
46  {
48  << "(almost)zero vector as direction for cell " << cellNo_
49  << abort(FatalError);
50  }
51  else if (mag(magDir - 1) > small)
52  {
53  // Normalise
54  direction_ /= mag(direction_);
55  }
56 }
57 
58 
60 :
61  cellNo_(readLabel(is)),
62  direction_(is)
63 {
64  scalar magDir = mag(direction_);
65 
66  if (magDir < small)
67  {
69  << "(almost)zero vector as direction for cell " << cellNo_
70  << abort(FatalError);
71  }
72  else if (mag(magDir - 1) > small)
73  {
74  // Normalise
75  direction_ /= mag(direction_);
76  }
77 }
78 
79 
80 // * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
81 
83 {
84  if (os.format() == IOstream::ASCII)
85  {
86  os << r.cellNo() << token::SPACE << r.direction();
87  }
88  else
89  {
90  os << r.cellNo() << r.direction();
91  }
92  return os;
93 }
94 
95 
96 // ************************************************************************* //
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
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:323
refineCell()
Null.
Definition: refineCell.C:31
uint8_t direction
Definition: direction.H:45
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
const vector & direction() const
Definition: refineCell.H:87
static const zero Zero
Definition: zero.H:97
streamFormat format() const
Return current stream format.
Definition: IOstream.H:374
Container with cells to refine. Refinement given as single direction.
Definition: refineCell.H:56
errorManip< error > abort(error &err)
Definition: errorManip.H:131
label readLabel(Istream &is)
Definition: label.H:64
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
label cellNo() const
Definition: refineCell.H:82
Ostream & operator<<(Ostream &, const ensightPart &)
dimensioned< scalar > mag(const dimensioned< Type > &)