mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: support disable libs when constructing Time from argList (#1714)
- previously relied on presence/absence of command-line options. Can now explicitly disable individually - provide shorter constructors for dealing with these types of cases. Make construction with non-default names for "system" and "constant" lengthier so there is no ambiguity.
This commit is contained in:
@ -490,7 +490,9 @@ Foam::Time::Time
|
||||
const word& ctrlDictName,
|
||||
const argList& args,
|
||||
const word& systemName,
|
||||
const word& constantName
|
||||
const word& constantName,
|
||||
const bool enableFunctionObjects,
|
||||
const bool enableLibs
|
||||
)
|
||||
:
|
||||
TimePaths(args, systemName, constantName),
|
||||
@ -543,17 +545,23 @@ Foam::Time::Time
|
||||
? !args.found("noFunctionObjects")
|
||||
: false
|
||||
)
|
||||
{
|
||||
if (enableFunctionObjects)
|
||||
{
|
||||
functionObjects_.on();
|
||||
}
|
||||
}
|
||||
|
||||
// Libraries
|
||||
//
|
||||
// * enabled unless '-no-libs' option was used
|
||||
// * enable by default unless '-no-libs' option was used
|
||||
if (!args.found("no-libs"))
|
||||
{
|
||||
if (enableLibs)
|
||||
{
|
||||
libs_.open(controlDict_, "libs");
|
||||
}
|
||||
}
|
||||
|
||||
// Explicitly set read flags on objectRegistry so anything constructed
|
||||
// from it reads as well (e.g. fvSolution).
|
||||
@ -716,10 +724,8 @@ Foam::autoPtr<Foam::Time> Foam::Time::New()
|
||||
return
|
||||
autoPtr<Time>::New
|
||||
(
|
||||
".", // root-path
|
||||
".", // case-name
|
||||
"system",
|
||||
"constant",
|
||||
fileName("."), // root-path
|
||||
fileName("."), // case-name
|
||||
false, // No enableFunctionObjects
|
||||
false // No enableLibs
|
||||
);
|
||||
@ -733,8 +739,19 @@ Foam::autoPtr<Foam::Time> Foam::Time::New(const fileName& caseDir)
|
||||
(
|
||||
caseDir.path(), // root-path
|
||||
caseDir.name(), // case-name
|
||||
"system",
|
||||
"constant",
|
||||
false, // No enableFunctionObjects
|
||||
false // No enableLibs
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Foam::autoPtr<Foam::Time> Foam::Time::New(const argList& args)
|
||||
{
|
||||
return
|
||||
autoPtr<Time>::New
|
||||
(
|
||||
Time::controlDictName,
|
||||
args,
|
||||
false, // No enableFunctionObjects
|
||||
false // No enableLibs
|
||||
);
|
||||
|
||||
@ -62,7 +62,7 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
// Forward Declarations
|
||||
class argList;
|
||||
class profilingTrigger;
|
||||
class OSstream;
|
||||
@ -221,54 +221,106 @@ private:
|
||||
|
||||
public:
|
||||
|
||||
TypeName("time");
|
||||
// Static Data Members
|
||||
|
||||
//- The default control dictionary name (normally "controlDict")
|
||||
static word controlDictName;
|
||||
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("time");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct given name of dictionary to read and argument list
|
||||
//- Construct from dictionary name to read and argument list.
|
||||
// Uses "system" and "constant" for its directories.
|
||||
inline Time
|
||||
(
|
||||
const word& ctrlDictName,
|
||||
const argList& args,
|
||||
const bool enableFunctionObjects = true,
|
||||
const bool enableLibs = true
|
||||
);
|
||||
|
||||
//- Construct given name of dictionary to read and root/case paths.
|
||||
// Uses "system" and "constant" for its directories.
|
||||
inline Time
|
||||
(
|
||||
const word& ctrlDictName,
|
||||
const fileName& rootPath,
|
||||
const fileName& caseName,
|
||||
const bool enableFunctionObjects = true,
|
||||
const bool enableLibs = true
|
||||
);
|
||||
|
||||
//- Construct given dictionary and root/case paths.
|
||||
// Uses "system" and "constant" for its directories.
|
||||
inline Time
|
||||
(
|
||||
const dictionary& dict,
|
||||
const fileName& rootPath,
|
||||
const fileName& caseName,
|
||||
const bool enableFunctionObjects = true,
|
||||
const bool enableLibs = true
|
||||
);
|
||||
|
||||
//- Construct at endTime and root/case paths.
|
||||
// Uses "system" and "constant" for its directories.
|
||||
inline Time
|
||||
(
|
||||
const fileName& rootPath,
|
||||
const fileName& caseName,
|
||||
const bool enableFunctionObjects = true,
|
||||
const bool enableLibs = true
|
||||
);
|
||||
|
||||
//- Construct from dictionary name to read and argument list.
|
||||
// Use specified system/constant directory names.
|
||||
Time
|
||||
(
|
||||
const word& ctrlDictName,
|
||||
const argList& args,
|
||||
const word& systemName = "system",
|
||||
const word& constantName = "constant"
|
||||
const word& systemName, //!< "system" directory name
|
||||
const word& constantName, //!< "constant" directory name
|
||||
const bool enableFunctionObjects = true,
|
||||
const bool enableLibs = true
|
||||
);
|
||||
|
||||
//- Construct given name of dictionary to read, rootPath and casePath
|
||||
//- Construct given name of dictionary to read and root/case paths.
|
||||
// Use specified system/constant directory names.
|
||||
Time
|
||||
(
|
||||
const word& ctrlDictName,
|
||||
const fileName& rootPath,
|
||||
const fileName& caseName,
|
||||
const word& systemName = "system",
|
||||
const word& constantName = "constant",
|
||||
const word& systemName, //!< "system" directory name
|
||||
const word& constantName, //!< "constant" directory name
|
||||
const bool enableFunctionObjects = true,
|
||||
const bool enableLibs = true
|
||||
);
|
||||
|
||||
//- Construct given dictionary, rootPath and casePath
|
||||
//- Construct given dictionary and root/case paths.
|
||||
// Use specified system/constant directory names.
|
||||
Time
|
||||
(
|
||||
const dictionary& dict,
|
||||
const fileName& rootPath,
|
||||
const fileName& caseName,
|
||||
const word& systemName = "system",
|
||||
const word& constantName = "constant",
|
||||
const word& systemName, //!< "system" directory name
|
||||
const word& constantName, //!< "constant" directory name
|
||||
const bool enableFunctionObjects = true,
|
||||
const bool enableLibs = true
|
||||
);
|
||||
|
||||
//- Construct given endTime, rootPath and casePath
|
||||
//- Construct given endTime and root/case paths.
|
||||
// Use specified system/constant directory names.
|
||||
Time
|
||||
(
|
||||
const fileName& rootPath,
|
||||
const fileName& caseName,
|
||||
const word& systemName = "system",
|
||||
const word& constantName = "constant",
|
||||
const word& systemName, //!< "system" directory name
|
||||
const word& constantName, //!< "constant" directory name
|
||||
const bool enableFunctionObjects = true,
|
||||
const bool enableLibs = true
|
||||
);
|
||||
@ -276,12 +328,15 @@ public:
|
||||
|
||||
// Selectors
|
||||
|
||||
//- Construct dummy time, without functionObjects or libraries
|
||||
//- Construct (dummy) Time - no functionObjects or libraries
|
||||
static autoPtr<Time> New();
|
||||
|
||||
//- Construct dummy time, without functionObjects or libraries
|
||||
//- Construct (dummy) Time - no functionObjects or libraries
|
||||
static autoPtr<Time> New(const fileName& caseDir);
|
||||
|
||||
//- Construct (dummy) Time - no functionObjects or libraries
|
||||
static autoPtr<Time> New(const argList& args);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~Time();
|
||||
@ -608,6 +663,10 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "TimeI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
114
src/OpenFOAM/db/Time/TimeI.H
Normal file
114
src/OpenFOAM/db/Time/TimeI.H
Normal file
@ -0,0 +1,114 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | www.openfoam.com
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
Copyright (C) 2020 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::Time::Time
|
||||
(
|
||||
const word& ctrlDictName,
|
||||
const argList& args,
|
||||
const bool enableFunctionObjects,
|
||||
const bool enableLibs
|
||||
)
|
||||
:
|
||||
Foam::Time
|
||||
(
|
||||
ctrlDictName,
|
||||
args,
|
||||
"system",
|
||||
"constant",
|
||||
enableFunctionObjects,
|
||||
enableLibs
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::Time::Time
|
||||
(
|
||||
const word& ctrlDictName,
|
||||
const fileName& rootPath,
|
||||
const fileName& caseName,
|
||||
const bool enableFunctionObjects,
|
||||
const bool enableLibs
|
||||
)
|
||||
:
|
||||
Foam::Time
|
||||
(
|
||||
ctrlDictName,
|
||||
rootPath,
|
||||
caseName,
|
||||
"system",
|
||||
"constant",
|
||||
enableFunctionObjects,
|
||||
enableLibs
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::Time::Time
|
||||
(
|
||||
const dictionary& dict,
|
||||
const fileName& rootPath,
|
||||
const fileName& caseName,
|
||||
const bool enableFunctionObjects,
|
||||
const bool enableLibs
|
||||
)
|
||||
:
|
||||
Foam::Time
|
||||
(
|
||||
dict,
|
||||
rootPath,
|
||||
caseName,
|
||||
"system",
|
||||
"constant",
|
||||
enableFunctionObjects,
|
||||
enableLibs
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
inline Foam::Time::Time
|
||||
(
|
||||
const fileName& rootPath,
|
||||
const fileName& caseName,
|
||||
const bool enableFunctionObjects,
|
||||
const bool enableLibs
|
||||
)
|
||||
:
|
||||
Time
|
||||
(
|
||||
rootPath,
|
||||
caseName,
|
||||
"system",
|
||||
"constant",
|
||||
enableFunctionObjects,
|
||||
enableLibs
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -46,7 +46,7 @@ SourceFiles
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// Forward declarations
|
||||
// Forward Declarations
|
||||
class argList;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
@ -56,7 +56,7 @@ class argList;
|
||||
|
||||
class TimePaths
|
||||
{
|
||||
// Private data
|
||||
// Private Data
|
||||
|
||||
bool processorCase_;
|
||||
bool distributed_;
|
||||
@ -79,7 +79,7 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct using characteristics given by the argList
|
||||
TimePaths
|
||||
explicit TimePaths
|
||||
(
|
||||
const argList& args,
|
||||
const word& systemName = "system",
|
||||
|
||||
Reference in New Issue
Block a user