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 | Copyright (C) 2011-2015 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 Description
25  Abstract base class for finite volume calculus convection schemes.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "fv.H"
30 #include "HashTable.H"
31 #include "linear.H"
32 
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37 
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 
40 namespace fv
41 {
42 
43 
44 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
45 
46 template<class Type>
48 :
49  refCount(),
50  mesh_(cs.mesh_)
51 {}
52 
53 
54 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
55 
56 template<class Type>
58 (
59  const fvMesh& mesh,
60  const surfaceScalarField& faceFlux,
61  Istream& schemeData
62 )
63 {
64  if (fv::debug)
65  {
66  Info<< "convectionScheme<Type>::New"
67  "(const fvMesh&, const surfaceScalarField&, Istream&) : "
68  "constructing convectionScheme<Type>"
69  << endl;
70  }
71 
72  if (schemeData.eof())
73  {
75  (
76  schemeData
77  ) << "Convection scheme not specified" << endl << endl
78  << "Valid convection schemes are :" << endl
79  << IstreamConstructorTablePtr_->sortedToc()
80  << exit(FatalIOError);
81  }
82 
83  const word schemeName(schemeData);
84 
85  typename IstreamConstructorTable::iterator cstrIter =
86  IstreamConstructorTablePtr_->find(schemeName);
87 
88  if (cstrIter == IstreamConstructorTablePtr_->end())
89  {
91  (
92  schemeData
93  ) << "Unknown convection scheme " << schemeName << nl << nl
94  << "Valid convection schemes are :" << endl
95  << IstreamConstructorTablePtr_->sortedToc()
96  << exit(FatalIOError);
97  }
98 
99  return cstrIter()(mesh, faceFlux, schemeData);
100 }
101 
102 
103 template<class Type>
105 (
106  const fvMesh& mesh,
108  fieldTable& fields,
109  const surfaceScalarField& faceFlux,
110  Istream& schemeData
111 )
112 {
113  if (fv::debug)
114  {
115  Info<< "convectionScheme<Type>::New"
116  "(const fvMesh&, "
117  "const typename multivariateSurfaceInterpolationScheme<Type>"
118  "::fieldTable&, const surfaceScalarField&, Istream&) : "
119  "constructing convectionScheme<Type>"
120  << endl;
121  }
122 
123  if (schemeData.eof())
124  {
126  (
127  schemeData
128  ) << "Convection scheme not specified" << endl << endl
129  << "Valid convection schemes are :" << endl
130  << MultivariateConstructorTablePtr_->sortedToc()
131  << exit(FatalIOError);
132  }
133 
134  const word schemeName(schemeData);
135 
136  typename MultivariateConstructorTable::iterator cstrIter =
137  MultivariateConstructorTablePtr_->find(schemeName);
138 
139  if (cstrIter == MultivariateConstructorTablePtr_->end())
140  {
142  (
143  schemeData
144  ) << "Unknown convection scheme " << schemeName << nl << nl
145  << "Valid convection schemes are :" << endl
146  << MultivariateConstructorTablePtr_->sortedToc()
147  << exit(FatalIOError);
148  }
149 
150  return cstrIter()(mesh, fields, faceFlux, schemeData);
151 }
152 
153 
154 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
155 
156 template<class Type>
158 {}
159 
160 
161 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
162 
163 template<class Type>
165 {
166  if (this == &cs)
167  {
169  << "attempted assignment to self"
170  << abort(FatalError);
171  }
172 }
173 
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 } // End namespace fv
178 
179 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
180 
181 } // End namespace Foam
182 
183 // ************************************************************************* //
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
fv.H
HashTable.H
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::fv::convectionScheme::~convectionScheme
virtual ~convectionScheme()
Destructor.
Definition: convectionScheme.C:157
Foam::refCount
Reference counter for various OpenFOAM components.
Definition: refCount.H:45
fields
Info<< "Creating field dpdt\n"<< endl;volScalarField dpdt(IOobject("dpdt", runTime.timeName(), mesh), mesh, dimensionedScalar("dpdt", p.dimensions()/dimTime, 0));Info<< "Creating field kinetic energy K\n"<< endl;volScalarField K("K", 0.5 *magSqr(U));volScalarField p_rgh(IOobject("p_rgh", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);p_rgh=p - rho *gh;mesh.setFluxRequired(p_rgh.name());multivariateSurfaceInterpolationScheme< scalar >::fieldTable fields
Definition: createFields.H:127
Foam::IOstream::eof
bool eof() const
Return true if end of input seen.
Definition: IOstream.H:339
Foam::fv::convectionScheme::New
static tmp< convectionScheme< Type > > New(const fvMesh &mesh, const surfaceScalarField &faceFlux, Istream &schemeData)
Return a pointer to a new convectionScheme created on freestore.
Definition: convectionScheme.C:58
Foam::fv::convectionScheme::convectionScheme
convectionScheme(const convectionScheme &)
Copy construct.
Definition: convectionScheme.C:47
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:57
Foam::nl
static const char nl
Definition: Ostream.H:260
Foam::Info
messageStream Info
Foam::multivariateSurfaceInterpolationScheme
Abstract base class for multi-variate surface interpolation schemes.
Definition: multivariateSurfaceInterpolationScheme.H:50
Foam::FatalError
error FatalError
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:131
Foam::fv::convectionScheme
Abstract base class for convection schemes.
Definition: convectionScheme.H:64
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
fv
labelList fv(nPoints)
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::fv::convectionScheme::operator=
void operator=(const convectionScheme< Type > &)
Definition: convectionScheme.C:164
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:330
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52