<commit_before>// The libMesh Finite Element Library.
// Copyright (C) 2002-2013 <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


#include "libmesh/libmesh_config.h"
#if defined(LIBMESH_HAVE_TRIANGLE) && defined(LIBMESH_HAVE_TETGEN)

// Local includes
#include "libmesh/elem_cutter.h"
#include "libmesh/elem.h"
#include "libmesh/serial_mesh.h"
#include "libmesh/mesh_triangle_interface.h"
#include "libmesh/mesh_tetgen_interface.h"

// C++ includes

namespace
{
unsigned int cut_cntr;
}

namespace libMesh
{

// ------------------------------------------------------------
// ElemCutter implementation
ElemCutter::ElemCutter()
{
  _inside_mesh_2D.reset  (new ReplicatedMesh(_comm_self,2)); /**/ _triangle_inside.reset  (new TriangleInterface (*_inside_mesh_2D));
  _outside_mesh_2D.reset (new ReplicatedMesh(_comm_self,2)); /**/ _triangle_outside.reset (new TriangleInterface (*_outside_mesh_2D));

  _inside_mesh_3D.reset  (new ReplicatedMesh(_comm_self,3)); /**/ _tetgen_inside.reset  (new TetGenMeshInterface (*_inside_mesh_3D));
  _outside_mesh_3D.reset (new ReplicatedMesh(_comm_self,3)); /**/ _tetgen_outside.reset (new TetGenMeshInterface (*_outside_mesh_3D));

  cut_cntr = 0;
}



ElemCutter::~ElemCutter()
{}



bool ElemCutter::is_inside (const Elem & elem,
                            const std::vector<Real> & vertex_distance_func) const
{
  libmesh_assert_equal_to (elem.n_vertices(), vertex_distance_func.size());

  for (std::vector<Real>::const_iterator it=vertex_distance_func.begin();
       it!=vertex_distance_func.end(); ++it)
    if (*it > 0.) return false;

  // if the distance function is nonpositive, we are outside
  return true;
}



bool ElemCutter::is_outside (const Elem & elem,
                             const std::vector<Real> & vertex_distance_func) const
{
  libmesh_assert_equal_to (elem.n_vertices(), vertex_distance_func.size());

  for (std::vector<Real>::const_iterator it=vertex_distance_func.begin();
       it!=vertex_distance_func.end(); ++it)
    if (*it < 0.) return false;

  // if the distance function is nonnegative, we are outside
  return true;
}



bool ElemCutter::is_cut (const Elem & elem,
                         const std::vector<Real> & vertex_distance_func) const
{
  libmesh_assert_equal_to (elem.n_vertices(), vertex_distance_func.size());

  Real
    vmin = vertex_distance_func.front(),
    vmax = vmin;

  for (std::vector<Real>::const_iterator it=vertex_distance_func.begin();
       it!=vertex_distance_func.end(); ++it)
    {
      vmin = std::min (vmin, *it);
      vmax = std::max (vmax, *it);
    }

  // if the distance function changes sign, we're cut.
  return (vmin*vmax < 0.);
}



void ElemCutter::operator()(const Elem & elem,
                            const std::vector<Real> & vertex_distance_func)

{
  libmesh_assert_equal_to (vertex_distance_func.size(), elem.n_vertices());<commit_msg>Fix unused variable warnings in ElemCutter.<commit_after>// The libMesh Finite Element Library.
// Copyright (C) 2002-2013 <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


#include "libmesh/libmesh_config.h"
#if defined(LIBMESH_HAVE_TRIANGLE) && defined(LIBMESH_HAVE_TETGEN)

// Local includes
#include "libmesh/elem_cutter.h"
#include "libmesh/elem.h"
#include "libmesh/serial_mesh.h"
#include "libmesh/mesh_triangle_interface.h"
#include "libmesh/mesh_tetgen_interface.h"

// C++ includes

namespace
{
unsigned int cut_cntr;
}

namespace libMesh
{

// ------------------------------------------------------------
// ElemCutter implementation
ElemCutter::ElemCutter()
{
  _inside_mesh_2D.reset  (new ReplicatedMesh(_comm_self,2)); /**/ _triangle_inside.reset  (new TriangleInterface (*_inside_mesh_2D));
  _outside_mesh_2D.reset (new ReplicatedMesh(_comm_self,2)); /**/ _triangle_outside.reset (new TriangleInterface (*_outside_mesh_2D));

  _inside_mesh_3D.reset  (new ReplicatedMesh(_comm_self,3)); /**/ _tetgen_inside.reset  (new TetGenMeshInterface (*_inside_mesh_3D));
  _outside_mesh_3D.reset (new ReplicatedMesh(_comm_self,3)); /**/ _tetgen_outside.reset (new TetGenMeshInterface (*_outside_mesh_3D));

  cut_cntr = 0;
}



ElemCutter::~ElemCutter()
{}



bool ElemCutter::is_inside (const Elem & libmesh_dbg_var(elem),
                            const std::vector<Real> & vertex_distance_func) const
{
  libmesh_assert_equal_to (elem.n_vertices(), vertex_distance_func.size());

  for (std::vector<Real>::const_iterator it=vertex_distance_func.begin();
       it!=vertex_distance_func.end(); ++it)
    if (*it > 0.) return false;

  // if the distance function is nonpositive, we are outside
  return true;
}



bool ElemCutter::is_outside (const Elem & libmesh_dbg_var(elem),
                             const std::vector<Real> & vertex_distance_func) const
{
  libmesh_assert_equal_to (elem.n_vertices(), vertex_distance_func.size());

  for (std::vector<Real>::const_iterator it=vertex_distance_func.begin();
       it!=vertex_distance_func.end(); ++it)
    if (*it < 0.) return false;

  // if the distance function is nonnegative, we are outside
  return true;
}



bool ElemCutter::is_cut (const Elem & libmesh_dbg_var(elem),
                         const std::vector<Real> & vertex_distance_func) const
{
  libmesh_assert_equal_to (elem.n_vertices(), vertex_distance_func.size());

  Real
    vmin = vertex_distance_func.front(),
    vmax = vmin;

  for (std::vector<Real>::const_iterator it=vertex_distance_func.begin();
       it!=vertex_distance_func.end(); ++it)
    {
      vmin = std::min (vmin, *it);
      vmax = std::max (vmax, *it);
    }

  // if the distance function changes sign, we're cut.
  return (vmin*vmax < 0.);
}



void ElemCutter::operator()(const Elem & elem,
                            const std::vector<Real> & vertex_distance_func)

{
  libmesh_assert_equal_to (vertex_distance_func.size(), elem.n_vertices());
{'fraction_non_alphanumeric': 0.13115432354158046, 'fraction_numerical': 0.011032960970900566, 'mean_word_length': 3.736773350751143, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 25, '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': '6681894', 'n_tokens_mistral': 2376, 'n_tokens_neox': 2235, 'n_words': 612}