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 gradingDescriptor;
62 class gradingDescriptors;
63 
64 Istream& operator>>(Istream&, gradingDescriptor&);
65 Ostream& operator<<(Ostream&, const gradingDescriptor&);
66 
67 /*---------------------------------------------------------------------------*\
68  Class gradingDescriptor Declaration
69 \*---------------------------------------------------------------------------*/
70 
72 {
73  // Private Data
74 
75  scalar blockFraction_;
76  scalar nDivFraction_;
77  scalar expansionRatio_;
78 
79 
80 public:
81 
82  // Friendship with gradingDescriptors
83  friend class gradingDescriptors;
84 
85 
86  // Constructors
87 
88  //- Default construct (1, 1, 1)
90 
91  //- Construct from components
93  (
94  const scalar blockFraction,
95  const scalar nDivFraction,
96  const scalar expansionRatio
97  );
98 
99  //- Construct from expansionRatio
100  explicit gradingDescriptor(const scalar expansionRatio);
101 
102  //- Construct from Istream
103  explicit gradingDescriptor(Istream& is);
104 
105 
106  //- Destructor
107  ~gradingDescriptor() = default;
108 
109 
110  // Member Functions
111 
112  scalar blockFraction() const
113  {
114  return blockFraction_;
115  }
116 
117  scalar nDivFraction() const
118  {
119  return nDivFraction_;
120  }
121 
122  scalar expansionRatio() const
123  {
124  return expansionRatio_;
125  }
126 
127  //- Adjust expansion ratio.
128  // Trap negative value and treat as its inverse.
129  void correct();
130 
131  //- Return the inverse gradingDescriptor with 1/expansionRatio
132  gradingDescriptor inv() const;
133 
134 
135  // Member Operators
136 
137  bool operator==(const gradingDescriptor&) const;
138  bool operator!=(const gradingDescriptor&) const;
139 
140 
141  // IOstream Operators
142 
144  friend Ostream& operator<<(Ostream&, const gradingDescriptor&);
145 };
146 
147 
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 
150 } // End namespace Foam
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 #endif
155 
156 // ************************************************************************* //
void correct()
Adjust expansion ratio.
bool operator==(const gradingDescriptor &) const
gradingDescriptor inv() const
Return the inverse gradingDescriptor with 1/expansionRatio.
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
gradingDescriptor()
Default construct (1, 1, 1)
Istream & operator>>(Istream &, directionInfo &)
Handles the specification for grading within a section of a block.
bool operator!=(const gradingDescriptor &) const
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
friend Istream & operator>>(Istream &, gradingDescriptor &)
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:77
List of gradingDescriptor for the sections of a block with additional IO functionality.
friend Ostream & operator<<(Ostream &, const gradingDescriptor &)
~gradingDescriptor()=default
Destructor.
Namespace for OpenFOAM.