meshPhiPreCorrectInfoI.H
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) 2011-2022 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 "meshPhiPreCorrectInfo.H"
27 #include "fvMesh.H"
28 
29 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
30 
32 :
33  layer_(-labelMax),
34  weight_(NaN)
35 {}
36 
37 
39 (
40  const label layer,
41  const scalar weight
42 )
43 :
44  layer_(layer),
45  weight_(weight)
46 {}
47 
48 
49 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
50 
52 {
53  return layer_;
54 }
55 
56 
57 inline Foam::scalar Foam::meshPhiPreCorrectInfo::weight() const
58 {
59  return weight_;
60 }
61 
62 
63 template<class TrackingData>
64 inline bool Foam::meshPhiPreCorrectInfo::valid(TrackingData& td) const
65 {
66  return layer_ != -labelMax;
67 }
68 
69 
70 template<class TrackingData>
72 (
73  const fvMesh&,
74  const meshPhiPreCorrectInfo& l,
75  const scalar tol,
76  TrackingData& td
77 ) const
78 {
79  return layer_ == l.layer_;
80 }
81 
82 
83 template<class TrackingData>
85 (
86  const fvPatch& patch,
87  const label patchFacei,
88  const transformer& transform,
89  TrackingData& td
90 )
91 {}
92 
93 
94 template<class TrackingData>
96 (
97  const fvMesh& mesh,
98  const label thisCelli,
99  const labelPair& neighbourPatchAndFacei,
100  const meshPhiPreCorrectInfo& neighbourInfo,
101  const scalar tol,
102  TrackingData& td
103 )
104 {
105  if (!valid(td))
106  {
107  layer_ = neighbourInfo.layer_ + 1;
108  weight_ = 0;
109  }
110 
111  if (layer_ > neighbourInfo.layer_)
112  {
113  weight_ += neighbourInfo.weight_;
114 
115  return true;
116  }
117  else
118  {
119  return false;
120  }
121 }
122 
123 
124 template<class TrackingData>
126 (
127  const fvMesh& mesh,
128  const labelPair& thisPatchAndFacei,
129  const label neighbourCelli,
130  const meshPhiPreCorrectInfo& neighbourInfo,
131  const scalar tol,
132  TrackingData& td
133 )
134 {
135  if (!valid(td))
136  {
137  layer_ = neighbourInfo.layer_ + 1;
138  }
139 
140  if (layer_ > neighbourInfo.layer_)
141  {
142  weight_ = neighbourInfo.weight_;
143 
144  return true;
145  }
146  else
147  {
148  return false;
149  }
150 }
151 
152 
153 template<class TrackingData>
155 (
156  const fvMesh& mesh,
157  const labelPair& thisPatchAndFacei,
158  const meshPhiPreCorrectInfo& neighbourInfo,
159  const scalar tol,
160  TrackingData& td
161 )
162 {
163  if (layer_ < neighbourInfo.layer_)
164  {
165  layer_ = neighbourInfo.layer_;
166  weight_ = neighbourInfo.weight_;
167  }
168 
169  return true;
170 }
171 
172 
173 template<class TrackingData>
175 (
176  const meshPhiPreCorrectInfo& rhs,
177  TrackingData& td
178 ) const
179 {
180  return operator==(rhs);
181 }
182 
183 
184 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
185 
186 inline bool Foam::meshPhiPreCorrectInfo::operator==
187 (
188  const Foam::meshPhiPreCorrectInfo& rhs
189 ) const
190 {
191  return layer_ == rhs.layer_ && weight_ == rhs.weight_;
192 }
193 
194 
195 inline bool Foam::meshPhiPreCorrectInfo::operator!=
196 (
197  const Foam::meshPhiPreCorrectInfo& rhs
198 ) const
199 {
200  return !(*this == rhs);
201 }
202 
203 
204 // * * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * //
205 
207 {
208  return os << l.layer_ << token::SPACE << l.weight_;
209 }
210 
211 
213 {
214  return is >> l.layer_ >> l.weight_;
215 }
216 
217 
218 // ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:60
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:99
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
bool updateCell(const fvMesh &mesh, const label thisCelli, const labelPair &neighbourPatchAndFacei, const meshPhiPreCorrectInfo &neighbourInfo, const scalar tol, TrackingData &td)
Influence of neighbouring face.
bool equal(const meshPhiPreCorrectInfo &, TrackingData &td) const
Test equality.
scalar weight() const
Return the weight.
bool valid(TrackingData &td) const
Check whether the meshPhiPreCorrectInfo has been changed at all.
label layer() const
Return the layer index.
bool updateFace(const fvMesh &mesh, const labelPair &thisPatchAndFacei, const label neighbourCelli, const meshPhiPreCorrectInfo &neighbourInfo, const scalar tol, TrackingData &td)
Influence of neighbouring cell.
bool sameGeometry(const fvMesh &mesh, const meshPhiPreCorrectInfo &, const scalar, TrackingData &td) const
Check for identical geometrical data. Used for checking.
void transform(const fvPatch &patch, const label patchFacei, const transformer &transform, TrackingData &td)
Transform across an interface.
Vector-tensor class used to perform translations, rotations and scaling operations in 3D space.
Definition: transformer.H:84
bool valid(const PtrList< ModelType > &l)
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
Istream & operator>>(Istream &, pistonPointEdgeData &)
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:504
Ostream & operator<<(Ostream &os, const fvConstraints &constraints)
static const label labelMax
Definition: label.H:62