<commit_before>// $Id$

// The libMesh Finite Element Library.
// Copyright (C) 2002-2008 <NAME>, <NAME>, <NAME>
  
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
  
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
  
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA



// C++ includes
#include <limits>
#include <set>

// Local includes
#include "boundary_info.h"
#include "elem.h"
#include "elem_range.h"
#include "location_maps.h"
#include "mesh_base.h"
#include "mesh_communication.h"
#include "mesh_tools.h"
#include "node_range.h"
#include "parallel.h"
#include "parallel_mesh.h"
#include "serial_mesh.h"
#include "sphere.h"
#include "threads.h"

#ifdef DEBUG
#  include "remote_elem.h"
#endif



// ------------------------------------------------------------
// anonymous namespace for helper classes
namespace {
  /**
   * SumElemWeight(Range) sums the number of nodes per element 
   * for each element in the provided range. The join() method
   * defines how to combine the reduction operation from two
   * distinct instances of this class which may be executed on 
   * separate threads.
   */
  class SumElemWeight
  {
  public:
    SumElemWeight () : 
      _weight(0) 
    {}

    SumElemWeight (SumElemWeight &, Threads::split) : 
      _weight(0)
    {}
    
    void operator()(const ConstElemRange &range)
    { 
      for (ConstElemRange::const_iterator it = range.begin(); it !=range.end(); ++it)
	_weight += (*it)->n_nodes();
    }

    unsigned int weight() const 
    { return _weight; }
    
    void join (const SumElemWeight &other)
    { _weight += other.weight(); }

  private:
    unsigned int _weight;
  };


  /**
   * FindBBox(Range) computes the bounding box for the objects
   * in the specified range.  This class may be split and subranges
   * can be executed on separate threads.  The join() method
   * defines how the results from two separate threads are combined.
   */
  class FindBBox
  {
  public:
    FindBBox () :
      _vmin(3,  std::numeric_limits<Real>::max()),
      _vmax(3, -std::numeric_limits<Real>::max())
    {}

    FindBBox (FindBBox &other, Threads::split) :
      _vmin(other._vmin),
      _vmax(other._vmax)
    {}

    std::vector<Real> & min() { return _vmin; }
    std::vector<Real> & max() { return _vmax; }
    
    void operator()(const ConstNodeRange &range)
    {
      for (ConstNodeRange::const_iterator it = range.begin(); it != range.end(); ++it)
	{
          const Node *node = *it;
	  libmesh_assert (node != NULL);
	  
	  for (unsigned int i=0; i<3; i++)
	    {
	      _vmin[i] = std::min(_vmin[i], (*node)(i));
	      _vmax[i] = std::max(_vmax[i], (*node)(i));
	    }      
        }
    }

    void operator()(const ConstElemRange &range)
    {
      for (ConstElemRange::const_iterator it = range.begin(); it != range.end(); ++it)
	{
          const Elem *elem = *it;
	  libmesh_assert (elem != NULL);

	  for (unsigned int n=0; n<elem->n_nodes(); n++)
	    {
	      const Point &point = elem->point(n);

	      for (unsigned int i=0; i<3; i++)
		{
		  _vmin[i] = std::min(_vmin[i], point(i));
		  _vmax[i] = std::max(_vmax[i], point(i));
		}     
	    } 
        }
    }

    void join (const FindBBox &other)
    {
      for (unsigned int i=0; i<3; i++)
	{
	  _vmin[i] = std::min(_vmin[i], other._vmin[i]);
	  _vmax[i] = std::max(_vmax[i], other._vmax[i]);
	}      
    }

    MeshTools::BoundingBox bbox () const
    {
      Point pmin(_vmin[0], _vmin[1], _vmin[2]);
      Point pmax(_vmax[0], _vmax[1], _vmax[2]);

      const MeshTools::BoundingBox ret_val(pmin, pmax);

      return ret_val;        
    }
    
  private:
    std::vector<Real> _vmin;
    std::vector<Real> _vmax;
  };
}



// ------------------------------------------------------------
// MeshTools functions
unsigned int MeshTools::total_weight(const MeshBase& mesh)
{
  if (!mesh.is_serial())
    {
      parallel_only();
      unsigned int weight = MeshTools::weight (mesh, libMesh::processor_id());
      Parallel::sum(weight);
      unsigned int unpartitioned_weight =
        MeshTools::weight (mesh, DofObject::invalid_processor_id);
      return weight + unpartitioned_weight;<commit_msg>Avoid compiler warnings when compiling without TBB<commit_after>// $Id$

// The libMesh Finite Element Library.
// Copyright (C) 2002-2008 <NAME>, <NAME>, <NAME>
  
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
  
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
  
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA



// C++ includes
#include <limits>
#include <set>

// Local includes
#include "boundary_info.h"
#include "elem.h"
#include "elem_range.h"
#include "location_maps.h"
#include "mesh_base.h"
#include "mesh_communication.h"
#include "mesh_tools.h"
#include "node_range.h"
#include "parallel.h"
#include "parallel_mesh.h"
#include "serial_mesh.h"
#include "sphere.h"
#include "threads.h"

#ifdef DEBUG
#  include "remote_elem.h"
#endif



// ------------------------------------------------------------
// anonymous namespace for helper classes
namespace {
  /**
   * SumElemWeight(Range) sums the number of nodes per element 
   * for each element in the provided range. The join() method
   * defines how to combine the reduction operation from two
   * distinct instances of this class which may be executed on 
   * separate threads.
   */
  class SumElemWeight
  {
  public:
    SumElemWeight () : 
      _weight(0) 
    {}

    SumElemWeight (SumElemWeight &, Threads::split) : 
      _weight(0)
    {}
    
    void operator()(const ConstElemRange &range)
    { 
      for (ConstElemRange::const_iterator it = range.begin(); it !=range.end(); ++it)
	_weight += (*it)->n_nodes();
    }

    unsigned int weight() const 
    { return _weight; }
    
// If we don't have threads we never need a join, and icpc yells a
// warning if it sees an anonymous function that's never used
#ifdef LIBMESH_HAVE_TBB_API
    void join (const SumElemWeight &other)
    { _weight += other.weight(); }
#endif

  private:
    unsigned int _weight;
  };


  /**
   * FindBBox(Range) computes the bounding box for the objects
   * in the specified range.  This class may be split and subranges
   * can be executed on separate threads.  The join() method
   * defines how the results from two separate threads are combined.
   */
  class FindBBox
  {
  public:
    FindBBox () :
      _vmin(3,  std::numeric_limits<Real>::max()),
      _vmax(3, -std::numeric_limits<Real>::max())
    {}

    FindBBox (FindBBox &other, Threads::split) :
      _vmin(other._vmin),
      _vmax(other._vmax)
    {}

    std::vector<Real> & min() { return _vmin; }
    std::vector<Real> & max() { return _vmax; }
    
    void operator()(const ConstNodeRange &range)
    {
      for (ConstNodeRange::const_iterator it = range.begin(); it != range.end(); ++it)
	{
          const Node *node = *it;
	  libmesh_assert (node != NULL);
	  
	  for (unsigned int i=0; i<3; i++)
	    {
	      _vmin[i] = std::min(_vmin[i], (*node)(i));
	      _vmax[i] = std::max(_vmax[i], (*node)(i));
	    }      
        }
    }

    void operator()(const ConstElemRange &range)
    {
      for (ConstElemRange::const_iterator it = range.begin(); it != range.end(); ++it)
	{
          const Elem *elem = *it;
	  libmesh_assert (elem != NULL);

	  for (unsigned int n=0; n<elem->n_nodes(); n++)
	    {
	      const Point &point = elem->point(n);

	      for (unsigned int i=0; i<3; i++)
		{
		  _vmin[i] = std::min(_vmin[i], point(i));
		  _vmax[i] = std::max(_vmax[i], point(i));
		}     
	    } 
        }
    }

// If we don't have threads we never need a join, and icpc yells a
// warning if it sees an anonymous function that's never used
#ifdef LIBMESH_HAVE_TBB_API
    void join (const FindBBox &other)
    {
      for (unsigned int i=0; i<3; i++)
	{
	  _vmin[i] = std::min(_vmin[i], other._vmin[i]);
	  _vmax[i] = std::max(_vmax[i], other._vmax[i]);
	}      
    }
#endif

    MeshTools::BoundingBox bbox () const
    {
      Point pmin(_vmin[0], _vmin[1], _vmin[2]);
      Point pmax(_vmax[0], _vmax[1], _vmax[2]);

      const MeshTools::BoundingBox ret_val(pmin, pmax);

      return ret_val;        
    }
    
  private:
    std::vector<Real> _vmin;
    std::vector<Real> _vmax;
  };
}



// ------------------------------------------------------------
// MeshTools functions
unsigned int MeshTools::total_weight(const MeshBase& mesh)
{
  if (!mesh.is_serial())
    {
      parallel_only();
      unsigned int weight = MeshTools::weight (mesh, libMesh::processor_id());
      Parallel::sum(weight);
      unsigned int unpartitioned_weight =
        MeshTools::weight (mesh, DofObject::invalid_processor_id);
      return weight + unpartitioned_weight;
{'fraction_non_alphanumeric': 0.1526267655726044, 'fraction_numerical': 0.008332486535921146, 'mean_word_length': 2.701391500564122, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1540556', 'n_tokens_mistral': 3264, 'n_tokens_neox': 3104, 'n_words': 953}