mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: readFields function object - read fields on construction
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -54,6 +54,9 @@ Foam::readFields::readFields
|
||||
if (isA<fvMesh>(obr_))
|
||||
{
|
||||
read(dict);
|
||||
|
||||
// Fields should all be present from start time so read on construction
|
||||
execute();
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -87,16 +90,28 @@ void Foam::readFields::execute()
|
||||
{
|
||||
if (active_)
|
||||
{
|
||||
if (log_) Info << type() << " " << name_ << ":" << nl;
|
||||
|
||||
bool loaded = false;
|
||||
forAll(fieldSet_, fieldI)
|
||||
{
|
||||
const word& fieldName = fieldSet_[fieldI];
|
||||
|
||||
// If necessary load field
|
||||
loadField<scalar>(fieldName);
|
||||
loadField<vector>(fieldName);
|
||||
loadField<sphericalTensor>(fieldName);
|
||||
loadField<symmTensor>(fieldName);
|
||||
loadField<tensor>(fieldName);
|
||||
// Load field if necessary
|
||||
loaded = loadField<scalar>(fieldName) || loaded;
|
||||
loaded = loadField<vector>(fieldName) || loaded;
|
||||
loaded = loadField<sphericalTensor>(fieldName) || loaded;
|
||||
loaded = loadField<symmTensor>(fieldName) || loaded;
|
||||
loaded = loadField<tensor>(fieldName) || loaded;
|
||||
}
|
||||
|
||||
if (log_)
|
||||
{
|
||||
if (!loaded)
|
||||
{
|
||||
Info<< " no fields loaded" << endl;
|
||||
}
|
||||
Info<< endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
|
||||
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -106,7 +106,7 @@ protected:
|
||||
// Protected Member Functions
|
||||
|
||||
template<class Type>
|
||||
void loadField(const word&) const;
|
||||
bool loadField(const word&) const;
|
||||
|
||||
|
||||
private:
|
||||
|
||||
@ -31,7 +31,7 @@ License
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
void Foam::readFields::loadField(const word& fieldName) const
|
||||
bool Foam::readFields::loadField(const word& fieldName) const
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> vfType;
|
||||
typedef GeometricField<Type, fvsPatchField, surfaceMesh> sfType;
|
||||
@ -77,6 +77,7 @@ void Foam::readFields::loadField(const word& fieldName) const
|
||||
if (log_) Info<< " Reading " << fieldName << endl;
|
||||
vfType* vfPtr = new vfType(fieldHeader, mesh);
|
||||
mesh.objectRegistry::store(vfPtr);
|
||||
return true;
|
||||
}
|
||||
else if
|
||||
(
|
||||
@ -88,8 +89,11 @@ void Foam::readFields::loadField(const word& fieldName) const
|
||||
if (log_) Info<< " Reading " << fieldName << endl;
|
||||
sfType* sfPtr = new sfType(fieldHeader, mesh);
|
||||
mesh.objectRegistry::store(sfPtr);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user