<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 "ElementalVariableValue.h"
#include "MooseMesh.h"
#include "SubProblem.h"

// libMesh
#include "libmesh/boundary_info.h"

template<>
InputParameters validParams<ElementalVariableValue>()
{
  InputParameters params = validParams<GeneralPostprocessor>();
  params.addRequiredParam<VariableName>("variable", "The variable to be monitored");
  params.addRequiredParam<unsigned int>("elementid", "The ID of the element where we monitor");
  return params;
}

ElementalVariableValue::ElementalVariableValue(const std::string & name, InputParameters parameters) :
    GeneralPostprocessor(name, parameters),
    _mesh(_subproblem.mesh()),
    _var_name(parameters.get<VariableName>("variable")),
    _element(_mesh.elem(parameters.get<unsigned int>("elementid")))
{
}

Real
ElementalVariableValue::getValue()
{
  Real value = 0;

  if(_element->processor_id() == libMesh::processor_id())
  {
    _subproblem.prepare(_element, _tid);
    _subproblem.reinitElem(_element, _tid);

    MooseVariable & var = _subproblem.getVariable(_tid, _var_name);
    VariableValue & u = var.sln();
    unsigned int n = u.size();
    for (unsigned int i = 0; i < n; i++)
      value += u[i];
    value /= n;
  }

  gatherSum(value);

  return value;
}<commit_msg>Make the ElementalVariableValue postprocessor safe to use with ParallelMesh.<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 "ElementalVariableValue.h"
#include "MooseMesh.h"
#include "SubProblem.h"

// libMesh
#include "libmesh/boundary_info.h"

template<>
InputParameters validParams<ElementalVariableValue>()
{
  InputParameters params = validParams<GeneralPostprocessor>();
  params.addRequiredParam<VariableName>("variable", "The variable to be monitored");
  params.addRequiredParam<unsigned int>("elementid", "The ID of the element where we monitor");
  return params;
}

ElementalVariableValue::ElementalVariableValue(const std::string & name, InputParameters parameters) :
    GeneralPostprocessor(name, parameters),
    _mesh(_subproblem.mesh()),
    _var_name(parameters.get<VariableName>("variable")),
    _element(_mesh.getMesh().query_elem(parameters.get<unsigned int>("elementid")))
{
}

Real
ElementalVariableValue::getValue()
{
  Real value = 0;

  if (_element && (_element->processor_id() == libMesh::processor_id()))
  {
    _subproblem.prepare(_element, _tid);
    _subproblem.reinitElem(_element, _tid);

    MooseVariable & var = _subproblem.getVariable(_tid, _var_name);
    VariableValue & u = var.sln();
    unsigned int n = u.size();
    for (unsigned int i = 0; i < n; i++)
      value += u[i];
    value /= n;
  }

  gatherSum(value);

  return value;
}
{'fraction_non_alphanumeric': 0.16597890875745072, 'fraction_numerical': 0.0068775790921595595, 'mean_word_length': 2.1939970717423134, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '2009019', 'n_tokens_mistral': 1113, 'n_tokens_neox': 1053, 'n_words': 258}