Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
MeshTopoUtil.hpp
Go to the documentation of this file.
1 /**
2  * MOAB, a Mesh-Oriented datABase, is a software component for creating,
3  * storing and accessing finite element mesh data.
4  *
5  * Copyright 2004 Sandia Corporation. Under the terms of Contract
6  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
7  * retains certain rights in this software.
8  *
9  * This library is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  */
15 
16 #ifndef MOAB_MESH_TOPO_UTIL_HPP
17 #define MOAB_MESH_TOPO_UTIL_HPP
18 
19 #include "moab/Forward.hpp"
20 
21 namespace moab
22 {
23 
24 /*!
25  * \authors Tim Tautges
26  * \date 2/04
27  * \brief MeshTopoUtil contains general mesh utility functions
28  *
29  */
31 {
32  public:
33  MeshTopoUtil( Interface* impl ) : mbImpl( impl ) {}
34 
36 
37  //! generate all the AEntities bounding the vertices
38  ErrorCode construct_aentities( const Range& vertices );
39 
40  //! given an entity, get its average position (avg vertex locations)
41  ErrorCode get_average_position( Range& entities, double* avg_position );
42 
43  //! given an entity, get its average position (avg vertex locations)
44  ErrorCode get_average_position( const EntityHandle entity, double* avg_position );
45 
46  //! given a set of entities, get their average position (avg vertex locations)
47  ErrorCode get_average_position( const EntityHandle* entities, const int num_entities, double* avg_position );
48 
49  //! get (target_dim)-dimensional manifold entities connected to star_entity; that is,
50  //! the entities with <= 1 connected (target_dim+2)-dimensional adjacent entities;
51  //! for target_dim=3, just return all of them
52  //! just insert into the list, w/o clearing manifold list first
53  ErrorCode get_manifold( const EntityHandle star_entity, const int target_dim, Range& manifold );
54 
55  //! given an entity, find the entities of next higher dimension around
56  //! that entity, ordered by connection through next higher dimension entities;
57  //! if any of the star entities is in only entity of next higher dimension,
58  //! on_boundary is returned true
59  ErrorCode star_entities( const EntityHandle star_center,
60  std::vector< EntityHandle >& star_entities,
61  bool& bdy_entity,
62  const EntityHandle starting_star_entity = 0,
63  std::vector< EntityHandle >* star_entities_dp1 = NULL,
64  Range* star_entities_candidates_dp1 = NULL );
65 
66  //! Get a series of (d+1)-dimensional stars around a d-dimensional entity, such that
67  //! each star is on a (d+2)-manifold containing the d-dimensional entity; each star
68  //! is either open or closed, and also defines a (d+2)-star whose entities are bounded by
69  //! (d+1)-entities on the star and on the (d+2)-manifold
71  std::vector< std::vector< EntityHandle > >& stars,
72  std::vector< bool >* bdy_flags = NULL,
73  std::vector< std::vector< EntityHandle > >* dp2_stars = NULL );
74 
75  //! given a star_center, a last_entity (whose dimension should be 1 greater than center)
76  //! and last_dp1 (dimension 2 higher than center), returns the next star entity across
77  //! last_dp1, and the next dp1 entity sharing next_entity; if star_candidates is non-empty,
78  //! star must come from those
79  ErrorCode star_next_entity( const EntityHandle star_center,
80  const EntityHandle last_entity,
81  const EntityHandle last_dp1,
82  Range* star_candidates_dp1,
83  EntityHandle& next_entity,
84  EntityHandle& next_dp1 );
85 
86  //! get "bridge" or "2nd order" adjacencies, going through dimension bridge_dim
87  ErrorCode get_bridge_adjacencies( Range& from_entities,
88  int bridge_dim,
89  int to_dim,
90  Range& to_ents,
91  int num_layers = 1 );
92 
93  //! get "bridge" or "2nd order" adjacencies, going through dimension bridge_dim
95  const int bridge_dim,
96  const int to_dim,
97  Range& to_adjs );
98 
99  //! return a common entity of the specified dimension, or 0 if there isn't one
100  EntityHandle common_entity( const EntityHandle ent1, const EntityHandle ent2, const int dim );
101 
102  //! return the opposite side entity given a parent and bounding entity.
103  //! This function is only defined for certain types of parent/child types;
104  //! See MBCN.hpp::OppositeSide for details.
105  //!
106  //! \param parent The parent element
107  //! \param child The child element
108  //! \param opposite_element The index of the opposite element
109  ErrorCode opposite_entity( const EntityHandle parent, const EntityHandle child, EntityHandle& opposite_element );
110 
111  //! split entity which is non-manifold, that is, which has > 2 connected entities
112  //! of next higher dimension; assumes that there are >= 2 connected regions of
113  //! (d+2)-dimensional entities; a new d-entity is created for each region after the
114  //! first, and it's made explicitly-adjacent to the region to which it corresponds
116  Range& old_adjs,
117  Range& new_adjs,
118  EntityHandle& new_entity );
119 
120  //! split entities that are manifold (shared by two or less entities of each higher dimension),
121  //! optionally creating an entity of next higher dimension to fill the gap
122  /**
123  \param entities The entities to be split
124  \param new_entities New entities, in order of correspondence to that of entities
125  \param fill_entities If non-NULL, create an entity of next higher dimension to fill the gap,
126  passing it back in *fill_entities
127  */
128  ErrorCode split_entities_manifold( Range& entities, Range& new_entities, Range* fill_entities );
129 
130  //! split entities that are manifold (shared by two or less entities of each higher dimension),
131  //! optionally creating an entity of next higher dimension to fill the gap
132  /**
133  \param entities The entities to be split
134  \param new_entities New entities, in order of correspondence to that of entities
135  \param fill_entities If non-NULL, create an entity of next higher dimension to fill the gap,
136  passing it back in *fill_entities
137  \param gowith_ents If non-NULL, each of the new entities will adj to the
138  corresponding gowith entities after the split; this parameter is
139  ignored for boundary split entities; in that case, the split entity
140  remains on the boundary (i.e. not adj to any entity of higher
141  dimension). Dimension of gowith_ents must be the same as entities.
142  */
144  const int num_entities,
145  EntityHandle* new_entities,
146  Range* fill_entities,
147  EntityHandle* gowith_ents = NULL );
148 
149  //! return whether entity is equivalent to any other of same type and same vertices;
150  //! if equivalent entity is found, it's returned in equiv_ents and return value is true,
151  //! false otherwise.
152  bool equivalent_entities( const EntityHandle entity, Range* equiv_ents = NULL );
153 
154  private:
156 };
157 
158 } // namespace moab
159 
160 #endif