<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 "AddPeriodicBCAction.h"
#include "InputParameters.h"
#include "FunctionPeriodicBoundary.h"
#include "NonlinearSystem.h"
#include "FEProblem.h"
#include "GeneratedMesh.h"
#include "MooseMesh.h"

// LibMesh includes
#include "libmesh/periodic_boundary.h" // translation PBCs provided by libmesh

template<>
InputParameters validParams<AddPeriodicBCAction>()
{
  InputParameters params = validParams<Action>();
  params.addParam<std::vector<std::string> >("auto_direction", "If using a generated mesh, you can specifiy just the dimension(s) you want to mark as periodic");

  params.addParam<BoundaryName>("primary", "Boundary ID associated with the primary boundary.");
  params.addParam<BoundaryName>("secondary", "Boundary ID associated with the secondary boundary.");
  params.addParam<RealVectorValue>("translation", "Vector that translates coordinates on the primary boundary to coordinates on the secondary boundary.");
  params.addParam<std::vector<std::string> >("transform_func", "Functions that specify the transformation");
  params.addParam<std::vector<std::string> >("inv_transform_func", "Functions that specify the inverse transformation");

  params.addParam<std::vector<VariableName> >("variable", "Variable for the periodic boundary");
  return params;
}

AddPeriodicBCAction::AddPeriodicBCAction(InputParameters params) :
    Action(params)
{
}

void
AddPeriodicBCAction::setPeriodicVars(PeriodicBoundaryBase & p, const std::vector<VariableName> & var_names)
{
  NonlinearSystem & nl = _problem->getNonlinearSystem();
  const std::vector<VariableName> * var_names_ptr;

  // If var_names is empty - then apply this periodic condition to all variables in the system
  if (var_names.empty())
    var_names_ptr = &nl.getVariableNames();
  else
    var_names_ptr = &var_names;

  for (const auto & var_name : *var_names_ptr)
  {
    unsigned int var_num = nl.getVariable(0, var_name).number();

    p.set_variable(var_num);
    _mesh->addPeriodicVariable(var_num, p.myboundary, p.pairedboundary);
  }
}

bool
AddPeriodicBCAction::autoTranslationBoundaries()
{
  if (isParamValid("auto_direction"))
  {
    // If we are working with a parallel mesh then we're going to ghost all the boundaries everywhere because we don't know what we need...
    if (_mesh->isDistributedMesh())
    {
      const std::set<BoundaryID> & ids = _mesh->meshBoundaryIds();
      for (const auto & bid : ids)
        _problem->addGhostedBoundary(bid);

      _problem->ghostGhostedBoundaries();
      _mesh->detectOrthogonalDimRanges();
    }

    NonlinearSystem & nl = _problem->getNonlinearSystem();
    std::vector<std::string> auto_dirs = getParam<std::vector<std::string> >("auto_direction");<commit_msg>Catch return value of detectOrthogonalDimRanges.<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 "AddPeriodicBCAction.h"
#include "InputParameters.h"
#include "FunctionPeriodicBoundary.h"
#include "NonlinearSystem.h"
#include "FEProblem.h"
#include "GeneratedMesh.h"
#include "MooseMesh.h"

// LibMesh includes
#include "libmesh/periodic_boundary.h" // translation PBCs provided by libmesh

template<>
InputParameters validParams<AddPeriodicBCAction>()
{
  InputParameters params = validParams<Action>();
  params.addParam<std::vector<std::string> >("auto_direction", "If using a generated mesh, you can specifiy just the dimension(s) you want to mark as periodic");

  params.addParam<BoundaryName>("primary", "Boundary ID associated with the primary boundary.");
  params.addParam<BoundaryName>("secondary", "Boundary ID associated with the secondary boundary.");
  params.addParam<RealVectorValue>("translation", "Vector that translates coordinates on the primary boundary to coordinates on the secondary boundary.");
  params.addParam<std::vector<std::string> >("transform_func", "Functions that specify the transformation");
  params.addParam<std::vector<std::string> >("inv_transform_func", "Functions that specify the inverse transformation");

  params.addParam<std::vector<VariableName> >("variable", "Variable for the periodic boundary");
  return params;
}

AddPeriodicBCAction::AddPeriodicBCAction(InputParameters params) :
    Action(params)
{
}

void
AddPeriodicBCAction::setPeriodicVars(PeriodicBoundaryBase & p, const std::vector<VariableName> & var_names)
{
  NonlinearSystem & nl = _problem->getNonlinearSystem();
  const std::vector<VariableName> * var_names_ptr;

  // If var_names is empty - then apply this periodic condition to all variables in the system
  if (var_names.empty())
    var_names_ptr = &nl.getVariableNames();
  else
    var_names_ptr = &var_names;

  for (const auto & var_name : *var_names_ptr)
  {
    unsigned int var_num = nl.getVariable(0, var_name).number();

    p.set_variable(var_num);
    _mesh->addPeriodicVariable(var_num, p.myboundary, p.pairedboundary);
  }
}

bool
AddPeriodicBCAction::autoTranslationBoundaries()
{
  if (isParamValid("auto_direction"))
  {
    // If we are working with a parallel mesh then we're going to ghost all the boundaries everywhere because we don't know what we need...
    if (_mesh->isDistributedMesh())
    {
      const std::set<BoundaryID> & ids = _mesh->meshBoundaryIds();
      for (const auto & bid : ids)
        _problem->addGhostedBoundary(bid);

      _problem->ghostGhostedBoundaries();

      bool is_orthogonal_mesh = _mesh->detectOrthogonalDimRanges();

      // If we can't detect the orthogonal dimension ranges for this
      // Mesh, then auto_direction periodicity isn't going to work.
      if (!is_orthogonal_mesh)
        mooseError("Could not detect orthogonal dimension ranges for DistributedMesh.");
    }

    NonlinearSystem & nl = _problem->getNonlinearSystem();
    std::vector<std::string> auto_dirs = getParam<std::vector<std::string> >("auto_direction");
{'fraction_non_alphanumeric': 0.1385782747603834, 'fraction_numerical': 0.003727369542066028, 'mean_word_length': 3.0588870880605077, 'pattern_counts': {'":': 0, '<': 43, '<?xml version=': 0, '>': 59, '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': '3302664', 'n_tokens_mistral': 2013, 'n_tokens_neox': 1934, 'n_words': 525}