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,
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,
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,
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::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::faePatchField
faePatchField<Type> abstract base class. This class gives a fat-interface to all derived classes cove...
Definition: edgeFieldsFwd.H:49
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::faePatchField::New
static tmp< faePatchField< Type > > New(const word &, const faPatch &, const DimensionedField< Type, edgeMesh > &)
Return a pointer to a new patchField created on freestore given.
Definition: faePatchFieldNew.C:33
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::faPatchFieldMapper
Definition: faPatchFieldMapper.H:44
DebugInFunction
#define DebugInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:388
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
FatalErrorInLookup
#define FatalErrorInLookup(lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalError.
Definition: error.H:457
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::nl
constexpr char nl
Definition: Ostream.H:404
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
Foam::faPatch
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition: faPatch.H:69
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54