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.04k stars 246 forks source link

[StructMech] Boost error when importing Structural Mechanics in FullDebug #4091

Closed maceligueta closed 5 years ago

maceligueta commented 5 years ago

I am getting:

Check failed in file /usr/include/boost/numeric/ublas/detail/vector_assign.hpp at line 370:
detail::expression_type_check (v, cv)
Traceback (most recent call last):
  File "dem_fem_launcher.py", line 8, in <module>
    import KratosMultiphysics.StructuralMechanicsApplication as Structural
  File "/home/maceli/kratos/KratosMultiphysics/StructuralMechanicsApplication/__init__.py", line 2, in <module>
    application = KratosStructuralMechanicsApplication()
RuntimeError: external logic or bad condition of inputs

The code exits, so no stacktrace is printed, however, I think I managed to stop the code at the message, and received the following stacktrace:

#0  boost::numeric::ublas::detail::expression_type_check<boost::numeric::ublas::vector<bool, boost::numeric::ublas::bounded_array<bool, 2ul, std::allocator<bool> > >, boost::numeric::ublas::vector<bool, boost::numeric::ublas::unbounded_array<bool, std::allocator<bool> > > > (e1=..., e2=...) at /usr/include/boost/numeric/ublas/detail/vector_assign.hpp:42
#1  0x00007fffed85245c in boost::numeric::ublas::vector_assign<boost::numeric::ublas::scalar_assign, boost::numeric::ublas::vector<bool, boost::numeric::ublas::bounded_array<bool, 2ul, std::allocator<bool> > >, boost::numeric::ublas::zero_vector<double, std::allocator<double> > > (v=..., e=...) at /usr/include/boost/numeric/ublas/detail/vector_assign.hpp:369
#2  0x00007fffed851c0d in boost::numeric::ublas::vector_assign<boost::numeric::ublas::scalar_assign, boost::numeric::ublas::vector<bool, boost::numeric::ublas::bounded_array<bool, 2ul, std::allocator<bool> > >, boost::numeric::ublas::zero_vector<double, std::allocator<double> > > (v=..., e=...) at /usr/include/boost/numeric/ublas/detail/vector_assign.hpp:448
#3  0x00007fffed851804 in boost::numeric::ublas::vector<bool, boost::numeric::ublas::bounded_array<bool, 2ul, std::allocator<bool> > >::vector<boost::numeric::ublas::zero_vector<double, std::allocator<double> > > (this=0xcecd58, ae=...) at /usr/include/boost/numeric/ublas/vector.hpp:122
#4  0x00007fffed8511c3 in boost::numeric::ublas::bounded_vector<bool, 2ul>::bounded_vector<boost::numeric::ublas::zero_vector<double, std::allocator<double> > > (this=0xcecd58, ae=...) at /usr/include/boost/numeric/ublas/vector.hpp:829
#5  0x00007fffed84d368 in Kratos::TrussPlasticityConstitutiveLaw::TrussPlasticityConstitutiveLaw (this=0xcecd38) at /home/maceli/kratos/applications/StructuralMechanicsApplication/custom_constitutive/truss_plasticity_constitutive_law.cpp:27
#6  0x00007fffed384894 in Kratos::KratosStructuralMechanicsApplication::KratosStructuralMechanicsApplication (this=0xce7650) at /home/maceli/kratos/applications/StructuralMechanicsApplication/structural_mechanics_application.cpp:176
#7  0x00007fffeeed434c in pybind11::detail::initimpl::construct_or_initialize<Kratos::KratosStructuralMechanicsApplication, , 0>() () at /home/maceli/kratos/external_libraries/pybind11/detail/init.h:61

I guess one of those vectors is giving problems: https://github.com/KratosMultiphysics/Kratos/blob/372671c85bb3533a9d6fe445059c24104c839851/applications/StructuralMechanicsApplication/custom_constitutive/truss_plasticity_constitutive_law.h#L221

Referencing @KratosMultiphysics/structural-mechanics and @KlausBSautter

philbucher commented 5 years ago

hm I ran the tests in FullDebug this afternoon, nothing suspicious ... Also this code has been unchanged for a while I think

maceligueta commented 5 years ago

I think I found the problem: https://github.com/KratosMultiphysics/Kratos/blob/372671c85bb3533a9d6fe445059c24104c839851/kratos/includes/ublas_interface.h#L80 ZeroVector is for doubles only, maybe that's the reason why vector_assign is complaining...

philbucher commented 5 years ago

oh yes this seems to be the reason @KlausBSautter in this case BoundedVector is not suitable anyway, an std::vector<bool> would be better

philbucher commented 5 years ago

Thanks @maceligueta !

KlausBSautter commented 5 years ago

What is the problem with a bounded vector here? I know the size will always be 2

maceligueta commented 5 years ago

Yes, the size is correct, but apparently ZeroVector is only compatible with vectors of doubles, not vectors of bools. I don’t know how to fix the problem using the tools in ublas_interface.h. Maybe we should create a FalseVector in the same way ZeroVector is defined...

philbucher commented 5 years ago

I will speak to you later Klaus then we can figure it out ;)

maceligueta commented 5 years ago

Thanks, @KlausBSautter and @philbucher !