41 #include "DTK_BasicEntitySet.hpp" 44 #include <Teuchos_CommHelpers.hpp> 45 #include <Teuchos_OrdinalTraits.hpp> 46 #include <Teuchos_Ptr.hpp> 54 BasicEntitySetIterator::BasicEntitySetIterator()
61 BasicEntitySetIterator::BasicEntitySetIterator(
62 Teuchos::RCP<std::unordered_map<EntityId, Entity>> map,
65 , d_map_it( d_map->begin() )
67 if ( ( d_map->size() > 0 ) && ( d_map_it != d_map->end() ) )
69 d_entity = &( d_map_it->second );
71 this->b_predicate = predicate;
76 BasicEntitySetIterator::BasicEntitySetIterator(
79 , d_map_it( rhs.d_map_it )
81 if ( ( d_map->size() > 0 ) && ( d_map_it != d_map->end() ) )
83 d_entity = &( d_map_it->second );
85 this->b_predicate = rhs.b_predicate;
93 this->b_predicate = rhs.b_predicate;
99 d_map_it = rhs.d_map_it;
100 if ( ( d_map->size() > 0 ) && ( d_map_it != d_map->end() ) )
102 d_entity = &( d_map_it->second );
117 Entity &BasicEntitySetIterator::operator*(
void )
125 Entity *BasicEntitySetIterator::operator->(
void )
127 DTK_REQUIRE( d_map_it != d_map->end() );
128 d_entity = &( d_map_it->second );
134 bool BasicEntitySetIterator::operator==(
const EntityIterator &rhs )
const 140 rhs_vec->b_iterator_impl.get() );
141 return ( rhs_vec_impl->d_map_it == d_map_it );
146 bool BasicEntitySetIterator::operator!=(
const EntityIterator &rhs )
const 152 rhs_vec->b_iterator_impl.get() );
153 return ( rhs_vec_impl->d_map_it != d_map_it );
168 end_it.d_map_it = d_map->end();
175 std::unique_ptr<EntityIterator> BasicEntitySetIterator::clone()
const 177 return std::unique_ptr<EntityIterator>(
186 const Teuchos::RCP<
const Teuchos::Comm<int>> comm,
187 const int physical_dimension )
189 , d_physical_dim( physical_dimension )
215 const int topological_dimension,
218 DTK_CHECK( d_entities[topological_dimension].count( entity_id ) );
219 entity = d_entities[topological_dimension].find( entity_id )->second;
229 Teuchos::RCP<std::unordered_map<EntityId, Entity>> map_ptr =
230 Teuchos::rcpFromRef( d_entities[topological_dimension] );
238 const Entity &entity,
const int adjacent_dimension,
239 Teuchos::Array<Entity> &adjacent_entities )
const 241 bool not_implemented =
true;
242 DTK_INSIST( !not_implemented );
Geometric entity interface definition.
EntityIterator entityIterator(const int topological_dimension, const PredicateFunction &predicate=EntitySet::selectAll) const override
Get an iterator over a subset of the entity set that satisfies the given predicate.
void getEntity(const EntityId entity_id, const int topological_dimension, Entity &entity) const override
Entity access functions.
virtual void getAdjacentEntities(const Entity &entity, const int adjacent_dimension, Teuchos::Array< Entity > &adjacent_entities) const override
Given an entity, get the entities of the given type that are adjacent to it.
Entity iterator interface.
void addEntity(const Entity &entity)
Add an entity to the set.
Assertions and Design-by-Contract for error handling.
BasicEntitySet(const Teuchos::RCP< const Teuchos::Comm< int >> comm, const int physical_dimension)
Constructor.
ementation of iterator over entities in a basic set.
Teuchos::RCP< const Teuchos::Comm< int > > communicator() const override
Parallel functions.
std::function< bool(Entity)> PredicateFunction
Predicate function typedef.
int physicalDimension() const override
Geometric data functions.
unsigned long int EntityId
Entity id type.
int topologicalDimension() const
Return the topological dimension of the entity.
BasicEntitySetIterator & operator=(const BasicEntitySetIterator &rhs)
Assignment operator.
EntityId id() const
Client interface.