cyclicACMIFvPatch.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2013-2020 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 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
41 
42 void Foam::cyclicACMIFvPatch::updateAreas() const
43 {
44  if (cyclicACMIPatch().updated())
45  {
46  if (debug)
47  {
48  Pout<< "cyclicACMIFvPatch::updateAreas() : updating fv areas for "
49  << name() << " and " << nonOverlapFvPatch().name()
50  << endl;
51  }
52 
53  // owner couple
54  const_cast<vectorField&>(Sf()) = patch().faceAreas();
55  const_cast<scalarField&>(magSf()) = patch().magFaceAreas();
56 
57  // owner non-overlapping
58  const fvPatch& nonOverlapPatch = nonOverlapFvPatch();
59  const_cast<vectorField&>(nonOverlapPatch.Sf()) =
60  nonOverlapPatch.patch().faceAreas();
61  const_cast<scalarField&>(nonOverlapPatch.magSf()) =
62  nonOverlapPatch.patch().magFaceAreas();
63 
64  // neighbour couple
65  const cyclicACMIFvPatch& nbrACMI = neighbFvPatch();
66  const_cast<vectorField&>(nbrACMI.Sf()) =
67  nbrACMI.patch().faceAreas();
68  const_cast<scalarField&>(nbrACMI.magSf()) =
69  nbrACMI.patch().magFaceAreas();
70 
71  // neighbour non-overlapping
72  const fvPatch& nbrNonOverlapPatch = nbrACMI.nonOverlapFvPatch();
73  const_cast<vectorField&>(nbrNonOverlapPatch.Sf()) =
74  nbrNonOverlapPatch.patch().faceAreas();
75  const_cast<scalarField&>(nbrNonOverlapPatch.magSf()) =
76  nbrNonOverlapPatch.patch().magFaceAreas();
77 
78  // set the updated flag
79  cyclicACMIPatch().setUpdated(false);
80  }
81 }
82 
83 
84 // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * //
85 
87 {
88  if (coupled())
89  {
90  // These deltas are of the cyclic part alone - they are
91  // not affected by the amount of overlap with the nonOverlapPatch
92  const scalarField deltan(this->deltan());
93  const scalarField nbrDeltan(this->nbrDeltan());
94 
95  forAll(deltan, facei)
96  {
97  scalar di = deltan[facei];
98  scalar dni = nbrDeltan[facei];
99 
100  if (dni < cyclicACMIPolyPatch::tolerance())
101  {
102  // Avoid zero weights on disconnected faces. This value
103  // will be weighted with the (zero) face area so will not
104  // influence calculations.
105  w[facei] = 1.0;
106  }
107  else
108  {
109  w[facei] = dni/(di + dni);
110  }
111  }
112  }
113  else
114  {
115  // Behave as uncoupled patch
117  }
118 }
119 
120 
121 // ************************************************************************* //
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
virtual void makeWeights(scalarField &) const
Make patch weighting factors.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Macros for easy insertion into run-time selection tables.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
3D tensor transformation operations.
virtual void makeWeights(scalarField &) const
Make patch weighting factors.
Definition: fvPatch.C:156
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
prefixOSstream Pout(cout, "Pout")
Definition: IOstreams.H:53
Field< vector > vectorField
Specialisation of Field<T> for vector.
Namespace for OpenFOAM.
static scalar tolerance()
Overlap tolerance.