From bf4c178b5b522515b4922f7d18713d774d32b581 Mon Sep 17 00:00:00 2001 From: Cody Permann Date: Tue, 26 Mar 2019 11:14:55 -0600 Subject: [PATCH] Switch to MooseIndex refs #13074 --- .../ComputePolycrystalElasticityTensor.C | 8 ++-- .../src/postprocessors/GrainBoundaryArea.C | 2 +- .../src/postprocessors/GrainTracker.C | 38 +++++++++---------- .../src/userobjects/PolycrystalEBSD.C | 2 +- 4 files changed, 24 insertions(+), 26 deletions(-) diff --git a/modules/phase_field/src/materials/ComputePolycrystalElasticityTensor.C b/modules/phase_field/src/materials/ComputePolycrystalElasticityTensor.C index e1dd69bc4509..e5b099914abd 100644 --- a/modules/phase_field/src/materials/ComputePolycrystalElasticityTensor.C +++ b/modules/phase_field/src/materials/ComputePolycrystalElasticityTensor.C @@ -40,7 +40,7 @@ ComputePolycrystalElasticityTensor::ComputePolycrystalElasticityTensor( _JtoeV(6.24150974e18) { // Loop over variables (ops) - for (auto op_index = decltype(_op_num)(0); op_index < _op_num; ++op_index) + for (MooseIndex(_op_num) op_index = 0; op_index < _op_num; ++op_index) { // Initialize variables _vals[op_index] = &coupledValue("v", op_index); @@ -60,7 +60,7 @@ ComputePolycrystalElasticityTensor::computeQpElasticityTensor() // Calculate elasticity tensor _elasticity_tensor[_qp].zero(); Real sum_h = 0.0; - for (auto op_index = beginIndex(op_to_grains); op_index < op_to_grains.size(); ++op_index) + for (MooseIndex(op_to_grains) op_index = 0; op_index < op_to_grains.size(); ++op_index) { auto grain_id = op_to_grains[op_index]; if (grain_id == FeatureFloodCount::invalid_id) @@ -79,10 +79,10 @@ ComputePolycrystalElasticityTensor::computeQpElasticityTensor() _elasticity_tensor[_qp] /= sum_h; // Calculate elasticity tensor derivative: Cderiv = dhdopi/sum_h * (Cop - _Cijkl) - for (auto op_index = decltype(_op_num)(0); op_index < _op_num; ++op_index) + for (MooseIndex(_op_num) op_index = 0; op_index < _op_num; ++op_index) (*_D_elastic_tensor[op_index])[_qp].zero(); - for (auto op_index = beginIndex(op_to_grains); op_index < op_to_grains.size(); ++op_index) + for (MooseIndex(op_to_grains) op_index = 0; op_index < op_to_grains.size(); ++op_index) { auto grain_id = op_to_grains[op_index]; if (grain_id == FeatureFloodCount::invalid_id) diff --git a/modules/phase_field/src/postprocessors/GrainBoundaryArea.C b/modules/phase_field/src/postprocessors/GrainBoundaryArea.C index 41606b270d6e..f2ce2ce80b45 100644 --- a/modules/phase_field/src/postprocessors/GrainBoundaryArea.C +++ b/modules/phase_field/src/postprocessors/GrainBoundaryArea.C @@ -44,7 +44,7 @@ GrainBoundaryArea::GrainBoundaryArea(const InputParameters & parameters) mooseError("Neither grains_per_side nor op_range may be zero."); // Loop over variables (ops) - for (auto op_index = decltype(_op_num)(0); op_index < _op_num; ++op_index) + for (MooseIndex(_op_num) op_index = 0; op_index < _op_num; ++op_index) _grads[op_index] = &coupledGradient("v", op_index); } diff --git a/modules/phase_field/src/postprocessors/GrainTracker.C b/modules/phase_field/src/postprocessors/GrainTracker.C index 073955745824..56fc6a523666 100644 --- a/modules/phase_field/src/postprocessors/GrainTracker.C +++ b/modules/phase_field/src/postprocessors/GrainTracker.C @@ -474,7 +474,7 @@ GrainTracker::trackGrains() if (_verbosity_level > 0) { _console << "\nGrain Tracker Status:"; - for (auto map_num = decltype(_maps_size)(0); map_num < _maps_size; ++map_num) + for (MooseIndex(_maps_size) map_num = 0; map_num < _maps_size; ++map_num) { _console << "\nGrains active index " << map_num << ": " << map_sizes[map_num] << " -> " << _feature_counts_per_map[map_num]; @@ -498,7 +498,7 @@ GrainTracker::trackGrains() std::vector new_grain_index_to_existing_grain_index(_feature_sets.size(), invalid_size_t); - for (auto old_grain_index = beginIndex(_feature_sets_old); + for (MooseIndex(_feature_sets_old) old_grain_index = 0; old_grain_index < _feature_sets_old.size(); ++old_grain_index) { @@ -526,8 +526,8 @@ GrainTracker::trackGrains() // We only need to examine grains that have matching variable indices bool any_boxes_intersect = false; - for (decltype(_feature_sets.size()) new_grain_index = - std::distance(_feature_sets.begin(), start_it); + for (MooseIndex(_feature_sets) + new_grain_index = std::distance(_feature_sets.begin(), start_it); new_grain_index < _feature_sets.size() && _feature_sets[new_grain_index]._var_index == old_grain._var_index; ++new_grain_index) @@ -601,7 +601,7 @@ GrainTracker::trackGrains() } // Mark all resolved grain matches - for (auto new_index = beginIndex(new_grain_index_to_existing_grain_index); + for (MooseIndex(new_grain_index_to_existing_grain_index) new_index = 0; new_index < new_grain_index_to_existing_grain_index.size(); ++new_index) { @@ -634,7 +634,7 @@ GrainTracker::trackGrains() * for any new grain which means it can't be marked inactive in the loop above. */ // Case 1 (new grains in _feature_sets): - for (auto grain_num = beginIndex(_feature_sets); grain_num < _feature_sets.size(); ++grain_num) + for (MooseIndex(_feature_sets) grain_num = 0; grain_num < _feature_sets.size(); ++grain_num) { auto & grain = _feature_sets[grain_num]; @@ -669,8 +669,8 @@ GrainTracker::trackGrains() // clang-format on // Loop over matching variable indices - for (decltype(_feature_sets.size()) new_grain_index = - std::distance(_feature_sets.begin(), start_it); + for (MooseIndex(_feature_sets) + new_grain_index = std::distance(_feature_sets.begin(), start_it); new_grain_index < _feature_sets.size() && _feature_sets[new_grain_index]._var_index == grain._var_index; ++new_grain_index) @@ -724,7 +724,7 @@ GrainTracker::trackGrains() << COLOR_DEFAULT; std::vector old_grain_indices; - for (auto old_grain_index = beginIndex(_feature_sets_old); + for (MooseIndex(_feature_sets_old) old_grain_index = 0; old_grain_index < _feature_sets_old.size(); ++old_grain_index) { @@ -904,11 +904,11 @@ GrainTracker::remapGrains() } // Make sure that all split pieces of any grain are on the same OP - for (auto i = beginIndex(_feature_sets); i < _feature_sets.size(); ++i) + for (MooseIndex(_feature_sets) i = 0; i < _feature_sets.size(); ++i) { auto & grain1 = _feature_sets[i]; - for (auto j = beginIndex(_feature_sets); j < _feature_sets.size(); ++j) + for (MooseIndex(_feature_sets) j = 0; j < _feature_sets.size(); ++j) { auto & grain2 = _feature_sets[j]; if (i == j) @@ -961,8 +961,7 @@ GrainTracker::remapGrains() << ", remapping to another variable\n" << COLOR_DEFAULT; - for (auto max = decltype(_max_remap_recursion_depth)(0); - max <= _max_remap_recursion_depth; + for (MooseIndex(_max_remap_recursion_depth) max = 0; max <= _max_remap_recursion_depth; ++max) if (max < _max_remap_recursion_depth) { @@ -1001,8 +1000,7 @@ GrainTracker::remapGrains() << grain2._id << " (variable index: " << grain1._var_index << ")\n" << COLOR_DEFAULT; - for (auto max = decltype(_max_remap_recursion_depth)(0); - max <= _max_remap_recursion_depth; + for (MooseIndex(_max_remap_recursion_depth) max = 0; max <= _max_remap_recursion_depth; ++max) { if (max < _max_remap_recursion_depth) @@ -1161,7 +1159,7 @@ GrainTracker::computeMinDistancesFromGrain(FeatureData & grain, * __/ 0 \___/ * */ - for (auto i = beginIndex(_feature_sets); i < _feature_sets.size(); ++i) + for (MooseIndex(_feature_sets) i = 0; i < _feature_sets.size(); ++i) { auto & other_grain = _feature_sets[i]; @@ -1197,7 +1195,7 @@ GrainTracker::computeMinDistancesFromGrain(FeatureData & grain, * parameter corresponding to this grain, we need to put them in the list or the grain tracker * won't realize that those vars are available for remapping. */ - for (auto var_index = beginIndex(_vars); var_index < _reserve_op_index; ++var_index) + for (MooseIndex(_vars) var_index = 0; var_index < _reserve_op_index; ++var_index) { // Don't put an entry in for matching variable indices (i.e. we can't remap to ourselves) if (grain._var_index == var_index) @@ -1507,7 +1505,7 @@ GrainTracker::updateFieldInfo() { TIME_SECTION(_update_field_info); - for (auto map_num = decltype(_maps_size)(0); map_num < _maps_size; ++map_num) + for (MooseIndex(_maps_size) map_num = 0; map_num < _maps_size; ++map_num) _feature_maps[map_num].clear(); std::map tmp_map; @@ -1562,7 +1560,7 @@ GrainTracker::updateFieldInfo() if (insert_pair.second) { // insert the reserve op numbers (if appropriate) - for (auto reserve_index = decltype(_n_reserve_ops)(0); reserve_index < _n_reserve_ops; + for (MooseIndex(_n_reserve_ops) reserve_index = 0; reserve_index < _n_reserve_ops; ++reserve_index) vec_ref[reserve_index] = _reserve_grain_first_index + reserve_index; } @@ -1601,7 +1599,7 @@ GrainTracker::communicateHaloMap() counts.resize(_n_procs); // Loop over the _halo_ids "field" and build minimal lists for all of the other ranks - for (auto var_index = beginIndex(_halo_ids); var_index < _halo_ids.size(); ++var_index) + for (MooseIndex(_halo_ids) var_index = 0; var_index < _halo_ids.size(); ++var_index) { for (const auto & entity_pair : _halo_ids[var_index]) { diff --git a/modules/phase_field/src/userobjects/PolycrystalEBSD.C b/modules/phase_field/src/userobjects/PolycrystalEBSD.C index e8bb8d7ed437..610fe0b117c0 100644 --- a/modules/phase_field/src/userobjects/PolycrystalEBSD.C +++ b/modules/phase_field/src/userobjects/PolycrystalEBSD.C @@ -73,7 +73,7 @@ PolycrystalEBSD::getNodalVariableValue(unsigned int op_index, const Node & n) co // Increment through all grains at node_index (these are global IDs if consider_phase is false and // local IDs otherwise) const auto num_grains = getNumGrains(); - for (auto index = decltype(num_grains)(0); index < num_grains; ++index) + for (MooseIndex(num_grains) index = 0; index < num_grains; ++index) { // If the current order parameter index (_op_index) is equal to the assigned index // (_assigned_op),