Loading...
Searching...
No Matches
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 Copyright (C) 2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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
29#include "refineCell.H"
30#include "error.H"
31
32// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33
35:
36 cellNo_(-1),
37 direction_(Zero)
38{}
39
40
41Foam::refineCell::refineCell(const label celli, const vector& direction)
42:
43 cellNo_(celli),
44 direction_(direction)
45{
46 scalar magDir = mag(direction_);
47
48 if (magDir < SMALL)
49 {
51 << "(almost)zero vector as direction for cell " << cellNo_
52 << abort(FatalError);
53 }
54 else if (mag(magDir - 1) > SMALL)
55 {
56 // Normalize
57 direction_ /= mag(direction_);
58 }
59}
60
61
63:
64 cellNo_(readLabel(is)),
65 direction_(is)
66{
67 scalar magDir = mag(direction_);
68
69 if (magDir < SMALL)
70 {
72 << "(almost)zero vector as direction for cell " << cellNo_
73 << abort(FatalError);
74 }
75 else if (mag(magDir - 1) > SMALL)
76 {
77 // Normalize
78 direction_ /= mag(direction_);
79 }
80}
81
82
83// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
84
85Foam::Ostream& Foam::operator<<(Ostream& os, const refineCell& r)
86{
88 {
89 os << r.cellNo() << token::SPACE << r.direction();
90 }
91 else
92 {
93 os << r.cellNo() << r.direction();
94 }
95 return os;
96}
97
98
99// ************************************************************************* //
streamFormat format() const noexcept
Get the current stream format.
@ ASCII
"ascii" (normal default)
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition Ostream.H:59
Container with cells to refine. Refinement given as single direction.
Definition refineCell.H:53
refineCell()
Default construct.
Definition refineCell.C:27
const vector & direction() const
Definition refineCell.H:94
label cellNo() const
Definition refineCell.H:89
@ SPACE
Space [isspace].
Definition token.H:144
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
OBJstream os(runTime.globalPath()/outputName)
label readLabel(const char *buf)
Parse entire buffer as a label, skipping leading/trailing whitespace.
Definition label.H:63
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces).
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
errorManip< error > abort(error &err)
Definition errorManip.H:139
uint8_t direction
Definition direction.H:49
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
Vector< scalar > vector
Definition vector.H:57