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-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 "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 (transform().transforms())
97  {
98  return
101  (
102  procPolyPatch_.neighbFaceCentres()
103  - procPolyPatch_.neighbFaceCellCentres()
104  );
105  }
106  else
107  {
108  return
110  - (
111  procPolyPatch_.neighbFaceCentres()
112  - procPolyPatch_.neighbFaceCellCentres()
113  );
114  }
115  }
116  else
117  {
118  return coupledFvPatch::delta();
119  }
120 }
121 
122 
124 (
125  const labelUList& internalData
126 ) const
127 {
128  return patchInternalField(internalData);
129 }
130 
131 
133 (
134  const Pstream::commsTypes commsType,
135  const labelUList& iF
136 ) const
137 {
138  send(commsType, patchInternalField(iF)());
139 }
140 
141 
143 (
144  const Pstream::commsTypes commsType,
145  const labelUList&
146 ) const
147 {
148  return receive<label>(commsType, this->size());
149 }
150 
151 
152 // ************************************************************************* //
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 > &)
friend dimensionSet transform(const dimensionSet &)
Return the argument; transformations do not change the dimensions.
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