From 59f17355cfd948d7e4c7a1b1b75e6bc44d37e2df Mon Sep 17 00:00:00 2001 From: Henry Weller <http://cfd.direct> Date: Fri, 3 Jul 2015 12:41:25 +0100 Subject: [PATCH] rotorDiskSource: Debugged the duplicated interpolation functions Needs rewriting to avoid unnecessary code duplication, preferably using standard OpenFOAM interpolation functionality. --- .../rotorDiskSource/bladeModel/bladeModel.C | 14 +++++++++----- .../profileModel/lookup/lookupProfile.C | 12 +++++++++--- .../simpleFoam/rotorDisk/system/fvOptions | 4 ++-- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/src/fvOptions/sources/derived/rotorDiskSource/bladeModel/bladeModel.C b/src/fvOptions/sources/derived/rotorDiskSource/bladeModel/bladeModel.C index 490e8f49511..0f8978c4eea 100644 --- a/src/fvOptions/sources/derived/rotorDiskSource/bladeModel/bladeModel.C +++ b/src/fvOptions/sources/derived/rotorDiskSource/bladeModel/bladeModel.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -29,7 +29,6 @@ License #include "vector.H" #include "IFstream.H" - // * * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * // bool Foam::bladeModel::readFromFile() const @@ -58,12 +57,18 @@ void Foam::bladeModel::interpolateWeights } else { - while ((values[i2] < xIn) && (i2 < nElem)) + while ((i2 < nElem) && (values[i2] < xIn)) { i2++; } - if (i2 == nElem) + if (i2 == 0) + { + i1 = i2; + ddx = 0.0; + return; + } + else if (i2 == nElem) { i2 = nElem - 1; i1 = i2; @@ -101,7 +106,6 @@ Foam::bladeModel::bladeModel(const dictionary& dict) dict.lookup("data") >> data; } - if (data.size() > 0) { profileName_.setSize(data.size()); diff --git a/src/fvOptions/sources/derived/rotorDiskSource/profileModel/lookup/lookupProfile.C b/src/fvOptions/sources/derived/rotorDiskSource/profileModel/lookup/lookupProfile.C index 1719768a0b5..f07821c27bc 100644 --- a/src/fvOptions/sources/derived/rotorDiskSource/profileModel/lookup/lookupProfile.C +++ b/src/fvOptions/sources/derived/rotorDiskSource/profileModel/lookup/lookupProfile.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -60,12 +60,18 @@ void Foam::lookupProfile::interpolateWeights } else { - while ((values[i2] < xIn) && (i2 < nElem)) + while ((i2 < nElem) && (values[i2] < xIn)) { i2++; } - if (i2 == nElem) + if (i2 == 0) + { + i1 = i2; + ddx = 0.0; + return; + } + else if (i2 == nElem) { i2 = nElem - 1; i1 = i2; diff --git a/tutorials/incompressible/simpleFoam/rotorDisk/system/fvOptions b/tutorials/incompressible/simpleFoam/rotorDisk/system/fvOptions index 5ad69108ea6..75f6c6c1c95 100644 --- a/tutorials/incompressible/simpleFoam/rotorDisk/system/fvOptions +++ b/tutorials/incompressible/simpleFoam/rotorDisk/system/fvOptions @@ -64,8 +64,8 @@ disk { data ( - (profile1 (0.1 -6 0.1)) - (profile1 (0.25 -6 0.1)) + (profile1 (0.1 -6 0.02)) + (profile1 (0.25 -6 0.02)) ); } -- GitLab