cyclicACMIFvPatch.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) 2013-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 "cyclicACMIFvPatch.H"
28 #include "fvMesh.H"
29 #include "transform.H"
30 
31 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
32 
33 namespace Foam
34 {
35  defineTypeNameAndDebug(cyclicACMIFvPatch, 0);
36  addToRunTimeSelectionTable(fvPatch, cyclicACMIFvPatch, polyPatch);
37 }
38 
39 
40 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
41 
43 {
44  if (cyclicACMIPolyPatch_.updated())
45  {
46  if (debug)
47  {
48  Pout<< "cyclicACMIFvPatch::updateAreas() : updating fv areas for "
49  << name() << " and " << this->nonOverlapPatch().name()
50  << endl;
51  }
52 
53  // owner couple
54  const_cast<vectorField&>(Sf()) = patch().faceAreas();
55  const_cast<scalarField&>(magSf()) = mag(patch().faceAreas());
56 
57  // owner non-overlapping
58  const fvPatch& nonOverlapPatch = this->nonOverlapPatch();
59  const_cast<vectorField&>(nonOverlapPatch.Sf()) =
60  nonOverlapPatch.patch().faceAreas();
61  const_cast<scalarField&>(nonOverlapPatch.magSf()) =
62  mag(nonOverlapPatch.patch().faceAreas());
63 
64  // neighbour couple
65  const cyclicACMIFvPatch& nbrACMI = neighbPatch();
66  const_cast<vectorField&>(nbrACMI.Sf()) =
67  nbrACMI.patch().faceAreas();
68  const_cast<scalarField&>(nbrACMI.magSf()) =
69  mag(nbrACMI.patch().faceAreas());
70 
71  // neighbour non-overlapping
72  const fvPatch& nbrNonOverlapPatch = nbrACMI.nonOverlapPatch();
73  const_cast<vectorField&>(nbrNonOverlapPatch.Sf()) =
74  nbrNonOverlapPatch.patch().faceAreas();
75  const_cast<scalarField&>(nbrNonOverlapPatch.magSf()) =
76  mag(nbrNonOverlapPatch.patch().faceAreas());
77 
78  // set the updated flag
79  cyclicACMIPolyPatch_.setUpdated(false);
80  }
81 }
82 
83 
85 {
86  if (coupled())
87  {
88  const cyclicACMIFvPatch& nbrPatch = neighbFvPatch();
89  const scalarField deltas(nf() & coupledFvPatch::delta());
90 
91  // These deltas are of the cyclic part alone - they are
92  // not affected by the amount of overlap with the nonOverlapPatch
93  scalarField nbrDeltas
94  (
96  (
97  nbrPatch.nf() & nbrPatch.coupledFvPatch::delta()
98  )
99  );
100 
101  scalar tol = cyclicACMIPolyPatch::tolerance();
102 
103 
104  forAll(deltas, facei)
105  {
106  scalar di = deltas[facei];
107  scalar dni = nbrDeltas[facei];
108 
109  if (dni < tol)
110  {
111  // Avoid zero weights on disconnected faces. This value
112  // will be weighted with the (zero) face area so will not
113  // influence calculations.
114  w[facei] = 1.0;
115  }
116  else
117  {
118  w[facei] = dni/(di + dni);
119  }
120  }
121  }
122  else
123  {
124  // Behave as uncoupled patch
126  }
127 }
128 
129 
130 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
131 
133 {
134  return Pstream::parRun() || (this->size() && neighbFvPatch().size());
135 }
136 
137 
139 {
140  if (coupled())
141  {
142  const cyclicACMIFvPatch& nbrPatch = neighbFvPatch();
143 
144  const vectorField patchD(coupledFvPatch::delta());
145 
146  vectorField nbrPatchD(interpolate(nbrPatch.coupledFvPatch::delta()));
147 
148 
149  tmp<vectorField> tpdv(new vectorField(patchD.size()));
150  vectorField& pdv = tpdv.ref();
151 
152  // do the transformation if necessary
153  if (parallel())
154  {
155  forAll(patchD, facei)
156  {
157  const vector& ddi = patchD[facei];
158  const vector& dni = nbrPatchD[facei];
159 
160  pdv[facei] = ddi - dni;
161  }
162  }
163  else
164  {
165  forAll(patchD, facei)
166  {
167  const vector& ddi = patchD[facei];
168  const vector& dni = nbrPatchD[facei];
169 
170  pdv[facei] = ddi - transform(forwardT()[0], dni);
171  }
172  }
173 
174  return tpdv;
175  }
176  else
177  {
178  return coupledFvPatch::delta();
179  }
180 }
181 
182 
184 (
185  const labelUList& internalData
186 ) const
187 {
188  return patchInternalField(internalData);
189 }
190 
191 
193 (
194  const Pstream::commsTypes commsType,
195  const labelUList& iF
196 ) const
197 {
198  return neighbFvPatch().patchInternalField(iF);
199 }
200 
201 
202 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:428
void makeWeights(scalarField &) const
Make patch weighting factors.
const scalarField & magSf() const
Return face area magnitudes.
Definition: fvPatch.C:136
commsTypes
Types of communications.
Definition: UPstream.H:64
void updateAreas() const
Update the patch areas after AMI update.
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
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:163
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:253
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Macros for easy insertion into run-time selection tables.
virtual tmp< labelField > internalFieldTransfer(const Pstream::commsTypes commsType, const labelUList &internalData) const
Return neighbour field.
Cyclic patch for Arbitrarily Coupled Mesh Interface (ACMI)
virtual tmp< vectorField > delta() const
Return delta (P to N) vectors across coupled patch.
const polyPatch & patch() const
Return the polyPatch.
Definition: fvPatch.H:143
3D tensor transformation operations.
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:61
virtual bool coupled() const
Return true if this patch is coupled. This is equivalent.
const vectorField::subField faceAreas() const
Return face normals.
Definition: polyPatch.C:290
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)
virtual const fvPatch & nonOverlapPatch() const
Return non-overlapping fvPatch.
const vectorField & Sf() const
Return face area vectors.
Definition: fvPatch.C:130
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:394
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
virtual tmp< vectorField > delta() const =0
Return delta (P to N) vectors across coupled patch.
dimensioned< scalar > mag(const dimensioned< Type > &)
Field< vector > vectorField
Specialisation of Field<T> for vector.
A class for managing temporary objects.
Definition: PtrList.H:53
virtual tmp< labelField > interfaceInternalField(const labelUList &internalData) const
Return the values of the given internal data adjacent to.
Namespace for OpenFOAM.
static scalar tolerance()
Overlap tolerance.
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:477