bool
GeometricCut2DUserObject::cutElementByGeometry(const Elem * elem,
                                               std::vector<Xfem::CutEdge> & cut_edges,
                                               std::vector<Xfem::CutNode> & cut_nodes,
                                               Real time) const
{
  bool cut_elem = false;

  for (unsigned int cut = 0; cut < _cut_line_endpoints.size(); ++cut)
  {
    Real fraction = cutFraction(cut, time);

    if (fraction > 0.0)
    {
      unsigned int n_sides = elem->n_sides();

      for (unsigned int i = 0; i < n_sides; ++i)
      {
        // This returns the lowest-order type of side, which should always
        // be an EDGE2 here because this class is for 2D only.
        std::unique_ptr<const Elem> curr_side = elem->side_ptr(i);
        if (curr_side->type() != EDGE2)
          mooseError("In cutElementByGeometry element side must be EDGE2, but type is: ",
                     libMesh::Utility::enum_to_string(curr_side->type()),
                     " base element type is: ",
                     libMesh::Utility::enum_to_string(elem->type()));

        const Node * node1 = curr_side->node_ptr(0);
        const Node * node2 = curr_side->node_ptr(1);
        Real seg_int_frac = 0.0;

        if (IntersectSegmentWithCutLine(
                *node1, *node2, _cut_line_endpoints[cut], fraction, seg_int_frac))
        {
          if (seg_int_frac > Xfem::tol && seg_int_frac < 1.0 - Xfem::tol)
          {
            cut_elem = true;
            Xfem::CutEdge mycut;
            mycut._id1 = node1->id();
            mycut._id2 = node2->id();
            mycut._distance = seg_int_frac;
            mycut._host_side_id = i;
            cut_edges.push_back(mycut);
          }
          else if (seg_int_frac < Xfem::tol)
          {
            cut_elem = true;
            Xfem::CutNode mycut;
            mycut._id = node1->id();
            mycut._host_id = i;
            cut_nodes.push_back(mycut);
          }
        }
      }
    }
  }
  return cut_elem;
}
Beispiel #2
0
bool
XFEMGeometricCut2D::cutElementByGeometry(const Elem * elem,
                                         std::vector<CutEdge> & cut_edges,
                                         Real time)
{
  bool cut_elem = false;

  Real fraction = cutFraction(time);

  if (fraction > 0.0)
  {
    unsigned int n_sides = elem->n_sides();

    for (unsigned int i = 0; i < n_sides; ++i)
    {
      // This returns the lowest-order type of side, which should always
      // be an EDGE2 here because this class is for 2D only.
      std::unique_ptr<Elem> curr_side = elem->side(i);
      if (curr_side->type() != EDGE2)
        mooseError("In cutElementByGeometry element side must be EDGE2, but type is: ",
                   libMesh::Utility::enum_to_string(curr_side->type()),
                   " base element type is: ",
                   libMesh::Utility::enum_to_string(elem->type()));

      const Node * node1 = curr_side->get_node(0);
      const Node * node2 = curr_side->get_node(1);
      Real seg_int_frac = 0.0;

      if (IntersectSegmentWithCutLine(
              *node1, *node2, _cut_line_start, _cut_line_end, fraction, seg_int_frac))
      {
        cut_elem = true;
        CutEdge mycut;
        mycut.id1 = node1->id();
        mycut.id2 = node2->id();
        mycut.distance = seg_int_frac;
        mycut.host_side_id = i;
        cut_edges.push_back(mycut);
      }
    }
  }
  return cut_elem;
}
bool
GeometricCut2DUserObject::cutFragmentByGeometry(std::vector<std::vector<Point>> & frag_edges,
                                                std::vector<Xfem::CutEdge> & cut_edges,
                                                Real time) const
{
  bool cut_frag = false;

  for (unsigned int cut = 0; cut < _cut_line_endpoints.size(); ++cut)
  {
    Real fraction = cutFraction(cut, time);

    if (fraction > 0.0)
    {
      unsigned int n_sides = frag_edges.size();

      for (unsigned int i = 0; i < n_sides; ++i)
      {
        Real seg_int_frac = 0.0;

        if (IntersectSegmentWithCutLine(frag_edges[i][0],
                                        frag_edges[i][1],
                                        _cut_line_endpoints[cut],
                                        fraction,
                                        seg_int_frac))
        {
          cut_frag = true;
          Xfem::CutEdge mycut;
          mycut._id1 = i;
          mycut._id2 = (i < (n_sides - 1) ? (i + 1) : 0);
          mycut._distance = seg_int_frac;
          mycut._host_side_id = i;
          cut_edges.push_back(mycut);
        }
      }
    }
  }
  return cut_frag;
}
Beispiel #4
0
bool
XFEMGeometricCut2D::cutFragmentByGeometry(std::vector<std::vector<Point>> & frag_edges,
                                          std::vector<CutEdge> & cut_edges,
                                          Real time)
{
  bool cut_frag = false;

  const Real fraction = cutFraction(time);

  if (fraction > 0.0)
  {
    unsigned int n_sides = frag_edges.size();

    for (unsigned int i = 0; i < n_sides; ++i)
    {
      Real seg_int_frac = 0.0;

      if (IntersectSegmentWithCutLine(frag_edges[i][0],
                                      frag_edges[i][1],
                                      _cut_line_start,
                                      _cut_line_end,
                                      fraction,
                                      seg_int_frac))
      {
        cut_frag = true;
        CutEdge mycut;
        mycut.id1 = i;
        mycut.id2 = (i < (n_sides - 1) ? (i + 1) : 0);
        mycut.distance = seg_int_frac;
        mycut.host_side_id = i;
        cut_edges.push_back(mycut);
      }
    }
  }

  return cut_frag;
}
Beispiel #5
0
bool
XFEMGeometricCut2D::active(Real time)
{
  return cutFraction(time) > 0;
}