FindNETGEN rework

About the development of the FEM module/workbench.

Moderator: bernd

Fat-Zer
Posts: 171
Joined: Thu Oct 30, 2014 10:38 pm

FindNETGEN rework

Postby Fat-Zer » Sun Jul 19, 2015 4:38 pm

Hi, I reworked FindNETGEN so it got additional features:
- The version 5 API is determined by features provided by the library rather than by system or pkg-config data.
- Checks during configuration if netgen was compiled with OpenCasCade support
- Checks if netgen was compiled with/without NO_PARALLEL_THREADS
- Cmake issues a more or less sane message if netgen's internal headers wasn't found.
- More guess paths for source headers
- The defines are provided to the appropriate modules rather than globally
- Support for pkg-config if it's provided.

https://github.com/Fat-Zer/FreeCAD_sf_m ... GEN-rework

What was tested:
Compilation against netgen-5.3, 5.1 and 4.9.
I will appreciate a feedback about built on fedora, ubuntu, <your distro>, macOS and windows.
User avatar
PrzemoF
Posts: 3049
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: FindNETGEN rework

Postby PrzemoF » Sun Jul 19, 2015 5:10 pm

Doesn't work on fedora 21:

Code: Select all

/home/przemo/fedora/FreeCAD/freecad/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_Mesher.cpp:60:0: warning: "OCCGEOMETRY" redefined
 #define OCCGEOMETRY
 ^
<command-line>:0:0: note: this is the location of the previous definition
/home/przemo/fedora/FreeCAD/freecad/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_Mesher.cpp: In member function ‘bool NETGENPlugin_Mesher::Compute()’:
/home/przemo/fedora/FreeCAD/freecad/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_Mesher.cpp:690:28: error: no matching function for call to ‘netgen::Mesh::CalcLocalH()’
         ngMesh->CalcLocalH();
                            ^
/home/przemo/fedora/FreeCAD/freecad/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_Mesher.cpp:690:28: note: candidate is:
In file included from /usr/include/netgen-mesher/private/meshing/meshing.hpp:25:0,
                 from /usr/include/netgen-mesher/private/occ/occgeom.hpp:12,
                 from /home/przemo/fedora/FreeCAD/freecad/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_Mesher.cpp:61:
/usr/include/netgen-mesher/private/meshing/meshclass.hpp:374:10: note: void netgen::Mesh::CalcLocalH(double)
     DLL_HEADER void CalcLocalH (double grading);
          ^
/usr/include/netgen-mesher/private/meshing/meshclass.hpp:374:10: note:   candidate expects 1 argument, 0 provided
src/3rdParty/salomesmesh/CMakeFiles/NETGENPlugin.dir/build.make:123: polecenia dla obiektu 'src/3rdParty/salomesmesh/CMakeFiles/NETGENPlugin.dir/src/NETGENPlugin/NETGENPlugin_Mesher.cpp.o' nie powiodły się
make[2]: *** [src/3rdParty/salomesmesh/CMakeFiles/NETGENPlugin.dir/src/NETGENPlugin/NETGENPlugin_Mesher.cpp.o] Błąd 1
CMakeFiles/Makefile2:470: polecenia dla obiektu 'src/3rdParty/salomesmesh/CMakeFiles/NETGENPlugin.dir/all' nie powiodły się
make[1]: *** [src/3rdParty/salomesmesh/CMakeFiles/NETGENPlugin.dir/all] Błąd 2
make[1]: *** Oczekiwanie na niezakończone zadania....
[ 50%] Built target PartDesign
[ 70%] Built target FreeCADGui
Makefile:117: polecenia dla obiektu 'all' nie powiodły się
make: *** [all] Błąd 2
NETGEN_LIBRARY_mesh and NETGEN_LIBRARY_occ are not found. The compilation error suggests that NETGEN_V5 is not set even if I have netgen > 5 on my system:

Code: Select all

$ rpm -qi netgen-mesher
Name        : netgen-mesher
Version     : 5.3.1
Release     : 3.fc21
The rest of NETGEN_DIR_* is set properly.
Fat-Zer
Posts: 171
Joined: Thu Oct 30, 2014 10:38 pm

Re: FindNETGEN rework

Postby Fat-Zer » Sun Jul 19, 2015 5:48 pm

PrzemoF wrote: NETGEN_LIBRARY_mesh and NETGEN_LIBRARY_occ are not found. The compilation error suggests that NETGEN_V5 is not set even if I have netgen > 5 on my system
The rest of NETGEN_DIR_* is set properly.
Thanks for reply, should be fixed now.
Seems fedora have prefixed libraries name: libocc -> libngocc and libmesh->libngmesh. Added such names as a search option.
User avatar
PrzemoF
Posts: 3049
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: FindNETGEN rework

Postby PrzemoF » Sun Jul 19, 2015 6:02 pm

Compiles & works! :D Thanks!
django013
Posts: 106
Joined: Tue Jan 13, 2015 7:51 am

Re: FindNETGEN rework

Postby django013 » Mon Jul 20, 2015 3:30 am

Hi,

very nice work.

I realized, that you partly already used the "new" library names.
Just for completeness:
general produces libgen.so
linalg produces libla.so
meshing produces libmesh.so
visualization produces libvisual.so
stlgeom produces libstl.so

Additionally I had a look at the patches of debians netgen package.
There is a patch, that renames all netgen libraries like this:
libgen.so -> libnetgen_gen.so
libinterface.so -> libnetgen_interface.so

Maybe you'd like to extend your work to handle debian systems too :)

P.S. there's a typo in second word of last line
OS: Linux Debian Jessie amd64 - FC: Git Master
User avatar
sgrogan
Posts: 6103
Joined: Wed Oct 22, 2014 5:02 pm

Re: FindNETGEN rework

Postby sgrogan » Mon Jul 20, 2015 11:18 am

This doesn't work on Windows, building FreeCAD using Netgen from FreeCADLibs_11.1_x64_VC12

Code: Select all

CMake Warning (dev) at CMakeLists.txt:47 (if):
  Policy CMP0054 is not set: Only interpret if() arguments as variables or
  keywords when unquoted.  Run "cmake --help-policy CMP0054" for policy
  details.  Use the cmake_policy command to set the policy and suppress this
  warning.

  Quoted variables like "MSVC" will no longer be dereferenced when the policy
  is set to NEW.  Since the policy is not set the OLD behavior will be used.
This warning is for project developers.  Use -Wno-dev to suppress it.

prefix: C:/Program Files/FreeCAD_trunk
datadir: data
docdir: doc
includedir: include
libdir: lib
PyCXX found:
  Headers:  C:/Users/sim/Documents/SW_Projects/Netgen-ReWork-code/src
  Sources:  C:/Users/sim/Documents/SW_Projects/Netgen-ReWork-code/src/CXX
Found SWIG: C:/Users/sim/Documents/SW_Projects/FreeCADLibs_11.1_x64_VC12/bin/swig/swig.exe (found version "1.3.40") 
Found PySide Tools: C:/Users/sim/Documents/SW_Projects/FreeCADLibs_11.1_x64_VC12/bin/pyside-uic, C:/Users/sim/Documents/SW_Projects/FreeCADLibs_11.1_x64_VC12/bin/pyside-rcc.exe
Found PythonInterp: C:/Users/sim/Documents/SW_Projects/FreeCADLibs_11.1_x64_VC12/bin/python.exe (found version "2.7.8") 
Found PythonLibs: optimized;C:/Users/sim/Documents/SW_Projects/FreeCADLibs_11.1_x64_VC12/lib/python27.lib;debug;C:/Users/sim/Documents/SW_Projects/FreeCADLibs_11.1_x64_VC12/lib/python27_d.lib (found suitable exact version "2.7.8") 
Boost version: 1.55.0
Found the following Boost libraries:
  filesystem
  program_options
  regex
  signals
  system
  thread
Found Xerces-C: C:/Users/sim/Documents/SW_Projects/FreeCADLibs_11.1_x64_VC12/lib/xerces-c_3.lib
Found ZLIB: C:/Users/sim/Documents/SW_Projects/FreeCADLibs_11.1_x64_VC12/lib/zlib.lib (found version "1.2.8") 
PyCXX found:
  Headers:  C:/Users/sim/Documents/SW_Projects/Netgen-ReWork-code/src
  Sources:  C:/Users/sim/Documents/SW_Projects/Netgen-ReWork-code/src/CXX
-- OpenCASCADE Community Edition has been found.
Found OCC: C:/Users/sim/Documents/SW_Projects/FreeCADLibs_11.1_x64_VC12/lib/cmake/../../include/oce (found version "6.8.0") 
-- Found OCE/OpenCASCADE version: 6.8.0
-- OCE/OpenCASCADE include directory: C:/Users/sim/Documents/SW_Projects/FreeCADLibs_11.1_x64_VC12/lib/cmake/../../include/oce
-- OCE/OpenCASCADE shared libraries directory: 
-- OpenCASCADE Community Edition has been found.
-- Found OCE/OpenCASCADE version: 6.8.0
-- OCE/OpenCASCADE include directory: C:/Users/sim/Documents/SW_Projects/FreeCADLibs_11.1_x64_VC12/lib/cmake/../../include/oce
-- OCE/OpenCASCADE shared libraries directory: 
Could NOT find PkgConfig (missing:  PKG_CONFIG_EXECUTABLE) 
Found NGLIB: C:/Users/sim/Documents/SW_Projects/FreeCADLibs_11.1_x64_VC12/include  
Performing Test NETGEN_VERSION_5
Performing Test NETGEN_VERSION_5 - Failed
Performing Test NETGEN_WITH_PARALLEL_THREADS
Performing Test NETGEN_WITH_PARALLEL_THREADS - Failed
Performing Test NETGEN_WITH_OCC
Performing Test NETGEN_WITH_OCC - Failed
CMake Error at CMakeLists.txt:621 (message):
  Found netgen library seems to be compiled without opencascade support.


Configuring incomplete, errors occurred!
See also "C:/Users/sim/Documents/SW_Projects/Netgen-RwWork-build/CMakeFiles/CMakeOutput.log".
See also "C:/Users/sim/Documents/SW_Projects/Netgen-RwWork-build/CMakeFiles/CMakeError.log".
"fight the good fight"
Fat-Zer
Posts: 171
Joined: Thu Oct 30, 2014 10:38 pm

Re: FindNETGEN rework

Postby Fat-Zer » Mon Jul 20, 2015 2:14 pm

sgrogan wrote:This doesn't work on Windows, building FreeCAD using Netgen from FreeCADLibs_11.1_x64_VC12
I don't know a lot about windows build... could you link me to some notes what netgen package looks like there.
Also could you provide CMakeCache.txt and CMakeFiles/CMakeError.log to see what gone wrong...
django013 wrote:Maybe you'd like to extend your work to handle debian systems too
Yes, I'd like to, thanks for the notice. Could you link me to the description? I can't find information about the fifth version on debian.
django013 wrote:P.S. there's a typo in second word of last line
Thanks, fixed.
django013
Posts: 106
Joined: Tue Jan 13, 2015 7:51 am

Re: FindNETGEN rework

Postby django013 » Mon Jul 20, 2015 2:53 pm

List of netgen packages without release-filter
newest netgen from sid (currently 4.9.13)

... and perhaps the most interesting part:
debian patches for netgen integration into debian standards
The debian-subdirectory contains a directory called patches - and that contains the meat :)
I like the idea of project-specific prefixes for libs - makes things cleaner.

@Fat-Zer
... by the way: I like your way of coding - beautiful and smart :)
OS: Linux Debian Jessie amd64 - FC: Git Master
User avatar
PrzemoF
Posts: 3049
Joined: Fri Jul 25, 2014 4:52 pm
Contact:

Re: FindNETGEN rework

Postby PrzemoF » Mon Jul 20, 2015 3:18 pm

I like the idea of functionality-based check, but is it really required? I mean are we dealing with systems that are not providing netgen version? It's a genuine question, as I never compiled FreeCAD on anything else than fedora linux.
Normally when I use automake and e.g. if the function that I use has been introduced in version X.X.X of package Y.Y.Y I just add a check for it and that's all. If very easy to change to version Y.Y.Z if there is a new function that has been added to X.X.X in version Y.Y.Z and I want to use it. That's not really the case with functionality-based check.

Minor typo:
https://github.com/Fat-Zer/FreeCAD_sf_m ... .cmake#L11
s/fas/was/
Fat-Zer
Posts: 171
Joined: Thu Oct 30, 2014 10:38 pm

Re: FindNETGEN rework

Postby Fat-Zer » Mon Jul 20, 2015 6:06 pm

PrzemoF wrote:I like the idea of functionality-based check, but is it really required? I mean are we dealing with systems that are not providing netgen version? It's a genuine question, as I never compiled FreeCAD on anything else than fedora linux.
Normally when I use automake and e.g. if the function that I use has been introduced in version X.X.X of package Y.Y.Y I just add a check for it and that's all. If very easy to change to version Y.Y.Z if there is a new function that has been added to X.X.X in version Y.Y.Z and I want to use it. That's not really the case with functionality-based check.
It's true only if package provides version information somehow, e.g. via pkg-config, but AFAIK fedora is the only distro who packaged a *.pc file for now. Note, that upstream doesn't also provide it, so it's totally a fedora extension so far.
There is no way to obtain the version information on other systems.