alphaContactAngleTwoPhaseFvPatchScalarField.C
Go to the documentation of this file.
1/*---------------------------------------------------------------------------*\
2 ========= |
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4 \\ / O peration |
5 \\ / A nd | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2011-2015 OpenFOAM Foundation
9 Copyright (C) 2019 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
30#include "fvPatchFieldMapper.H"
31#include "volMesh.H"
32
33// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34
35const Foam::Enum
36<
38>
40({
41 { limitControls::lcNone, "none" },
42 { limitControls::lcGradient, "gradient" },
43 { limitControls::lcZeroGradient, "zeroGradient" },
44 { limitControls::lcAlpha, "alpha" },
45});
46
47
48// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49
50Foam::alphaContactAngleTwoPhaseFvPatchScalarField::
51alphaContactAngleTwoPhaseFvPatchScalarField
52(
53 const fvPatch& p,
55)
56:
57 fixedGradientFvPatchScalarField(p, iF),
58 limit_(lcZeroGradient)
59{}
60
61
62Foam::alphaContactAngleTwoPhaseFvPatchScalarField::
63alphaContactAngleTwoPhaseFvPatchScalarField
64(
65 const fvPatch& p,
67 const dictionary& dict
68)
69:
70 fixedGradientFvPatchScalarField(p, iF),
71 limit_(limitControlNames_.get("limit", dict))
72{
73 if (dict.found("gradient"))
74 {
75 gradient() = scalarField("gradient", dict, p.size());
76 fixedGradientFvPatchScalarField::updateCoeffs();
77 fixedGradientFvPatchScalarField::evaluate();
78 }
79 else
80 {
81 fvPatchField<scalar>::operator=(patchInternalField());
82 gradient() = 0.0;
83 }
84}
85
86
87Foam::alphaContactAngleTwoPhaseFvPatchScalarField::
88alphaContactAngleTwoPhaseFvPatchScalarField
89(
91 const fvPatch& p,
93 const fvPatchFieldMapper& mapper
94)
95:
96 fixedGradientFvPatchScalarField(acpsf, p, iF, mapper),
97 limit_(acpsf.limit_)
98{}
99
100
101Foam::alphaContactAngleTwoPhaseFvPatchScalarField::
102alphaContactAngleTwoPhaseFvPatchScalarField
103(
105)
106:
107 fixedGradientFvPatchScalarField(acpsf),
108 limit_(acpsf.limit_)
109{}
110
111
112Foam::alphaContactAngleTwoPhaseFvPatchScalarField::
113alphaContactAngleTwoPhaseFvPatchScalarField
114(
117)
118:
119 fixedGradientFvPatchScalarField(acpsf, iF),
120 limit_(acpsf.limit_)
121{}
122
123
124// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
125
127(
129)
130{
131 if (limit_ == lcGradient)
132 {
133 gradient() =
134 patch().deltaCoeffs()
135 *(
136 max(min
137 (
138 *this + gradient()/patch().deltaCoeffs(),
139 scalar(1)), scalar(0)
140 ) - *this
141 );
142 }
143 else if (limit_ == lcZeroGradient)
144 {
145 gradient() = 0.0;
146 }
147
148 fixedGradientFvPatchScalarField::evaluate();
149
150 if (limit_ == lcAlpha)
151 {
152 scalarField::operator=(max(min(*this, scalar(1)), scalar(0)));
153 }
154}
155
156
158(
159 Ostream& os
160) const
161{
162 fixedGradientFvPatchScalarField::write(os);
163 os.writeEntry("limit", limitControlNames_[limit_]);
164}
165
166
167// ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: Enum.H:61
void operator=(const Field< scalar > &)
Copy assignment.
Definition: Field.C:641
void evaluate()
Evaluate boundary conditions.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:62
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:239
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
commsTypes
Types of communications.
Definition: UPstream.H:67
Abstract base class for two-phase alphaContactAngle boundary conditions.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
bool found(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Search for an entry (const access) with the given keyword.
Definition: dictionaryI.H:87
virtual bool write()
Write the output fields.
A FieldMapper for finite-volume patch fields.
virtual void operator=(const UList< Type > &)
Definition: fvPatchField.C:408
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:71
volScalarField & p
OBJstream os(runTime.globalPath()/outputName)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
dictionary dict