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

Add identifiable Python include directory name for Python wrappers #3608

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
12 changes: 0 additions & 12 deletions python/dolfinx/wrappers/__init__.py

This file was deleted.

31 changes: 16 additions & 15 deletions python/dolfinx/wrappers/assemble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "array.h"
#include "pycoeff.h"
#include "dolfinx_wrappers/array.h"
#include "dolfinx_wrappers/pycoeff.h"
#include <array>
#include <complex>
#include <cstdint>
Expand Down Expand Up @@ -229,7 +229,7 @@ void declare_assembly_functions(nb::module_& m)
{
return dolfinx::fem::assemble_scalar<T>(
M, std::span(constants.data(), constants.size()),
py_to_cpp_coeffs(coefficients));
dolfinx_wrappers::py_to_cpp_coeffs(coefficients));
},
nb::arg("M"), nb::arg("constants"), nb::arg("coefficients"),
"Assemble functional over mesh with provided constants and "
Expand All @@ -247,7 +247,7 @@ void declare_assembly_functions(nb::module_& m)
dolfinx::fem::assemble_vector<T>(
std::span(b.data(), b.size()), L,
std::span(constants.data(), constants.size()),
py_to_cpp_coeffs(coefficients));
dolfinx_wrappers::py_to_cpp_coeffs(coefficients));
},
nb::arg("b"), nb::arg("L"), nb::arg("constants"), nb::arg("coeffs"),
"Assemble linear form into an existing vector with pre-packed constants "
Expand Down Expand Up @@ -288,63 +288,63 @@ void declare_assembly_functions(nb::module_& m)
dolfinx::fem::assemble_matrix(
A.mat_add_values(), a,
std::span<const T>(constants.data(), constants.size()),
py_to_cpp_coeffs(coefficients), _bcs);
dolfinx_wrappers::py_to_cpp_coeffs(coefficients), _bcs);
}
else if (data_bs[0] == 2)
{
auto mat_add = A.template mat_add_values<2, 2>();
dolfinx::fem::assemble_matrix(
mat_add, a, std::span(constants.data(), constants.size()),
py_to_cpp_coeffs(coefficients), _bcs);
dolfinx_wrappers::py_to_cpp_coeffs(coefficients), _bcs);
}
else if (data_bs[0] == 3)
{
auto mat_add = A.template mat_add_values<3, 3>();
dolfinx::fem::assemble_matrix(
mat_add, a, std::span(constants.data(), constants.size()),
py_to_cpp_coeffs(coefficients), _bcs);
dolfinx_wrappers::py_to_cpp_coeffs(coefficients), _bcs);
}
else if (data_bs[0] == 4)
{
auto mat_add = A.template mat_add_values<4, 4>();
dolfinx::fem::assemble_matrix(
mat_add, a, std::span(constants.data(), constants.size()),
py_to_cpp_coeffs(coefficients), _bcs);
dolfinx_wrappers::py_to_cpp_coeffs(coefficients), _bcs);
}
else if (data_bs[0] == 5)
{
auto mat_add = A.template mat_add_values<5, 5>();
dolfinx::fem::assemble_matrix(
mat_add, a, std::span(constants.data(), constants.size()),
py_to_cpp_coeffs(coefficients), _bcs);
dolfinx_wrappers::py_to_cpp_coeffs(coefficients), _bcs);
}
else if (data_bs[0] == 6)
{
auto mat_add = A.template mat_add_values<6, 6>();
dolfinx::fem::assemble_matrix(
mat_add, a, std::span(constants.data(), constants.size()),
py_to_cpp_coeffs(coefficients), _bcs);
dolfinx_wrappers::py_to_cpp_coeffs(coefficients), _bcs);
}
else if (data_bs[0] == 7)
{
auto mat_add = A.template mat_add_values<7, 7>();
dolfinx::fem::assemble_matrix(
mat_add, a, std::span(constants.data(), constants.size()),
py_to_cpp_coeffs(coefficients), _bcs);
dolfinx_wrappers::py_to_cpp_coeffs(coefficients), _bcs);
}
else if (data_bs[0] == 8)
{
auto mat_add = A.template mat_add_values<8, 8>();
dolfinx::fem::assemble_matrix(
mat_add, a, std::span(constants.data(), constants.size()),
py_to_cpp_coeffs(coefficients), _bcs);
dolfinx_wrappers::py_to_cpp_coeffs(coefficients), _bcs);
}
else if (data_bs[0] == 9)
{
auto mat_add = A.template mat_add_values<9, 9>();
dolfinx::fem::assemble_matrix(
mat_add, a, std::span(constants.data(), constants.size()),
py_to_cpp_coeffs(coefficients), _bcs);
dolfinx_wrappers::py_to_cpp_coeffs(coefficients), _bcs);
}
else
throw std::runtime_error("Block size not supported in Python");
Expand Down Expand Up @@ -468,8 +468,9 @@ void declare_assembly_functions(nb::module_& m)
std::vector<std::map<std::pair<dolfinx::fem::IntegralType, int>,
std::pair<std::span<const T>, int>>>
_coeffs;
std::ranges::transform(coeffs, std::back_inserter(_coeffs),
[](auto& c) { return py_to_cpp_coeffs(c); });
std::ranges::transform(
coeffs, std::back_inserter(_coeffs),
[](auto& c) { return dolfinx_wrappers::py_to_cpp_coeffs(c); });

dolfinx::fem::apply_lifting<T>(std::span<T>(b.data(), b.size()), _a,
_constants, _coeffs, _bcs, _x0, alpha);
Expand Down
6 changes: 3 additions & 3 deletions python/dolfinx/wrappers/common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "MPICommWrapper.h"
#include "array.h"
#include "caster_mpi.h"
#include "dolfinx_wrappers/MPICommWrapper.h"
#include "dolfinx_wrappers/array.h"
#include "dolfinx_wrappers/caster_mpi.h"
#include <complex>
#include <dolfinx/common/IndexMap.h>
#include <dolfinx/common/Scatterer.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#include <nanobind/ndarray.h>
#include <span>

namespace dolfinx_wrappers
{
template <typename T>
std::map<std::pair<dolfinx::fem::IntegralType, int>,
std::pair<std::span<const T>, int>>
Expand All @@ -30,3 +32,4 @@ py_to_cpp_coeffs(
});
return c;
}
} // namespace dolfinx_wrappers
6 changes: 3 additions & 3 deletions python/dolfinx/wrappers/fem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "array.h"
#include "caster_mpi.h"
#include "numpy_dtype.h"
#include "dolfinx_wrappers/array.h"
#include "dolfinx_wrappers/caster_mpi.h"
#include "dolfinx_wrappers/numpy_dtype.h"
#include <array>
#include <cstdint>
#include <dolfinx/common/IndexMap.h>
Expand Down
4 changes: 2 additions & 2 deletions python/dolfinx/wrappers/geometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "array.h"
#include "caster_mpi.h"
#include "dolfinx_wrappers/array.h"
#include "dolfinx_wrappers/caster_mpi.h"
#include <array>
#include <dolfinx/common/utils.h>
#include <dolfinx/geometry/BoundingBoxTree.h>
Expand Down
2 changes: 1 addition & 1 deletion python/dolfinx/wrappers/graph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "caster_mpi.h"
#include "dolfinx_wrappers/caster_mpi.h"
#include <array>
#include <dolfinx/graph/AdjacencyList.h>
#include <dolfinx/graph/ordering.h>
Expand Down
4 changes: 2 additions & 2 deletions python/dolfinx/wrappers/io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "array.h"
#include "caster_mpi.h"
#include "dolfinx_wrappers/array.h"
#include "dolfinx_wrappers/caster_mpi.h"
#include <basix/mdspan.hpp>
#include <dolfinx/common/defines.h>
#include <dolfinx/fem/Function.h>
Expand Down
6 changes: 3 additions & 3 deletions python/dolfinx/wrappers/la.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "array.h"
#include "caster_mpi.h"
#include "numpy_dtype.h"
#include "dolfinx_wrappers/array.h"
#include "dolfinx_wrappers/caster_mpi.h"
#include "dolfinx_wrappers/numpy_dtype.h"
#include <complex>
#include <cstdint>
#include <dolfinx/common/IndexMap.h>
Expand Down
10 changes: 5 additions & 5 deletions python/dolfinx/wrappers/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "mesh.h"
#include "MPICommWrapper.h"
#include "array.h"
#include "caster_mpi.h"
#include "numpy_dtype.h"
#include "dolfinx_wrappers/mesh.h"
#include "dolfinx_wrappers/MPICommWrapper.h"
#include "dolfinx_wrappers/array.h"
#include "dolfinx_wrappers/caster_mpi.h"
#include "dolfinx_wrappers/numpy_dtype.h"
#include <dolfinx/common/IndexMap.h>
#include <dolfinx/fem/CoordinateElement.h>
#include <dolfinx/fem/ElementDofLayout.h>
Expand Down
14 changes: 7 additions & 7 deletions python/dolfinx/wrappers/petsc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

#if defined(HAS_PETSC) && defined(HAS_PETSC4PY)

#include "array.h"
#include "caster_mpi.h"
#include "caster_petsc.h"
#include "pycoeff.h"
#include "dolfinx_wrappers/array.h"
#include "dolfinx_wrappers/caster_mpi.h"
#include "dolfinx_wrappers/caster_petsc.h"
#include "dolfinx_wrappers/pycoeff.h"
#include <concepts>
#include <dolfinx/common/IndexMap.h>
#include <dolfinx/fem/DirichletBC.h>
Expand Down Expand Up @@ -333,14 +333,14 @@ void petsc_fem_module(nb::module_& m)
a.function_spaces()[1]->dofmap()->bs(), ADD_VALUES);
dolfinx::fem::assemble_matrix(
set_fn, a, std::span(constants.data(), constants.size()),
py_to_cpp_coeffs(coefficients), _bcs);
dolfinx_wrappers::py_to_cpp_coeffs(coefficients), _bcs);
}
else
{
dolfinx::fem::assemble_matrix(
dolfinx::la::petsc::Matrix::set_block_fn(A, ADD_VALUES), a,
std::span(constants.data(), constants.size()),
py_to_cpp_coeffs(coefficients), _bcs);
dolfinx_wrappers::py_to_cpp_coeffs(coefficients), _bcs);
}
},
nb::arg("A"), nb::arg("a"), nb::arg("constants"), nb::arg("coeffs"),
Expand Down Expand Up @@ -372,7 +372,7 @@ void petsc_fem_module(nb::module_& m)

dolfinx::fem::assemble_matrix(
set_fn, a, std::span(constants.data(), constants.size()),
py_to_cpp_coeffs(coefficients),
dolfinx_wrappers::py_to_cpp_coeffs(coefficients),
std::span(rows0.data(), rows0.size()),
std::span(rows1.data(), rows1.size()));
},
Expand Down
6 changes: 3 additions & 3 deletions python/dolfinx/wrappers/refinement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
//
// SPDX-License-Identifier: LGPL-3.0-or-later

#include "MPICommWrapper.h"
#include "array.h"
#include "mesh.h"
#include "dolfinx_wrappers/MPICommWrapper.h"
#include "dolfinx_wrappers/array.h"
#include "dolfinx_wrappers/mesh.h"
#include <concepts>
#include <cstdint>
#include <dolfinx/mesh/Mesh.h>
Expand Down
Loading