<commit_before>#include "Component.h"
#include "Simulation.h"
#include "MooseApp.h"

unsigned int Component::subdomain_ids = 0;
unsigned int Component::bc_ids = 0;

template<>
InputParameters validParams<Component>()
{
  InputParameters params = validParams<R7Object>();
  params.addPrivateParam<Simulation *>("_sim");

  params.addParam<std::string>("physics_input_file", "Input file with physics");
  params.addPrivateParam<std::string>("built_by_action", "add_component");

  params.registerBase("Component");

  return params;
}

/*
 * Component implementation
 */
static unsigned int comp_id = 0;

std::string
Component::genName(const std::string & prefix, unsigned int id, const std::string & suffix)
{
  std::stringstream ss;
  ss << prefix << ":" << id << ":" << suffix;
  return ss.str();
}

std::string
Component::genName(const std::string & prefix, const std::string & suffix)
{
  std::stringstream ss;
  ss << prefix << ":" << suffix;
  return ss.str();
}
std::string
Component::genName(const std::string & prefix, const std::string & middle, const std::string & suffix)
{
  std::stringstream ss;
  ss << prefix << ":" << middle << ":" << suffix;
  return ss.str();
}

std::vector<std::string>
Component::split(const std::string & rname)
{
  std::vector<std::string> splitted;
  MooseUtils::tokenize(rname, splitted, 1, ":");

  std::string section_name("");
  for (unsigned int i = 0; i < splitted.size() - 1; i++)
  {
    if (i > 0)
      section_name.append(":");
    section_name.append(splitted[i]);
  }
  std::string prop_name = splitted[splitted.size() - 1];

  // construct the 2 element array with section and property name
  std::vector<std::string> result(2);
  result[0] = section_name;
  result[1] = prop_name;

  return result;
}

Component::Component(const std::string & name, InputParameters parameters) :
    R7Object(name, parameters),
    _id(comp_id++),
    _parent(parameters.have_parameter<Component *>("_parent") ? getParam<Component *>("_parent") : NULL),
    _sim(*getParam<Simulation *>("_sim")),
    _factory(_app.getFactory()),
    _mesh(_sim.mesh()),
    _phys_mesh(_sim.physicalMesh()),

    _input_file_name(getParam<std::string>("physics_input_file")),

    _zero(_sim._zero)
{
}

Component::~Component()
{
}

void
Component::init()
{
}

unsigned int
Component::getNextSubdomainId()
{
  unsigned int sd_id = subdomain_ids++;
  _subdomains.push_back(sd_id);
  if (_parent)
    _parent->_subdomains.push_back(sd_id);
  return sd_id;
}

unsigned int
Component::getNextBCId()
{
  unsigned int id = bc_ids++;
  return id;
}

void
Component::aliasParam(const std::string & rname, const std::string & name, Component * comp/* = NULL*/)
{
  if (comp == NULL)
    _param_alias_map[rname] = std::pair<Component *, std::string>(this, name);
  else
    _param_alias_map[rname] = std::pair<Component *, std::string>(comp, name);
}

void
Component::aliasVectorParam(const std::string & rname, const std::string & name, unsigned int pos, Component * /*comp = NULL*/)
{
  createVectorControllableParMapping(rname, name, pos);
}

void
Component::connectObject(const std::string & rname, const std::string & mooseName, const std::string & name)
{
  ControlLogicNameEntry rne(mooseName, name);
  if (_parent != NULL)
    _parent->_rname_map[rname][name].push_back(rne);
  else
    _rname_map[rname][name].push_back(rne);
}

void
Component::connectObject(const std::string & rname, const std::string & mooseName, const std::string & name, const std::string & par_name)
{
  ControlLogicNameEntry rne(mooseName, par_name);
  if (_parent != NULL)
    _parent->_rname_map[rname][name].push_back(rne);
  else
    _rname_map[rname][name].push_back(rne);
}


void
Component::createVectorControllableParMapping(const std::string & rname, const std::string & mooseName, unsigned int pos)
{
  ControlLogicMapContainer mc(mooseName, pos);
  _rvect_map.insert(std::pair<std::string, ControlLogicMapContainer>(rname, mc));
}
<commit_msg>Fixing to use globally unique name for the heat structure.<commit_after>#include "Component.h"
#include "Simulation.h"
#include "MooseApp.h"

unsigned int Component::subdomain_ids = 0;
unsigned int Component::bc_ids = 0;

template<>
InputParameters validParams<Component>()
{
  InputParameters params = validParams<R7Object>();
  params.addPrivateParam<Simulation *>("_sim");

  params.addParam<std::string>("physics_input_file", "Input file with physics");
  params.addPrivateParam<std::string>("built_by_action", "add_component");

  params.registerBase("Component");

  return params;
}

/*
 * Component implementation
 */
static unsigned int comp_id = 0;

std::string
Component::genName(const std::string & prefix, unsigned int id, const std::string & suffix)
{
  std::stringstream ss;
  ss << prefix << ":" << id << ":" << suffix;
  return ss.str();
}

std::string
Component::genName(const std::string & prefix, const std::string & suffix)
{
  std::stringstream ss;
  ss << prefix << ":" << suffix;
  return ss.str();
}

std::string
Component::genName(const std::string & prefix, const std::string & middle, const std::string & suffix)
{
  std::stringstream ss;
  ss << prefix << ":" << middle << ":" << suffix;
  return ss.str();
}

std::vector<std::string>
Component::split(const std::string & rname)
{
  std::vector<std::string> splitted;
  MooseUtils::tokenize(rname, splitted, 1, ":");

  std::string section_name("");
  for (unsigned int i = 0; i < splitted.size() - 1; i++)
  {
    if (i > 0)
      section_name.append(":");
    section_name.append(splitted[i]);
  }
  std::string prop_name = splitted[splitted.size() - 1];

  // construct the 2 element array with section and property name
  std::vector<std::string> result(2);
  result[0] = section_name;
  result[1] = prop_name;

  return result;
}

Component::Component(const std::string & name, InputParameters parameters) :
    R7Object(name, parameters),
    _id(comp_id++),
    _parent(parameters.have_parameter<Component *>("_parent") ? getParam<Component *>("_parent") : NULL),
    _sim(*getParam<Simulation *>("_sim")),
    _factory(_app.getFactory()),
    _mesh(_sim.mesh()),
    _phys_mesh(_sim.physicalMesh()),

    _input_file_name(getParam<std::string>("physics_input_file")),

    _zero(_sim._zero)
{
}

Component::~Component()
{
}

void
Component::init()
{
}

unsigned int
Component::getNextSubdomainId()
{
  unsigned int sd_id = subdomain_ids++;
  _subdomains.push_back(sd_id);
  if (_parent)
    _parent->_subdomains.push_back(sd_id);
  return sd_id;
}

unsigned int
Component::getNextBCId()
{
  unsigned int id = bc_ids++;
  return id;
}

void
Component::aliasParam(const std::string & rname, const std::string & name, Component * comp/* = NULL*/)
{
  if (comp == NULL)
    _param_alias_map[rname] = std::pair<Component *, std::string>(this, name);
  else
    _param_alias_map[rname] = std::pair<Component *, std::string>(comp, name);
}

void
Component::aliasVectorParam(const std::string & rname, const std::string & name, unsigned int pos, Component * /*comp = NULL*/)
{
  createVectorControllableParMapping(rname, name, pos);
}

void
Component::connectObject(const std::string & rname, const std::string & mooseName, const std::string & name)
{
  ControlLogicNameEntry rne(mooseName, name);
  if (_parent != NULL)
    _parent->_rname_map[rname][name].push_back(rne);
  else
    _rname_map[rname][name].push_back(rne);
}

void
Component::connectObject(const std::string & rname, const std::string & mooseName, const std::string & name, const std::string & par_name)
{
  ControlLogicNameEntry rne(mooseName, par_name);
  if (_parent != NULL)
    _parent->_rname_map[rname][name].push_back(rne);
  else
    _rname_map[rname][name].push_back(rne);
}


void
Component::createVectorControllableParMapping(const std::string & rname, const std::string & mooseName, unsigned int pos)
{
  ControlLogicMapContainer mc(mooseName, pos);
  _rvect_map.insert(std::pair<std::string, ControlLogicMapContainer>(rname, mc));
}

{'fraction_non_alphanumeric': 0.15953160412994208, 'fraction_numerical': 0.0035255603122639136, 'mean_word_length': 5.415993537964459, 'pattern_counts': {'":': 14, '<': 89, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3504432', 'n_tokens_mistral': 2685, 'n_tokens_neox': 2659, 'n_words': 561}