SpECTRE Documentation Coverage Report
Current view: top level - Domain/Structure - TrimMap.hpp Hit Total Coverage
Commit: 1bd361db2ecec890b34404958975897856517ca1 Lines: 1 2 50.0 %
Date: 2024-05-08 20:10:16
Legend: Lines: hit not hit

          Line data    Source code
       1           0 : // Distributed under the MIT License.
       2             : // See LICENSE.txt for details.
       3             : 
       4             : #pragma once
       5             : 
       6             : #include <cstddef>
       7             : #include <utility>
       8             : 
       9             : #include "Domain/Structure/DirectionalId.hpp"
      10             : #include "Domain/Structure/DirectionalIdMap.hpp"
      11             : #include "Domain/Structure/Element.hpp"
      12             : #include "Domain/Structure/ElementId.hpp"
      13             : #include "Utilities/Gsl.hpp"
      14             : 
      15             : namespace domain {
      16             : /*!
      17             :  * \brief Remove entries in `map_to_trim` that aren't face neighbors of the
      18             :  * `element`
      19             :  */
      20             : template <size_t Dim, typename T>
      21           1 : void remove_nonexistent_neighbors(
      22             :     const gsl::not_null<DirectionalIdMap<Dim, T>*> map_to_trim,
      23             :     const Element<Dim>& element) {
      24             :   std::array<DirectionalId<Dim>, maximum_number_of_neighbors(Dim)>
      25             :       ids_to_remove{};
      26             :   size_t ids_index = 0;
      27             :   for (const auto& [neighbor_id, mesh] : *map_to_trim) {
      28             :     const auto& neighbors = element.neighbors();
      29             :     if (const auto neighbors_it = neighbors.find(neighbor_id.direction);
      30             :         neighbors_it != neighbors.end()) {
      31             :       if (const auto neighbor_it =
      32             :               neighbors_it->second.ids().find(neighbor_id.id);
      33             :           neighbor_it == neighbors_it->second.ids().end()) {
      34             :         gsl::at(ids_to_remove, ids_index) = neighbor_id;
      35             :         ++ids_index;
      36             :       }
      37             :     } else {
      38             :       gsl::at(ids_to_remove, ids_index) = neighbor_id;
      39             :       ++ids_index;
      40             :     }
      41             :   }
      42             :   for (size_t i = 0; i < ids_index; ++i) {
      43             :     map_to_trim->erase(gsl::at(ids_to_remove, i));
      44             :   }
      45             : }
      46             : }  // namespace domain

Generated by: LCOV version 1.14