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-2026 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"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 const Foam::NamedEnum
33 <
35  4
37 {
38  "none",
39  "gradient",
40  "zeroGradient",
41  "alpha"
42 };
43 
44 
45 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
46 
48 (
49  const fvPatch& p,
51  const dictionary& dict
52 )
53 :
54  fixedGradientFvPatchScalarField(p, iF),
55  contactAngle_(contactAngleModel::New(dict)),
56  limit_(limitControlNames_.read(dict.lookup("limit")))
57 {
58  if (dict.found("gradient"))
59  {
60  gradient() =
61  scalarField("gradient", iF.dimensions()/dimLength, dict, p.size());
62  fixedGradientFvPatchScalarField::updateCoeffs();
64  }
65  else
66  {
67  gradient() = 0.0;
68  fvPatchField<scalar>::operator=(patchInternalField());
69  }
70 }
71 
72 
74 (
75  const contactAngleFvPatchScalarField& acpsf,
76  const fvPatch& p,
78  const fieldMapper& mapper
79 )
80 :
81  fixedGradientFvPatchScalarField(acpsf, p, iF, mapper),
82  contactAngle_(acpsf.contactAngle_, false),
83  limit_(acpsf.limit_)
84 {}
85 
86 
88 (
89  const contactAngleFvPatchScalarField& acpsf,
91 )
92 :
93  fixedGradientFvPatchScalarField(acpsf, iF),
94  contactAngle_(acpsf.contactAngle_, false),
95  limit_(acpsf.limit_)
96 {}
97 
98 
99 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
100 
102 (
103  const fvPatchVectorField& Up,
104  const vectorField& nHat
105 ) const
106 {
107  return contactAngle_->cosTheta(Up, nHat);
108 }
109 
110 
112 (
113  const Pstream::commsTypes
114 )
115 {
116  if (limit_ == lcGradient)
117  {
118  gradient() =
119  patch().deltaCoeffs()
120  *(
121  max(min
122  (
123  *this + gradient()/patch().deltaCoeffs(),
124  scalar(1)), scalar(0)
125  ) - *this
126  );
127  }
128  else if (limit_ == lcZeroGradient)
129  {
130  gradient() = 0.0;
131  }
132 
134 
135  if (limit_ == lcAlpha)
136  {
137  scalarField::operator=(max(min(*this, scalar(1)), scalar(0)));
138  }
139 }
140 
141 
143 (
144  Ostream& os
145 ) const
146 {
148  writeEntry(os, contactAngle_());
149  writeEntry(os, "limit", limitControlNames_[limit_]);
150  writeEntry(os, "value", *this);
151 }
152 
153 
154 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
155 
156 namespace Foam
157 {
159  (
162  );
163 }
164 
165 
166 // ************************************************************************* //
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.
contactAngleFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, fvMesh > &, const dictionary &)
Construct from patch, internal field and dictionary.
tmp< scalarField > cosTheta(const fvPatchVectorField &Up, const vectorField &nHat) const
Return the cosine of the contact angle.
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:90
virtual void operator=(const UList< Type > &)
Definition: fvPatchField.C:255
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:58
A class for managing temporary objects.
Definition: tmp.H:55
void read(Istream &, label &, const dictionary &)
In-place read with dictionary lookup.
const unitSet & lookup(const word &unitName)
Lookup and return the named unit from the table.
Definition: units.C:346
void write(std::ostream &os, const bool binary, List< floatScalar > &fField)
Write floats ascii or binary.
Namespace for OpenFOAM.
const dimensionSet & dimLength
Definition: dimensions.C:141
makePatchTypeField(fvPatchScalarField, atmosphericBoundaryLayerTurbulentEpsilonFvPatchScalarField)
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void evaluate(GeometricField< Type, GeoMesh > &result, const Function1< Type > &func, const GeometricField< Type, GeoMesh > &x)
dimensioned< Type > min(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
tmp< DimensionedField< TypeR, GeoMesh, Field > > New(const tmp< DimensionedField< TypeR, GeoMesh, Field >> &tdf1, const word &name, const dimensionSet &dimensions)
void writeEntry(Ostream &os, const word &key, const DimensionedFieldFunction< DimensionedFieldType > &f)
dimensioned< Type > max(const DimensionedField< Type, GeoMesh, PrimitiveField > &df)
dictionary dict
volScalarField & p