Loading...
Searching...
No Matches
pointPatchFieldNew.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) 2011-2016 OpenFOAM Foundation
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 pointPatch& 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 autoPtr<pointPatchField<Type>> tpfld(ctorPtr(p, iF));
58
59 if (actualPatchType.empty() || actualPatchType != p.type())
60 {
61 if (tpfld().constraintType() != p.constraintType())
62 {
63 // Incompatible (constraint-wise) with the patch type
64 // - use default constraint type
65
66 auto* patchTypeCtor = patchConstructorTable(p.type());
67
68 if (!patchTypeCtor)
69 {
71 << "Inconsistent patch and patchField types for\n"
72 << " patch type " << p.type()
73 << " and patchField type " << patchFieldType
74 << exit(FatalError);
75 }
76
77 return patchTypeCtor(p, iF);
78 }
79 }
80 else
81 {
82 if (patchConstructorTablePtr_->found(p.type()))
83 {
84 tpfld.ref().patchType() = actualPatchType;
85 }
86 }
87
88 return tpfld;
89}
90
91
92template<class Type>
94(
95 const word& patchFieldType,
96 const pointPatch& p,
97 const DimensionedField<Type, pointMesh>& iF
99{
100 return New(patchFieldType, word::null, p, iF);
101}
102
103
104template<class Type>
106(
107 const pointPatch& p,
109 const dictionary& dict
110)
111{
112 const word patchFieldType(dict.get<word>("type"));
113
114 word actualPatchType;
115 dict.readIfPresent("patchType", actualPatchType, keyType::LITERAL);
116
118 << "patchFieldType = " << patchFieldType
119 << " [" << actualPatchType
120 << "] : " << p.type() << " name = " << p.name() << endl;
121
122 auto* ctorPtr = dictionaryConstructorTable(patchFieldType);
123
124 if (!ctorPtr)
125 {
127 {
128 ctorPtr = dictionaryConstructorTable("generic");
129 }
130
131 if (!ctorPtr)
132 {
134 << "Unknown patchField type " << patchFieldType
135 << " for patch type " << p.type() << nl << nl
136 << "Valid patchField types :" << endl
137 << dictionaryConstructorTablePtr_->sortedToc()
138 << exit(FatalIOError);
139 }
140 }
141
142 // Construct (but not necessarily returned)
143 autoPtr<pointPatchField<Type>> tpfld(ctorPtr(p, iF, dict));
144
145 if (actualPatchType.empty() || actualPatchType != p.type())
146 {
147 if (tpfld().constraintType() != p.constraintType())
148 {
149 // Incompatible (constraint-wise) with the patch type
150 // - use default constraint type
151
152 auto* patchTypeCtor = dictionaryConstructorTable(p.type());
153
154 if (!patchTypeCtor)
155 {
157 << "Inconsistent patch and patchField types for\n"
158 << " patch type " << p.type()
159 << " and patchField type " << patchFieldType
160 << exit(FatalIOError);
161 }
162
163 return patchTypeCtor(p, iF, dict);
164 }
166
167 return tpfld;
168}
169
170
171template<class Type>
173(
174 const pointPatchField<Type>& ptf,
175 const pointPatch& p,
176 const DimensionedField<Type, pointMesh>& iF,
177 const pointPatchFieldMapper& pfMapper
178)
179{
181 << "patchFieldType = " << ptf.type()
182 << " : " << p.type() << " name = " << p.name() << endl;
183
184 auto* ctorPtr = patchMapperConstructorTable(ptf.type());
185
186 if (!ctorPtr)
187 {
189 (
190 "patchField",
191 ptf.type(),
192 *patchMapperConstructorTablePtr_
193 ) << exit(FatalError);
194 }
195
196 return ctorPtr(ptf, p, iF, pfMapper);
197}
198
199
200// ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
T & ref()
Return reference to the managed object without nullptr checking.
Definition autoPtr.H:231
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
@ LITERAL
String literal.
Definition keyType.H:82
virtual const word & constraintType() const
The constraint type the pointPatchField implements.
static int disallowGenericPatchField
Debug switch to disallow the use of generic pointPatchField.
Foam::pointPatchFieldMapper.
static autoPtr< pointPatchField< Type > > New(const word &patchFieldType, const pointPatch &p, const DimensionedField< Type, pointMesh > &iF)
Return a pointer to a new patchField created on freestore given.
pointPatchField(const pointPatch &, const DimensionedField< Type, pointMesh > &)
Construct from patch and internal field.
Basic pointPatch represents a set of points from the mesh.
Definition pointPatch.H:67
A class for handling words, derived from Foam::string.
Definition word.H:66
static const word null
An empty word.
Definition word.H:84
volScalarField & p
#define FatalErrorInLookup(lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalError.
Definition error.H:607
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition error.H:629
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
#define DebugInFunction
Report an information message using Foam::Info.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
dictionary dict