libMesh/libmesh: coverage diff

Base a68dd6 Head #4640 c5f9f0
Total Total +/- New
Rate 66.55% 66.54% -0.01% 100.00%
Hits 80740 80725 -15 9
Misses 40586 40599 +13 0
Filename Stmts Miss Cover
include/systems/variational_smoother_constraint.h 0 +8 -30.77%
src/mesh/distributed_mesh.C 0 +2 -0.24%
src/systems/variational_smoother_constraint.C -2 +3 -0.83%
TOTAL -2 +13 -0.01%
code
coverage unchanged
code
coverage increased
code
coverage decreased
+
line added or modified

include/systems/variational_smoother_constraint.h

97  
98  
99  
100  
101  
102  
103  
  /**
   * Const getter for the _point attribute
   */
  const Point &point() const { return _point; }

  /**
   * Const getter for the _tol attribute
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.
365  
366  
367  
368  
369  
370  
371  
 * @param b Constraint to combine with a.
 * @return Combination (intersection) of constraint a and b.
 */
inline ConstraintVariant intersect_constraints(const ConstraintVariant &a,
                                               const ConstraintVariant &b) {
  // std::visit applies the visitor v (a Callable that can be called with any
  // combination of types from Variants) to the active value inside a
374  
375  
376  
377  
378  
379  
380  
  // ConstraintVariant do)
  return std::visit(
      [](const auto &lhs, const auto &rhs) -> ConstraintVariant {
        return lhs.intersect(rhs);
      },
      a, b);
}

src/mesh/distributed_mesh.C

1617  
1618  
1619  
1620  
1621  
1622  
1623  
1624  
1625  
1626  
1627  
1628  
1629  
1630  
                      sender_could_become_owner)
                    {
                      if (it != repartitioned_node_pids.end() &&
                          pid < it->second)
                        it->second = pid;
                      else
                        repartitioned_node_pids[n] = pid;
                    }
                  else
                    if (it == repartitioned_node_pids.end())
                      repartitioned_node_pids[n] =
                        DofObject::invalid_processor_id;

                  repartitioned_node_sets_to_push[pid].insert(n);

src/systems/variational_smoother_constraint.C

27  
28  
29  
30 +
31  
32  
33  
auto get_positive_vector = [](const Point & vec) -> Point {
  // unit() rounds to within a few ulps of length 1, so TOLERANCE only
  // rejects vectors that were never normalized
  libmesh_assert(absolute_fuzzy_equals(vec.norm(), 1., TOLERANCE));

  // Choose sign such that direction vector points in the positive x/y/z
  // direction This helps to eliminate duplicate lines/planes
43  
44  
45  
46 +
47  
48  
49  
  const auto dot_prod = vec * canonical;
  libmesh_assert(!absolute_fuzzy_equals(dot_prod, 0.));

  return (dot_prod > 0) ? vec : Point(-vec);
};

PointConstraint::PointConstraint(const Point & point, const Real & tol) : _point(point), _tol(tol)
80  
81  
82  
83 +
84  
85  
86  
LineConstraint::LineConstraint(const Point & point, const Point & direction, const Real & tol)
  : _point(point), _direction(get_positive_vector(direction)), _tol(tol)
{
  libmesh_assert_msg(_direction.norm() >= _tol,
                     "Can't define a line with zero magnitude direction vector.");
}

116  
117  
118  
119 +
120  
121  
122  

bool LineConstraint::is_parallel(const PlaneConstraint & p) const
{
  return std::abs(_direction * p.normal()) < _tol;
}

ConstraintVariant LineConstraint::intersect(const ConstraintVariant & other) const
180  
181  
182  
183 +
184  
185  
186  
PlaneConstraint::PlaneConstraint(const Point & point, const Point & normal, const Real & tol)
  : _point(point), _normal(get_positive_vector(normal)), _tol(tol)
{
  libmesh_assert_msg(_normal.norm() >= _tol,
                     "Can't define a plane with zero magnitude direction vector.");
}

206  
207  
208  
209 +
210  
211  
212  
  // |n1 x n2| is the sine of the angle between the unit normals, and its
  // square is the determinant that intersect() divides by, so any pair of
  // planes that fails this test can be intersected.
  return _normal.cross(p.normal()).norm() <= _tol;
}

bool PlaneConstraint::is_parallel(const LineConstraint & l) const { return l.is_parallel(*this); }
270  
271  
272  
273 +
274  
275  
276  
277  
278 +
279  
280  
281  
            // nonzero because the planes are not parallel. Computing it from
            // dir avoids the cancellation in 1 - cos^2 for nearly parallel
            // planes.
            const Real denom = -dir.norm_sq();

            const Real s = -(n1_dot_n2 * n2_dot_w - n2_dot_n2 * n1_dot_w) / denom;
            const Point p0 = _point + s * _normal;

            return LineConstraint{p0, dir.unit()};
          }

        else if constexpr (std::is_same_v<T, LineConstraint>)
285  
286  
287  
288  
289  
290  
291  

            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
860  
861  
862  
863 +
864  
865  
866  
              if (candidate_normal.norm() <= TOLERANCE)
                continue;

              const PlaneConstraint candidate_plane{node, candidate_normal.unit()};
              valid_planes.emplace(candidate_plane);
            }
        }
882  
883  
884  
885  
886  
887  
888  
889  
      // Fall back to fixed node constraint
      if (std::holds_alternative<InvalidConstraint>(current))
        {
          current = PointConstraint(node);
          break;
        }
    }