Skip to content

Commit

Permalink
Apply suggestions from Alex
Browse files Browse the repository at this point in the history
- static cast what can be
- make_range over  loops

Co-authored-by: Alex Lindsay <[email protected]>

Apply clang format
  • Loading branch information
GiudGiud committed Jun 28, 2023
1 parent 89303cf commit 3327884
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
14 changes: 7 additions & 7 deletions framework/src/userobjects/LayeredBase.C
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ LayeredBase::integralValue(Point p) const

if (higher_layer != -1)
{
for (unsigned int i = 0; i < _average_radius; i++)
for (const auto i : make_range(_average_radius))
{
int current_layer = higher_layer + i;

Expand All @@ -267,7 +267,7 @@ LayeredBase::integralValue(Point p) const

if (lower_layer != -1)
{
for (unsigned int i = 0; i < _average_radius; i++)
for (const auto i : make_range(_average_radius))
{
int current_layer = lower_layer - i;

Expand Down Expand Up @@ -303,7 +303,7 @@ LayeredBase::initialize()
if (_using_displaced_mesh)
getBounds();

for (unsigned int i = 0; i < _layer_values.size(); i++)
for (const auto i : index_range(_layer_values))
{
_layer_values[i] = 0.0;
_layer_has_value[i] = false;
Expand All @@ -321,7 +321,7 @@ LayeredBase::finalize()
Real value = 0;

if (_positive_cumulative_direction)
for (unsigned i = 0; i < _num_layers; i++)
for (const auto i : make_range(_num_layers))
{
value += getLayerValue(i);
setLayerValue(i, value);
Expand All @@ -339,7 +339,7 @@ void
LayeredBase::threadJoin(const UserObject & y)
{
const LayeredBase & lb = dynamic_cast<const LayeredBase &>(y);
for (unsigned int i = 0; i < _layer_values.size(); i++)
for (const auto i : index_range(_layer_values))
if (lb.layerHasValue(i))
setLayerValue(i, getLayerValue(i) + lb._layer_values[i]);
}
Expand Down Expand Up @@ -393,12 +393,12 @@ LayeredBase::computeLayerCenters()
{
Real dx = (_direction_max - _direction_min) / _num_layers;

for (unsigned int i = 0; i < _num_layers; ++i)
for (const auto i : make_range(_num_layers))
_layer_centers[i] = (i + 0.5) * dx;
}
else
{
for (unsigned int i = 0; i < _num_layers; ++i)
for (const auto i : make_range(_num_layers))
_layer_centers[i] = 0.5 * (_layer_bounds[i + 1] + _layer_bounds[i]);
}
}
Expand Down
4 changes: 2 additions & 2 deletions framework/src/userobjects/LayeredExtremumMaterialProperty.C
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ void
LayeredExtremumMaterialProperty::threadJoin(const UserObject & y)
{
const LayeredExtremumMaterialProperty & lb =
dynamic_cast<const LayeredExtremumMaterialProperty &>(y);
for (unsigned int i = 0; i < _num_layers; i++)
static_cast<const LayeredExtremumMaterialProperty &>(y);
for (const auto i : make_range(_num_layers))
if (lb.layerHasValue(i))
setLayerValue(i, extreme_value(getLayerValue(i), lb.getLayerValue(i)));
}
Expand Down

0 comments on commit 3327884

Please sign in to comment.