jumpCyclicFvPatchFields.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) 2018-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 
31 #include "volFields.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  makePatchFieldTypeNames(jumpCyclic);
38 }
39 
40 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
41 
42 template<>
44 (
45  solveScalarField& result,
46  const bool add,
47  const solveScalarField& psiInternal,
48  const scalarField& coeffs,
49  const direction cmpt,
51 ) const
52 {
53  solveScalarField pnf(this->size());
54 
55  const labelUList& nbrFaceCells =
56  this->cyclicPatch().neighbFvPatch().faceCells();
57 
58  // only apply jump to original field
59  if
60  (
61  reinterpret_cast<const void*>(&psiInternal)
62  == reinterpret_cast<const void*>(&this->primitiveField())
63  )
64  {
65  Field<scalar> jf(this->jump());
66 
67  if (!this->cyclicPatch().owner())
68  {
69  jf *= -1.0;
70  }
71 
72  forAll(*this, facei)
73  {
74  pnf[facei] = psiInternal[nbrFaceCells[facei]] - jf[facei];
75  }
76  }
77  else
78  {
79  forAll(*this, facei)
80  {
81  pnf[facei] = psiInternal[nbrFaceCells[facei]];
82  }
83  }
84 
85  // Transform according to the transformation tensors
86  this->transformCoupleField(pnf, cmpt);
87 
88  // Multiply the field by coefficients and add into the result
89  this->addToInternalField(result, !add, coeffs, pnf);
90 }
91 
92 
93 template<>
95 (
96  solveScalarField& result,
97  const bool add,
98  const solveScalarField& psiInternal,
99  const scalarField& coeffs,
100  const direction cmpt,
101  const Pstream::commsTypes
102 ) const
103 {
104  solveScalarField pnf(this->size());
105 
106  const labelUList& nbrFaceCells =
107  this->cyclicPatch().neighbFvPatch().faceCells();
108 
109  const Field<vector>& iField = this->primitiveField();
110 
111  // only apply jump to original field
112  if
113  (
114  reinterpret_cast<const void*>(&psiInternal)
115  == reinterpret_cast<const void*>(&(iField.component(cmpt).ref()))
116  )
117  {
118  Field<vector> jf(this->jump());
119 
120  if (!this->cyclicPatch().owner())
121  {
122  jf *= -1.0;
123  }
124 
125  forAll(*this, facei)
126  {
127  pnf[facei] =
128  psiInternal[nbrFaceCells[facei]]
129  - jf[facei].component(cmpt);
130  }
131  }
132  else
133  {
134  forAll(*this, facei)
135  {
136  pnf[facei] = psiInternal[nbrFaceCells[facei]];
137  }
138  }
139 
140  // Transform according to the transformation tensors
141  this->transformCoupleField(pnf, cmpt);
142 
143  // Multiply the field by coefficients and add into the result
144  this->addToInternalField(result, !add, coeffs, pnf);
145 }
146 
147 // ************************************************************************* //
volFields.H
jumpCyclicFvPatchFields.H
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
Foam::Field< solveScalar >
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
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::Field::component
tmp< Field< cmptType > > component(const direction) const
Return a component field of the field.
Definition: Field.C:551
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:69
Foam::makePatchFieldTypeNames
makePatchFieldTypeNames(coupled)
Foam::UList< label >
Foam::direction
uint8_t direction
Definition: direction.H:52