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-------------------------------------------------------------------------------
10License
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 "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:
63 cellNo_(readLabel(is)),
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)
label readLabel(const char *buf)
Parse entire buffer as a label, skipping leading/trailing whitespace.
Definition: label.H:66
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
errorManip< error > abort(error &err)
Definition: errorManip.H:144
uint8_t direction
Definition: direction.H:56
error FatalError