reverseLinear.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2016 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::reverseLinear
28 
29 Group
30  grpFvSurfaceInterpolationSchemes
31 
32 Description
33  Inversed weight central-differencing interpolation scheme class.
34 
35  Useful for inverse weighted and harmonic interpolations.
36 
37 SourceFiles
38  reverseLinear.C
39 
40 \*---------------------------------------------------------------------------*/
41 
42 #ifndef reverseLinear_H
43 #define reverseLinear_H
44 
46 #include "volFields.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 
53 /*---------------------------------------------------------------------------*\
54  Class reverseLinear Declaration
55 \*---------------------------------------------------------------------------*/
56 
57 template<class Type>
58 class reverseLinear
59 :
60  public surfaceInterpolationScheme<Type>
61 {
62  // Private Member Functions
63 
64  //- No copy assignment
65  void operator=(const reverseLinear&) = delete;
66 
67 
68 public:
69 
70  //- Runtime type information
71  TypeName("reverseLinear");
72 
73 
74  // Constructors
75 
76  //- Construct from mesh
77  reverseLinear(const fvMesh& mesh)
78  :
80  {}
81 
82  //- Construct from Istream
84  :
86  {}
87 
88  //- Construct from faceFlux and Istream
90  (
91  const fvMesh& mesh,
92  const surfaceScalarField&,
93  Istream&
94  )
95  :
97  {}
98 
99 
100  // Member Functions
101 
102  //- Return the interpolation weighting factors
104  (
106  ) const
107  {
108  const fvMesh& mesh = this->mesh();
109 
110  tmp<surfaceScalarField> tcdWeights
111  (
112  mesh.surfaceInterpolation::weights()
113  );
114  const surfaceScalarField& cdWeights = tcdWeights();
115 
116  auto treverseLinearWeights = surfaceScalarField::New
117  (
118  "reverseLinearWeights",
120  mesh,
121  dimless
122  );
123  auto& reverseLinearWeights = treverseLinearWeights.ref();
124 
125  reverseLinearWeights.primitiveFieldRef() =
126  1.0 - cdWeights.primitiveField();
127 
128  auto& rlwbf = reverseLinearWeights.boundaryFieldRef();
129 
130 
131  forAll(mesh.boundary(), patchi)
132  {
133  if (rlwbf[patchi].coupled())
134  {
135  rlwbf[patchi] = 1.0 - cdWeights.boundaryField()[patchi];
136  }
137  else
138  {
139  rlwbf[patchi] = cdWeights.boundaryField()[patchi];
140  }
141  }
142 
143  return treverseLinearWeights;
144  }
145 };
146 
147 
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 
150 } // End namespace Foam
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 #endif
155 
156 // ************************************************************************* //
const Internal::FieldType & primitiveField() const noexcept
Return a const-reference to the internal field values.
TypeName("reverseLinear")
Runtime type information.
Inversed weight central-differencing interpolation scheme class.
Definition: reverseLinear.H:53
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
tmp< surfaceScalarField > weights(const GeometricField< Type, fvPatchField, volMesh > &) const
Return the interpolation weighting factors.
const dimensionSet dimless
Dimensionless.
const fvMesh & mesh() const
Return mesh reference.
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:421
reverseLinear(const fvMesh &mesh)
Construct from mesh.
Definition: reverseLinear.H:78
static tmp< GeometricField< scalar, fvsPatchField, surfaceMesh > > New(const word &name, IOobjectOption::registerOption regOpt, const Mesh &mesh, const dimensionSet &dims, const word &patchFieldType=fvsPatchField< scalar >::calculatedType())
Return tmp field (NO_READ, NO_WRITE) from name, mesh, dimensions and patch type. [Takes current timeN...
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
const fvBoundaryMesh & boundary() const noexcept
Return reference to boundary mesh.
Definition: fvMesh.H:395
A class for managing temporary objects.
Definition: HashPtrTable.H:50
bool coupled
Abstract base class for surface interpolation schemes.
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
Do not request registration (bool: false)
Namespace for OpenFOAM.