ddtScheme.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 \*---------------------------------------------------------------------------*/
25 
26 #include "fv.H"
27 #include "HashTable.H"
28 #include "surfaceInterpolate.H"
29 #include "fvMatrix.H"
30 #include "cyclicAMIFvPatch.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 
37 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 
39 namespace fv
40 {
41 
42 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
43 
44 template<class Type>
45 tmp<ddtScheme<Type> > ddtScheme<Type>::New
46 (
47  const fvMesh& mesh,
48  Istream& schemeData
49 )
50 {
51  if (fv::debug)
52  {
53  Info<< "ddtScheme<Type>::New(const fvMesh&, Istream&) : "
54  "constructing ddtScheme<Type>"
55  << endl;
56  }
57 
58  if (schemeData.eof())
59  {
61  (
62  schemeData
63  ) << "Ddt scheme not specified" << endl << endl
64  << "Valid ddt schemes are :" << endl
65  << IstreamConstructorTablePtr_->sortedToc()
66  << exit(FatalIOError);
67  }
68 
69  const word schemeName(schemeData);
70 
71  typename IstreamConstructorTable::iterator cstrIter =
72  IstreamConstructorTablePtr_->find(schemeName);
73 
74  if (cstrIter == IstreamConstructorTablePtr_->end())
75  {
77  (
78  schemeData
79  ) << "Unknown ddt scheme " << schemeName << nl << nl
80  << "Valid ddt schemes are :" << endl
81  << IstreamConstructorTablePtr_->sortedToc()
82  << exit(FatalIOError);
83  }
84 
85  return cstrIter()(mesh, schemeData);
86 }
87 
88 
89 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
90 
91 template<class Type>
93 {}
94 
95 
96 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
97 
98 template<class Type>
100 (
101  const volScalarField& alpha,
102  const volScalarField& rho,
104 )
105 {
107 
109  (
111  );
112 }
113 
114 
115 template<class Type>
117 (
118  const volScalarField& alpha,
119  const volScalarField& rho,
121 )
122 {
124 
125  return tmp<fvMatrix<Type> >
126  (
127  new fvMatrix<Type>
128  (
129  vf,
130  alpha.dimensions()*rho.dimensions()
131  *vf.dimensions()*dimVol/dimTime
132  )
133  );
134 }
135 
136 
137 template<class Type>
139 (
141  const fluxFieldType& phi,
142  const fluxFieldType& phiCorr
143 )
144 {
145  tmp<surfaceScalarField> tddtCouplingCoeff = scalar(1)
146  - min
147  (
148  mag(phiCorr)
149  /(mag(phi) + dimensionedScalar("small", phi.dimensions(), SMALL)),
150  scalar(1)
151  );
152 
153  surfaceScalarField& ddtCouplingCoeff = tddtCouplingCoeff();
154 
155  forAll(U.boundaryField(), patchi)
156  {
157  if
158  (
159  U.boundaryField()[patchi].fixesValue()
160  || isA<cyclicAMIFvPatch>(mesh().boundary()[patchi])
161  )
162  {
163  ddtCouplingCoeff.boundaryField()[patchi] = 0.0;
164  }
165  }
166 
167  if (debug > 1)
168  {
169  Info<< "ddtCouplingCoeff mean max min = "
170  << gAverage(ddtCouplingCoeff.internalField())
171  << " " << gMax(ddtCouplingCoeff.internalField())
172  << " " << gMin(ddtCouplingCoeff.internalField())
173  << endl;
174  }
175 
176  return tddtCouplingCoeff;
177 }
178 
179 
180 template<class Type>
182 (
184  const fluxFieldType& phi
185 )
186 {
187  return fvcDdtPhiCoeff(U, phi, phi - (mesh().Sf() & fvc::interpolate(U)));
188 }
189 
190 
191 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
192 
193 } // End namespace fv
194 
195 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
196 
197 } // End namespace Foam
198 
199 // ************************************************************************* //
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
fv.H
HashTable.H
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:118
Foam::gAverage
Type gAverage(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:571
Foam::IOstream::eof
bool eof() const
Return true if end of input seen.
Definition: IOstream.H:339
phi
surfaceScalarField & phi
Definition: setRegionFluidFields.H:8
Foam::constant::atomic::alpha
const dimensionedScalar alpha
Fine-structure constant: default SI units: [].
Definition: readThermalProperties.H:216
boundary
faceListList boundary(nPatches)
Foam::fvc::interpolate
tmp< GeometricField< Type, fvsPatchField, surfaceMesh > > interpolate(const GeometricField< Type, fvPatchField, volMesh > &vf, const surfaceScalarField &faceFlux, Istream &schemeData)
Interpolate field onto faces using scheme given by Istream.
Definition: surfaceInterpolate.C:110
Foam::GeometricField::boundaryField
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
Definition: GeometricField.C:735
Foam::FatalIOError
IOerror FatalIOError
fvMatrix.H
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
Foam::fv::ddtScheme::~ddtScheme
virtual ~ddtScheme()
Destructor.
Definition: ddtScheme.C:92
U
U
Definition: pEqn.H:46
NotImplemented
#define NotImplemented
Issue a FatalErrorIn for a function not currently implemented.
Definition: error.H:365
Foam::dimTime
const dimensionSet dimTime(0, 0, 1, 0, 0, 0, 0)
Definition: dimensionSets.H:51
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::fv::ddtScheme::fvcDdtPhiCoeff
tmp< surfaceScalarField > fvcDdtPhiCoeff(const GeometricField< Type, fvPatchField, volMesh > &U, const fluxFieldType &phi, const fluxFieldType &phiCorr)
Definition: ddtScheme.C:139
Foam::GeometricField::internalField
InternalField & internalField()
Return internal field.
Definition: GeometricField.C:724
Foam::dimensionedScalar
dimensioned< scalar > dimensionedScalar
Dimensioned scalar obtained from generic dimensioned type.
Definition: dimensionedScalarFwd.H:41
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
surfaceInterpolate.H
Surface Interpolation.
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
rho
rho
Definition: pEqn.H:3
fv
labelList fv(nPoints)
Foam::fv::ddtScheme::fvcDdt
virtual tmp< GeometricField< Type, fvPatchField, volMesh > > fvcDdt(const dimensioned< Type > &)=0
patchi
label patchi
Definition: getPatchFieldScalar.H:1
Foam::fvMatrix< Type >
Foam::dimVol
const dimensionSet dimVol(dimVolume)
Definition: dimensionSets.H:59
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:330
Foam::GeometricField::null
static const GeometricField< Type, PatchField, GeoMesh > & null()
Return a null geometric field.
Definition: GeometricFieldI.H:30
Foam::gMin
Type gMin(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:563
Foam::dimensioned::dimensions
const dimensionSet & dimensions() const
Return const reference to dimensions.
Definition: dimensionedType.C:248
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::fv::ddtScheme::New
static tmp< ddtScheme< Type > > New(const fvMesh &mesh, Istream &schemeData)
Return a pointer to a new ddtScheme created on freestore.
Definition: ddtScheme.C:46
Foam::min
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
cyclicAMIFvPatch.H
Foam::gMax
Type gMax(const FieldField< Field, Type > &f)
Definition: FieldFieldFunctions.C:562
Foam::fv::ddtScheme::fvmDdt
virtual tmp< fvMatrix< Type > > fvmDdt(const GeometricField< Type, fvPatchField, volMesh > &)=0