fixedNormalSlipFvPatchField.C 4.92 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-2016 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 34 35

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

#include "fixedNormalSlipFvPatchField.H"
#include "symmTransformField.H"


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

template<class Type>
36
Foam::fixedNormalSlipFvPatchField<Type>::fixedNormalSlipFvPatchField
37 38 39 40 41 42
(
    const fvPatch& p,
    const DimensionedField<Type, volMesh>& iF
)
:
    transformFvPatchField<Type>(p, iF),
43
    fixedValue_(p.size(), Zero)
44 45 46 47
{}


template<class Type>
48
Foam::fixedNormalSlipFvPatchField<Type>::fixedNormalSlipFvPatchField
49 50 51 52 53 54 55 56 57 58 59 60 61
(
    const fixedNormalSlipFvPatchField<Type>& ptf,
    const fvPatch& p,
    const DimensionedField<Type, volMesh>& iF,
    const fvPatchFieldMapper& mapper
)
:
    transformFvPatchField<Type>(ptf, p, iF, mapper),
    fixedValue_(ptf.fixedValue_, mapper)
{}


template<class Type>
62
Foam::fixedNormalSlipFvPatchField<Type>::fixedNormalSlipFvPatchField
63 64 65 66 67 68 69 70 71
(
    const fvPatch& p,
    const DimensionedField<Type, volMesh>& iF,
    const dictionary& dict
)
:
    transformFvPatchField<Type>(p, iF),
    fixedValue_("fixedValue", dict, p.size())
{
72
    this->patchType() = dict.getOrDefault<word>("patchType", word::null);
73 74 75 76 77
    evaluate();
}


template<class Type>
78
Foam::fixedNormalSlipFvPatchField<Type>::fixedNormalSlipFvPatchField
79 80 81 82 83 84 85 86 87 88
(
    const fixedNormalSlipFvPatchField<Type>& ptf
)
:
    transformFvPatchField<Type>(ptf),
    fixedValue_(ptf.fixedValue_)
{}


template<class Type>
89
Foam::fixedNormalSlipFvPatchField<Type>::fixedNormalSlipFvPatchField
90 91 92 93 94 95 96 97 98 99 100 101 102
(
    const fixedNormalSlipFvPatchField<Type>& ptf,
    const DimensionedField<Type, volMesh>& iF
)
:
    transformFvPatchField<Type>(ptf, iF),
    fixedValue_(ptf.fixedValue_)
{}


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

template<class Type>
103
void Foam::fixedNormalSlipFvPatchField<Type>::autoMap
104 105 106 107 108 109 110 111 112 113
(
    const fvPatchFieldMapper& m
)
{
    transformFvPatchField<Type>::autoMap(m);
    fixedValue_.autoMap(m);
}


template<class Type>
114
void Foam::fixedNormalSlipFvPatchField<Type>::rmap
115 116 117 118 119 120 121 122
(
    const fvPatchField<Type>& ptf,
    const labelList& addr
)
{
    transformFvPatchField<Type>::rmap(ptf, addr);

    const fixedNormalSlipFvPatchField<Type>& dmptf =
123
        refCast<const fixedNormalSlipFvPatchField<Type>>(ptf);
124 125 126 127 128 129

    fixedValue_.rmap(dmptf.fixedValue_, addr);
}


template<class Type>
130
Foam::tmp<Foam::Field<Type>>
131
Foam::fixedNormalSlipFvPatchField<Type>::snGrad() const
132
{
133 134
    const vectorField nHat(this->patch().nf());
    const Field<Type> pif(this->patchInternalField());
135 136 137 138 139 140 141 142 143

    return
    (
        (nHat*(nHat & fixedValue_) + transform(I - sqr(nHat), pif)) - pif
    )*this->patch().deltaCoeffs();
}


template<class Type>
144 145 146 147
void Foam::fixedNormalSlipFvPatchField<Type>::evaluate
(
    const Pstream::commsTypes
)
148 149 150 151 152 153
{
    if (!this->updated())
    {
        this->updateCoeffs();
    }

154
    const vectorField nHat(this->patch().nf());
155 156 157 158 159 160 161 162 163 164 165 166

    Field<Type>::operator=
    (
        nHat*(nHat & fixedValue_)
      + transform(I - sqr(nHat), this->patchInternalField())
    );

    transformFvPatchField<Type>::evaluate();
}


template<class Type>
167
Foam::tmp<Foam::Field<Type>>
168
Foam::fixedNormalSlipFvPatchField<Type>::snGradTransformDiag() const
169
{
170
    const vectorField nHat(this->patch().nf());
171 172 173 174 175 176 177 178 179 180 181
    vectorField diag(nHat.size());

    diag.replace(vector::X, mag(nHat.component(vector::X)));
    diag.replace(vector::Y, mag(nHat.component(vector::Y)));
    diag.replace(vector::Z, mag(nHat.component(vector::Z)));

    return transformFieldMask<Type>(pow<vector, pTraits<Type>::rank>(diag));
}


template<class Type>
182
void Foam::fixedNormalSlipFvPatchField<Type>::write(Ostream& os) const
183 184 185 186 187 188 189
{
    transformFvPatchField<Type>::write(os);
    fixedValue_.writeEntry("fixedValue", os);
}


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