Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[do not merge/ to discuss] freecad needs some adoptions of netgen #4

Closed
wants to merge 2 commits into from

Conversation

looooo
Copy link
Contributor

@looooo looooo commented Sep 15, 2017

As you may know, FreeCAD uses Netgen to generate meshes. While this was working quite good for older releases, there were introduced some changes in the recent Netgen version which had to be patched from our side to get Netgen work with FreeCAD.

While some of these patches can be applied directly, others are maybe more difficult to incorporate.

@luzpaz
Copy link
Contributor

luzpaz commented Oct 17, 2017

ping @JSchoeberl @mhochsteger

@@ -118,122 +118,122 @@ void Ng_LoadMeshFromStream ( istream & input )

void Ng_LoadMesh (const char * filename)
{
{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do you comment this code ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it was a problem with gcc4.8. This is more a problem with conda. So for sure this shouldn't be merged. I just wanted to start a little discussion to see which stuff has potential to be accepted...

Copy link
Member

@mhochsteger mhochsteger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with the CMake changes concerning USE_GUI, the DLL_HEADER stuff and the changes in occgeom.cpp

Concerning the install path for python modules:
We are providing installers (msi, dmg) for Windows and MacOS, so we need relocatable packages containing also the python files.
In addition, we don't know where the user installed Python.
It should be possible for you to set NG_INSTALL_DIR_PYTHON at configure time to your preferred value.

Concerning pybind headers: They are needed by dependent packages (most notably NGSolve). I could add an option do disable installing them but would rather have them installed by default.

CMakeLists.txt Outdated
@@ -207,7 +228,7 @@ if(WIN32)
else(WIN32)
# build shared libraries
set(NG_LIB_TYPE SHARED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think about raising the minimum CMake version to 3.1 and using
CXX_STANDARD instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is 14 actually really necessary? I think that was my problem.

install(FILES nglib.h DESTINATION ${NG_INSTALL_DIR_INCLUDE}/include COMPONENT netgen_devel)
install(FILES nglib.h DESTINATION ${NG_INSTALL_DIR_INCLUDE}/nglib COMPONENT netgen_devel)
install(FILES nglib.h DESTINATION ${NG_INSTALL_DIR_INCLUDE} COMPONENT netgen_devel)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you install nglib.h four times?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did this after some frustration with the cmake of FreeCAD. The proper solution is to change the FindNetgen used in FreeCAD.
But the place where it got placed originally is also quite strange... /include/netgen/include .

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concerning the include dir structure: That's because we maintain the relative paths of the header files in the source code. The headers in
libsrc/include contain statements like

#include "../gprim/gprim.hpp"

Therefore we need an additional "include" in the path.

Concerning the FindNetgen.cmake in FreeCAD: Are there reasons not to use NetgenConfig.cmake and netgen-targets.cmake provided by Netgen itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will have a look at the default cmake, but I think we need our custom FindNetgen, because we are also using older versions of netgen which was build without cmake...

Element2d (Element2d &&) = default;
Element2d & operator= (const Element2d &) = default;
Element2d & operator= (Element2d &&) = default;
DLL_HEADER Element2d () = default;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When a whole class is exported, inline member functions are not inlined anymore. Therefore we prefer exporting members explicitly. See here for example.

@looooo
Copy link
Contributor Author

looooo commented Oct 19, 2017

In addition, we don't know where the user installed Python.
It should be possible for you to set NG_INSTALL_DIR_PYTHON at configure time to your preferred value.

Why you need this information? Also you can always get this information if python is directly available, and if it is not directly available there will be problems anyway.

@luzpaz
Copy link
Contributor

luzpaz commented Nov 8, 2017

In addition, we don't know where the user installed Python.
It should be possible for you to set NG_INSTALL_DIR_PYTHON at configure time to your preferred value.

Why you need this information? Also you can always get this information if python is directly available, and if it is not directly available there will be problems anyway.

@mhochsteger care to weigh in?

@looooo
Copy link
Contributor Author

looooo commented Nov 8, 2017

Regarding this issue: I see now, that the method to use python to find out where to install the library is also not the best way. One problem I had with this, are local installation. Python will always point to the main site-package/dist-package in the root dir, if python is installed in a root directory...
But sometimes there is the need to install something locally... With conda this is no problem as one can install conda locally and therefor python is also locally. No idea how to proceed with this.

@mhochsteger
Copy link
Member

I think I understand the problem now. We have to distinguish between USE_SUPERBUILD=ON and USE_SUPERBUILD=OFF.

Let NG_INSTALL_DIR_PYTHON=${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1,0,''))"
for instance NG_INSTALL_DIR_PYTHON=lib/python3.6/site-packages

WITH superbuild the current behavior is to install python modules to ${CMAKE_INSTALL_PREFIX}/${NG_INSTALL_DIR_PYTHON}, which is fine for local and global installations.

WITHOUT superbuild, NG_INSTALL_DIR_PYTHON is not set at all, which leads to errors at configure time. I will fix that and hope this sorts out the problem.

@looooo
Copy link
Contributor Author

looooo commented Nov 13, 2017

can we check for python default install dir if no NG_INSTALL_DIR_PYTHON is given?

@mhochsteger
Copy link
Member

Yes, that's whats happening now. If nothing is set by the user, it will install to
${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import get_python_lib; print(get_python_lib(1,0,''))".
If you set NG_INSTALL_DIR_PYTHON at configure time, it will be used instead.

@looooo
Copy link
Contributor Author

looooo commented Nov 13, 2017

👍

mhochsteger added a commit that referenced this pull request Jan 23, 2018
Includes parts of pull request by looooo
#4
Element2d & operator= (const Element2d &) = default;
Element2d & operator= (Element2d &&) = default;
DLL_HEADER Element2d () = default;
DLL_HEADER Element2d (const Element2d &) = default;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DLL_HEADER is not needed for default constructors (Tested with VS2015 on Windows). The others functions are exported with commit 0b411e1.

@@ -1291,7 +1291,7 @@ namespace netgen
if (mparam.perfstepsstart <= MESHCONST_ANALYSE)
{
// delete mesh;
// mesh = make_shared<Mesh>();
mesh = make_shared<Mesh>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to preserve the given pointer in order to visualize the mesh during mesh generation. I assume the following works for you:

if(mesh.get() == nullptr)
  mesh = make_shared<Mesh>();

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I have experimented with exactly this and it works for us. It seems this is the missing part which makes netgen again usable for FreeCAD.
Thanks for all the work!

@looooo looooo force-pushed the master branch 3 times, most recently from 22756da to 252a0c1 Compare February 13, 2018 18:11
@looooo
Copy link
Contributor Author

looooo commented Feb 17, 2018

I think everything is included. I will make a PR for the new changes.

@looooo looooo closed this Feb 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants