コード例 #1
0
ファイル: MooseApp.C プロジェクト: radioactivekate/moose
void
MooseApp::registerRestartableData(std::string name,
                                  std::unique_ptr<RestartableDataValue> data,
                                  THREAD_ID tid)
{
  auto & restartable_data = _restartable_data[tid];
  auto insert_pair = moose_try_emplace(restartable_data, name, std::move(data));

  if (!insert_pair.second)
    mooseError("Attempted to declare restartable twice with the same name: ", name);
}
コード例 #2
0
void
FauxGrainTracker::execute()
{
  Moose::perf_log.push("execute()", "FauxGrainTracker");

  for (const auto & current_elem : _mesh.getMesh().active_local_element_ptr_range())
  {
    // Loop over elements or nodes and populate the data structure with the first variable with a
    // value above a threshold
    if (_is_elemental)
    {
      std::vector<Point> centroid(1, current_elem->centroid());
      _fe_problem.reinitElemPhys(current_elem, centroid, 0);

      auto entity = current_elem->id();
      auto insert_pair =
          moose_try_emplace(_entity_var_to_features,
                            entity,
                            std::vector<unsigned int>(_n_vars, FeatureFloodCount::invalid_id));
      auto & vec_ref = insert_pair.first->second;

      for (MooseIndex(_vars) var_num = 0; var_num < _n_vars; ++var_num)
      {
        auto entity_value = _vars[var_num]->sln()[0];

        if ((_use_less_than_threshold_comparison && (entity_value >= _threshold)) ||
            (!_use_less_than_threshold_comparison && (entity_value <= _threshold)))
        {
          _entity_id_to_var_num[current_elem->id()] = var_num;
          _variables_used.insert(var_num);
          _volume[var_num] += current_elem->volume();
          _vol_count[var_num]++;
          // Sum the centroid values for now, we'll average them later
          _centroid[var_num] += current_elem->centroid();
          vec_ref[var_num] = var_num;
          break;
        }
      }
    }
    else
    {
      unsigned int n_nodes = current_elem->n_vertices();
      for (unsigned int i = 0; i < n_nodes; ++i)
      {
        const Node * current_node = current_elem->get_node(i);

        for (MooseIndex(_vars) var_num = 0; var_num < _n_vars; ++var_num)
        {
          auto entity_value = _vars[var_num]->getNodalValue(*current_node);
          if ((_use_less_than_threshold_comparison && (entity_value >= _threshold)) ||
              (!_use_less_than_threshold_comparison && (entity_value <= _threshold)))
          {
            _entity_id_to_var_num[current_node->id()] = var_num;
            _variables_used.insert(var_num);
            break;
          }
        }
      }
    }
  }

  _grain_count = std::max(_grain_count, _variables_used.size());

  Moose::perf_log.pop("execute()", "FauxGrainTracker");
}