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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011-2017 OpenFOAM Foundation
9  Copyright (C) 2016-2020 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 \*---------------------------------------------------------------------------*/
28 
29 #include "maxDeltaxyz.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace LESModels
37 {
39  addToRunTimeSelectionTable(LESdelta, maxDeltaxyz, dictionary);
40 }
41 }
42 
43 
44 // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
45 
47 {
48  const fvMesh& mesh = turbulenceModel_.mesh();
49 
50  label nD = mesh.nGeometricD();
51 
52  const cellList& cells = mesh.cells();
53  const vectorField& cellC = mesh.cellCentres();
54  const vectorField& faceC = mesh.faceCentres();
55  const vectorField faceN(mesh.faceAreas()/mag(mesh.faceAreas()));
56  scalarField hmax(cells.size());
57 
58  forAll(cells, celli)
59  {
60  scalar deltaMaxTmp = 0.0;
61  const labelList& cFaces = cells[celli];
62  const point& cc = cellC[celli];
63 
64  forAll(cFaces, cFacei)
65  {
66  label facei = cFaces[cFacei];
67  const point& fc = faceC[facei];
68  const vector& n = faceN[facei];
69 
70  scalar tmp = mag(n & (fc - cc));
71  if (tmp > deltaMaxTmp)
72  {
73  deltaMaxTmp = tmp;
74  }
75  }
76 
77  hmax[celli] = deltaCoeff_*deltaMaxTmp;
78  }
79 
80  if (nD == 3)
81  {
82  delta_.primitiveFieldRef() = hmax;
83  }
84  else if (nD == 2)
85  {
87  << "Case is 2D, LES is not strictly applicable" << nl
88  << endl;
89 
90  delta_.primitiveFieldRef() = hmax;
91  }
92  else
93  {
95  << "Case is not 3D or 2D, LES is not applicable"
96  << exit(FatalError);
97  }
98 
99  // Handle coupled boundaries
101 }
102 
103 
104 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
105 
106 Foam::LESModels::maxDeltaxyz::maxDeltaxyz
107 (
108  const word& name,
110  const dictionary& dict
111 )
112 :
114  deltaCoeff_
115  (
116  dict.optionalSubDict(type() + "Coeffs").getOrDefault<scalar>
117  (
118  "deltaCoeff",
119  2
120  )
121  )
122 {
123  calcDelta();
124 }
125 
126 
127 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
128 
130 {
131  const dictionary& coeffsDict(dict.optionalSubDict(type() + "Coeffs"));
132 
133  coeffsDict.readIfPresent<scalar>("deltaCoeff", deltaCoeff_);
134 
135  calcDelta();
136 }
137 
138 
140 {
141  if (turbulenceModel_.mesh().changing())
142  {
143  calcDelta();
144  }
145 }
146 
147 
148 // ************************************************************************* //
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
turbulence
Info<< "Reading field U\n"<< endl;volVectorField U(IOobject("U", runTime.timeName(), mesh, IOobject::MUST_READ, IOobject::AUTO_WRITE), mesh);volScalarField rho(IOobject("rho", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::AUTO_WRITE), thermo.rho());volVectorField rhoU(IOobject("rhoU", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), rho *U);volScalarField rhoE(IOobject("rhoE", runTime.timeName(), mesh, IOobject::NO_READ, IOobject::NO_WRITE), rho *(e+0.5 *magSqr(U)));surfaceScalarField pos(IOobject("pos", runTime.timeName(), mesh), mesh, dimensionedScalar("pos", dimless, 1.0));surfaceScalarField neg(IOobject("neg", runTime.timeName(), mesh), mesh, dimensionedScalar("neg", dimless, -1.0));surfaceScalarField phi("phi", fvc::flux(rhoU));Info<< "Creating turbulence model\n"<< endl;autoPtr< compressible::turbulenceModel > turbulence(compressible::turbulenceModel::New(rho, U, phi, thermo))
Definition: createFields.H:94
Foam::tmp
A class for managing temporary objects.
Definition: PtrList.H:61
Foam::LESdelta::delta_
volScalarField delta_
Definition: LESdelta.H:61
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:369
Foam::LESModels::maxDeltaxyz::correct
virtual void correct()
Definition: maxDeltaxyz.C:139
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:296
Foam::LESModels::maxDeltaxyz::calcDelta
void calcDelta()
Calculate the delta values.
Definition: maxDeltaxyz.C:46
n
label n
Definition: TABSMDCalcMethod2.H:31
Foam::Field< vector >
Foam::LESdelta::turbulenceModel_
const turbulenceModel & turbulenceModel_
Definition: LESdelta.H:59
Foam::LESModels::maxDeltaxyz::read
virtual void read(const dictionary &)
Read the LESdelta dictionary.
Definition: maxDeltaxyz.C:129
maxDeltaxyz.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::turbulenceModel
Abstract base class for turbulence models (RAS, LES and laminar).
Definition: turbulenceModel.H:63
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:6
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:85
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::GeometricField::primitiveFieldRef
Internal::FieldType & primitiveFieldRef(const bool updateAccessTime=true)
Return a reference to the internal field.
Definition: GeometricField.C:766
Foam::GeometricField::correctBoundaryConditions
void correctBoundaryConditions()
Correct boundary field.
Definition: GeometricField.C:940
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::LESdelta
Abstract base class for LES deltas.
Definition: LESdelta.H:53
Foam::LESModels::defineTypeNameAndDebug
defineTypeNameAndDebug(cubeRootVolDelta, 0)
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::Vector< scalar >
Foam::List< cell >
Foam::turbulenceModel::mesh
const fvMesh & mesh() const
Definition: turbulenceModel.H:129
Foam::mag
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
Foam::LESModels::addToRunTimeSelectionTable
addToRunTimeSelectionTable(LESfluidThermoCompressibleTurbulenceModel, SmagorinskyLESfluidThermoCompressibleTurbulenceModel, dictionary)
Foam::name
word name(const expressions::valueTypeCode typeCode)
A word representation of a valueTypeCode. Empty for INVALID.
Definition: exprTraits.C:59
cells
const cellShapeList & cells
Definition: gmvOutputHeader.H:3
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:328
Foam::dictionary::readIfPresent
bool readIfPresent(const word &keyword, T &val, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:405