CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Bugs (https://www.cfd-online.com/Forums/openfoam-bugs/)
-   -   Possible bug in OpenFoam Interpolation class (https://www.cfd-online.com/Forums/openfoam-bugs/130858-possible-bug-openfoam-interpolation-class.html)

MMC15 March 5, 2014 06:35

Possible bug in OpenFoam Interpolation class
 
Hello everybody,

I'm currrently using the class interpolationCellPoint, but I experienced a strange behaviour in its usage.

I'm using this class in two different ways:
- the first, I declare an object Uinter of class interpolationCellPoint in the header file of my custom class:
Code:

#include "interpolationCellPoint.H" // need by Uinter
namespace Foam {
class myClass {
public:
...some objects...
interpolationCellPoint<vector> Uinter;
vector velInterp(point &iVelPoint,label &iVelCell);
private:
...
  }
}

and I define it in constructor:
Code:

#include "myClass.h"
namespace Foam {
defineTypeNameAndDebug(myClass, 1);
// Default Constructor
myClass::myClass(const volVectorField& U):
    ...some definitions...
    // Set the pointer to the velocity field
    U_(U),
    // Uinter construction
    Uinter(U),
...other definitions...
{}
}

where const volVectorField& U comes from my custom solver based on simpleFoam. Then in velInterp I call the interpolate member function of Uinter:
Code:

#include "myClass.h"
namespace Foam {
vector myClass::velInterp(point &iVelPoint,label &iVelCell)
    {
V=Uinter.interpolate(iVelPoint, iVelCell);
return(V);
}
}

That works correctly and gives me a vector output as expected.

- the second, I declare and define the variable Uinter of class intersectioCellPoint directly inside the velInterp function, so it is no more a myClass public member, but it borns and dies directly inside the function:
Code:

#include "myClass.h"
namespace Foam {
vector myClass::velInterp(point &iVelPoint,label &iVelCell)
    {
interpolationCellPoint<vector> Uinter(U_);
V=Uinter.interpolate(iVelPoint, iVelCell);
return(V);
}
}

I obviously expect that these two methods are equivalent, but I noticed that the vectors V are different.

I can't figure out the reason for this discrepancy in the results.
Is it my fault or have I found a bug?

MMC15 March 6, 2014 05:08

I forgot to mention that I'm using openfoam 2.2.2.

wyldckat March 23, 2014 12:55

Greetings Matteo,

Without a complete test case (case + application source code) for easily+quickly testing this, it's very hard for anyone to be able to answer to your question(s), without taking several hours to set-up an identical code structure and test case.

Best regards,
Bruno


All times are GMT -4. The time now is 00:00.