FreeFOAM The Cross-Platform CFD Toolkit
maxhxhyhzDelta.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) 2010-2010 OpenCFD Ltd.
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 "maxhxhyhzDelta.H"
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 defineTypeNameAndDebug(maxhxhyhzDelta, 0);
37 addToRunTimeSelectionTable(LESdelta, maxhxhyhzDelta, dictionary);
38 
39 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
40 
41 void maxhxhyhzDelta::calcDelta()
42 {
43  label nD = mesh().nGeometricD();
44 
45  tmp<volScalarField> hmax
46  (
47  new volScalarField
48  (
49  IOobject
50  (
51  "hmax",
52  mesh().time().timeName(),
53  mesh(),
56  ),
57  mesh(),
58  dimensionedScalar("zrero", dimLength, 0.0)
59  )
60  );
61 
62  const cellList& cells = mesh().cells();
63 
64  forAll(cells,cellI)
65  {
66  scalar deltaMaxTmp = 0.0;
67  const labelList& cFaces = mesh().cells()[cellI];
68  const point& centrevector = mesh().cellCentres()[cellI];
69 
70  forAll(cFaces, cFaceI)
71  {
72  label faceI = cFaces[cFaceI];
73  const point& facevector = mesh().faceCentres()[faceI];
74  scalar tmp = mag(facevector - centrevector);
75  if (tmp > deltaMaxTmp)
76  {
77  deltaMaxTmp = tmp;
78  }
79  }
80  hmax()[cellI] = deltaCoeff_*deltaMaxTmp;
81  }
82 
83  if (nD == 3)
84  {
85  delta_.internalField() = hmax();
86  }
87  else if (nD == 2)
88  {
89  WarningIn("maxhxhyhzDelta::calcDelta()")
90  << "Case is 2D, LES is not strictly applicable\n"
91  << endl;
92 
93  delta_.internalField() = hmax();
94  }
95  else
96  {
97  FatalErrorIn("maxhxhyhzDelta::calcDelta()")
98  << "Case is not 3D or 2D, LES is not applicable"
99  << exit(FatalError);
100  }
101 }
102 
103 
104 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
105 
106 maxhxhyhzDelta::maxhxhyhzDelta
107 (
108  const word& name,
109  const fvMesh& mesh,
110  const dictionary& dd
111 )
112 :
113  LESdelta(name, mesh),
114  deltaCoeff_(readScalar(dd.subDict(type() + "Coeffs").lookup("deltaCoeff")))
115 {
116  calcDelta();
117 }
118 
119 
120 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
121 
123 {
124  dd.subDict(type() + "Coeffs").lookup("deltaCoeff") >> deltaCoeff_;
125  calcDelta();
126 }
127 
128 
130 {
131  if (mesh_.changing())
132  {
133  calcDelta();
134  }
135 }
136 
137 
138 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
139 
140 } // End namespace Foam
141 
142 // ************************ vim: set sw=4 sts=4 et: ************************ //