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-2020 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 "Time.H"
30 #include "transform.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  defineTypeNameAndDebug(cyclicAMIFvPatch, 0);
37  addToRunTimeSelectionTable(fvPatch, cyclicAMIFvPatch, polyPatch);
38 }
39 
40 
41 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
42 
44 {
45  return nf() & coupledFvPatch::delta();
46 }
47 
48 
50 {
51  if (coupled())
52  {
53  const cyclicAMIFvPatch& nbrPatch = neighbFvPatch();
54 
55  tmp<scalarField> tnbrDeltan;
56  if (applyLowWeightCorrection())
57  {
58  tnbrDeltan =
60  (
61  nbrPatch.nf() & nbrPatch.coupledFvPatch::delta(),
62  scalarField(this->size(), 1.0)
63  );
64  }
65  else
66  {
67  tnbrDeltan =
68  interpolate(nbrPatch.nf() & nbrPatch.coupledFvPatch::delta());
69  }
70 
71  return tnbrDeltan;
72  }
73  else
74  {
75  return tmp<scalarField>();
76  }
77 }
78 
79 
81 {
82  if (coupled())
83  {
84  const scalarField deltan(this->deltan());
85  const scalarField nbrDeltan(this->nbrDeltan());
86 
87  forAll(deltan, facei)
88  {
89  scalar di = deltan[facei];
90  scalar dni = nbrDeltan[facei];
91 
92  w[facei] = dni/(di + dni);
93  }
94  }
95  else
96  {
97  // Behave as uncoupled patch
99  }
100 }
101 
102 
103 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
104 
106 {
107  return
109  || !this->boundaryMesh().mesh().time().processorCase();
110 }
111 
112 
114 {
115  const cyclicAMIFvPatch& nbrPatch = neighbFvPatch();
116 
117  if (coupled())
118  {
119  const vectorField patchD(coupledFvPatch::delta());
120 
121  tmp<vectorField> tnbrPatchD;
122  if (applyLowWeightCorrection())
123  {
124  tnbrPatchD =
126  (
127  nbrPatch.coupledFvPatch::delta(),
128  vectorField(this->size(), Zero)
129  );
130  }
131  else
132  {
133  tnbrPatchD = interpolate(nbrPatch.coupledFvPatch::delta());
134  }
135 
136  const vectorField& nbrPatchD = tnbrPatchD();
137 
138  tmp<vectorField> tpdv(new vectorField(patchD.size()));
139  vectorField& pdv = tpdv.ref();
140 
141  // do the transformation if necessary
142  if (transform().transforms())
143  {
144  forAll(patchD, facei)
145  {
146  const vector& ddi = patchD[facei];
147  const vector& dni = nbrPatchD[facei];
148 
149  pdv[facei] = ddi - transform().transform(dni);
150  }
151  }
152  else
153  {
154  forAll(patchD, facei)
155  {
156  const vector& ddi = patchD[facei];
157  const vector& dni = nbrPatchD[facei];
158 
159  pdv[facei] = ddi - dni;
160  }
161  }
162 
163  return tpdv;
164  }
165  else
166  {
167  return coupledFvPatch::delta();
168  }
169 }
170 
171 
173 (
174  const labelUList& internalData
175 ) const
176 {
177  return patchInternalField(internalData);
178 }
179 
180 
182 (
183  const Pstream::commsTypes commsType,
184  const labelUList& iF
185 ) const
186 {
187  return neighbFvPatch().patchInternalField(iF);
188 }
189 
190 
191 // ************************************************************************* //
transformer transforms
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:434
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:181
tmp< vectorField > nf() const
Return face normals.
Definition: fvPatch.C:130
Cyclic patch for Arbitrary Mesh Interface (AMI)
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:164
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:156
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:60
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:399
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.
friend dimensionSet transform(const dimensionSet &)
Return the argument; transformations do not change the dimensions.
A class for managing temporary objects.
Definition: PtrList.H:53
Namespace for OpenFOAM.
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:483