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 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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  List<gradingDescriptor>(1, gd)
42 {}
43 
44 
45 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
46 
48 {
49  gradingDescriptors ret(*this);
50 
51  forAll(ret, i)
52  {
53  ret[i] = operator[](ret.size() - i - 1).inv();
54  }
55 
56  return ret;
57 }
58 
59 
60 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
61 
63 {
64  // Examine next token
65  token t(is);
66 
67  if (t.isNumber())
68  {
70  }
71  else
72  {
73  is.putBack(t);
74 
75  // Read the list for gradingDescriptors
76  is >> static_cast<List<gradingDescriptor>&>(gds);
77 
78  // Check state of Istream
79  is.check(FUNCTION_NAME);
80 
81  // Normalize the blockFractions and nDivFractions
82  // of the list of gradingDescriptors
83 
84  scalar sumBlockFraction = 0;
85  scalar sumNDivFraction = 0;
86 
87  forAll(gds, i)
88  {
89  sumBlockFraction += gds[i].blockFraction_;
90  sumNDivFraction += gds[i].nDivFraction_;
91  }
92 
93  forAll(gds, i)
94  {
95  gds[i].blockFraction_ /= sumBlockFraction;
96  gds[i].nDivFraction_ /= sumNDivFraction;
97  }
98  }
99 
100  return is;
101 }
102 
103 
104 // ************************************************************************* //
Foam::token::isNumber
bool isNumber() const
Token is LABEL, FLOAT_SCALAR or DOUBLE_SCALAR.
Definition: tokenI.H:530
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:228
Foam::token
A token holds an item read from Istream.
Definition: token.H:69
Foam::gradingDescriptors
List of gradingDescriptor for the sections of a block with additional IO functionality.
Definition: gradingDescriptors.H:58
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
gradingDescriptors.H
Foam::gradingDescriptors::gradingDescriptors
gradingDescriptors()
Default constructor.
Definition: gradingDescriptors.C:33
Foam::token::number
scalar number() const
Return label, float or double value.
Definition: tokenI.H:536
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::inv
dimensionedSphericalTensor inv(const dimensionedSphericalTensor &dt)
Definition: dimensionedSphericalTensor.C:73
Foam::IOstream::check
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:51
Foam::gradingDescriptors::inv
gradingDescriptors inv() const
Return the inverse gradingDescriptors with 1/expansionRatio.
Definition: gradingDescriptors.C:47
Foam::gradingDescriptor
Handles the specification for grading within a section of a block.
Definition: gradingDescriptor.H:72
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:102
Foam::Istream::putBack
void putBack(const token &tok)
Put back token.
Definition: Istream.C:53
FUNCTION_NAME
#define FUNCTION_NAME
Definition: messageStream.H:261