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