functions.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2023-2024 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 "functions.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33 namespace solvers
34 {
37 }
38 }
39 
40 
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 
44 :
45  movingMesh(mesh)
46 {
47  // Read the solverName from the subSolver or solver entry in controlDict
48  word solverName;
50  {
51  solverName = runTime.controlDict().lookup<word>("solver");
52  }
53  if (!functionObject::postProcess || solverName == typeName)
54  {
55  solverName = runTime.controlDict().lookup<word>("subSolver");
56  }
57  if (solverName == typeName)
58  {
60  << "Invalid sub-solver type "
61  << solverName << exit(FatalIOError);
62  }
63 
64  Time& time(const_cast<Time&>(runTime));
65  const TimeState ts(time);
66  bool startTimeChanged = false;
67 
68  if (runTime.controlDict().found("subSolverTime"))
69  {
70  const scalar subSolverTime
71  (
72  runTime.controlDict().lookup<scalar>("subSolverTime")
73  );
74 
75  time.setTime(subSolverTime, 0);
76 
77  startTimeChanged = true;
78  }
79 
80  // Instantiate the selected solver
81  solverPtr = solver::New(solverName, mesh);
82 
83  if (startTimeChanged)
84  {
85  time.setTime(ts, ts.timeIndex());
86  }
87 
88  // Set all registered objects to NO_WRITE
89  // so only those created by the functionObjects are written
90  for
91  (
92  objectRegistry::iterator iter = mesh.objectRegistry::begin();
93  iter != mesh.objectRegistry::end();
94  ++iter
95  )
96  {
97  iter()->writeOpt() = IOobject::NO_WRITE;
98  }
99 }
100 
101 
102 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
103 
105 {}
106 
107 
108 // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
109 
111 {
112  return vGreat;
113 }
114 
115 
117 {}
118 
119 
121 {}
122 
123 
125 {}
126 
127 
129 {}
130 
131 
133 {}
134 
135 
137 {}
138 
139 
140 // ************************************************************************* //
Macros for easy insertion into run-time selection tables.
friend class iterator
Declare friendship with the iterator.
Definition: HashTable.H:194
const Time & time() const
Return time.
Definition: IOobject.C:318
The time value with time-stepping information, user-defined remapping, etc.
Definition: TimeState.H:55
label timeIndex() const
Return current time index.
Definition: TimeStateI.H:28
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:76
virtual void setTime(const Time &)
Reset the time and time-index to those of the given time.
Definition: Time.C:985
const IOdictionary & controlDict() const
Return the control dict.
Definition: Time.H:269
ITstream & lookup(const word &, bool recursive=false, bool patternMatch=true) const
Find and return an entry data stream.
Definition: dictionary.C:710
bool found(const word &, bool recursive=false, bool patternMatch=true) const
Search dictionary for given keyword.
Definition: dictionary.C:509
static bool postProcess
Global post-processing mode switch.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:99
Abstract base class for run-time selectable region solvers.
Definition: solver.H:56
static autoPtr< solver > New(const word &solverName, fvMesh &mesh)
Select, construct and return the solver.
Definition: solverNew.C:37
const Time & runTime
Time.
Definition: solver.H:104
const fvMesh & mesh
Region mesh.
Definition: solver.H:101
Solver module to execute the functionObjects for a specified solver.
Definition: functions.H:70
virtual void thermophysicalPredictor()
Construct and solve the energy equation,.
Definition: functions.C:124
virtual void prePredictor()
Called at the beginning of the PIMPLE loop.
Definition: functions.C:116
virtual void postSolve()
Called after the PIMPLE loop at the end of the time-step.
Definition: functions.C:136
virtual scalar maxDeltaT() const
Return the current maximum time-step for stable solution.
Definition: functions.C:110
virtual void pressureCorrector()
Construct and solve the pressure equation in the PISO loop.
Definition: functions.C:128
virtual void postCorrector()
Correct the thermophysical transport modelling.
Definition: functions.C:132
virtual void momentumPredictor()
Construct and optionally solve the momentum equation.
Definition: functions.C:120
autoPtr< solver > solverPtr
Pointer to the solid or fluid solver.
Definition: functions.H:75
functions(fvMesh &mesh)
Construct from region mesh.
Definition: functions.C:43
virtual ~functions()
Destructor.
Definition: functions.C:104
Solver module to move the mesh.
Definition: movingMesh.H:56
A class for handling words, derived from string.
Definition: word.H:62
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:346
addToRunTimeSelectionTable(solver, compressibleMultiphaseVoF, fvMesh)
defineTypeNameAndDebug(compressibleMultiphaseVoF, 0)
Namespace for OpenFOAM.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
IOerror FatalIOError