MOAB: Mesh Oriented datABase  (version 5.3.1)
MeshTopoUtil.hpp
Go to the documentation of this file.
00001 /**
00002  * MOAB, a Mesh-Oriented datABase, is a software component for creating,
00003  * storing and accessing finite element mesh data.
00004  *
00005  * Copyright 2004 Sandia Corporation.  Under the terms of Contract
00006  * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
00007  * retains certain rights in this software.
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Lesser General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2.1 of the License, or (at your option) any later version.
00013  *
00014  */
00015 
00016 #ifndef MOAB_MESH_TOPO_UTIL_HPP
00017 #define MOAB_MESH_TOPO_UTIL_HPP
00018 
00019 #include "moab/Forward.hpp"
00020 
00021 namespace moab
00022 {
00023 
00024 /*!
00025  *  \authors Tim Tautges
00026  *  \date    2/04
00027  *  \brief   MeshTopoUtil contains general mesh utility functions
00028  *
00029  */
00030 class MeshTopoUtil
00031 {
00032   public:
00033     MeshTopoUtil( Interface* impl ) : mbImpl( impl ) {}
00034 
00035     ~MeshTopoUtil() {}
00036 
00037     //! generate all the AEntities bounding the vertices
00038     ErrorCode construct_aentities( const Range& vertices );
00039 
00040     //! given an entity, get its average position (avg vertex locations)
00041     ErrorCode get_average_position( Range& entities, double* avg_position );
00042 
00043     //! given an entity, get its average position (avg vertex locations)
00044     ErrorCode get_average_position( const EntityHandle entity, double* avg_position );
00045 
00046     //! given a set of entities, get their average position (avg vertex locations)
00047     ErrorCode get_average_position( const EntityHandle* entities, const int num_entities, double* avg_position );
00048 
00049     //! get (target_dim)-dimensional manifold entities connected to star_entity; that is,
00050     //! the entities with <= 1 connected (target_dim+2)-dimensional adjacent entities;
00051     //! for target_dim=3, just return all of them
00052     //! just insert into the list, w/o clearing manifold list first
00053     ErrorCode get_manifold( const EntityHandle star_entity, const int target_dim, Range& manifold );
00054 
00055     //! given an entity, find the entities of next higher dimension around
00056     //! that entity, ordered by connection through next higher dimension entities;
00057     //! if any of the star entities is in only entity of next higher dimension,
00058     //! on_boundary is returned true
00059     ErrorCode star_entities( const EntityHandle star_center, std::vector< EntityHandle >& star_entities,
00060                              bool& bdy_entity, const EntityHandle starting_star_entity = 0,
00061                              std::vector< EntityHandle >* star_entities_dp1 = NULL,
00062                              Range* star_entities_candidates_dp1            = NULL );
00063 
00064     //! Get a series of (d+1)-dimensional stars around a d-dimensional entity, such that
00065     //! each star is on a (d+2)-manifold containing the d-dimensional entity; each star
00066     //! is either open or closed, and also defines a (d+2)-star whose entities are bounded by
00067     //! (d+1)-entities on the star and on the (d+2)-manifold
00068     ErrorCode star_entities_nonmanifold( const EntityHandle star_entity,
00069                                          std::vector< std::vector< EntityHandle > >& stars,
00070                                          std::vector< bool >* bdy_flags                        = NULL,
00071                                          std::vector< std::vector< EntityHandle > >* dp2_stars = NULL );
00072 
00073     //! given a star_center, a last_entity (whose dimension should be 1 greater than center)
00074     //! and last_dp1 (dimension 2 higher than center), returns the next star entity across
00075     //! last_dp1, and the next dp1 entity sharing next_entity; if star_candidates is non-empty,
00076     //! star must come from those
00077     ErrorCode star_next_entity( const EntityHandle star_center, const EntityHandle last_entity,
00078                                 const EntityHandle last_dp1, Range* star_candidates_dp1, EntityHandle& next_entity,
00079                                 EntityHandle& next_dp1 );
00080 
00081     //! get "bridge" or "2nd order" adjacencies, going through dimension bridge_dim
00082     ErrorCode get_bridge_adjacencies( Range& from_entities, int bridge_dim, int to_dim, Range& to_ents,
00083                                       int num_layers = 1 );
00084 
00085     //! get "bridge" or "2nd order" adjacencies, going through dimension bridge_dim
00086     ErrorCode get_bridge_adjacencies( const EntityHandle from_entity, const int bridge_dim, const int to_dim,
00087                                       Range& to_adjs );
00088 
00089     //! return a common entity of the specified dimension, or 0 if there isn't one
00090     EntityHandle common_entity( const EntityHandle ent1, const EntityHandle ent2, const int dim );
00091 
00092     //! return the opposite side entity given a parent and bounding entity.
00093     //! This function is only defined for certain types of parent/child types;
00094     //! See MBCN.hpp::OppositeSide for details.
00095     //!
00096     //! \param parent The parent element
00097     //! \param child The child element
00098     //! \param opposite_element The index of the opposite element
00099     ErrorCode opposite_entity( const EntityHandle parent, const EntityHandle child, EntityHandle& opposite_element );
00100 
00101     //! split entity which is non-manifold, that is, which has > 2 connected entities
00102     //! of next higher dimension; assumes that there are >= 2 connected regions of
00103     //! (d+2)-dimensional entities; a new d-entity is created for each region after the
00104     //! first, and it's made explicitly-adjacent to the region to which it corresponds
00105     ErrorCode split_entity_nonmanifold( EntityHandle split_ent, Range& old_adjs, Range& new_adjs,
00106                                         EntityHandle& new_entity );
00107 
00108     //! split entities that are manifold (shared by two or less entities of each higher dimension),
00109     //! optionally creating an entity of next higher dimension to fill the gap
00110     /**
00111        \param entities The entities to be split
00112        \param new_entities New entities, in order of correspondence to that of entities
00113        \param fill_entities If non-NULL, create an entity of next higher dimension to fill the gap,
00114                        passing it back in *fill_entities
00115     */
00116     ErrorCode split_entities_manifold( Range& entities, Range& new_entities, Range* fill_entities );
00117 
00118     //! split entities that are manifold (shared by two or less entities of each higher dimension),
00119     //! optionally creating an entity of next higher dimension to fill the gap
00120     /**
00121        \param entities The entities to be split
00122        \param new_entities New entities, in order of correspondence to that of entities
00123        \param fill_entities If non-NULL, create an entity of next higher dimension to fill the gap,
00124                        passing it back in *fill_entities
00125        \param gowith_ents If non-NULL, each of the new entities will adj to the
00126                        corresponding gowith entities after the split; this parameter is
00127                        ignored for boundary split entities; in that case, the split entity
00128                        remains on the boundary (i.e. not adj to any entity of higher
00129                        dimension).  Dimension of gowith_ents must be the same as entities.
00130     */
00131     ErrorCode split_entities_manifold( EntityHandle* entities, const int num_entities, EntityHandle* new_entities,
00132                                        Range* fill_entities, EntityHandle* gowith_ents = NULL );
00133 
00134     //! return whether entity is equivalent to any other of same type and same vertices;
00135     //! if equivalent entity is found, it's returned in equiv_ents and return value is true,
00136     //! false otherwise.
00137     bool equivalent_entities( const EntityHandle entity, Range* equiv_ents = NULL );
00138 
00139   private:
00140     Interface* mbImpl;
00141 };
00142 
00143 }  // namespace moab
00144 
00145 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines