jumpCyclicFvPatchField.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-2017 OpenFOAM Foundation
9  Copyright (C) 2019-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 
29 #include "jumpCyclicFvPatchField.H"
30 
31 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
32 
33 template<class Type>
35 (
36  const fvPatch& p,
38 )
39 :
41 {}
42 
43 
44 template<class Type>
46 (
48  const fvPatch& p,
50  const fvPatchFieldMapper& mapper
51 )
52 :
53  cyclicFvPatchField<Type>(ptf, p, iF, mapper)
54 {}
55 
56 
57 template<class Type>
59 (
60  const fvPatch& p,
62  const dictionary& dict,
63  const bool valueRequired
64 )
65 :
66  cyclicFvPatchField<Type>(p, iF, dict, valueRequired)
67 {
68  // Call this evaluation in derived classes
69  //this->evaluate(Pstream::commsTypes::blocking);
70 }
71 
72 
73 template<class Type>
75 (
77 )
78 :
80 {}
81 
82 
83 template<class Type>
85 (
88 )
89 :
91 {}
92 
93 
94 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
95 
96 template<class Type>
99 {
100  const Field<Type>& iField = this->primitiveField();
101  const labelUList& nbrFaceCells =
102  this->cyclicPatch().neighbFvPatch().faceCells();
103 
104  auto tpnf = tmp<Field<Type>>::New(this->size());
105  auto& pnf = tpnf.ref();
106 
107  Field<Type> jf(this->jump());
108  if (!this->cyclicPatch().owner())
109  {
110  jf *= -1.0;
111  }
112 
113  if (this->doTransform())
114  {
115  forAll(*this, facei)
116  {
117  pnf[facei] = transform
118  (
119  this->forwardT()[0], iField[nbrFaceCells[facei]]
120  ) - jf[facei];
121  }
122  }
123  else
124  {
125  forAll(*this, facei)
126  {
127  pnf[facei] = iField[nbrFaceCells[facei]] - jf[facei];
128  }
129  }
130 
131  return tpnf;
132 }
133 
134 
135 template<class Type>
137 (
138  solveScalarField& result,
139  const bool add,
140  const lduAddressing& lduAddr,
141  const label patchId,
142  const solveScalarField& psiInternal,
143  const scalarField& coeffs,
144  const direction cmpt,
145  const Pstream::commsTypes
146 ) const
147 {
149 }
150 
151 
152 template<class Type>
154 (
155  Field<Type>& result,
156  const bool add,
157  const lduAddressing& lduAddr,
158  const label patchId,
159  const Field<Type>& psiInternal,
160  const scalarField& coeffs,
161  const Pstream::commsTypes
162 ) const
163 {
164  Field<Type> pnf(this->size());
165 
166  const labelUList& nbrFaceCells =
167  lduAddr.patchAddr
168  (
169  this->cyclicPatch().neighbPatchID()
170  );
171 
172  // only apply jump to original field
173  if (&psiInternal == &this->primitiveField())
174  {
175  Field<Type> jf(this->jump());
176 
177  if (!this->cyclicPatch().owner())
178  {
179  jf *= -1.0;
180  }
181 
182  forAll(*this, facei)
183  {
184  pnf[facei] = psiInternal[nbrFaceCells[facei]] - jf[facei];
185  }
186  }
187  else
188  {
189  forAll(*this, facei)
190  {
191  pnf[facei] = psiInternal[nbrFaceCells[facei]];
192  }
193  }
194 
195  // Transform according to the transformation tensors
196  this->transformCoupleField(pnf);
197 
198  const labelUList& faceCells = lduAddr.patchAddr(patchId);
199 
200  // Multiply the field by coefficients and add into the result
201  this->addToInternalField(result, !add, faceCells, coeffs, pnf);
202 }
203 
204 
205 // ************************************************************************* //
Foam::lduAddressing
The class contains the addressing required by the lduMatrix: upper, lower and losort.
Definition: lduAddressing.H:114
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::transform
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:521
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:517
Foam::Field
Generic templated field type.
Definition: Field.H:63
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:65
Foam::jumpCyclicFvPatchField
This boundary condition provides a base class for coupled-cyclic conditions with a specified 'jump' (...
Definition: jumpCyclicFvPatchField.H:59
Foam::jumpCyclicFvPatchField::jumpCyclicFvPatchField
jumpCyclicFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Definition: jumpCyclicFvPatchField.C:35
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:123
Foam::add
void add(FieldField< Field1, typename typeOfSum< Type1, Type2 >::type > &f, const FieldField< Field1, Type1 > &f1, const FieldField< Field2, Type2 > &f2)
Definition: FieldFieldFunctions.C:939
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
Foam::jumpCyclicFvPatchField::patchNeighbourField
tmp< Field< Type > > patchNeighbourField() const
Return neighbour coupled given internal cell data.
Definition: jumpCyclicFvPatchField.C:98
Foam::UList< label >
Foam::jumpCyclicFvPatchField::updateInterfaceMatrix
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.
Definition: jumpCyclicFvPatchField.C:137
Foam::direction
uint8_t direction
Definition: direction.H:52
Foam::lduAddressing::patchAddr
virtual const labelUList & patchAddr(const label patchNo) const =0
Return patch to internal addressing given patch number.
Foam::cyclicFvPatchField
This boundary condition enforces a cyclic condition between a pair of boundaries.
Definition: cyclicFvPatchField.H:72
Foam::fvPatchFieldMapper
Foam::fvPatchFieldMapper.
Definition: fvPatchFieldMapper.H:47
patchId
label patchId(-1)
jumpCyclicFvPatchField.H
Foam::faceCells
Smooth ATC in cells next to a set of patches supplied by type.
Definition: faceCells.H:56
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54