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 -------------------------------------------------------------------------------
11 License
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 
35 const 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 
52 (
53  const fvPatch& p,
55 )
56 :
57  fixedGradientFvPatchScalarField(p, iF),
58  limit_(lcZeroGradient)
59 {}
60 
61 
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();
78  }
79  else
80  {
81  fvPatchField<scalar>::operator=(patchInternalField());
82  gradient() = 0.0;
83  }
84 }
85 
86 
89 (
91  const fvPatch& p,
93  const fvPatchFieldMapper& mapper
94 )
95 :
96  fixedGradientFvPatchScalarField(acpsf, p, iF, mapper),
97  limit_(acpsf.limit_)
98 {}
99 
100 
103 (
105 )
106 :
107  fixedGradientFvPatchScalarField(acpsf),
108  limit_(acpsf.limit_)
109 {}
110 
111 
114 (
117 )
118 :
119  fixedGradientFvPatchScalarField(acpsf, iF),
120  limit_(acpsf.limit_)
121 {}
122 
123 
124 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
125 
127 (
128  const Pstream::commsTypes
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 
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 {
163  os.writeEntry("limit", limitControlNames_[limit_]);
164 }
165 
166 
167 // ************************************************************************* //
Foam::fvPatchField
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: volSurfaceMapping.H:51
Foam::alphaContactAngleTwoPhaseFvPatchScalarField::alphaContactAngleTwoPhaseFvPatchScalarField
alphaContactAngleTwoPhaseFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Construct from patch and internal field.
Definition: alphaContactAngleTwoPhaseFvPatchScalarField.C:52
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:52
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::Enum
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: IOstreamOption.H:57
Foam::alphaContactAngleTwoPhaseFvPatchScalarField::write
virtual void write(Ostream &os) const
Write.
Definition: alphaContactAngleTwoPhaseFvPatchScalarField.C:158
volMesh.H
fvPatchFieldMapper.H
Foam::alphaContactAngleTwoPhaseFvPatchScalarField::evaluate
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Evaluate the patch field.
Definition: alphaContactAngleTwoPhaseFvPatchScalarField.C:127
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
Foam::alphaContactAngleTwoPhaseFvPatchScalarField::limitControls
limitControls
Alpha limit options.
Definition: alphaContactAngleTwoPhaseFvPatchScalarField.H:87
Foam::alphaContactAngleTwoPhaseFvPatchScalarField
Abstract base class for two-phase alphaContactAngle boundary conditions.
Definition: alphaContactAngleTwoPhaseFvPatchScalarField.H:78
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
Foam::foamVersion::patch
const std::string patch
OpenFOAM patch number as a std::string.
Foam::vtk::write
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Component-wise write of a value (N times)
Definition: foamVtkOutputTemplates.C:36
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
Foam::alphaContactAngleTwoPhaseFvPatchScalarField::limitControlNames_
static const Enum< limitControls > limitControlNames_
Definition: alphaContactAngleTwoPhaseFvPatchScalarField.H:95
alphaContactAngleTwoPhaseFvPatchScalarField.H
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::alphaContactAngleTwoPhaseFvPatchScalarField::limit_
limitControls limit_
Definition: alphaContactAngleTwoPhaseFvPatchScalarField.H:96
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54
Foam::stringOps::evaluate
string evaluate(label fieldWidth, const std::string &s, size_t pos=0, size_t len=std::string::npos)
String evaluation with specified (positive, non-zero) field width.
Definition: stringOpsEvaluate.C:37