Loading...
Searching...
No Matches
basicSymmetryFvPatchField.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) 2025 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
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\*---------------------------------------------------------------------------*/
30#include "symmTransformField.H"
31
32// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
33
34template<class Type>
36(
37 const fvPatch& p,
49 const fvPatch& p,
51 const fvPatchFieldMapper& mapper
53:
54 transformFvPatchField<Type>(ptf, p, iF, mapper)
55{}
56
57
58template<class Type>
60(
61 const fvPatch& p,
63 const dictionary& dict
64)
65:
67{
68 this->evaluate();
69}
70
71
72template<class Type>
74(
77)
78:
79 transformFvPatchField<Type>(ptf, iF)
80{}
81
82
83// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
84
85template<class Type>
87{
89 {
90 // Rotational-invariant type : treat like zero-gradient
91 result = Foam::zero{};
92 }
93 else
94 {
95 // Get patch internal field, stored temporarily in result
96 this->patchInternalField(result);
97 const auto& pif = result;
98
99 tmp<vectorField> tnHat = this->patch().nf();
100 const auto& nHat = tnHat();
101
102 const auto& dc = this->patch().deltaCoeffs();
103
104 const label len = result.size();
105
106 // (dc/2.0)*(transform(I - 2.0*sqr(nHat), iF) - iF);
107
108 for (label i = 0; i < len; ++i)
109 {
110 result[i] =
111 (
112 (0.5*dc[i])
113 * (transform(I - 2.0*sqr(nHat[i]), pif[i]) - pif[i])
114 );
116 }
117}
118
119
120template<class Type>
121Foam::tmp<Foam::Field<Type>>
123{
125 {
126 // Rotational-invariant type : treat like zero-gradient
127 return tmp<Field<Type>>::New(this->size(), Foam::zero{});
128 }
129 else
130 {
131 auto tresult = tmp<Field<Type>>::New(this->size());
132 this->snGrad(static_cast<UList<Type>&>(tresult.ref()));
133 return tresult;
134 }
135}
136
137
138template<class Type>
140{
141 if (!this->updated())
142 {
143 this->updateCoeffs();
144 }
145
147 {
148 // Rotational-invariant type : treat like zero-gradient
149 this->extrapolateInternal();
150 }
151 else
152 {
153 tmp<vectorField> nHat = this->patch().nf();
154
155 const Field<Type> pif(this->patchInternalField());
156
158 (
159 0.5*(pif + transform(I - 2.0*sqr(nHat), pif))
160 );
161 }
164}
165
166
167template<class Type>
170{
172 {
173 // Rotational-invariant type
174 // FatalErrorInFunction
175 // << "Should not be called for this type"
176 // << ::Foam::abort(FatalError);
177 return tmp<Field<Type>>::New(this->size(), Foam::zero{});
178 }
179 else
180 {
181 tmp<vectorField> diag(cmptMag(this->patch().nf()));
182
184 }
185}
186
187
188// ************************************************************************* //
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition UList.H:89
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
commsTypes
Communications types.
Definition UPstream.H:81
A symmetry patch. The "value" entry is NO_READ, NO_WRITE.
basicSymmetryFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
virtual tmp< Field< Type > > snGrad() const
Retrieve patch-normal gradient at boundary.
virtual tmp< Field< Type > > snGradTransformDiag() const
Return face-gradient transform diagonal.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Evaluate the patch field.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
const fvPatch & patch() const noexcept
Return the patch.
bool updated() const noexcept
True if the boundary condition has already been updated.
A FieldMapper for finite-volume patch fields.
virtual tmp< Field< Type > > patchInternalField() const
Return internal field next to patch.
virtual void updateCoeffs()
Update the coefficients associated with the patch field.
void extrapolateInternal()
Assign the patch field from the internal field.
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::buffered)
Evaluate the patch field, sets updated() to false.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition fvPatch.H:71
A traits class, which is primarily used for primitives and vector-space.
Definition pTraits.H:64
A class for managing temporary objects.
Definition tmp.H:75
transformFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition zero.H:58
volScalarField & p
const std::string patch
OpenFOAM patch number as a std::string.
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.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
tmp< Field< Type1 > > transformFieldMask(const Field< Type2 > &fld)
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
static const Identity< scalar > I
Definition Identity.H:100
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
constexpr bool is_rotational_vectorspace_v
The is_rotational_vectorspace value of Type.
Definition pTraits.H:251
void cmptMag(FieldField< Field, Type > &cf, const FieldField< Field, Type > &f)
Vector< scalar > vector
Definition vector.H:57
void diag(pointPatchField< vector > &, const pointPatchField< tensor > &)
dictionary dict