Skip to content

Commit

Permalink
Style updates
Browse files Browse the repository at this point in the history
  • Loading branch information
garth-wells committed Jan 13, 2025
1 parent 52521ac commit 00f0672
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
15 changes: 9 additions & 6 deletions cpp/dolfinx/fem/Form.h
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,8 @@ class Form
const geometry_type*, const int*, const uint8_t*)>
kernel(IntegralType type, int i, int kernel_idx) const
{
const auto& integrals = _integrals[static_cast<std::size_t>(type)];
const std::vector<integral_data<scalar_type, geometry_type>>& integrals
= _integrals[static_cast<std::size_t>(type)];

// Get the range of integrals with a given ID
auto get_id = [](const auto& a) { return a.id; };
Expand Down Expand Up @@ -332,8 +333,7 @@ class Form
/// @param[in] i Index of the integral.
std::vector<int> active_coeffs(IntegralType type, std::size_t i) const
{
assert(i < _integrals[static_cast<std::size_t>(type)].size());
return _integrals[static_cast<std::size_t>(type)][i].coeffs;
return _integrals[static_cast<std::size_t>(type)].at(i).coeffs;
}

/// @brief Get the IDs for integrals (kernels) for given integral type.
Expand All @@ -346,7 +346,8 @@ class Form
std::vector<int> integral_ids(IntegralType type) const
{
std::vector<int> ids;
const auto& integrals = _integrals[static_cast<std::size_t>(type)];
const std::vector<integral_data<scalar_type, geometry_type>>& integrals
= _integrals[static_cast<std::size_t>(type)];
std::ranges::transform(integrals, std::back_inserter(ids),
[](auto& integral) { return integral.id; });

Expand Down Expand Up @@ -377,7 +378,8 @@ class Form
std::span<const std::int32_t> domain(IntegralType type, int i) const
{
// FIXME This should call domain with kernel_idx=0
const auto& integrals = _integrals[static_cast<std::size_t>(type)];
const std::vector<integral_data<scalar_type, geometry_type>>& integrals
= _integrals[static_cast<std::size_t>(type)];
auto it = std::ranges::lower_bound(integrals, i, std::less<>{},
[](const auto& a) { return a.id; });
if (it != integrals.end() and it->id == i)
Expand All @@ -396,7 +398,8 @@ class Form
std::vector<std::int32_t> domain(IntegralType type, int i,
int kernel_idx) const
{
const auto& integrals = _integrals[static_cast<std::size_t>(type)];
const std::vector<integral_data<scalar_type, geometry_type>>& integrals
= _integrals[static_cast<std::size_t>(type)];
auto get_id = [](const auto& a) { return a.id; };
auto start = std::ranges::lower_bound(integrals, i, std::less<>{}, get_id);
auto end = std::ranges::upper_bound(integrals, i, std::less<>{}, get_id);
Expand Down
4 changes: 4 additions & 0 deletions cpp/dolfinx/fem/FunctionSpace.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,15 @@ class FunctionSpace
std::vector<mesh::CellType> cell_types = mesh->topology()->cell_types();
int num_cell_types = cell_types.size();
if (elements.size() != num_cell_types)
{
throw std::runtime_error(
"Number of elements must match number of cell types");
}
if (dofmaps.size() != num_cell_types)
{
throw std::runtime_error(
"Number of dofmaps must match number of cell types");
}
for (std::size_t i = 0; i < num_cell_types; ++i)
{
if (elements.at(i)->cell_type() != cell_types.at(i))
Expand Down

0 comments on commit 00f0672

Please sign in to comment.