gradingDescriptor.H
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 -------------------------------------------------------------------------------
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 Class
28  Foam::gradingDescriptor
29 
30 Description
31  Handles the specification for grading within a section of a block
32 
33  The grading specification is handled is controlled by three parameters:
34 
35  - blockFraction: the fraction of the block the section occupies
36 
37  - nDivFraction: the fraction of the divisions of the block allocated to
38  the section
39 
40  - expansionRatio:
41  the expansion ratio for the grading with the section of
42  block defined as the ratio of end-size / start-size for the section.
43  A negative value is trapped and treated as its inverse.
44 
45 SourceFiles
46  gradingDescriptor.C
47 
48 \*---------------------------------------------------------------------------*/
49 
50 #ifndef gradingDescriptor_H
51 #define gradingDescriptor_H
52 
53 #include "scalar.H"
54 
55 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
56 
57 namespace Foam
58 {
59 
60 // Forward Declarations
61 class Istream;
62 class Ostream;
63 class gradingDescriptor;
64 class gradingDescriptors;
65 
66 Istream& operator>>(Istream&, gradingDescriptor&);
67 Ostream& operator<<(Ostream&, const gradingDescriptor&);
68 
69 /*---------------------------------------------------------------------------*\
70  Class gradingDescriptor Declaration
71 \*---------------------------------------------------------------------------*/
72 
74 {
75  // Private Data
76 
77  scalar blockFraction_;
78  scalar nDivFraction_;
79  scalar expansionRatio_;
80 
81 
82 public:
83 
84  // Friendship with gradingDescriptors
85  friend class gradingDescriptors;
86 
87 
88  // Constructors
89 
90  //- Default construct (1, 1, 1)
92 
93  //- Construct from components
95  (
96  const scalar blockFraction,
97  const scalar nDivFraction,
98  const scalar expansionRatio
99  );
100 
101  //- Construct from expansionRatio
102  explicit gradingDescriptor(const scalar expansionRatio);
103 
104  //- Construct from Istream
105  explicit gradingDescriptor(Istream& is);
106 
107 
108  //- Destructor
109  ~gradingDescriptor() = default;
110 
111 
112  // Member Functions
113 
114  scalar blockFraction() const
115  {
116  return blockFraction_;
117  }
118 
119  scalar nDivFraction() const
120  {
121  return nDivFraction_;
122  }
123 
124  scalar expansionRatio() const
125  {
126  return expansionRatio_;
127  }
128 
129  //- Adjust expansion ratio.
130  // Trap negative value and treat as its inverse.
131  void correct();
132 
133  //- Return the inverse gradingDescriptor with 1/expansionRatio
134  gradingDescriptor inv() const;
135 
136 
137  // Member Operators
138 
139  bool operator==(const gradingDescriptor&) const;
140  bool operator!=(const gradingDescriptor&) const;
141 
142 
143  // IOstream Operators
144 
146  friend Ostream& operator<<(Ostream&, const gradingDescriptor&);
147 };
148 
149 
150 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
151 
152 } // End namespace Foam
153 
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 
156 #endif
157 
158 // ************************************************************************* //
Foam::gradingDescriptor::inv
gradingDescriptor inv() const
Return the inverse gradingDescriptor with 1/expansionRatio.
Definition: gradingDescriptor.C:88
Foam::operator>>
Istream & operator>>(Istream &, directionInfo &)
Definition: directionInfo.C:230
Foam::gradingDescriptors
List of gradingDescriptor for the sections of a block with additional IO functionality.
Definition: gradingDescriptors.H:58
Foam::gradingDescriptor::expansionRatio
scalar expansionRatio() const
Definition: gradingDescriptor.H:123
Foam::operator<<
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:83
Foam::gradingDescriptor::operator<<
friend Ostream & operator<<(Ostream &, const gradingDescriptor &)
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::gradingDescriptor::blockFraction
scalar blockFraction() const
Definition: gradingDescriptor.H:113
Foam::gradingDescriptor::operator!=
bool operator!=(const gradingDescriptor &) const
Definition: gradingDescriptor.C:110
scalar.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::gradingDescriptor::gradingDescriptor
gradingDescriptor()
Default construct (1, 1, 1)
Definition: gradingDescriptor.C:35
Foam::gradingDescriptor
Handles the specification for grading within a section of a block.
Definition: gradingDescriptor.H:72
Foam::gradingDescriptor::operator==
bool operator==(const gradingDescriptor &) const
Definition: gradingDescriptor.C:101
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::gradingDescriptor::nDivFraction
scalar nDivFraction() const
Definition: gradingDescriptor.H:118
Foam::gradingDescriptor::correct
void correct()
Adjust expansion ratio.
Definition: gradingDescriptor.C:79
Foam::gradingDescriptor::~gradingDescriptor
~gradingDescriptor()=default
Destructor.
Foam::gradingDescriptor::operator>>
friend Istream & operator>>(Istream &, gradingDescriptor &)