alphaContactAngleFvPatchScalarField.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) 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 
28 #include "fvPatchFieldMapper.H"
29 
30 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
31 
33 (
34  const fvPatch& p,
36 )
37 :
38  zeroGradientFvPatchScalarField(p, iF)
39 {}
40 
41 
43 (
45  const fvPatch& p,
47  const fvPatchFieldMapper& mapper
48 )
49 :
50  zeroGradientFvPatchScalarField(gcpsf, p, iF, mapper),
51  thetaProps_(gcpsf.thetaProps_)
52 {}
53 
54 
56 (
57  const fvPatch& p,
59  const dictionary& dict
60 )
61 :
62  zeroGradientFvPatchScalarField(p, iF, dict),
63  thetaProps_()
64 {
65  forAllConstIter(dictionary, dict.subDict("contactAngleProperties"), iter)
66  {
67  thetaProps_.insert
68  (
69  iter().keyword(),
71  );
72  }
73 }
74 
75 
77 (
80 )
81 :
82  zeroGradientFvPatchScalarField(gcpsf, iF),
83  thetaProps_(gcpsf.thetaProps_)
84 {}
85 
86 
87 Foam::alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField::
88 contactAngleProperties::contactAngleProperties()
89 :
90  theta0_(NaN),
91  dynamic_(false),
92  uTheta_(NaN),
93  thetaA_(NaN),
94  thetaR_(NaN)
95 {}
96 
97 
98 Foam::alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField::
99 contactAngleProperties::contactAngleProperties(const scalar theta0)
100 :
101  theta0_(theta0),
102  dynamic_(false),
103  uTheta_(NaN),
104  thetaA_(NaN),
105  thetaR_(NaN)
106 {}
107 
108 
109 Foam::alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField::
110 contactAngleProperties::contactAngleProperties
111 (
112  const scalar theta0,
113  const scalar uTheta,
114  const scalar thetaA,
115  const scalar thetaR
116 )
117 :
118  theta0_(theta0),
119  dynamic_(true),
120  uTheta_(uTheta),
121  thetaA_(thetaA),
122  thetaR_(thetaR)
123 {}
124 
125 Foam::alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField::
126 contactAngleProperties::contactAngleProperties(const dictionary& dict)
127 :
128  theta0_(dict.lookup<scalar>("theta0")),
129  dynamic_(dict.found("uTheta")),
130  uTheta_(dynamic_ ? dict.lookup<scalar>("uTheta") : NaN),
131  thetaA_(dynamic_ ? dict.lookup<scalar>("thetaA") : NaN),
132  thetaR_(dynamic_ ? dict.lookup<scalar>("thetaR") : NaN)
133 {}
134 
135 
136 
137 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
138 
140 {
142 
143  writeKeyword(os, "contactAngleProperties")
144  << nl << indent << token::BEGIN_BLOCK << nl << incrIndent;
146  {
147  writeKeyword(os, iter.key())
148  << nl << indent << token::BEGIN_BLOCK << nl << incrIndent;
149  iter().write(os);
150  os << decrIndent << indent << token::END_BLOCK << endl;
151  }
152  os << decrIndent << indent << token::END_BLOCK << endl;
153 
154  writeEntry(os, "value", *this);
155 }
156 
157 
158 Foam::alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField::
159 contactAngleProperties
160 Foam::alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField::
161 contactAngleProperties::reversed()
162 const
163 {
164  return
165  dynamic()
167  (
168  180 - theta0_,
169  uTheta_,
170  180 - thetaA_,
171  180 - thetaR_
172  )
174  (
175  180 - theta0_
176  );
177 }
178 
179 
180 void
183 {
184  writeEntry(os, "theta0", theta0_);
185  if (dynamic())
186  {
187  writeEntry(os, "uTheta", uTheta_);
188  writeEntry(os, "thetaA", thetaA_);
189  writeEntry(os, "thetaR", thetaR_);
190  }
191 }
192 
193 
194 bool
195 Foam::alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField::
196 contactAngleProperties::operator==
197 (
199 ) const
200 {
201  if (dynamic() != thetaProps.dynamic()) return false;
202 
203  static const scalar thetaTol = 180*rootSmall;
204  static const scalar uThetaTol = rootSmall;
205 
206  return
207  dynamic()
208  ? mag(theta0() - thetaProps.theta0()) < thetaTol
209  && mag(uTheta() - thetaProps.uTheta()) < uThetaTol
210  && mag(thetaA() - thetaProps.thetaA()) < thetaTol
211  && mag(thetaR() - thetaProps.thetaR()) < thetaTol
212  : mag(theta0() - thetaProps.theta0()) < thetaTol;
213 }
214 
215 
216 bool
217 Foam::alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField::
218 contactAngleProperties::operator!=
219 (
221 ) const
222 {
223  return !(*this == thetaProps);
224 }
225 
226 
227 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
228 
229 namespace Foam
230 {
232  (
235  );
236 }
237 
238 // ************************************************************************* //
dictionary dict
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:663
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:221
Ostream & writeKeyword(Foam::Ostream &os, const keyType &kw)
Write the keyword to the Ostream with the current level of indentation.
Definition: keyType.C:155
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
#define forAllConstIter(Container, container, iter)
Iterate across all elements in the container object of type.
Definition: UList.H:477
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:63
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:243
const HashTable< contactAngleProperties > & thetaProps() const
Return the contact angle properties.
Macros for easy insertion into run-time selection tables.
const dictionary & subDict(const word &) const
Find and return a sub-dictionary.
Definition: dictionary.C:1002
Foam::fvPatchFieldMapper.
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
An STL-conforming hash table.
Definition: HashTable.H:61
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
static const char nl
Definition: Ostream.H:260
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:235
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
dimensioned< scalar > mag(const dimensioned< Type > &)
Contact-angle boundary condition for multi-phase interface-capturing simulations. ...
alphaContactAngleFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:228
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
Namespace for OpenFOAM.
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:864