trelau / SMESH

Mesh module from the Salome Platform
GNU Lesser General Public License v2.1
52 stars 32 forks source link

Support of Netgen 6.2.2004 or higher #28

Closed wwmayer closed 3 years ago

wwmayer commented 4 years ago

This PR is mainly a replacement for @looooo 's #21. As you have discussed in that PR the netgen devs have extended the NetgenConfig.cmake file by adding several variables. Mainly the new NETGEN_VERSION_PATCH is very useful as it's now possible to distinguish between different 6.2.x netgen versions.

This solves many open issues of #21:

Open issues: The version number is encoded by shifting the major version by 16 bits, the minor version by 8 bits and the patch number by 0 bits. So, the patch number has 8 bits available but the highest number that can be represented is 255. Since the real patch number is something like 1808, 2004, 2006, ... this causes an ambiguity. E.g. when encoding 6.2.2004 we end up with the same number as the possible version 6.9.212 A solution will be to shift the minor number by 12 instead of 8 bits. But at the moment this is only a theoretical issue.

As mentioned above I needed a workaround to avoid a crash when the "optimize" option of the NETGENPlugin_Hypothesis is on. For the meshing this sets the perfstepsend value to MESHCONST_OPTSURFACE but somehow netgen doesn't like it and causes a segmentation fault. So, the workaround is to check this beforehand and set the value to MESHCONST_MESHSURFACE. Since the function OCCGenerateMesh() has been removed from netgen it's a bit difficult to achieve the same behaviour with the new API. If I find a proper solution I will create a new PR. So, this PR can be already merged (if OK).

wwmayer commented 4 years ago

In the meantime I got the pdb files of the dlls to analyse the crash. The segmentation fault occurs in:

    virtual Vec<3> GetNormal(int surfind, const Point<3> & p, const PointGeomInfo* gi = nullptr) const
    { return faces[surfind-1]->GetNormal(p, gi); }

which is a method of the class NetgenGeometry declared in basegeom.hpp and faces is an empty array.

The member variable faces is of type Array<unique_ptr>. Now the point is that GeometryFace is an abstract class and nowhere else in the netgen code base there is a sub-class of it.

So, this means with this netgen version the option MESHCONST_OPTSURFACE cannot be used as the algorithm behind the scene is kind of broken. Thus, the only option for now is to disable it as I did in this PR.

trelau commented 3 years ago

Related to https://github.com/trelau/SMESH/pull/31. That PR sets the direction of this project to target Netgen 5.3 and be in sync with upstream Salome sources. The maintenance of the changing Netgen API is a burden and it's not clear what the real benefit is in the later Netgen versions. Will likely close this PR after https://github.com/trelau/SMESH/pull/31 is merged.

trelau commented 3 years ago

Closing for now. If supporting the latest versions of netgen is needed please open an issue for discussion.