inletOutletFvPatchField.C 4.25 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           | www.openfoam.com
OpenFOAM bot's avatar
OpenFOAM bot committed
6 7
     \\/     M anipulation  |
-------------------------------------------------------------------------------
OpenFOAM bot's avatar
OpenFOAM bot committed
8
    Copyright (C) 2011-2017 OpenFOAM Foundation
9
    Copyright (C) 2017-2020 OpenCFD Ltd.
10 11 12 13
-------------------------------------------------------------------------------
License
    This file is part of OpenFOAM.

14 15 16 17
    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.
18 19 20 21 22 23 24

    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
25
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
26 27 28 29 30 31 32 33

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

#include "inletOutletFvPatchField.H"

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

template<class Type>
34
Foam::inletOutletFvPatchField<Type>::inletOutletFvPatchField
35 36 37 38 39 40 41 42
(
    const fvPatch& p,
    const DimensionedField<Type, volMesh>& iF
)
:
    mixedFvPatchField<Type>(p, iF),
    phiName_("phi")
{
43 44
    this->refValue() = Zero;
    this->refGrad() = Zero;
45 46 47 48 49
    this->valueFraction() = 0.0;
}


template<class Type>
50
Foam::inletOutletFvPatchField<Type>::inletOutletFvPatchField
51 52 53 54 55 56 57 58 59 60 61 62 63
(
    const inletOutletFvPatchField<Type>& ptf,
    const fvPatch& p,
    const DimensionedField<Type, volMesh>& iF,
    const fvPatchFieldMapper& mapper
)
:
    mixedFvPatchField<Type>(ptf, p, iF, mapper),
    phiName_(ptf.phiName_)
{}


template<class Type>
64
Foam::inletOutletFvPatchField<Type>::inletOutletFvPatchField
65 66 67 68 69 70 71
(
    const fvPatch& p,
    const DimensionedField<Type, volMesh>& iF,
    const dictionary& dict
)
:
    mixedFvPatchField<Type>(p, iF),
72
    phiName_(dict.getOrDefault<word>("phi", "phi"))
73
{
74
    this->patchType() = dict.getOrDefault<word>("patchType", word::null);
75

76 77 78 79 80 81 82 83 84 85 86 87 88 89
    this->refValue() = Field<Type>("inletValue", dict, p.size());

    if (dict.found("value"))
    {
        fvPatchField<Type>::operator=
        (
            Field<Type>("value", dict, p.size())
        );
    }
    else
    {
        fvPatchField<Type>::operator=(this->refValue());
    }

90
    this->refGrad() = Zero;
91 92 93 94 95
    this->valueFraction() = 0.0;
}


template<class Type>
96
Foam::inletOutletFvPatchField<Type>::inletOutletFvPatchField
97 98 99 100 101 102 103 104 105 106
(
    const inletOutletFvPatchField<Type>& ptf
)
:
    mixedFvPatchField<Type>(ptf),
    phiName_(ptf.phiName_)
{}


template<class Type>
107
Foam::inletOutletFvPatchField<Type>::inletOutletFvPatchField
108 109 110 111 112 113 114 115 116 117 118 119 120
(
    const inletOutletFvPatchField<Type>& ptf,
    const DimensionedField<Type, volMesh>& iF
)
:
    mixedFvPatchField<Type>(ptf, iF),
    phiName_(ptf.phiName_)
{}


// * * * * * * * * * * * * * * * Member Functions  * * * * * * * * * * * * * //

template<class Type>
121
void Foam::inletOutletFvPatchField<Type>::updateCoeffs()
122 123 124 125 126 127
{
    if (this->updated())
    {
        return;
    }

128 129 130 131 132
    const Field<scalar>& phip =
        this->patch().template lookupPatchField<surfaceScalarField, scalar>
        (
            phiName_
        );
133

Henry Weller's avatar
Henry Weller committed
134
    this->valueFraction() = 1.0 - pos0(phip);
135 136 137 138 139 140

    mixedFvPatchField<Type>::updateCoeffs();
}


template<class Type>
141
void Foam::inletOutletFvPatchField<Type>::write(Ostream& os) const
142 143
{
    fvPatchField<Type>::write(os);
144
    os.writeEntryIfDifferent<word>("phi", "phi", phiName_);
145 146 147 148 149
    this->refValue().writeEntry("inletValue", os);
    this->writeEntry("value", os);
}


150 151 152
// * * * * * * * * * * * * * * * Member Operators  * * * * * * * * * * * * * //

template<class Type>
153
void Foam::inletOutletFvPatchField<Type>::operator=
154 155 156 157 158 159 160 161 162 163 164 165
(
    const fvPatchField<Type>& ptf
)
{
    fvPatchField<Type>::operator=
    (
        this->valueFraction()*this->refValue()
        + (1 - this->valueFraction())*ptf
    );
}


166
// ************************************************************************* //