faePatchFieldNew.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-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
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 
31 template<class Type>
33 (
34  const word& patchFieldType,
35  const faPatch& p,
36  const DimensionedField<Type, edgeMesh>& iF
37 )
38 {
39  DebugInFunction << "Constructing faePatchField" << endl;
40 
41  auto* ctorPtr = patchConstructorTable(patchFieldType);
42 
43  if (!ctorPtr)
44  {
46  (
47  "patchField",
48  patchFieldType,
49  *patchConstructorTablePtr_
50  ) << exit(FatalError);
51  }
52 
53  auto* patchTypeCtor = patchConstructorTable(p.type());
54 
55  if (patchTypeCtor)
56  {
57  return patchTypeCtor(p, iF);
58  }
59  else
60  {
61  return ctorPtr(p, iF);
62  }
63 }
64 
65 
66 template<class Type>
68 (
69  const faPatch& p,
70  const DimensionedField<Type, edgeMesh>& iF,
71  const dictionary& dict
72 )
73 {
74  DebugInFunction << "Constructing faePatchField" << endl;
75 
76  const word patchFieldType(dict.get<word>("type"));
77 
78  auto* ctorPtr = dictionaryConstructorTable(patchFieldType);
79 
80  if (!ctorPtr)
81  {
82  if (!disallowGenericFaePatchField)
83  {
84  ctorPtr = dictionaryConstructorTable("generic");
85  }
86 
87  if (!ctorPtr)
88  {
90  << "Unknown patchField type " << patchFieldType
91  << " for patch type " << p.type() << nl << nl
92  << "Valid patchField types are :" << nl
93  << dictionaryConstructorTablePtr_->sortedToc()
94  << exit(FatalIOError);
95  }
96  }
97 
98  auto* patchTypeCtor = dictionaryConstructorTable(p.type());
99 
100  if (patchTypeCtor && patchTypeCtor != ctorPtr)
101  {
103  << "inconsistent patch and patchField types for \n"
104  << " patch type " << p.type()
105  << " and patchField type " << patchFieldType
106  << exit(FatalIOError);
107  }
108 
109  return ctorPtr(p, iF, dict);
110 }
111 
112 
113 template<class Type>
115 (
116  const faePatchField<Type>& ptf,
117  const faPatch& p,
118  const DimensionedField<Type, edgeMesh>& iF,
119  const faPatchFieldMapper& pfMapper
120 )
121 {
122  DebugInFunction << "Constructing faePatchField<Type>" << endl;
123 
124  auto* ctorPtr = patchMapperConstructorTable(ptf.type());
125 
126  if (!ctorPtr)
127  {
129  (
130  "patchField",
131  ptf.type(),
132  *patchMapperConstructorTablePtr_
133  ) << exit(FatalError);
134  }
135 
136  auto* patchTypeCtor = patchMapperConstructorTable(p.type());
137 
138  if (patchTypeCtor)
139  {
140  return patchTypeCtor(ptf, p, iF, pfMapper);
141  }
142 
143  return ctorPtr(ptf, p, iF, pfMapper);
144 }
145 
146 
147 // ************************************************************************* //
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:57
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Definition: Ostream.H:381
Foam::faePatchField::New
static tmp< faePatchField< Type > > New(const word &, const faPatch &, const DimensionedField< Type, edgeMesh > &)
DebugInFunction
#define DebugInFunction
Definition: messageStream.H:445
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
FatalErrorInLookup
#define FatalErrorInLookup(lookupTag, lookupName, lookupTable)
Definition: error.H:472
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
Foam::nl
constexpr char nl
Definition: Ostream.H:424
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Definition: error.H:494