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 (
90  const alphaContactAngleTwoPhaseFvPatchScalarField& acpsf,
91  const fvPatch& p,
92  const DimensionedField<scalar, volMesh>& iF,
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:47
Foam::alphaContactAngleTwoPhaseFvPatchScalarField::alphaContactAngleTwoPhaseFvPatchScalarField
alphaContactAngleTwoPhaseFvPatchScalarField(const fvPatch &, const DimensionedField< scalar, volMesh > &)
Definition: alphaContactAngleTwoPhaseFvPatchScalarField.C:45
Foam::fvPatchField::operator=
virtual void operator=(const UList< Type > &)
Foam::scalarField
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Definition: primitiveFieldsFwd.H:46
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:53
Foam::alphaContactAngleTwoPhaseFvPatchScalarField::write
virtual void write(Ostream &os) const
Definition: alphaContactAngleTwoPhaseFvPatchScalarField.C:151
volMesh.H
fvPatchFieldMapper.H
Foam::alphaContactAngleTwoPhaseFvPatchScalarField::evaluate
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Definition: alphaContactAngleTwoPhaseFvPatchScalarField.C:120
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Definition: hashSets.C:26
Foam::alphaContactAngleTwoPhaseFvPatchScalarField::limitControls
limitControls
Definition: alphaContactAngleTwoPhaseFvPatchScalarField.H:83
Foam::alphaContactAngleTwoPhaseFvPatchScalarField
Abstract base class for two-phase alphaContactAngle boundary conditions.
Definition: alphaContactAngleTwoPhaseFvPatchScalarField.H:74
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Definition: hashSets.C:40
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:119
os
OBJstream os(runTime.globalPath()/outputName)
Foam::Field::operator=
void operator=(const Field< Type > &)
Foam::UPstream::commsTypes
commsTypes
Definition: UPstream.H:65
Foam::foamVersion::patch
const std::string patch
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Definition: Ostream.H:232
Foam::vtk::write
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Definition: foamVtkOutputTemplates.C:29
Foam::PtrListOps::get
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:41
Foam::alphaContactAngleTwoPhaseFvPatchScalarField::limitControlNames_
static const Enum< limitControls > limitControlNames_
Definition: alphaContactAngleTwoPhaseFvPatchScalarField.H:91
alphaContactAngleTwoPhaseFvPatchScalarField.H
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:52
Foam::alphaContactAngleTwoPhaseFvPatchScalarField::limit_
limitControls limit_
Definition: alphaContactAngleTwoPhaseFvPatchScalarField.H:92
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:50
Foam::stringOps::evaluate
string evaluate(label fieldWidth, const std::string &s, size_t pos=0, size_t len=std::string::npos)
Definition: stringOpsEvaluate.C:30