<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 "GapValueAux.h"

#include "MooseMesh.h"
#include "SystemBase.h"
#include "MooseEnum.h"

#include "string_to_enum.h"

template<>
InputParameters validParams<GapValueAux>()
{
  MooseEnum orders("FIRST, SECOND, THIRD, FOURTH", "FIRST");

  InputParameters params = validParams<AuxKernel>();
  params.addRequiredParam<BoundaryName>("paired_boundary", "The boundary on the other side of a gap.");
  params.addRequiredParam<VariableName>("paired_variable", "The variable to get the value of.");
  params.set<bool>("use_displaced_mesh") = true;
  params.addParam<Real>("tangential_tolerance", "Tangential distance to extend edges of contact surfaces");
  params.addParam<MooseEnum>("order", orders, "The finite element order");
  params.addParam<bool>("warnings", false, "Whether to output warning messages concerning nodes not being found");
  return params;
}

//
// Look up the MooseVariable and index directly (not using the Coupleable
// interface) to avoid an inappropriate error check.
//
MooseVariable &
getVariable(InputParameters & params, const std::string & name)
{
  SubProblem & problem = *params.get<SubProblem*>("_subproblem");
  if (!problem.hasVariable( name ))
  {
    mooseError("Unable to find variable " + name);
  }
  return problem.getVariable( params.get<THREAD_ID>("_tid"), name );
}

GapValueAux::GapValueAux(const std::string & name, InputParameters parameters) :
    AuxKernel(name, parameters),
    _penetration_locator(_nodal ?  getPenetrationLocator(parameters.get<BoundaryName>("paired_boundary"), getParam<std::vector<BoundaryName> >("boundary")[0], Utility::string_to_enum<Order>(parameters.get<MooseEnum>("order"))) : getQuadraturePenetrationLocator(parameters.get<BoundaryName>("paired_boundary"), getParam<std::vector<BoundaryName> >("boundary")[0], Utility::string_to_enum<Order>(parameters.get<MooseEnum>("order")))),
    _moose_var(_subproblem.getVariable(_tid, getParam<VariableName>("paired_variable"))),
    _serialized_solution(_moose_var.sys().currentSolution()),
    _dof_map(_moose_var.dofMap()),
    _warnings(getParam<bool>("warnings"))
{
  if (parameters.isParamValid("tangential_tolerance"))
  {
    _penetration_locator.setTangentialTolerance(getParam<Real>("tangential_tolerance"));
  }
  MooseVariable & pv(getVariable(parameters, getParam<VariableName>("paired_variable")));
  Order pairedVarOrder(pv.getOrder());
  Order gvaOrder(Utility::string_to_enum<Order>(parameters.get<MooseEnum>("order")));
  if (pairedVarOrder != gvaOrder && pairedVarOrder != CONSTANT)
  {
    mooseError("ERROR: specified order for GapValueAux ("<<Utility::enum_to_string<Order>(gvaOrder)
               <<") does not match order for paired_variable \""<<pv.name()<<"\" ("
               <<Utility::enum_to_string<Order>(pairedVarOrder)<<")");
  }
}

GapValueAux::~GapValueAux()
{
}

Real
GapValueAux::computeValue()
{
  const Node * current_node = NULL;

  if(_nodal)
    current_node = _current_node;
  else
    current_node = _mesh.getQuadratureNode(_current_elem, _current_side, _qp);

  PenetrationLocator::PenetrationInfo * pinfo = _penetration_locator._penetration_info[current_node->id()];

  Real gap_value(0.0);

  if (pinfo)
  {
    if (_moose_var.feType().order != CONSTANT)
    {
      Elem * side = pinfo->_side;
      std::vector<std::vector<Real> > & side_phi = pinfo->_side_phi;
      std::vector<unsigned int> side_dof_indices;

      _dof_map.dof_indices(side, side_dof_indices, _moose_var.number());

      for (unsigned int i=0; i < side_dof_indices.size(); ++i)
      {
        //The zero index is because we only have one point that the phis are evaluated at
        gap_value += side_phi[i][0] * (*_serialized_solution)(side_dof_indices[i]);
      }
    }
    else
    {
      const Elem * elem = pinfo->_elem;
      std::vector<unsigned int> side_dof_indices;
      _dof_map.dof_indices(elem, side_dof_indices, _moose_var.number());
      mooseAssert(side_dof_indices.size() == 1, "Wrong size for dof indices");
      gap_value = (*_serialized_solution)(side_dof_indices[0]);
    }
  }
  else
  {
    if (_warnings)
    {
      std::stringstream msg;
      msg << "No gap value information found for node ";
      msg << current_node->id();
      msg << " on processor ";
      msg << libMesh::processor_id();
      mooseWarning( msg.str() );
    }
  }
  return gap_value;
}
<commit_msg>Add exodiff tolerance file for test<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 "GapValueAux.h"

#include "MooseMesh.h"
#include "SystemBase.h"
#include "MooseEnum.h"

#include "string_to_enum.h"

template<>
InputParameters validParams<GapValueAux>()
{
  MooseEnum orders("FIRST, SECOND, THIRD, FOURTH", "FIRST");

  InputParameters params = validParams<AuxKernel>();
  params.addRequiredParam<BoundaryName>("paired_boundary", "The boundary on the other side of a gap.");
  params.addRequiredParam<VariableName>("paired_variable", "The variable to get the value of.");
  params.set<bool>("use_displaced_mesh") = true;
  params.addParam<Real>("tangential_tolerance", "Tangential distance to extend edges of contact surfaces");
  params.addParam<MooseEnum>("order", orders, "The finite element order");
  params.addParam<bool>("warnings", false, "Whether to output warning messages concerning nodes not being found");
  return params;
}

//
// Look up the MooseVariable and index directly (not using the Coupleable
// interface) to avoid an inappropriate error check.
//
MooseVariable &
getVariable(InputParameters & params, const std::string & name)
{
  SubProblem & problem = *params.get<SubProblem*>("_subproblem");
  if (!problem.hasVariable( name ))
  {
    mooseError("Unable to find variable " + name);
  }
  return problem.getVariable( params.get<THREAD_ID>("_tid"), name );
}

GapValueAux::GapValueAux(const std::string & name, InputParameters parameters) :
    AuxKernel(name, parameters),
    _penetration_locator(_nodal ?  getPenetrationLocator(parameters.get<BoundaryName>("paired_boundary"), getParam<std::vector<BoundaryName> >("boundary")[0], Utility::string_to_enum<Order>(parameters.get<MooseEnum>("order"))) : getQuadraturePenetrationLocator(parameters.get<BoundaryName>("paired_boundary"), getParam<std::vector<BoundaryName> >("boundary")[0], Utility::string_to_enum<Order>(parameters.get<MooseEnum>("order")))),
    _moose_var(_subproblem.getVariable(_tid, getParam<VariableName>("paired_variable"))),
    _serialized_solution(_moose_var.sys().currentSolution()),
    _dof_map(_moose_var.dofMap()),
    _warnings(getParam<bool>("warnings"))
{
  if (parameters.isParamValid("tangential_tolerance"))
  {
    _penetration_locator.setTangentialTolerance(getParam<Real>("tangential_tolerance"));
  }
  MooseVariable & pv(getVariable(parameters, getParam<VariableName>("paired_variable")));
  Order pairedVarOrder(pv.getOrder());
  Order gvaOrder(Utility::string_to_enum<Order>(parameters.get<MooseEnum>("order")));
  if (pairedVarOrder != gvaOrder && pairedVarOrder != CONSTANT)
  {
    mooseError("ERROR: specified order for GapValueAux ("<<Utility::enum_to_string<Order>(gvaOrder)
               <<") does not match order for paired_variable \""<<pv.name()<<"\" ("
               <<Utility::enum_to_string<Order>(pairedVarOrder)<<")");
  }
}

GapValueAux::~GapValueAux()
{
}

Real
GapValueAux::computeValue()
{
  const Node * current_node = NULL;

  if(_nodal)
    current_node = _current_node;
  else
    current_node = _mesh.getQuadratureNode(_current_elem, _current_side, _qp);

  PenetrationLocator::PenetrationInfo * pinfo = _penetration_locator._penetration_info[current_node->id()];

  Real gap_value(0.0);

  if (pinfo)
  {
    if (_moose_var.feType().order != CONSTANT)
    {
      Elem * side = pinfo->_side;
      std::vector<std::vector<Real> > & side_phi = pinfo->_side_phi;
      std::vector<unsigned int> side_dof_indices;

      _dof_map.dof_indices(side, side_dof_indices, _moose_var.number());

      for (unsigned int i=0; i < side_dof_indices.size(); ++i)
      {
        //The zero index is because we only have one point that the phis are evaluated at
        gap_value += side_phi[i][0] * (*_serialized_solution)(side_dof_indices[i]);
      }
    }
    else
    {
      const Elem * elem = pinfo->_elem;
      std::vector<unsigned int> side_dof_indices;
      _dof_map.dof_indices(elem, side_dof_indices, _moose_var.number());
      mooseAssert(side_dof_indices.size() == 1, "Wrong size for dof indices");
      gap_value = (*_serialized_solution)(side_dof_indices[0]);
    }
  }
  else
  {
    if (_warnings)
    {
      std::stringstream msg;
      msg << "No gap value information found for node ";
      msg << current_node->id();
      msg << " on processor ";
      msg << libMesh::processor_id();
      mooseWarning( msg.str() );
    }
  }
  return gap_value;
}
{'fraction_non_alphanumeric': 0.15267321071190318, 'fraction_numerical': 0.004002668445630421, 'mean_word_length': 3.3597839634399667, 'pattern_counts': {'":': 0, '<': 111, '<?xml version=': 0, '>': 79, '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': '395903', 'n_tokens_mistral': 3209, 'n_tokens_neox': 3130, 'n_words': 625}