mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'update-registry-handling0' into 'develop'
Improved DimensionedField/GeometricField factory methods See merge request Development/openfoam!650
This commit is contained in:
@ -5,7 +5,7 @@
|
|||||||
\\ / A nd | www.openfoam.com
|
\\ / A nd | www.openfoam.com
|
||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -45,10 +45,31 @@ Description
|
|||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
|
enum loadTestTypes
|
||||||
|
{
|
||||||
|
PLAIN_PTR, AUTO_PTR, REF_PTR, TMP_PTR, CACHE_PTR
|
||||||
|
};
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
void printIOobject(const regIOobject* io)
|
||||||
|
{
|
||||||
|
if (io)
|
||||||
|
{
|
||||||
|
Info<< io->name() << ' ' << "type=" << io->type()
|
||||||
|
<< " registered=" << io->registered()
|
||||||
|
<< " owned=" << io->ownedByRegistry() << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type>
|
template<class Type>
|
||||||
bool loadField(fvMesh& mesh, const word& fieldName)
|
bool loadField
|
||||||
|
(
|
||||||
|
fvMesh& mesh,
|
||||||
|
const word& fieldName,
|
||||||
|
enum loadTestTypes wrapper = loadTestTypes::PLAIN_PTR
|
||||||
|
)
|
||||||
{
|
{
|
||||||
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
typedef GeometricField<Type, fvPatchField, volMesh> VolFieldType;
|
||||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
typedef GeometricField<Type, fvsPatchField, surfaceMesh> SurfaceFieldType;
|
||||||
@ -66,20 +87,67 @@ bool loadField(fvMesh& mesh, const word& fieldName)
|
|||||||
mesh,
|
mesh,
|
||||||
IOobject::MUST_READ,
|
IOobject::MUST_READ,
|
||||||
IOobject::NO_WRITE
|
IOobject::NO_WRITE
|
||||||
|
// Value of register is fairly irrelevant
|
||||||
);
|
);
|
||||||
|
|
||||||
if (fieldHeader.typeHeaderOk<VolFieldType>(true, true, false))
|
if (fieldHeader.typeHeaderOk<VolFieldType>(true, true, false))
|
||||||
{
|
{
|
||||||
// Store field on mesh database
|
// Store field on mesh database
|
||||||
VolFieldType* ptr = new VolFieldType(fieldHeader, mesh);
|
switch (wrapper)
|
||||||
mesh.objectRegistry::store(ptr);
|
{
|
||||||
|
case loadTestTypes::PLAIN_PTR :
|
||||||
|
{
|
||||||
|
auto* ptr = new VolFieldType(fieldHeader, mesh);
|
||||||
|
printIOobject(ptr);
|
||||||
|
regIOobject::store(ptr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case loadTestTypes::AUTO_PTR :
|
||||||
|
{
|
||||||
|
auto ptr = autoPtr<VolFieldType>::New(fieldHeader, mesh);
|
||||||
|
printIOobject(ptr.get());
|
||||||
|
regIOobject::store(ptr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case loadTestTypes::REF_PTR :
|
||||||
|
{
|
||||||
|
auto ptr = refPtr<VolFieldType>::New(fieldHeader, mesh);
|
||||||
|
printIOobject(ptr.get());
|
||||||
|
regIOobject::store(ptr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case loadTestTypes::TMP_PTR :
|
||||||
|
{
|
||||||
|
auto ptr = tmp<VolFieldType>::New(fieldHeader, mesh);
|
||||||
|
printIOobject(ptr.get());
|
||||||
|
Info<< "pointer:" << ptr.is_pointer()
|
||||||
|
<< " movable:" << ptr.movable() << nl;
|
||||||
|
regIOobject::store(ptr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case loadTestTypes::CACHE_PTR :
|
||||||
|
{
|
||||||
|
auto ptr = tmp<VolFieldType>::New(fieldHeader, mesh);
|
||||||
|
ptr.protect(true);
|
||||||
|
printIOobject(ptr.get());
|
||||||
|
Info<< "pointer:" << ptr.is_pointer()
|
||||||
|
<< " movable:" << ptr.movable() << nl;
|
||||||
|
regIOobject::store(ptr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (fieldHeader.typeHeaderOk<SurfaceFieldType>(true, true, false))
|
else if (fieldHeader.typeHeaderOk<SurfaceFieldType>(true, true, false))
|
||||||
{
|
{
|
||||||
// Store field on mesh database
|
// Store field on mesh database
|
||||||
SurfaceFieldType* ptr = new SurfaceFieldType(fieldHeader, mesh);
|
SurfaceFieldType* ptr = new SurfaceFieldType(fieldHeader, mesh);
|
||||||
mesh.objectRegistry::store(ptr);
|
regIOobject::store(ptr);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -87,28 +155,38 @@ bool loadField(fvMesh& mesh, const word& fieldName)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool loadField(fvMesh& mesh, const word& fieldName)
|
bool loadField
|
||||||
|
(
|
||||||
|
fvMesh& mesh,
|
||||||
|
const word& fieldName,
|
||||||
|
enum loadTestTypes wrapper = loadTestTypes::PLAIN_PTR
|
||||||
|
)
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
(
|
(
|
||||||
!mesh.objectRegistry::found(fieldName)
|
!mesh.objectRegistry::found(fieldName)
|
||||||
&&
|
&&
|
||||||
(
|
(
|
||||||
loadField<scalar>(mesh, fieldName)
|
loadField<scalar>(mesh, fieldName, wrapper)
|
||||||
|| loadField<vector>(mesh, fieldName)
|
|| loadField<vector>(mesh, fieldName, wrapper)
|
||||||
|| loadField<sphericalTensor>(mesh, fieldName)
|
|| loadField<sphericalTensor>(mesh, fieldName, wrapper)
|
||||||
|| loadField<symmTensor>(mesh, fieldName)
|
|| loadField<symmTensor>(mesh, fieldName, wrapper)
|
||||||
|| loadField<tensor>(mesh, fieldName)
|
|| loadField<tensor>(mesh, fieldName, wrapper)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void loadFields(fvMesh& mesh, const IOobjectList& objects)
|
void loadFields
|
||||||
|
(
|
||||||
|
fvMesh& mesh,
|
||||||
|
const IOobjectList& objects,
|
||||||
|
enum loadTestTypes wrapper = loadTestTypes::PLAIN_PTR
|
||||||
|
)
|
||||||
{
|
{
|
||||||
for (const word& fieldName : objects.names())
|
for (const word& fieldName : objects.names())
|
||||||
{
|
{
|
||||||
loadField(mesh, fieldName);
|
loadField(mesh, fieldName, wrapper);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -286,8 +364,46 @@ int main(int argc, char *argv[])
|
|||||||
// timeSelector::addOptions();
|
// timeSelector::addOptions();
|
||||||
timeSelector::addOptions(true, true);
|
timeSelector::addOptions(true, true);
|
||||||
|
|
||||||
|
argList::addBoolOption("plain", "Store from raw pointer (default)");
|
||||||
|
argList::addBoolOption("autoPtr", "Store from autoPtr");
|
||||||
|
argList::addBoolOption("refPtr", "Store from refPtr");
|
||||||
|
argList::addBoolOption("cacheTmp", "Store from tmp (cached)");
|
||||||
|
argList::addBoolOption("tmp", "Store from tmp (regular)");
|
||||||
|
|
||||||
|
argList::addVerboseOption("increase debug value");
|
||||||
|
|
||||||
#include "setRootCase.H"
|
#include "setRootCase.H"
|
||||||
|
|
||||||
|
const int optVerbose = args.verbose();
|
||||||
|
|
||||||
|
enum loadTestTypes loadWrapper = loadTestTypes::PLAIN_PTR;
|
||||||
|
|
||||||
|
if (args.found("autoPtr"))
|
||||||
|
{
|
||||||
|
Info<< "loading via autoPtr" << nl;
|
||||||
|
loadWrapper = loadTestTypes::AUTO_PTR;
|
||||||
|
}
|
||||||
|
else if (args.found("refPtr"))
|
||||||
|
{
|
||||||
|
Info<< "loading via refPtr" << nl;
|
||||||
|
loadWrapper = loadTestTypes::REF_PTR;
|
||||||
|
}
|
||||||
|
else if (args.found("cacheTmp"))
|
||||||
|
{
|
||||||
|
Info<< "loading via tmp (cached)" << nl;
|
||||||
|
loadWrapper = loadTestTypes::CACHE_PTR;
|
||||||
|
}
|
||||||
|
else if (args.found("tmp"))
|
||||||
|
{
|
||||||
|
Info<< "loading via tmp (regular)" << nl;
|
||||||
|
loadWrapper = loadTestTypes::TMP_PTR;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Info<< "loading via plain ptr" << nl;
|
||||||
|
loadWrapper = loadTestTypes::PLAIN_PTR;
|
||||||
|
}
|
||||||
|
|
||||||
// wordRes matcher;
|
// wordRes matcher;
|
||||||
// if (args.readListIfPresent<wordRe>("filter", matcher))
|
// if (args.readListIfPresent<wordRe>("filter", matcher))
|
||||||
// {
|
// {
|
||||||
@ -299,6 +415,12 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
instantList timeDirs = timeSelector::select0(runTime, args);
|
instantList timeDirs = timeSelector::select0(runTime, args);
|
||||||
|
|
||||||
|
if (optVerbose)
|
||||||
|
{
|
||||||
|
objectRegistry::debug = optVerbose;
|
||||||
|
regIOobject::debug = optVerbose;
|
||||||
|
}
|
||||||
|
|
||||||
forAll(timeDirs, timeI)
|
forAll(timeDirs, timeI)
|
||||||
{
|
{
|
||||||
runTime.setTime(timeDirs[timeI], timeI);
|
runTime.setTime(timeDirs[timeI], timeI);
|
||||||
@ -309,7 +431,7 @@ int main(int argc, char *argv[])
|
|||||||
IOobjectList objects(mesh, runTime.timeName());
|
IOobjectList objects(mesh, runTime.timeName());
|
||||||
|
|
||||||
// Read volFields
|
// Read volFields
|
||||||
loadFields(mesh, objects);
|
loadFields(mesh, objects, loadWrapper);
|
||||||
|
|
||||||
printRegistry(Info, mesh);
|
printRegistry(Info, mesh);
|
||||||
|
|
||||||
|
|||||||
@ -633,7 +633,13 @@ public:
|
|||||||
//FUTURE void addTemporaryObject(const word& name) const;
|
//FUTURE void addTemporaryObject(const word& name) const;
|
||||||
|
|
||||||
//- True if given name is in the cacheTemporaryObjects set
|
//- True if given name is in the cacheTemporaryObjects set
|
||||||
bool cacheTemporaryObject(const word& name) const;
|
bool is_cacheTemporaryObject(const word& name) const;
|
||||||
|
|
||||||
|
//- True if name of object is in the cacheTemporaryObjects set
|
||||||
|
bool is_cacheTemporaryObject(const regIOobject* io) const;
|
||||||
|
|
||||||
|
//- True if name of object is in the cacheTemporaryObjects set
|
||||||
|
bool is_cacheTemporaryObject(const regIOobject& io) const;
|
||||||
|
|
||||||
//- Cache the given object. Moves content and stores
|
//- Cache the given object. Moves content and stores
|
||||||
template<class Type>
|
template<class Type>
|
||||||
@ -643,7 +649,7 @@ public:
|
|||||||
void resetCacheTemporaryObject(const regIOobject* io) const;
|
void resetCacheTemporaryObject(const regIOobject* io) const;
|
||||||
|
|
||||||
//- Reset the cache state of the given object
|
//- Reset the cache state of the given object
|
||||||
// in the cacheTemporaryObjects set
|
//- in the cacheTemporaryObjects set
|
||||||
void resetCacheTemporaryObject(const regIOobject& io) const;
|
void resetCacheTemporaryObject(const regIOobject& io) const;
|
||||||
|
|
||||||
//- Check that all objects specified in the cacheTemporaryObjects
|
//- Check that all objects specified in the cacheTemporaryObjects
|
||||||
|
|||||||
@ -65,6 +65,12 @@ void Foam::objectRegistry::readCacheTemporaryObjects() const
|
|||||||
{
|
{
|
||||||
cacheTemporaryObjects_.emplace(objName, false, false);
|
cacheTemporaryObjects_.emplace(objName, false, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (objectRegistry::debug)
|
||||||
|
{
|
||||||
|
Info<< "objectRegistry::cacheTemporaryObjects : "
|
||||||
|
<< flatOutput(objectNames) << endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -75,6 +81,8 @@ void Foam::objectRegistry::deleteCachedObject(regIOobject* io) const
|
|||||||
{
|
{
|
||||||
io->release(); // Relinquish any ownership by registry
|
io->release(); // Relinquish any ownership by registry
|
||||||
io->checkOut();
|
io->checkOut();
|
||||||
|
// Additional safety - not certain this is actually needed...
|
||||||
|
io->rename(io->name() + "-Cache");
|
||||||
delete io;
|
delete io;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -90,12 +98,24 @@ void Foam::objectRegistry::deleteCachedObject(regIOobject* io) const
|
|||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
bool Foam::objectRegistry::cacheTemporaryObject
|
bool Foam::objectRegistry::is_cacheTemporaryObject
|
||||||
(
|
(
|
||||||
const word& name
|
const word& name
|
||||||
) const
|
) const
|
||||||
{
|
{
|
||||||
return cacheTemporaryObjects_.found(name);
|
return cacheTemporaryObjects_.contains(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::objectRegistry::is_cacheTemporaryObject(const regIOobject* io) const
|
||||||
|
{
|
||||||
|
return io && cacheTemporaryObjects_.contains(io->name());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Foam::objectRegistry::is_cacheTemporaryObject(const regIOobject& io) const
|
||||||
|
{
|
||||||
|
return cacheTemporaryObjects_.contains(io.name());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2017 OpenFOAM Foundation
|
Copyright (C) 2011-2017 OpenFOAM Foundation
|
||||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -56,7 +56,7 @@ Foam::regIOobject::regIOobject(const IOobject& io, const bool isTimeObject)
|
|||||||
metaDataPtr_(nullptr),
|
metaDataPtr_(nullptr),
|
||||||
isPtr_(nullptr)
|
isPtr_(nullptr)
|
||||||
{
|
{
|
||||||
if (registerObject())
|
if (IOobject::registerObject())
|
||||||
{
|
{
|
||||||
// Register (check-in) with objectRegistry if requested
|
// Register (check-in) with objectRegistry if requested
|
||||||
checkIn();
|
checkIn();
|
||||||
@ -137,7 +137,7 @@ Foam::regIOobject::regIOobject
|
|||||||
metaDataPtr_(rio.metaDataPtr_.clone()),
|
metaDataPtr_(rio.metaDataPtr_.clone()),
|
||||||
isPtr_(nullptr)
|
isPtr_(nullptr)
|
||||||
{
|
{
|
||||||
if (registerObject())
|
if (IOobject::registerObject())
|
||||||
{
|
{
|
||||||
checkIn();
|
checkIn();
|
||||||
}
|
}
|
||||||
@ -194,7 +194,7 @@ bool Foam::regIOobject::checkIn()
|
|||||||
{
|
{
|
||||||
// multiple checkin of same object is disallowed - this would mess up
|
// multiple checkin of same object is disallowed - this would mess up
|
||||||
// any mapping
|
// any mapping
|
||||||
registered_ = db().checkIn(*this);
|
registered_ = db().checkIn(this);
|
||||||
|
|
||||||
// check-in on defaultRegion is allowed to fail, since subsetted meshes
|
// check-in on defaultRegion is allowed to fail, since subsetted meshes
|
||||||
// are created with the same name as their originating mesh
|
// are created with the same name as their originating mesh
|
||||||
@ -205,17 +205,18 @@ bool Foam::regIOobject::checkIn()
|
|||||||
// for ease of finding where attempted duplicate check-in
|
// for ease of finding where attempted duplicate check-in
|
||||||
// originated
|
// originated
|
||||||
FatalErrorInFunction
|
FatalErrorInFunction
|
||||||
<< "failed to register object " << objectPath()
|
<< "Failed to register: " << name() << ' '
|
||||||
<< " the name already exists in the objectRegistry" << endl
|
<< objectRelPath()
|
||||||
<< "Contents:" << db().sortedToc()
|
<< " : the name already exists in the registry" << nl
|
||||||
|
<< "Contents:" << db().sortedToc() << endl
|
||||||
<< abort(FatalError);
|
<< abort(FatalError);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
WarningInFunction
|
WarningInFunction
|
||||||
<< "failed to register object " << objectPath()
|
<< "Failed to register: " << name() << ' '
|
||||||
<< " the name already exists in the objectRegistry"
|
<< objectRelPath()
|
||||||
<< endl;
|
<< " : the name already exists in the registry" << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -474,7 +475,7 @@ void Foam::regIOobject::rename(const word& newName)
|
|||||||
|
|
||||||
IOobject::rename(newName);
|
IOobject::rename(newName);
|
||||||
|
|
||||||
if (registerObject())
|
if (IOobject::registerObject())
|
||||||
{
|
{
|
||||||
// Re-register object with objectRegistry
|
// Re-register object with objectRegistry
|
||||||
checkIn();
|
checkIn();
|
||||||
@ -519,7 +520,7 @@ void Foam::regIOobject::operator=(const IOobject& io)
|
|||||||
|
|
||||||
IOobject::operator=(io);
|
IOobject::operator=(io);
|
||||||
|
|
||||||
if (registerObject())
|
if (IOobject::registerObject())
|
||||||
{
|
{
|
||||||
// Re-register object with objectRegistry
|
// Re-register object with objectRegistry
|
||||||
checkIn();
|
checkIn();
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2015 OpenFOAM Foundation
|
Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||||
Copyright (C) 2018-2022 OpenCFD Ltd.
|
Copyright (C) 2018-2023 OpenCFD Ltd.
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
License
|
License
|
||||||
This file is part of OpenFOAM.
|
This file is part of OpenFOAM.
|
||||||
@ -145,6 +145,8 @@ inline Type& Foam::regIOobject::store(tmp<Type>& ptr)
|
|||||||
if (ptr.is_pointer())
|
if (ptr.is_pointer())
|
||||||
{
|
{
|
||||||
// Acquire ownership, pass management to objectRegistry
|
// Acquire ownership, pass management to objectRegistry
|
||||||
|
|
||||||
|
ptr.protect(false); // Storing (ie, not cached/protected)
|
||||||
p = ptr.ptr();
|
p = ptr.ptr();
|
||||||
|
|
||||||
store(p);
|
store(p);
|
||||||
|
|||||||
@ -376,6 +376,16 @@ Foam::DimensionedField<Type, GeoMesh>::clone() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type, class GeoMesh>
|
||||||
|
Foam::DimensionedField<Type, GeoMesh>::~DimensionedField()
|
||||||
|
{
|
||||||
|
// FUTURE: register cache field info
|
||||||
|
// // this->db().cacheTemporaryObject(*this);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type, class GeoMesh>
|
template<class Type, class GeoMesh>
|
||||||
|
|||||||
@ -117,6 +117,17 @@ private:
|
|||||||
|
|
||||||
void readIfPresent(const word& fieldDictEntry = "value");
|
void readIfPresent(const word& fieldDictEntry = "value");
|
||||||
|
|
||||||
|
//- Implementation for 'New' with specified registerObject preference.
|
||||||
|
// For LEGACY_REGISTER, registration is determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
|
template<class... Args>
|
||||||
|
static tmp<DimensionedField<Type, GeoMesh>> New_impl
|
||||||
|
(
|
||||||
|
IOobjectOption::registerOption regOpt,
|
||||||
|
const word& name,
|
||||||
|
const Mesh& mesh,
|
||||||
|
Args&&... args
|
||||||
|
);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@ -298,10 +309,25 @@ public:
|
|||||||
|
|
||||||
// Factory Methods
|
// Factory Methods
|
||||||
|
|
||||||
//- Return tmp field from name, mesh, dimensions,
|
//- Return tmp field (NO_READ, NO_WRITE)
|
||||||
//- copy of internal field.
|
//- from name, mesh, dimensions, copy of internal field.
|
||||||
// The field is NO_READ, NO_WRITE, unregistered and uses the
|
//- [Takes current timeName from the mesh registry].
|
||||||
// current timeName from the mesh registry
|
// For LEGACY_REGISTER, registration is determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
|
static tmp<DimensionedField<Type, GeoMesh>> New
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
IOobjectOption::registerOption regOpt,
|
||||||
|
const Mesh& mesh,
|
||||||
|
const dimensionSet& dims,
|
||||||
|
const Field<Type>& iField
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Return tmp field (NO_READ, NO_WRITE)
|
||||||
|
//- from name, mesh, dimensions, copy of internal field.
|
||||||
|
//- [Takes current timeName from the mesh registry].
|
||||||
|
// Registration/persistence determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
static tmp<DimensionedField<Type, GeoMesh>> New
|
static tmp<DimensionedField<Type, GeoMesh>> New
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
@ -310,10 +336,25 @@ public:
|
|||||||
const Field<Type>& iField
|
const Field<Type>& iField
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Return tmp field from name, mesh, dimensions,
|
//- Return tmp field (NO_READ, NO_WRITE)
|
||||||
//- moved internal field contents.
|
//- from name, mesh, dimensions, move internal field contents.
|
||||||
// The field is NO_READ, NO_WRITE, unregistered and uses the
|
//- [Takes current timeName from the mesh registry].
|
||||||
// current timeName from the mesh registry
|
// For LEGACY_REGISTER, registration is determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
|
static tmp<DimensionedField<Type, GeoMesh>> New
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
IOobjectOption::registerOption regOpt,
|
||||||
|
const Mesh& mesh,
|
||||||
|
const dimensionSet& dims,
|
||||||
|
Field<Type>&& iField
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Return tmp field (NO_READ, NO_WRITE)
|
||||||
|
//- from name, mesh, dimensions, move internal field contents.
|
||||||
|
//- [Takes current timeName from the mesh registry].
|
||||||
|
// Registration/persistence determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
static tmp<DimensionedField<Type, GeoMesh>> New
|
static tmp<DimensionedField<Type, GeoMesh>> New
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
@ -322,9 +363,24 @@ public:
|
|||||||
Field<Type>&& iField
|
Field<Type>&& iField
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Return tmp field from name, mesh, dimensions.
|
//- Return tmp field (NO_READ, NO_WRITE)
|
||||||
// The field is NO_READ, NO_WRITE, unregistered and uses the
|
//- from name, mesh, dimensions.
|
||||||
// current timeName from the mesh registry
|
//- [Takes current timeName from the mesh registry].
|
||||||
|
// For LEGACY_REGISTER, registration is determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
|
static tmp<DimensionedField<Type, GeoMesh>> New
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
IOobjectOption::registerOption regOpt,
|
||||||
|
const Mesh& mesh,
|
||||||
|
const dimensionSet& dims
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Return tmp field (NO_READ, NO_WRITE)
|
||||||
|
//- from name, mesh, dimensions.
|
||||||
|
//- [Takes current timeName from the mesh registry].
|
||||||
|
// Registration/persistence determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
static tmp<DimensionedField<Type, GeoMesh>> New
|
static tmp<DimensionedField<Type, GeoMesh>> New
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
@ -332,9 +388,25 @@ public:
|
|||||||
const dimensionSet& dims
|
const dimensionSet& dims
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Return uniform value tmp field from name, mesh, dimensions, value.
|
//- Return tmp field (NO_READ, NO_WRITE)
|
||||||
// The field is NO_READ, NO_WRITE, unregistered and uses the
|
//- from name, mesh, value, dimensions.
|
||||||
// current timeName from the mesh registry
|
//- [Takes current timeName from the mesh registry].
|
||||||
|
// For LEGACY_REGISTER, registration is determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
|
static tmp<DimensionedField<Type, GeoMesh>> New
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
IOobjectOption::registerOption regOpt,
|
||||||
|
const Mesh& mesh,
|
||||||
|
const Type& value,
|
||||||
|
const dimensionSet& dims
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Return tmp field (NO_READ, NO_WRITE)
|
||||||
|
//- from name, mesh, value, dimensions.
|
||||||
|
//- [Takes current timeName from the mesh registry].
|
||||||
|
// Registration/persistence determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
static tmp<DimensionedField<Type, GeoMesh>> New
|
static tmp<DimensionedField<Type, GeoMesh>> New
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
@ -343,9 +415,24 @@ public:
|
|||||||
const dimensionSet& dims
|
const dimensionSet& dims
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Return tmp field from name, mesh, dimensioned\<Type\>.
|
//- Return tmp field (NO_READ, NO_WRITE)
|
||||||
// The field is NO_READ, NO_WRITE, unregistered and uses the
|
//- from name, mesh, dimensioned-type.
|
||||||
// current timeName from the mesh registry
|
//- [Takes current timeName from the mesh registry].
|
||||||
|
// For LEGACY_REGISTER, registration is determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
|
static tmp<DimensionedField<Type, GeoMesh>> New
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
IOobjectOption::registerOption regOpt,
|
||||||
|
const Mesh& mesh,
|
||||||
|
const dimensioned<Type>& dt
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Return tmp field (NO_READ, NO_WRITE)
|
||||||
|
//- from name, mesh, dimensioned-type.
|
||||||
|
//- [Takes current timeName from the mesh registry].
|
||||||
|
// Registration/persistence determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
static tmp<DimensionedField<Type, GeoMesh>> New
|
static tmp<DimensionedField<Type, GeoMesh>> New
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
@ -353,19 +440,21 @@ public:
|
|||||||
const dimensioned<Type>& dt
|
const dimensioned<Type>& dt
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Return renamed tmp field
|
//- Return renamed tmp field (NO_READ, NO_WRITE).
|
||||||
// The field is NO_READ, NO_WRITE, unregistered and uses the
|
//- [Takes current timeName from the mesh registry].
|
||||||
// current timeName from the mesh registry
|
// Registration/persistence determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
static tmp<DimensionedField<Type, GeoMesh>> New
|
static tmp<DimensionedField<Type, GeoMesh>> New
|
||||||
(
|
(
|
||||||
const word& newName,
|
const word& newName,
|
||||||
const tmp<DimensionedField<Type, GeoMesh>>& tfld
|
const tmp<DimensionedField<Type, GeoMesh>>& tfld
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct tmp field based on mesh/registry information from
|
//- Construct tmp field (NO_READ, NO_WRITE)
|
||||||
//- an existing field.
|
//- based on mesh/registry information from an existing field.
|
||||||
// Created NO_READ, NO_WRITE, NO_REGISTER, using the instance
|
//- [Takes instance from the field].
|
||||||
// from the field
|
// Registration/persistence determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
template<class AnyType>
|
template<class AnyType>
|
||||||
static tmp<DimensionedField<Type, GeoMesh>> New
|
static tmp<DimensionedField<Type, GeoMesh>> New
|
||||||
(
|
(
|
||||||
@ -374,10 +463,11 @@ public:
|
|||||||
const dimensionSet& dims
|
const dimensionSet& dims
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct tmp field based on mesh/registry information from
|
//- Construct tmp field (NO_READ, NO_WRITE)
|
||||||
//- an existing field and initialise with value.
|
//- based on mesh/registry information from an existing field
|
||||||
// Created NO_READ, NO_WRITE, NO_REGISTER, using the instance
|
//- and initialise with value.
|
||||||
// from the field
|
// Registration/persistence determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
template<class AnyType>
|
template<class AnyType>
|
||||||
static tmp<DimensionedField<Type, GeoMesh>> New
|
static tmp<DimensionedField<Type, GeoMesh>> New
|
||||||
(
|
(
|
||||||
@ -388,7 +478,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
//- Destructor
|
//- Destructor
|
||||||
virtual ~DimensionedField() = default;
|
virtual ~DimensionedField();
|
||||||
|
|
||||||
|
|
||||||
// Member Functions
|
// Member Functions
|
||||||
@ -469,11 +559,15 @@ public:
|
|||||||
) const;
|
) const;
|
||||||
|
|
||||||
|
|
||||||
// Write
|
// Write
|
||||||
|
|
||||||
bool writeData(Ostream& os, const word& fieldDictEntry) const;
|
//- Write dimensions, oriented flag (if valid) and the
|
||||||
|
//- field data as a dictionary entry with the specified name.
|
||||||
|
bool writeData(Ostream& os, const word& fieldDictEntry) const;
|
||||||
|
|
||||||
bool writeData(Ostream& os) const;
|
//- The writeData function (required by regIOobject),
|
||||||
|
//- call writeData with dictionary entry name = "value"
|
||||||
|
bool writeData(Ostream& os) const;
|
||||||
|
|
||||||
|
|
||||||
// Member Operators
|
// Member Operators
|
||||||
|
|||||||
@ -25,23 +25,21 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
template<class Type, class GeoMesh>
|
template<class Type, class GeoMesh>
|
||||||
|
template<class... Args>
|
||||||
Foam::tmp<Foam::DimensionedField<Type, GeoMesh>>
|
Foam::tmp<Foam::DimensionedField<Type, GeoMesh>>
|
||||||
Foam::DimensionedField<Type, GeoMesh>::New
|
Foam::DimensionedField<Type, GeoMesh>::New_impl
|
||||||
(
|
(
|
||||||
|
IOobjectOption::registerOption regOpt,
|
||||||
const word& name,
|
const word& name,
|
||||||
const Mesh& mesh,
|
const Mesh& mesh,
|
||||||
const dimensionSet& dims,
|
Args&&... args
|
||||||
const Field<Type>& iField
|
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const bool caching = mesh.thisDb().cacheTemporaryObject(name);
|
auto ptr = tmp<DimensionedField<Type, GeoMesh>>::New
|
||||||
|
|
||||||
return tmp<DimensionedField<Type, GeoMesh>>::NewImmovable
|
|
||||||
(
|
(
|
||||||
caching, // (true: immovable, false: movable)
|
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
@ -49,9 +47,48 @@ Foam::DimensionedField<Type, GeoMesh>::New
|
|||||||
mesh.thisDb(),
|
mesh.thisDb(),
|
||||||
IOobjectOption::NO_READ,
|
IOobjectOption::NO_READ,
|
||||||
IOobjectOption::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
caching // (true: REGISTER, false: NO_REGISTER)
|
IOobjectOption::NO_REGISTER
|
||||||
),
|
),
|
||||||
mesh,
|
mesh,
|
||||||
|
std::forward<Args>(args)...
|
||||||
|
);
|
||||||
|
|
||||||
|
if (IOobjectOption::REGISTER == regOpt)
|
||||||
|
{
|
||||||
|
ptr->checkIn();
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
// LEGACY_REGISTER: detect if caching is desired
|
||||||
|
(IOobjectOption::LEGACY_REGISTER == regOpt)
|
||||||
|
&& ptr->db().is_cacheTemporaryObject(ptr.get())
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ptr.protect(true);
|
||||||
|
ptr->checkIn();
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type, class GeoMesh>
|
||||||
|
Foam::tmp<Foam::DimensionedField<Type, GeoMesh>>
|
||||||
|
Foam::DimensionedField<Type, GeoMesh>::New
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
IOobjectOption::registerOption regOpt,
|
||||||
|
const Mesh& mesh,
|
||||||
|
const dimensionSet& dims,
|
||||||
|
const Field<Type>& iField
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return DimensionedField<Type, GeoMesh>::New_impl
|
||||||
|
(
|
||||||
|
regOpt,
|
||||||
|
name,
|
||||||
|
mesh,
|
||||||
dims,
|
dims,
|
||||||
iField
|
iField
|
||||||
);
|
);
|
||||||
@ -65,23 +102,35 @@ Foam::DimensionedField<Type, GeoMesh>::New
|
|||||||
const word& name,
|
const word& name,
|
||||||
const Mesh& mesh,
|
const Mesh& mesh,
|
||||||
const dimensionSet& dims,
|
const dimensionSet& dims,
|
||||||
|
const Field<Type>& iField
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return DimensionedField<Type, GeoMesh>::New_impl
|
||||||
|
(
|
||||||
|
IOobjectOption::LEGACY_REGISTER,
|
||||||
|
name,
|
||||||
|
mesh,
|
||||||
|
dims,
|
||||||
|
iField
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, class GeoMesh>
|
||||||
|
Foam::tmp<Foam::DimensionedField<Type, GeoMesh>>
|
||||||
|
Foam::DimensionedField<Type, GeoMesh>::New
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
IOobjectOption::registerOption regOpt,
|
||||||
|
const Mesh& mesh,
|
||||||
|
const dimensionSet& dims,
|
||||||
Field<Type>&& iField
|
Field<Type>&& iField
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const bool caching = mesh.thisDb().cacheTemporaryObject(name);
|
return DimensionedField<Type, GeoMesh>::New_impl
|
||||||
|
|
||||||
return tmp<DimensionedField<Type, GeoMesh>>::NewImmovable
|
|
||||||
(
|
(
|
||||||
caching, // (true: immovable, false: movable)
|
regOpt,
|
||||||
IOobject
|
name,
|
||||||
(
|
|
||||||
name,
|
|
||||||
mesh.thisDb().time().timeName(),
|
|
||||||
mesh.thisDb(),
|
|
||||||
IOobjectOption::NO_READ,
|
|
||||||
IOobjectOption::NO_WRITE,
|
|
||||||
caching // (true: REGISTER, false: NO_REGISTER)
|
|
||||||
),
|
|
||||||
mesh,
|
mesh,
|
||||||
dims,
|
dims,
|
||||||
std::move(iField)
|
std::move(iField)
|
||||||
@ -95,26 +144,81 @@ Foam::DimensionedField<Type, GeoMesh>::New
|
|||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
const Mesh& mesh,
|
const Mesh& mesh,
|
||||||
|
const dimensionSet& dims,
|
||||||
|
Field<Type>&& iField
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return DimensionedField<Type, GeoMesh>::New_impl
|
||||||
|
(
|
||||||
|
IOobjectOption::LEGACY_REGISTER,
|
||||||
|
name,
|
||||||
|
mesh,
|
||||||
|
dims,
|
||||||
|
std::move(iField)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, class GeoMesh>
|
||||||
|
Foam::tmp<Foam::DimensionedField<Type, GeoMesh>>
|
||||||
|
Foam::DimensionedField<Type, GeoMesh>::New
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
IOobjectOption::registerOption regOpt,
|
||||||
|
const Mesh& mesh,
|
||||||
const dimensionSet& dims
|
const dimensionSet& dims
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const bool caching = mesh.thisDb().cacheTemporaryObject(name);
|
return DimensionedField<Type, GeoMesh>::New_impl
|
||||||
|
|
||||||
return tmp<DimensionedField<Type, GeoMesh>>::NewImmovable
|
|
||||||
(
|
(
|
||||||
caching, // (true: immovable, false: movable)
|
regOpt,
|
||||||
IOobject
|
name,
|
||||||
(
|
|
||||||
name,
|
|
||||||
mesh.thisDb().time().timeName(),
|
|
||||||
mesh.thisDb(),
|
|
||||||
IOobjectOption::NO_READ,
|
|
||||||
IOobjectOption::NO_WRITE,
|
|
||||||
caching // (true: REGISTER, false: NO_REGISTER)
|
|
||||||
),
|
|
||||||
mesh,
|
mesh,
|
||||||
dims,
|
dims,
|
||||||
false // checkIOFlags off
|
false // No checkIOFlags (is NO_READ anyhow)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, class GeoMesh>
|
||||||
|
Foam::tmp<Foam::DimensionedField<Type, GeoMesh>>
|
||||||
|
Foam::DimensionedField<Type, GeoMesh>::New
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const Mesh& mesh,
|
||||||
|
const dimensionSet& dims
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return DimensionedField<Type, GeoMesh>::New_impl
|
||||||
|
(
|
||||||
|
IOobjectOption::LEGACY_REGISTER,
|
||||||
|
name,
|
||||||
|
mesh,
|
||||||
|
dims,
|
||||||
|
false // No checkIOFlags (is NO_READ anyhow)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, class GeoMesh>
|
||||||
|
Foam::tmp<Foam::DimensionedField<Type, GeoMesh>>
|
||||||
|
Foam::DimensionedField<Type, GeoMesh>::New
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
IOobjectOption::registerOption regOpt,
|
||||||
|
const Mesh& mesh,
|
||||||
|
const Type& value,
|
||||||
|
const dimensionSet& dims
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return DimensionedField<Type, GeoMesh>::New_impl
|
||||||
|
(
|
||||||
|
regOpt,
|
||||||
|
name,
|
||||||
|
mesh,
|
||||||
|
value,
|
||||||
|
dims,
|
||||||
|
false // No checkIOFlags (is NO_READ anyhow)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -129,24 +233,35 @@ Foam::DimensionedField<Type, GeoMesh>::New
|
|||||||
const dimensionSet& dims
|
const dimensionSet& dims
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const bool caching = mesh.thisDb().cacheTemporaryObject(name);
|
return DimensionedField<Type, GeoMesh>::New_impl
|
||||||
|
|
||||||
return tmp<DimensionedField<Type, GeoMesh>>::NewImmovable
|
|
||||||
(
|
(
|
||||||
caching, // (true: immovable, false: movable)
|
IOobjectOption::LEGACY_REGISTER,
|
||||||
IOobject
|
name,
|
||||||
(
|
|
||||||
name,
|
|
||||||
mesh.thisDb().time().timeName(),
|
|
||||||
mesh.thisDb(),
|
|
||||||
IOobjectOption::NO_READ,
|
|
||||||
IOobjectOption::NO_WRITE,
|
|
||||||
caching // (true: REGISTER, false: NO_REGISTER)
|
|
||||||
),
|
|
||||||
mesh,
|
mesh,
|
||||||
value,
|
value,
|
||||||
dims,
|
dims,
|
||||||
false // checkIOFlags off
|
false // No checkIOFlags (is NO_READ anyhow)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, class GeoMesh>
|
||||||
|
Foam::tmp<Foam::DimensionedField<Type, GeoMesh>>
|
||||||
|
Foam::DimensionedField<Type, GeoMesh>::New
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
IOobjectOption::registerOption regOpt,
|
||||||
|
const Mesh& mesh,
|
||||||
|
const dimensioned<Type>& dt
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return DimensionedField<Type, GeoMesh>::New
|
||||||
|
(
|
||||||
|
name,
|
||||||
|
regOpt,
|
||||||
|
mesh,
|
||||||
|
dt.value(),
|
||||||
|
dt.dimensions()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -178,11 +293,8 @@ Foam::DimensionedField<Type, GeoMesh>::New
|
|||||||
const tmp<DimensionedField<Type, GeoMesh>>& tfld
|
const tmp<DimensionedField<Type, GeoMesh>>& tfld
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const bool caching = tfld().db().cacheTemporaryObject(name);
|
auto ptr = tmp<DimensionedField<Type, GeoMesh>>::New
|
||||||
|
|
||||||
return tmp<DimensionedField<Type, GeoMesh>>::NewImmovable
|
|
||||||
(
|
(
|
||||||
caching, // (true: immovable, false: movable)
|
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
@ -191,10 +303,20 @@ Foam::DimensionedField<Type, GeoMesh>::New
|
|||||||
tfld().db(),
|
tfld().db(),
|
||||||
IOobjectOption::NO_READ,
|
IOobjectOption::NO_READ,
|
||||||
IOobjectOption::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
caching // (true: REGISTER, false: NO_REGISTER)
|
IOobjectOption::NO_REGISTER
|
||||||
),
|
),
|
||||||
tfld
|
tfld
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
ptr->db().is_cacheTemporaryObject(ptr.get())
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ptr.protect(true);
|
||||||
|
ptr->checkIn();
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -208,11 +330,8 @@ Foam::DimensionedField<Type, GeoMesh>::New
|
|||||||
const dimensionSet& dims
|
const dimensionSet& dims
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const bool caching = fld.db().cacheTemporaryObject(name);
|
auto ptr = tmp<DimensionedField<Type, GeoMesh>>::New
|
||||||
|
|
||||||
return tmp<DimensionedField<Type, GeoMesh>>::NewImmovable
|
|
||||||
(
|
(
|
||||||
caching, // (true: immovable, false: movable)
|
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
@ -220,11 +339,21 @@ Foam::DimensionedField<Type, GeoMesh>::New
|
|||||||
fld.db(),
|
fld.db(),
|
||||||
IOobjectOption::NO_READ,
|
IOobjectOption::NO_READ,
|
||||||
IOobjectOption::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
caching // (true: REGISTER, false: NO_REGISTER)
|
IOobjectOption::NO_REGISTER
|
||||||
),
|
),
|
||||||
fld.mesh(),
|
fld.mesh(),
|
||||||
dims
|
dims
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
ptr->db().is_cacheTemporaryObject(ptr.get())
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ptr.protect(true);
|
||||||
|
ptr->checkIn();
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -238,11 +367,8 @@ Foam::DimensionedField<Type, GeoMesh>::New
|
|||||||
const dimensioned<Type>& dt
|
const dimensioned<Type>& dt
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const bool caching = fld.db().cacheTemporaryObject(name);
|
auto ptr = tmp<DimensionedField<Type, GeoMesh>>::New
|
||||||
|
|
||||||
return tmp<DimensionedField<Type, GeoMesh>>::NewImmovable
|
|
||||||
(
|
(
|
||||||
caching, // (true: immovable, false: movable)
|
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
@ -250,12 +376,22 @@ Foam::DimensionedField<Type, GeoMesh>::New
|
|||||||
fld.db(),
|
fld.db(),
|
||||||
IOobjectOption::NO_READ,
|
IOobjectOption::NO_READ,
|
||||||
IOobjectOption::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
caching // (true: REGISTER, false: NO_REGISTER)
|
IOobjectOption::NO_REGISTER
|
||||||
),
|
),
|
||||||
fld.mesh(),
|
fld.mesh(),
|
||||||
dt.value(),
|
dt.value(),
|
||||||
dt.dimensions()
|
dt.dimensions()
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
ptr->db().is_cacheTemporaryObject(ptr.get())
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ptr.protect(true);
|
||||||
|
ptr->checkIn();
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -899,6 +899,11 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::~GeometricField()
|
|||||||
|
|
||||||
deleteDemandDrivenData(field0Ptr_);
|
deleteDemandDrivenData(field0Ptr_);
|
||||||
deleteDemandDrivenData(fieldPrevIterPtr_);
|
deleteDemandDrivenData(fieldPrevIterPtr_);
|
||||||
|
|
||||||
|
// FUTURE: register cache field info
|
||||||
|
// // this->db().cacheTemporaryObject(*this);
|
||||||
|
|
||||||
|
clearOldTimes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -955,6 +960,14 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::boundaryFieldRef
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
|
Foam::label
|
||||||
|
Foam::GeometricField<Type, PatchField, GeoMesh>::nOldTimes() const noexcept
|
||||||
|
{
|
||||||
|
return (field0Ptr_ ? (field0Ptr_->nOldTimes() + 1) : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
void Foam::GeometricField<Type, PatchField, GeoMesh>::storeOldTimes() const
|
void Foam::GeometricField<Type, PatchField, GeoMesh>::storeOldTimes() const
|
||||||
{
|
{
|
||||||
@ -995,18 +1008,6 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::storeOldTime() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
|
||||||
Foam::label Foam::GeometricField<Type, PatchField, GeoMesh>::nOldTimes() const
|
|
||||||
{
|
|
||||||
if (field0Ptr_)
|
|
||||||
{
|
|
||||||
return field0Ptr_->nOldTimes() + 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
const Foam::GeometricField<Type, PatchField, GeoMesh>&
|
const Foam::GeometricField<Type, PatchField, GeoMesh>&
|
||||||
Foam::GeometricField<Type, PatchField, GeoMesh>::oldTime() const
|
Foam::GeometricField<Type, PatchField, GeoMesh>::oldTime() const
|
||||||
@ -1097,6 +1098,14 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::prevIter() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
|
void Foam::GeometricField<Type, PatchField, GeoMesh>::clearOldTimes()
|
||||||
|
{
|
||||||
|
deleteDemandDrivenData(field0Ptr_);
|
||||||
|
deleteDemandDrivenData(fieldPrevIterPtr_);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
void Foam::GeometricField<Type, PatchField, GeoMesh>::
|
void Foam::GeometricField<Type, PatchField, GeoMesh>::
|
||||||
correctBoundaryConditions()
|
correctBoundaryConditions()
|
||||||
|
|||||||
@ -134,6 +134,18 @@ private:
|
|||||||
//- Read the field - create the field dictionary on-the-fly
|
//- Read the field - create the field dictionary on-the-fly
|
||||||
void readFields();
|
void readFields();
|
||||||
|
|
||||||
|
//- Implementation for 'New' with specified registerObject preference.
|
||||||
|
// For LEGACY_REGISTER, registration is determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
|
template<class... Args>
|
||||||
|
static tmp<GeometricField<Type, PatchField, GeoMesh>> New_impl
|
||||||
|
(
|
||||||
|
IOobjectOption::registerOption regOpt,
|
||||||
|
const word& name,
|
||||||
|
const Mesh& mesh,
|
||||||
|
Args&&... args
|
||||||
|
);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
//- Runtime type information
|
//- Runtime type information
|
||||||
@ -405,9 +417,25 @@ public:
|
|||||||
|
|
||||||
// Factory Methods
|
// Factory Methods
|
||||||
|
|
||||||
//- Return tmp field from name, mesh, dimensions and patch type.
|
//- Return tmp field (NO_READ, NO_WRITE)
|
||||||
// The field is NO_READ, NO_WRITE, unregistered and uses the
|
//- from name, mesh, dimensions and patch type.
|
||||||
// current timeName from the mesh registry
|
//- [Takes current timeName from the mesh registry].
|
||||||
|
// For LEGACY_REGISTER, registration is determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
|
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
IOobjectOption::registerOption regOpt,
|
||||||
|
const Mesh& mesh,
|
||||||
|
const dimensionSet& dims,
|
||||||
|
const word& patchFieldType = PatchField<Type>::calculatedType()
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Return tmp field (NO_READ, NO_WRITE)
|
||||||
|
//- from name, mesh, dimensions and patch type.
|
||||||
|
//- [Takes current timeName from the mesh registry].
|
||||||
|
// Registration/persistence determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
@ -416,10 +444,26 @@ public:
|
|||||||
const word& patchFieldType = PatchField<Type>::calculatedType()
|
const word& patchFieldType = PatchField<Type>::calculatedType()
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Return tmp field from name, mesh, dimensions,
|
//- Return tmp field (NO_READ, NO_WRITE)
|
||||||
//- copy of internal field, with specified patch type.
|
//- from name, mesh, dimensions, copy of internal field and patch type.
|
||||||
// The field is NO_READ, NO_WRITE, unregistered and uses the
|
//- [Takes current timeName from the mesh registry].
|
||||||
// current timeName from the mesh registry
|
// For LEGACY_REGISTER, registration is determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
|
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
IOobjectOption::registerOption regOpt,
|
||||||
|
const Mesh& mesh,
|
||||||
|
const dimensionSet& dims,
|
||||||
|
const Field<Type>& iField,
|
||||||
|
const word& patchFieldType = PatchField<Type>::calculatedType()
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Return tmp field (NO_READ, NO_WRITE)
|
||||||
|
//- from name, mesh, dimensions, copy of internal field and patch type.
|
||||||
|
//- [Takes current timeName from the mesh registry].
|
||||||
|
// Registration/persistence determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
@ -429,10 +473,28 @@ public:
|
|||||||
const word& patchFieldType = PatchField<Type>::calculatedType()
|
const word& patchFieldType = PatchField<Type>::calculatedType()
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Return tmp field from name, mesh, dimensions,
|
//- Return tmp field (NO_READ, NO_WRITE)
|
||||||
//- moved internal field contents, with specified patch type.
|
//- from name, mesh, dimensions, moved internal field contents
|
||||||
// The field is NO_READ, NO_WRITE, unregistered and uses the
|
//- and patch type.
|
||||||
// current timeName from the mesh registry
|
//- [Takes current timeName from the mesh registry].
|
||||||
|
// For LEGACY_REGISTER, registration is determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
|
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
IOobjectOption::registerOption regOpt,
|
||||||
|
const Mesh& mesh,
|
||||||
|
const dimensionSet& dims,
|
||||||
|
Field<Type>&& iField,
|
||||||
|
const word& patchFieldType = PatchField<Type>::calculatedType()
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Return tmp field (NO_READ, NO_WRITE)
|
||||||
|
//- from name, mesh, dimensions, moved internal field contents
|
||||||
|
//- and patch type.
|
||||||
|
//- [Takes current timeName from the mesh registry].
|
||||||
|
// Registration/persistence determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
@ -442,10 +504,26 @@ public:
|
|||||||
const word& patchFieldType = PatchField<Type>::calculatedType()
|
const word& patchFieldType = PatchField<Type>::calculatedType()
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Return tmp field from name, mesh, dimensions, initial field value
|
//- Return tmp field (NO_READ, NO_WRITE)
|
||||||
//- and patch type.
|
//- from name, mesh, field value, dimensions and patch type.
|
||||||
// The field is NO_READ, NO_WRITE, unregistered and uses the
|
//- [Takes current timeName from the mesh registry].
|
||||||
// current timeName from the mesh registry
|
// For LEGACY_REGISTER, registration is determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
|
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
IOobjectOption::registerOption regOpt,
|
||||||
|
const Mesh& mesh,
|
||||||
|
const Type& value,
|
||||||
|
const dimensionSet& dims,
|
||||||
|
const word& patchFieldType = PatchField<Type>::calculatedType()
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Return tmp field (NO_READ, NO_WRITE)
|
||||||
|
//- from name, mesh, field value, dimensions and patch type.
|
||||||
|
//- [Takes current timeName from the mesh registry].
|
||||||
|
// Registration/persistence determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
@ -455,10 +533,27 @@ public:
|
|||||||
const word& patchFieldType = PatchField<Type>::calculatedType()
|
const word& patchFieldType = PatchField<Type>::calculatedType()
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Return tmp field from name, mesh, dimensioned\<Type\>
|
//- Return tmp field (NO_READ, NO_WRITE)
|
||||||
//- and patch types.
|
//- from name, mesh, field value, dimensions and patch field types.
|
||||||
// The field is NO_READ, NO_WRITE, unregistered and uses the
|
//- [Takes current timeName from the mesh registry].
|
||||||
// current timeName from the mesh registry
|
// For LEGACY_REGISTER, registration is determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
|
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
IOobjectOption::registerOption regOpt,
|
||||||
|
const Mesh& mesh,
|
||||||
|
const Type& value,
|
||||||
|
const dimensionSet& dims,
|
||||||
|
const wordList& patchFieldTypes,
|
||||||
|
const wordList& actualPatchTypes = wordList()
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Return tmp field (NO_READ, NO_WRITE)
|
||||||
|
//- from name, mesh, field value, dimensions and patch field types.
|
||||||
|
//- [Takes current timeName from the mesh registry].
|
||||||
|
// Registration/persistence determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
@ -469,10 +564,25 @@ public:
|
|||||||
const wordList& actualPatchTypes = wordList()
|
const wordList& actualPatchTypes = wordList()
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Return tmp field from name, mesh, dimensioned\<Type\>
|
//- Return tmp field (NO_READ, NO_WRITE)
|
||||||
//- and patch type.
|
//- from name, mesh, dimensioned-type and patch type.
|
||||||
// The field is NO_READ, NO_WRITE, unregistered and uses the
|
//- [Takes current timeName from the mesh registry].
|
||||||
// current timeName from the mesh registry
|
// For LEGACY_REGISTER, registration is determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
|
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
IOobjectOption::registerOption regOpt,
|
||||||
|
const Mesh& mesh,
|
||||||
|
const dimensioned<Type>& dt,
|
||||||
|
const word& patchFieldType = PatchField<Type>::calculatedType()
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Return tmp field (NO_READ, NO_WRITE)
|
||||||
|
//- from name, mesh, dimensioned-type and patch type.
|
||||||
|
//- [Takes current timeName from the mesh registry].
|
||||||
|
// Registration/persistence determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
@ -481,10 +591,26 @@ public:
|
|||||||
const word& patchFieldType = PatchField<Type>::calculatedType()
|
const word& patchFieldType = PatchField<Type>::calculatedType()
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Return tmp field from name, mesh, dimensioned\<Type\>
|
//- Return tmp field (NO_READ, NO_WRITE)
|
||||||
//- and patch types.
|
//- from name, mesh, dimensioned-type and patch field types.
|
||||||
// The field is NO_READ, NO_WRITE, unregistered and uses the
|
//- [Takes current timeName from the mesh registry].
|
||||||
// current timeName from the mesh registry
|
// For LEGACY_REGISTER, registration is determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
|
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
IOobjectOption::registerOption regOpt,
|
||||||
|
const Mesh& mesh,
|
||||||
|
const dimensioned<Type>& dt,
|
||||||
|
const wordList& patchFieldTypes,
|
||||||
|
const wordList& actualPatchTypes = wordList()
|
||||||
|
);
|
||||||
|
|
||||||
|
//- Return tmp field (NO_READ, NO_WRITE)
|
||||||
|
//- from name, mesh, dimensioned-type and patch field types.
|
||||||
|
//- [Takes current timeName from the mesh registry].
|
||||||
|
// Registration/persistence determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
@ -494,18 +620,21 @@ public:
|
|||||||
const wordList& actualPatchTypes = wordList()
|
const wordList& actualPatchTypes = wordList()
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Return renamed tmp field
|
//- Return renamed tmp field (NO_READ, NO_WRITE)
|
||||||
// The field is NO_READ, NO_WRITE, unregistered and uses the
|
//- [Takes current timeName from the mesh registry].
|
||||||
// current timeName from the mesh registry
|
// Registration/persistence determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
||||||
(
|
(
|
||||||
const word& newName,
|
const word& newName,
|
||||||
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf
|
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Rename tmp field and reset patch field type
|
//- Return renamed tmp field (NO_READ, NO_WRITE)
|
||||||
// The field is NO_READ, NO_WRITE, unregistered and uses the
|
//- with reset patch field type.
|
||||||
// current timeName from the mesh registry
|
//- [Takes current timeName from the mesh registry].
|
||||||
|
// Registration/persistence determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
||||||
(
|
(
|
||||||
const word& newName,
|
const word& newName,
|
||||||
@ -513,9 +642,11 @@ public:
|
|||||||
const word& patchFieldType
|
const word& patchFieldType
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Rename tmp field and reset patch field types and return
|
//- Return renamed tmp field (NO_READ, NO_WRITE)
|
||||||
// The field is NO_READ, NO_WRITE, unregistered and uses the
|
//- with reset patch field types.
|
||||||
// current timeName from the mesh registry
|
//- [Takes instance from the field].
|
||||||
|
// Registration/persistence determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
||||||
(
|
(
|
||||||
const word& newName,
|
const word& newName,
|
||||||
@ -524,10 +655,11 @@ public:
|
|||||||
const wordList& actualPatchTypes = wordList()
|
const wordList& actualPatchTypes = wordList()
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct tmp field based on mesh/registry information from
|
//- Construct tmp field (NO_READ, NO_WRITE)
|
||||||
//- an existing field.
|
//- based on mesh/registry information from an existing field.
|
||||||
// Created NO_READ, NO_WRITE, NO_REGISTER, using the instance
|
//- [Takes instance from the field].
|
||||||
// from the field
|
// Registration/persistence determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
template<class AnyType>
|
template<class AnyType>
|
||||||
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
||||||
(
|
(
|
||||||
@ -537,10 +669,12 @@ public:
|
|||||||
const word& patchFieldType = PatchField<Type>::calculatedType()
|
const word& patchFieldType = PatchField<Type>::calculatedType()
|
||||||
);
|
);
|
||||||
|
|
||||||
//- Construct tmp field based on mesh/registry information from
|
//- Construct tmp field (NO_READ, NO_WRITE)
|
||||||
//- an existing field and initialise with value.
|
//- based on mesh/registry information from an existing field.
|
||||||
// Created NO_READ, NO_WRITE, NO_REGISTER, using the instance
|
//- and initialise with value.
|
||||||
// from the field
|
//- [Takes instance from the field].
|
||||||
|
// Registration/persistence determined by
|
||||||
|
// objectRegistry::is_cacheTemporaryObject().
|
||||||
template<class AnyType>
|
template<class AnyType>
|
||||||
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
static tmp<GeometricField<Type, PatchField, GeoMesh>> New
|
||||||
(
|
(
|
||||||
@ -610,15 +744,15 @@ public:
|
|||||||
//- Write-access to the time index of the field
|
//- Write-access to the time index of the field
|
||||||
inline label& timeIndex() noexcept;
|
inline label& timeIndex() noexcept;
|
||||||
|
|
||||||
|
//- The number of old time fields stored
|
||||||
|
label nOldTimes() const noexcept;
|
||||||
|
|
||||||
//- Store the old-time fields
|
//- Store the old-time fields
|
||||||
void storeOldTimes() const;
|
void storeOldTimes() const;
|
||||||
|
|
||||||
//- Store the old-time field
|
//- Store the old-time field
|
||||||
void storeOldTime() const;
|
void storeOldTime() const;
|
||||||
|
|
||||||
//- Return the number of old time fields stored
|
|
||||||
label nOldTimes() const;
|
|
||||||
|
|
||||||
//- Return old time field
|
//- Return old time field
|
||||||
const GeometricField<Type, PatchField, GeoMesh>& oldTime() const;
|
const GeometricField<Type, PatchField, GeoMesh>& oldTime() const;
|
||||||
|
|
||||||
@ -632,6 +766,9 @@ public:
|
|||||||
//- Return previous iteration field
|
//- Return previous iteration field
|
||||||
const GeometricField<Type, PatchField, GeoMesh>& prevIter() const;
|
const GeometricField<Type, PatchField, GeoMesh>& prevIter() const;
|
||||||
|
|
||||||
|
//- Remove old-time and prev-iter fields
|
||||||
|
void clearOldTimes();
|
||||||
|
|
||||||
//- Correct boundary field
|
//- Correct boundary field
|
||||||
void correctBoundaryConditions();
|
void correctBoundaryConditions();
|
||||||
|
|
||||||
@ -648,9 +785,6 @@ public:
|
|||||||
const direction
|
const direction
|
||||||
) const;
|
) const;
|
||||||
|
|
||||||
//- WriteData member function required by regIOobject
|
|
||||||
bool writeData(Ostream&) const;
|
|
||||||
|
|
||||||
//- Return transpose (only if it is a tensor field)
|
//- Return transpose (only if it is a tensor field)
|
||||||
tmp<GeometricField<Type, PatchField, GeoMesh>> T() const;
|
tmp<GeometricField<Type, PatchField, GeoMesh>> T() const;
|
||||||
|
|
||||||
@ -774,6 +908,13 @@ public:
|
|||||||
bool operator!=(const dimensioned<Type>&) = delete;
|
bool operator!=(const dimensioned<Type>&) = delete;
|
||||||
|
|
||||||
|
|
||||||
|
// Write
|
||||||
|
|
||||||
|
//- The writeData function (required by regIOobject),
|
||||||
|
//- calls operator<<
|
||||||
|
bool writeData(Ostream& os) const;
|
||||||
|
|
||||||
|
|
||||||
// Ostream Operators
|
// Ostream Operators
|
||||||
|
|
||||||
friend Ostream& operator<< <Type, PatchField, GeoMesh>
|
friend Ostream& operator<< <Type, PatchField, GeoMesh>
|
||||||
|
|||||||
@ -26,8 +26,76 @@ License
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
|
template<class... Args>
|
||||||
|
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
|
||||||
|
Foam::GeometricField<Type, PatchField, GeoMesh>::New_impl
|
||||||
|
(
|
||||||
|
IOobjectOption::registerOption regOpt,
|
||||||
|
const word& name,
|
||||||
|
const Mesh& mesh,
|
||||||
|
Args&&... args
|
||||||
|
)
|
||||||
|
{
|
||||||
|
auto ptr = tmp<GeometricField<Type, PatchField, GeoMesh>>::New
|
||||||
|
(
|
||||||
|
IOobject
|
||||||
|
(
|
||||||
|
name,
|
||||||
|
mesh.thisDb().time().timeName(),
|
||||||
|
mesh.thisDb(),
|
||||||
|
IOobjectOption::NO_READ,
|
||||||
|
IOobjectOption::NO_WRITE,
|
||||||
|
IOobjectOption::NO_REGISTER
|
||||||
|
),
|
||||||
|
mesh,
|
||||||
|
std::forward<Args>(args)...
|
||||||
|
);
|
||||||
|
|
||||||
|
if (IOobjectOption::REGISTER == regOpt)
|
||||||
|
{
|
||||||
|
ptr->checkIn();
|
||||||
|
}
|
||||||
|
else if
|
||||||
|
(
|
||||||
|
// LEGACY_REGISTER: detect if caching is desired
|
||||||
|
(IOobjectOption::LEGACY_REGISTER == regOpt)
|
||||||
|
&& ptr->db().is_cacheTemporaryObject(ptr.get())
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ptr.protect(true);
|
||||||
|
ptr->checkIn();
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
|
||||||
|
|
||||||
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
|
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
|
||||||
|
Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
IOobjectOption::registerOption regOpt,
|
||||||
|
const Mesh& mesh,
|
||||||
|
const dimensionSet& dims,
|
||||||
|
const word& patchFieldType
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return GeometricField<Type, PatchField, GeoMesh>::New_impl
|
||||||
|
(
|
||||||
|
regOpt,
|
||||||
|
name,
|
||||||
|
mesh,
|
||||||
|
dims,
|
||||||
|
patchFieldType
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
|
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
|
||||||
Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
||||||
@ -38,20 +106,10 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
const word& patchFieldType
|
const word& patchFieldType
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const bool caching = mesh.thisDb().cacheTemporaryObject(name);
|
return GeometricField<Type, PatchField, GeoMesh>::New_impl
|
||||||
|
|
||||||
return tmp<GeometricField<Type, PatchField, GeoMesh>>::NewImmovable
|
|
||||||
(
|
(
|
||||||
caching, // (true: immovable, false: movable)
|
IOobjectOption::LEGACY_REGISTER,
|
||||||
IOobject
|
name,
|
||||||
(
|
|
||||||
name,
|
|
||||||
mesh.thisDb().time().timeName(),
|
|
||||||
mesh.thisDb(),
|
|
||||||
IOobjectOption::NO_READ,
|
|
||||||
IOobjectOption::NO_WRITE,
|
|
||||||
caching // (true: REGISTER, false: NO_REGISTER)
|
|
||||||
),
|
|
||||||
mesh,
|
mesh,
|
||||||
dims,
|
dims,
|
||||||
patchFieldType
|
patchFieldType
|
||||||
@ -59,6 +117,30 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
|
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
|
||||||
|
Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
IOobjectOption::registerOption regOpt,
|
||||||
|
const Mesh& mesh,
|
||||||
|
const dimensionSet& dims,
|
||||||
|
const Field<Type>& iField,
|
||||||
|
const word& patchFieldType
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return GeometricField<Type, PatchField, GeoMesh>::New_impl
|
||||||
|
(
|
||||||
|
regOpt,
|
||||||
|
name,
|
||||||
|
mesh,
|
||||||
|
dims,
|
||||||
|
iField,
|
||||||
|
patchFieldType
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
|
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
|
||||||
Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
||||||
@ -70,20 +152,10 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
const word& patchFieldType
|
const word& patchFieldType
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const bool caching = mesh.thisDb().cacheTemporaryObject(name);
|
return GeometricField<Type, PatchField, GeoMesh>::New_impl
|
||||||
|
|
||||||
return tmp<GeometricField<Type, PatchField, GeoMesh>>::NewImmovable
|
|
||||||
(
|
(
|
||||||
caching, // (true: immovable, false: movable)
|
IOobjectOption::LEGACY_REGISTER,
|
||||||
IOobject
|
name,
|
||||||
(
|
|
||||||
name,
|
|
||||||
mesh.thisDb().time().timeName(),
|
|
||||||
mesh.thisDb(),
|
|
||||||
IOobjectOption::NO_READ,
|
|
||||||
IOobjectOption::NO_WRITE,
|
|
||||||
caching // (true: REGISTER, false: NO_REGISTER)
|
|
||||||
),
|
|
||||||
mesh,
|
mesh,
|
||||||
dims,
|
dims,
|
||||||
iField,
|
iField,
|
||||||
@ -92,6 +164,30 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
|
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
|
||||||
|
Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
IOobjectOption::registerOption regOpt,
|
||||||
|
const Mesh& mesh,
|
||||||
|
const dimensionSet& dims,
|
||||||
|
Field<Type>&& iField,
|
||||||
|
const word& patchFieldType
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return GeometricField<Type, PatchField, GeoMesh>::New_impl
|
||||||
|
(
|
||||||
|
regOpt,
|
||||||
|
name,
|
||||||
|
mesh,
|
||||||
|
dims,
|
||||||
|
std::move(iField),
|
||||||
|
patchFieldType
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
|
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
|
||||||
Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
||||||
@ -103,20 +199,10 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
const word& patchFieldType
|
const word& patchFieldType
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const bool caching = mesh.thisDb().cacheTemporaryObject(name);
|
return GeometricField<Type, PatchField, GeoMesh>::New_impl
|
||||||
|
|
||||||
return tmp<GeometricField<Type, PatchField, GeoMesh>>::NewImmovable
|
|
||||||
(
|
(
|
||||||
caching, // (true: immovable, false: movable)
|
IOobjectOption::LEGACY_REGISTER,
|
||||||
IOobject
|
name,
|
||||||
(
|
|
||||||
name,
|
|
||||||
mesh.thisDb().time().timeName(),
|
|
||||||
mesh.thisDb(),
|
|
||||||
IOobjectOption::NO_READ,
|
|
||||||
IOobjectOption::NO_WRITE,
|
|
||||||
caching // (true: REGISTER, false: NO_REGISTER)
|
|
||||||
),
|
|
||||||
mesh,
|
mesh,
|
||||||
dims,
|
dims,
|
||||||
std::move(iField),
|
std::move(iField),
|
||||||
@ -130,26 +216,17 @@ Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
|
|||||||
Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
||||||
(
|
(
|
||||||
const word& name,
|
const word& name,
|
||||||
|
IOobjectOption::registerOption regOpt,
|
||||||
const Mesh& mesh,
|
const Mesh& mesh,
|
||||||
const Type& value,
|
const Type& value,
|
||||||
const dimensionSet& dims,
|
const dimensionSet& dims,
|
||||||
const word& patchFieldType
|
const word& patchFieldType
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const bool caching = mesh.thisDb().cacheTemporaryObject(name);
|
return GeometricField<Type, PatchField, GeoMesh>::New_impl
|
||||||
|
|
||||||
return tmp<GeometricField<Type, PatchField, GeoMesh>>::NewImmovable
|
|
||||||
(
|
(
|
||||||
caching, // (true: immovable, false: movable)
|
regOpt,
|
||||||
IOobject
|
name,
|
||||||
(
|
|
||||||
name,
|
|
||||||
mesh.thisDb().time().timeName(),
|
|
||||||
mesh.thisDb(),
|
|
||||||
IOobjectOption::NO_READ,
|
|
||||||
IOobjectOption::NO_WRITE,
|
|
||||||
caching // (true: REGISTER, false: NO_REGISTER)
|
|
||||||
),
|
|
||||||
mesh,
|
mesh,
|
||||||
value,
|
value,
|
||||||
dims,
|
dims,
|
||||||
@ -166,24 +243,38 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
const Mesh& mesh,
|
const Mesh& mesh,
|
||||||
const Type& value,
|
const Type& value,
|
||||||
const dimensionSet& dims,
|
const dimensionSet& dims,
|
||||||
|
const word& patchFieldType
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return GeometricField<Type, PatchField, GeoMesh>::New_impl
|
||||||
|
(
|
||||||
|
IOobjectOption::LEGACY_REGISTER,
|
||||||
|
name,
|
||||||
|
mesh,
|
||||||
|
value,
|
||||||
|
dims,
|
||||||
|
patchFieldType
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
|
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
|
||||||
|
Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
IOobjectOption::registerOption regOpt,
|
||||||
|
const Mesh& mesh,
|
||||||
|
const Type& value,
|
||||||
|
const dimensionSet& dims,
|
||||||
const wordList& patchFieldTypes,
|
const wordList& patchFieldTypes,
|
||||||
const wordList& actualPatchTypes
|
const wordList& actualPatchTypes
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const bool caching = mesh.thisDb().cacheTemporaryObject(name);
|
return GeometricField<Type, PatchField, GeoMesh>::New_impl
|
||||||
|
|
||||||
return tmp<GeometricField<Type, PatchField, GeoMesh>>::NewImmovable
|
|
||||||
(
|
(
|
||||||
caching, // (true: immovable, false: movable)
|
regOpt,
|
||||||
IOobject
|
name,
|
||||||
(
|
|
||||||
name,
|
|
||||||
mesh.thisDb().time().timeName(),
|
|
||||||
mesh.thisDb(),
|
|
||||||
IOobjectOption::NO_READ,
|
|
||||||
IOobjectOption::NO_WRITE,
|
|
||||||
caching // (true: REGISTER, false: NO_REGISTER)
|
|
||||||
),
|
|
||||||
mesh,
|
mesh,
|
||||||
value,
|
value,
|
||||||
dims,
|
dims,
|
||||||
@ -193,6 +284,54 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
|
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
|
||||||
|
Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
const Mesh& mesh,
|
||||||
|
const Type& value,
|
||||||
|
const dimensionSet& dims,
|
||||||
|
const wordList& patchFieldTypes,
|
||||||
|
const wordList& actualPatchTypes
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return GeometricField<Type, PatchField, GeoMesh>::New_impl
|
||||||
|
(
|
||||||
|
IOobjectOption::LEGACY_REGISTER,
|
||||||
|
name,
|
||||||
|
mesh,
|
||||||
|
value,
|
||||||
|
dims,
|
||||||
|
patchFieldTypes,
|
||||||
|
actualPatchTypes
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
|
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
|
||||||
|
Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
IOobjectOption::registerOption regOpt,
|
||||||
|
const Mesh& mesh,
|
||||||
|
const dimensioned<Type>& dt,
|
||||||
|
const word& patchFieldType
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return GeometricField<Type, PatchField, GeoMesh>::New
|
||||||
|
(
|
||||||
|
name,
|
||||||
|
regOpt,
|
||||||
|
mesh,
|
||||||
|
dt.value(),
|
||||||
|
dt.dimensions(),
|
||||||
|
patchFieldType
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
|
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
|
||||||
Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
||||||
@ -214,6 +353,31 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
|
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
|
||||||
|
Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
||||||
|
(
|
||||||
|
const word& name,
|
||||||
|
IOobjectOption::registerOption regOpt,
|
||||||
|
const Mesh& mesh,
|
||||||
|
const dimensioned<Type>& dt,
|
||||||
|
const wordList& patchFieldTypes,
|
||||||
|
const wordList& actualPatchTypes
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return GeometricField<Type, PatchField, GeoMesh>::New
|
||||||
|
(
|
||||||
|
name,
|
||||||
|
regOpt,
|
||||||
|
mesh,
|
||||||
|
dt.value(),
|
||||||
|
dt.dimensions(),
|
||||||
|
patchFieldTypes,
|
||||||
|
actualPatchTypes
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class Type, template<class> class PatchField, class GeoMesh>
|
template<class Type, template<class> class PatchField, class GeoMesh>
|
||||||
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
|
Foam::tmp<Foam::GeometricField<Type, PatchField, GeoMesh>>
|
||||||
Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
||||||
@ -246,11 +410,8 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
const word& patchFieldType
|
const word& patchFieldType
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const bool caching = tgf().db().cacheTemporaryObject(name);
|
auto ptr = tmp<GeometricField<Type, PatchField, GeoMesh>>::New
|
||||||
|
|
||||||
return tmp<GeometricField<Type, PatchField, GeoMesh>>::NewImmovable
|
|
||||||
(
|
(
|
||||||
caching, // (true: immovable, false: movable)
|
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
@ -259,11 +420,21 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
tgf().db(),
|
tgf().db(),
|
||||||
IOobjectOption::NO_READ,
|
IOobjectOption::NO_READ,
|
||||||
IOobjectOption::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
caching // (true: REGISTER, false: NO_REGISTER)
|
IOobjectOption::NO_REGISTER
|
||||||
),
|
),
|
||||||
tgf,
|
tgf,
|
||||||
patchFieldType
|
patchFieldType
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
ptr->db().is_cacheTemporaryObject(ptr.get())
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ptr.protect(true);
|
||||||
|
ptr->checkIn();
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -275,11 +446,8 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf
|
const tmp<GeometricField<Type, PatchField, GeoMesh>>& tgf
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const bool caching = tgf().db().cacheTemporaryObject(name);
|
auto ptr = tmp<GeometricField<Type, PatchField, GeoMesh>>::New
|
||||||
|
|
||||||
return tmp<GeometricField<Type, PatchField, GeoMesh>>::NewImmovable
|
|
||||||
(
|
(
|
||||||
caching, // (true: immovable, false: movable)
|
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
@ -288,10 +456,20 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
tgf().db(),
|
tgf().db(),
|
||||||
IOobjectOption::NO_READ,
|
IOobjectOption::NO_READ,
|
||||||
IOobjectOption::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
caching // (true: REGISTER, false: NO_REGISTER)
|
IOobjectOption::NO_REGISTER
|
||||||
),
|
),
|
||||||
tgf
|
tgf
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
ptr->db().is_cacheTemporaryObject(ptr.get())
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ptr.protect(true);
|
||||||
|
ptr->checkIn();
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -305,11 +483,8 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
const wordList& actualPatchTypes
|
const wordList& actualPatchTypes
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const bool caching = tgf().db().cacheTemporaryObject(name);
|
auto ptr = tmp<GeometricField<Type, PatchField, GeoMesh>>::New
|
||||||
|
|
||||||
return tmp<GeometricField<Type, PatchField, GeoMesh>>::NewImmovable
|
|
||||||
(
|
(
|
||||||
caching, // (true: immovable, false: movable)
|
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
@ -318,12 +493,22 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
tgf().db(),
|
tgf().db(),
|
||||||
IOobjectOption::NO_READ,
|
IOobjectOption::NO_READ,
|
||||||
IOobjectOption::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
caching // (true: REGISTER, false: NO_REGISTER)
|
IOobjectOption::NO_REGISTER
|
||||||
),
|
),
|
||||||
tgf,
|
tgf,
|
||||||
patchFieldTypes,
|
patchFieldTypes,
|
||||||
actualPatchTypes
|
actualPatchTypes
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
ptr->db().is_cacheTemporaryObject(ptr.get())
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ptr.protect(true);
|
||||||
|
ptr->checkIn();
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -338,11 +523,8 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
const word& patchFieldType
|
const word& patchFieldType
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const bool caching = fld.db().cacheTemporaryObject(name);
|
auto ptr = tmp<GeometricField<Type, PatchField, GeoMesh>>::New
|
||||||
|
|
||||||
return tmp<GeometricField<Type, PatchField, GeoMesh>>::NewImmovable
|
|
||||||
(
|
(
|
||||||
caching, // (true: immovable, false: movable)
|
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
@ -350,12 +532,22 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
fld.db(),
|
fld.db(),
|
||||||
IOobjectOption::NO_READ,
|
IOobjectOption::NO_READ,
|
||||||
IOobjectOption::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
caching // (true: REGISTER, false: NO_REGISTER)
|
IOobjectOption::NO_REGISTER
|
||||||
),
|
),
|
||||||
fld.mesh(),
|
fld.mesh(),
|
||||||
dims,
|
dims,
|
||||||
patchFieldType
|
patchFieldType
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
ptr->db().is_cacheTemporaryObject(ptr.get())
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ptr.protect(true);
|
||||||
|
ptr->checkIn();
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -370,11 +562,8 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
const word& patchFieldType
|
const word& patchFieldType
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
const bool caching = fld.db().cacheTemporaryObject(name);
|
auto ptr = tmp<GeometricField<Type, PatchField, GeoMesh>>::New
|
||||||
|
|
||||||
return tmp<GeometricField<Type, PatchField, GeoMesh>>::NewImmovable
|
|
||||||
(
|
(
|
||||||
caching, // (true: immovable, false: movable)
|
|
||||||
IOobject
|
IOobject
|
||||||
(
|
(
|
||||||
name,
|
name,
|
||||||
@ -382,13 +571,23 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::New
|
|||||||
fld.db(),
|
fld.db(),
|
||||||
IOobjectOption::NO_READ,
|
IOobjectOption::NO_READ,
|
||||||
IOobjectOption::NO_WRITE,
|
IOobjectOption::NO_WRITE,
|
||||||
caching // (true: REGISTER, false: NO_REGISTER)
|
IOobjectOption::NO_REGISTER
|
||||||
),
|
),
|
||||||
fld.mesh(),
|
fld.mesh(),
|
||||||
dt.value(),
|
dt.value(),
|
||||||
dt.dimensions(),
|
dt.dimensions(),
|
||||||
patchFieldType
|
patchFieldType
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if
|
||||||
|
(
|
||||||
|
ptr->db().is_cacheTemporaryObject(ptr.get())
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ptr.protect(true);
|
||||||
|
ptr->checkIn();
|
||||||
|
}
|
||||||
|
return ptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -120,10 +120,6 @@ public:
|
|||||||
//- Construct, taking ownership of the pointer.
|
//- Construct, taking ownership of the pointer.
|
||||||
inline explicit tmp(T* p);
|
inline explicit tmp(T* p);
|
||||||
|
|
||||||
//- Construct, taking ownership of the pointer,
|
|
||||||
//- with specified protection against moving.
|
|
||||||
inline tmp(bool immovable, T* p);
|
|
||||||
|
|
||||||
//- Implicit construct for a const reference to an object.
|
//- Implicit construct for a const reference to an object.
|
||||||
inline constexpr tmp(const T& obj) noexcept;
|
inline constexpr tmp(const T& obj) noexcept;
|
||||||
|
|
||||||
@ -173,19 +169,6 @@ public:
|
|||||||
return tmp<T>(new T(std::forward<Args>(args)...));
|
return tmp<T>(new T(std::forward<Args>(args)...));
|
||||||
}
|
}
|
||||||
|
|
||||||
//- Construct movable/immovable tmp with forwarding arguments
|
|
||||||
// \param immovable create as non-movable pointer
|
|
||||||
// \param args list of arguments with which an instance of T
|
|
||||||
// will be constructed.
|
|
||||||
//
|
|
||||||
// \note Similar to std::make_shared, but the overload for
|
|
||||||
// array types is not disabled.
|
|
||||||
template<class... Args>
|
|
||||||
static tmp<T> NewImmovable(bool immovable, Args&&... args)
|
|
||||||
{
|
|
||||||
return tmp<T>(immovable, new T(std::forward<Args>(args)...));
|
|
||||||
}
|
|
||||||
|
|
||||||
//- Construct tmp from derived type with forwarding arguments
|
//- Construct tmp from derived type with forwarding arguments
|
||||||
// \param args list of arguments with which an instance of U
|
// \param args list of arguments with which an instance of U
|
||||||
// will be constructed.
|
// will be constructed.
|
||||||
@ -256,16 +239,16 @@ public:
|
|||||||
//- delete object and set pointer to nullptr
|
//- delete object and set pointer to nullptr
|
||||||
inline void clear() const noexcept;
|
inline void clear() const noexcept;
|
||||||
|
|
||||||
|
//- Use specified protection against moving for the managed pointer.
|
||||||
|
//- No-op for references.
|
||||||
|
inline void protect(bool on) noexcept;
|
||||||
|
|
||||||
//- Clear existing and transfer ownership.
|
//- Clear existing and transfer ownership.
|
||||||
inline void reset(tmp<T>&& other) noexcept;
|
inline void reset(tmp<T>&& other) noexcept;
|
||||||
|
|
||||||
//- Delete managed temporary object and set to new given pointer.
|
//- Delete managed temporary object and set to new given pointer.
|
||||||
inline void reset(T* p = nullptr) noexcept;
|
inline void reset(T* p = nullptr) noexcept;
|
||||||
|
|
||||||
//- Delete managed temporary object and set to new given pointer,
|
|
||||||
//- with specified protection against moving.
|
|
||||||
inline void reset(bool immovable, T* p) noexcept;
|
|
||||||
|
|
||||||
//- Avoid inadvertent casting (to object or pointer)
|
//- Avoid inadvertent casting (to object or pointer)
|
||||||
void reset(const autoPtr<T>&) = delete;
|
void reset(const autoPtr<T>&) = delete;
|
||||||
|
|
||||||
|
|||||||
@ -90,15 +90,6 @@ inline Foam::tmp<T>::tmp(T* p)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline Foam::tmp<T>::tmp(bool immovable, T* p)
|
|
||||||
:
|
|
||||||
tmp<T>(p)
|
|
||||||
{
|
|
||||||
if (ptr_ && immovable) type_ = CACHE_PTR;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline constexpr Foam::tmp<T>::tmp(const T& obj) noexcept
|
inline constexpr Foam::tmp<T>::tmp(const T& obj) noexcept
|
||||||
:
|
:
|
||||||
@ -319,6 +310,28 @@ inline void Foam::tmp<T>::clear() const noexcept
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class T>
|
||||||
|
inline void Foam::tmp<T>::protect(bool on) noexcept
|
||||||
|
{
|
||||||
|
if (on)
|
||||||
|
{
|
||||||
|
// ON: from PTR -> CACHE_PTR, but not nullptr
|
||||||
|
if (ptr_ && type_ == PTR)
|
||||||
|
{
|
||||||
|
type_ = CACHE_PTR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// OFF: from CACHE_PTR -> PTR
|
||||||
|
if (type_ == CACHE_PTR)
|
||||||
|
{
|
||||||
|
type_ = PTR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline void Foam::tmp<T>::reset(T* p) noexcept
|
inline void Foam::tmp<T>::reset(T* p) noexcept
|
||||||
{
|
{
|
||||||
@ -328,14 +341,6 @@ inline void Foam::tmp<T>::reset(T* p) noexcept
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
|
||||||
inline void Foam::tmp<T>::reset(bool immovable, T* p) noexcept
|
|
||||||
{
|
|
||||||
reset(p);
|
|
||||||
if (ptr_ && immovable) type_ = CACHE_PTR;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
template<class T>
|
template<class T>
|
||||||
inline void Foam::tmp<T>::reset(tmp<T>&& other) noexcept
|
inline void Foam::tmp<T>::reset(tmp<T>&& other) noexcept
|
||||||
{
|
{
|
||||||
|
|||||||
@ -222,13 +222,14 @@ bool Foam::functionObjects::writeObjects::write()
|
|||||||
// TBD:
|
// TBD:
|
||||||
// If the object is a temporary field expression wrap with tmp<...>
|
// If the object is a temporary field expression wrap with tmp<...>
|
||||||
|
|
||||||
// if (obj.db().cacheTemporaryObject(objName))
|
// if (obj.db().is_cacheTemporaryObject(obj))
|
||||||
// {
|
// {
|
||||||
// obj.IOobject::rename("tmp<" + objName + ">");
|
// const word oldName(obj.name());
|
||||||
|
// obj.IOobject::rename("tmp<" + oldName + ">");
|
||||||
//
|
//
|
||||||
// Log << " writing object " << obj.name() << endl;
|
// Log << " writing object " << obj.name() << endl;
|
||||||
// obj.write();
|
// obj.write();
|
||||||
// obj.IOobject::rename(objName);
|
// obj.IOobject::rename(oldName);
|
||||||
// }
|
// }
|
||||||
// else
|
// else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -89,7 +89,7 @@ void Foam::heThermo<BasicThermo, MixtureType>::init
|
|||||||
this->heBoundaryCorrection(he);
|
this->heBoundaryCorrection(he);
|
||||||
|
|
||||||
// Note: T does not have oldTime
|
// Note: T does not have oldTime
|
||||||
if (p.nOldTimes() > 0)
|
if (p.nOldTimes())
|
||||||
{
|
{
|
||||||
init(p.oldTime(), T.oldTime(), he.oldTime());
|
init(p.oldTime(), T.oldTime(), he.oldTime());
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user