cyclicAMIFvPatch.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-2018 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 "cyclicAMIFvPatch.H"
28 #include "fvMesh.H"
29 #include "transform.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(cyclicAMIFvPatch, 0);
36  addToRunTimeSelectionTable(fvPatch, cyclicAMIFvPatch, polyPatch);
37 }
38 
39 
40 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
41 
43 {
44  return nf() & coupledFvPatch::delta();
45 }
46 
47 
49 {
50  if (coupled())
51  {
52  const cyclicAMIFvPatch& nbrPatch = neighbFvPatch();
53 
54  tmp<scalarField> tnbrDeltan;
55  if (applyLowWeightCorrection())
56  {
57  tnbrDeltan =
59  (
60  nbrPatch.nf() & nbrPatch.coupledFvPatch::delta(),
61  scalarField(this->size(), 1.0)
62  );
63  }
64  else
65  {
66  tnbrDeltan =
67  interpolate(nbrPatch.nf() & nbrPatch.coupledFvPatch::delta());
68  }
69 
70  return tnbrDeltan;
71  }
72  else
73  {
74  return tmp<scalarField>();
75  }
76 }
77 
78 
80 {
81  if (coupled())
82  {
83  const scalarField deltan(this->deltan());
84  const scalarField nbrDeltan(this->nbrDeltan());
85 
86  forAll(deltan, facei)
87  {
88  scalar di = deltan[facei];
89  scalar dni = nbrDeltan[facei];
90 
91  w[facei] = dni/(di + dni);
92  }
93  }
94  else
95  {
96  // Behave as uncoupled patch
98  }
99 }
100 
101 
102 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
103 
105 {
106  return Pstream::parRun() || (this->size() && neighbFvPatch().size());
107 }
108 
109 
111 {
112  const cyclicAMIFvPatch& nbrPatch = neighbFvPatch();
113 
114  if (coupled())
115  {
116  const vectorField patchD(coupledFvPatch::delta());
117 
118  tmp<vectorField> tnbrPatchD;
119  if (applyLowWeightCorrection())
120  {
121  tnbrPatchD =
123  (
124  nbrPatch.coupledFvPatch::delta(),
125  vectorField(this->size(), Zero)
126  );
127  }
128  else
129  {
130  tnbrPatchD = interpolate(nbrPatch.coupledFvPatch::delta());
131  }
132 
133  const vectorField& nbrPatchD = tnbrPatchD();
134 
135  tmp<vectorField> tpdv(new vectorField(patchD.size()));
136  vectorField& pdv = tpdv.ref();
137 
138  // do the transformation if necessary
139  if (parallel())
140  {
141  forAll(patchD, facei)
142  {
143  const vector& ddi = patchD[facei];
144  const vector& dni = nbrPatchD[facei];
145 
146  pdv[facei] = ddi - dni;
147  }
148  }
149  else
150  {
151  forAll(patchD, facei)
152  {
153  const vector& ddi = patchD[facei];
154  const vector& dni = nbrPatchD[facei];
155 
156  pdv[facei] = ddi - transform(forwardT()[0], dni);
157  }
158  }
159 
160  return tpdv;
161  }
162  else
163  {
164  return coupledFvPatch::delta();
165  }
166 }
167 
168 
170 (
171  const labelUList& internalData
172 ) const
173 {
174  return patchInternalField(internalData);
175 }
176 
177 
179 (
180  const Pstream::commsTypes commsType,
181  const labelUList& iF
182 ) const
183 {
184  return neighbFvPatch().patchInternalField(iF);
185 }
186 
187 
188 // ************************************************************************* //
virtual tmp< labelField > internalFieldTransfer(const Pstream::commsTypes commsType, const labelUList &internalData) const
Return neighbour field.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
virtual tmp< labelField > interfaceInternalField(const labelUList &internalData) const
Return the values of the given internal data adjacent to.
commsTypes
Types of communications.
Definition: UPstream.H:64
bool interpolate(const vector &p1, const vector &p2, const vector &o, vector &n, scalar l)
Definition: curveTools.C:75
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:174
tmp< vectorField > nf() const
Return face normals.
Definition: fvPatch.C:124
Cyclic patch for Arbitrary Mesh Interface (AMI)
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:163
Macros for easy insertion into run-time selection tables.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
tmp< scalarField > nbrDeltan() const
Return the neighbour patch-normal component of the deltas.
3D tensor transformation operations.
virtual void makeWeights(scalarField &) const
Make patch weighting factors.
Definition: fvPatch.C:150
static const zero Zero
Definition: zero.H:97
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:61
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)
tmp< scalarField > deltan() const
Return the patch-normal component of the deltas.
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:397
virtual bool coupled() const
Return true if this patch is coupled. This is equivalent.
virtual tmp< vectorField > delta() const =0
Return delta (P to N) vectors across coupled patch.
virtual tmp< vectorField > delta() const
Return delta (P to N) vectors across coupled patch.
virtual void makeWeights(scalarField &) const
Make patch weighting factors.
Field< vector > vectorField
Specialisation of Field<T> for vector.
A class for managing temporary objects.
Definition: PtrList.H:53
Namespace for OpenFOAM.
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:477