DataTransferKit - Multiphysics Solution Transfer Services  2.0
DTK_STKMeshEntityIterator.hpp
1 //---------------------------------------------------------------------------//
2 /*
3  Copyright (c) 2012, Stuart R. Slattery
4  All rights reserved.
5 
6  Redistribution and use in source and binary forms, with or without
7  modification, are permitted provided that the following conditions are
8  met:
9 
10  *: Redistributions of source code must retain the above copyright
11  notice, this list of conditions and the following disclaimer.
12 
13  *: Redistributions in binary form must reproduce the above copyright
14  notice, this list of conditions and the following disclaimer in the
15  documentation and/or other materials provided with the distribution.
16 
17  *: Neither the name of the University of Wisconsin - Madison nor the
18  names of its contributors may be used to endorse or promote products
19  derived from this software without specific prior written permission.
20 
21  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25  HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 */
33 //---------------------------------------------------------------------------//
39 //---------------------------------------------------------------------------//
40 
41 #ifndef DTK_STKMESHENTITYITERATOR_HPP
42 #define DTK_STKMESHENTITYITERATOR_HPP
43 
44 #include <functional>
45 #include <vector>
46 
47 #include "DTK_Entity.hpp"
48 #include "DTK_EntityIterator.hpp"
49 #include "DTK_STKMeshEntityIteratorRange.hpp"
50 
51 #include <Teuchos_Ptr.hpp>
52 #include <Teuchos_RCP.hpp>
53 
54 #include <stk_mesh/base/BulkData.hpp>
55 #include <stk_mesh/base/Entity.hpp>
56 
57 namespace DataTransferKit
58 {
59 //---------------------------------------------------------------------------//
64 //---------------------------------------------------------------------------//
66 {
67  public:
72 
77  const Teuchos::RCP<STKMeshEntityIteratorRange> &entity_range,
78  const Teuchos::Ptr<stk::mesh::BulkData> &bulk_data,
79  const PredicateFunction &predicate );
80 
85 
90 
91  // Pre-increment operator.
92  EntityIterator &operator++() override;
93 
94  // Dereference operator.
95  Entity &operator*(void)override;
96 
97  // Dereference operator.
98  Entity *operator->(void)override;
99 
100  // Equal comparison operator.
101  bool operator==( const EntityIterator &rhs ) const override;
102 
103  // Not equal comparison operator.
104  bool operator!=( const EntityIterator &rhs ) const override;
105 
106  // An iterator assigned to the first valid element in the iterator.
107  EntityIterator begin() const override;
108 
109  // An iterator assigned to the end of all elements under the iterator.
110  EntityIterator end() const override;
111 
112  // Create a clone of the iterator. We need this for the copy constructor
113  // and assignment operator to pass along the underlying implementation.
114  std::unique_ptr<EntityIterator> clone() const override;
115 
116  private:
117  // Range of entities over which the iterator is defined.
118  Teuchos::RCP<STKMeshEntityIteratorRange> d_entity_range;
119 
120  // Iterator over the entities.
121  std::vector<stk::mesh::Entity>::const_iterator d_stk_entity_it;
122 
123  // The bulk data owning the entities.
124  Teuchos::Ptr<stk::mesh::BulkData> d_bulk_data;
125 
126  // Current entity.
127  Entity d_current_entity;
128 };
129 
130 //---------------------------------------------------------------------------//
131 
132 } // end namespace DataTransferKit
133 
134 #endif // end DTK_STKMESHENTITYITERATOR_HPP
135 
136 //---------------------------------------------------------------------------//
137 // end DTK_STKMeshEntityIterator.hpp
138 //---------------------------------------------------------------------------//
Geometric entity interface definition.
Definition: DTK_Entity.hpp:61
Entity iterator interface.
STK mesh entity iterator implementation.
std::function< bool(Entity)> PredicateFunction
Predicate function typedef.
Definition: DTK_Types.hpp:64
DTK_BasicEntitySet.cpp.
STKMeshEntityIterator & operator=(const STKMeshEntityIterator &rhs)
Assignment operator.