Skip to content

Commit

Permalink
Merge pull request espressomd#3 from itischler/walberla_ekin_scriptin…
Browse files Browse the repository at this point in the history
…terface

ek boundary methods in scriptinterface
  • Loading branch information
reinaual committed Dec 7, 2021
2 parents 5696627 + 6f5311d commit 2593649
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/python/espressomd/EKSpecies.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,10 @@ def add_boundary_from_shape(self, shape,
value_flat, dtype=np.double)
cdef int[::1] raster_view = np.ascontiguousarray(
mask_flat, dtype=np.int32)
self.species.call_method("ek_update_boundary_from_shape", raster_view, value_view)
if issubclass(boundary_type, FluxBoundary):
self.species.call_method("update_flux_boundary_from_shape", raster_view, value_view)
if issubclass(boundary_type, DensityBoundary):
self.species.call_method("update_density_boundary_from_shape", raster_view, value_view)

def add_boundary_from_list(self, nodes,
value, boundary_type):
Expand Down Expand Up @@ -217,7 +220,10 @@ def add_boundary_from_list(self, nodes,
value.reshape((-1,)), dtype=np.double)
cdef int[::1] nodes_view = np.ascontiguousarray(
nodes.reshape((-1,)), dtype=np.int32)
self.species.call_method("ek_update_boundary_from_list", nodes_view, value_view)
if issubclass(boundary_type, FluxBoundary):
self.species.call_method("update_flux_boundary_from_list", nodes_view, value_view)
if issubclass(boundary_type, DensityBoundary):
self.species.call_method("update_density_boundary_from_list", nodes_view, value_view)

def get_nodes_in_shape(self, shape):
"""Provides a generator for iterating over all ek nodes inside the given shape"""
Expand Down
24 changes: 24 additions & 0 deletions src/script_interface/walberla/EKSpecies.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,30 @@ class EKSpecies : public AutoParameters<EKinWalberlaBase<double>> {
return mpi_return_one_rank(m_ekinstance->get_node_is_boundary(
get_value<Utils::Vector3i>(parameters, "position"), false));
}
if (method == "update_flux_boundary_from_shape") {
m_ekinstance->update_flux_boundary_from_shape(
get_value<std::Vector<int>>(parameters, "raster_view"),
get_value<std::Vector<double>>(parameters, "value_view"));
return none;
}
if (method == "update_density_boundary_from_shape") {
m_ekinstance->update_density_boundary_from_shape(
get_value<std::Vector<int>>(parameters, "raster_view"),
get_value<std::Vector<double>>(parameters, "value_view"));
return none;
}
if (method == "update_flux_boundary_from_list") {
m_ekinstance->update_flux_boundary_from_list(
get_value<std::Vector<int>>(parameters, "nodes_view"),
get_value<std::Vector<double>>(parameters, "value_view"));
return none;
}
if (method == "update_density_boundary_from_list") {
m_ekinstance->update_density_boundary_from_list(
get_value<std::Vector<int>>(parameters, "nodes_view"),
get_value<std::Vector<double>>(parameters, "value_view"));
return none;
}
return none;
}

Expand Down

0 comments on commit 2593649

Please sign in to comment.