libMesh/libmesh: coverage diff

Base 034308 Head #4268 a01b14
Total Total +/- New
Rate 64.96% 64.98% +0.02% 70.86%
Hits 76814 76923 +109 107
Misses 41432 41451 +19 44
Filename Stmts Miss Cover
src/geom/cell_inf_prism.C 0 +7 -5.34%
src/mesh/boundary_info.C +128 +12 +1.48%
TOTAL +128 +19 +0.02%
code
coverage unchanged
code
coverage increased
code
coverage decreased
+
line added or modified

src/geom/cell_inf_prism.C

303  
304  
305  
306  
307  
308  
309  
310  
311  
312  
313  
314  
315  
316  
317  
318  
319  
320  
321  
322  
  // this captures the case that the point is not (almost) in the direction of the element.:
  // first, project the problem onto the unit sphere:
  Point p_o(p - my_origin);
  pt0_o /= pt0_o.norm();
  pt1_o /= pt1_o.norm();
  pt2_o /= pt2_o.norm();
  p_o /= p_o.norm();

  // now, check if it is in the projected face; by comparing the distance of
  // any point in the element to \p p with the largest distance between this point
  // to any other point in the element.
  if ((p_o - pt0_o).norm_sq() > std::max((pt0_o - pt1_o).norm_sq(), (pt0_o - pt2_o).norm_sq()) ||
      (p_o - pt1_o).norm_sq() > std::max((pt1_o - pt2_o).norm_sq(), (pt1_o - pt0_o).norm_sq()) ||
      (p_o - pt2_o).norm_sq() > std::max((pt2_o - pt0_o).norm_sq(), (pt2_o - pt1_o).norm_sq()) )
    {
      // the physical point is definitely not contained in the element
      return false;
    }


src/mesh/boundary_info.C

421  
422  
423  
424 +
425 +
426  
427  
428  
429 +
430  
431  
432 +
433 +
434 +
435 +
436  
437  
438  
      _communicator.set_union(_es_id_to_name);
    }

  this->synchronize_global_id_set();
}



void BoundaryInfo::synchronize_global_id_set()
{
  // Handle global data
  _global_boundary_ids = _boundary_ids;
  libmesh_assert(_mesh);
  if (!_mesh->is_serial())
    _communicator.set_union(_global_boundary_ids);
}


1826  
1827  
1828  
1829  
1830  
1831  
1832  
1833  
1834  
1835  
1836  
1837  
1838  
1839  
1840  
1841  
1842  
1843  
1844  
1845  
1846  
1847  
1848  



void BoundaryInfo::remove_edge (const Elem * elem,
                                const unsigned short int edge,
                                const boundary_id_type id)
{
  libmesh_assert(elem);

  // Only touch BCs for edges that exist.
  libmesh_assert_less (edge, elem->n_edges());

  // Only level 0 elements are stored in BoundaryInfo.
  libmesh_assert_equal_to (elem->level(), 0);

  // Erase (elem, edge, id) entries from map.
  erase_if(_boundary_edge_id, elem,
           [edge, id](decltype(_boundary_edge_id)::mapped_type & pr)
           {return pr.first == edge && pr.second == id;});
}


void BoundaryInfo::remove_shellface (const Elem * elem,
1938  
1939  
1940  
1941 +
1942 +
1943 +
1944 +
1945  
1946  
1947  
1948 +
1949  
1950  
1951  
1952 +
1953  
1954  
1955 +
1956  
1957 +
1958 +
1959 +
1960 +
1961  
1962 +
1963 +
1964  
1965 +
1966 +
1967 +
1968 +
1969  
1970  
1971  
1972  
1973  
1974  
1975 +
1976  
1977  
1978  
1979 +
1980  
1981  
1982 +
1983  
1984 +
1985 +
1986 +
1987 +
1988  
1989 +
1990 +
1991  
1992 +
1993 +
1994 +
1995 +
1996  
1997  
1998  
1999 +
2000 +
2001 +
2002 +
2003  
2004  
2005  
2006 +
2007  
2008  
2009 +
2010  
2011 +
2012 +
2013 +
2014 +
2015  
2016 +
2017  
2018 +
2019 +
2020 +
2021 +
2022  
2023  
2024  
2025 +
2026 +
2027 +
2028 +
2029  
2030  
2031  
2032 +
2033  
2034  
2035 +
2036  
2037 +
2038 +
2039 +
2040 +
2041  
2042 +
2043  
2044 +
2045 +
2046 +
2047 +
2048  
2049  
2050  
2051 +
2052 +
2053 +
2054  
2055  
2056  
{
  // Pass global==false to the sub-methods here, so we can avoid
  // unnecessary communications
  this->remove_side_id(id, false);
  this->remove_edge_id(id, false);
  this->remove_shellface_id(id, false);
  this->remove_node_id(id, false);

  if (global)
    _global_boundary_ids.erase(id);
}



void BoundaryInfo::remove_side_id (boundary_id_type id, const bool global)
{
  // Erase id from ids containers
  _side_boundary_ids.erase(id);

  if (!_edge_boundary_ids.count(id) &&
      !_shellface_boundary_ids.count(id) &&
      !_node_boundary_ids.count(id))
    _boundary_ids.erase(id);

  _ss_id_to_name.erase(id);
  if (global)
    {
      bool someone_has_it = _boundary_ids.count(id);
      this->comm().max(someone_has_it);
      if (!someone_has_it)
        _global_boundary_ids.erase(id);
    }

  // Erase (*, *, id) entries from map.
  erase_if(_boundary_side_id,
           [id](decltype(_boundary_side_id)::mapped_type & pr)
           {return pr.second == id;});
}



void BoundaryInfo::remove_edge_id (boundary_id_type id, const bool global)
{
  // Erase id from ids containers
  _edge_boundary_ids.erase(id);

  if (!_side_boundary_ids.count(id) &&
      !_shellface_boundary_ids.count(id) &&
      !_node_boundary_ids.count(id))
    _boundary_ids.erase(id);

  _es_id_to_name.erase(id);
  if (global)
    {
      bool someone_has_it = _boundary_ids.count(id);
      this->comm().max(someone_has_it);
      if (!someone_has_it)
        _global_boundary_ids.erase(id);
    }

  // Erase (*, *, id) entries from map.
  erase_if(_boundary_edge_id,
           [id](decltype(_boundary_edge_id)::mapped_type & pr)
           {return pr.second == id;});
}



void BoundaryInfo::remove_shellface_id (boundary_id_type id, const bool global)
{
  // Erase id from ids containers
  _shellface_boundary_ids.erase(id);

  if (!_side_boundary_ids.count(id) &&
      !_edge_boundary_ids.count(id) &&
      !_node_boundary_ids.count(id))
    _boundary_ids.erase(id);

  if (global)
    {
      bool someone_has_it = _boundary_ids.count(id);
      this->comm().max(someone_has_it);
      if (!someone_has_it)
        _global_boundary_ids.erase(id);
    }

  // Erase (*, *, id) entries from map.
  erase_if(_boundary_shellface_id,
           [id](decltype(_boundary_shellface_id)::mapped_type & pr)
           {return pr.second == id;});
}



void BoundaryInfo::remove_node_id (boundary_id_type id, const bool global)
{
  // Erase id from ids containers
  _node_boundary_ids.erase(id);

  if (!_side_boundary_ids.count(id) &&
      !_edge_boundary_ids.count(id) &&
      !_shellface_boundary_ids.count(id))
    _boundary_ids.erase(id);

  if (global)
    {
      bool someone_has_it = _boundary_ids.count(id);
      this->comm().max(someone_has_it);
      if (!someone_has_it)
        _global_boundary_ids.erase(id);
    }

  // Erase (*, id) entries from map.
  erase_if(_boundary_node_id,
           [id](decltype(_boundary_node_id)::mapped_type & val)
           {return val == id;});
}


2138  
2139  
2140  
2141 +
2142  
2143  
2144  
2145  
2146 +
2147  
2148  
2149  
2150 +
2151 +
2152  
2153 +
2154 +
2155 +
2156  
2157  
2158  
2159 +
2160 +
2161 +
2162  
2163 +
2164  
2165 +
2166  
2167 +
2168  
2169 +
2170 +
2171 +
2172  
2173 +
2174  
2175 +
2176  
2177  
2178 +
2179  
2180 +
2181  
2182  
2183  
2184  
2185 +
2186  
2187  
2188  
2189 +
2190 +
2191  
2192 +
2193 +
2194 +
2195  
2196  
2197  
2198 +
2199 +
2200 +
2201  
2202 +
2203  
2204 +
2205  
2206 +
2207  
2208 +
2209 +
2210 +
2211  
2212 +
2213  
2214 +
2215  
2216  
2217 +
2218  
2219 +
2220  
2221  
2222  
2223  
2224 +
2225  
2226  
2227  
2228 +
2229 +
2230  
2231 +
2232 +
2233 +
2234  
2235  
2236  
2237 +
2238 +
2239 +
2240  
2241 +
2242  
2243 +
2244  
2245 +
2246  
2247 +
2248 +
2249 +
2250  
2251 +
2252  
2253 +
2254  
2255  
2256 +
2257  
2258  
2259  
2260  
2261 +
2262  
2263  
2264  
2265 +
2266 +
2267  
2268 +
2269 +
2270 +
2271  
2272  
2273  
2274 +
2275 +
2276 +
2277  
2278 +
2279  
2280 +
2281  
2282 +
2283  
2284 +
2285 +
2286 +
2287  
2288 +
2289  
2290 +
2291  
2292  
2293 +
2294  
2295  
2296  
  renumber_name(_ns_id_to_name, old_id, new_id);
  renumber_name(_es_id_to_name, old_id, new_id);

  this->libmesh_assert_valid_multimaps();
}



void BoundaryInfo::renumber_side_id (boundary_id_type old_id,
                                     boundary_id_type new_id)
{
  // If the IDs are the same, this is a no-op.
  if (old_id == new_id)
    return;

  bool found_side = false;
  for (auto & p : _boundary_side_id)
    if (p.second.second == old_id)
      {
        // If we already have this id on this side, we don't want to
        // create a duplicate in our multimap
        this->remove_side(p.first, p.second.first, new_id);
        p.second.second = new_id;
        found_side = true;
      }
  _side_boundary_ids.erase(old_id);

  if (found_side)
    {
      _side_boundary_ids.insert(new_id);

      if (!_shellface_boundary_ids.count(old_id) &&
          !_edge_boundary_ids.count(old_id) &&
          !_node_boundary_ids.count(old_id))
        {
          _boundary_ids.erase(old_id);
        }
      _boundary_ids.insert(new_id);
    }

  renumber_name(_ss_id_to_name, old_id, new_id);

  this->libmesh_assert_valid_multimaps();
}



void BoundaryInfo::renumber_edge_id (boundary_id_type old_id,
                                     boundary_id_type new_id)
{
  // If the IDs are the same, this is a no-op.
  if (old_id == new_id)
    return;

  bool found_edge = false;
  for (auto & p : _boundary_edge_id)
    if (p.second.second == old_id)
      {
        // If we already have this id on this edge, we don't want to
        // create a duplicate in our multimap
        this->remove_edge(p.first, p.second.first, new_id);
        p.second.second = new_id;
        found_edge = true;
      }
  _edge_boundary_ids.erase(old_id);

  if (found_edge)
    {
      _edge_boundary_ids.insert(new_id);

      if (!_shellface_boundary_ids.count(old_id) &&
          !_side_boundary_ids.count(old_id) &&
          !_node_boundary_ids.count(old_id))
        {
          _boundary_ids.erase(old_id);
        }
      _boundary_ids.insert(new_id);
    }

  renumber_name(_es_id_to_name, old_id, new_id);

  this->libmesh_assert_valid_multimaps();
}



void BoundaryInfo::renumber_shellface_id (boundary_id_type old_id,
                                          boundary_id_type new_id)
{
  // If the IDs are the same, this is a no-op.
  if (old_id == new_id)
    return;

  bool found_shellface = false;
  for (auto & p : _boundary_shellface_id)
    if (p.second.second == old_id)
      {
        // If we already have this id on this shellface, we don't want
        // to create a duplicate in our multimap
        this->remove_shellface(p.first, p.second.first, new_id);
        p.second.second = new_id;
        found_shellface = true;
      }
  _shellface_boundary_ids.erase(old_id);

  if (found_shellface)
    {
      _shellface_boundary_ids.insert(new_id);

      if (!_edge_boundary_ids.count(old_id) &&
          !_side_boundary_ids.count(old_id) &&
          !_node_boundary_ids.count(old_id))
        {
          _boundary_ids.erase(old_id);
        }
      _boundary_ids.insert(new_id);
    }

  this->libmesh_assert_valid_multimaps();
}



void BoundaryInfo::renumber_node_id (boundary_id_type old_id,
                                     boundary_id_type new_id)
{
  // If the IDs are the same, this is a no-op.
  if (old_id == new_id)
    return;

  bool found_node = false;
  for (auto & p : _boundary_node_id)
    if (p.second == old_id)
      {
        // If we already have this id on this node, we don't want to
        // create a duplicate in our multimap
        this->remove_node(p.first, new_id);
        p.second = new_id;
        found_node = true;
      }
  _node_boundary_ids.erase(old_id);

  if (found_node)
    {
      _node_boundary_ids.insert(new_id);

      if (!_shellface_boundary_ids.count(old_id) &&
          !_side_boundary_ids.count(old_id) &&
          !_edge_boundary_ids.count(old_id))
        {
          _boundary_ids.erase(old_id);
        }
      _boundary_ids.insert(new_id);
    }

  renumber_name(_ns_id_to_name, old_id, new_id);

  this->libmesh_assert_valid_multimaps();
}
2713  
2714  
2715  
2716 +
2717  
2718  
2719  


void
BoundaryInfo::build_node_list_from_side_list(const std::set<boundary_id_type> & sideset_list)
{
  // If we're on a distributed mesh, even the owner of a node is not
  // guaranteed to be able to properly assign its new boundary id(s)!
2738  
2739  
2740  
2741  
2742  
2743 +
2744  
2745 +
2746 +
2747  
2748  
2749  
2750  
2751 +
2752  
2753  
2754  
2755  
2756  
2757  
2758 +
2759  
2760  
2761  
    {
      // Don't add remote sides
      if (elem->is_remote())
        continue;

      auto [sidenum, bcid] = id_pair;

      if (!sideset_list.empty() && !sideset_list.count(bcid))
        continue;

      // Need to loop over the sides of any possible children
      std::vector<const Elem *> family;
#ifdef LIBMESH_ENABLE_AMR
      elem->active_family_tree_by_side (family, sidenum);
#else
      family.push_back(elem);
#endif

      for (const auto & cur_elem : family)
        {
          side = &side_builder(*cur_elem, sidenum);

          // Add each node node on the side with the side's boundary id
          for (auto i : side->node_index_range())
2954  
2955  
2956  
2957  
2958  
2959  
2960  
2961  
2962  
2963  
2964  
2965  
2966  
2967  
2968  
2969  
2970  
2971  
2972  
2973  
2974  
2975  
2976  
2977  
2978  
2979  
2980  
2981  
2982  
2983  
2984  
2985  
2986  
2987  
2988  
2989  
2990  
2991  
2992  
2993  
2994  
2995  
2996  
2997  
2998  
2999  
3000  
3001  
3002  
3003  
3004  
       node_id_action_functor, datum_type_ex);
}

void BoundaryInfo::build_side_list_from_node_list(const std::set<boundary_id_type> & nodeset_list)
{
  // Check for early return
  if (_boundary_node_id.empty())
    {
      libMesh::out << "No boundary node IDs have been added: cannot build side list!" << std::endl;
      return;
    }

  // For avoiding extraneous element side construction
  ElemSideBuilder side_builder;
  // Pull objects out of the loop to reduce heap operations
  const Elem * side_elem;

  for (const auto & elem : _mesh->active_element_ptr_range())
    for (auto side : elem->side_index_range())
      {
        side_elem = &side_builder(*elem, side);

        // map from nodeset_id to count for that ID
        std::map<boundary_id_type, unsigned> nodesets_node_count;

        // For each nodeset that this node is a member of, increment the associated
        // nodeset ID count
        for (const auto & node : side_elem->node_ref_range())
          for (const auto & pr : as_range(_boundary_node_id.equal_range(&node)))
            if (nodeset_list.empty() || nodeset_list.count(pr.second))
              nodesets_node_count[pr.second]++;

        // Now check to see what nodeset_counts have the correct
        // number of nodes in them.  For any that do, add this side to
        // the sideset, making sure the sideset inherits the
        // nodeset's name, if there is one.
        for (const auto & pr : nodesets_node_count)
          if (pr.second == side_elem->n_nodes())
            {
              add_side(elem, side, pr.first);

              // Let the sideset inherit any non-empty name from the nodeset
              std::string & nset_name = nodeset_name(pr.first);

              if (nset_name != "")
                sideset_name(pr.first) = nset_name;
            }
      } // end for side
}