maxDeltaxyz.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 | Copyright (C) 2016 OpenCFD Ltd.
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 "maxDeltaxyz.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 namespace LESModels
34 {
36  addToRunTimeSelectionTable(LESdelta, maxDeltaxyz, dictionary);
37 }
38 }
39 
40 
41 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
42 
44 {
45  const fvMesh& mesh = turbulenceModel_.mesh();
46 
47  label nD = mesh.nGeometricD();
48 
50  (
51  new volScalarField
52  (
53  IOobject
54  (
55  "hmax",
56  mesh.time().timeName(),
57  mesh,
60  ),
61  mesh,
62  dimensionedScalar("zrero", dimLength, 0.0)
63  )
64  );
65 
66  const cellList& cells = mesh.cells();
67 
68  forAll(cells,cellI)
69  {
70  scalar deltaMaxTmp = 0.0;
71  const labelList& cFaces = mesh.cells()[cellI];
72  const point& centrevector = mesh.cellCentres()[cellI];
73 
74  forAll(cFaces, cFaceI)
75  {
76  label faceI = cFaces[cFaceI];
77  const point& facevector = mesh.faceCentres()[faceI];
78  scalar tmp = mag(facevector - centrevector);
79  if (tmp > deltaMaxTmp)
80  {
81  deltaMaxTmp = tmp;
82  }
83  }
84  hmax()[cellI] = deltaCoeff_*deltaMaxTmp;
85  }
86 
87  if (nD == 3)
88  {
89  delta_.internalField() = hmax();
90  }
91  else if (nD == 2)
92  {
94  << "Case is 2D, LES is not strictly applicable\n"
95  << endl;
96 
97  delta_.internalField() = hmax();
98  }
99  else
100  {
102  << "Case is not 3D or 2D, LES is not applicable"
103  << exit(FatalError);
104  }
105 
106  // Handle coupled boundaries
108 }
109 
110 
111 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
112 
114 (
115  const word& name,
117  const dictionary& dict
118 )
119 :
121  deltaCoeff_
122  (
123  dict.subDict(type() + "Coeffs").lookupOrDefault<scalar>("deltaCoeff", 1)
124  )
125 {
126  calcDelta();
127 }
128 
129 
130 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
131 
133 {
134  const dictionary& coeffsDict(dict.subDict(type() + "Coeffs"));
135 
136  coeffsDict.readIfPresent<scalar>("deltaCoeff", deltaCoeff_);
137 
138  calcDelta();
139 }
140 
141 
143 {
144  if (turbulenceModel_.mesh().changing())
145  {
146  calcDelta();
147  }
148 }
149 
150 
151 // ************************************************************************* //
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::word
A class for handling words, derived from string.
Definition: word.H:59
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
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::dictionary::readIfPresent
bool readIfPresent(const word &, T &, bool recursive=false, bool patternMatch=true) const
Find an entry if present, and assign to T.
Definition: dictionaryTemplates.C:94
Foam::LESdelta::delta_
volScalarField delta_
Definition: LESdelta.H:59
maxDeltaxyz
Delta calculated by taking the maximum distance between the cell centre and any face centre....
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::LESModels::maxDeltaxyz::correct
virtual void correct()
Definition: maxDeltaxyz.C:142
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
Foam::IOobject::NO_WRITE
@ NO_WRITE
Definition: IOobject.H:118
Foam::LESModels::maxDeltaxyz::calcDelta
void calcDelta()
Definition: maxDeltaxyz.C:43
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
turbulence
autoPtr< compressible::turbulenceModel > turbulence
Definition: createFields.H:23
Foam::IOobject::NO_READ
@ NO_READ
Definition: IOobject.H:111
Foam::LESdelta::turbulenceModel_
const turbulenceModel & turbulenceModel_
Definition: LESdelta.H:57
Foam::GeometricField::internalField
InternalField & internalField()
Return internal field.
Definition: GeometricField.C:724
Foam::LESModels::maxDeltaxyz::read
virtual void read(const dictionary &)
Read the LESdelta dictionary.
Definition: maxDeltaxyz.C:132
maxDeltaxyz.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::turbulenceModel
Abstract base class for turbulence models (RAS, LES and laminar).
Definition: turbulenceModel.H:60
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by any number of values (e....
Definition: dictionary.H:137
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::LESModels::maxDeltaxyz::deltaCoeff_
scalar deltaCoeff_
Model coefficient.
Definition: maxDeltaxyz.H:60
Foam::dimensioned
Generic dimensioned Type class.
Definition: dimensionedScalarFwd.H:41
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
Foam::GeometricField::correctBoundaryConditions
void correctBoundaryConditions()
Correct boundary field.
Definition: GeometricField.C:885
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:318
Foam::LESdelta
Abstract base class for LES deltas.
Definition: LESdelta.H:50
Foam::LESModels::defineTypeNameAndDebug
defineTypeNameAndDebug(cubeRootVolDelta, 0)
Foam::Vector< scalar >
Foam::List
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
Definition: HashTable.H:59
Foam::turbulenceModel::mesh
const fvMesh & mesh() const
Definition: turbulenceModel.H:127
Foam::LESModels::addToRunTimeSelectionTable
addToRunTimeSelectionTable(LESfluidThermoCompressibleTurbulenceModel, SmagorinskyLESfluidThermoCompressibleTurbulenceModel, dictionary)
cells
const cellShapeList & cells
Definition: gmvOutputHeader.H:3
Foam::type
fileName::Type type(const fileName &)
Return the file type: DIRECTORY or FILE.
Definition: POSIX.C:588
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:259
Foam::name
word name(const complex &)
Return a string representation of a complex.
Definition: complex.C:47
Foam::LESModels::maxDeltaxyz::maxDeltaxyz
maxDeltaxyz(const maxDeltaxyz &)
Disallow default bitwise copy construct and assignment.