ENH: propellerInfo - updated to work in postProcess mode. Fixes #2588

This commit is contained in:
Andrew Heather 2024-06-07 12:36:24 +01:00
parent 440cb83fa7
commit 1bce1e44c4
2 changed files with 26 additions and 8 deletions

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021-2022 OpenCFD Ltd.
Copyright (C) 2021-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -808,6 +808,7 @@ Foam::functionObjects::propellerInfo::propellerInfo
)
:
forces(name, runTime, dict, false),
dict_(dict),
radius_(0),
URefPtr_(nullptr),
rotationMode_(rotationMode::SPECIFIED),
@ -827,7 +828,8 @@ Foam::functionObjects::propellerInfo::propellerInfo
interpolationScheme_("cell"),
wakeFilePtr_(nullptr),
axialWakeFilePtr_(nullptr),
nanValue_(pTraits<scalar>::min)
nanValue_(pTraits<scalar>::min),
initialised_(false)
{
if (readFields)
{
@ -855,21 +857,18 @@ bool Foam::functionObjects::propellerInfo::read(const dictionary& dict)
{
if (forces::read(dict))
{
dict_ = dict;
radius_ = dict.getScalar("radius");
URefPtr_.reset(Function1<scalar>::New("URef", dict, &mesh_));
rotationMode_ = rotationModeNames_.get("rotationMode", dict);
// Must be set before setting the surface
setCoordinateSystem(dict);
writePropellerPerformance_ =
dict.get<bool>("writePropellerPerformance");
writeWakeFields_ = dict.get<bool>("writeWakeFields");
if (writeWakeFields_)
{
setSampleDiskSurface(dict);
dict.readIfPresent("interpolationScheme", interpolationScheme_);
dict.readIfPresent("nanValue", nanValue_);
@ -884,6 +883,19 @@ bool Foam::functionObjects::propellerInfo::read(const dictionary& dict)
bool Foam::functionObjects::propellerInfo::execute()
{
if (!initialised_)
{
// Must be set before setting the surface
setCoordinateSystem(dict_);
if (writeWakeFields_)
{
setSampleDiskSurface(dict_);
}
initialised_ = true;
}
calcForcesMoments();
createFiles();

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2021 OpenCFD Ltd.
Copyright (C) 2021-2024 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -205,6 +205,9 @@ protected:
// Protected data
//- Copy of dictionary used during construction
dictionary dict_;
//- Propeller radius
scalar radius_;
@ -271,6 +274,9 @@ protected:
//- scalar::min
scalar nanValue_;
//- Initialised flag
bool initialised_;
// Protected Member Functions