basicSymmetryFaPatchField.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) 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 
30 #include "symmTransformField.H"
31 
32 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33 
34 template<class Type>
36 (
37  const faPatch& p,
39 )
40 :
41  transformFaPatchField<Type>(p, iF)
42 {}
43 
44 
45 template<class Type>
47 (
49  const faPatch& p,
51  const faPatchFieldMapper& mapper
52 )
53 :
54  transformFaPatchField<Type>(ptf, p, iF, mapper)
55 {}
56 
57 
58 template<class Type>
60 (
61  const faPatch& p,
63  const dictionary& dict
64 )
65 :
66  transformFaPatchField<Type>(p, iF, dict)
67 {
68  this->evaluate();
69 }
70 
71 
72 template<class Type>
74 (
77 )
78 :
79  transformFaPatchField<Type>(ptf, iF)
80 {}
81 
82 
83 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
84 
85 template<class Type>
88 {
89  if constexpr (!is_rotational_vectorspace_v<Type>)
90  {
91  // Rotational-invariant type : treat like zero-gradient
92  return tmp<Field<Type>>::New(this->size(), Foam::zero{});
93  }
94  else
95  {
96  tmp<vectorField> nHat = this->patch().edgeNormals();
97 
98  const auto& dc = this->patch().deltaCoeffs();
99 
100  const Field<Type> pif(this->patchInternalField());
101 
102  return
103  (
104  (0.5*dc)
105  * (transform(I - 2.0*sqr(nHat), pif) - pif)
106  );
107  }
108 }
109 
110 
111 template<class Type>
112 void Foam::basicSymmetryFaPatchField<Type>::evaluate(const Pstream::commsTypes)
113 {
114  if (!this->updated())
115  {
116  this->updateCoeffs();
117  }
118 
119  if constexpr (!is_rotational_vectorspace_v<Type>)
120  {
121  // Rotational-invariant type : treat like zero-gradient
122  this->extrapolateInternal();
123  }
124  else
125  {
126  tmp<vectorField> nHat = this->patch().edgeNormals();
127 
128  const Field<Type> pif(this->patchInternalField());
129 
130  Field<Type>::operator=
131  (
132  0.5*(pif + transform(I - 2.0*sqr(nHat), pif))
133  );
134  }
137 }
138 
139 
140 template<class Type>
143 {
144  tmp<vectorField> diag(cmptMag(this->patch().edgeNormals()));
145 
146  return transformFieldMask<Type>(pow<vector, pTraits<Type>::rank>(diag));
147 }
148 
149 
150 // ************************************************************************* //
dictionary dict
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
virtual tmp< Field< Type > > snGradTransformDiag() const
Return face-gradient transform diagonal.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
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.
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.
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
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
string evaluate(label fieldWidth, const std::string &s, size_t pos=0, size_t len=std::string::npos)
String evaluation with specified (positive, non-zero) field width.
basicSymmetryFaPatchField(const faPatch &, const DimensionedField< Type, areaMesh > &)
Construct from patch and internal field.
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
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.
virtual tmp< Field< Type > > snGrad() const
Return gradient at boundary.