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 {
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()) =
56  const_cast<scalarField&>(nonOverlapPatch.magSf()) =
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
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 // ************************************************************************* //
Foam::cyclicACMIPolyPatch::setUpdated
void setUpdated(bool flag) const
Reset the updated flag.
Definition: cyclicACMIPolyPatchI.H:28
Foam::fvPatch::Sf
const vectorField & Sf() const
Return face area vectors.
Definition: fvPatch.C:130
Foam::cyclicACMIFvPatch::updateAreas
void updateAreas() const
Update the patch areas after AMI update.
Definition: cyclicACMIFvPatch.C:42
w
volScalarField w(IOobject("w", runTime.timeName(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE), mesh, dimensionedScalar("w", dimensionSet(0, 0, 0, 0, 0, 0, 0), 0.0))
Foam::Vector< scalar >::zero
static const Vector zero
Definition: Vector.H:80
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
Foam::coupledFvPatch::delta
virtual tmp< vectorField > delta() const =0
Return delta (P to N) vectors across coupled patch.
Definition: coupledFvPatch.C:44
Foam::fvPatch::delta
virtual tmp< vectorField > delta() const
Return cell-centre to face-centre vector.
Definition: fvPatch.C:142
Foam::UPstream::parRun
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:377
Foam::cyclicACMIPolyPatch::updated
bool updated() const
Return access to the updated flag.
Definition: cyclicACMIPolyPatchI.H:34
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
Foam::cyclicACMIFvPatch::delta
virtual tmp< vectorField > delta() const
Return delta (P to N) vectors across coupled patch.
Definition: cyclicACMIFvPatch.C:121
Foam::cyclicACMIFvPatch::coupled
virtual bool coupled() const
Return true if this patch is coupled. This is equivalent.
Definition: cyclicACMIFvPatch.C:115
Foam::cyclicACMIFvPatch::internalFieldTransfer
virtual tmp< labelField > internalFieldTransfer(const Pstream::commsTypes commsType, const labelUList &internalData) const
Return neighbour field.
Definition: cyclicACMIFvPatch.C:194
Foam::transform
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:465
Foam::vectorField
Field< vector > vectorField
Specialisation of Field<T> for vector.
Definition: primitiveFieldsFwd.H:49
Foam::fvPatch::size
virtual label size() const
Return size.
Definition: fvPatch.H:161
Foam::fvPatch::nf
tmp< vectorField > nf() const
Return face normals.
Definition: fvPatch.C:124
Foam::interpolate
bool interpolate(const vector &p1, const vector &p2, const vector &o, vector &n, scalar l)
Definition: curveTools.C:75
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::cyclicACMIFvPatch::neighbPatch
virtual const cyclicACMIFvPatch & neighbPatch() const
Return neighbour fvPatch.
Definition: cyclicACMIFvPatch.H:111
Foam::cyclicACMIFvPatch::nonOverlapPatch
virtual const fvPatch & nonOverlapPatch() const
Return non-overlapping fvPatch.
Definition: cyclicACMIFvPatch.H:126
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
fvMesh.H
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::UPstream::commsTypes
commsTypes
Types of communications.
Definition: UPstream.H:64
Foam::Vector< scalar >
Foam::polyPatch::faceAreas
const vectorField::subField faceAreas() const
Return face normals.
Definition: polyPatch.C:314
Foam::UList
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
Foam::cyclicACMIFvPatch::interfaceInternalField
virtual tmp< labelField > interfaceInternalField(const labelUList &internalData) const
Return the values of the given internal data adjacent to.
Definition: cyclicACMIFvPatch.C:185
Foam::cyclicACMIFvPatch::cyclicACMIPolyPatch_
const cyclicACMIPolyPatch & cyclicACMIPolyPatch_
Definition: cyclicACMIFvPatch.H:58
Foam::fvPatch::patch
const polyPatch & patch() const
Return the polyPatch.
Definition: fvPatch.H:143
cyclicACMIFvPatch.H
transform.H
3D tensor transformation operations.
Foam::fvPatch::magSf
const scalarField & magSf() const
Return face area magnitudes.
Definition: fvPatch.C:136
Foam::cyclicACMIFvPatch::makeWeights
void makeWeights(scalarField &) const
Make patch weighting factors.
Definition: cyclicACMIFvPatch.C:79
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::fvPatch::makeWeights
virtual void makeWeights(scalarField &) const
Make patch weighting factors.
Definition: fvPatch.C:150
Foam::cyclicACMIFvPatch
Cyclic patch for Arbitrarily Coupled Mesh Interface (ACMI)
Definition: cyclicACMIFvPatch.H:51