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-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 "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  // Set Sf and magSf for both sides' coupled and non-overlapping patches
47 
48  // owner couple
49  const_cast<vectorField&>(Sf()) = patch().faceAreas();
50  const_cast<scalarField&>(magSf()) = mag(patch().faceAreas());
51 
52  // owner non-overlapping
53  const fvPatch& nonOverlapPatch = this->nonOverlapPatch();
54  const_cast<vectorField&>(nonOverlapPatch.Sf()) =
55  nonOverlapPatch.patch().faceAreas();
56  const_cast<scalarField&>(nonOverlapPatch.magSf()) =
57  mag(nonOverlapPatch.patch().faceAreas());
58 
59  // neighbour couple
60  const cyclicACMIFvPatch& nbrACMI = neighbPatch();
61  const_cast<vectorField&>(nbrACMI.Sf()) =
62  nbrACMI.patch().faceAreas();
63  const_cast<scalarField&>(nbrACMI.magSf()) =
64  mag(nbrACMI.patch().faceAreas());
65 
66  // neighbour non-overlapping
67  const fvPatch& nbrNonOverlapPatch = nbrACMI.nonOverlapPatch();
68  const_cast<vectorField&>(nbrNonOverlapPatch.Sf()) =
69  nbrNonOverlapPatch.patch().faceAreas();
70  const_cast<scalarField&>(nbrNonOverlapPatch.magSf()) =
71  mag(nbrNonOverlapPatch.patch().faceAreas());
72 
73  // set the updated flag
74  cyclicACMIPolyPatch_.setUpdated(false);
75  }
76 }
77 
78 
80 {
81  if (coupled())
82  {
83  const cyclicACMIFvPatch& nbrPatch = neighbFvPatch();
84  const fvPatch& nbrPatchNonOverlap = nonOverlapPatch();
85 
86  const scalarField deltas(nf() & coupledFvPatch::delta());
87 
88  const scalarField nbrDeltas
89  (
91  (
92  nbrPatch.nf() & nbrPatch.coupledFvPatch::delta(),
93  nbrPatchNonOverlap.nf() & nbrPatchNonOverlap.delta()
94  )
95  );
96 
97  forAll(deltas, faceI)
98  {
99  scalar di = deltas[faceI];
100  scalar dni = nbrDeltas[faceI];
101 
102  w[faceI] = dni/(di + dni);
103  }
104  }
105  else
106  {
107  // Behave as uncoupled patch
109  }
110 }
111 
112 
113 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
114 
116 {
117  return Pstream::parRun() || (this->size() && neighbFvPatch().size());
118 }
119 
120 
122 {
123  if (coupled())
124  {
125  const cyclicACMIFvPatch& nbrPatchCoupled = neighbFvPatch();
126  const fvPatch& nbrPatchNonOverlap = nonOverlapPatch();
127 
128  const vectorField patchD(coupledFvPatch::delta());
129 
130  vectorField nbrPatchD
131  (
133  (
134  nbrPatchCoupled.coupledFvPatch::delta(),
135  nbrPatchNonOverlap.delta()
136  )
137  );
138 
139  const vectorField nbrPatchD0
140  (
142  (
143  vectorField(nbrPatchCoupled.size(), vector::zero),
144  nbrPatchNonOverlap.delta()()
145  )
146  );
147 
148  nbrPatchD -= nbrPatchD0;
149 
150  tmp<vectorField> tpdv(new vectorField(patchD.size()));
151  vectorField& pdv = tpdv();
152 
153  // do the transformation if necessary
154  if (parallel())
155  {
156  forAll(patchD, faceI)
157  {
158  const vector& ddi = patchD[faceI];
159  const vector& dni = nbrPatchD[faceI];
160 
161  pdv[faceI] = ddi - dni;
162  }
163  }
164  else
165  {
166  forAll(patchD, faceI)
167  {
168  const vector& ddi = patchD[faceI];
169  const vector& dni = nbrPatchD[faceI];
170 
171  pdv[faceI] = ddi - transform(forwardT()[0], dni);
172  }
173  }
174 
175  return tpdv;
176  }
177  else
178  {
179  return coupledFvPatch::delta();
180  }
181 }
182 
183 
185 (
186  const labelUList& internalData
187 ) const
188 {
189  return patchInternalField(internalData);
190 }
191 
192 
194 (
195  const Pstream::commsTypes commsType,
196  const labelUList& iF
197 ) const
198 {
199  return neighbFvPatch().patchInternalField(iF);
200 }
201 
202 
203 // ************************************************************************* //
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.
const vectorField::subField faceAreas() const
Return face normals.
Definition: polyPatch.C:290
dimensioned< scalar > mag(const dimensioned< Type > &)
void updateAreas() const
Update the patch areas after AMI update.
virtual tmp< vectorField > delta() const
Return cell-centre to face-centre vector.
Definition: fvPatch.C:142
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
const vectorField & Sf() const
Return face area vectors.
Definition: fvPatch.C:130
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
Namespace for OpenFOAM.
void makeWeights(scalarField &) const
Make patch weighting factors.
const polyPatch & patch() const
Return the polyPatch.
Definition: fvPatch.H:143
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
virtual const fvPatch & nonOverlapPatch() const
Return non-overlapping fvPatch.
#define forAll(list, i)
Definition: UList.H:421
Macros for easy insertion into run-time selection tables.
Cyclic patch for Arbitrarily Coupled Mesh Interface (ACMI)
virtual tmp< vectorField > delta() const
Return delta (P to N) vectors across coupled patch.
virtual tmp< labelField > internalFieldTransfer(const Pstream::commsTypes commsType, const labelUList &internalData) const
Return neighbour field.
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< labelField > interfaceInternalField(const labelUList &internalData) const
Return the values of the given internal data adjacent to.
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
const scalarField & magSf() const
Return face area magnitudes.
Definition: fvPatch.C:136
virtual label size() const
Return size.
Definition: fvPatch.H:161
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
A class for managing temporary objects.
Definition: PtrList.H:118
defineTypeNameAndDebug(combustionModel, 0)