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-2014 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(), vector::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();
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 // ************************************************************************* //
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:380
virtual tmp< vectorField > delta() const =0
Return delta (P to N) vectors across coupled patch.
Cyclic patch for Arbitrary Mesh Interface (AMI)
virtual bool coupled() const
Return true if this patch is coupled. This is equivalent.
bool interpolate(const vector &p1, const vector &p2, const vector &o, vector &n, scalar l)
Definition: curveTools.C:75
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
virtual tmp< labelField > internalFieldTransfer(const Pstream::commsTypes commsType, const labelUList &internalData) const
Return neighbour field.
Namespace for OpenFOAM.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
void makeWeights(scalarField &) const
Make patch weighting factors.
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:465
Field< vector > vectorField
Specialisation of Field<T> for vector.
commsTypes
Types of communications.
Definition: UPstream.H:64
#define forAll(list, i)
Definition: UList.H:421
Macros for easy insertion into run-time selection tables.
tmp< vectorField > nf() const
Return face normals.
Definition: fvPatch.C:124
virtual void makeWeights(scalarField &) const
Make patch weighting factors.
Definition: fvPatch.C:150
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
static const Vector zero
Definition: Vector.H:80
3D tensor transformation operations.
virtual tmp< vectorField > delta() const
Return delta (P to N) vectors across coupled patch.
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
A class for managing temporary objects.
Definition: PtrList.H:118
virtual tmp< labelField > interfaceInternalField(const labelUList &internalData) const
Return the values of the given internal data adjacent to.
defineTypeNameAndDebug(combustionModel, 0)