Ejemplo n.º 1
0
Order
ScalarCoupleable::coupledScalarOrder(const std::string & var_name, unsigned int comp)
{
  if (!isCoupledScalar(var_name, comp))
    return _sc_fe_problem.getMaxScalarOrder();

  return getScalarVar(var_name, comp)->order();
}
Ejemplo n.º 2
0
VariableValue &
ScalarCoupleable::coupledScalarDotDu(const std::string & var_name, unsigned int comp)
{
  checkVar(var_name);
  validateExecutionerType(var_name, "coupledScalarDotDu");
  MooseVariableScalar * var = getScalarVar(var_name, comp);
  return var->duDotDu();
}
Ejemplo n.º 3
0
VariableValue &
ScalarCoupleable::coupledScalarValueOld(const std::string & var_name, unsigned int comp)
{
  if (!isCoupledScalar(var_name, comp))
    return *getDefaultValue(var_name);

  MooseVariableScalar * var = getScalarVar(var_name, comp);
  return (_sc_is_implicit) ? var->slnOld() : var->slnOlder();
}
Ejemplo n.º 4
0
VariableValue &
ScalarCoupleable::coupledScalarValueOlder(const std::string & var_name, unsigned int comp)
{
  checkVar(var_name);
  if (!isCoupledScalar(var_name, comp))
    return *getDefaultValue(var_name);

  validateExecutionerType(var_name, "coupledScalarValueOlder");
  MooseVariableScalar * var = getScalarVar(var_name, comp);
  if (_sc_is_implicit)
    return var->slnOlder();
  else
    mooseError("Older values not available for explicit schemes");
}
Ejemplo n.º 5
0
ParsedODEKernel::ParsedODEKernel(const InputParameters & parameters)
  : ODEKernel(parameters),
    FunctionParserUtils(parameters),
    _function(getParam<std::string>("function")),
    _nargs(coupledScalarComponents("args")),
    _args(_nargs),
    _arg_names(_nargs),
    _func_dFdarg(_nargs),
    _number_of_nl_variables(_sys.nVariables()),
    _arg_index(_number_of_nl_variables, -1)
{
  // build variables argument (start with variable the kernel is operating on)
  std::string variables = _var.name();

  // add additional coupled variables
  for (unsigned int i = 0; i < _nargs; ++i)
  {
    _arg_names[i] = getScalarVar("args", i)->name();
    variables += "," + _arg_names[i];
    _args[i] = &coupledScalarValue("args", i);

    // populate number -> arg index lookup table skipping aux variables
    unsigned int number = coupledScalar("args", i);
    if (number < _number_of_nl_variables)
      _arg_index[number] = i;
  }

  // base function object
  _func_F = ADFunctionPtr(new ADFunction());

  // set FParser interneal feature flags
  setParserFeatureFlags(_func_F);

  // add the constant expressions
  addFParserConstants(_func_F,
                      getParam<std::vector<std::string>>("constant_names"),
                      getParam<std::vector<std::string>>("constant_expressions"));

  // parse function
  if (_func_F->Parse(_function, variables) >= 0)
    mooseError("Invalid function\n",
               _function,
               "\nin ParsedODEKernel ",
               name(),
               ".\n",
               _func_F->ErrorMsg());

  // on-diagonal derivative
  _func_dFdu = ADFunctionPtr(new ADFunction(*_func_F));

  if (_func_dFdu->AutoDiff(_var.name()) != -1)
    mooseError("Failed to take first derivative w.r.t. ", _var.name());

  // off-diagonal derivatives
  for (unsigned int i = 0; i < _nargs; ++i)
  {
    _func_dFdarg[i] = ADFunctionPtr(new ADFunction(*_func_F));

    if (_func_dFdarg[i]->AutoDiff(_arg_names[i]) != -1)
      mooseError("Failed to take first derivative w.r.t. ", _arg_names[i]);
  }

  // optimize
  if (!_disable_fpoptimizer)
  {
    _func_F->Optimize();
    _func_dFdu->Optimize();
    for (unsigned int i = 0; i < _nargs; ++i)
      _func_dFdarg[i]->Optimize();
  }

  // just-in-time compile
  if (_enable_jit)
  {
    _func_F->JITCompile();
    _func_dFdu->JITCompile();
    for (unsigned int i = 0; i < _nargs; ++i)
      _func_dFdarg[i]->JITCompile();
  }

  // reserve storage for parameter passing buffer
  _func_params.resize(_nargs + 1);
}
Ejemplo n.º 6
0
unsigned int
ScalarCoupleable::coupledScalar(const std::string & var_name, unsigned int comp)
{
  checkVar(var_name);
  return getScalarVar(var_name, comp)->number();
}
Ejemplo n.º 7
0
VariableValue &
ScalarCoupleable::coupledScalarDot(const std::string & var_name, unsigned int comp)
{
  MooseVariableScalar * var = getScalarVar(var_name, comp);
  return var->uDot();
}
Ejemplo n.º 8
0
VariableValue &
ScalarCoupleable::coupledScalarValue(const std::string & var_name, unsigned int comp)
{
  MooseVariableScalar * var = getScalarVar(var_name, comp);
  return (_sc_is_implicit) ? var->sln() : var->slnOld();
}