Kratos: [Dem-Structural] Compilation error after master update

Created on 6 Mar 2020  Â·  6Comments  Â·  Source: KratosMultiphysics/Kratos

Hello,

Yesterday I updated the master branch and I found some errors related to PR #6339 while compiling the DemStructuresCouplingApplication...

I managed to fix most of them, but there is one which I couldn't. I paste here the method I have problems with:

std::string CheckProvidedProperties(Properties::Pointer props) {
    std::vector< Variable<double> > list_of_variables_double_to_check = {FRICTION, WALL_COHESION, SEVERITY_OF_WEAR, IMPACT_WEAR_SEVERITY, BRINELL_HARDNESS, YOUNG_MODULUS, POISSON_RATIO};
    std::vector< Variable<bool> > list_of_variables_bool_to_check = {COMPUTE_WEAR};
    for (int i=0; i<(int)list_of_variables_double_to_check.size(); i++) {
        if(!props->Has(list_of_variables_double_to_check[i])) return list_of_variables_double_to_check[i].Name();
    }
    for (int i=0; i<(int)list_of_variables_bool_to_check.size(); i++) {
        if(!props->Has(list_of_variables_bool_to_check[i])) return list_of_variables_bool_to_check[i].Name();
    }
    return "all_ok";
}

Part of the error I get is the following:

In file included from /home/ipouplana/Kratos/applications/DemStructuresCouplingApplication/custom_python/add_custom_utilities_to_python.cpp:10:0:
/home/ipouplana/Kratos/applications/DemStructuresCouplingApplication/custom_utilities/dem_structures_coupling_utilities.h: In member function ‘std::__cxx11::string Kratos::DemStructuresCouplingUtilities::CheckProvidedProperties(Kratos::Properties::Pointer)’:
/home/ipouplana/Kratos/applications/DemStructuresCouplingApplication/custom_utilities/dem_structures_coupling_utilities.h:89:185: error: no matching function for call to ‘Kratos::Variable<double>::Variable(Kratos::Variable<double>&)’
     std::vector< Variable<double> > list_of_variables_double_to_check = {FRICTION, WALL_COHESION, SEVERITY_OF_WEAR, IMPACT_WEAR_SEVERITY, BRINELL_HARDNESS, YOUNG_MODULUS, POISSON_RATIO};
                                                                                                                                                                                         ^
In file included from /home/ipouplana/Kratos/kratos/containers/data_value_container.h:31:0,

And if I modify the code like this:

std::string CheckProvidedProperties(Properties::Pointer props) {
    std::vector<const Variable<double>& > list_of_variables_double_to_check = {FRICTION, WALL_COHESION, SEVERITY_OF_WEAR, IMPACT_WEAR_SEVERITY, BRINELL_HARDNESS, YOUNG_MODULUS, POISSON_RATIO};
    std::vector<const Variable<bool>& > list_of_variables_bool_to_check = {COMPUTE_WEAR};
    for (int i=0; i<(int)list_of_variables_double_to_check.size(); i++) {
        if(!props->Has(list_of_variables_double_to_check[i])) return list_of_variables_double_to_check[i].Name();
    }
    for (int i=0; i<(int)list_of_variables_bool_to_check.size(); i++) {
        if(!props->Has(list_of_variables_bool_to_check[i])) return list_of_variables_bool_to_check[i].Name();
    }
    return "all_ok";
}

Then I get something like:

In file included from /usr/include/c++/7/ext/alloc_traits.h:36:0,
                 from /usr/include/c++/7/bits/forward_list.h:41,
                 from /usr/include/c++/7/forward_list:38,
                 from /home/ipouplana/Kratos/external_libraries/pybind11/detail/common.h:140,
                 from /home/ipouplana/Kratos/external_libraries/pybind11/pytypes.h:12,
                 from /home/ipouplana/Kratos/external_libraries/pybind11/cast.h:13,
                 from /home/ipouplana/Kratos/external_libraries/pybind11/attr.h:13,
                 from /home/ipouplana/Kratos/external_libraries/pybind11/pybind11.h:43,
                 from /home/ipouplana/Kratos/applications/DemStructuresCouplingApplication/custom_python/add_custom_utilities_to_python.h:14,
                 from /home/ipouplana/Kratos/applications/DemStructuresCouplingApplication/custom_python/add_custom_utilities_to_python.cpp:7:
/usr/include/c++/7/bits/alloc_traits.h: In instantiation of ‘struct std::allocator_traits<std::allocator<const Kratos::Variable<double>&> >’:
/usr/include/c++/7/ext/alloc_traits.h:50:10:   required from ‘struct __gnu_cxx::__alloc_traits<std::allocator<const Kratos::Variable<double>&> >’
/usr/include/c++/7/bits/stl_vector.h:77:21:   required from ‘struct std::__cxx1998::_Vector_base<const Kratos::Variable<double>&, std::allocator<const Kratos::Variable<double>&> >’
/usr/include/c++/7/bits/stl_vector.h:216:11:   required from ‘class std::__cxx1998::vector<const Kratos::Variable<double>&, std::allocator<const Kratos::Variable<double>&> >’
/usr/include/c++/7/debug/vector:113:11:   required from ‘class std::__debug::vector<const Kratos::Variable<double>&>’
/home/ipouplana/Kratos/applications/DemStructuresCouplingApplication/custom_utilities/dem_structures_coupling_utilities.h:89:43:   required from here
/usr/include/c++/7/bits/alloc_traits.h:392:27: error: forming pointer to reference type ‘const Kratos::Variable<double>&’
       using pointer = _Tp*;

Do you have a clue on what is happening ? Is there an easy way to fix this?

Thanks in advance.

Error Help Wanted

All 6 comments

So yes, should be easy to fix, nothing we haven’t done before :)

Thanks @philbucher . I tried the following:

std::string CheckProvidedProperties(Properties::Pointer props) {
    std::vector<const Variable<double>* > list_of_variables_double_to_check = {FRICTION, WALL_COHESION, SEVERITY_OF_WEAR, IMPACT_WEAR_SEVERITY, BRINELL_HARDNESS, YOUNG_MODULUS, POISSON_RATIO};
    std::vector<const Variable<bool>* > list_of_variables_bool_to_check = {COMPUTE_WEAR};
    for (int i=0; i<(int)list_of_variables_double_to_check.size(); i++) {
        if(!props->Has(list_of_variables_double_to_check[i])) return list_of_variables_double_to_check[i].Name();
    }
    for (int i=0; i<(int)list_of_variables_bool_to_check.size(); i++) {
        if(!props->Has(list_of_variables_bool_to_check[i])) return list_of_variables_bool_to_check[i].Name();
    }
    return "all_ok";
}

but got this error:

In file included from /home/ipouplana/Kratos/applications/DemStructuresCouplingApplication/custom_python/add_custom_utilities_to_python.cpp:10:0:
/home/ipouplana/Kratos/applications/DemStructuresCouplingApplication/custom_utilities/dem_structures_coupling_utilities.h: In member function ‘std::__cxx11::string Kratos::DemStructuresCouplingUtilities::CheckProvidedProperties(Kratos::Properties::Pointer)’:
/home/ipouplana/Kratos/applications/DemStructuresCouplingApplication/custom_utilities/dem_structures_coupling_utilities.h:88:191: error: could not convert ‘{Kratos::FRICTION, Kratos::WALL_COHESION, Kratos::SEVERITY_OF_WEAR, Kratos::IMPACT_WEAR_SEVERITY, Kratos::BRINELL_HARDNESS, Kratos::YOUNG_MODULUS, Kratos::POISSON_RATIO}’ from ‘<brace-enclosed initializer list>’ to ‘std::__debug::vector<const Kratos::Variable<double>*>’
     std::vector<const Variable<double>* > list_of_variables_double_to_check = {FRICTION, WALL_COHESION, SEVERITY_OF_WEAR, IMPACT_WEAR_SEVERITY, BRINELL_HARDNESS, YOUNG_MODULUS, POISSON_RATIO};

well you now need to pass pointers in the unitializer list

i mean &VELOCITY instead of just VELOCITY

Thanks @RiccardoRossi ! It now compiles ok.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jcotela picture jcotela  Â·  4Comments

maceligueta picture maceligueta  Â·  6Comments

ipouplana picture ipouplana  Â·  7Comments

armingeiser picture armingeiser  Â·  6Comments

KlausBSautter picture KlausBSautter  Â·  6Comments