faPatchFieldNew.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 | www.openfoam.com
6 \\/ M anipulation |
7-------------------------------------------------------------------------------
8 Copyright (C) 2016-2017 Wikki Ltd
9 Copyright (C) 2019-2022 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 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// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
30
31template<class Type>
33(
34 const word& patchFieldType,
35 const word& actualPatchType,
36 const faPatch& p,
38)
39{
41 << "patchFieldType = " << patchFieldType
42 << " [" << actualPatchType
43 << "] : " << p.type() << " name = " << p.name() << endl;
44
45 auto* ctorPtr = patchConstructorTable(patchFieldType);
46
47 if (!ctorPtr)
48 {
50 (
51 "patchField",
52 patchFieldType,
53 *patchConstructorTablePtr_
54 ) << exit(FatalError);
55 }
56
57 auto* patchTypeCtor = patchConstructorTable(p.type());
58
59 if (actualPatchType.empty() || actualPatchType != p.type())
60 {
61 if (patchTypeCtor)
62 {
63 return patchTypeCtor(p, iF);
64 }
65 else
66 {
67 return ctorPtr(p, iF);
68 }
69 }
70
71
72 tmp<faPatchField<Type>> tfap = ctorPtr(p, iF);
73
74 // Check if constraint type override and store patchType if so
75 if (patchTypeCtor)
76 {
77 tfap.ref().patchType() = actualPatchType;
78 }
79 return tfap;
80}
81
82
83template<class Type>
85(
86 const word& patchFieldType,
87 const faPatch& p,
89)
90{
91 return New(patchFieldType, word::null, p, iF);
92}
93
94
95template<class Type>
97(
98 const faPatch& p,
100 const dictionary& dict
101)
102{
103 const word patchFieldType(dict.get<word>("type"));
104
105 word actualPatchType;
106 dict.readIfPresent("patchType", actualPatchType, keyType::LITERAL);
107
109 << "patchFieldType = " << patchFieldType
110 << " [" << actualPatchType
111 << "] : " << p.type() << " name = " << p.name() << endl;
112
113 auto* ctorPtr = dictionaryConstructorTable(patchFieldType);
114
115 if (!ctorPtr)
116 {
117 if (!disallowGenericFaPatchField)
118 {
119 ctorPtr = dictionaryConstructorTable("generic");
120 }
121
122 if (!ctorPtr)
123 {
125 << "Unknown patchField type " << patchFieldType
126 << " for patch type " << p.type() << nl << nl
127 << "Valid patchField types are :" << nl
128 << dictionaryConstructorTablePtr_->sortedToc()
129 << exit(FatalIOError);
130 }
131 }
132
133 if (actualPatchType.empty() || actualPatchType != p.type())
134 {
135 auto* patchTypeCtor = dictionaryConstructorTable(p.type());
136
137 if (patchTypeCtor && patchTypeCtor != ctorPtr)
138 {
140 << "inconsistent patch and patchField types for\n"
141 " patch type " << p.type()
142 << " and patchField type " << patchFieldType
143 << exit(FatalIOError);
144 }
145 }
146
147 return ctorPtr(p, iF, dict);
148}
149
150
151template<class Type>
153(
154 const faPatchField<Type>& ptf,
155 const faPatch& p,
157 const faPatchFieldMapper& pfMapper
158)
159{
161 << "patchFieldType = " << ptf.type()
162 << " : " << p.type() << " name = " << p.name() << endl;
163
164 auto* ctorPtr = patchMapperConstructorTable(ptf.type());
165
166 if (!ctorPtr)
167 {
169 (
170 "patchField",
171 ptf.type(),
172 *patchMapperConstructorTablePtr_
173 ) << exit(FatalError);
174 }
175
176 auto* patchTypeCtor = patchMapperConstructorTable(p.type());
177
178 if (patchTypeCtor)
179 {
180 return patchTypeCtor(ptf, p, iF, pfMapper);
181 }
182
183 return ctorPtr(ptf, p, iF, pfMapper);
184}
185
186
187// ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
A FieldMapper for finite-area patch fields.
faPatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cover...
Definition: faPatchField.H:82
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition: faPatch.H:78
A class for managing temporary objects.
Definition: tmp.H:65
T & ref() const
Definition: tmpI.H:227
A class for handling words, derived from Foam::string.
Definition: word.H:68
volScalarField & p
#define FatalErrorInLookup(lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalError.
Definition: error.H:457
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
#define DebugInFunction
Report an information message using Foam::Info.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
IOerror FatalIOError
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
error FatalError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
dictionary dict