gradingDescriptors.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) 2015 OpenFOAM Foundation
9 Copyright (C) 2019-2020 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 "gradingDescriptors.H"
30
31// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32
34:
36{}
37
38
40(
41 const label len
42)
43:
45{}
46
47
49:
51{}
52
53
54// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
55
57{
58 for (gradingDescriptor& gd : *this)
59 {
60 gd.correct();
61 }
62}
63
64
66{
67 scalar sumBlockFraction = 0;
68 scalar sumNDivFraction = 0;
69
70 for (const gradingDescriptor& gd : *this)
71 {
72 sumBlockFraction += gd.blockFraction_;
73 sumNDivFraction += gd.nDivFraction_;
74 }
75
76 for (gradingDescriptor& gd : *this)
77 {
78 gd.blockFraction_ /= sumBlockFraction;
79 gd.nDivFraction_ /= sumNDivFraction;
80 gd.correct();
81 }
82}
83
84
86{
87 gradingDescriptors ret(*this);
88
89 forAll(ret, i)
90 {
91 ret[i] = operator[](ret.size() - i - 1).inv();
92 }
93
94 return ret;
95}
96
97
98// * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
99
101{
102 // Examine next token
103 token t(is);
104
105 if (t.isNumber())
106 {
108 gds.correct();
109 }
110 else
111 {
112 is.putBack(t);
113
114 // Read the list for gradingDescriptors
115 is >> static_cast<List<gradingDescriptor>&>(gds);
116
117 gds.normalise();
118 }
119
121 return is;
122}
123
124
125// ************************************************************************* //
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:58
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
void putBack(const token &tok)
Put back a token. Only a single put back is permitted.
Definition: Istream.C:70
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: List.H:77
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
Handles the specification for grading within a section of a block.
void correct()
Adjust expansion ratio.
List of gradingDescriptor for the sections of a block with additional IO functionality.
void correct()
Adjust expansion ratios.
gradingDescriptors()
Default construct with a single default gradingDescriptor.
gradingDescriptors inv() const
Return the inverse gradingDescriptors with 1/expansionRatio.
A token holds an item read from Istream.
Definition: token.H:69
bool isNumber() const noexcept
Token is LABEL, FLOAT or DOUBLE.
Definition: tokenI.H:587
scalar number() const
Return label, float or double value.
Definition: tokenI.H:593
#define FUNCTION_NAME
Istream & operator>>(Istream &, directionInfo &)
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333