CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   OpenFOAM Programming & Development (https://www.cfd-online.com/Forums/openfoam-programming-development/)
-   -   WENO Schemes for OpenFOAM v5 (https://www.cfd-online.com/Forums/openfoam-programming-development/219206-weno-schemes-openfoam-v5.html)

ndtrong July 19, 2019 05:37

WENO Schemes for OpenFOAM v5
 
1 Attachment(s)
Hi everyone,

I am trying to apply WENO scheme that is build based on OpenFOAM v2.3 to OpenFOAM v5.
https://github.com/TobiasMartin/WENO...bWENOEXT-2.3.x
However, when i compile the new library I got error as shown in the attached figure.

It would be appreciate if could someone help me to fix this error.

Thanks and Best regards

mAlletto July 20, 2019 07:52

The definition of the factorial function changed from of 2.3 to 5. In 2.3 it takes a scalar as argument and returns a scalar. In 5 it takes a label (int) as argument and returns a label. So you have to change the function calls in the weno schemes accordingly.

Zeppo July 20, 2019 14:50

Your library runs this code:
Code:

Foam::scalar Foam::geometryWENO::Fac(scalar x)
{
        if (x <= 0) return 1.0;       
        else
        {       
                return Foam::factorial(x);
        }
}

It is
Code:

Foam::factorial(x)
that fails to compile.
There are 2 versions of overloaded function factorial in OpenFOAM, with function parameters being uLabel and label:
Code:

  54 Foam::uLabel Foam::factorial(uLabel n)
  55 {
  56    static uLabel factTable[13] =
  57    {
  58        1, 1, 2, 6, 24, 120, 720, 5040, 40320,
  59        362880, 3628800, 39916800, 479001600
  60    };
  61
  62    #ifdef FULLDEBUG
  63    if (n > 12)
  64    {
  65        FatalErrorInFunction
  66            << "n value out of range (> 12)"
  67            << abort(FatalError);
  68    }
  69    #endif
  70
  71    return factTable[n];

Code:

  63 Foam::label Foam::factorial(label n)
  64 {
  65    static label factTable[13] =
  66    {
  67        1, 1, 2, 6, 24, 120, 720, 5040, 40320,
  68        362880, 3628800, 39916800, 479001600
  69    };
  70
  71    #ifdef FULLDEBUG
  72    if (n > 12 && n < 0)
  73    {
  74        FatalErrorInFunction
  75            << "n value out of range"
  76            << abort(FatalError);
  77    }
  78    #endif
  79
  80    return factTable[n];
  81 }

Try this to see if it works
Code:

return Foam::factorial(static_cast<uLabel>(x));

tiam July 20, 2019 15:20

Quote:

Originally Posted by ndtrong (Post 739403)
Hi everyone,

I am trying to apply WENO scheme that is build based on OpenFOAM v2.3 to OpenFOAM v5.
https://github.com/TobiasMartin/WENO...bWENOEXT-2.3.x
However, when i compile the new library I got error as shown in the attached figure.

It would be appreciate if could someone help me to fix this error.

Thanks and Best regards


I've been in contact with Tobias, the author of the library, and offered to upgrade the library so that it compiles across most version of OF and he agreed. I will get this done in the next month. That being said, I quickly patched the library to get it compiled on OFv1806, check the fork by timofeymukha on GitHub. The downside is that the tutorial crashed :p. I hope me and Tobias together can make things work.

ndtrong July 23, 2019 01:41

Quote:

Originally Posted by tiam (Post 739516)
I've been in contact with Tobias, the author of the library, and offered to upgrade the library so that it compiles across most version of OF and he agreed. I will get this done in the next month. That being said, I quickly patched the library to get it compiled on OFv1806, check the fork by timofeymukha on GitHub. The downside is that the tutorial crashed :p. I hope me and Tobias together can make things work.

Thank you very much with your information.
Could you please share with me some update, I also would like to read to get more understanding OpenFOAM.

Thanks and Best regards

tiam November 18, 2019 06:07

Dear all,


I am happy to say that after me and Tobias having put in some work, the library should now work for modern OpenFOAM versions, both .org and .com. Please feel free to test it. I should say directly that any questions regarding the functionality are better directed at Tobias, since I've only helped with the version upgrade, but now little about how the code functions.


Best,
Timofey


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