<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 "MooseMesh.h"
#include "Factory.h"
#include "MeshModifier.h"
#include "GatherNearbyElements.h"

// libMesh
#include "boundary_info.h"
#include "mesh_tools.h"
#include "mesh_refinement.h"
#include "parallel.h"
#include "mesh_communication.h"
#include "parallel_mesh.h"

static const int GRAIN_SIZE = 1;     // the grain_size does not have much influence on our execution speed


MooseMesh::MooseMesh(int mesh_dim) :
    _mesh(mesh_dim),
    _is_changed(false),
    //_is_parallel(false),
    _init_refinement_level(0),
    _active_local_elem_range(NULL),
    _active_semilocal_node_range(NULL),
    _active_node_range(NULL),
    _local_node_range(NULL),
    _bnd_node_range(NULL)
{
}

MooseMesh::MooseMesh(const MooseMesh & other_mesh) :
    _mesh(other_mesh._mesh),
    _is_changed(false),
    //_is_parallel(false),
    _init_refinement_level(other_mesh._init_refinement_level),
    _active_local_elem_range(NULL),
    _active_semilocal_node_range(NULL),
    _active_node_range(NULL),
    _local_node_range(NULL),
    _bnd_node_range(NULL)
{
  (*_mesh.boundary_info) = (*other_mesh._mesh.boundary_info);
}

MooseMesh::~MooseMesh()
{
  freeBndNodes();

  delete _active_local_elem_range;
  delete _active_node_range;
  delete _active_semilocal_node_range;
  delete _local_node_range;
  delete _bnd_node_range;
}

void
MooseMesh::freeBndNodes()
{
  // free memory
  for (std::vector<BndNode *>::iterator it = _bnd_nodes.begin(); it != _bnd_nodes.end(); ++it)
    delete (*it);
}

void
MooseMesh::read(const std::string file_name)
{
  _mesh.read(file_name);
}

void
MooseMesh::prepare()
{
  // This is now done in Nemesis_IO::read()
  // If we are using a truly Parallel mesh (like Nemesis) then we might not even have neighbors!
//  if(parallel())
//    MeshCommunication().gather_neighboring_elements(libmesh_cast_ref<ParallelMesh&>(getMesh()));
//
  if(!_mesh.is_serial())
    Moose::gatherNearbyElements(*this, _ghosted_boundaries, _ghosted_boundaries_inflation);

  _mesh.prepare_for_use(false);
  
  // If using ParallelMesh this will delete non-local elements from the current processor
  // If using SerialMesh, this function is a no-op.
  _mesh.delete_remote_elements();

  

  // Collect (local) subdomain IDs
  const MeshBase::element_iterator el_end = _mesh.elements_end();

  unsigned int num_elems = 0;
  for (MeshBase::element_iterator el = _mesh.elements_begin(); el != el_end; ++el)
    num_elems++;

//  std::cerr<<libMesh::processor_id()<<": num_elems: "<<num_elems<<std::endl;

  Parallel::sum(num_elems);

//  std::cout<<"Total elems: "<<num_elems<<std::endl;
  
  
  for (MeshBase::element_iterator el = _mesh.elements_begin(); el != el_end; ++el)<commit_msg>fix for boundary ghosting<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 "MooseMesh.h"
#include "Factory.h"
#include "MeshModifier.h"
#include "GatherNearbyElements.h"

// libMesh
#include "boundary_info.h"
#include "mesh_tools.h"
#include "mesh_refinement.h"
#include "parallel.h"
#include "mesh_communication.h"
#include "parallel_mesh.h"

static const int GRAIN_SIZE = 1;     // the grain_size does not have much influence on our execution speed


MooseMesh::MooseMesh(int mesh_dim) :
    _mesh(mesh_dim),
    _is_changed(false),
    //_is_parallel(false),
    _init_refinement_level(0),
    _active_local_elem_range(NULL),
    _active_semilocal_node_range(NULL),
    _active_node_range(NULL),
    _local_node_range(NULL),
    _bnd_node_range(NULL)
{
}

MooseMesh::MooseMesh(const MooseMesh & other_mesh) :
    _mesh(other_mesh._mesh),
    _is_changed(false),
    //_is_parallel(false),
    _init_refinement_level(other_mesh._init_refinement_level),
    _active_local_elem_range(NULL),
    _active_semilocal_node_range(NULL),
    _active_node_range(NULL),
    _local_node_range(NULL),
    _bnd_node_range(NULL)
{
  (*_mesh.boundary_info) = (*other_mesh._mesh.boundary_info);
}

MooseMesh::~MooseMesh()
{
  freeBndNodes();

  delete _active_local_elem_range;
  delete _active_node_range;
  delete _active_semilocal_node_range;
  delete _local_node_range;
  delete _bnd_node_range;
}

void
MooseMesh::freeBndNodes()
{
  // free memory
  for (std::vector<BndNode *>::iterator it = _bnd_nodes.begin(); it != _bnd_nodes.end(); ++it)
    delete (*it);
}

void
MooseMesh::read(const std::string file_name)
{
  _mesh.read(file_name);
}

void
MooseMesh::prepare()
{
  // This is now done in Nemesis_IO::read()
  // If we are using a truly Parallel mesh (like Nemesis) then we might not even have neighbors!
//  if(parallel())
//    MeshCommunication().gather_neighboring_elements(libmesh_cast_ref<ParallelMesh&>(getMesh()));
//
  _mesh.prepare_for_use(false);
  
  // If using ParallelMesh this will delete non-local elements from the current processor
  // If using SerialMesh, this function is a no-op.
  _mesh.delete_remote_elements();
  
  if(!_mesh.is_serial())
    Moose::gatherNearbyElements(*this, _ghosted_boundaries, _ghosted_boundaries_inflation);
  
  // Collect (local) subdomain IDs
  const MeshBase::element_iterator el_end = _mesh.elements_end();
/*
  unsigned int num_elems = 0;
  for (MeshBase::element_iterator el = _mesh.elements_begin(); el != el_end; ++el)
    num_elems++;

//  std::cerr<<libMesh::processor_id()<<": num_elems: "<<num_elems<<std::endl;

  Parallel::sum(num_elems);

  std::cout<<"Total elems: "<<num_elems<<std::endl;
*/
  
  for (MeshBase::element_iterator el = _mesh.elements_begin(); el != el_end; ++el)
{'fraction_non_alphanumeric': 0.1502373638648422, 'fraction_numerical': 0.004468025691147724, 'mean_word_length': 2.897170837867247, 'pattern_counts': {'":': 2, '<': 35, '<?xml version=': 0, '>': 7, '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': '337442', 'n_tokens_mistral': 2274, 'n_tokens_neox': 2211, 'n_words': 448}