libMesh/libmesh: coverage diff

Base 45b804 Head #4287 5376a2
Total Total +/- New
Rate 64.99% 65.01% +0.02% 97.78%
Hits 76923 76959 +36 44
Misses 41440 41429 -11 1
Filename Stmts Miss Cover
include/systems/variational_smoother_constraint.h 0 -5 +19.23%
src/geom/cell_tet10.C 0 -3 +1.12%
src/geom/cell_tet14.C 0 -1 +0.37%
src/mesh/mesh_tools.C +17 0 +0.40%
src/systems/variational_smoother_constraint.C -17 -3 +0.19%
src/systems/variational_smoother_system.C +25 +1 +0.33%
TOTAL +25 -11 +0.02%
code
coverage unchanged
code
coverage increased
code
coverage decreased
+
line added or modified

include/systems/variational_smoother_constraint.h

327  
328  
329  
330  
331  
332  
333  
334  
335  
336  
337  
338  
339  
340  
341  
342  
 * Represents an invalid constraint (i.e., when the two constraints don't
 * intersect)
 */
class InvalidConstraint
{

public:
  InvalidConstraint()
    : _err_msg("We should never get here! The InvalidConstraint object should be "
               "detected and replaced with a valid ConstraintVariant prior to calling "
               "any class methods.")
  {
  }

  /**
   * Dummy intersect method that should never be called.

src/geom/cell_tet10.C

146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
  Point v = this->point(1) - this->point(0);
  if (!v.relative_fuzzy_equals
      ((this->point(4) - this->point(0))*2, affine_tol))
    return false;
  v = this->point(2) - this->point(1);
  if (!v.relative_fuzzy_equals
      ((this->point(5) - this->point(1))*2, affine_tol))
    return false;
  v = this->point(2) - this->point(0);
  if (!v.relative_fuzzy_equals
      ((this->point(6) - this->point(0))*2, affine_tol))
158  
159  
160  
161  
162  
163  
164  
  v = this->point(3) - this->point(0);
  if (!v.relative_fuzzy_equals
      ((this->point(7) - this->point(0))*2, affine_tol))
    return false;
  v = this->point(3) - this->point(1);
  if (!v.relative_fuzzy_equals
      ((this->point(8) - this->point(1))*2, affine_tol))

src/geom/cell_tet14.C

156  
157  
158  
159  
160  
161  
162  
  Point v10 = this->point(1) - this->point(0);
  if (!v10.relative_fuzzy_equals
      ((this->point(4) - this->point(0))*2))
    return false;
  Point v21 = this->point(2) - this->point(1);
  if (!v21.relative_fuzzy_equals
      ((this->point(5) - this->point(1))*2))

src/mesh/mesh_tools.C

1061  
1062  
1063  
1064 +
1065  
1066  
1067  
  find_nodal_neighbors_helper(node.id(), node_to_elem_vec, neighbors);
}

void find_nodal_or_face_neighbors(
    const MeshBase & mesh,
    const Node & node,
    const std::unordered_map<dof_id_type, std::vector<const Elem *>> & nodes_to_elem_map,
1069  
1070  
1071  
1072 +
1073  
1074  
1075  
1076 +
1077  
1078  
1079 +
1080  
1081 +
1082  
1083 +
1084  
1085 +
1086 +
1087 +
1088  
1089 +
1090  
1091 +
1092  
1093 +
1094 +
1095 +
1096 +
1097  
1098  
1099  
1100 +
1101 +
1102  
1103  
1104  
{
  // Find all the nodal neighbors... that is the nodes directly connected
  // to this node through one edge.
  find_nodal_neighbors(mesh, node, nodes_to_elem_map, neighbors);

  // If no neighbors are found, use all nodes on the containing side as
  // neighbors.
  if (!neighbors.size())
    {
      // Grab the element containing node
      const auto * elem = libmesh_map_find(nodes_to_elem_map, node.id()).front();
      // Find the element side containing node
      for (const auto &side : elem->side_index_range())
        {
          const auto &nodes_on_side = elem->nodes_on_side(side);
          const auto it =
              std::find_if(nodes_on_side.begin(), nodes_on_side.end(), [&](auto local_node_id) {
                return elem->node_id(local_node_id) == node.id();
              });

          if (it != nodes_on_side.end())
            {
              for (const auto &local_node_id : nodes_on_side)
                // No need to add node itself as a neighbor
                if (const auto *node_ptr = elem->node_ptr(local_node_id);
                    *node_ptr != node)
                  neighbors.push_back(node_ptr);
              break;
            }
        }
    }
  libmesh_assert(neighbors.size());
}



src/systems/variational_smoother_constraint.C

278  
279  
280  
281  
282  
283  
284  

            if (this->is_parallel(o))
              // Line is parallel and does not intersect the plane
              return InvalidConstraint();

            // Solve for t in the parametric equation:
            //   p(t) = point + t·d
632  
633  
634  
635 +
636  
637  
638  
  // to this node through one edge, or if none exists, use other nodes on the
  // containing face
  std::vector<const Node *> neighbors;
  MeshTools::find_nodal_or_face_neighbors(
      mesh, node, nodes_to_elem_map, neighbors);

  // Each constituent set corresponds to neighbors sharing a face on the
718  
719  
720  
721 +
722  
723  
724  
  // to this node through one edge, or if none exists, use other nodes on the
  // containing face
  std::vector<const Node *> neighbors;
  MeshTools::find_nodal_or_face_neighbors(
      mesh, node, nodes_to_elem_map, neighbors);

  // Each constituent set corresponds to neighbors sharing a face on the
864  
865  
866  
867  
868  
869  
870  
871  
      // Fall back to fixed node constraint
      if (std::holds_alternative<InvalidConstraint>(current))
        {
          current = PointConstraint(node);
          break;
        }
    }

src/systems/variational_smoother_system.C

923  
924  
925  
926 +
927  
928  
929  
  const auto ref_vol = target_elem->reference_elem()->volume();

  // Update the nodes of the target element, depending on type
  const Real sqrt_2 = std::sqrt(Real(2));
  const Real sqrt_3 = std::sqrt(Real(3));
  std::vector<std::unique_ptr<Node>> owned_nodes;

1111  
1112  
1113  
1114 +
1115  
1116  
1117  
    } // if Pyramid

  // Elems deriving from Tet
  else if (type_str.compare(0, 3, "TET") == 0)
    {

      // The ideal target element is a a regular tet with equilateral
1128  
1129  
1130  
1131 +
1132  
1133 +
1134  
1135 +
1136 +
1137  
1138  
1139  
1140 +
1141 +
1142 +
1143 +
1144  
1145 +
1146  
1147 +
1148  
1149  
1150  
1151 +
1152 +
1153 +
1154  
1155 +
1156 +
1157 +
1158  
1159 +
1160  
1161  
1162 +
1163 +
1164 +
1165 +
1166 +
1167  
1168  
1169 +
1170 +
1171  
1172  
1173  
      // of the non-optimal reference element (i.e., a right tet).

      // Side length that preserves the volume of the reference element
      const auto side_length = std::cbrt(6. * sqrt_2 * ref_vol);
      // tet height with the property that all faces are equilateral triangles
      const auto target_height = sqrt_2 / sqrt_3 * side_length;

      const auto & s = side_length;
      const auto & h = target_height;

      // For regular tet
      //                                         x        y                z     node_id
      owned_nodes.emplace_back(Node::build(Point(0.,      0.,               0.), 0));
      owned_nodes.emplace_back(Node::build(Point(s,       0.,               0.), 1));
      owned_nodes.emplace_back(Node::build(Point(0.5 * s, 0.5 * sqrt_3 * s, 0.), 2));
      owned_nodes.emplace_back(Node::build(Point(0.5 * s, sqrt_3 / 6. * s,  h),  3));

      if (type == TET10 || type == TET14)
        {
          const auto & on = owned_nodes;
          // Define the edge midpoint nodes of the tet

          // Base node to base node midpoint nodes
          owned_nodes.emplace_back(Node::build(Point((*on[0] + *on[1]) / 2.), 4));
          owned_nodes.emplace_back(Node::build(Point((*on[1] + *on[2]) / 2.), 5));
          owned_nodes.emplace_back(Node::build(Point((*on[2] + *on[0]) / 2.), 6));
          // Base node to apex node midpoint nodes
          owned_nodes.emplace_back(Node::build(Point((*on[0] + *on[3]) / 2.), 7));
          owned_nodes.emplace_back(Node::build(Point((*on[1] + *on[3]) / 2.), 8));
          owned_nodes.emplace_back(Node::build(Point((*on[2] + *on[3]) / 2.), 9));

          if (type == TET14)
            {
              // Define the face midpoint nodes of the tet
              owned_nodes.emplace_back(Node::build(Point((*on[0] + *on[1] + *on[2]) / 3.), 10));
              owned_nodes.emplace_back(Node::build(Point((*on[0] + *on[1] + *on[3]) / 3.), 11));
              owned_nodes.emplace_back(Node::build(Point((*on[1] + *on[2] + *on[3]) / 3.), 12));
              owned_nodes.emplace_back(Node::build(Point((*on[0] + *on[2] + *on[3]) / 3.), 13));
            }
        }

      else if (type != TET4)
        libmesh_error_msg("Unsupported tet element: " << type_str);

    } // if Tet