Beispiel #1
0
Real
SolutionAux::computeValue()
{
  // The value to output
  Real output;

  // _direct=true, extract the values using the dof
  if (_direct)
  {
    if (isNodal())
      output = _solution_object.directValue(_current_node, _var_name);

    else
      output = _solution_object.directValue(_current_elem, _var_name);
  }

  // _direct=false, extract the values using time and point
  else
  {
    if (isNodal())
      output = _solution_object.pointValue(_t, *_current_node, _var_name);

    else
      output = _solution_object.pointValue(_t, _current_elem->centroid(), _var_name);
  }

  // Apply factors and return the value
  return _scale_factor*output + _add_factor;
}
GlobalDisplacementAux::GlobalDisplacementAux(const InputParameters & parameters)
  : AuxKernel(parameters),
    _scalar_global_strain(coupledScalarValue("scalar_global_strain")),
    _component(getParam<unsigned int>("component")),
    _output_global_disp(getParam<bool>("output_global_displacement")),
    _pst(getUserObject<GlobalStrainUserObjectInterface>("global_strain_uo")),
    _periodic_dir(_pst.getPeriodicDirections()),
    _dim(_mesh.dimension()),
    _ndisp(coupledComponents("displacements")),
    _disp(_ndisp)
{
  if (!isNodal())
    paramError("variable", "GlobalDisplacementAux must be used on a nodal auxiliary variable");

  if (_component >= _dim)
    paramError("component",
               "The component ",
               _component,
               " does not exist for ",
               _dim,
               " dimensional problems");

  for (unsigned int i = 0; i < _ndisp; ++i)
    _disp[i] = &coupledValue("displacements", i);
}
void
EulerAngleProvider2RGBAux::precalculateValue()
{
  // ID of unique grain at current point
  const int grain_id = _grain_tracker.getEntityValue((isNodal() ? _current_node->id() : _current_elem->id()),
                                                              FeatureFloodCount::FieldType::UNIQUE_REGION, 0);
  // Recover euler angles for current grain
  RealVectorValue angles;
  if (grain_id >= 0)
    angles = _euler.getEulerAngles(grain_id);

  // Assign correct RGB value either from euler2RGB or from _no_grain_color
  Point RGB;
  if (grain_id < 0) //If not in a grain, return _no_grain_color
    RGB = _no_grain_color;
  else
    RGB = euler2RGB(_sd, angles(0) / 180.0 * libMesh::pi, angles(1) / 180.0 * libMesh::pi, angles(2) / 180.0 * libMesh::pi, 1.0, _xtal_class);

  // Create correct scalar output
  if (_output_type < 3)
    _value = RGB(_output_type);
  else if (_output_type == 3)
  {
      Real RGBint = 0.0;
      for (unsigned int i = 0; i < 3; ++i)
        RGBint = 256 * RGBint + (RGB(i) >= 1 ? 255 : std::floor(RGB(i) * 256.0));

      _value = RGBint;
  }
  else
    mooseError("Incorrect value for output_type in EulerAngleProvider2RGBAux");
}
Beispiel #4
0
Real
NodalFloodCountAux::computeValue()
{
  switch (_field_display)
  {
  case 0:  // UNIQUE_REGION
  case 1:  // VARIABLE_COLORING
    return _flood_counter.getNodalValue(_current_node->id(), _var_idx, _var_coloring);
  case 2:  // ACTIVE_BOUNDS
    if (isNodal())
      return _flood_counter.getNodalValues(_current_node->id()).size();
    else
    {
      size_t size=0;
      std::vector<std::vector<std::pair<unsigned int, unsigned int> > > values = _flood_counter.getElementalValues(_current_elem->id());

      for (unsigned int i = 0; i < values.size(); ++i)
        size += values[i].size();
      return size;
    }
  case 3:  // CENTROID
    return _flood_counter.getElementalValue(_current_elem->id());
  }

  return 0;
}
Beispiel #5
0
void
FeatureFloodCountAux::precalculateValue()
{
  switch (_field_display)
  {
  case 0:  // UNIQUE_REGION
  case 1:  // VARIABLE_COLORING
  case 2:  // GHOSTED_ENTITIES
  case 3:  // HALOS
  case 4:  // CENTROID
    _value = _flood_counter.getEntityValue((isNodal() ? _current_node->id() : _current_elem->id()), _field_type, _var_idx);
    break;
  case 5:  // ACTIVE_BOUNDS
    if (_grain_tracker_ptr)
    {
      const auto & op_to_grains = _grain_tracker_ptr->getOpToGrainsVector(_current_elem->id());
      _value = std::count_if(op_to_grains.begin(), op_to_grains.end(),
                             [](unsigned int grain_id)
                             {
                               return grain_id != libMesh::invalid_uint;
                             });
    }
    else
      _value = 0;
    break;
  default:
    mooseError("Unimplemented \"field_display\" type");
  }
}
Beispiel #6
0
Real
NewmarkVelAux::computeValue()
{
  Real vel_old = _u_old[_qp];
  if (!isNodal())
    mooseError("must run on a nodal variable");
  return vel_old + (_dt*(1-_gamma))*_accel_old[_qp] + _gamma*_dt*_accel[_qp];
}
Beispiel #7
0
Real
ProcessorIDAux::computeValue()
{
  if (isNodal())
    return _current_node->processor_id();
  else
    return _current_elem->processor_id();
}
Beispiel #8
0
Real
AccumulateAux::computeValue()
{
  if (isNodal())
    return _var.nodalSln()[_qp] + _accumulate_from[_qp];
  else
    return _var.nodalSln()[0] + _accumulate_from[_qp];
}
Beispiel #9
0
Real
Position::computeValue()
{
  if (isNodal())
    return (*_current_node)(0) / _r_units;
  else
    return _q_point[_qp](0) / _r_units;
}
Beispiel #10
0
Real
FunctionAux::computeValue()
{
  if (isNodal())
    return _func.value(_t, *_current_node);
  else
    return _func.value(_t, _q_point[_qp]);
}
Beispiel #11
0
Real
FunctionOfVariableAux::computeValue()
{
  Real t_val = _t_variable[_qp];
  if (isNodal())
    return _func.value(t_val, *_current_node);
  else
    return _func.value(t_val, _current_elem->centroid());
}
Beispiel #12
0
Real
NewmarkVelAux::computeValue()
{
  Real vel_old = _u_old[_qp];
  if (!isNodal())
    mooseError("must run on a nodal variable");
  // Calculates Velocity using Newmark time integration scheme
  return vel_old + (_dt * (1 - _gamma)) * _accel_old[_qp] + _gamma * _dt * _accel[_qp];
}
Beispiel #13
0
Real
TestNewmarkTI::computeValue()
{
  if (!isNodal())
    mooseError("must run on a nodal variable");

  // assigns the first/second time derivative of displacement to the provided auxvariable
  return _value[_qp];
}
Beispiel #14
0
Real
FissionRateAux::computeValue()
{
  //Aux to calcu the fission rate.Axial and radical power function are defined as function1 and 2.
  if (isNodal())
  return _Function1->value(_t,*_current_node)*_Function2->value(_t,*_current_node)/_energy_per_fission;
  else
  return _Function1->value(_t,_q_point[_qp])*_Function2->value(_t,_q_point[_qp])/_energy_per_fission;
}
VectorVariableComponentAux::VectorVariableComponentAux(const InputParameters & parameters)
  : AuxKernel(parameters),
    _vector_variable_value(coupledNodalValue<RealVectorValue>("vector_variable")),
    _component(getParam<MooseEnum>("component"))
{
  if (!isNodal())
    mooseError(
        "VectorVariableComponentAux is meant to be used with LAGRANGE_VEC variables and so the "
        "auxiliary variable should be nodal");
}
Beispiel #16
0
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);
    }
  }
}
Beispiel #17
0
Real
NewmarkAccelAux::computeValue()
{
  if (!isNodal())
    mooseError("must run on a nodal variable");

  Real accel_old = _u_old[_qp];
  if (_dt == 0)
    return accel_old;
  return 1/_beta*(((_disp[_qp]-_disp_old[_qp])/(_dt*_dt)) - _vel_old[_qp]/_dt - accel_old*(0.5-_beta));
}
Beispiel #18
0
MultipleUpdateElemAux::MultipleUpdateElemAux(const InputParameters & parameters) :
    AuxKernel(parameters),
    _n_vars(coupledComponents("vars"))
{
    for (unsigned int i=0; i<_n_vars; i++)
    {
        _vars.push_back(getVar("vars", i));
        if (_vars[i]->isNodal()) mooseError("variables have to be elemental");
    }
    if (isNodal()) mooseError("variable have to be elemental");
}
Beispiel #19
0
void
MooseVariable::computeIncrementAtNode(const NumericVector<Number> & increment_vec)
{
  if (!isNodal())
    mooseError("computeIncrementAtNode can only be called for nodal variables");

  _increment.resize(1);

  // Compute the increment for the current DOF
  _increment[0] = increment_vec(_dof_indices[0]);
}
Beispiel #20
0
void
MooseVariable::setNodalValueNeighbor(Number value)
{
  _nodal_u_neighbor[0] = value;                  // update variable nodal value
  _has_nodal_value_neighbor = true;

  if (!isNodal()) // If this is an elemental variable, then update the qp values as well
  {
    for (unsigned int qp=0; qp<_u_neighbor.size(); qp++)
      _u_neighbor[qp] = value;
  }
}
Beispiel #21
0
Real
OutputEulerAngles::computeValue()
{
  // ID of unique grain at current point
  const unsigned int grain_id = _grain_tracker.getEntityValue((isNodal() ? _current_node->id() : _current_elem->id()), 0, false);

  // Recover euler angles for current grain
  const RealVectorValue angles = _euler.getEulerAngles(grain_id);

  // Return specific euler angle
  return angles(_output_euler_angle);
}
Beispiel #22
0
Real
AxialBurnupAux::computeValue()
{
  Real Pi=3.14159265;
  Real temp=(_Density*_Fuel_Percentage*238/270.0)*Pi*pow(_Pellet_Diameter,2)/4.0;
  //Aux to calcu the fission rate.Axial and radical power function are defined as function1 and 2.
  if (isNodal())
  return _AxialPowerDis->value(_t,*_current_node)*_dt/temp;
  else
  return (_AxialPowerDis->value(_t,_q_point[_qp])+_AxialPowerDis->value(_t+_dt,_q_point[_qp]))/2*_dt/temp*1.0e-6+_u_old[_qp];//error NOT *_q_point[_qp]
 //Average burnup can be cal by post..
}
Beispiel #23
0
void
MooseVariable::setNodalValue(Number value, unsigned int idx/* = 0*/)
{
  _nodal_u[idx] = value;                  // update variable nodal value
  _has_nodal_value = true;

  if (!isNodal()) // If this is an elemental variable, then update the qp values as well
  {
    for (unsigned int qp=0; qp<_u.size(); qp++)
      _u[qp] = value;
  }
}
Beispiel #24
0
const VariableValue &
MooseVariable::nodalValuePreviousNL()
{
  if (isNodal())
  {
    _need_nodal_u_previous_nl = true;
    return _nodal_u_previous_nl;
  }
  else
    mooseError("Nodal values can be requested only on nodal variables, variable '",
               name(),
               "' is not nodal.");
}
Beispiel #25
0
const VariableValue &
MooseVariable::nodalValueDotNeighbor()
{
  if (isNodal())
  {
    _need_nodal_u_dot_neighbor = true;
    return _nodal_u_dot_neighbor;
  }
  else
    mooseError("Nodal values can be requested only on nodal variables, variable '",
               name(),
               "' is not nodal.");
}
Beispiel #26
0
FeatureFloodCountAux::FeatureFloodCountAux(const InputParameters & parameters) :
    AuxKernel(parameters),
    _flood_counter(getUserObject<FeatureFloodCount>("flood_counter")),
    _grain_tracker_ptr(dynamic_cast<const GrainTrackerInterface *>(&_flood_counter)),
    _var_idx(isParamValid("map_index") ? getParam<unsigned int>("map_index") : std::numeric_limits<unsigned int>::max()),
    _field_display(getParam<MooseEnum>("field_display")),
    _var_coloring(_field_display == "VARIABLE_COLORING"),
    _field_type(_field_display.getEnum<FeatureFloodCount::FieldType>())
{
  if (_flood_counter.isElemental() == isNodal() &&
      (_field_display == "UNIQUE_REGION" || _field_display == "VARIABLE_COLORING" || _field_display == "GHOSTED_ENTITIES" || _field_display == "HALOS"))
    mooseError("UNIQUE_REGION, VARIABLE_COLORING, GHOSTED_ENTITIES and HALOS must be on variable types that match the entity mode of the FeatureFloodCounter");

  if (isNodal())
  {
    if (_field_display == "ACTIVE_BOUNDS")
      mooseError("ACTIVE_BOUNDS is only available for elemental aux variables");

    if (_field_display == "CENTROID")
      mooseError("CENTROID is only available for elemental aux variables");
  }
}
Beispiel #27
0
/**
 * Auxiliary Kernels override computeValue() instead of computeQpResidual().  Aux Variables
 * are calculated either one per elemenet or one per node depending on whether we declare
 * them as "Elemental (Constant Monomial)" or "Nodal (First Lagrange)".  No changes to the
 * source are necessary to switch from one type or the other.
 */
Real
CoolantChannelAux::computeValue()
{
  //integral power distribution function value
  std::vector<Real> axial_height(_axial_layeredvalue+1);
  std::vector<Real> function_value(_axial_layeredvalue);
  std::vector<Real> integral_value(_axial_layeredvalue+1);
  
  Point  p1;
  p1(0)=0.0;
  p1(1)=0.0;
  p1(2)=0.0;
  
  /*
  0----1----2----3 axial_height
     0----1---2    function_value
  */
  axial_height[0] = 0.0;
  integral_value[0] = 0.0;
  
  axial_height[_axial_layeredvalue] = _total_pellet_height;
  double step=_total_pellet_height/_axial_layeredvalue;
  
  p1(2)=0.5*step;
  function_value[0]=_Axial_Power_Dis.value(_t,p1);
  
  p1(2)=0.0;
  function_value[0]=_Axial_Power_Dis.value(_t,p1);
  //
  for(unsigned int i=1;i<=_axial_layeredvalue-1;++i)
  {
    axial_height[i]=axial_height[i-1]+step;
    p1(2)=p1(2)+step;
    function_value[i]=_Axial_Power_Dis.value(_t,p1);
    integral_value[i] = integral_value[i-1]+function_value[i-1]*step; 
  }
    integral_value[_axial_layeredvalue]=integral_value[_axial_layeredvalue-1]+function_value[_axial_layeredvalue-1]*step;
   
   _coolant_temp.setData(axial_height,integral_value);
    
  if (isNodal())
   mooseError("error!NOT nodal,should be monomial and constant ");
 
  else
  if(_dimension=="2D")
  //2D default axial direction is Y.
  return _coolant_temp.sample(_q_point[_qp](1))/_coef/_coolant_heatcapacity[_qp]/_coolant_density[_qp]+_inlet_temp;
  else
  //3D default axial direction is Z.
  return _coolant_temp.sample(_q_point[_qp](2))/_coef/_coolant_heatcapacity[_qp]/_coolant_density[_qp]+_inlet_temp;
}
Beispiel #28
0
Real
EBSDReaderAvgDataAux::computeValue()
{
  // get the dominant grain for the current element/node
  const int grain_id = _grain_tracker.getEntityValue(isNodal() ? _current_node->id() : _current_elem->id(),
                                                     FeatureFloodCount::FieldType::UNIQUE_REGION, 0);

  // no grain found
  if (grain_id < 0)
    return _invalid;

  // get the data for the grain
  return (*_val)(_ebsd_reader.getAvgData(grain_id));
}
Beispiel #29
0
XFEMCutPlaneAux::XFEMCutPlaneAux(const InputParameters & parameters) :
    AuxKernel(parameters),
    _quantity(Xfem::XFEM_CUTPLANE_QUANTITY(int(getParam<MooseEnum>("quantity")))),
    _plane_id(getParam<unsigned int>("plane_id"))
{
  FEProblem * fe_problem = dynamic_cast<FEProblem *>(&_subproblem);
  if (fe_problem == NULL)
    mooseError("Problem casting _subproblem to FEProblem in XFEMCutPlaneAux");
  _xfem = MooseSharedNamespace::dynamic_pointer_cast<XFEM>(fe_problem->getXFEM());
  if (_xfem == NULL)
    mooseError("Problem casting to XFEM in XFEMCutPlaneAux");
  if (isNodal())
    mooseError("XFEMCutPlaneAux can only be run on an element variable");
}
Beispiel #30
0
Real
NewmarkAccelAux::computeValue()
{
  if (!isNodal())
    mooseError("must run on a nodal variable");

  Real accel_old = _u_old[_qp];
  if (_dt == 0)
    return accel_old;

  // Calculates acceeleration using Newmark time integration method
  return 1.0 / _beta * ((_disp[_qp] - _disp_old[_qp]) / (_dt * _dt) - _vel_old[_qp] / _dt -
                        accel_old * (0.5 - _beta));
}