-
Notifications
You must be signed in to change notification settings - Fork 277
[Core] Replace explicit functions with lambdas in add_constitutive_law_to_python.cpp
#13588
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
base: master
Are you sure you want to change the base?
Conversation
…aw_to_python.cpp`
|
I am quite sure that we used lambdas only as temp solution while we still had C++11 I think the proper solution is |
I am unable to compile in Windows, I tried this already |
|
can you post the error? Then again, its already used in other places |
I did some test, can you point me where are we using it? |
|
just search |
Looks like fixed |
👋 |
| .def("Create", static_cast<ConstitutiveLaw::Pointer(ConstitutiveLaw::*)(Kratos::Parameters) const>(&ConstitutiveLaw::Create)) | ||
| .def("Create", static_cast<ConstitutiveLaw::Pointer(ConstitutiveLaw::*)(Kratos::Parameters, const Properties&) const>(&ConstitutiveLaw::Create)) | ||
| .def("WorkingSpaceDimension", &ConstitutiveLaw::WorkingSpaceDimension) | ||
| .def("GetStrainSize", &ConstitutiveLaw::GetStrainSize) | ||
| .def("GetStressMeasure", &ConstitutiveLaw::GetStressMeasure) | ||
| .def("IsIncremental", &ConstitutiveLaw::IsIncremental) | ||
| .def("Has", static_cast<bool (ConstitutiveLaw::*)(const Variable<bool>&)>(&ConstitutiveLaw::Has)) | ||
| .def("Has", static_cast<bool (ConstitutiveLaw::*)(const Variable<int>&)>(&ConstitutiveLaw::Has)) | ||
| .def("Has", static_cast<bool (ConstitutiveLaw::*)(const Variable<double>&)>(&ConstitutiveLaw::Has)) | ||
| .def("Has", static_cast<bool (ConstitutiveLaw::*)(const Variable<array_1d<double, 3>>&)>(&ConstitutiveLaw::Has)) | ||
| .def("Has", static_cast<bool (ConstitutiveLaw::*)(const Variable<Vector>&)>(&ConstitutiveLaw::Has)) | ||
| .def("Has", static_cast<bool (ConstitutiveLaw::*)(const Variable<Matrix>&)>(&ConstitutiveLaw::Has)) | ||
| .def("GetValue", [](ConstitutiveLaw& rCL, const Variable<bool>& rVar) { bool v; rCL.GetValue(rVar, v); return v; }) | ||
| .def("GetValue", [](ConstitutiveLaw& rCL, const Variable<int>& rVar) { int v; rCL.GetValue(rVar, v); return v; }) | ||
| .def("GetValue", [](ConstitutiveLaw& rCL, const Variable<double>& rVar) { double v; rCL.GetValue(rVar, v); return v; }) | ||
| .def("GetValue", [](ConstitutiveLaw& rCL, const Variable<array_1d<double, 3>>& rVar) { array_1d<double, 3> v; rCL.GetValue(rVar, v); return v; }) | ||
| .def("GetValue", [](ConstitutiveLaw& rCL, const Variable<Vector>& rVar) { Vector v; rCL.GetValue(rVar, v); return v; }) | ||
| .def("GetValue", [](ConstitutiveLaw& rCL, const Variable<Matrix>& rVar) { Matrix v; rCL.GetValue(rVar, v); return v; }) | ||
| .def("SetValue", py::overload_cast<const Variable<int>&, const int&, const ProcessInfo&>(&ConstitutiveLaw::SetValue)) | ||
| .def("SetValue", py::overload_cast<const Variable<double>&, const double&, const ProcessInfo&>(&ConstitutiveLaw::SetValue)) | ||
| .def("SetValue", py::overload_cast<const Variable<array_1d<double, 3>>&, const array_1d<double, 3>&, const ProcessInfo&>(&ConstitutiveLaw::SetValue)) | ||
| .def("SetValue", py::overload_cast<const Variable<Vector>&, const Vector&, const ProcessInfo&>(&ConstitutiveLaw::SetValue)) | ||
| .def("SetValue", py::overload_cast<const Variable<Matrix>&, const Matrix&, const ProcessInfo&>(&ConstitutiveLaw::SetValue)) | ||
| .def("CalculateValue", [](ConstitutiveLaw& rCL, ConstitutiveLaw::Parameters& rP, const Variable<bool>& rVar) { bool v; rCL.CalculateValue(rP, rVar, v); return v; }) | ||
| .def("CalculateValue", [](ConstitutiveLaw& rCL, ConstitutiveLaw::Parameters& rP, const Variable<int>& rVar) { int v; rCL.CalculateValue(rP, rVar, v); return v; }) | ||
| .def("CalculateValue", [](ConstitutiveLaw& rCL, ConstitutiveLaw::Parameters& rP, const Variable<double>& rVar) { double v; rCL.CalculateValue(rP, rVar, v); return v; }) | ||
| .def("CalculateValue", [](ConstitutiveLaw& rCL, ConstitutiveLaw::Parameters& rP, const Variable<array_1d<double, 3>>& rVar) { array_1d<double, 3> v; rCL.CalculateValue(rP, rVar, v); return v; }) | ||
| .def("CalculateValue", [](ConstitutiveLaw& rCL, ConstitutiveLaw::Parameters& rP, const Variable<Vector>& rVar) { Vector v; rCL.CalculateValue(rP, rVar, v); return v; }) | ||
| .def("CalculateValue", [](ConstitutiveLaw& rCL, ConstitutiveLaw::Parameters& rP, const Variable<Matrix>& rVar) { Matrix v; rCL.CalculateValue(rP, rVar, v); return v; }) | ||
| .def("CalculateMaterialResponse", &ConstitutiveLaw::CalculateMaterialResponse) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use overload_cast here?
| .def("PushForwardConstitutiveMatrix", &ConstitutiveLaw::PushForwardConstitutiveMatrix) | ||
| .def("Check", &ConstitutiveLaw::Check) | ||
| .def("GetLawFeatures", &ConstitutiveLaw::GetLawFeatures) | ||
| .def("Info", [](const ConstitutiveLaw& rThisConstitutiveLaw){return rThisConstitutiveLaw.Info();}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you change this?
|
What is the status of this? |
|
waiting for answers in the unresolved threads |
📝 Description
Replaced explicit global functions with inline lambda expressions for pybind11 bindings in
kratos/python/add_constitutive_law_to_python.cpp.This change improves code readability and conciseness by defining the wrapper functions directly where they are used.
🆕 Changelog
add_constitutive_law_to_python.cpp