fixedNormalSlipFvPatchField.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) 2017-2021 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 fvPatch& p,
39 )
40 :
41  parent_bctype(p, iF),
42  fixedValue_(p.size(), Zero),
43  writeValue_(false)
44 {}
45 
46 
47 template<class Type>
49 (
51  const fvPatch& p,
53  const fvPatchFieldMapper& mapper
54 )
55 :
56  parent_bctype(ptf, p, iF, mapper),
57  fixedValue_(ptf.fixedValue_, mapper),
58  writeValue_(ptf.writeValue_)
59 {}
60 
61 
62 template<class Type>
64 (
65  const fvPatch& p,
67  const dictionary& dict
68 )
69 :
70  parent_bctype(p, iF),
71  fixedValue_("fixedValue", dict, p.size()),
72  writeValue_(dict.getOrDefault("writeValue", false))
73 {
74  this->patchType() = dict.getOrDefault<word>("patchType", word::null);
75  evaluate();
76 }
77 
78 
79 template<class Type>
81 (
83 )
84 :
85  parent_bctype(ptf),
86  fixedValue_(ptf.fixedValue_),
87  writeValue_(ptf.writeValue_)
88 {}
89 
90 
91 template<class Type>
93 (
96 )
97 :
98  parent_bctype(ptf, iF),
99  fixedValue_(ptf.fixedValue_),
100  writeValue_(ptf.writeValue_)
101 {}
102 
103 
104 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
105 
106 template<class Type>
108 (
109  const fvPatchFieldMapper& m
110 )
111 {
112  parent_bctype::autoMap(m);
113  fixedValue_.autoMap(m);
114 }
115 
116 
117 template<class Type>
119 (
120  const fvPatchField<Type>& ptf,
121  const labelList& addr
122 )
123 {
124  parent_bctype::rmap(ptf, addr);
125 
126  const auto& dmptf =
127  refCast<const fixedNormalSlipFvPatchField<Type>>(ptf);
128 
129  fixedValue_.rmap(dmptf.fixedValue_, addr);
130 }
131 
132 
133 template<class Type>
136 {
137  const vectorField nHat(this->patch().nf());
138  const Field<Type> pif(this->patchInternalField());
139 
140  return
141  (
142  (nHat*(nHat & fixedValue_) + transform(I - sqr(nHat), pif)) - pif
143  )*this->patch().deltaCoeffs();
144 }
145 
146 
147 template<class Type>
149 (
150  const Pstream::commsTypes
151 )
152 {
153  if (!this->updated())
154  {
155  this->updateCoeffs();
156  }
157 
158  const vectorField nHat(this->patch().nf());
159 
161  (
162  nHat*(nHat & fixedValue_)
163  + transform(I - sqr(nHat), this->patchInternalField())
164  );
165 
166  this->parent_bctype::evaluate();
167 }
168 
169 
170 template<class Type>
173 {
174  const vectorField nHat(this->patch().nf());
175  vectorField diag(nHat.size());
176 
177  diag.replace(vector::X, mag(nHat.component(vector::X)));
178  diag.replace(vector::Y, mag(nHat.component(vector::Y)));
180 
181  return transformFieldMask<Type>(pow<vector, pTraits<Type>::rank>(diag));
182 }
183 
184 
185 template<class Type>
187 {
188  this->parent_bctype::write(os);
189  fixedValue_.writeEntry("fixedValue", os);
190 
191  if (writeValue_)
192  {
193  os.writeEntry("writeValue", "true");
194  this->writeEntry("value", os);
195  }
196 }
197 
198 
199 // ************************************************************************* //
Foam::fvPatchField< Type >
Foam::fixedNormalSlipFvPatchField::write
virtual void write(Ostream &) const
Definition: fixedNormalSlipFvPatchField.C:179
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::Vector< scalar >::Z
@ Z
Definition: Vector.H:77
symmTransformField.H
Foam::Vector< scalar >::Y
@ Y
Definition: Vector.H:77
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:63
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:57
Foam::Zero
static constexpr const zero Zero
Definition: zero.H:131
Foam::fixedNormalSlipFvPatchField::autoMap
virtual void autoMap(const fvPatchFieldMapper &m)
Definition: fixedNormalSlipFvPatchField.C:101
Foam::diag
void diag(pointPatchField< vector > &, const pointPatchField< tensor > &)
Definition: pointPatchFieldFunctions.H:280
Foam::fixedNormalSlipFvPatchField::evaluate
virtual void evaluate(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking)
Definition: fixedNormalSlipFvPatchField.C:142
Foam::Field< Type >::operator
friend Ostream & operator(Ostream &, const Field< Type > &)
Foam::transform
dimensionSet transform(const dimensionSet &ds)
Definition: dimensionSet.C:514
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:48
fixedNormalSlipFvPatchField.H
Foam::Field
Generic templated field type.
Definition: Field.H:59
Foam::fixedNormalSlipFvPatchField::fixedNormalSlipFvPatchField
fixedNormalSlipFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Definition: fixedNormalSlipFvPatchField.C:29
Foam::Vector< scalar >::X
@ X
Definition: Vector.H:77
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::pow
dimensionedScalar pow(const dimensionedScalar &ds, const dimensionedScalar &expt)
Definition: dimensionedScalar.C:68
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:119
Foam::fixedNormalSlipFvPatchField
This boundary condition sets the patch-normal component to the field (vector or tensor) to the patch-...
Definition: fixedNormalSlipFvPatchField.H:117
os
OBJstream os(runTime.globalPath()/outputName)
Foam::Field::component
tmp< Field< cmptType > > component(const direction) const
Definition: Field.C:532
Y
PtrList< volScalarField > & Y
Definition: createFieldRefs.H:7
Foam::fixedNormalSlipFvPatchField::snGradTransformDiag
virtual tmp< Field< Type > > snGradTransformDiag() const
Definition: fixedNormalSlipFvPatchField.C:165
Foam::UPstream::commsTypes
commsTypes
Definition: UPstream.H:65
Foam::sqr
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Definition: dimensionedSymmTensor.C:44
Foam::fixedNormalSlipFvPatchField::snGrad
virtual tmp< Field< Type > > snGrad() const
Definition: fixedNormalSlipFvPatchField.C:128
Foam::foamVersion::patch
const std::string patch
Foam::Vector< scalar >
Foam::fvPatchField< Type >::patchType
const word & patchType() const
Definition: fvPatchField.H:371
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: BitOps.H:58
Foam::pTraits
A traits class, which is primarily used for primitives.
Definition: pTraits.H:50
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::word::null
static const word null
Definition: word.H:78
Foam::transformFvPatchField
Foam::transformFvPatchField.
Definition: transformFvPatchField.H:50
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Definition: Ostream.H:232
Foam::vtk::write
void write(vtk::formatter &fmt, const Type &val, const label n=1)
Definition: foamVtkOutputTemplates.C:29
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:41
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:52
Foam::dictionary::getOrDefault
T getOrDefault(const word &keyword, const T &deflt, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:141
Foam::fixedNormalSlipFvPatchField::rmap
virtual void rmap(const fvPatchField< Type > &ptf, const labelList &addr)
Definition: fixedNormalSlipFvPatchField.C:112
Foam::I
static const Identity< scalar > I
Definition: Identity.H:89
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:50
Foam::stringOps::evaluate
string evaluate(label fieldWidth, const std::string &s, size_t pos=0, size_t len=std::string::npos)
Definition: stringOpsEvaluate.C:30