fvsPatchFieldNew.C 4.84 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
6
     \\/     M anipulation  |
OpenFOAM bot's avatar
OpenFOAM bot committed
7
-------------------------------------------------------------------------------
OpenFOAM bot's avatar
OpenFOAM bot committed
8
    Copyright (C) 2011-2016 OpenFOAM Foundation
9
    Copyright (C) 2019 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

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

// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //

template<class Type>
32
Foam::tmp<Foam::fvsPatchField<Type>> Foam::fvsPatchField<Type>::New
33 34
(
    const word& patchFieldType,
35
    const word& actualPatchType,
36 37 38 39
    const fvPatch& p,
    const DimensionedField<Type, surfaceMesh>& iF
)
{
40
    DebugInFunction << "Constructing fvsPatchField" << endl;
41

42
    auto cstrIter = patchConstructorTablePtr_->cfind(patchFieldType);
43

44
    if (!cstrIter.found())
45
    {
46 47 48 49 50 51
        FatalErrorInLookup
        (
            "patchField",
            patchFieldType,
            *patchConstructorTablePtr_
        ) << exit(FatalError);
52 53
    }

54 55 56 57 58
    if
    (
        actualPatchType == word::null
     || actualPatchType != p.type()
    )
59
    {
60
        auto patchTypeCstrIter = patchConstructorTablePtr_->cfind(p.type());
61

62
        if (patchTypeCstrIter.found())
63 64 65
        {
            return patchTypeCstrIter()(p, iF);
        }
66
    }
67 68

    return cstrIter()(p, iF);
69 70 71
}


72
template<class Type>
73
Foam::tmp<Foam::fvsPatchField<Type>> Foam::fvsPatchField<Type>::New
74 75 76 77 78 79 80 81 82 83
(
    const word& patchFieldType,
    const fvPatch& p,
    const DimensionedField<Type, surfaceMesh>& iF
)
{
    return New(patchFieldType, word::null, p, iF);
}


84
template<class Type>
85
Foam::tmp<Foam::fvsPatchField<Type>> Foam::fvsPatchField<Type>::New
86 87 88 89 90 91
(
    const fvPatch& p,
    const DimensionedField<Type, surfaceMesh>& iF,
    const dictionary& dict
)
{
92
    DebugInFunction << "Constructing fvsPatchField" << endl;
93

94
    const word patchFieldType(dict.get<word>("type"));
95

96
    auto cstrIter = dictionaryConstructorTablePtr_->cfind(patchFieldType);
97

98
    if (!cstrIter.found())
99
    {
100
        if (!disallowGenericFvsPatchField)
101
        {
102
            cstrIter = dictionaryConstructorTablePtr_->cfind("generic");
103 104
        }

105
        if (!cstrIter.found())
106
        {
107 108
            FatalIOErrorInFunction(dict)
                << "Unknown patchField type " << patchFieldType
109
                << " for patch type " << p.type() << nl << nl
110
                << "Valid patchField types :" << endl
111
                << dictionaryConstructorTablePtr_->sortedToc()
112 113 114 115
                << exit(FatalIOError);
        }
    }

116
    if
117 118
    (
        !dict.found("patchType")
119
     || dict.get<word>("patchType") != p.type()
120 121
    )
    {
122 123
        auto patchTypeCstrIter
            = dictionaryConstructorTablePtr_->cfind(p.type());
124

125
        if (patchTypeCstrIter.found() && patchTypeCstrIter() != cstrIter())
126
        {
127
            FatalIOErrorInFunction(dict)
128
                << "inconsistent patch and patchField types for\n"
129 130 131 132 133 134 135 136 137 138 139
                   "    patch type " << p.type()
                << " and patchField type " << patchFieldType
                << exit(FatalIOError);
        }
    }

    return cstrIter()(p, iF, dict);
}


template<class Type>
140
Foam::tmp<Foam::fvsPatchField<Type>> Foam::fvsPatchField<Type>::New
141 142 143 144 145 146 147
(
    const fvsPatchField<Type>& ptf,
    const fvPatch& p,
    const DimensionedField<Type, surfaceMesh>& iF,
    const fvPatchFieldMapper& pfMapper
)
{
148
    DebugInFunction << "Constructing fvsPatchField" << endl;
149

150
    auto cstrIter = patchMapperConstructorTablePtr_->cfind(ptf.type());
151

152
    if (!cstrIter.found())
153
    {
154 155 156 157 158 159
        FatalErrorInLookup
        (
            "patchField",
            ptf.type(),
            *patchMapperConstructorTablePtr_
        ) << exit(FatalError);
160 161
    }

162
    auto patchTypeCstrIter = patchMapperConstructorTablePtr_->cfind(p.type());
163

164
    if (patchTypeCstrIter.found())
165 166 167
    {
        return patchTypeCstrIter()(ptf, p, iF, pfMapper);
    }
168 169

    return cstrIter()(ptf, p, iF, pfMapper);
170 171 172 173
}


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