jumpCyclicFvPatchField.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2022 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "jumpCyclicFvPatchField.H"
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
30 template<class Type>
32 (
33  const fvPatch& p,
35 )
36 :
38 {}
39 
40 
41 template<class Type>
43 (
44  const fvPatch& p,
46  const dictionary& dict
47 )
48 :
50 {
51  // Call this evaluation in derived classes
52  // this->evaluate(Pstream::commsTypes::blocking);
53 }
54 
55 
56 template<class Type>
58 (
60  const fvPatch& p,
62  const fvPatchFieldMapper& mapper
63 )
64 :
65  cyclicFvPatchField<Type>(ptf, p, iF, mapper)
66 {}
67 
68 
69 template<class Type>
71 (
74 )
75 :
77 {}
78 
79 
80 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
81 
82 template<class Type>
85 (
87 ) const
88 {
89  const Field<Type>& iField = this->primitiveField();
90  const labelUList& nbrFaceCells =
91  this->cyclicPatch().neighbFvPatch().faceCells();
92 
93  tmp<Field<Type>> tpnf(new Field<Type>(this->size()));
94  Field<Type>& pnf = tpnf.ref();
95 
96  Field<Type> jf(this->jump());
97  if (!this->cyclicPatch().owner())
98  {
99  jf *= -1.0;
100  }
101 
102  forAll(*this, facei)
103  {
104  pnf[facei] =
105  this->transform().transform(iField[nbrFaceCells[facei]])
106  - jf[facei];
107  }
108 
109  return tpnf;
110 }
111 
112 
113 template<class Type>
115 (
116  scalarField& result,
117  const scalarField& psiInternal,
118  const scalarField& coeffs,
119  const direction cmpt,
120  const Pstream::commsTypes
121 ) const
122 {
124 }
125 
126 
127 template<class Type>
129 (
130  Field<Type>& result,
131  const Field<Type>& psiInternal,
132  const scalarField& coeffs,
133  const Pstream::commsTypes
134 ) const
135 {
136  Field<Type> pnf(this->size());
137 
138  const labelUList& nbrFaceCells =
139  this->cyclicPatch().neighbFvPatch().faceCells();
140 
141  // only apply jump to original field
142  if (&psiInternal == &this->primitiveField())
143  {
144  Field<Type> jf(this->jump());
145 
146  if (!this->cyclicPatch().owner())
147  {
148  jf *= -1.0;
149  }
150 
151  forAll(*this, facei)
152  {
153  pnf[facei] = psiInternal[nbrFaceCells[facei]] - jf[facei];
154  }
155  }
156  else
157  {
158  forAll(*this, facei)
159  {
160  pnf[facei] = psiInternal[nbrFaceCells[facei]];
161  }
162  }
163 
164  // Transform according to the transformation tensors
165  this->transformCoupleField(pnf);
166 
167  // Multiply the field by coefficients and add into the result
168  const labelUList& faceCells = this->cyclicPatch().faceCells();
169  forAll(faceCells, elemI)
170  {
171  result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI];
172  }
173 }
174 
175 
176 // ************************************************************************* //
dictionary dict
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:156
virtual tmp< Field< Type > > patchNeighbourField(const Pstream::commsTypes) const
Return neighbour coupled given internal cell data.
commsTypes
Types of communications.
Definition: UPstream.H:64
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:181
uint8_t direction
Definition: direction.H:45
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:63
Pre-declare SubField and related Field type.
Definition: Field.H:56
jumpCyclicFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Foam::fvPatchFieldMapper.
This boundary condition provides a base class for coupled-cyclic conditions with a specified &#39;jump&#39; (...
virtual void updateInterfaceMatrix(scalarField &result, const scalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Update result field based on interface functionality.
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
This boundary condition enforces a cyclic condition between a pair of boundaries. ...
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
friend dimensionSet transform(const dimensionSet &)
Return the argument; transformations do not change the dimensions.
volScalarField & p
A class for managing temporary objects.
Definition: PtrList.H:53
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:353
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:483