localMax.H
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-2022 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 Class
25  Foam::localMax
26 
27 Description
28  Local maximum interpolation scheme in which the face value is set to
29  the maximum of the two neighbouring cell values.
30 
31 SourceFiles
32  localMax.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef localMax_H
37 #define localMax_H
38 
40 #include "volFields.H"
41 #include "surfaceFields.H"
42 
43 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
44 
45 namespace Foam
46 {
47 
48 /*---------------------------------------------------------------------------*\
49  Class localMax Declaration
50 \*---------------------------------------------------------------------------*/
51 
52 template<class Type>
53 class localMax
54 :
55  public surfaceInterpolationScheme<Type>
56 {
57  // Private Member Functions
58 
59  //- Disallow default bitwise assignment
60  void operator=(const localMax&) = delete;
61 
62 
63 public:
64 
65  //- Runtime type information
66  TypeName("localMax");
67 
68 
69  // Constructors
70 
71  //- Construct from mesh
72  localMax(const fvMesh& mesh)
73  :
74  surfaceInterpolationScheme<Type>(mesh)
75  {}
76 
77  //- Construct from Istream.
78  // The name of the flux field is read from the Istream and looked-up
79  // from the mesh objectRegistry
81  (
82  const fvMesh& mesh,
83  Istream& is
84  )
85  :
86  surfaceInterpolationScheme<Type>(mesh)
87  {}
88 
89  //- Construct from faceFlux and Istream
91  (
92  const fvMesh& mesh,
93  const surfaceScalarField& faceFlux,
94  Istream& is
95  )
96  :
97  surfaceInterpolationScheme<Type>(mesh)
98  {}
99 
100 
101  // Member Functions
102 
103  //- Return the interpolation weighting factors
105  (
107  ) const
108  {
110 
111  return tmp<surfaceScalarField>(nullptr);
112  }
113 
114  //- Return the face-interpolate of the given cell field
117  (
119  ) const
120  {
121  const fvMesh& mesh = vf.mesh();
122 
124  (
126  (
127  "localMax::interpolate(" + vf.name() + ')',
128  mesh,
129  vf.dimensions()
130  )
131  );
133 
134  const labelUList& own = mesh.owner();
135  const labelUList& nei = mesh.neighbour();
136 
137  forAll(vff, facei)
138  {
139  vff[facei] = max(vf[own[facei]], vf[nei[facei]]);
140  }
141 
143  Boundary& bff = vff.boundaryFieldRef();
144 
145  forAll(bff, patchi)
146  {
147  const fvPatchField<Type>& pf = vf.boundaryField()[patchi];
148  Field<Type>& pff = bff[patchi];
149 
150  if (pf.coupled())
151  {
153  const Field<Type>& pif = tpif();
154 
156  const Field<Type>& pnf = tpnf();
157 
158  forAll(pff, i)
159  {
160  pff[i] = max(pif[i], pnf[i]);
161  }
162  }
163  else
164  {
165  pff = pf;
166  }
167  }
168 
169  return tvff;
170  }
171 };
172 
173 
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
175 
176 } // End namespace Foam
177 
178 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 
180 #endif
181 
182 // ************************************************************************* //
Foam::surfaceFields.
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:434
layerAndWeight max(const layerAndWeight &a, const layerAndWeight &b)
const word & name() const
Return name.
Definition: IOobject.H:315
const Boundary & boundaryField() const
Return const-reference to the boundary field.
T & ref() const
Return non-const reference or generate a fatal error.
Definition: tmpI.H:181
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
Local maximum interpolation scheme in which the face value is set to the maximum of the two neighbour...
Definition: localMax.H:52
virtual tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &vf) const
Return the face-interpolate of the given cell field.
Definition: localMax.H:116
Abstract base class with a fat-interface to all derived classes covering all possible ways in which t...
Definition: fvPatchField.H:66
const fvMesh & mesh() const
Return mesh reference.
const labelUList & neighbour() const
Internal face neighbour.
Definition: fvMesh.H:423
TypeName("localMax")
Runtime type information.
virtual tmp< surfaceScalarField > weights(const GeometricField< Type, fvPatchField, volMesh > &) const
Return the interpolation weighting factors.
Definition: localMax.H:104
const dimensionSet & dimensions() const
Return dimensions.
Pre-declare SubField and related Field type.
Definition: Field.H:56
virtual bool coupled() const
Return true if this patch field is coupled.
Definition: fvPatchField.H:323
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
localMax(const fvMesh &mesh)
Construct from mesh.
Definition: localMax.H:71
virtual tmp< Field< Type > > patchInternalField() const
Return internal field next to patch as patch field.
Definition: fvPatchField.C:174
const Mesh & mesh() const
Return mesh.
const labelUList & owner() const
Internal face owner.
Definition: fvMesh.H:417
label patchi
Boundary & boundaryFieldRef()
Return a reference to the boundary field.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:95
A class for managing temporary objects.
Definition: PtrList.H:53
virtual tmp< Field< Type > > patchNeighbourField(const Pstream::commsTypes commsType=Pstream::commsTypes::blocking) const
Return patchField on the opposite patch of a coupled patch.
Definition: fvPatchField.H:433
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:353
Abstract base class for surface interpolation schemes.
Namespace for OpenFOAM.