All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
gradingDescriptors.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2015-2018 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "gradingDescriptors.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
31 :
33 {}
34 
35 
37 :
38  List<gradingDescriptor>(1, gd)
39 {}
40 
41 
42 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
43 
45 {
46  gradingDescriptors ret(*this);
47 
48  forAll(ret, i)
49  {
50  ret[i] = operator[](ret.size() - i - 1).inv();
51  }
52 
53  return ret;
54 }
55 
56 
57 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
58 
60 {
61  // Examine next token
62  token t(is);
63 
64  if (t.isNumber())
65  {
67  }
68  else
69  {
70  is.putBack(t);
71 
72  // Read the list for gradingDescriptors
73  is >> static_cast<List<gradingDescriptor>& >(gds);
74 
75  // Check state of Istream
76  is.check("operator>>(Istream&, gradingDescriptor&)");
77 
78  // Normalize the blockFractions and nDivFractions
79  // of the list of gradingDescriptors
80 
81  scalar sumBlockFraction = 0;
82  scalar sumNDivFraction = 0;
83 
84  forAll(gds, i)
85  {
86  sumBlockFraction += gds[i].blockFraction_;
87  sumNDivFraction += gds[i].nDivFraction_;
88  }
89 
90  forAll(gds, i)
91  {
92  gds[i].blockFraction_ /= sumBlockFraction;
93  gds[i].nDivFraction_ /= sumNDivFraction;
94  }
95  }
96 
97  return is;
98 }
99 
100 
101 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
T & operator[](const label)
Return element of UList.
Definition: UListI.H:167
virtual bool check(const char *operation) const
Check IOstream status for given operation.
Definition: IOstream.C:92
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
scalar number() const
Definition: tokenI.H:503
gradingDescriptors inv() const
Return the inverse gradingDescriptors with 1/expansionRatio.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
A token holds items read from Istream.
Definition: token.H:72
void putBack(const token &)
Put back token.
Definition: Istream.C:30
gradingDescriptors()
Default constructor.
bool isNumber() const
Definition: tokenI.H:498
Istream & operator>>(Istream &, directionInfo &)
Handles the specification for grading within a section of a block.
List of gradingDescriptor for the sections of a block with additional IO functionality.