<commit_before>#include "GeometricalComponent.h"
#include "Conversion.h"
#include "ConstantFunction.h"
#include "R7Conversion.h"

template<>
InputParameters validParams<GeometricalComponent>()
{
  InputParameters params = validParams<Component>();

  params.addRequiredParam<Point>("position", "Origin (start) of the pipe");
  params.addParam<RealVectorValue>("offset", RealVectorValue(), "Offset of the origin for mesh generation");
  params.addRequiredParam<RealVectorValue>("orientation", "Orientation vector of the pipe");
  params.addParam<Real>("rotation", 0., "Rotation of the component (in degrees)");
  params.addParam<std::vector<Real> >("length", "The lengths of the subsections of the geometric component along the main axis");
  params.addParam<std::vector<unsigned int> >("n_elems", "The number of elements in each subsection along the main axis");

  return params;
}

GeometricalComponent::GeometricalComponent(const InputParameters & parameters) :
    Component(parameters),
    _position(getParam<Point>("position")),
    _offset(getParam<RealVectorValue>("offset")),
    _dir(getParam<RealVectorValue>("orientation")),
    _rotation(getParam<Real>("rotation")),
    _2nd_order_mesh(_sim.getParam<bool>("2nd_order_mesh")),
    _lengths(getParam<std::vector<Real> >("length")),
    _n_elems(getParam<std::vector<unsigned int> >("n_elems"))
{
  _n_sections = validateNSectionsConsistent(_lengths.size(), _n_elems.size());
  _length = std::accumulate(_lengths.begin(), _lengths.end(), 0.0);
  _n_elem = std::accumulate(_n_elems.begin(), _n_elems.end(), 0);
  _n_nodes = computeNumberOfNodes(_n_elem);
}

GeometricalComponent::~GeometricalComponent()
{
}

unsigned int
GeometricalComponent::validateNSectionsConsistent(int n_lengths, int n_n_elems)
{
  bool specified_lengths = n_lengths > 0;
  bool specified_n_elems = n_n_elems > 0;
  bool agreeing_inputs = n_lengths == n_n_elems;
  bool valid_inputs = specified_n_elems && specified_lengths && agreeing_inputs;

  if (!valid_inputs)
  {
    std::string error = name() + ": Invalid input specification for GeometricalComponent. ";

    if (!agreeing_inputs)
      error += "The size of n_elems and length are not in agreement. ";

    if (!specified_lengths)
      error += "The array for length is not specified. ";

    if (!specified_n_elems)
      error += "The n_elems are not specified. ";
<commit_msg>Made length and n_elems required in GeometricalComponent<commit_after>#include "GeometricalComponent.h"
#include "Conversion.h"
#include "ConstantFunction.h"
#include "R7Conversion.h"

template<>
InputParameters validParams<GeometricalComponent>()
{
  InputParameters params = validParams<Component>();

  params.addRequiredParam<Point>("position", "Origin (start) of the pipe");
  params.addParam<RealVectorValue>("offset", RealVectorValue(), "Offset of the origin for mesh generation");
  params.addRequiredParam<RealVectorValue>("orientation", "Orientation vector of the pipe");
  params.addParam<Real>("rotation", 0., "Rotation of the component (in degrees)");
  params.addRequiredParam<std::vector<Real> >("length", "The lengths of the subsections of the geometric component along the main axis");
  params.addRequiredParam<std::vector<unsigned int> >("n_elems", "The number of elements in each subsection along the main axis");

  return params;
}

GeometricalComponent::GeometricalComponent(const InputParameters & parameters) :
    Component(parameters),
    _position(getParam<Point>("position")),
    _offset(getParam<RealVectorValue>("offset")),
    _dir(getParam<RealVectorValue>("orientation")),
    _rotation(getParam<Real>("rotation")),
    _2nd_order_mesh(_sim.getParam<bool>("2nd_order_mesh")),
    _lengths(getParam<std::vector<Real> >("length")),
    _n_elems(getParam<std::vector<unsigned int> >("n_elems"))
{
  _n_sections = validateNSectionsConsistent(_lengths.size(), _n_elems.size());
  _length = std::accumulate(_lengths.begin(), _lengths.end(), 0.0);
  _n_elem = std::accumulate(_n_elems.begin(), _n_elems.end(), 0);
  _n_nodes = computeNumberOfNodes(_n_elem);
}

GeometricalComponent::~GeometricalComponent()
{
}

unsigned int
GeometricalComponent::validateNSectionsConsistent(int n_lengths, int n_n_elems)
{
  bool specified_lengths = n_lengths > 0;
  bool specified_n_elems = n_n_elems > 0;
  bool agreeing_inputs = n_lengths == n_n_elems;
  bool valid_inputs = specified_n_elems && specified_lengths && agreeing_inputs;

  if (!valid_inputs)
  {
    std::string error = name() + ": Invalid input specification for GeometricalComponent:";

    if (!agreeing_inputs)
      error += "\n  * The number of entries in the parameter 'length' does not equal the number of entries in the parameter 'n_elems'.";

    if (!specified_lengths)
      error += "\n  * There are zero entries for the parameter 'length'.";

    if (!specified_n_elems)
      error += "\n  * There are zero entries for the parameter 'n_elems'.";

{'fraction_non_alphanumeric': 0.1305939788445891, 'fraction_numerical': 0.003661513425549227, 'mean_word_length': 6.054519368723099, 'pattern_counts': {'":': 2, '<': 43, '<?xml version=': 0, '>': 47, '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': '408583', 'n_tokens_mistral': 1543, 'n_tokens_neox': 1517, 'n_words': 354}