contactAngleFvPatchScalarField.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-2025 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 
27 #include "fieldMapper.H"
28 #include "volMesh.H"
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 const Foam::NamedEnum
34 <
36  4
38 {
39  "none",
40  "gradient",
41  "zeroGradient",
42  "alpha"
43 };
44 
45 
46 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 
49 (
50  const fvPatch& p,
52  const dictionary& dict
53 )
54 :
55  fixedGradientFvPatchScalarField(p, iF),
56  contactAngle_(contactAngleModel::New(dict)),
57  limit_(limitControlNames_.read(dict.lookup("limit")))
58 {
59  if (dict.found("gradient"))
60  {
61  gradient() =
62  scalarField("gradient", iF.dimensions()/dimLength, dict, p.size());
63  fixedGradientFvPatchScalarField::updateCoeffs();
65  }
66  else
67  {
68  gradient() = 0.0;
69  fvPatchField<scalar>::operator=(patchInternalField());
70  }
71 }
72 
73 
75 (
76  const contactAngleFvPatchScalarField& acpsf,
77  const fvPatch& p,
79  const fieldMapper& mapper
80 )
81 :
82  fixedGradientFvPatchScalarField(acpsf, p, iF, mapper),
83  contactAngle_(acpsf.contactAngle_, false),
84  limit_(acpsf.limit_)
85 {}
86 
87 
89 (
90  const contactAngleFvPatchScalarField& acpsf,
92 )
93 :
94  fixedGradientFvPatchScalarField(acpsf, iF),
95  contactAngle_(acpsf.contactAngle_, false),
96  limit_(acpsf.limit_)
97 {}
98 
99 
100 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
101 
103 (
104  const fvPatchVectorField& Up,
105  const vectorField& nHat
106 ) const
107 {
108  return contactAngle_->cosTheta(Up, nHat);
109 }
110 
111 
113 (
114  const Pstream::commsTypes
115 )
116 {
117  if (limit_ == lcGradient)
118  {
119  gradient() =
120  patch().deltaCoeffs()
121  *(
122  max(min
123  (
124  *this + gradient()/patch().deltaCoeffs(),
125  scalar(1)), scalar(0)
126  ) - *this
127  );
128  }
129  else if (limit_ == lcZeroGradient)
130  {
131  gradient() = 0.0;
132  }
133 
135 
136  if (limit_ == lcAlpha)
137  {
138  scalarField::operator=(max(min(*this, scalar(1)), scalar(0)));
139  }
140 }
141 
142 
144 (
145  Ostream& os
146 ) const
147 {
149  writeEntry(os, contactAngle_());
150  writeEntry(os, "limit", limitControlNames_[limit_]);
151  writeEntry(os, "value", *this);
152 }
153 
154 
155 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
156 
157 namespace Foam
158 {
160  (
163  );
164 }
165 
166 
167 // ************************************************************************* //
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...
const dimensionSet & dimensions() const
Return dimensions.
void operator=(const Field< scalar > &)
Definition: Field.C:557
Initialise the NamedEnum HashTable from the static list of names.
Definition: NamedEnum.H:55
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
commsTypes
Types of communications.
Definition: UPstream.H:65
General alpha contact angle boundary condition.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
virtual void write(Ostream &) const
Write.
static const NamedEnum< limitControls, 4 > limitControlNames_
Alpha limit option names.
tmp< scalarField > cosTheta(const fvPatchVectorField &Up, const vectorField &nHat) const
Return the cosine of the contact angle.
contactAngleFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
Abstract base-class for contact-angle models which return the cosine contact angle field.
A list of keywords followed by any number of values (e.g. words and numbers) or sub-dictionaries.
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:91
virtual void operator=(const UList< Type > &)
Definition: fvPatchField.C:257
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
A class for managing temporary objects.
Definition: tmp.H:55
void read(Istream &, label &, const dictionary &)
In-place read with dictionary lookup.
autoPtr< CompressibleMomentumTransportModel > New(const volScalarField &rho, const volVectorField &U, const surfaceScalarField &phi, const viscosity &viscosity)
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
Namespace for OpenFOAM.
const dimensionSet dimLength
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
layerAndWeight min(const layerAndWeight &a, const layerAndWeight &b)
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
void evaluate(GeometricField< Type, GeoMesh > &result, const Function1< Type > &func, const GeometricField< Type, GeoMesh > &x)
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
makePatchTypeField(fvPatchScalarField, atmBoundaryLayerInletEpsilonFvPatchScalarField)
dictionary dict
volScalarField & p