wedgeFaPatchField.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 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "wedgeFaPatch.H"
29 #include "wedgeFaPatchField.H"
30 #include "transformField.H"
31 #include "symmTransform.H"
32 
33 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
34 
35 template<class Type>
37 (
38  const faPatch& p,
40 )
41 :
42  transformFaPatchField<Type>(p, iF)
43 {}
44 
45 
46 template<class Type>
48 (
49  const wedgeFaPatchField<Type>& ptf,
50  const faPatch& p,
52  const faPatchFieldMapper& mapper
53 )
54 :
55  transformFaPatchField<Type>(ptf, p, iF, mapper)
56 {
57  if (!isType<wedgeFaPatch>(this->patch()))
58  {
60  << "Field type does not correspond to patch type for patch "
61  << this->patch().index() << "." << endl
62  << "Field type: " << typeName << endl
63  << "Patch type: " << this->patch().type()
65  }
66 }
67 
68 
69 template<class Type>
71 (
72  const faPatch& p,
73  const DimensionedField<Type, areaMesh>& iF,
74  const dictionary& dict
75 )
76 :
77  transformFaPatchField<Type>(p, iF, dict)
78 {
79  if (!isType<wedgeFaPatch>(p))
80  {
82  << "patch " << this->patch().index() << " not wedge type. "
83  << "Patch type = " << p.type()
84  << exit(FatalIOError);
85  }
86 
87  this->evaluate();
88 }
89 
90 
91 template<class Type>
93 (
94  const wedgeFaPatchField<Type>& ptf,
96 )
97 :
98  transformFaPatchField<Type>(ptf, iF)
99 {}
100 
101 
102 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
103 
104 template<class Type>
106 {
107  if constexpr (!is_rotational_vectorspace_v<Type>)
108  {
109  // Rotational-invariant type: treat like zero-gradient
110  return tmp<Field<Type>>::New(this->size(), Foam::zero{});
111  }
112  else
113  {
114  const auto& rot = refCast<const wedgeFaPatch>(this->patch()).faceT();
115 
116  const Field<Type> pif(this->patchInternalField());
117 
118  const auto& dc = this->patch().deltaCoeffs();
119 
120  return
121  (
122  (0.5*dc)
123  * (transform(rot, pif) - pif)
124  );
125  }
126 }
127 
128 
129 template<class Type>
131 {
132  if (!this->updated())
133  {
134  this->updateCoeffs();
135  }
136 
137  if constexpr (!is_rotational_vectorspace_v<Type>)
138  {
139  // Rotational-invariant type: treat like zero-gradient
140  this->extrapolateInternal();
141  }
142  else
143  {
144  const auto& rot = refCast<const wedgeFaPatch>(this->patch()).edgeT();
145 
147  (
148  transform(rot, this->patchInternalField())
149  );
150  }
151 }
152 
153 
154 template<class Type>
157 {
158  const auto& rot = refCast<const wedgeFaPatch>(this->patch()).faceT();
159 
160  const vector diagV = 0.5*(I - rot).diag();
161 
162  return tmp<Field<Type>>::New
163  (
164  this->size(),
165  transformMask<Type>
166  (
167  pow
168  (
169  diagV,
170  pTraits
171  <
172  typename powProduct<vector, pTraits<Type>::rank>::type
173  >::zero
174  )
175  )
176  );
177 }
178 
179 
180 // ************************************************************************* //
3D symmetric tensor transformation operations.
dictionary dict
const faPatch & patch() const noexcept
Return the patch.
Definition: faPatchField.H:231
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:125
commsTypes
Communications types.
Definition: UPstream.H:77
virtual tmp< Field< Type > > snGradTransformDiag() const
Return face-gradient transform diagonal.
error FatalError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL ERROR&#39; header text and sta...
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:600
friend Ostream & operator(Ostream &, const faPatchField< Type > &)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:529
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.
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
wedgeFaPatchField(const faPatch &, const DimensionedField< Type, areaMesh > &)
Construct from patch and internal field.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Evaluate the patch field.
Author Zeljko Tukovic, FMENA Hrvoje Jasak, Wikki Ltd.
Vector< scalar > vector
Definition: vector.H:57
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition: faPatch.H:72
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 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
label index() const noexcept
The index of this patch in the boundaryMesh.
Author Zeljko Tukovic, FMENA Hrvoje Jasak, Wikki Ltd.
volScalarField & p
A class for managing temporary objects.
Definition: HashPtrTable.H:50
A FieldMapper for finite-area patch fields.
IOerror FatalIOError
Error stream (stdout output on all processes), with additional &#39;FOAM FATAL IO ERROR&#39; header text and ...