calculatedFvPatchField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2023 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "calculatedFvPatchField.H"
27 #include "fieldMapper.H"
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33  template<class Type>
35  {
36  return pTraits<Type>::nan;
37  }
38 
39  template<>
41  {
42  return -labelMax;
43  }
44 }
45 
46 
47 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 
49 template<class Type>
51 {
53 }
54 
55 
56 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
57 
58 template<class Type>
60 (
61  const fvPatch& p,
63 )
64 :
65  fvPatchField<Type>(p, iF)
66 {}
67 
68 
69 template<class Type>
71 (
72  const fvPatch& p,
74  const dictionary& dict,
75  const bool valueRequired
76 )
77 :
78  fvPatchField<Type>(p, iF, dict, valueRequired)
79 {}
80 
81 
82 template<class Type>
84 (
86  const fvPatch& p,
88  const fieldMapper& mapper,
89  const bool mappingRequired
90 )
91 :
92  fvPatchField<Type>(ptf, p, iF, mapper, false)
93 {
94  if (mappingRequired)
95  {
96  mapper(*this, ptf, calculatedFvPatchFieldNaN<Type>());
97  }
98 }
99 
100 
101 template<class Type>
103 (
104  const calculatedFvPatchField<Type>& ptf,
106 )
107 :
108  fvPatchField<Type>(ptf, iF)
109 {}
110 
111 
112 template<class Type>
115 (
116  const fvPatch& p
117 )
118 {
119  typename patchConstructorTable::iterator patchTypeCstrIter =
120  patchConstructorTablePtr_->find(p.type());
121 
122  if (patchTypeCstrIter != patchConstructorTablePtr_->end())
123  {
124  return patchTypeCstrIter()
125  (
126  p,
128  );
129  }
130  else
131  {
132  return tmp<fvPatchField<Type>>
133  (
135  (
136  p,
138  )
139  );
140  }
141 }
142 
143 
144 template<class Type>
145 template<class Type2>
147 (
148  const fvPatchField<Type2>& pf
149 )
150 {
151  return NewCalculatedType(pf.patch());
152 }
153 
154 
155 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
156 
157 template<class Type>
159 (
160  const fvPatchField<Type>& ptf,
161  const fieldMapper& mapper
162 )
163 {
164  mapper(*this, ptf, calculatedFvPatchFieldNaN<Type>());
165 }
166 
167 
168 template<class Type>
171 (
172  const tmp<scalarField>&
173 ) const
174 {
176  << "cannot be called for a calculatedFvPatchField"
177  << "\n on patch " << this->patch().name()
178  << " of field " << this->internalField().name()
179  << " in file " << this->internalField().objectPath()
180  << "\n You are probably trying to solve for a field with a "
181  "default boundary condition."
182  << abort(FatalError);
183 
184  return *this;
185 }
186 
187 
188 template<class Type>
191 (
192  const tmp<scalarField>&
193 ) const
194 {
196  << "cannot be called for a calculatedFvPatchField"
197  << "\n on patch " << this->patch().name()
198  << " of field " << this->internalField().name()
199  << " in file " << this->internalField().objectPath()
200  << "\n You are probably trying to solve for a field with a "
201  "default boundary condition."
202  << abort(FatalError);
203 
204  return *this;
205 }
206 
207 
208 template<class Type>
211 {
213  << "cannot be called for a calculatedFvPatchField"
214  << "\n on patch " << this->patch().name()
215  << " of field " << this->internalField().name()
216  << " in file " << this->internalField().objectPath()
217  << "\n You are probably trying to solve for a field with a "
218  "default boundary condition."
219  << abort(FatalError);
220 
221  return *this;
222 }
223 
224 
225 template<class Type>
228 {
230  << "cannot be called for a calculatedFvPatchField"
231  << "\n on patch " << this->patch().name()
232  << " of field " << this->internalField().name()
233  << " in file " << this->internalField().objectPath()
234  << "\n You are probably trying to solve for a field with a "
235  "default boundary condition."
236  << abort(FatalError);
237 
238  return *this;
239 }
240 
241 
242 template<class Type>
244 {
246  writeEntry(os, "value", *this);
247 }
248 
249 
250 // ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
static const DimensionedField< Type, GeoMesh > & null()
Return a null DimensionedField.
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:57
This boundary condition is not designed to be evaluated; it is assumed that the value is assigned via...
calculatedFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
virtual void write(Ostream &) const
Write.
tmp< Field< Type > > gradientInternalCoeffs() const
Return the matrix diagonal coefficients corresponding to the.
virtual tmp< Field< Type > > valueInternalCoeffs(const tmp< scalarField > &) const
Return the matrix diagonal coefficients corresponding to the.
tmp< Field< Type > > gradientBoundaryCoeffs() const
Return the matrix source coefficients corresponding to the.
virtual tmp< Field< Type > > valueBoundaryCoeffs(const tmp< scalarField > &) const
Return the matrix source coefficients corresponding to the.
virtual void map(const fvPatchField< Type > &, const fieldMapper &)
Map the given fvPatchField onto this fvPatchField.
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:162
Abstract base class for field mapping.
Definition: fieldMapper.H:48
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:88
virtual void write(Ostream &) const
Write.
Definition: fvPatchField.C:229
static tmp< fvPatchField< Type > > NewCalculatedType(const fvPatch &)
Return a pointer to a new calculatedFvPatchField created on.
const fvPatch & patch() const
Return patch.
Definition: fvPatchField.H:356
static const word & calculatedType()
Return the type of the calculated for of fvPatchField.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:64
Traits class for primitives.
Definition: pTraits.H:53
A class for managing temporary objects.
Definition: tmp.H:55
A class for handling words, derived from string.
Definition: word.H:62
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:334
Namespace for OpenFOAM.
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
errorManip< error > abort(error &err)
Definition: errorManip.H:131
label calculatedFvPatchFieldNaN< label >()
Type calculatedFvPatchFieldNaN()
void writeEntry(Ostream &os, const HashTable< T, Key, Hash > &ht)
Definition: HashTableIO.C:96
error FatalError
static const label labelMax
Definition: label.H:62
dictionary dict
volScalarField & p