The open source CFD toolbox
refineCell.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-------------------------------------------------------------------------------
11 This file is part of OpenFOAM.
12
13 OpenFOAM is free software: you can redistribute it and/or modify it
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 "refineCell.H"
29#include "error.H"
30
31// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32
34:
35 cellNo_(-1),
36 direction_(Zero)
37{}
38
39
41:
42 cellNo_(celli),
43 direction_(direction)
44{
45 scalar magDir = mag(direction_);
46
47 if (magDir < SMALL)
48 {
50 << "(almost)zero vector as direction for cell " << cellNo_
51 << abort(FatalError);
52 }
53 else if (mag(magDir - 1) > SMALL)
54 {
55 // Normalize
56 direction_ /= mag(direction_);
57 }
58}
59
60
62:
64 direction_(is)
65{
66 scalar magDir = mag(direction_);
67
68 if (magDir < SMALL)
69 {
71 << "(almost)zero vector as direction for cell " << cellNo_
72 << abort(FatalError);
73 }
74 else if (mag(magDir - 1) > SMALL)
75 {
76 // Normalize
77 direction_ /= mag(direction_);
78 }
79}
80
81
82// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
83
85{
86 if (os.format() == IOstream::ASCII)
87 {
88 os << r.cellNo() << token::SPACE << r.direction();
89 }
90 else
91 {
92 os << r.cellNo() << r.direction();
93 }
94 return os;
95}
96
97
98// ************************************************************************* //
streamFormat format() const noexcept
Get the current stream format.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Container with cells to refine. Refinement given as single direction.
Definition: refineCell.H:57
refineCell()
Default construct.
Definition: refineCell.C:33
const vector & direction() const
Definition: refineCell.H:88
label cellNo() const
Definition: refineCell.H:83
@ SPACE
Space [isspace].
Definition: token.H:125
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
OBJstream os(runTime.globalPath()/outputName)