KratosMultiphysics / Kratos

Kratos Multiphysics (A.K.A Kratos) is a framework for building parallel multi-disciplinary simulation software. Modularity, extensibility and HPC are the main objectives. Kratos has BSD license and is written in C++ with extensive Python interface.
https://kratosmultiphysics.github.io/Kratos/
Other
1.01k stars 244 forks source link

Problems with importing application in python #7957

Closed PhiHo-eng closed 3 years ago

PhiHo-eng commented 3 years ago

Hi everyone,

I am currently trying to reactivate TopologyOptimizationApplication. I followed the PyBind11 common steps and changed the code like recommended. Additionally I linked the TopOptApp with StructuralMechanis instead of SolidMechanics. I am able to compile the application. But when I try to import the TopOptApp in python I get the following error:

_ZN5boost10hash_rangeINS_7numeric5ublas6vectorIiNS2_15unbounded_arrayIiSaIiEEEE14const_iteratorEEEmT_S9_

I used c++filt on it and got:

unsigned long boost::hash_range<boost::numeric::ublas::vector<int, boost::numeric::ublas::unbounded_array<int, std::allocator<int> > >::const_iterator>(boost::numeric::ublas::vector<int, boost::numeric::ublas::unbounded_array<int, std::allocator<int> > >::const_iterator, boost::numeric::ublas::vector<int, boost::numeric::ublas::unbounded_array<int, std::allocator<int> > >::const_iterator)

Has anybody an idea what I am missing or did anyone encounter the same or a similar problem?

Thank you in advance!

philbucher commented 3 years ago

Hi @PhiHo-eng Hm I haven't encountered this particular error before. anyone else has an idea? @roigcarlo @loumalouomega @rubenzorrilla ? Do you have a branch we could try? Cheers

loumalouomega commented 3 years ago

I need to see what are you doing in order to help you @PhiHo-eng, which is your branch?

PhiHo-eng commented 3 years ago

Thank you for you quick answer!

I made a Repository on my account, in order to work on the code. Is that allright with you or should I make a branch?

This is the link to my Repository

loumalouomega commented 3 years ago

You should do a branch only if you are a developer part of the Kratos team, if you are external it is Ok to do a fork for a later PR

loumalouomega commented 3 years ago

Ok, if I have a moment I will try to compile it in my machine. BTW, I do not recommend to copy paste the base solid element, I instead recommend to add as dependency the Structural application and include from there

PhiHo-eng commented 3 years ago

thanks for looking into it!

Oh thanks for pointing that out. I had that in there in order to get it running in the beginning, but I totally forgot about it. I removed it now. However I still need solid_mechanics_math_utilities, that the code works, but I intend to remove that as soon as possible.

roigcarlo commented 3 years ago

Two guesses:

1 - https://github.com/PhiHo-eng/Kratos/blob/master/applications/TopologyOptimizationApplication/custom_strategies/custom_schemes/residualbased_incrementalupdate_static_simp_scheme.hpp#L18

Remove this. It may be casuing you to import undesiered headers that may be adding dependencies.

2 - If this does not solve the problem, it could be caused by some header using forward declaration of unbounded array iterators, if you are using includes to boost directly in your app, try to add this include when they are used. ´#include <boost/numeric/ublas/storage.hpp>´ somewhere.

Other than that I cannot see any other problem

PhiHo-eng commented 3 years ago

@roigcarlo thanks for your help, but it seems, that this does not solve the problem. I still get the same error.

PhiHo-eng commented 3 years ago

I think the boost::hash_range in topology_extractor_utilities.h may cause this problem. There was already a discussion about this in #1778. Is there already a solution for the problem or am I going totally in the wrong direction?

philbucher commented 3 years ago

does it work when you comment the hash_range related things?

PhiHo-eng commented 3 years ago

Hi @philbucher, yes that worked. But I am not sure yet how to implement the hash_range - "function" back in the program!

philbucher commented 3 years ago

Looking at your code I think you could either refactor completely (e.g. using the SkinDetectionProcess Or take a look here, maybe you can use this instead: https://github.com/KratosMultiphysics/Kratos/blob/master/kratos/includes/key_hash.h

PhiHo-eng commented 3 years ago

I used the key_hash.h. It seems to work now. I am able to import TopOpt - App in python. Thanks you for your help @philbucher !