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] Some python binding clean up (II) #11585

Merged
merged 2 commits into from
Sep 21, 2023
Merged
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
16 changes: 4 additions & 12 deletions kratos/python/add_cfd_variables_to_python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,30 +4,23 @@
// _|\_\_| \__,_|\__|\___/ ____/
// Multi-Physics
//
// License: BSD License
// Kratos default license: kratos/license.txt
// License: BSD License
// Kratos default license: kratos/license.txt
//
// Main authors: Pooyan Dadvand
// Riccardo Rossi
//



// System includes

// External includes


// Project includes
#include "includes/define_python.h"
#include "includes/cfd_variables.h"
#include "python/add_cfd_variables_to_python.h"

namespace Kratos
{
//KRATOS_CREATE_FLAG(STRUCTURE, 63);

namespace Python
namespace Kratos::Python
{
namespace py = pybind11;

Expand Down Expand Up @@ -63,6 +56,5 @@ namespace Python
KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, CROSS_WIND_STABILIZATION_FACTOR );

}
} // namespace Python.
} // Namespace Kratos
} // namespace Kratos::Python.

54 changes: 9 additions & 45 deletions kratos/python/add_communicator_to_python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,43 +19,8 @@
#include "add_communicator_to_python.h"
#include "includes/communicator.h"

namespace Kratos {
namespace Python {

Communicator::MeshType& CommunicatorGetLocalMesh(Communicator& rCommunicator)
{
return rCommunicator.LocalMesh();
}

Communicator::MeshType& CommunicatorGetLocalMeshWithIndex(Communicator& rCommunicator, Communicator::IndexType Index)
{
return rCommunicator.LocalMesh(Index);
}

Communicator::MeshType& CommunicatorGetGhostMesh(Communicator& rCommunicator)
{
return rCommunicator.GhostMesh();
}

Communicator::MeshType& CommunicatorGetGhostMeshWithIndex(Communicator& rCommunicator, Communicator::IndexType Index)
namespace Kratos::Python
{
return rCommunicator.GhostMesh(Index);
}

Communicator::MeshType& CommunicatorGetInterfaceMesh(Communicator& rCommunicator)
{
return rCommunicator.InterfaceMesh();
}

Communicator::MeshType& CommunicatorGetInterfaceMeshWithIndex(Communicator& rCommunicator, Communicator::IndexType Index)
{
return rCommunicator.InterfaceMesh(Index);
}

Communicator::NeighbourIndicesContainerType const& NeighbourIndicesConst(Communicator& rCommunicator)
{
return rCommunicator.NeighbourIndices();
}

template<class TDataType>
bool CommunicatorSynchronizeVariable(Communicator& rCommunicator, Variable<TDataType> const& ThisVariable)
Expand Down Expand Up @@ -94,18 +59,18 @@ void AddCommunicatorToPython(pybind11::module &m)
.def("GlobalNumberOfConditions", &Communicator::GlobalNumberOfConditions)
.def("GlobalNumberOfMasterSlaveConstraints", &Communicator::GlobalNumberOfMasterSlaveConstraints)
.def("GetNumberOfColors", &Communicator::GetNumberOfColors)
.def("NeighbourIndices", NeighbourIndicesConst, py::return_value_policy::reference_internal)
.def("NeighbourIndices", [](Communicator& rCommunicator){return rCommunicator.NeighbourIndices();}, py::return_value_policy::reference_internal )
.def("SynchronizeNodalSolutionStepsData", &Communicator::SynchronizeNodalSolutionStepsData)
.def("SynchronizeNodalFlags", &Communicator::SynchronizeNodalFlags)
.def("SynchronizeOrNodalFlags", &Communicator::SynchronizeOrNodalFlags)
.def("SynchronizeAndNodalFlags", &Communicator::SynchronizeAndNodalFlags)
.def("SynchronizeDofs", &Communicator::SynchronizeDofs)
.def("LocalMesh", CommunicatorGetLocalMesh, py::return_value_policy::reference_internal )
.def("LocalMesh", CommunicatorGetLocalMeshWithIndex, py::return_value_policy::reference_internal )
.def("GhostMesh", CommunicatorGetGhostMesh, py::return_value_policy::reference_internal )
.def("GhostMesh", CommunicatorGetGhostMeshWithIndex, py::return_value_policy::reference_internal )
.def("InterfaceMesh", CommunicatorGetInterfaceMesh, py::return_value_policy::reference_internal )
.def("InterfaceMesh", CommunicatorGetInterfaceMeshWithIndex, py::return_value_policy::reference_internal )
.def("LocalMesh", [](Communicator& rCommunicator){return rCommunicator.LocalMesh();}, py::return_value_policy::reference_internal )
loumalouomega marked this conversation as resolved.
Show resolved Hide resolved
.def("LocalMesh", [](Communicator& rCommunicator, Communicator::IndexType Index){return rCommunicator.LocalMesh(Index);}, py::return_value_policy::reference_internal )
.def("GhostMesh", [](Communicator& rCommunicator){return rCommunicator.GhostMesh();}, py::return_value_policy::reference_internal )
.def("GhostMesh", [](Communicator& rCommunicator, Communicator::IndexType Index){return rCommunicator.GhostMesh(Index);}, py::return_value_policy::reference_internal )
.def("InterfaceMesh", [](Communicator& rCommunicator){return rCommunicator.InterfaceMesh();}, py::return_value_policy::reference_internal )
.def("InterfaceMesh", [](Communicator& rCommunicator, Communicator::IndexType Index){return rCommunicator.InterfaceMesh(Index);}, py::return_value_policy::reference_internal )
.def("GetDataCommunicator", &Communicator::GetDataCommunicator, py::return_value_policy::reference_internal )
.def("SynchronizeVariable", CommunicatorSynchronizeVariable<int> )
.def("SynchronizeVariable", CommunicatorSynchronizeVariable<double> )
Expand All @@ -131,5 +96,4 @@ void AddCommunicatorToPython(pybind11::module &m)
;
}

} // namespace Python.
} // Namespace Kratos
} // namespace Kratos::Python.
Loading