From fa29a5759170a6e0c92d0d4915ee8790e190af5b Mon Sep 17 00:00:00 2001 From: Vicente Mataix Ferrandiz Date: Thu, 21 Sep 2023 17:06:25 +0200 Subject: [PATCH] [Core] Some python binding clean up (III) --- .../python/add_constitutive_law_to_python.cpp | 4 - kratos/python/add_containers_to_python.cpp | 8 +- ...add_convergence_accelerators_to_python.cpp | 6 +- .../add_data_communicator_to_python.cpp | 8 +- kratos/python/add_dem_variables_to_python.cpp | 12 +-- .../add_deprecated_variables_to_python.cpp | 12 +-- kratos/python/add_factories_to_python.cpp | 33 +++---- kratos/python/add_fsi_variables_to_python.cpp | 11 +-- kratos/python/add_io_to_python.cpp | 9 +- .../add_kratos_application_to_python.cpp | 11 +-- .../add_kratos_parameters_to_python.cpp | 8 +- .../python/add_linear_solvers_to_python.cpp | 11 +-- kratos/python/add_logger_to_python.cpp | 11 +-- kratos/python/add_mapper_to_python.cpp | 10 +-- .../add_mapping_variables_to_python.cpp | 12 +-- kratos/python/add_mat_variables_to_python.cpp | 12 +-- .../add_matrix_market_interface_to_python.cpp | 16 +--- kratos/python/add_matrix_to_python.cpp | 13 +-- .../add_mesh_moving_variables_to_python.cpp | 14 ++- kratos/python/add_model_to_python.cpp | 10 +-- kratos/python/add_modeler_to_python.cpp | 9 +- kratos/python/add_node_to_python.cpp | 86 ++++++++----------- .../python/add_other_utilities_to_python.cpp | 7 +- .../add_parallel_environment_to_python.cpp | 8 +- kratos/python/add_points_to_python.cpp | 15 +--- kratos/python/add_process_info_to_python.cpp | 12 +-- kratos/python/add_properties_to_python.cpp | 2 +- .../add_response_functions_to_python.cpp | 15 ++-- 28 files changed, 133 insertions(+), 252 deletions(-) diff --git a/kratos/python/add_constitutive_law_to_python.cpp b/kratos/python/add_constitutive_law_to_python.cpp index a7044f928bd3..66089984ba11 100644 --- a/kratos/python/add_constitutive_law_to_python.cpp +++ b/kratos/python/add_constitutive_law_to_python.cpp @@ -11,8 +11,6 @@ // Riccardo Rossi // - - // System includes // External includes @@ -26,7 +24,6 @@ #include "containers/variable.h" - namespace Kratos::Python { namespace py = pybind11; @@ -81,7 +78,6 @@ ConstitutiveLaw::DeformationGradientMatrixType& GetDeformationGradientF2(Constit ConstitutiveLaw::Pointer CreateWithoutProperties(ConstitutiveLaw& rThisConstitutiveLaw, Kratos::Parameters NewParameters){ return rThisConstitutiveLaw.Create(NewParameters);} ConstitutiveLaw::Pointer CreateWithProperties(ConstitutiveLaw& rThisConstitutiveLaw, Kratos::Parameters NewParameters, const Properties& rProperties){ return rThisConstitutiveLaw.Create(NewParameters, rProperties);} - void AddConstitutiveLawToPython(pybind11::module& m) { diff --git a/kratos/python/add_containers_to_python.cpp b/kratos/python/add_containers_to_python.cpp index 0c8c148ce87f..4af42af84a29 100644 --- a/kratos/python/add_containers_to_python.cpp +++ b/kratos/python/add_containers_to_python.cpp @@ -84,10 +84,10 @@ template< class TBinderType, typename TContainerType, typename TVariableType > v void AddContainersToPython(pybind11::module& m) { - typedef Variable > Array1DVariable3; - typedef Variable > Array1DVariable4; - typedef Variable > Array1DVariable6; - typedef Variable > Array1DVariable9; + using Array1DVariable3 = Variable >; + using Array1DVariable4 = Variable >; + using Array1DVariable6 = Variable >; + using Array1DVariable9 = Variable >; py::class_(m, "VariableData" ) .def("Name", &VariableData::Name, py::return_value_policy::copy) diff --git a/kratos/python/add_convergence_accelerators_to_python.cpp b/kratos/python/add_convergence_accelerators_to_python.cpp index 677fb651e7a0..d6557337cbb5 100644 --- a/kratos/python/add_convergence_accelerators_to_python.cpp +++ b/kratos/python/add_convergence_accelerators_to_python.cpp @@ -21,8 +21,7 @@ #include "solving_strategies/convergence_accelerators/convergence_accelerator.h" #include "spaces/ublas_space.h" -namespace Kratos { -namespace Python { +namespace Kratos::Python { void AddConvergenceAcceleratorsToPython(pybind11::module &m) { @@ -50,5 +49,4 @@ void AddConvergenceAcceleratorsToPython(pybind11::module &m) } -} // namespace Python. -} // Namespace Kratos +} // namespace Kratos::Python. diff --git a/kratos/python/add_data_communicator_to_python.cpp b/kratos/python/add_data_communicator_to_python.cpp index fe9e99cb8b58..c3518499a96f 100644 --- a/kratos/python/add_data_communicator_to_python.cpp +++ b/kratos/python/add_data_communicator_to_python.cpp @@ -21,9 +21,7 @@ #include "includes/data_communicator.h" #include "includes/parallel_environment.h" -namespace Kratos { - -namespace Python { +namespace Kratos::Python { template std::vector VectorBroadcastWrapper( @@ -172,6 +170,4 @@ void AddDataCommunicatorToPython(pybind11::module &m) .def("__str__", PrintObject); } -} // namespace Python. - -} // Namespace Kratos +} // namespace Kratos::Python. diff --git a/kratos/python/add_dem_variables_to_python.cpp b/kratos/python/add_dem_variables_to_python.cpp index 58c5bde177b5..e5e134462133 100644 --- a/kratos/python/add_dem_variables_to_python.cpp +++ b/kratos/python/add_dem_variables_to_python.cpp @@ -4,8 +4,8 @@ // _|\_\_| \__,_|\__|\___/ ____/ // 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 @@ -20,10 +20,7 @@ #include "includes/dem_variables.h" #include "python/add_dem_variables_to_python.h" -namespace Kratos -{ - -namespace Python +namespace Kratos::Python { void AddDEMVariablesToPython(pybind11::module& m) @@ -153,5 +150,4 @@ void AddDEMVariablesToPython(pybind11::module& m) KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, ENTHAPLY_ACTIVATION ) } -} // namespace Python. -} // Namespace Kratos +} // namespace Kratos::Python. diff --git a/kratos/python/add_deprecated_variables_to_python.cpp b/kratos/python/add_deprecated_variables_to_python.cpp index 125e799e279d..0182691a6d97 100644 --- a/kratos/python/add_deprecated_variables_to_python.cpp +++ b/kratos/python/add_deprecated_variables_to_python.cpp @@ -4,8 +4,8 @@ // _|\_\_| \__,_|\__|\___/ ____/ // 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 @@ -20,10 +20,7 @@ #include "python/add_deprecated_variables_to_python.h" #include "includes/deprecated_variables.h" -namespace Kratos -{ - -namespace Python +namespace Kratos::Python { void AddDeprecatedVariablesToPython(pybind11::module& m) @@ -130,5 +127,4 @@ void AddDeprecatedVariablesToPython(pybind11::module& m) KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, IS_GRAVITY_FILLING) } -} // namespace Python. -} // Namespace Kratos +} // namespace Kratos::Python. diff --git a/kratos/python/add_factories_to_python.cpp b/kratos/python/add_factories_to_python.cpp index 68933101c51b..46ef77273b77 100644 --- a/kratos/python/add_factories_to_python.cpp +++ b/kratos/python/add_factories_to_python.cpp @@ -4,8 +4,8 @@ // _|\_\_| \__,_|\__|\___/ ____/ // Multi-Physics // -// License: BSD License -// Kratos default license: kratos/license.txt +// License: BSD License +// Kratos default license: kratos/license.txt // // Main authors: Riccardo Rossi // Vicente Mataix Ferrandiz @@ -23,23 +23,20 @@ #include "factories/preconditioner_factory.h" #include "factories/register_factories.h" -namespace Kratos +namespace Kratos::Python { -namespace Python -{ - -typedef UblasSpace> SpaceType; -typedef UblasSpace LocalSpaceType; -typedef LinearSolver LinearSolverType; -typedef TUblasSparseSpace> ComplexSpaceType; -typedef TUblasDenseSpace> ComplexLocalSpaceType; +using SpaceType = UblasSpace>; +using LocalSpaceType = UblasSpace; +using LinearSolverType = LinearSolver; +using ComplexSpaceType = TUblasSparseSpace>; +using ComplexLocalSpaceType = TUblasDenseSpace>; -typedef LinearSolverFactory< SpaceType, LocalSpaceType > LinearSolverFactoryType; -typedef LinearSolverFactory< ComplexSpaceType, ComplexLocalSpaceType > ComplexLinearSolverFactoryType; -typedef PreconditionerFactory< SpaceType, LocalSpaceType > PreconditionerFactoryType; -typedef ExplicitBuilder< SpaceType, LocalSpaceType > ExplicitBuilderType; -typedef Factory< ExplicitBuilderType > ExplicitBuilderFactoryType; +using LinearSolverFactoryType = LinearSolverFactory; +using ComplexLinearSolverFactoryType = LinearSolverFactory; +using PreconditionerFactoryType = PreconditionerFactory; +using ExplicitBuilderType = ExplicitBuilder; +using ExplicitBuilderFactoryType = Factory; void AddFactoriesToPython(pybind11::module& m) { @@ -81,6 +78,4 @@ void AddFactoriesToPython(pybind11::module& m) } -} // namespace Python. - -} // Namespace Kratos +} // namespace Kratos::Python. diff --git a/kratos/python/add_fsi_variables_to_python.cpp b/kratos/python/add_fsi_variables_to_python.cpp index 044503656d1b..ae306ee77cb4 100644 --- a/kratos/python/add_fsi_variables_to_python.cpp +++ b/kratos/python/add_fsi_variables_to_python.cpp @@ -11,7 +11,6 @@ // Ruben Zorrilla // - // System includes // External includes @@ -21,14 +20,11 @@ #include "includes/fsi_variables.h" #include "python/add_fsi_variables_to_python.h" -namespace Kratos -{ - -namespace Python +namespace Kratos::Python { namespace py = pybind11; -void AddFSIVariablesToPython(pybind11::module& m) +void AddFSIVariablesToPython(pybind11::module& m) { //registering variables in python @@ -59,5 +55,4 @@ void AddFSIVariablesToPython(pybind11::module& m) KRATOS_REGISTER_IN_PYTHON_3D_VARIABLE_WITH_COMPONENTS(m,NEGATIVE_MAPPED_VECTOR_VARIABLE); } -} // namespace Python. -} // Namespace Kratos +} // namespace Kratos::Python. diff --git a/kratos/python/add_io_to_python.cpp b/kratos/python/add_io_to_python.cpp index 7c1595a9e000..1983a02a2f22 100644 --- a/kratos/python/add_io_to_python.cpp +++ b/kratos/python/add_io_to_python.cpp @@ -38,10 +38,7 @@ #include "includes/json_io.h" #endif -namespace Kratos -{ - -namespace Python +namespace Kratos::Python { void (GidIO<>::*pointer_to_io_read_single_properties)(Properties& rThisProperties ) = &IO::ReadProperties; @@ -242,8 +239,6 @@ void AddIOToPython(pybind11::module& m) vtu_output.attr("CONDITIONS") = VtuOutput::CONDITIONS; vtu_output.attr("ELEMENTS") = VtuOutput::ELEMENTS; } -} // namespace Python. - -} // Namespace Kratos +} // namespace Kratos::Python. diff --git a/kratos/python/add_kratos_application_to_python.cpp b/kratos/python/add_kratos_application_to_python.cpp index c0d68a80ec5a..f0d542c8148e 100644 --- a/kratos/python/add_kratos_application_to_python.cpp +++ b/kratos/python/add_kratos_application_to_python.cpp @@ -4,8 +4,8 @@ // _|\_\_| \__,_|\__|\___/ ____/ // 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 @@ -20,8 +20,7 @@ #include "includes/kratos_application.h" #include "python/add_kratos_application_to_python.h" -namespace Kratos { -namespace Python { +namespace Kratos::Python { namespace py = pybind11; void RegisterToPythonApplicationVariables(std::string ApplicationName) @@ -53,6 +52,4 @@ void AddKratosApplicationToPython(pybind11::module& m) { ; } -} // namespace Python. - -} // Namespace Kratos +} // namespace Kratos::Python. diff --git a/kratos/python/add_kratos_parameters_to_python.cpp b/kratos/python/add_kratos_parameters_to_python.cpp index 3d260e6c3a7a..764538651baa 100644 --- a/kratos/python/add_kratos_parameters_to_python.cpp +++ b/kratos/python/add_kratos_parameters_to_python.cpp @@ -19,9 +19,7 @@ #include "includes/kratos_parameters.h" #include "add_kratos_parameters_to_python.h" -namespace Kratos { - -namespace Python { +namespace Kratos::Python { pybind11::list items(Parameters const& self) { @@ -146,6 +144,4 @@ void AddKratosParametersToPython(pybind11::module& m) ; } -} // namespace Python. - -} // Namespace Kratos +} // namespace Kratos::Python. diff --git a/kratos/python/add_linear_solvers_to_python.cpp b/kratos/python/add_linear_solvers_to_python.cpp index 1ce7fe5f08c3..76b8f059eae3 100644 --- a/kratos/python/add_linear_solvers_to_python.cpp +++ b/kratos/python/add_linear_solvers_to_python.cpp @@ -11,12 +11,10 @@ // // - // System includes // External includes - // Project includes #include "includes/define_python.h" #include "python/add_linear_solvers_to_python.h" @@ -42,10 +40,7 @@ #include "linear_solvers/power_iteration_highest_eigenvalue_solver.h" #include "linear_solvers/rayleigh_quotient_iteration_eigenvalue_solver.h" -namespace Kratos -{ - -namespace Python +namespace Kratos::Python { template using TSpaceType = UblasSpace, boost::numeric::ublas::vector>; @@ -244,6 +239,4 @@ void AddLinearSolversToPython(pybind11::module& m) } -} // namespace Python. - -} // Namespace Kratos +} // namespace Kratos::Python. diff --git a/kratos/python/add_logger_to_python.cpp b/kratos/python/add_logger_to_python.cpp index f16843e40d2f..755b8ca1199f 100644 --- a/kratos/python/add_logger_to_python.cpp +++ b/kratos/python/add_logger_to_python.cpp @@ -4,8 +4,8 @@ // _|\_\_| \__,_|\__|\___/ ____/ // Multi-Physics // -// License: BSD License -// Kratos default license: kratos/license.txt +// License: BSD License +// Kratos default license: kratos/license.txt // // Main authors: Carlos A. Roig // @@ -20,9 +20,7 @@ #include "input_output/file_logger_output.h" #include "input_output/logger_table_output.h" - -namespace Kratos { -namespace Python { +namespace Kratos::Python { namespace py = pybind11; @@ -208,5 +206,4 @@ void AddLoggerToPython(pybind11::module& m) { .value("CHECKING", Logger::Category::CHECKING); } -} // namespace Python. -} // Namespace Kratos +} // namespace Kratos::Python. diff --git a/kratos/python/add_mapper_to_python.cpp b/kratos/python/add_mapper_to_python.cpp index 51b6253fc78a..3d5ca501ce04 100644 --- a/kratos/python/add_mapper_to_python.cpp +++ b/kratos/python/add_mapper_to_python.cpp @@ -4,8 +4,8 @@ // _|\_\_| \__,_|\__|\___/ ____/ // Multi-Physics // -// License: BSD License -// Kratos default license: kratos/license.txt +// License: BSD License +// Kratos default license: kratos/license.txt // // Main authors: Philipp Bucher (https://github.com/philbucher) @@ -17,13 +17,11 @@ #include "mappers/mapper_define.h" #include "add_mapper_to_python.h" -namespace Kratos { -namespace Python { +namespace Kratos::Python { void AddMapperToPython(pybind11::module& m) { AddMappingToPython(m); } -} // namespace Python. -} // namespace Kratos. +} // namespace Kratos::Python. diff --git a/kratos/python/add_mapping_variables_to_python.cpp b/kratos/python/add_mapping_variables_to_python.cpp index 23ae0ca25392..2ffd52df0ec4 100644 --- a/kratos/python/add_mapping_variables_to_python.cpp +++ b/kratos/python/add_mapping_variables_to_python.cpp @@ -4,8 +4,8 @@ // _|\_\_| \__,_|\__|\___/ ____/ // Multi-Physics // -// License: BSD License -// Kratos default license: kratos/license.txt +// License: BSD License +// Kratos default license: kratos/license.txt // // Main authors: Vicente Mataix Ferrandiz // @@ -19,10 +19,7 @@ #include "includes/mapping_variables.h" #include "python/add_mapping_variables_to_python.h" -namespace Kratos -{ - -namespace Python +namespace Kratos::Python { namespace py = pybind11; @@ -30,6 +27,5 @@ namespace Python { KRATOS_REGISTER_IN_PYTHON_VARIABLE(m,TANGENT_FACTOR) } -} // namespace Python. -} // Namespace Kratos +} // namespace Kratos::Python. diff --git a/kratos/python/add_mat_variables_to_python.cpp b/kratos/python/add_mat_variables_to_python.cpp index 664ecf4124a6..4fc9ab6d92f6 100644 --- a/kratos/python/add_mat_variables_to_python.cpp +++ b/kratos/python/add_mat_variables_to_python.cpp @@ -7,15 +7,13 @@ // License: BSD License // Kratos default license: kratos/license.txt // -// Main authors: Josep Maria Carbonell +// Main authors: Josep Maria Carbonell // - // System includes // External includes - // Project includes #include "includes/define_python.h" #include "includes/variables.h" @@ -24,11 +22,8 @@ //commented variables are registered in add_containers_to_python.cpp -namespace Kratos +namespace Kratos::Python { - - namespace Python - { namespace py = pybind11; void AddMATVariablesToPython(pybind11::module& m) @@ -151,7 +146,6 @@ namespace Kratos KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, INITIAL_STRESS_VECTOR ) KRATOS_REGISTER_IN_PYTHON_VARIABLE(m, INITIAL_DEFORMATION_GRADIENT_MATRIX ) } - } // namespace Python. -} // Namespace Kratos +} // Namespace Kratos::Python. diff --git a/kratos/python/add_matrix_market_interface_to_python.cpp b/kratos/python/add_matrix_market_interface_to_python.cpp index 9e19c707a170..9c78d2ca21fd 100644 --- a/kratos/python/add_matrix_market_interface_to_python.cpp +++ b/kratos/python/add_matrix_market_interface_to_python.cpp @@ -4,15 +4,13 @@ // _|\_\_| \__,_|\__|\___/ ____/ // 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 @@ -24,14 +22,10 @@ #include "includes/ublas_complex_interface.h" #include "python/add_matrix_market_interface_to_python.h" -namespace Kratos -{ - -namespace Python +namespace Kratos::Python { void AddMatrixMarketInterfaceToPython(pybind11::module& m) { - namespace py = pybind11; m.def("ReadMatrixMarketMatrix", ReadMatrixMarketMatrix ); @@ -46,7 +40,5 @@ void AddMatrixMarketInterfaceToPython(pybind11::module& m) } -} // namespace Python. - -} // Namespace Kratos +} // namespace Kratos::Python. diff --git a/kratos/python/add_matrix_to_python.cpp b/kratos/python/add_matrix_to_python.cpp index d2a0575081d2..2af4850c8134 100644 --- a/kratos/python/add_matrix_to_python.cpp +++ b/kratos/python/add_matrix_to_python.cpp @@ -4,13 +4,12 @@ // _|\_\_| \__,_|\__|\___/ ____/ // Multi-Physics // -// License: BSD License -// Kratos default license: kratos/license.txt +// License: BSD License +// Kratos default license: kratos/license.txt // // Main authors: Pooyan Dadvand // - // System includes // External includes @@ -23,9 +22,7 @@ #include "add_matrix_to_python.h" #include "containers/array_1d.h" -namespace Kratos -{ -namespace Python +namespace Kratos::Python { namespace py = pybind11; @@ -228,7 +225,5 @@ namespace Python } -} // namespace Python. - -} // Namespace Kratos +} // namespace Kratos::Python. diff --git a/kratos/python/add_mesh_moving_variables_to_python.cpp b/kratos/python/add_mesh_moving_variables_to_python.cpp index 276210609933..9172e4f06ac5 100644 --- a/kratos/python/add_mesh_moving_variables_to_python.cpp +++ b/kratos/python/add_mesh_moving_variables_to_python.cpp @@ -4,10 +4,10 @@ // _|\_\_| \__,_|\__|\___/ ____/ // Multi-Physics // -// License: BSD License -// Kratos default license: kratos/license.txt +// License: BSD License +// Kratos default license: kratos/license.txt // -// Main authors: msandre +// Main authors: Michael Andre // // System includes @@ -19,10 +19,7 @@ #include "includes/mesh_moving_variables.h" #include "python/add_mesh_moving_variables_to_python.h" -namespace Kratos -{ - -namespace Python +namespace Kratos::Python { namespace py = pybind11; @@ -37,5 +34,4 @@ namespace Python KRATOS_REGISTER_IN_PYTHON_VARIABLE(m,MESH_POISSON_RATIO) } -} // namespace Python. -} // Namespace Kratos +} // namespace Kratos::Python. diff --git a/kratos/python/add_model_to_python.cpp b/kratos/python/add_model_to_python.cpp index 462a4e785740..11739912fb0d 100644 --- a/kratos/python/add_model_to_python.cpp +++ b/kratos/python/add_model_to_python.cpp @@ -4,8 +4,8 @@ // _|\_\_| \__,_|\__|\___/ ____/ // Multi-Physics // -// License: BSD License -// Kratos default license: kratos/license.txt +// License: BSD License +// Kratos default license: kratos/license.txt // // Main authors: Riccardo Rossi // Pooyan Dadvand @@ -20,8 +20,7 @@ #include "containers/model.h" #include "python/add_model_to_python.h" -namespace Kratos { -namespace Python { +namespace Kratos::Python { ModelPart& Model_GetModelPart(Model& rModel, const std::string& rFullModelPartName) { @@ -44,5 +43,4 @@ void AddModelToPython(pybind11::module& m) .def("__str__", PrintObject); } -} // namespace Python. -} // Namespace Kratos +} // namespace Kratos::Python. diff --git a/kratos/python/add_modeler_to_python.cpp b/kratos/python/add_modeler_to_python.cpp index 0feb33f4115f..3ca8ca5bc200 100644 --- a/kratos/python/add_modeler_to_python.cpp +++ b/kratos/python/add_modeler_to_python.cpp @@ -26,10 +26,7 @@ #include "modeler/copy_properties_modeler.h" #include "modeler/combine_model_part_modeler.h" -namespace Kratos -{ - -namespace Python +namespace Kratos::Python { namespace py = pybind11; @@ -111,6 +108,4 @@ void AddModelerToPython(pybind11::module& m) } -} // namespace Python. - -} // Namespace Kratos +} // namespace Kratos::Python. \ No newline at end of file diff --git a/kratos/python/add_node_to_python.cpp b/kratos/python/add_node_to_python.cpp index 4db322e665fd..11a621184e46 100644 --- a/kratos/python/add_node_to_python.cpp +++ b/kratos/python/add_node_to_python.cpp @@ -4,8 +4,8 @@ // _|\_\_| \__,_|\__|\___/ ____/ // Multi-Physics // -// License: BSD License -// Kratos default license: kratos/license.txt +// License: BSD License +// Kratos default license: kratos/license.txt // // Main authors: Pooyan Dadvand // @@ -24,83 +24,79 @@ #include "python/containers_interface.h" #include "python/add_mesh_to_python.h" -namespace Kratos -{ -namespace Python +namespace Kratos::Python { namespace py = pybind11; -typedef Node NodeType; - template inline -void NodeFix(NodeType& rThisNode, TVariableType const& rThisVariable) +void NodeFix(Node& rThisNode, TVariableType const& rThisVariable) { rThisNode.Fix(rThisVariable); } template inline -void NodeFree(NodeType& rThisNode, TVariableType const& rThisVariable) +void NodeFree(Node& rThisNode, TVariableType const& rThisVariable) { rThisNode.Free(rThisVariable); } template inline -bool NodeIsFixed(NodeType& rThisNode, TVariableType const& rThisVariable) +bool NodeIsFixed(Node& rThisNode, TVariableType const& rThisVariable) { return rThisNode.IsFixed(rThisVariable); } template inline -bool NodeHasDofFor(NodeType& rThisNode, TVariableType const& rThisVariable) +bool NodeHasDofFor(Node& rThisNode, TVariableType const& rThisVariable) { return rThisNode.HasDofFor(rThisVariable); } template inline -void NodeAddDof(NodeType& rThisNode, TVariableType const& rThisVariable) +void NodeAddDof(Node& rThisNode, TVariableType const& rThisVariable) { rThisNode.pAddDof(rThisVariable); } template inline -void NodeAddDofwithReaction(NodeType& rThisNode, TVariableType const& rThisVariable, TVariableType const& rReactionVariable) +void NodeAddDofwithReaction(Node& rThisNode, TVariableType const& rThisVariable, TVariableType const& rReactionVariable) { // KRATOS_WATCH(rReactionVariable); rThisNode.pAddDof(rThisVariable, rReactionVariable); } template -bool NodeSolutionStepsDataHas(NodeType& rThisNode, const TVariableType& rThisVariable) +bool NodeSolutionStepsDataHas(Node& rThisNode, const TVariableType& rThisVariable) { return rThisNode.SolutionStepsDataHas(rThisVariable); } -void PointSetX0(NodeType& ThisPoint, double Value) +void PointSetX0(Node& ThisPoint, double Value) { ThisPoint.X0() = Value; } -void PointSetY0(NodeType& ThisPoint, double Value) +void PointSetY0(Node& ThisPoint, double Value) { ThisPoint.Y0() = Value; } -void PointSetZ0(NodeType& ThisPoint, double Value) +void PointSetZ0(Node& ThisPoint, double Value) { ThisPoint.Z0() = Value; } -double PointGetX0(NodeType& ThisPoint) +double PointGetX0(Node& ThisPoint) { return ThisPoint.X0(); } -double PointGetY0(NodeType& ThisPoint) +double PointGetY0(Node& ThisPoint) { return ThisPoint.Y0(); } -double PointGetZ0(NodeType& ThisPoint) +double PointGetZ0(Node& ThisPoint) { return ThisPoint.Z0(); } @@ -130,38 +126,34 @@ template< class TBinderType, typename TContainerType, typename TVariableType > v void AddNodeToPython(pybind11::module& m) { - typedef Mesh MeshType; - - typedef MeshType::NodeType NodeType; - + using MeshType = Mesh; py::class_(m,"IndexedObject") .def_property("Id", &IndexedObject::GetId, &IndexedObject::SetId) .def("__str__", PrintObject) ; - - typedef py::class_ NodeBinderType; + typedef py::class_ NodeBinderType; NodeBinderType node_binder(m,"Node"); - node_binder.def(py::init()); - node_binder.def(py::init()); - - IndexingUtility >(node_binder); - IndexingUtility >(node_binder); - IndexingUtility >(node_binder); - IndexingUtility > >(node_binder); - IndexingUtility > >(node_binder); - IndexingUtility > >(node_binder); - IndexingUtility > >(node_binder); - IndexingUtility > >(node_binder); - IndexingUtility >(node_binder); - IndexingUtility >(node_binder); - - node_binder.def("GetBufferSize", &NodeType::GetBufferSize); + node_binder.def(py::init()); + node_binder.def(py::init()); + + IndexingUtility >(node_binder); + IndexingUtility >(node_binder); + IndexingUtility >(node_binder); + IndexingUtility > >(node_binder); + IndexingUtility > >(node_binder); + IndexingUtility > >(node_binder); + IndexingUtility > >(node_binder); + IndexingUtility > >(node_binder); + IndexingUtility >(node_binder); + IndexingUtility >(node_binder); + + node_binder.def("GetBufferSize", &Node::GetBufferSize); node_binder.def("AddDof", NodeAddDof >); node_binder.def("AddDof", NodeAddDofwithReaction >); node_binder.def("GetDof", - [](const NodeType& rNode, const Variable& rVar) -> NodeType::DofType& {return *rNode.pGetDof(rVar); } + [](const Node& rNode, const Variable& rVar) -> Node::DofType& {return *rNode.pGetDof(rVar); } ,py::return_value_policy::reference_internal ); node_binder.def("Fix", NodeFix >); @@ -177,18 +169,16 @@ void AddNodeToPython(pybind11::module& m) node_binder.def("SolutionStepsDataHas", &NodeSolutionStepsDataHas > >); node_binder.def("SolutionStepsDataHas", &NodeSolutionStepsDataHas >); node_binder.def("SolutionStepsDataHas", &NodeSolutionStepsDataHas > >); - node_binder.def("__str__", PrintObject); - node_binder.def("OverwriteSolutionStepData", &NodeType::OverwriteSolutionStepData); + node_binder.def("__str__", PrintObject); + node_binder.def("OverwriteSolutionStepData", &Node::OverwriteSolutionStepData); node_binder.def_property("X0", PointGetX0, PointSetX0); node_binder.def_property("Y0", PointGetY0, PointSetY0); node_binder.def_property("Z0", PointGetZ0, PointSetZ0); - node_binder.def_property("Id", &NodeType::GetId, &NodeType::SetId); + node_binder.def_property("Id", &Node::GetId, &Node::SetId); PointerVectorSetPythonInterface().CreateInterface(m,"NodesArray"); } -} // namespace Python. - -} // Namespace Kratos +} // namespace Kratos::Python. diff --git a/kratos/python/add_other_utilities_to_python.cpp b/kratos/python/add_other_utilities_to_python.cpp index 22806d8e3dbf..a36819f83974 100644 --- a/kratos/python/add_other_utilities_to_python.cpp +++ b/kratos/python/add_other_utilities_to_python.cpp @@ -11,7 +11,6 @@ // Main authors: Riccardo Rossi // - // System includes #include @@ -70,8 +69,7 @@ #include "utilities/string_utilities.h" #include "utilities/model_part_operation_utilities.h" -namespace Kratos { -namespace Python { +namespace Kratos::Python { /** * @brief A thin wrapper for GetSortedListOfFileNameData. The reason for having the wrapper is to replace the original lambda implementation as it causes gcc 4.8 to generate bad code on Centos7 which leads to memory corruption. @@ -824,5 +822,4 @@ void AddOtherUtilitiesToPython(pybind11::module &m) } -} // namespace Python. -} // Namespace Kratos +} // namespace Kratos::Python. diff --git a/kratos/python/add_parallel_environment_to_python.cpp b/kratos/python/add_parallel_environment_to_python.cpp index b8a0372a7e12..e69f0f9874e4 100644 --- a/kratos/python/add_parallel_environment_to_python.cpp +++ b/kratos/python/add_parallel_environment_to_python.cpp @@ -18,9 +18,7 @@ #include "add_parallel_environment_to_python.h" #include "includes/parallel_environment.h" -namespace Kratos { - -namespace Python { +namespace Kratos::Python { void AddParallelEnvironmentToPython(pybind11::module &m) { @@ -54,6 +52,4 @@ void AddParallelEnvironmentToPython(pybind11::module &m) }); } -} // namespace Python. - -} // Namespace Kratos +} // namespace Kratos::Python. diff --git a/kratos/python/add_points_to_python.cpp b/kratos/python/add_points_to_python.cpp index f1a9a193b989..cfe1b959ddca 100644 --- a/kratos/python/add_points_to_python.cpp +++ b/kratos/python/add_points_to_python.cpp @@ -4,13 +4,12 @@ // _|\_\_| \__,_|\__|\___/ ____/ // Multi-Physics // -// License: BSD License -// Kratos default license: kratos/license.txt +// License: BSD License +// Kratos default license: kratos/license.txt // // Main authors: Riccardo Rossi // - // System includes // External includes @@ -20,11 +19,7 @@ #include "geometries/point.h" #include "python/add_points_to_python.h" - -namespace Kratos -{ - -namespace Python +namespace Kratos::Python { template inline void PointSetX(TPointType& ThisPoint, double Value) @@ -77,7 +72,5 @@ void AddPointsToPython(pybind11::module& m) ; } -} // namespace Python. - -} // Namespace Kratos +} // namespace Kratos::Python. diff --git a/kratos/python/add_process_info_to_python.cpp b/kratos/python/add_process_info_to_python.cpp index 3ae9921e92aa..968d4efdebff 100644 --- a/kratos/python/add_process_info_to_python.cpp +++ b/kratos/python/add_process_info_to_python.cpp @@ -4,8 +4,8 @@ // _|\_\_| \__,_|\__|\___/ ____/ // Multi-Physics // -// License: BSD License -// Kratos default license: kratos/license.txt +// License: BSD License +// Kratos default license: kratos/license.txt // // Main authors: Pooyan Dadvand // @@ -19,10 +19,7 @@ #include "includes/process_info.h" #include "python/add_process_info_to_python.h" -namespace Kratos -{ - -namespace Python +namespace Kratos::Python { ProcessInfo::Pointer ProcessInfoGetPreviousSolutionStepInfo(ProcessInfo& rProcessInfo) @@ -49,6 +46,5 @@ void AddProcessInfoToPython(pybind11::module& m) ; } -} // namespace Python. -} // Namespace Kratos +} // namespace Kratos::Python. diff --git a/kratos/python/add_properties_to_python.cpp b/kratos/python/add_properties_to_python.cpp index 5c3cc94c7542..3db5acf8d5b9 100644 --- a/kratos/python/add_properties_to_python.cpp +++ b/kratos/python/add_properties_to_python.cpp @@ -5,7 +5,7 @@ // Multi-Physics // // License: BSD License -// Kratos default license: kratos/license.txt +// Kratos default license: kratos/license.txt // // Main authors: Pooyan Dadvand // Riccardo Rossi diff --git a/kratos/python/add_response_functions_to_python.cpp b/kratos/python/add_response_functions_to_python.cpp index e8f68c0391d7..961b2f170504 100644 --- a/kratos/python/add_response_functions_to_python.cpp +++ b/kratos/python/add_response_functions_to_python.cpp @@ -4,10 +4,10 @@ // _|\_\_| \__,_|\__|\___/ ____/ // Multi-Physics // -// License: BSD License -// Kratos default license: kratos/license.txt +// License: BSD License +// Kratos default license: kratos/license.txt // -// Main authors: +// Main authors: Michael Andre // // System includes @@ -20,10 +20,7 @@ #include "response_functions/adjoint_response_function.h" #include "includes/model_part.h" -namespace Kratos -{ - -namespace Python +namespace Kratos::Python { class PyAdjointResponseFunction : public AdjointResponseFunction @@ -69,6 +66,4 @@ void AddResponseFunctionsToPython(pybind11::module& m) ; } -} // namespace Python. - -} // Namespace Kratos +} // namespace Kratos::Python.