alphaContactAngleFvPatchScalarField.C 4.49 KB
Newer Older
1
2
3
4
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     |
OpenFOAM bot's avatar
OpenFOAM bot committed
5
    \\  /    A nd           |
6
     \\/     M anipulation  |
OpenFOAM bot's avatar
OpenFOAM bot committed
7
8
-------------------------------------------------------------------------------
                            | Copyright (C) 2011-2015 OpenFOAM Foundation
9
10
11
12
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

13
14
15
16
    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
17
18
19
20
21
22
23

    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
24
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
25
26
27
28
29
30

\*---------------------------------------------------------------------------*/

#include "alphaContactAngleFvPatchScalarField.H"
#include "fvPatchFieldMapper.H"
#include "volMesh.H"
31
#include "addToRunTimeSelectionTable.H"
32
33
34
35
36
37

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{
    defineTypeNameAndDebug(alphaContactAngleFvPatchScalarField, 0);
38
}
39

40
const Foam::Enum
41
<
42
43
44
    Foam::alphaContactAngleFvPatchScalarField::limitControls
>
Foam::alphaContactAngleFvPatchScalarField::limitControlNames_
Mark Olesen's avatar
Mark Olesen committed
45
({
46
47
48
49
    { limitControls::lcNone, "none" },
    { limitControls::lcGradient, "gradient" },
    { limitControls::lcZeroGradient, "zeroGradient" },
    { limitControls::lcAlpha, "alpha" },
Mark Olesen's avatar
Mark Olesen committed
50
});
51

52
53
54
55
56
57
58
59
60

// * * * * * * * * * * * * * * * * Constructors  * * * * * * * * * * * * * * //

Foam::alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField
(
    const fvPatch& p,
    const DimensionedField<scalar, volMesh>& iF
)
:
61
62
    fixedGradientFvPatchScalarField(p, iF),
    limit_(lcZeroGradient)
63
64
65
66
67
68
69
70
71
72
{}


Foam::alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField
(
    const fvPatch& p,
    const DimensionedField<scalar, volMesh>& iF,
    const dictionary& dict
)
:
73
    fixedGradientFvPatchScalarField(p, iF),
Mark Olesen's avatar
Mark Olesen committed
74
    limit_(limitControlNames_.get("limit", dict))
75
{
76
77
78
79
80
81
82
83
84
85
86
    if (dict.found("gradient"))
    {
        gradient() = scalarField("gradient", dict, p.size());
        fixedGradientFvPatchScalarField::updateCoeffs();
        fixedGradientFvPatchScalarField::evaluate();
    }
    else
    {
        fvPatchField<scalar>::operator=(patchInternalField());
        gradient() = 0.0;
    }
87
88
89
}


90
91
92
93
94
95
96
97
98
99
100
101
102
Foam::alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField
(
    const alphaContactAngleFvPatchScalarField& acpsf,
    const fvPatch& p,
    const DimensionedField<scalar, volMesh>& iF,
    const fvPatchFieldMapper& mapper
)
:
    fixedGradientFvPatchScalarField(acpsf, p, iF, mapper),
    limit_(acpsf.limit_)
{}


103
104
Foam::alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField
(
105
    const alphaContactAngleFvPatchScalarField& acpsf
106
107
)
:
108
109
    fixedGradientFvPatchScalarField(acpsf),
    limit_(acpsf.limit_)
110
111
112
113
114
{}


Foam::alphaContactAngleFvPatchScalarField::alphaContactAngleFvPatchScalarField
(
115
    const alphaContactAngleFvPatchScalarField& acpsf,
116
117
118
    const DimensionedField<scalar, volMesh>& iF
)
:
119
120
    fixedGradientFvPatchScalarField(acpsf, iF),
    limit_(acpsf.limit_)
121
122
123
{}


124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //

void Foam::alphaContactAngleFvPatchScalarField::evaluate
(
    const Pstream::commsTypes
)
{
    if (limit_ == lcGradient)
    {
        gradient() =
        patch().deltaCoeffs()
       *(
           max(min
           (
               *this + gradient()/patch().deltaCoeffs(),
               scalar(1)), scalar(0)
           ) - *this
       );
    }
    else if (limit_ == lcZeroGradient)
    {
        gradient() = 0.0;
    }

    fixedGradientFvPatchScalarField::evaluate();

    if (limit_ == lcAlpha)
    {
        scalarField::operator=(max(min(*this, scalar(1)), scalar(0)));
    }
}


void Foam::alphaContactAngleFvPatchScalarField::write
(
    Ostream& os
) const
{
    fixedGradientFvPatchScalarField::write(os);
163
    os.writeEntry("limit", limitControlNames_[limit_]);
164
165
166
}


167
// ************************************************************************* //