Skip to content

Commit

Permalink
Tidy
Browse files Browse the repository at this point in the history
  • Loading branch information
garth-wells committed Nov 10, 2024
1 parent 5f412bb commit bfd2991
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 80 deletions.
64 changes: 6 additions & 58 deletions cpp/dolfinx/fem/FunctionSpace.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,33 +24,6 @@

namespace dolfinx::fem
{
// /// @brief Compute the physical value shape of an element for a mesh
// /// @param[in] element The element
// /// @param[in] tdim Topological dimension
// /// @param[in] gdim Geometric dimension
// /// @return Physical value shape
// template <std::floating_point T>
// std::vector<std::size_t>
// compute_value_shape(const dolfinx::fem::FiniteElement<T>& element,
// std::size_t tdim, std::size_t gdim)
// {
// std::span<const std::size_t> rvs = element.reference_value_shape();
// if (element.block_size() > 1)
// return std::vector<std::size_t>(rvs.begin(), rvs.end());
// else
// {
// std::vector<std::size_t> value_shape;
// for (auto vs : rvs)
// {
// if (vs == tdim)
// value_shape.push_back(gdim);
// else
// value_shape.push_back(vs);
// }
// return value_shape;
// }
// }

/// @brief This class represents a finite element function space defined
/// by a mesh, a finite element, and a local-to-global map of the
/// degrees-of-freedom.
Expand Down Expand Up @@ -133,19 +106,13 @@ class FunctionSpace
/// FunctionSpace
bool contains(const FunctionSpace& V) const
{
if (this == std::addressof(V))
{
// Spaces are the same (same memory address)
if (this == std::addressof(V)) // Spaces are the same (same memory address)
return true;
}
else if (_root_space_id != V._root_space_id)
{
// Different root spaces
else if (_root_space_id != V._root_space_id) // Different root spaces
return false;
}
else if (_component.size() > V._component.size())
else if (_component.size()
> V._component.size()) // V is a superspace of *this
{
// V is a superspace of *this
return false;
}
else if (!std::equal(_component.begin(), _component.end(),
Expand All @@ -155,11 +122,8 @@ class FunctionSpace
// of V
return false;
}
else
{
// Ok, V is really our subspace
else // Ok, V is really our subspace
return true;
}
}

/// Collapse a subspace and return a new function space and a map from
Expand Down Expand Up @@ -357,23 +321,7 @@ class FunctionSpace
/// @note The return value of this function is equivalent to
/// `std::accumulate(value_shape().begin(), value_shape().end(), 1,
/// std::multiplies{})`.
int value_size() const
{
return _element->value_size();
// int vs0 = std::accumulate(_value_shape.begin(), _value_shape.end(), 1,
// std::multiplies{});
// std::cout << "Get element evs" << std::endl;
// auto evs = _element->value_shape();
// std::cout << "Post element evs" << std::endl;
// int vs1 = std::accumulate(evs.begin(), evs.end(), 1, std::multiplies{});
// if (vs0 != vs1)
// {
// std::cout << "Not equal:" << vs0 << ", " << vs1 << std::endl;
// throw std::runtime_error("oops");
// }
// return std::accumulate(_value_shape.begin(), _value_shape.end(), 1,
// std::multiplies{});
}
int value_size() const { return _element->value_size(); }

private:
// The mesh
Expand Down
13 changes: 0 additions & 13 deletions cpp/dolfinx/fem/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -789,17 +789,11 @@ template <std::floating_point T>
FunctionSpace<T> create_functionspace(
std::shared_ptr<mesh::Mesh<T>> mesh,
std::shared_ptr<const fem::FiniteElement<T>> e,
std::optional<std::vector<std::size_t>> value_shape = std::nullopt,
std::function<std::vector<int>(const graph::AdjacencyList<std::int32_t>&)>
reorder_fn
= nullptr)
{
assert(e);
if (value_shape and !e->reference_value_shape().empty())
{
throw std::runtime_error(
"Cannot specify value shape for non-scalar base element.");
}

// TODO: check cell type of e (need to add method to fem::FiniteElement)
assert(mesh);
Expand All @@ -817,13 +811,6 @@ FunctionSpace<T> create_functionspace(
auto dofmap = std::make_shared<const DofMap>(create_dofmap(
mesh->comm(), layout, *mesh->topology(), permute_inv, reorder_fn));

// TODO: clarify what is happening here
// const std::vector<std::size_t> _value_shape
// = !e->is_mixed() and !value_shape and !e->reference_value_shape().empty()
// ? fem::compute_value_shape(*e, mesh->topology()->dim(),
// mesh->geometry().dim())
// : value_shape.value_or(std::vector<std::size_t>());

return FunctionSpace(mesh, e, dofmap);
}

Expand Down
9 changes: 0 additions & 9 deletions python/dolfinx/wrappers/fem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,6 @@ void declare_function_space(nb::module_& m, std::string type)
.def_prop_ro("element", &dolfinx::fem::FunctionSpace<T>::element)
.def_prop_ro("mesh", &dolfinx::fem::FunctionSpace<T>::mesh)
.def_prop_ro("dofmap", &dolfinx::fem::FunctionSpace<T>::dofmap)
// .def_prop_ro(
// "value_shape",
// [](const dolfinx::fem::FunctionSpace<T>& self)
// {
// std::span<const std::size_t> vshape = self.value_shape();
// return nb::ndarray<const std::size_t, nb::numpy>(vshape.data(),
// {vshape.size()});
// },
// nb::rv_policy::reference_internal)
.def("sub", &dolfinx::fem::FunctionSpace<T>::sub, nb::arg("component"))
.def("tabulate_dof_coordinates",
[](const dolfinx::fem::FunctionSpace<T>& self)
Expand Down

0 comments on commit bfd2991

Please sign in to comment.