Skip to content
Snippets Groups Projects
Commit 39e6ebd3 authored by Dr. Felix Tobias Schindler's avatar Dr. Felix Tobias Schindler
Browse files

[P|tools.adaptation] allow to keep track of refined elements

parent b93f6f6f
No related branches found
No related tags found
No related merge requests found
Pipeline #64893 failed
...@@ -61,19 +61,11 @@ public: ...@@ -61,19 +61,11 @@ public:
GDT::FiniteVolumeSpace<GV, r, rC> marker_indices; GDT::FiniteVolumeSpace<GV, r, rC> marker_indices;
XT::LA::CommonDenseVector<size_t> markers; XT::LA::CommonDenseVector<size_t> markers;
G& grid() // expose access for mark() below G& grid() // expose access for bindings below
{ {
return this->grid_; return this->grid_;
} }
void post_adapt(const bool post_adapt_grid = true, const bool clear = false)
{
BaseType::post_adapt(post_adapt_grid, clear);
this->marker_indices.update_after_adapt();
this->markers.resize(this->marker_indices.mapper().size());
this->markers *= 0.;
}
static bound_type bind(pybind11::module& m, static bound_type bind(pybind11::module& m,
const std::string& layer_id = "", const std::string& layer_id = "",
const std::string& grid_id = XT::Grid::bindings::grid_name<G>::value(), const std::string& grid_id = XT::Grid::bindings::grid_name<G>::value(),
...@@ -127,9 +119,23 @@ public: ...@@ -127,9 +119,23 @@ public:
py::call_guard<py::gil_scoped_release>()); py::call_guard<py::gil_scoped_release>());
c.def( c.def(
"post_adapt", "post_adapt",
[](type& self, const bool post_adapt_grid, const bool clear) { self.post_adapt(post_adapt_grid, clear); }, [](type& self, const bool post_adapt_grid, const bool clear, const bool indicate_new_elements) {
// we need to keep track of these elements before ...
self.marker_indices.update_after_adapt();
self.markers.resize(self.marker_indices.mapper().size());
self.markers *= 0.;
if (indicate_new_elements) {
auto grid_view = self.grid().leafGridView();
for (auto&& element : elements(grid_view))
if (element.isNew())
self.markers[self.marker_indices.mapper().global_index(element, size_t(0))] = size_t(1);
}
// ... possibly cleaning up the grid
self.post_adapt(post_adapt_grid, clear);
},
"post_adapt_grid"_a = true, "post_adapt_grid"_a = true,
"clear"_a = false, "clear"_a = false,
"indicate_new_elements"_a = false,
py::call_guard<py::gil_scoped_release>()); py::call_guard<py::gil_scoped_release>());
const auto FactoryName = XT::Common::to_camel_case(class_id); const auto FactoryName = XT::Common::to_camel_case(class_id);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment