Skip to content

Commit

Permalink
Merge pull request #13122 from permcody/moose_index
Browse files Browse the repository at this point in the history
Switch to MooseIndex
  • Loading branch information
lindsayad committed Mar 26, 2019
2 parents 6fb0152 + bf4c178 commit 5240a54
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 26 deletions.
Expand Up @@ -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);
Expand All @@ -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)
Expand All @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion modules/phase_field/src/postprocessors/GrainBoundaryArea.C
Expand Up @@ -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);
}

Expand Down
38 changes: 18 additions & 20 deletions modules/phase_field/src/postprocessors/GrainTracker.C
Expand Up @@ -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];
Expand All @@ -498,7 +498,7 @@ GrainTracker::trackGrains()
std::vector<std::size_t> 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)
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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];

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -724,7 +724,7 @@ GrainTracker::trackGrains()
<< COLOR_DEFAULT;

std::vector<std::size_t> 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)
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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];

Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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<dof_id_type, Real> tmp_map;
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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])
{
Expand Down
2 changes: 1 addition & 1 deletion modules/phase_field/src/userobjects/PolycrystalEBSD.C
Expand Up @@ -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),
Expand Down

0 comments on commit 5240a54

Please sign in to comment.