Loading...
Searching...
No Matches
cyclicFaPatchField.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) 2019-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\*---------------------------------------------------------------------------*/
28
29#include "cyclicFaPatchField.H"
30
31// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32
33template<class Type>
35(
36 const faPatch& p,
38)
40 coupledFaPatchField<Type>(p, iF),
41 cyclicPatch_(refCast<const cyclicFaPatch>(p))
42{}
43
44
45template<class Type>
47(
48 const cyclicFaPatchField<Type>& ptf,
49 const faPatch& p,
51 const faPatchFieldMapper& mapper
52)
53:
54 coupledFaPatchField<Type>(ptf, p, iF, mapper),
55 cyclicPatch_(refCast<const cyclicFaPatch>(p))
56{
57 if (!isA<cyclicFaPatch>(this->patch()))
58 {
60 << "\n patch type '" << p.type()
61 << "' not constraint type '" << typeName << "'"
62 << "\n for patch " << p.name()
63 << " of field " << this->internalField().name()
64 << " in file " << this->internalField().objectPath()
65 << exit(FatalError);
66 }
67}
68
69
70template<class Type>
72(
73 const faPatch& p,
74 const DimensionedField<Type, areaMesh>& iF,
75 const dictionary& dict,
77)
78:
79 coupledFaPatchField<Type>(p, iF, dict, IOobjectOption::NO_READ),
80 cyclicPatch_(refCast<const cyclicFaPatch>(p, dict))
81{
83 {
85 << "\n patch type '" << p.type()
86 << "' not constraint type '" << typeName << "'"
87 << "\n for patch " << p.name()
88 << " of field " << this->internalField().name()
89 << " in file " << this->internalField().objectPath()
91 }
92
93 if (IOobjectOption::isReadRequired(requireValue))
94 {
96 }
97}
98
99
100template<class Type>
102(
103 const cyclicFaPatchField<Type>& ptf
104)
105:
107 coupledFaPatchField<Type>(ptf),
108 cyclicPatch_(ptf.cyclicPatch_)
109{}
110
111
112template<class Type>
114(
115 const cyclicFaPatchField<Type>& ptf,
117)
118:
119 coupledFaPatchField<Type>(ptf, iF),
120 cyclicPatch_(ptf.cyclicPatch_)
121{}
122
123
124// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
125
126template<class Type>
128(
129 UList<Type>& pnf
130) const
131{
132 const Field<Type>& iField = this->primitiveField();
133 const labelUList& faceCells = cyclicPatch_.faceCells();
134
135 const label sizeby2 = pnf.size()/2;
136
137 if (doTransform())
138 {
139 for (label facei=0; facei<sizeby2; ++facei)
140 {
141 pnf[facei] = transform
142 (
143 forwardT()[0], iField[faceCells[facei + sizeby2]]
144 );
145
146 pnf[facei + sizeby2] = transform
147 (
148 reverseT()[0], iField[faceCells[facei]]
149 );
150 }
151 }
152 else
153 {
154 for (label facei=0; facei<sizeby2; ++facei)
155 {
156 pnf[facei] = iField[faceCells[facei + sizeby2]];
157 pnf[facei + sizeby2] = iField[faceCells[facei]];
159 }
160}
161
162
163template<class Type>
164Foam::tmp<Foam::Field<Type>>
166{
167 auto tpnf = tmp<Field<Type>>::New(this->size());
168 this->patchNeighbourField(tpnf.ref());
169 return tpnf;
170}
171
172
173template<class Type>
175(
176 solveScalarField& result,
177 const bool add,
178 const lduAddressing& lduAddr,
179 const label patchId,
180 const solveScalarField& psiInternal,
181 const scalarField& coeffs,
182 const direction cmpt,
183 const Pstream::commsTypes commsType
184) const
185{
186 solveScalarField pnf(this->size());
187
188 const label sizeby2 = this->size()/2;
189 const labelUList& faceCells = cyclicPatch_.faceCells();
190
191 for (label facei = 0; facei < sizeby2; ++facei)
192 {
193 pnf[facei] = psiInternal[faceCells[facei + sizeby2]];
194 pnf[facei + sizeby2] = psiInternal[faceCells[facei]];
195 }
196
197 // Transform according to the transformation tensors
198 transformCoupleField(pnf, cmpt);
200 // Multiply the field by coefficients and add into the result
201 this->addToInternalField(result, !add, faceCells, coeffs, pnf);
202}
203
204
205template<class Type>
207(
208 Field<Type>& result,
209 const bool add,
210 const lduAddressing& lduAddr,
211 const label patchId,
212 const Field<Type>& psiInternal,
213 const scalarField& coeffs,
214 const Pstream::commsTypes commsType
215) const
216{
217 Field<Type> pnf(this->size());
218
219 const label sizeby2 = this->size()/2;
220 const labelUList& faceCells = cyclicPatch_.faceCells();
221
222 for (label facei = 0; facei < sizeby2; ++facei)
223 {
224 pnf[facei] = psiInternal[faceCells[facei + sizeby2]];
225 pnf[facei + sizeby2] = psiInternal[faceCells[facei]];
226 }
227
228 // Transform according to the transformation tensors
229 transformCoupleField(pnf);
230
231 // Multiply the field by coefficients and add into the result
232 this->addToInternalField(result, !add, faceCells, coeffs, pnf);
233}
234
235
236// ************************************************************************* //
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 simple container of IOobject preferences. Can also be used for general handling of read/no-read/rea...
bool isReadRequired() const noexcept
True if (MUST_READ | READ_MODIFIED) bits are set.
static bool isReadRequired(readOption opt) noexcept
True if (MUST_READ | READ_MODIFIED) bits are set.
readOption
Enumeration defining read preferences.
const word & name() const noexcept
Return the object name.
Definition IOobjectI.H:205
fileName objectPath() const
The complete path + object name.
Definition IOobjectI.H:313
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
@ buffered
"buffered" : (MPI_Bsend, MPI_Recv)
Definition UPstream.H:82
Author Zeljko Tukovic, FMENA Hrvoje Jasak, Wikki Ltd.
coupledFaPatchField(const faPatch &, const DimensionedField< Type, areaMesh > &)
Construct from patch and internal field.
virtual void evaluate(const Pstream::commsTypes commsType)
Evaluate the patch field.
Foam::cyclicFaPatchField.
virtual bool doTransform() const
Cyclic coupled interface functions.
virtual void updateInterfaceMatrix(solveScalarField &result, const bool add, const lduAddressing &lduAddr, const label patchId, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Update result field based on interface functionality.
virtual const tensorField & reverseT() const
Return neighbour-cell transformation tensor.
virtual tmp< Field< Type > > patchNeighbourField() const
Return neighbour coupled given internal cell data.
virtual const tensorField & forwardT() const
Return face transformation tensor.
cyclicFaPatchField(const faPatch &, const DimensionedField< Type, areaMesh > &)
Construct from patch and internal field.
Cyclic-plane patch.
cyclicLduInterfaceField()=default
Construct null.
void transformCoupleField(Field< Type > &f) const
Transform given patch field.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
const faPatch & patch() const noexcept
Return the patch.
A FieldMapper for finite-area patch fields.
const Field< Type > & primitiveField() const noexcept
Return const-reference to the internal field values.
const DimensionedField< Type, areaMesh > & internalField() const noexcept
Return const-reference to the dimensioned internal field.
Finite area patch class. Used for 2-D non-Euclidian finite area method.
Definition faPatch.H:76
Smooth ATC in cells next to a set of patches supplied by type.
Definition faceCells.H:55
The class contains the addressing required by the lduMatrix: upper, lower and losort.
void addToInternalField(Field< Type > &result, const bool add, const labelUList &faceCells, const scalarField &coeffs, const Field< Type > &vals) const
Add/subtract weighted contributions to internal field.
A class for managing temporary objects.
Definition tmp.H:75
volScalarField & p
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition error.H:629
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
label patchId(-1)
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
Definition typeInfo.H:172
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.
refinementData transform(const tensor &, const refinementData val)
No-op rotational transform for base types.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const word GlobalIOList< Tuple2< scalar, vector > >::typeName("scalarVectorTable")
void add(DimensionedField< scalar, GeoMesh > &result, const dimensioned< scalar > &dt1, const DimensionedField< scalar, GeoMesh > &f2)
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
Definition typeInfo.H:87
Field< solveScalar > solveScalarField
uint8_t direction
Definition direction.H:49
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
error FatalError
Error stream (stdout output on all processes), with additional 'FOAM FATAL ERROR' header text and sta...
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
UList< label > labelUList
A UList of labels.
Definition UList.H:75
dict add("bounds", meshBb)
dictionary dict