wedgeFvPatchField.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) 2024-2025 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 #include "wedgeFvPatch.H"
30 #include "wedgeFvPatchField.H"
31 #include "transformField.H"
32 #include "symmTransform.H"
33 
34 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
35 
36 template<class Type>
38 (
39  const fvPatch& p,
41 )
42 :
43  parent_bctype(p, iF)
44 {}
45 
46 
47 template<class Type>
49 (
50  const wedgeFvPatchField<Type>& ptf,
51  const fvPatch& p,
53  const fvPatchFieldMapper& mapper
54 )
55 :
56  parent_bctype(ptf, p, iF, mapper)
57 {
58  if (!isType<wedgeFvPatch>(this->patch()))
59  {
61  << "\n patch type '" << p.type()
62  << "' not constraint type '" << typeName << "'"
63  << "\n for patch " << p.name()
64  << " of field " << this->internalField().name()
65  << " in file " << this->internalField().objectPath()
67  }
68 }
69 
70 
71 template<class Type>
73 (
74  const fvPatch& p,
75  const DimensionedField<Type, volMesh>& iF,
76  const dictionary& dict
77 )
78 :
79  parent_bctype(p, iF, dict) // "value" is NO_READ
80 {
81  if (!isType<wedgeFvPatch>(p))
82  {
84  << "\n patch type '" << p.type()
85  << "' not constraint type '" << typeName << "'"
86  << "\n for patch " << p.name()
87  << " of field " << this->internalField().name()
88  << " in file " << this->internalField().objectPath()
89  << exit(FatalIOError);
90  }
91 
92  evaluate();
93 }
94 
95 
96 template<class Type>
98 (
99  const wedgeFvPatchField<Type>& ptf,
101 )
102 :
103  parent_bctype(ptf, iF)
104 {}
105 
106 
107 template<class Type>
109 (
110  const wedgeFvPatchField<Type>& ptf
111 )
112 :
113  wedgeFvPatchField<Type>(ptf, ptf.internalField())
114 {}
115 
116 
117 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
118 
119 template<class Type>
121 {
122  if constexpr (!is_rotational_vectorspace_v<Type>)
123  {
124  // Rotational-invariant type : treat like zero-gradient
125  return tmp<Field<Type>>::New(this->size(), Foam::zero{});
126  }
127  else
128  {
129  const auto& rot = refCast<const wedgeFvPatch>(this->patch()).cellT();
130 
131  const Field<Type> pif(this->patchInternalField());
132 
133  const auto& dc = this->patch().deltaCoeffs();
134 
135  return
136  (
137  (0.5*dc)
138  * (transform(rot, pif) - pif)
139  );
140  }
141 }
142 
143 
144 template<class Type>
146 {
147  if (!this->updated())
148  {
149  this->updateCoeffs();
150  }
151 
152  if constexpr (!is_rotational_vectorspace_v<Type>)
153  {
154  // Rotational-invariant type : treat like zero-gradient
155  this->extrapolateInternal();
156  }
157  else
158  {
159  const auto& rot = refCast<const wedgeFvPatch>(this->patch()).faceT();
160 
162  (
163  transform(rot, this->patchInternalField())
164  );
165  }
166 }
167 
168 
169 template<class Type>
172 {
173  const auto& rot = refCast<const wedgeFvPatch>(this->patch()).cellT();
174 
175  const vector diagV = 0.5*(I - rot).diag();
176 
177  return tmp<Field<Type>>::New
178  (
179  this->size(),
180  transformMask<Type>
181  (
182  pow
183  (
184  diagV,
185  pTraits
186  <
187  typename powProduct<vector, pTraits<Type>::rank>::type
188  >::zero
189  )
190  )
191  );
192 }
193 
194 
195 // ************************************************************************* //
3D symmetric tensor transformation operations.
dictionary dict
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
commsTypes
Communications types.
Definition: UPstream.H:77
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
const fvPatch & patch() const noexcept
Return the patch.
Definition: fvPatchField.H:250
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:600
friend Ostream & operator(Ostream &, const fvPatchField< Type > &)
virtual tmp< Field< Type > > snGradTransformDiag() const
Return face-gradient transform diagonal.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:70
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
virtual tmp< Field< Type > > snGrad() const
Return gradient at boundary.
wedgeFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
static const char *const typeName
Typename for Field.
Definition: Field.H:87
Spatial transformation functions for primitive fields.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: POSIX.C:801
void diag(pointPatchField< vector > &, const pointPatchField< tensor > &)
static const Identity< scalar > I
Definition: Identity.H:100
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Evaluate the patch field.
A FieldMapper for finite-volume patch fields.
Vector< scalar > vector
Definition: vector.H:57
This boundary condition is similar to the cyclic condition, except that it is applied to 2-D geometri...
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
Intermediate layer (not used directly as a user boundary condition). The "value" entry is NO_READ...
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:629
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
const DimensionedField< Type, volMesh > & internalField() const noexcept
Return const-reference to the dimensioned internal field.
Definition: fvPatchField.H:706
const std::string patch
OpenFOAM patch number as a std::string.
::Foam::direction rank(const expressions::valueTypeCode) noexcept
The vector-space rank associated with given valueTypeCode.
Definition: exprTraits.C:70
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
volScalarField & p
A class for managing temporary objects.
Definition: HashPtrTable.H:50
IOerror FatalIOError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL IO ERROR&#39; header text and ...