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