13 #include <stk_mesh/fem/BoundaryAnalysis.hpp> 14 #include <stk_mesh/fem/FEMMetaData.hpp> 15 #include <stk_mesh/fem/FEMHelpers.hpp> 17 #include <stk_mesh/base/BulkData.hpp> 18 #include <stk_mesh/base/Entity.hpp> 19 #include <stk_mesh/base/Part.hpp> 26 const EntityRank NODE_RANK = fem::FEMMetaData::NODE_RANK;
28 void filter_superimposed_entities(
const Entity & entity, EntityVector & entities)
32 PairIterRelation irel = entity.
relations(NODE_RANK);
33 EntityVector entity_nodes;
34 entity_nodes.reserve(irel.size());
35 for ( ; !irel.empty(); ++irel ) {
36 entity_nodes.push_back(irel->entity());
38 std::sort(entity_nodes.begin(), entity_nodes.end());
41 unsigned num_nodes_in_orig_entity = entity_nodes.size();
42 EntityVector current_nodes;
43 current_nodes.resize(num_nodes_in_orig_entity);
44 EntityVector::iterator itr = entities.begin();
45 while ( itr != entities.end() ) {
46 Entity * current_entity = *itr;
47 PairIterRelation relations = current_entity->relations(NODE_RANK);
49 if (current_entity == &entity) {
51 itr = entities.erase(itr);
53 else if (relations.size() != num_nodes_in_orig_entity) {
59 for (
unsigned i = 0; relations.first != relations.second;
60 ++relations.first, ++i ) {
61 current_nodes[i] = relations.first->entity();
63 std::sort(current_nodes.begin(), current_nodes.end());
65 bool entities_are_superimposed = entity_nodes == current_nodes;
66 if (entities_are_superimposed) {
67 itr = entities.erase(itr);
88 void get_adjacent_entities(
const Entity & entity ,
89 EntityRank subcell_rank ,
90 unsigned subcell_identifier ,
91 std::vector< EntitySideComponent> & adjacent_entities)
93 adjacent_entities.clear();
96 EntityVector subcell_nodes;
105 EntityVector potentially_adjacent_entities;
109 potentially_adjacent_entities);
113 filter_superimposed_entities(entity, potentially_adjacent_entities);
118 std::reverse(subcell_nodes.begin(),subcell_nodes.end());
120 for (EntityVector::const_iterator eitr = potentially_adjacent_entities.begin();
121 eitr != potentially_adjacent_entities.end(); ++eitr) {
126 if ( local_subcell_num != -1) {
127 adjacent_entities.push_back(EntitySideComponent(*eitr, local_subcell_num));
134 void boundary_analysis(
const BulkData& bulk_data,
135 const EntityVector & entities_closure,
136 EntityRank closure_rank,
137 EntitySideVector& boundary)
144 EntityVector::const_iterator itr =
145 std::lower_bound(entities_closure.begin(),
146 entities_closure.end(),
147 EntityKey(closure_rank, 0),
151 for ( ; itr != entities_closure.end() && (*itr)->entity_rank() == closure_rank; ++itr) {
153 std::vector<EntitySideComponent > adjacent_entities;
154 Entity& curr_entity = **itr;
155 const CellTopologyData* celltopology = fem::get_cell_topology(curr_entity).getCellTopologyData();
156 if (celltopology == NULL) {
160 unsigned subcell_rank = closure_rank - 1;
161 PairIterRelation relations = curr_entity.relations(NODE_RANK);
164 for (
unsigned nitr = 0; nitr < celltopology->subcell_count[subcell_rank]; ++nitr) {
166 unsigned subcell_identifier = nitr;
167 get_adjacent_entities(curr_entity,
180 if (adjacent_entities.empty()) {
182 keeper.inside.entity = &curr_entity;
183 keeper.inside.side_ordinal = subcell_identifier;
184 keeper.outside.entity = NULL;
185 keeper.outside.side_ordinal = 0;
186 boundary.push_back(keeper);
191 for (std::vector<EntitySideComponent >::const_iterator
192 adj_itr = adjacent_entities.begin();
193 adj_itr != adjacent_entities.end(); ++adj_itr) {
195 const Entity& neighbor = *(adj_itr->entity);
198 bool neighbor_is_in_closure =
199 std::binary_search(entities_closure.begin(),
200 entities_closure.end(),
204 if (neighbor_is_in_closure) {
209 if ( locally_used( neighbor.bucket()) || locally_used( curr_entity.bucket() ) ) {
211 keeper.inside.entity = &curr_entity;
212 keeper.inside.side_ordinal = subcell_identifier;
213 keeper.outside = *adj_itr;
215 boundary.push_back(keeper);
int get_entity_subcell_id(const Entity &entity, const EntityRank subcell_rank, const CellTopologyData *side_topology, const EntityVector &side_nodes)
Given an entity and collection of nodes, return the local id of the subcell that contains those nodes...
const CellTopologyData * get_subcell_nodes(const Entity &entity, EntityRank subcell_rank, unsigned subcell_identifier, EntityVector &subcell_nodes)
PairIterRelation relations() const
All Entity relations for which this entity is a member. The relations are ordered from lowest entity-...
void get_entities_through_relations(const std::vector< Entity *> &entities, std::vector< Entity *> &entities_related)
Query which mesh entities have a relation to all of the input mesh entities.
EntityRank entity_rank() const
The rank of this entity.