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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2013-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "cyclicACMIFvPatch.H"
30 #include "fvMesh.H"
31 #include "transform.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  defineTypeNameAndDebug(cyclicACMIFvPatch, 0);
38  addToRunTimeSelectionTable(fvPatch, cyclicACMIFvPatch, polyPatch);
39 }
40 
41 
42 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
43 
45 {
46  if (cyclicACMIPolyPatch_.updated())
47  {
48  if (debug)
49  {
50  Pout<< "cyclicACMIFvPatch::updateAreas() : updating fv areas for "
51  << name() << " and " << this->nonOverlapPatch().name()
52  << endl;
53  }
54 
55  // owner couple
56  const_cast<vectorField&>(Sf()) = patch().faceAreas();
57  const_cast<scalarField&>(magSf()) = mag(patch().faceAreas());
58 
59  // owner non-overlapping
60  const fvPatch& nonOverlapPatch = this->nonOverlapPatch();
61  const_cast<vectorField&>(nonOverlapPatch.Sf()) =
63  const_cast<scalarField&>(nonOverlapPatch.magSf()) =
65 
66  // neighbour couple
67  const cyclicACMIFvPatch& nbrACMI = neighbPatch();
68  const_cast<vectorField&>(nbrACMI.Sf()) =
69  nbrACMI.patch().faceAreas();
70  const_cast<scalarField&>(nbrACMI.magSf()) =
71  mag(nbrACMI.patch().faceAreas());
72 
73  // neighbour non-overlapping
74  const fvPatch& nbrNonOverlapPatch = nbrACMI.nonOverlapPatch();
75  const_cast<vectorField&>(nbrNonOverlapPatch.Sf()) =
76  nbrNonOverlapPatch.patch().faceAreas();
77  const_cast<scalarField&>(nbrNonOverlapPatch.magSf()) =
78  mag(nbrNonOverlapPatch.patch().faceAreas());
79 
80  // set the updated flag
81  cyclicACMIPolyPatch_.setUpdated(false);
82  }
83 }
84 
85 
87 {
88  if (coupled())
89  {
90  const cyclicACMIFvPatch& nbrPatch = neighbFvPatch();
91  const scalarField deltas(nf() & coupledFvPatch::delta());
92 
93  // These deltas are of the cyclic part alone - they are
94  // not affected by the amount of overlap with the nonOverlapPatch
95  scalarField nbrDeltas
96  (
98  (
99  nbrPatch.nf() & nbrPatch.coupledFvPatch::delta()
100  )
101  );
102 
103  scalar tol = cyclicACMIPolyPatch::tolerance();
104 
105 
106  forAll(deltas, facei)
107  {
108  scalar di = deltas[facei];
109  scalar dni = nbrDeltas[facei];
110 
111  if (dni < tol)
112  {
113  // Avoid zero weights on disconnected faces. This value
114  // will be weighted with the (zero) face area so will not
115  // influence calculations.
116  w[facei] = 1.0;
117  }
118  else
119  {
120  w[facei] = dni/(di + dni);
121  }
122  }
123  }
124  else
125  {
126  // Behave as uncoupled patch
128  }
129 }
130 
131 
132 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
133 
135 {
136  return Pstream::parRun() || (this->size() && neighbFvPatch().size());
137 }
138 
139 
141 {
142  if (coupled())
143  {
144  const cyclicACMIFvPatch& nbrPatch = neighbFvPatch();
145 
146  const vectorField patchD(coupledFvPatch::delta());
147 
148  vectorField nbrPatchD(interpolate(nbrPatch.coupledFvPatch::delta()));
149 
150 
151  tmp<vectorField> tpdv(new vectorField(patchD.size()));
152  vectorField& pdv = tpdv.ref();
153 
154  // do the transformation if necessary
155  if (parallel())
156  {
157  forAll(patchD, facei)
158  {
159  const vector& ddi = patchD[facei];
160  const vector& dni = nbrPatchD[facei];
161 
162  pdv[facei] = ddi - dni;
163  }
164  }
165  else
166  {
167  forAll(patchD, facei)
168  {
169  const vector& ddi = patchD[facei];
170  const vector& dni = nbrPatchD[facei];
171 
172  pdv[facei] = ddi - transform(forwardT()[0], dni);
173  }
174  }
175 
176  return tpdv;
177  }
178  else
179  {
180  return coupledFvPatch::delta();
181  }
182 }
183 
184 
186 (
187  const labelUList& internalData
188 ) const
189 {
190  return patchInternalField(internalData);
191 }
192 
193 
195 (
196  const Pstream::commsTypes commsType,
197  const labelUList& iF
198 ) const
199 {
200  return neighbFvPatch().patchInternalField(iF);
201 }
202 
203 
204 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::cyclicACMIPolyPatch::setUpdated
void setUpdated(bool flag) const
Reset the updated flag.
Definition: cyclicACMIPolyPatchI.H:30
Foam::fvPatch::Sf
const vectorField & Sf() const
Return face area vectors.
Definition: fvPatch.C:126
Foam::cyclicACMIFvPatch::updateAreas
void updateAreas() const
Update the patch areas after AMI update.
Definition: cyclicACMIFvPatch.C:44
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:59
Foam::coupledFvPatch::delta
virtual tmp< vectorField > delta() const =0
Return delta (P to N) vectors across coupled patch.
Definition: coupledFvPatch.C:46
Foam::UPstream::parRun
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:414
Foam::cyclicACMIPolyPatch::tolerance
static scalar tolerance()
Overlap tolerance.
Definition: cyclicACMIPolyPatchI.H:79
Foam::cyclicACMIPolyPatch::updated
bool updated() const
Return access to the updated flag.
Definition: cyclicACMIPolyPatchI.H:36
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:337
Foam::fvPatch::name
virtual const word & name() const
Return name.
Definition: fvPatch.H:151
Foam::Pout
prefixOSstream Pout
An Ostream wrapper for parallel output to std::cout.
Foam::transform
dimensionSet transform(const dimensionSet &ds)
Return the argument; transformations do not change the dimensions.
Definition: dimensionSet.C:519
Foam::cyclicACMIFvPatch::delta
virtual tmp< vectorField > delta() const
Return delta (P to N) vectors across coupled patch.
Definition: cyclicACMIFvPatch.C:140
Foam::cyclicACMIFvPatch::coupled
virtual bool coupled() const
Return true if this patch is coupled. This is equivalent.
Definition: cyclicACMIFvPatch.C:134
Foam::cyclicACMIFvPatch::internalFieldTransfer
virtual tmp< labelField > internalFieldTransfer(const Pstream::commsTypes commsType, const labelUList &internalData) const
Return neighbour field.
Definition: cyclicACMIFvPatch.C:195
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:290
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:54
Foam::fvPatch::nf
tmp< vectorField > nf() const
Return face normals.
Definition: fvPatch.C:120
Foam::tmp::ref
T & ref() const
Definition: tmpI.H:258
Foam::interpolate
bool interpolate(const vector &p1, const vector &p2, const vector &o, vector &n, scalar l)
Definition: curveTools.C:75
Foam::Field< vector >
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:63
Foam::cyclicACMIFvPatch::neighbPatch
virtual const cyclicACMIFvPatch & neighbPatch() const
Return neighbour fvPatch.
Definition: cyclicACMIFvPatch.H:113
Foam::cyclicACMIFvPatch::nonOverlapPatch
virtual const fvPatch & nonOverlapPatch() const
Return non-overlapping fvPatch.
Definition: cyclicACMIFvPatch.H:128
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:66
Foam::Vector< scalar >
Foam::polyPatch::faceAreas
const vectorField::subField faceAreas() const
Return face normals.
Definition: polyPatch.C:317
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::UList< label >
Foam::cyclicACMIFvPatch::interfaceInternalField
virtual tmp< labelField > interfaceInternalField(const labelUList &internalData) const
Return the values of the given internal data adjacent to.
Definition: cyclicACMIFvPatch.C:186
Foam::fvPatch::patch
const polyPatch & patch() const
Return the polyPatch.
Definition: fvPatch.H:145
cyclicACMIFvPatch.H
transform.H
3D tensor transformation operations.
Foam::fvPatch::magSf
const scalarField & magSf() const
Return face area magnitudes.
Definition: fvPatch.C:132
Foam::cyclicACMIFvPatch::makeWeights
void makeWeights(scalarField &) const
Make patch weighting factors.
Definition: cyclicACMIFvPatch.C:86
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::fvPatch::makeWeights
virtual void makeWeights(scalarField &) const
Make patch weighting factors.
Definition: fvPatch.C:146
Foam::cyclicACMIFvPatch
Cyclic patch for Arbitrarily Coupled Mesh Interface (ACMI)
Definition: cyclicACMIFvPatch.H:53