RASTurbulenceModel.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) 2007-2019 PCOpt/NTUA
9  Copyright (C) 2013-2019 FOSS GP
10  Copyright (C) 2019 OpenCFD Ltd.
11 -------------------------------------------------------------------------------
12 License
13  This file is part of OpenFOAM.
14 
15  OpenFOAM is free software: you can redistribute it and/or modify it
16  under the terms of the GNU General Public License as published by
17  the Free Software Foundation, either version 3 of the License, or
18  (at your option) any later version.
19 
20  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
21  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
22  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23  for more details.
24 
25  You should have received a copy of the GNU General Public License
26  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
27 
28 \*---------------------------------------------------------------------------*/
29 
30 #include "RASTurbulenceModel.H"
31 #include "findRefCell.H"
32 #include "Time.H"
34 
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 
37 namespace Foam
38 {
39  defineTypeNameAndDebug(RASTurbulenceModel, 0);
41  (
42  incompressiblePrimalSolver,
43  RASTurbulenceModel,
44  dictionary
45  );
46 }
47 
48 
49 // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
50 
52 {
54  return getIncoVars();
55 }
56 
57 
58 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
59 
60 Foam::RASTurbulenceModel::RASTurbulenceModel
61 (
62  fvMesh& mesh,
63  const word& managerType,
64  const dictionary& dict
65 )
66 :
67  incompressiblePrimalSolver(mesh, managerType, dict),
68  solverControl_(SIMPLEControl::New(mesh, managerType, *this)),
69  incoVars_(allocateVars())
70 {
72  (
73  incoVars_.pInst(),
74  solverControl_().dict(),
75  solverControl_().pRefCell(),
76  solverControl_().pRefValue()
77  );
78 }
79 
80 
81 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
82 
84 {
85  const Time& time = mesh_.time();
86  Info<< "Time = " << time.timeName() << "\n" << endl;
87 
88  // Grab references
90  incoVars_.turbulence();
91  turbulence->correct();
92 
93  solverControl_().write();
94 
95  // Average fields if necessary
96  incoVars_.computeMeanFields();
97 
99 }
100 
101 
103 {
104  // Iterate
105  if (active_)
106  {
107  // Reset initial and mean fields before solving
108  while (solverControl_().loop())
109  {
110  solveIter();
111  }
112  }
113 }
114 
115 
117 {
118  return solverControl_().loop();
119 }
120 
121 
123 {
124  os.writeEntry("averageIter", solverControl_().averageIter());
125 
126  return true;
127 }
128 
129 
130 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::RASTurbulenceModel::solverControl_
autoPtr< SIMPLEControl > solverControl_
Solver control.
Definition: RASTurbulenceModel.H:70
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::RASTurbulenceModel::solveIter
virtual void solveIter()
Execute one iteration of the solution algorithm.
Definition: RASTurbulenceModel.C:83
findRefCell.H
Find the reference cell nearest (in index) to the given cell but which is not on a cyclic,...
RASTurbulenceModel.H
Foam::solver::mesh_
fvMesh & mesh_
Reference to the mesh database.
Definition: solver.H:60
Foam::Time::timeName
static word timeName(const scalar t, const int precision=precision_)
Definition: Time.C:780
Foam::RASTurbulenceModel::allocateVars
incompressibleVars & allocateVars()
Protected Member Functions.
Definition: RASTurbulenceModel.C:51
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::Time::printExecutionTime
Ostream & printExecutionTime(OSstream &os) const
Print the elapsed ExecutionTime (cpu-time), ClockTime.
Definition: TimeIO.C:618
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::setRefCell
bool setRefCell(const volScalarField &field, const volScalarField &fieldRef, const dictionary &dict, label &refCelli, scalar &refValue, const bool forceReference=false)
If the field fieldRef needs referencing find the reference cell nearest.
Definition: findRefCell.C:34
Foam::RASTurbulenceModel::loop
virtual bool loop()
Looper (advances iters, time step)
Definition: RASTurbulenceModel.C:116
Foam::RASTurbulenceModel::solve
virtual void solve()
Main control loop.
Definition: RASTurbulenceModel.C:102
Foam::incompressiblePrimalSolver
Base class for primal incompressible solvers.
Definition: incompressiblePrimalSolver.H:53
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
os
OBJstream os(runTime.globalPath()/outputName)
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::SIMPLEControl::New
static autoPtr< SIMPLEControl > New(fvMesh &mesh, const word &managerType, const solver &solver)
Return a reference to the selected turbulence model.
Definition: SIMPLEControl.C:64
Time.H
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::solver::vars_
autoPtr< variablesSet > vars_
Base variableSet pointer.
Definition: solver.H:82
Foam::Ostream::writeEntry
Ostream & writeEntry(const keyType &key, const T &value)
Write a keyword/value entry.
Definition: Ostream.H:236
Foam::Ostream
An Ostream is an abstract base class for all output systems (streams, files, token lists,...
Definition: Ostream.H:56
Foam::incompressiblePrimalSolver::getIncoVars
const incompressibleVars & getIncoVars() const
Access to the incompressible variables set.
Definition: incompressiblePrimalSolver.C:154
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::objectRegistry::time
const Time & time() const noexcept
Return time registry.
Definition: objectRegistry.H:178
Foam::incompressibleVars
Base class for solution control classes.
Definition: incompressibleVars.H:54
Foam::RASTurbulenceModel::writeData
virtual bool writeData(Ostream &os) const
Read average iteration.
Definition: RASTurbulenceModel.C:122