Esempio n. 1
0
Real
ExceptionKernel::computeQpResidual()
{
  // We need a thread lock here so that we don't introduce a race condition when inspecting or
  // changing the static variable
  Threads::spin_mutex::scoped_lock lock(Threads::spin_mutex);

  if (_when == WhenType::INITIAL_CONDITION)
    throw MooseException("MooseException thrown during initial condition computation");

  // Make sure we have called computeQpResidual enough times to
  // guarantee that we are in the middle of a linear solve, to verify
  // that we can throw an exception at that point.
  // Also, only throw on one rank if the user requests it
  else if (_when == WhenType::RESIDUAL && !_res_has_thrown && time_to_throw() &&
           (_rank == DofObject::invalid_processor_id || _rank == processor_id()))
  {
    // The residual has now thrown
    _res_has_thrown = true;

    if (_should_throw)
      throw MooseException("MooseException thrown during residual calculation");
    else
      mooseError("Intentional error triggered during residual calculation");
  }
  else
    return 0.;
}
Esempio n. 2
0
Real
ExceptionKernel::computeQpJacobian()
{
  // Throw on the first nonlinear step of the first timestep -- should
  // hopefully be the same in both serial and parallel.
  if (_when == JACOBIAN && !_jac_has_thrown && time_to_throw())
  {
    // The Jacobian has now thrown
    _jac_has_thrown = true;

    throw MooseException("MooseException thrown during Jacobian calculation");
  }

  return 0.;
}
Esempio n. 3
0
Real
ExceptionKernel::computeQpJacobian()
{
  // We need a thread lock here so that we don't introduce a race condition when inspecting or changing the static variable
  Threads::spin_mutex::scoped_lock lock(Threads::spin_mutex);

  // Throw on the first nonlinear step of the first timestep -- should
  // hopefully be the same in both serial and parallel.
  if (_when == JACOBIAN && !_jac_has_thrown && time_to_throw())
  {
    // The Jacobian has now thrown
    _jac_has_thrown = true;

    throw MooseException("MooseException thrown during Jacobian calculation");
  }

  return 0.;
}
Esempio n. 4
0
Real
ExceptionKernel::computeQpResidual()
{
  if (_when == INITIAL_CONDITION)
    throw MooseException("MooseException thrown during initial condition computation");

  // Make sure we have called computeQpResidual enough times to
  // guarantee that we are in the middle of a linear solve, to verify
  // that we can throw an exception at that point.
  else if (_when == RESIDUAL && !_res_has_thrown && time_to_throw())
  {
    // The residual has now thrown
    _res_has_thrown = true;

    throw MooseException("MooseException thrown during residual calculation");
  }
  else
    return 0;
}
Esempio n. 5
0
Real
ExceptionKernel::computeQpResidual()
{
  // We need a thread lock here so that we don't introduce a race condition when inspecting or changing the static variable
  Threads::spin_mutex::scoped_lock lock(Threads::spin_mutex);

  if (_when == INITIAL_CONDITION)
    throw MooseException("MooseException thrown during initial condition computation");

  // Make sure we have called computeQpResidual enough times to
  // guarantee that we are in the middle of a linear solve, to verify
  // that we can throw an exception at that point.
  else if (_when == RESIDUAL && !_res_has_thrown && time_to_throw())
  {
    // The residual has now thrown
    _res_has_thrown = true;

    throw MooseException("MooseException thrown during residual calculation");
  }
  else
    return 0;
}
Esempio n. 6
0
Real
ExceptionKernel::computeQpJacobian()
{
  // We need a thread lock here so that we don't introduce a race condition when inspecting or
  // changing the static variable
  Threads::spin_mutex::scoped_lock lock(Threads::spin_mutex);

  // Throw on the first nonlinear step of the first timestep -- should
  // hopefully be the same in both serial and parallel.
  if (_when == WhenType::JACOBIAN && !_jac_has_thrown && time_to_throw() &&
      (_rank == DofObject::invalid_processor_id || _rank == processor_id()))
  {
    // The Jacobian has now thrown
    _jac_has_thrown = true;

    if (_should_throw)
      throw MooseException("MooseException thrown during Jacobian calculation");
    else
      mooseError("Intentional error triggered during Jacobian calculation");
  }

  return 0.;
}