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