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 | Copyright (C) 2011-2012 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 (
45  const fvPatch& p,
47  const fvPatchFieldMapper& mapper
48 )
49 :
50  cyclicFvPatchField<Type>(ptf, p, iF, mapper)
51 {}
52 
53 
54 template<class Type>
56 (
57  const fvPatch& p,
59  const dictionary& dict
60 )
61 :
63 {
64  // Call this evaluation in derived classes
65  //this->evaluate(Pstream::blocking);
66 }
67 
68 
69 template<class Type>
71 (
73 )
74 :
76 {}
77 
78 
79 template<class Type>
81 (
84 )
85 :
87 {}
88 
89 
90 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
91 
92 template<class Type>
95 {
96  const Field<Type>& iField = this->internalField();
97  const labelUList& nbrFaceCells =
98  this->cyclicPatch().neighbFvPatch().faceCells();
99 
100  tmp<Field<Type> > tpnf(new Field<Type>(this->size()));
101  Field<Type>& pnf = tpnf();
102 
103  Field<Type> jf(this->jump());
104  if (!this->cyclicPatch().owner())
105  {
106  jf *= -1.0;
107  }
108 
109  if (this->doTransform())
110  {
111  forAll(*this, facei)
112  {
113  pnf[facei] = transform
114  (
115  this->forwardT()[0], iField[nbrFaceCells[facei]]
116  ) - jf[facei];
117  }
118  }
119  else
120  {
121  forAll(*this, facei)
122  {
123  pnf[facei] = iField[nbrFaceCells[facei]] - jf[facei];
124  }
125  }
126 
127  return tpnf;
128 }
129 
130 
131 template<class Type>
133 (
134  scalarField& result,
135  const scalarField& psiInternal,
136  const scalarField& coeffs,
137  const direction cmpt,
138  const Pstream::commsTypes
139 ) const
140 {
142  (
143  "void Foam::jumpCyclicFvPatchField<Type>::updateInterfaceMatrix"
144  "("
145  "scalarField&, "
146  "const scalarField&, "
147  "const scalarField&, "
148  "const direction, "
149  "const Pstream::commsTypes"
150  ") const"
151  );
152 }
153 
154 
155 template<class Type>
157 (
158  Field<Type>& result,
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  this->cyclicPatch().neighbFvPatch().faceCells();
168 
169  // only apply jump to original field
170  if (&psiInternal == &this->internalField())
171  {
172  Field<Type> jf(this->jump());
173 
174  if (!this->cyclicPatch().owner())
175  {
176  jf *= -1.0;
177  }
178 
179  forAll(*this, facei)
180  {
181  pnf[facei] = psiInternal[nbrFaceCells[facei]] - jf[facei];
182  }
183  }
184  else
185  {
186  forAll(*this, facei)
187  {
188  pnf[facei] = psiInternal[nbrFaceCells[facei]];
189  }
190  }
191 
192  // Transform according to the transformation tensors
193  this->transformCoupleField(pnf);
194 
195  // Multiply the field by coefficients and add into the result
196  const labelUList& faceCells = this->cyclicPatch().faceCells();
197  forAll(faceCells, elemI)
198  {
199  result[faceCells[elemI]] -= coeffs[elemI]*pnf[elemI];
200  }
201 }
202 
203 
204 // ************************************************************************* //
unsigned char direction
Definition: direction.H:43
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
jumpCyclicFvPatchField(const fvPatch &, const DimensionedField< Type, volMesh > &)
Construct from patch and internal field.
Foam::fvPatchFieldMapper.
tmp< Field< Type > > patchNeighbourField() const
Return neighbour coupled given internal cell data.
A list of keyword definitions, which are a keyword followed by any number of values (e...
Definition: dictionary.H:137
This boundary condition enforces a cyclic condition between a pair of boundaries. ...
dictionary dict
volScalarField & p
Definition: createFields.H:51
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:465
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.
commsTypes
Types of communications.
Definition: UPstream.H:64
#define forAll(list, i)
Definition: UList.H:421
Pre-declare SubField and related Field type.
Definition: Field.H:57
This boundary condition provides a base class for coupled-cyclic conditions with a specified &#39;jump&#39; (...
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
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
#define notImplemented(functionName)
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:356
A class for managing temporary objects.
Definition: PtrList.H:118
conserve internalField()+