From: Daniel Arndt Date: Sat, 5 Jan 2019 22:08:48 +0000 (+0100) Subject: Fix include/fe X-Git-Tag: v9.1.0-rc1~425^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F7609%2Fhead;p=dealii.git Fix include/fe --- diff --git a/include/deal.II/fe/block_mask.h b/include/deal.II/fe/block_mask.h index 71a170f6e1..052ce80a72 100644 --- a/include/deal.II/fe/block_mask.h +++ b/include/deal.II/fe/block_mask.h @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -289,11 +290,9 @@ BlockMask::n_selected_blocks(const unsigned int n) const else { AssertDimension(real_n, block_mask.size()); - unsigned int c = 0; - for (unsigned int i = 0; i < block_mask.size(); ++i) - if (block_mask[i] == true) - ++c; - return c; + return std::count_if(block_mask.begin(), + block_mask.end(), + [](const bool selected) { return selected; }); } } diff --git a/include/deal.II/fe/component_mask.h b/include/deal.II/fe/component_mask.h index 9d1a696da3..9599ee873a 100644 --- a/include/deal.II/fe/component_mask.h +++ b/include/deal.II/fe/component_mask.h @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -319,11 +320,9 @@ ComponentMask::n_selected_components(const unsigned int n) const else { AssertDimension(real_n, component_mask.size()); - unsigned int c = 0; - for (unsigned int i = 0; i < component_mask.size(); ++i) - if (component_mask[i] == true) - ++c; - return c; + return std::count_if(component_mask.begin(), + component_mask.end(), + [](const bool selected) { return selected; }); } } diff --git a/include/deal.II/fe/fe_tools.templates.h b/include/deal.II/fe/fe_tools.templates.h index 7a0f374a30..be0bc3ff29 100644 --- a/include/deal.II/fe/fe_tools.templates.h +++ b/include/deal.II/fe/fe_tools.templates.h @@ -642,11 +642,12 @@ namespace FETools { // The base element establishing a component does not make sense in // this case. Set up to something meaningless: - for (unsigned int i = 0; i < component_to_base_table.size(); i++) - component_to_base_table[i] = - std::make_pair(std::make_pair(numbers::invalid_unsigned_int, - numbers::invalid_unsigned_int), - numbers::invalid_unsigned_int); + std::fill( + component_to_base_table.begin(), + component_to_base_table.end(), + std::make_pair(std::make_pair(numbers::invalid_unsigned_int, + numbers::invalid_unsigned_int), + numbers::invalid_unsigned_int)); } @@ -1403,16 +1404,16 @@ namespace FETools comp_start.resize(element.n_base_elements()); - unsigned int k = 0; + unsigned int index = 0; for (unsigned int i = 0; i < comp_start.size(); ++i) { comp_start[i].resize(element.element_multiplicity(i)); const unsigned int increment = element.base_element(i).dofs_per_cell; - for (unsigned int j = 0; j < comp_start[i].size(); ++j) + for (unsigned int &first_index_of_component : comp_start[i]) { - comp_start[i][j] = k; - k += increment; + first_index_of_component = index; + index += increment; } }