FreeFOAM The Cross-Platform CFD Toolkit
alphaContactAngleFvPatchScalarField.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 | Copyright (C) 1991-2010 OpenCFD Ltd.
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 
29 #include <finiteVolume/volMesh.H>
30 
31 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(alphaContactAngleFvPatchScalarField, 0);
36 }
37 
38 template<>
39 const char* Foam::NamedEnum
40 <
42  4
43 >::names[] =
44 {
45  "none",
46  "gradient",
47  "zeroGradient",
48  "alpha"
49 };
50 
51 const Foam::NamedEnum
52 <
54  4
56 
57 
58 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
59 
61 (
62  const fvPatch& p,
64 )
65 :
66  fixedGradientFvPatchScalarField(p, iF),
67  limit_(lcZeroGradient)
68 {}
69 
70 
72 (
74  const fvPatch& p,
76  const fvPatchFieldMapper& mapper
77 )
78 :
79  fixedGradientFvPatchScalarField(acpsf, p, iF, mapper),
80  limit_(acpsf.limit_)
81 {}
82 
83 
85 (
86  const fvPatch& p,
88  const dictionary& dict
89 )
90 :
91  fixedGradientFvPatchScalarField(p, iF),
92  limit_(limitControlNames_.read(dict.lookup("limit")))
93 {
94  if (dict.found("gradient"))
95  {
96  gradient() = scalarField("gradient", dict, p.size());
97  fixedGradientFvPatchScalarField::updateCoeffs();
98  fixedGradientFvPatchScalarField::evaluate();
99  }
100  else
101  {
102  fvPatchField<scalar>::operator=(patchInternalField());
103  gradient() = 0.0;
104  }
105 }
106 
107 
109 (
111 )
112 :
113  fixedGradientFvPatchScalarField(acpsf),
114  limit_(acpsf.limit_)
115 {}
116 
117 
119 (
122 )
123 :
124  fixedGradientFvPatchScalarField(acpsf, iF),
125  limit_(acpsf.limit_)
126 {}
127 
128 
129 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
130 
132 (
133  const Pstream::commsTypes
134 )
135 {
136  if (limit_ == lcGradient)
137  {
138  gradient() =
139  patch().deltaCoeffs()
140  *(
141  max(min
142  (
143  *this + gradient()/patch().deltaCoeffs(),
144  scalar(1)), scalar(0)
145  ) - *this
146  );
147  }
148  else if (limit_ == lcZeroGradient)
149  {
150  gradient() = 0.0;
151  }
152 
153  fixedGradientFvPatchScalarField::evaluate();
154 
155  if (limit_ == lcAlpha)
156  {
157  scalarField::operator=(max(min(*this, scalar(1)), scalar(0)));
158  }
159 }
160 
161 
163 (
164  Ostream& os
165 ) const
166 {
167  fixedGradientFvPatchScalarField::write(os);
168  os.writeKeyword("limit")
169  << limitControlNames_[limit_] << token::END_STATEMENT << nl;
170 }
171 
172 
173 // ************************ vim: set sw=4 sts=4 et: ************************ //