cyclicAMIFvPatch.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-2016 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 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
41 
43 {
44  return Pstream::parRun() || (this->size() && neighbFvPatch().size());
45 }
46 
47 
49 {
50  if (coupled())
51  {
52  const cyclicAMIFvPatch& nbrPatch = neighbFvPatch();
53 
54  const scalarField deltas(nf() & coupledFvPatch::delta());
55 
56  tmp<scalarField> tnbrDeltas;
57  if (applyLowWeightCorrection())
58  {
59  tnbrDeltas =
61  (
62  nbrPatch.nf() & nbrPatch.coupledFvPatch::delta(),
63  scalarField(this->size(), 1.0)
64  );
65  }
66  else
67  {
68  tnbrDeltas =
69  interpolate(nbrPatch.nf() & nbrPatch.coupledFvPatch::delta());
70  }
71 
72  const scalarField& nbrDeltas = tnbrDeltas();
73 
74  forAll(deltas, facei)
75  {
76  scalar di = deltas[facei];
77  scalar dni = nbrDeltas[facei];
78 
79  w[facei] = dni/(di + dni);
80  }
81  }
82  else
83  {
84  // Behave as uncoupled patch
86  }
87 }
88 
89 
91 {
92  const cyclicAMIFvPatch& nbrPatch = neighbFvPatch();
93 
94  if (coupled())
95  {
96  const vectorField patchD(coupledFvPatch::delta());
97 
98  tmp<vectorField> tnbrPatchD;
99  if (applyLowWeightCorrection())
100  {
101  tnbrPatchD =
103  (
104  nbrPatch.coupledFvPatch::delta(),
105  vectorField(this->size(), Zero)
106  );
107  }
108  else
109  {
110  tnbrPatchD = interpolate(nbrPatch.coupledFvPatch::delta());
111  }
112 
113  const vectorField& nbrPatchD = tnbrPatchD();
114 
115  tmp<vectorField> tpdv(new vectorField(patchD.size()));
116  vectorField& pdv = tpdv.ref();
117 
118  // do the transformation if necessary
119  if (parallel())
120  {
121  forAll(patchD, facei)
122  {
123  const vector& ddi = patchD[facei];
124  const vector& dni = nbrPatchD[facei];
125 
126  pdv[facei] = ddi - dni;
127  }
128  }
129  else
130  {
131  forAll(patchD, facei)
132  {
133  const vector& ddi = patchD[facei];
134  const vector& dni = nbrPatchD[facei];
135 
136  pdv[facei] = ddi - transform(forwardT()[0], dni);
137  }
138  }
139 
140  return tpdv;
141  }
142  else
143  {
144  return coupledFvPatch::delta();
145  }
146 }
147 
148 
150 (
151  const labelUList& internalData
152 ) const
153 {
154  return patchInternalField(internalData);
155 }
156 
157 
159 (
160  const Pstream::commsTypes commsType,
161  const labelUList& iF
162 ) const
163 {
164  return neighbFvPatch().patchInternalField(iF);
165 }
166 
167 
168 // ************************************************************************* //
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.
3D tensor transformation operations.
virtual void makeWeights(scalarField &) const
Make patch weighting factors.
Definition: fvPatch.C:150
static const zero Zero
Definition: zero.H:91
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)
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:394
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.
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