convectionScheme.C
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  Copyright (C) 2019-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Description
28  Abstract base class for finite volume calculus convection schemes.
29 
30 \*---------------------------------------------------------------------------*/
31 
32 #include "fv.H"
33 #include "HashTable.H"
34 #include "linear.H"
35 
36 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
37 
38 namespace Foam
39 {
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace fv
44 {
45 
46 
47 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
48 
49 template<class Type>
51 :
52  refCount(),
53  mesh_(cs.mesh_)
54 {}
55 
56 
57 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
58 
59 template<class Type>
61 (
62  const fvMesh& mesh,
63  const surfaceScalarField& faceFlux,
64  Istream& schemeData
65 )
66 {
67  if (fv::debug)
68  {
69  InfoInFunction << "Constructing convectionScheme<Type>" << endl;
70  }
71 
72  if (schemeData.eof())
73  {
74  FatalIOErrorInFunction(schemeData)
75  << "Convection scheme not specified" << endl << endl
76  << "Valid convection schemes are :" << endl
77  << IstreamConstructorTablePtr_->sortedToc()
78  << exit(FatalIOError);
79  }
80 
81  const word schemeName(schemeData);
82 
83  if (fv::debug)
84  {
85  InfoInFunction << "schemeName:" << schemeName << endl;
86  }
87 
88  auto* ctorPtr = IstreamConstructorTable(schemeName);
89 
90  if (!ctorPtr)
91  {
93  (
94  schemeData,
95  "convection",
96  schemeName,
97  *IstreamConstructorTablePtr_
98  ) << exit(FatalIOError);
99  }
100 
101  return ctorPtr(mesh, faceFlux, schemeData);
102 }
103 
104 
105 template<class Type>
107 (
108  const fvMesh& mesh,
110  fieldTable& fields,
111  const surfaceScalarField& faceFlux,
112  Istream& schemeData
113 )
114 {
115  if (fv::debug)
116  {
117  InfoInFunction << "Constructing convectionScheme<Type>" << endl;
118  }
119 
120  if (schemeData.eof())
121  {
122  FatalIOErrorInFunction(schemeData)
123  << "Convection scheme not specified" << endl << endl
124  << "Valid convection schemes are :" << endl
125  << MultivariateConstructorTablePtr_->sortedToc()
126  << exit(FatalIOError);
127  }
128 
129  const word schemeName(schemeData);
130 
131  auto* ctorPtr = MultivariateConstructorTable(schemeName);
132 
133  if (!ctorPtr)
134  {
136  (
137  schemeData,
138  "convection",
139  schemeName,
140  *MultivariateConstructorTablePtr_
141  ) << exit(FatalIOError);
142  }
143 
144  return ctorPtr(mesh, fields, faceFlux, schemeData);
145 }
146 
147 
148 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
149 
150 template<class Type>
152 {}
153 
154 
155 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
156 
157 template<class Type>
159 {
160  if (this == &cs)
161  {
162  return; // Self-assignment is a no-op
163  }
164 }
165 
166 
167 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 
169 } // End namespace fv
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 } // End namespace Foam
174 
175 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
InfoInFunction
#define InfoInFunction
Report an information message using Foam::Info.
Definition: messageStream.H:350
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
fv.H
HashTable.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::refCount
Reference counter for various OpenFOAM components.
Definition: refCount.H:50
Foam::fv::convectionScheme::convectionScheme
convectionScheme(const convectionScheme &)
Copy construct.
Definition: convectionScheme.C:50
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
FatalIOErrorInLookup
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:478
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::IOstream::eof
bool eof() const noexcept
True if end of input seen.
Definition: IOstream.H:239
Foam::multivariateSurfaceInterpolationScheme
Abstract base class for multi-variate surface interpolation schemes.
Definition: multivariateSurfaceInterpolationScheme.H:52
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::fv::convectionScheme
Abstract base class for convection schemes.
Definition: convectionScheme.H:69
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
fv
labelList fv(nPoints)
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
Foam::GeometricField< scalar, fvsPatchField, surfaceMesh >
fields
multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
Definition: createFields.H:97