processorFvPatch.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) 2011-2019 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 "processorFvPatch.H"
28 #include "transformField.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34  defineTypeNameAndDebug(processorFvPatch, 0);
35  addToRunTimeSelectionTable(fvPatch, processorFvPatch, polyPatch);
36 }
37 
38 
39 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
40 
42 {
43  if (Pstream::parRun())
44  {
46 
47  // The face normals point in the opposite direction on the other side
48  const vectorField nbrDelta
49  (
50  procPolyPatch_.neighbFaceCentres()
51  - procPolyPatch_.neighbFaceCellCentres()
52  );
53 
54  const scalarField nfDelta(nf() & delta);
55 
56  const scalarField nbrNfDelta
57  (
58  (
59  procPolyPatch_.neighbFaceAreas()
60  /(mag(procPolyPatch_.neighbFaceAreas()) + vSmall)
61  ) & nbrDelta
62  );
63 
64  forAll(delta, facei)
65  {
66  const scalar ndoi = nfDelta[facei];
67  const scalar ndni = nbrNfDelta[facei];
68  const scalar ndi = ndoi + ndni;
69 
70  if (ndni/vGreat < ndi)
71  {
72  w[facei] = ndni/ndi;
73  }
74  else
75  {
76  const scalar doi = mag(delta[facei]);
77  const scalar dni = mag(nbrDelta[facei]);
78  const scalar di = doi + dni;
79 
80  w[facei] = dni/di;
81  }
82  }
83  }
84  else
85  {
86  w = 1.0;
87  }
88 }
89 
90 
92 {
93  if (Pstream::parRun())
94  {
95  // To the transformation if necessary
96  if (parallel())
97  {
98  return
100  - (
101  procPolyPatch_.neighbFaceCentres()
102  - procPolyPatch_.neighbFaceCellCentres()
103  );
104  }
105  else
106  {
107  return
109  - transform
110  (
111  forwardT(),
112  (
113  procPolyPatch_.neighbFaceCentres()
114  - procPolyPatch_.neighbFaceCellCentres()
115  )
116  );
117  }
118  }
119  else
120  {
121  return coupledFvPatch::delta();
122  }
123 }
124 
125 
127 (
128  const labelUList& internalData
129 ) const
130 {
131  return patchInternalField(internalData);
132 }
133 
134 
136 (
137  const Pstream::commsTypes commsType,
138  const labelUList& iF
139 ) const
140 {
141  send(commsType, patchInternalField(iF)());
142 }
143 
144 
146 (
147  const Pstream::commsTypes commsType,
148  const labelUList&
149 ) const
150 {
151  return receive<label>(commsType, this->size());
152 }
153 
154 
155 // ************************************************************************* //
virtual tmp< labelField > interfaceInternalField(const labelUList &internalData) const
Return the values of the given internal data adjacent to.
scalar delta
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
commsTypes
Types of communications.
Definition: UPstream.H:64
Macros for easy insertion into run-time selection tables.
virtual tmp< vectorField > delta() const
Return delta (P to N) vectors across coupled patch.
Spatial transformation functions for primitive fields.
void makeWeights(scalarField &) const
Make patch weighting factors.
virtual tmp< labelField > internalFieldTransfer(const Pstream::commsTypes commsType, const labelUList &internalData) const
Return neighbour field.
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
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)
static bool & parRun()
Is this a parallel run?
Definition: UPstream.H:399
virtual tmp< vectorField > delta() const =0
Return delta (P to N) vectors across coupled patch.
dimensioned< scalar > mag(const dimensioned< Type > &)
A class for managing temporary objects.
Definition: PtrList.H:53
virtual void initInternalFieldTransfer(const Pstream::commsTypes commsType, const labelUList &internalData) const
Initialise neighbour field transfer.
Namespace for OpenFOAM.
dimensionSet transform(const dimensionSet &)
Definition: dimensionSet.C:477