コード例 #1
0
ファイル: AuxKernel.C プロジェクト: radioactivekate/moose
void
AuxKernel::compute()
{
  precalculateValue();

  if (isNodal()) /* nodal variables */
  {
    if (_var.isNodalDefined())
    {
      _qp = 0;
      Real value = computeValue();
      // update variable data, which is referenced by other kernels, so the value is up-to-date
      _var.setNodalValue(value);
    }
  }
  else /* elemental variables */
  {
    _n_local_dofs = _var.numberOfDofs();

    if (_n_local_dofs == 1) /* p0 */
    {
      Real value = 0;
      for (_qp = 0; _qp < _qrule->n_points(); _qp++)
        value += _JxW[_qp] * _coord[_qp] * computeValue();
      value /= (_bnd ? _current_side_volume : _current_elem_volume);
      // update the variable data refernced by other kernels.
      // Note that this will update the values at the quadrature points too
      // (because this is an Elemental variable)
      _var.setNodalValue(value);
    }
    else /* high-order */
    {
      _local_re.resize(_n_local_dofs);
      _local_re.zero();
      _local_ke.resize(_n_local_dofs, _n_local_dofs);
      _local_ke.zero();

      // assemble the local mass matrix and the load
      for (unsigned int i = 0; i < _test.size(); i++)
        for (_qp = 0; _qp < _qrule->n_points(); _qp++)
        {
          Real t = _JxW[_qp] * _coord[_qp] * _test[i][_qp];
          _local_re(i) += t * computeValue();
          for (unsigned int j = 0; j < _test.size(); j++)
            _local_ke(i, j) += t * _test[j][_qp];
        }

      // mass matrix is always SPD
      _local_sol.resize(_n_local_dofs);
      _local_ke.cholesky_solve(_local_re, _local_sol);

      _var.setNodalValue(_local_sol);
    }
  }
}
コード例 #2
0
void
ElementH1ErrorFunctionAux::compute()
{
  precalculateValue();

  if (isNodal())
    mooseError("ElementH1ErrorFunctionAux only makes sense as an Elemental AuxVariable.");

  Real summed_value = 0;
  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
  {
    Real val = computeValue(); // already raised to the p, see below.
    summed_value += _JxW[_qp] * _coord[_qp] * val;
  }

  _var.setNodalValue(std::pow(summed_value, 1./_p));
}
コード例 #3
0
ファイル: ElementLpNormAux.C プロジェクト: aeslaughter/moose
void
ElementLpNormAux::compute()
{
  precalculateValue();

  if (isNodal())
    mooseError("ElementLpNormAux only makes sense as an Elemental AuxVariable.");

  // Sum up the squared-error values by calling computeValue(), then
  // return the sqrt of the result.
  Real summed_value = 0;
  for (_qp = 0; _qp < _qrule->n_points(); _qp++)
  {
    Real val = computeValue();
    summed_value += _JxW[_qp] * _coord[_qp] * std::pow(std::abs(val), _p);
  }

  _var.setNodalValue(std::pow(summed_value, 1. / _p));
}