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

[Core] Add variable type - vector of data value container #12812

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions kratos/python/add_containers_to_python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ void AddContainersToPython(pybind11::module& m)
.def("__str__", PrintObject<Variable<Quaternion<double> >>)
;

py::class_<Variable<std::vector<DataValueContainer>>>(m, "DataValueContainerVectorVariable")
.def("__str__", PrintObject<Variable<std::vector<DataValueContainer>>>)
;

typedef py::class_<DataValueContainer, DataValueContainer::Pointer> DataValueContainerBinderType;
DataValueContainerBinderType DataValueBinder(m, "DataValueContainer" );
DataValueBinder.def( "__len__", &DataValueContainer::Size );
Expand All @@ -175,6 +179,7 @@ void AddContainersToPython(pybind11::module& m)
DataValueContainerIndexingUtility< DataValueContainerBinderType, DataValueContainer, Variable<RadiationSettings::Pointer> >(DataValueBinder);
DataValueContainerIndexingUtility< DataValueContainerBinderType, DataValueContainer, Variable<Quaternion<double>> >(DataValueBinder);
DataValueContainerIndexingUtility< DataValueContainerBinderType, DataValueContainer, Variable<std::string> >(DataValueBinder);
DataValueContainerIndexingUtility< DataValueContainerBinderType, DataValueContainer, Variable<std::vector<DataValueContainer>> >(DataValueBinder);

typedef py::class_<VariablesListDataValueContainer, VariablesListDataValueContainer::Pointer> VariableDataValueContainerBinderType;
VariableDataValueContainerBinderType VariableDataValueBinder(m, "VariablesListDataValueContainer" );
Expand Down
12 changes: 12 additions & 0 deletions kratos/python/add_mesh_to_python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,12 @@ void AddMeshToPython(pybind11::module& m)
.def("SetValue", SetValueHelperFunction< Element, Variable< std::string > >)
.def("GetValue", GetValueHelperFunction< Element, Variable< std::string > >)

.def("__setitem__", SetValueHelperFunction< Element, Variable< std::vector<DataValueContainer> > >)
.def("__getitem__", GetValueHelperFunction< Element, Variable< std::vector<DataValueContainer> > >)
.def("Has", HasHelperFunction< Element, Variable< std::vector<DataValueContainer> > >)
.def("SetValue", SetValueHelperFunction< Element, Variable< std::vector<DataValueContainer> > >)
.def("GetValue", GetValueHelperFunction< Element, Variable< std::vector<DataValueContainer> > >)

.def("GetNode", GetNodeFromElement )
.def("GetNodes", GetNodesFromElement )
.def("GetIntegrationPoints", GetIntegrationPointsFromElement )
Expand Down Expand Up @@ -603,6 +609,12 @@ void AddMeshToPython(pybind11::module& m)
.def("SetValue", SetValueHelperFunction< Condition, Variable< std::string > >)
.def("GetValue", GetValueHelperFunction< Condition, Variable< std::string > >)

.def("__setitem__", SetValueHelperFunction< Condition, Variable< std::vector<DataValueContainer> > >)
.def("__getitem__", GetValueHelperFunction< Condition, Variable< std::vector<DataValueContainer> > >)
.def("Has", HasHelperFunction< Condition, Variable< std::vector<DataValueContainer> > >)
.def("SetValue", SetValueHelperFunction< Condition, Variable< std::vector<DataValueContainer> > >)
.def("GetValue", GetValueHelperFunction< Condition, Variable< std::vector<DataValueContainer> > >)

.def("GetNode", GetNodeFromCondition )
.def("GetNodes", GetNodesFromCondition )

Expand Down
1 change: 1 addition & 0 deletions kratos/python/add_node_to_python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ void AddNodeToPython(pybind11::module& m)
IndexingUtility<NodeBinderType,Node,Variable<Quaternion<double> > >(node_binder);
IndexingUtility<NodeBinderType,Node,Variable<Vector > >(node_binder);
IndexingUtility<NodeBinderType,Node,Variable<Matrix > >(node_binder);
IndexingUtility<NodeBinderType,Node,Variable<std::vector<DataValueContainer>> >(node_binder);

node_binder.def("GetBufferSize", &Node::GetBufferSize);
node_binder.def("AddDof", NodeAddDof<Variable<double> >);
Expand Down
Loading