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 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 )
64 :
66 {
67  // Call this evaluation in derived classes
68  //this->evaluate(Pstream::commsTypes::blocking);
69 }
70 
71 
72 template<class Type>
74 (
76 )
77 :
79 {}
80 
81 
82 template<class Type>
84 (
87 )
88 :
90 {}
91 
92 
93 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
94 
95 template<class Type>
98 {
99  const Field<Type>& iField = this->primitiveField();
100  const labelUList& nbrFaceCells =
101  this->cyclicPatch().neighbFvPatch().faceCells();
102 
103  tmp<Field<Type>> tpnf(new Field<Type>(this->size()));
104  Field<Type>& pnf = tpnf.ref();
105 
106  Field<Type> jf(this->jump());
107  if (!this->cyclicPatch().owner())
108  {
109  jf *= -1.0;
110  }
111 
112  if (this->doTransform())
113  {
114  forAll(*this, facei)
115  {
116  pnf[facei] = transform
117  (
118  this->forwardT()[0], iField[nbrFaceCells[facei]]
119  ) - jf[facei];
120  }
121  }
122  else
123  {
124  forAll(*this, facei)
125  {
126  pnf[facei] = iField[nbrFaceCells[facei]] - jf[facei];
127  }
128  }
129 
130  return tpnf;
131 }
132 
133 
134 template<class Type>
136 (
137  solveScalarField& result,
138  const bool add,
139  const solveScalarField& psiInternal,
140  const scalarField& coeffs,
141  const direction cmpt,
142  const Pstream::commsTypes
143 ) const
144 {
146 }
147 
148 
149 template<class Type>
151 (
152  Field<Type>& result,
153  const bool add,
154  const Field<Type>& psiInternal,
155  const scalarField& coeffs,
156  const Pstream::commsTypes
157 ) const
158 {
159  Field<Type> pnf(this->size());
160 
161  const labelUList& nbrFaceCells =
162  this->cyclicPatch().neighbFvPatch().faceCells();
163 
164  // only apply jump to original field
165  if (&psiInternal == &this->primitiveField())
166  {
167  Field<Type> jf(this->jump());
168 
169  if (!this->cyclicPatch().owner())
170  {
171  jf *= -1.0;
172  }
173 
174  forAll(*this, facei)
175  {
176  pnf[facei] = psiInternal[nbrFaceCells[facei]] - jf[facei];
177  }
178  }
179  else
180  {
181  forAll(*this, facei)
182  {
183  pnf[facei] = psiInternal[nbrFaceCells[facei]];
184  }
185  }
186 
187  // Transform according to the transformation tensors
188  this->transformCoupleField(pnf);
189 
190  // Multiply the field by coefficients and add into the result
191  this->addToInternalField(result, !add, coeffs, pnf);
192 }
193 
194 
195 // ************************************************************************* //
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:519
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::jumpCyclicFvPatchField::updateInterfaceMatrix
virtual void updateInterfaceMatrix(solveScalarField &result, const bool add, const solveScalarField &psiInternal, const scalarField &coeffs, const direction cmpt, const Pstream::commsTypes commsType) const
Update result field based on interface functionality.
Definition: jumpCyclicFvPatchField.C:136
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:445
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:228
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:121
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::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:97
Foam::UList< label >
Foam::direction
uint8_t direction
Definition: direction.H:52
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
jumpCyclicFvPatchField.H
Foam::DimensionedField
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Definition: DimensionedField.H:54