<commit_before>/****************************************************************/
/*               DO NOT MODIFY THIS HEADER                      */
/* MOOSE - Multiphysics Object Oriented Simulation Environment  */
/*                                                              */
/*           (c) 2010 Battelle Energy Alliance, LLC             */
/*                   ALL RIGHTS RESERVED                        */
/*                                                              */
/*          Prepared by Battelle Energy Alliance, LLC           */
/*            Under Contract No. DE-AC07-05ID14517              */
/*            With the U. S. Department of Energy               */
/*                                                              */
/*            See COPYRIGHT for full restrictions               */
/****************************************************************/

#include "TransientInterface.h"
#include "FEProblem.h"
#include "TimePeriod.h"

template<>
InputParameters validParams<TransientInterface>()
{
  InputParameters params = emptyInputParameters();
  params.addPrivateParam<bool>("implicit", true);
  return params;
}


TransientInterface::TransientInterface(const InputParameters & parameters, const std::string & object_type) :
    _ti_feproblem(*parameters.get<FEProblem *>("_fe_problem")),
    _is_implicit(parameters.have_parameter<bool>("implicit") ? parameters.get<bool>("implicit") : true),
    _t(_is_implicit ? _ti_feproblem.time() : _ti_feproblem.timeOld()),
    _t_step(_ti_feproblem.timeStep()),
    _dt(_ti_feproblem.dt()),
    _dt_old(_ti_feproblem.dtOld()),
    _is_transient(_ti_feproblem.isTransient()),
    _object_type(object_type),
    _time_periods(_ti_feproblem.getTimePeriods()),
    _ti_name(MooseUtils::shortName(parameters.get<std::string>("name")))
{
}

TransientInterface::~TransientInterface()
{
}

bool
TransientInterface::isActive()
{
  // if we have zero or one time periods -> all objects are active all the time
  if (_time_periods.size() <= 1)
    return true;

  // look if _t lies in one of our time periods
  for (unsigned int i=1; i <= _time_periods.size(); ++i)  // Careful! We are purposely indexing one past the end of the array
    if ((i == _time_periods.size()) || // Are we in the last time period?
        ((_time_periods[i-1]->start() <= _t) && (_t < _time_periods[i]->start())))  // OR are we in one of the intermediate periods?
    {
      bool ret_value;
      const std::vector<std::string> & objects = _time_periods[i-1]->getObjectList(_object_type, ret_value);
      if (std::find(objects.begin(), objects.end(), _ti_name) != objects.end())
        return ret_value;
      else
        return !ret_value;
    }

  return false;
}
<commit_msg>Make implicit visible<commit_after>/****************************************************************/
/*               DO NOT MODIFY THIS HEADER                      */
/* MOOSE - Multiphysics Object Oriented Simulation Environment  */
/*                                                              */
/*           (c) 2010 Battelle Energy Alliance, LLC             */
/*                   ALL RIGHTS RESERVED                        */
/*                                                              */
/*          Prepared by Battelle Energy Alliance, LLC           */
/*            Under Contract No. DE-AC07-05ID14517              */
/*            With the U. S. Department of Energy               */
/*                                                              */
/*            See COPYRIGHT for full restrictions               */
/****************************************************************/

#include "TransientInterface.h"
#include "FEProblem.h"
#include "TimePeriod.h"

template<>
InputParameters validParams<TransientInterface>()
{
  InputParameters params = emptyInputParameters();
  params.addParam<bool>("implicit", true, "Determines whether this object is calculated using an implicit or explicit form");

  params.addParamNamesToGroup("implicit", "Advanced");
  return params;
}


TransientInterface::TransientInterface(const InputParameters & parameters, const std::string & object_type) :
    _ti_feproblem(*parameters.get<FEProblem *>("_fe_problem")),
    _is_implicit(parameters.have_parameter<bool>("implicit") ? parameters.get<bool>("implicit") : true),
    _t(_is_implicit ? _ti_feproblem.time() : _ti_feproblem.timeOld()),
    _t_step(_ti_feproblem.timeStep()),
    _dt(_ti_feproblem.dt()),
    _dt_old(_ti_feproblem.dtOld()),
    _is_transient(_ti_feproblem.isTransient()),
    _object_type(object_type),
    _time_periods(_ti_feproblem.getTimePeriods()),
    _ti_name(MooseUtils::shortName(parameters.get<std::string>("name")))
{
}

TransientInterface::~TransientInterface()
{
}

bool
TransientInterface::isActive()
{
  // if we have zero or one time periods -> all objects are active all the time
  if (_time_periods.size() <= 1)
    return true;

  // look if _t lies in one of our time periods
  for (unsigned int i=1; i <= _time_periods.size(); ++i)  // Careful! We are purposely indexing one past the end of the array
    if ((i == _time_periods.size()) || // Are we in the last time period?
        ((_time_periods[i-1]->start() <= _t) && (_t < _time_periods[i]->start())))  // OR are we in one of the intermediate periods?
    {
      bool ret_value;
      const std::vector<std::string> & objects = _time_periods[i-1]->getObjectList(_object_type, ret_value);
      if (std::find(objects.begin(), objects.end(), _ti_name) != objects.end())
        return ret_value;
      else
        return !ret_value;
    }

  return false;
}

{'fraction_non_alphanumeric': 0.16327259735619865, 'fraction_numerical': 0.006073597713469096, 'mean_word_length': 2.4286589099816287, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 12, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4612177', 'n_tokens_mistral': 1578, 'n_tokens_neox': 1498, 'n_words': 364}