Mesh Oriented datABase  (version 5.6.0)
An array-based unstructured mesh library
moab::Core Class Reference

Implementation of MOAB Interface Implementation of the MOAB Interface class. You shouldn't call functions directly on an object of type Core (use Interface instead), unless you really have to access non-API functionality. More...

#include <Core.hpp>

+ Inheritance diagram for moab::Core:
+ Collaboration diagram for moab::Core:

Classes

class  HONodeAddedRemoved
 function object for recieving events from MB of higher order nodes added to entities More...
 

Public Types

typedef unsigned long long type_memstorage
 
- Public Types inherited from moab::Interface
enum  { INTERSECT , UNION }
 Enumerated type used in get_adjacencies() and other functions. More...
 

Public Member Functions

 Core ()
 constructor More...
 
 ~Core ()
 destructor More...
 
virtual ErrorCode query_interface_type (const std::type_info &interface_type, void *&ptr)
 Get a pointer to an internal MOAB interface. More...
 
virtual ErrorCode release_interface_type (const std::type_info &interface_type, void *iface)
 Release reference to MB interface. More...
 
virtual int QueryInterface (const MBuuid &uuid, UnknownInterface **iface)
 
virtual float impl_version (std::string *version_string=NULL)
 Returns the major.minor version number of the implementation. More...
 
virtual EntityType type_from_handle (const EntityHandle handle) const
 get the type from a handle, returns type More...
 
virtual EntityID id_from_handle (const EntityHandle handle) const
 get the id from a handle, returns id More...
 
virtual ErrorCode handle_from_id (const EntityType type, const EntityID id, EntityHandle &handle) const
 get a handle from an id and type More...
 
virtual int dimension_from_handle (const EntityHandle) const
 Returns the topological dimension of an entity. More...
 
virtual ErrorCode load_mesh (const char *file_name, const int *active_block_id_list=NULL, const int num_blocks=0)
 load mesh from data in file NOTE: if there is mesh already present, the new mesh will be added More...
 
virtual ErrorCode load_file (const char *file_name, const EntityHandle *file_set=0, const char *options=0, const char *set_tag_name=0, const int *set_tag_vals=0, int num_set_tag_vals=0)
 
ErrorCode serial_load_file (const char *file_name, const EntityHandle *file_set, const FileOptions &opts, const ReaderIface::SubsetList *subsets=0, const Tag *file_id_tag=0)
 
ErrorCode serial_read_tag (const char *file_name, const char *tag_name, const FileOptions &opts, std::vector< int > &tag_vals, const ReaderIface::SubsetList *subsets=0)
 
virtual ErrorCode write_mesh (const char *file_name, const EntityHandle *output_list=NULL, const int num_sets=0)
 Writes mesh to a file. More...
 
virtual ErrorCode write_file (const char *file_name, const char *file_type=0, const char *options=0, const EntityHandle *output_sets=0, int num_output_sets=0, const Tag *tag_list=0, int num_tags=0)
 
virtual ErrorCode write_file (const char *file_name, const char *file_type, const char *options, const Range &output_sets, const Tag *tag_list=0, int num_tags=0)
 
virtual ErrorCode delete_mesh ()
 deletes all mesh entities from this datastore More...
 
virtual ErrorCode get_dimension (int &dim) const
 get overall geometric dimension More...
 
virtual ErrorCode set_dimension (const int dim)
 set overall geometric dimension More...
 
virtual ErrorCode get_vertex_coordinates (std::vector< double > &coords) const
 get blocked vertex coordinates for all vertices More...
 
virtual ErrorCode coords_iterate (Range::const_iterator iter, Range::const_iterator end, double *&xcoords_ptr, double *&ycoords_ptr, double *&zcoords_ptr, int &count)
 get pointers to coordinate data More...
 
virtual ErrorCode get_coords (const Range &entities, double *coords) const
 get the coordinate information for this handle if it is of type Vertex otherwise, return an error More...
 
virtual ErrorCode get_coords (const EntityHandle *entities, const int num_entities, double *coords) const
 Gets xyz coordinate information for vector of vertices. More...
 
virtual ErrorCode get_coords (const EntityHandle entity_handle, const double *&x, const double *&y, const double *&z) const
 
virtual ErrorCode get_coords (const Range &entities, double *x_coords, double *y_coords, double *z_coords) const
 
virtual ErrorCode set_coords (const EntityHandle *entity_handles, const int num_entities, const double *coords)
 set the coordinate information for this handle if it is of type Vertex otherwise, return an error More...
 
virtual ErrorCode set_coords (Range entity_handles, const double *coords)
 set the coordinate information for this handle if it is of type Vertex otherwise, return an error More...
 
virtual ErrorCode get_connectivity_by_type (const EntityType type, std::vector< EntityHandle > &connect) const
 get global connectivity array for specified entity type More...
 
virtual ErrorCode connect_iterate (Range::const_iterator iter, Range::const_iterator end, EntityHandle *&connect, int &verts_per_entity, int &count)
 get pointer to connectivity data More...
 
virtual ErrorCode get_connectivity (const EntityHandle *entity_handles, const int num_handles, std::vector< EntityHandle > &connectivity, bool corners_only=false, std::vector< int > *offsets=NULL) const
 Gets the connectivity for an element EntityHandle. More...
 
virtual ErrorCode get_connectivity (const EntityHandle *entity_handles, const int num_handles, Range &connectivity, bool corners_only=false) const
 Gets the connectivity for a vector of elements. More...
 
virtual ErrorCode get_connectivity (const Range &from_entities, Range &adj_entities, bool corners_only=false) const
 Gets the connectivity for elements. More...
 
virtual ErrorCode get_connectivity (const EntityHandle entity_handle, const EntityHandle *&connectivity, int &number_nodes, bool corners_only=false, std::vector< EntityHandle > *storage=0) const
 Gets a pointer to constant connectivity data of entity_handle More...
 
virtual ErrorCode set_connectivity (const EntityHandle entity_handle, EntityHandle *connect, const int num_connect)
 Sets the connectivity for an EntityHandle. For non-element handles, return an error. More...
 
virtual ErrorCode get_adjacencies (const EntityHandle *from_entities, const int num_entities, const int to_dimension, const bool create_if_missing, std::vector< EntityHandle > &adj_entities, const int operation_type=Interface::INTERSECT)
 get the adjacencies associated with a set of entities More...
 
virtual ErrorCode get_adjacencies (const EntityHandle *from_entities, const int num_entities, const int to_dimension, const bool create_if_missing, Range &adj_entities, const int operation_type=Interface::INTERSECT)
 Get the adjacencies associated with a vector of entities to entities of a specfied dimension. More...
 
virtual ErrorCode get_adjacencies (const Range &from_entities, const int to_dimension, const bool create_if_missing, Range &adj_entities, const int operation_type=Interface::INTERSECT)
 Get the adjacencies associated with a range of entities to entities of a specfied dimension. More...
 
ErrorCode adjacencies_iterate (Range::const_iterator iter, Range::const_iterator end, const std::vector< EntityHandle > **&adjs_ptr, int &count)
 Get a ptr to adjacency lists Get a pointer to adjacency lists. These lists are std::vector<EntityHandle>, which are pointed to by adjs[i]. Adjacencies are not guaranteed to be in order of increasing dimension. Only a const version of this function is given, because adjacency data is managed more carefully in MOAB and should be treated as read-only by applications. If adjacencies have not yet been initialized, adjs_ptr will be NULL (i.e. adjs_ptr == NULL). There may also be NULL entries for individual entities, i.e. adjs_ptr[i] == NULL. More...
 
virtual ErrorCode get_vertices (const Range &from_entities, Range &vertices)
 Get all vertices for input entities. More...
 
virtual ErrorCode get_entities_by_dimension (const EntityHandle meshset, const int dimension, Range &entities, const bool recursive=false) const
 Adds adjacencies. More...
 
virtual ErrorCode get_entities_by_dimension (const EntityHandle meshset, const int dimension, std::vector< EntityHandle > &entities, const bool recursive=false) const
 Retrieves all entities of a given topological dimension in the database or meshset. More...
 
virtual ErrorCode get_entities_by_type (const EntityHandle meshset, const EntityType type, Range &entities, const bool recursive=false) const
 Retrieves all entities in the data base of given type. More...
 
virtual ErrorCode get_entities_by_type (const EntityHandle meshset, const EntityType type, std::vector< EntityHandle > &entities, const bool recursive=false) const
 Retrieves all entities in the data base of given type. More...
 
virtual ErrorCode get_entities_by_type_and_tag (const EntityHandle meshset, const EntityType type, const Tag *tags, const void *const *values, const int num_tags, Range &entities, const int condition=Interface::INTERSECT, const bool recursive=false) const
 Retrieve entities in the database or meshset which have any or all of the tag(s) and (optionally) value(s) specified. More...
 
virtual ErrorCode get_entities_by_handle (const EntityHandle meshset, Range &entities, const bool recursive=false) const
 Retrieves all entities in the data base. More...
 
virtual ErrorCode get_entities_by_handle (const EntityHandle meshset, std::vector< EntityHandle > &entities, const bool recursive=false) const
 Retrieves all entities in the data base. More...
 
virtual ErrorCode get_number_entities_by_dimension (const EntityHandle meshset, const int dimension, int &number, const bool recursive=false) const
 Retrieves all entities in the database of given dimension. More...
 
virtual ErrorCode get_number_entities_by_type (const EntityHandle meshset, const EntityType type, int &num_entities, const bool recursive=false) const
 Retrieves all entities in the data base of given type. More...
 
virtual ErrorCode get_number_entities_by_type_and_tag (const EntityHandle meshset, const EntityType type, const Tag *tag_handles, const void *const *values, const int num_tags, int &num_entities, const int condition=Interface::INTERSECT, const bool recursive=false) const
 Retrieve number of entities in the database or meshset which have any or all of the tag(s) and (optionally) value(s) specified. More...
 
virtual ErrorCode get_number_entities_by_handle (const EntityHandle meshset, int &num_entities, const bool recursive=false) const
 Retrieves all entities in the data base. More...
 
virtual ErrorCode create_element (const EntityType type, const EntityHandle *connectivity, const int num_nodes, EntityHandle &element_handle)
 Creates an element based on the type and connectivity. More...
 
virtual ErrorCode create_vertex (const double coords[3], EntityHandle &entity_handle)
 Creates a vertex based on coordinates. More...
 
virtual ErrorCode create_vertices (const double *coordinates, const int nverts, Range &entity_handles)
 Create a set of vertices with the specified coordinates. More...
 
virtual ErrorCode merge_entities (EntityHandle entity_to_keep, EntityHandle entity_to_remove, bool auto_merge, bool delete_removed_entity)
 merges two entities More...
 
virtual ErrorCode delete_entities (const EntityHandle *entities, const int num_entities)
 Removes entities in a vector from the data base. More...
 
virtual ErrorCode delete_entities (const Range &range)
 Removes entities in a range from the data base. More...
 
virtual ErrorCode list_entities (const Range &temp_range) const
 List entities to standard output. More...
 
virtual ErrorCode list_entities (const EntityHandle *entities, const int num_entities) const
 List entities, or number of entities in database, to standard output. More...
 
virtual ErrorCode list_entity (const EntityHandle entity) const
 List a single entity; no header printed. More...
 
virtual ErrorCode convert_entities (const EntityHandle meshset, const bool mid_side, const bool mid_face, const bool mid_volume, Interface::HONodeAddedRemoved *function_object=0)
 Convert entities to higher-order elements by adding mid nodes. More...
 
virtual ErrorCode side_number (const EntityHandle parent, const EntityHandle child, int &sd_number, int &sense, int &offset) const
 function to get the side number given two elements; returns MB_FAILURE if child not related to parent; does not create adjacencies between parent and child More...
 
virtual ErrorCode high_order_node (const EntityHandle parent_handle, const EntityHandle *subfacet_conn, const EntityType subfacet_type, EntityHandle &hon) const
 given an entity and the connectivity and type of one of its subfacets, find the high order node on that subfacet, if any More...
 
virtual ErrorCode side_element (const EntityHandle source_entity, const int dim, const int sd_number, EntityHandle &target_entity) const
 given an entity and a target dimension & side number, get that entity More...
 
virtual ErrorCode tag_get_handle (const char *name, int size, DataType type, Tag &tag_handle, unsigned flags=0, const void *default_value=0, bool *created=0)
 Get a tag handle, possibly creating the tag. More...
 
virtual ErrorCode tag_get_handle (const char *name, int size, DataType type, Tag &tag_handle, unsigned flags=0, const void *default_value=0) const
 same as non-const version, except that TAG_CREAT flag is ignored. More...
 
virtual ErrorCode tag_get_name (const Tag tag_handle, std::string &tag_name) const
 Gets the tag name string of the tag_handle. More...
 
virtual ErrorCode tag_get_handle (const char *tag_name, Tag &tag_handle) const
 Gets the tag handle corresponding to a name. More...
 
virtual ErrorCode tag_get_tags_on_entity (const EntityHandle entity, std::vector< Tag > &tag_handles) const
 Get handles for all tags defined on this entity. More...
 
virtual ErrorCode tag_get_bytes (const Tag tag, int &tag_size) const
 Get the size of the specified tag in bytes. More...
 
virtual ErrorCode tag_get_length (const Tag tag, int &tag_size) const
 Get the array length of a tag. More...
 
virtual ErrorCode tag_get_default_value (const Tag tag, void *def_val) const
 Get the default value of the specified tag. More...
 
virtual ErrorCode tag_get_default_value (Tag tag, const void *&ptr, int &size) const
 Get a tag handle, possibly creating the tag. More...
 
virtual ErrorCode tag_get_type (const Tag, TagType &tag_type) const
 get type of tag (sparse, dense, etc.; 0 = dense, 1 = sparse, 2 = bit, 3 = mesh) More...
 
virtual ErrorCode tag_get_data_type (const Tag handle, DataType &type) const
 Get data type of tag. More...
 
virtual ErrorCode tag_get_tags (std::vector< Tag > &tag_handles) const
 get handles for all tags defined More...
 
virtual ErrorCode tag_get_data (const Tag tag_handle, const EntityHandle *entity_handles, const int num_entities, void *tag_data) const
 return the tag data for a given EntityHandle and Tag More...
 
virtual ErrorCode tag_get_data (const Tag tag_handle, const Range &entity_handles, void *tag_data) const
 return the tag data for a given EntityHandle and Tag More...
 
virtual ErrorCode tag_set_data (Tag tag_handle, const EntityHandle *entity_handles, int num_entities, const void *tag_data)
 Sets the data of a given EntityHandle and Tag. More...
 
virtual ErrorCode tag_set_data (Tag tag_handle, const Range &entity_handles, const void *tag_data)
 set the data for given EntityHandles and Tag More...
 
virtual ErrorCode tag_get_by_ptr (const Tag tag_handle, const EntityHandle *entity_handles, int num_entities, const void **tag_data, int *tag_sizes=0) const
 Get pointers to tag data. More...
 
virtual ErrorCode tag_get_by_ptr (const Tag tag_handle, const Range &entity_handles, const void **tag_data, int *tag_sizes=0) const
 Get pointers to tag data. More...
 
virtual ErrorCode tag_set_by_ptr (Tag tag_handle, const EntityHandle *entity_handles, int num_entities, void const *const *tag_data, const int *tag_sizes=0)
 Set tag data given an array of pointers to tag values. More...
 
virtual ErrorCode tag_set_by_ptr (Tag tag_handle, const Range &entity_handles, void const *const *tag_data, const int *tag_sizes=0)
 Set tag data given an array of pointers to tag values. More...
 
virtual ErrorCode tag_clear_data (Tag tag_handle, const Range &entity_handles, const void *tag_data, int tag_size=0)
 Set tag data given value. More...
 
virtual ErrorCode tag_clear_data (Tag tag_handle, const EntityHandle *entity_handles, int num_entities, const void *tag_data, int tag_size=0)
 Set tag data given value. More...
 
virtual ErrorCode tag_delete_data (Tag tag_handle, const EntityHandle *entity_handles, int num_entities)
 Delete the data of a vector of entity handles and sparse tag. More...
 
virtual ErrorCode tag_delete_data (Tag tag_handle, const Range &entity_handles)
 Delete the data of a range of entity handles and sparse tag. More...
 
virtual ErrorCode tag_delete (Tag tag_handle)
 Removes the tag from the database and deletes all of its associated data. More...
 
virtual ErrorCode tag_iterate (Tag tag_handle, Range::const_iterator iter, Range::const_iterator end, int &count, void *&data_ptr, bool allocate=true)
 Access tag data via direct pointer into contiguous blocks. More...
 
virtual ErrorCode create_meshset (const unsigned int options, EntityHandle &ms_handle, int start_id=0)
 creates a mesh set More...
 
virtual ErrorCode clear_meshset (const EntityHandle *ms_handles, const int num_meshsets)
 Empty a vector of mesh set. More...
 
virtual ErrorCode clear_meshset (const Range &ms_handles)
 Empty a range of mesh set. More...
 
virtual ErrorCode get_meshset_options (const EntityHandle ms_handle, unsigned int &options) const
 get the options of a mesh set More...
 
virtual ErrorCode set_meshset_options (const EntityHandle ms_handle, const unsigned int options)
 set the options of a mesh set More...
 
virtual ErrorCode subtract_meshset (EntityHandle meshset1, const EntityHandle meshset2)
 subtracts meshset2 from meshset1 - modifies meshset1 More...
 
virtual ErrorCode intersect_meshset (EntityHandle meshset1, const EntityHandle meshset2)
 intersects meshset2 with meshset1 - modifies meshset1 More...
 
virtual ErrorCode unite_meshset (EntityHandle meshset1, const EntityHandle meshset2)
 unites meshset2 with meshset1 - modifies meshset1 More...
 
virtual ErrorCode add_entities (EntityHandle meshset, const Range &entities)
 add entities to meshset More...
 
virtual ErrorCode add_entities (EntityHandle meshset, const EntityHandle *entities, const int num_entities)
 add entities to meshset More...
 
virtual ErrorCode remove_entities (EntityHandle meshset, const Range &entities)
 remove entities from meshset More...
 
virtual ErrorCode remove_entities (EntityHandle meshset, const EntityHandle *entities, const int num_entities)
 remove entities from meshset More...
 
virtual bool contains_entities (EntityHandle meshset, const EntityHandle *entities, int num_entities, const int operation_type=Interface::INTERSECT)
 return true if all entities are contained in set More...
 
virtual ErrorCode replace_entities (EntityHandle meshset, const EntityHandle *old_entities, const EntityHandle *new_entities, int num_entities)
 replace entities More...
 
virtual ErrorCode get_parent_meshsets (const EntityHandle meshset, std::vector< EntityHandle > &parents, const int num_hops=1) const
 get parent meshsets More...
 
virtual ErrorCode get_parent_meshsets (const EntityHandle meshset, Range &parents, const int num_hops=1) const
 get parent meshsets More...
 
virtual ErrorCode get_child_meshsets (const EntityHandle meshset, std::vector< EntityHandle > &children, const int num_hops=1) const
 get child meshsets More...
 
virtual ErrorCode get_child_meshsets (const EntityHandle meshset, Range &children, const int num_hops=1) const
 get child meshsets More...
 
virtual ErrorCode get_contained_meshsets (const EntityHandle meshset, std::vector< EntityHandle > &children, const int num_hops=1) const
 get contained meshsets More...
 
virtual ErrorCode get_contained_meshsets (const EntityHandle meshset, Range &children, const int num_hops=1) const
 get contained meshsets More...
 
virtual ErrorCode num_parent_meshsets (const EntityHandle meshset, int *number, const int num_hops=1) const
 gets number of parent meshsets More...
 
virtual ErrorCode num_child_meshsets (const EntityHandle meshset, int *number, const int num_hops=1) const
 gets number of child meshsets More...
 
virtual ErrorCode num_contained_meshsets (const EntityHandle meshset, int *number, const int num_hops=1) const
 gets number of contained meshsets More...
 
virtual ErrorCode add_parent_meshset (EntityHandle meshset, const EntityHandle parent_meshset)
 add a parent meshset More...
 
virtual ErrorCode add_parent_meshsets (EntityHandle meshset, const EntityHandle *parents, int count)
 add parent meshsets More...
 
virtual ErrorCode add_child_meshset (EntityHandle meshset, const EntityHandle child_meshset)
 add a child meshset More...
 
virtual ErrorCode add_child_meshsets (EntityHandle meshset, const EntityHandle *children, int count)
 add parent meshsets More...
 
virtual ErrorCode add_parent_child (EntityHandle parent, EntityHandle child)
 adds 'parent' to child's parent list and adds 'child' to parent's child list More...
 
virtual ErrorCode remove_parent_child (EntityHandle parent, EntityHandle child)
 removes 'parent' to child's parent list and removes 'child' to parent's child list More...
 
virtual ErrorCode remove_parent_meshset (EntityHandle meshset, const EntityHandle parent_meshset)
 remove parent meshset More...
 
virtual ErrorCode remove_child_meshset (EntityHandle meshset, const EntityHandle child_meshset)
 remove child meshset More...
 
Tag material_tag ()
 return various specific tag handles More...
 
Tag neumannBC_tag ()
 
Tag dirichletBC_tag ()
 
Tag globalId_tag ()
 Get parent mesh sets of a mesh set. More...
 
Tag geom_dimension_tag ()
 
SequenceManagersequence_manager ()
 get/set the number of nodes More...
 
const SequenceManagersequence_manager () const
 
ErrorCode create_scd_sequence (const HomCoord &coord_min, const HomCoord &coord_max, EntityType type, EntityID start_id_hint, EntityHandle &first_handle_out, EntitySequence *&sequence_out)
 create structured sequence More...
 
ErrorCode add_vsequence (EntitySequence *vert_seq, EntitySequence *elem_seq, const HomCoord &p1, const HomCoord &q1, const HomCoord &p2, const HomCoord &q2, const HomCoord &p3, const HomCoord &q3, bool bb_input=false, const HomCoord *bb_min=NULL, const HomCoord *bb_max=NULL)
 
AEntityFactorya_entity_factory ()
 return the a_entity_factory pointer More...
 
const AEntityFactorya_entity_factory () const
 
ReaderWriterSetreader_writer_set ()
 return set of registered IO tools More...
 
void print (const EntityHandle handle, const char *prefix, bool first_call=true) const
 
ErrorCode print_entity_tags (std::string indent_prefix, const EntityHandle handle, TagType tp) const
 
virtual ErrorCode get_last_error (std::string &info) const
 Return information about the last error. More...
 
virtual std::string get_error_string (const ErrorCode code) const
 Return string representation of given error code. More...
 
ErrorCode check_adjacencies ()
 check all adjacencies for consistency More...
 
ErrorCode check_adjacencies (const EntityHandle *ents, int num_ents)
 check some adjacencies for consistency More...
 
bool is_valid (const EntityHandle this_ent) const
 return whether the input handle is valid or not More...
 
virtual ErrorCode create_set_iterator (EntityHandle meshset, EntityType ent_type, int ent_dim, int chunk_size, bool check_valid, SetIterator *&set_iter)
 Create an iterator over the set Create a new iterator that iterates over entities with the specified type or dimension. Only one of ent_type or dim can be set; use dim=-1 or ent_type=MBMAXTYPE for the other. Iterators for list-type (ordered) sets are stable over set modification, unless entity removed or deleted is the one at the current position of the iterator. If the check_valid parameter is passed as true, entities are checked for validity before being passed back by get_next_entities function (checking entity validity can have a non-negligible cost). More...
 
ErrorCode remove_set_iterator (SetIterator *set_iter)
 Remove the set iterator from the instance's list. More...
 
ErrorCode get_set_iterators (EntityHandle meshset, std::vector< SetIterator * > &set_iters)
 Get all set iterators associated with the set passed in. More...
 
void estimated_memory_use (const EntityHandle *ent_array=0, unsigned long num_ents=0, unsigned long long *total_storage=0, unsigned long long *total_amortized_storage=0, unsigned long long *entity_storage=0, unsigned long long *amortized_entity_storage=0, unsigned long long *adjacency_storage=0, unsigned long long *amortized_adjacency_storage=0, const Tag *tag_array=0, unsigned num_tags=0, unsigned long long *tag_storage=0, unsigned long long *amortized_tag_storage=0)
 Calculate amount of memory used to store MOAB data. More...
 
void estimated_memory_use (const Range &ents, unsigned long long *total_storage=0, unsigned long long *total_amortized_storage=0, unsigned long long *entity_storage=0, unsigned long long *amortized_entity_storage=0, unsigned long long *adjacency_storage=0, unsigned long long *amortized_adjacency_storage=0, const Tag *tag_array=0, unsigned num_tags=0, unsigned long long *tag_storage=0, unsigned long long *amortized_tag_storage=0)
 Calculate amount of memory used to store MOAB data. More...
 
void print_database () const
 
Sequence Option controllers
virtual double get_sequence_multiplier () const
 Interface to control memory allocation for sequences Provide a factor that controls the size of the sequence that gets allocated. This is typically useful in the parallel setting when a-priori, the number of ghost entities and the memory required for them within the same sequence as the owned entities are unknown. The default factor is 1.0 but this can be appropriately updated at runtime so that we do not have broken sequences. More...
 
virtual void set_sequence_multiplier (double factor)
 Interface to control memory allocation for sequences Provide a factor that controls the size of the sequence that gets allocated. This is typically useful in the parallel setting when a-priori, the number of ghost entities and the memory required for them within the same sequence as the owned entities are unknown. The default factor is 1.0 but this can be appropriately updated at runtime so that we do not have broken sequences. More...
 
- Public Member Functions inherited from moab::Interface
 Interface ()
 constructor More...
 
virtual ~Interface ()
 destructor More...
 
template<class IFace >
ErrorCode query_interface (IFace *&ptr)
 Get a pointer to an internal MOAB interface. More...
 
template<class IFace >
ErrorCode release_interface (IFace *interface)
 constructor More...
 
virtual float api_version (std::string *version_string=NULL)
 Release reference to MB interface. More...
 
virtual ErrorCode add_adjacencies (const EntityHandle from_handle, const EntityHandle *to_handles, const int num_handles, bool both_ways)=0
 Adds adjacencies between "from" and "to" entities. More...
 
virtual ErrorCode add_adjacencies (const EntityHandle from_handle, Range &adjacencies, bool both_ways)=0
 Adds adjacencies; same as vector-based, but with range instead. More...
 
virtual ErrorCode remove_adjacencies (const EntityHandle from_handle, const EntityHandle *to_handles, const int num_handles)=0
 Removes adjacencies between handles. More...
 
- Public Member Functions inherited from moab::UnknownInterface
virtual ~UnknownInterface ()
 

Private Member Functions

 Core (const Core &copy)
 Do not allow copying. More...
 
Coreoperator= (const Core &copy)
 Do not allow copying. More...
 
void estimated_memory_use_internal (const Range *ents, unsigned long long *total_storage, unsigned long long *total_amortized_storage, unsigned long long *entity_storage, unsigned long long *amortized_entity_storage, unsigned long long *adjacency_storage, unsigned long long *amortized_adjacency_storage, const Tag *tag_array, unsigned num_tags, unsigned long long *tag_storage, unsigned long long *amortized_tag_storage)
 
ErrorCode initialize ()
 database init and de-init routines More...
 
void deinitialize ()
 
EntityHandle get_root_set ()
 return the entity set representing the whole mesh More...
 
void clean_up_failed_read (const Range &initial_ents, std::vector< Tag > initial_tags)
 Clean up after a file reader returns failure. More...
 
bool valid_tag_handle (const TagInfo *t) const
 

Private Attributes

WriteUtilmMBWriteUtil
 
ReadUtilmMBReadUtil
 
ScdInterfacescdInterface
 
int geometricDimension
 store the total number of elements defined in this interface More...
 
Tag materialTag
 
Tag neumannBCTag
 
Tag dirichletBCTag
 
Tag geomDimensionTag
 
Tag globalIdTag
 
std::list< TagInfo * > tagList
 tag server for this interface More...
 
SequenceManagersequenceManager
 
AEntityFactoryaEntityFactory
 
ReaderWriterSetreaderWriterSet
 
ErrormError
 
bool mpiFinalize
 
int writeMPELog
 
bool initErrorHandlerInCore
 
std::vector< SetIterator * > setIterators
 list of iterators More...
 

Friends

class SetIterator
 

Detailed Description

Implementation of MOAB Interface Implementation of the MOAB Interface class. You shouldn't call functions directly on an object of type Core (use Interface instead), unless you really have to access non-API functionality.

Examples
ComputeTriDual.cpp, ExchangeHalos.cpp, GeomSetHierarchy.cpp, GetEntities.cpp, HelloMOAB.cpp, HelloParMOAB.cpp, KDTree.cpp, ObbTree.cpp, ReadWriteTest.cpp, UniformRefinement.cpp, mbex1.cpp, mbex2.cpp, mbex3.cpp, and mbex4.cpp.

Definition at line 49 of file Core.hpp.

Member Typedef Documentation

◆ type_memstorage

typedef unsigned long long moab::Core::type_memstorage

Definition at line 558 of file Core.hpp.

Constructor & Destructor Documentation

◆ Core() [1/2]

moab::Core::Core ( )

constructor

Constructor.

Definition at line 170 of file Core.cpp.

171 {
172  if( initialize() != MB_SUCCESS )
173  {
174  printf( "Error initializing moab::Core\n" );
175  exit( 1 );
176  }
177 }

References GaussIntegration::initialize(), and MB_SUCCESS.

◆ ~Core()

moab::Core::~Core ( )

destructor

Definition at line 180 of file Core.cpp.

181 {
182  if( mMBWriteUtil ) delete mMBWriteUtil;
183  if( mMBReadUtil ) delete mMBReadUtil;
184  if( scdInterface ) delete scdInterface;
185 
186  mMBWriteUtil = NULL;
187  mMBReadUtil = NULL;
188  scdInterface = NULL;
189 
190  deinitialize();
191 }

◆ Core() [2/2]

moab::Core::Core ( const Core copy)
private

Do not allow copying.

Member Function Documentation

◆ a_entity_factory() [1/2]

AEntityFactory* moab::Core::a_entity_factory ( )
inline

◆ a_entity_factory() [2/2]

const AEntityFactory* moab::Core::a_entity_factory ( ) const
inline

Definition at line 1073 of file Core.hpp.

1074  {
1075  return aEntityFactory;
1076  }

References aEntityFactory.

◆ add_child_meshset()

ErrorCode moab::Core::add_child_meshset ( EntityHandle  meshset,
const EntityHandle  child_meshset 
)
virtual

add a child meshset

Implements moab::Interface.

Definition at line 3621 of file Core.cpp.

3622 {
3623  MeshSet* set_ptr = get_mesh_set( sequence_manager(), meshset );
3624  MeshSet* child_ptr = get_mesh_set( sequence_manager(), child_meshset );
3625  if( !set_ptr || !child_ptr ) return MB_ENTITY_NOT_FOUND;
3626 
3627  set_ptr->add_child( child_meshset );
3628  return MB_SUCCESS;
3629 }

References moab::MeshSet::add_child(), moab::get_mesh_set(), MB_ENTITY_NOT_FOUND, and MB_SUCCESS.

◆ add_child_meshsets()

ErrorCode moab::Core::add_child_meshsets ( EntityHandle  meshset,
const EntityHandle children,
int  count 
)
virtual

add parent meshsets

Implements moab::Interface.

Definition at line 3631 of file Core.cpp.

3632 {
3633  MeshSet* set_ptr = get_mesh_set( sequence_manager(), meshset );
3634  if( !set_ptr ) return MB_ENTITY_NOT_FOUND;
3635 
3636  for( int i = 0; i < count; ++i )
3637  if( !get_mesh_set( sequence_manager(), children[i] ) ) return MB_ENTITY_NOT_FOUND;
3638 
3639  for( int i = 0; i < count; ++i )
3640  set_ptr->add_child( children[i] );
3641  return MB_SUCCESS;
3642 }

References moab::MeshSet::add_child(), moab::get_mesh_set(), MB_ENTITY_NOT_FOUND, and MB_SUCCESS.

◆ add_entities() [1/2]

ErrorCode moab::Core::add_entities ( EntityHandle  meshset,
const EntityHandle entities,
const int  num_entities 
)
virtual

add entities to meshset

Implements moab::Interface.

Definition at line 3419 of file Core.cpp.

3420 {
3421  MeshSet* set = get_mesh_set( sequence_manager(), meshset );
3422  if( set )
3423  return set->add_entities( entities, num_entities, meshset, a_entity_factory() );
3424  else
3425  return MB_ENTITY_NOT_FOUND;
3426 }

References moab::MeshSet::add_entities(), moab::get_mesh_set(), and MB_ENTITY_NOT_FOUND.

◆ add_entities() [2/2]

ErrorCode moab::Core::add_entities ( EntityHandle  meshset,
const Range entities 
)
virtual

add entities to meshset

Implements moab::Interface.

Definition at line 3410 of file Core.cpp.

3411 {
3412  MeshSet* set = get_mesh_set( sequence_manager(), meshset );
3413  if( set )
3414  return set->add_entities( entities, meshset, a_entity_factory() );
3415  else
3416  return MB_ENTITY_NOT_FOUND;
3417 }

References moab::MeshSet::add_entities(), moab::get_mesh_set(), and MB_ENTITY_NOT_FOUND.

Referenced by moab::NestedRefine::create_hm_storage_single_level(), moab::NestedRefine::exchange_ghosts(), main(), process_partition_file(), moab::ReorderTool::update_set_contents(), and moab::NestedRefine::update_special_tags().

◆ add_parent_child()

ErrorCode moab::Core::add_parent_child ( EntityHandle  parent,
EntityHandle  child 
)
virtual

adds 'parent' to child's parent list and adds 'child' to parent's child list

Implements moab::Interface.

Definition at line 3644 of file Core.cpp.

3645 {
3646  MeshSet* parent_ptr = get_mesh_set( sequence_manager(), parent );
3647  MeshSet* child_ptr = get_mesh_set( sequence_manager(), child );
3648  if( !parent_ptr || !child_ptr ) return MB_ENTITY_NOT_FOUND;
3649 
3650  parent_ptr->add_child( child );
3651  child_ptr->add_parent( parent );
3652  return MB_SUCCESS;
3653 }

References moab::MeshSet::add_child(), moab::MeshSet::add_parent(), moab::get_mesh_set(), MB_ENTITY_NOT_FOUND, and MB_SUCCESS.

Referenced by main().

◆ add_parent_meshset()

ErrorCode moab::Core::add_parent_meshset ( EntityHandle  meshset,
const EntityHandle  parent_meshset 
)
virtual

add a parent meshset

Implements moab::Interface.

Definition at line 3598 of file Core.cpp.

3599 {
3600  MeshSet* set_ptr = get_mesh_set( sequence_manager(), meshset );
3601  MeshSet* parent_ptr = get_mesh_set( sequence_manager(), parent_meshset );
3602  if( !set_ptr || !parent_ptr ) return MB_ENTITY_NOT_FOUND;
3603 
3604  set_ptr->add_parent( parent_meshset );
3605  return MB_SUCCESS;
3606 }

References moab::MeshSet::add_parent(), moab::get_mesh_set(), MB_ENTITY_NOT_FOUND, and MB_SUCCESS.

◆ add_parent_meshsets()

ErrorCode moab::Core::add_parent_meshsets ( EntityHandle  meshset,
const EntityHandle parents,
int  count 
)
virtual

add parent meshsets

Implements moab::Interface.

Definition at line 3608 of file Core.cpp.

3609 {
3610  MeshSet* set_ptr = get_mesh_set( sequence_manager(), meshset );
3611  if( !set_ptr ) return MB_ENTITY_NOT_FOUND;
3612 
3613  for( int i = 0; i < count; ++i )
3614  if( !get_mesh_set( sequence_manager(), parents[i] ) ) return MB_ENTITY_NOT_FOUND;
3615 
3616  for( int i = 0; i < count; ++i )
3617  set_ptr->add_parent( parents[i] );
3618  return MB_SUCCESS;
3619 }

References moab::MeshSet::add_parent(), moab::get_mesh_set(), MB_ENTITY_NOT_FOUND, and MB_SUCCESS.

◆ add_vsequence()

ErrorCode moab::Core::add_vsequence ( EntitySequence vert_seq,
EntitySequence elem_seq,
const HomCoord p1,
const HomCoord q1,
const HomCoord p2,
const HomCoord q2,
const HomCoord p3,
const HomCoord q3,
bool  bb_input = false,
const HomCoord bb_min = NULL,
const HomCoord bb_max = NULL 
)

Definition at line 4334 of file Core.cpp.

4345 {
4346  return sequence_manager()->add_vsequence( vert_seq, elem_seq, p1, q1, p2, q2, p3, q3, bb_input, bb_min, bb_max );
4347 }

◆ adjacencies_iterate()

ErrorCode moab::Core::adjacencies_iterate ( Range::const_iterator  iter,
Range::const_iterator  end,
const std::vector< EntityHandle > **&  adjs_ptr,
int &  count 
)
virtual

Get a ptr to adjacency lists Get a pointer to adjacency lists. These lists are std::vector<EntityHandle>, which are pointed to by adjs[i]. Adjacencies are not guaranteed to be in order of increasing dimension. Only a const version of this function is given, because adjacency data is managed more carefully in MOAB and should be treated as read-only by applications. If adjacencies have not yet been initialized, adjs_ptr will be NULL (i.e. adjs_ptr == NULL). There may also be NULL entries for individual entities, i.e. adjs_ptr[i] == NULL.

Parameters
iterIterator to beginning of entity range desired
endEnd iterator for which adjacencies are requested
adjs_ptrPointer to pointer to const std::vector<EntityHandle>; each member of that array is the vector of adjacencies for this entity
countNumber of entities in the contiguous chunk starting from *iter

Implements moab::Interface.

Definition at line 1842 of file Core.cpp.

1846 {
1847  // Make sure the entity should have a connectivity.
1848  EntityType entity_type = TYPE_FROM_HANDLE( *iter );
1849 
1850  // WARNING: This is very dependent on the ordering of the EntityType enum
1851  if( entity_type < MBVERTEX || entity_type > MBENTITYSET ) return MB_TYPE_OUT_OF_RANGE;
1852 
1853  EntitySequence* seq = NULL;
1854 
1855  // We know that connectivity is stored in an EntitySequence so jump straight
1856  // to the entity sequence
1857  ErrorCode rval = sequence_manager()->find( *iter, seq );
1858  if( !seq || rval != MB_SUCCESS ) return MB_ENTITY_NOT_FOUND;
1859 
1860  adjs_ptr = const_cast< const std::vector< EntityHandle >** >( seq->data()->get_adjacency_data() );
1861  if( !adjs_ptr ) return rval;
1862 
1863  adjs_ptr += *iter - seq->data()->start_handle();
1864 
1865  EntityHandle real_end = *( iter.end_of_block() );
1866  if( *end ) real_end = std::min( real_end, *end );
1867  count = real_end - *iter + 1;
1868 
1869  return MB_SUCCESS;
1870 }

References moab::EntitySequence::data(), moab::Range::const_iterator::end_of_block(), ErrorCode, moab::SequenceData::get_adjacency_data(), MB_ENTITY_NOT_FOUND, MB_SUCCESS, MB_TYPE_OUT_OF_RANGE, MBENTITYSET, moab::SequenceData::start_handle(), and moab::TYPE_FROM_HANDLE().

◆ check_adjacencies() [1/2]

ErrorCode moab::Core::check_adjacencies ( )

check all adjacencies for consistency

Definition at line 3833 of file Core.cpp.

3834 {
3835  // run through all entities, checking adjacencies and reverse-evaluating them
3836  Range all_ents;
3837  ErrorCode result = get_entities_by_handle( 0, all_ents );
3838  MB_CHK_ERR( result );
3839 
3840  for( Range::iterator rit = all_ents.begin(); rit != all_ents.end(); ++rit )
3841  {
3842  result = check_adjacencies( &( *rit ), 1 );
3843  MB_CHK_ERR( result );
3844  }
3845 
3846  return MB_SUCCESS;
3847 }

References moab::Range::begin(), moab::Range::end(), ErrorCode, MB_CHK_ERR, and MB_SUCCESS.

◆ check_adjacencies() [2/2]

ErrorCode moab::Core::check_adjacencies ( const EntityHandle ents,
int  num_ents 
)

check some adjacencies for consistency

Definition at line 3849 of file Core.cpp.

3850 {
3851 
3852  ErrorCode result = MB_SUCCESS, tmp_result;
3853  std::ostringstream oss;
3854 
3855  for( int i = 0; i < num_ents; i++ )
3856  {
3857  EntityHandle this_ent = ents[i];
3858  std::ostringstream ent_str;
3859  ent_str << CN::EntityTypeName( TYPE_FROM_HANDLE( this_ent ) ) << " " << ID_FROM_HANDLE( this_ent ) << ": ";
3860  int this_dim = dimension_from_handle( this_ent );
3861 
3862  if( !is_valid( this_ent ) )
3863  {
3864  std::cerr << ent_str.str() << "Not a valid entity." << std::endl;
3865  result = MB_FAILURE;
3866  }
3867 
3868  else
3869  {
3870  if( TYPE_FROM_HANDLE( this_ent ) == MBENTITYSET ) continue;
3871 
3872  // get adjacencies for this entity
3873  Range adjs;
3874  for( int dim = 0; dim <= 3; dim++ )
3875  {
3876  if( dim == this_dim ) continue;
3877  tmp_result = get_adjacencies( &this_ent, 1, dim, false, adjs, Interface::UNION );
3878  if( MB_SUCCESS != tmp_result )
3879  {
3880  oss << ent_str.str() << "Failed to get adjacencies for dimension " << dim << "." << std::endl;
3881  result = tmp_result;
3882  }
3883  }
3884  if( !oss.str().empty() )
3885  {
3886  std::cerr << oss.str();
3887  oss.str( "" );
3888  }
3889 
3890  // now check and reverse-evaluate them
3891  for( Range::iterator rit = adjs.begin(); rit != adjs.end(); ++rit )
3892  {
3893  EntitySequence* seq = 0;
3894  tmp_result = sequence_manager()->find( *rit, seq );
3895  if( seq == 0 || tmp_result != MB_SUCCESS )
3896  {
3897  oss << ent_str.str() << "Adjacent entity " << CN::EntityTypeName( TYPE_FROM_HANDLE( *rit ) ) << " "
3898  << ID_FROM_HANDLE( *rit ) << " is invalid." << std::endl;
3899  result = tmp_result;
3900  }
3901  else
3902  {
3903  Range rev_adjs;
3904  tmp_result = get_adjacencies( &( *rit ), 1, this_dim, false, rev_adjs );
3905  if( MB_SUCCESS != tmp_result )
3906  {
3907  oss << ent_str.str() << "Failed to get reverse adjacency from "
3908  << CN::EntityTypeName( TYPE_FROM_HANDLE( *rit ) ) << " " << ID_FROM_HANDLE( *rit );
3909  if( MB_MULTIPLE_ENTITIES_FOUND == tmp_result )
3910  oss << " (MULTIPLE)" << std::endl;
3911  else
3912  oss << " (" << tmp_result << ")" << std::endl;
3913  result = tmp_result;
3914  }
3915  else if( rev_adjs.find( this_ent ) == rev_adjs.end() )
3916  {
3917  oss << ent_str.str() << "Failed to find adjacency to this entity from "
3918  << CN::EntityTypeName( TYPE_FROM_HANDLE( *rit ) ) << " " << ID_FROM_HANDLE( *rit ) << "."
3919  << std::endl;
3920  result = tmp_result;
3921  }
3922  }
3923  if( !oss.str().empty() )
3924  {
3925  std::cerr << oss.str();
3926  oss.str( "" );
3927  }
3928  }
3929  }
3930  }
3931 
3932  return result;
3933 }

References moab::Range::begin(), moab::Range::end(), moab::CN::EntityTypeName(), ErrorCode, moab::Range::find(), moab::ID_FROM_HANDLE(), MB_MULTIPLE_ENTITIES_FOUND, MB_SUCCESS, MBENTITYSET, moab::TYPE_FROM_HANDLE(), and moab::Interface::UNION.

◆ clean_up_failed_read()

void moab::Core::clean_up_failed_read ( const Range initial_ents,
std::vector< Tag initial_tags 
)
private

Clean up after a file reader returns failure.

Delete all entities not contained in initial_entities and all tags not contained in initial_tags.

Definition at line 493 of file Core.cpp.

494 {
495  Range new_ents;
496  get_entities_by_handle( 0, new_ents );
497  new_ents = subtract( new_ents, initial_ents );
498  delete_entities( new_ents );
499 
500  std::vector< Tag > all_tags, new_tags;
501  tag_get_tags( all_tags );
502  std::sort( initial_tags.begin(), initial_tags.end() );
503  std::sort( all_tags.begin(), all_tags.end() );
504  std::set_difference( all_tags.begin(), all_tags.end(), initial_tags.begin(), initial_tags.end(),
505  std::back_inserter( new_tags ) );
506  while( !new_tags.empty() )
507  {
508  tag_delete( new_tags.back() );
509  new_tags.pop_back();
510  }
511 }

References moab::subtract().

◆ clear_meshset() [1/2]

ErrorCode moab::Core::clear_meshset ( const EntityHandle ms_handles,
const int  num_meshsets 
)
virtual

Empty a vector of mesh set.

Empty a mesh set.

Parameters
ms_handles1d vector of handles of sets being emptied
num_meshsetsNumber of entities in 1d vector

Implements moab::Interface.

Definition at line 3353 of file Core.cpp.

3354 {
3355  ErrorCode result = MB_SUCCESS;
3356  for( int i = 0; i < num_meshsets; ++i )
3357  {
3358  MeshSet* set = get_mesh_set( sequence_manager(), ms_handles[i] );
3359  if( set )
3360  set->clear( ms_handles[i], a_entity_factory() );
3361  else
3362  result = MB_ENTITY_NOT_FOUND;
3363  }
3364 
3365  return result;
3366 }

References moab::MeshSet::clear(), ErrorCode, moab::get_mesh_set(), MB_ENTITY_NOT_FOUND, and MB_SUCCESS.

Referenced by main(), process_partition_file(), moab::AEntityFactory::remove_all_adjacencies(), and moab::ReorderTool::update_set_contents().

◆ clear_meshset() [2/2]

ErrorCode moab::Core::clear_meshset ( const Range ms_handles)
virtual

Empty a range of mesh set.

Empty a mesh set.

Parameters
ms_handlesRange of handles of sets being emptied

Implements moab::Interface.

Definition at line 3368 of file Core.cpp.

3369 {
3370  ErrorCode result = MB_SUCCESS;
3371  for( Range::iterator i = ms_handles.begin(); i != ms_handles.end(); ++i )
3372  {
3373  MeshSet* set = get_mesh_set( sequence_manager(), *i );
3374  if( set )
3375  set->clear( *i, a_entity_factory() );
3376  else
3377  result = MB_ENTITY_NOT_FOUND;
3378  }
3379 
3380  return result;
3381 }

References moab::Range::begin(), moab::MeshSet::clear(), moab::Range::end(), ErrorCode, moab::get_mesh_set(), MB_ENTITY_NOT_FOUND, and MB_SUCCESS.

◆ connect_iterate()

ErrorCode moab::Core::connect_iterate ( Range::const_iterator  iter,
Range::const_iterator  end,
EntityHandle *&  connect,
int &  verts_per_entity,
int &  count 
)
virtual

get pointer to connectivity data

Implements moab::Interface.

Definition at line 1697 of file Core.cpp.

1702 {
1703  // Make sure the entity should have a connectivity.
1704  EntityType entity_type = TYPE_FROM_HANDLE( *iter );
1705 
1706  // WARNING: This is very dependent on the ordering of the EntityType enum
1707  if( entity_type <= MBVERTEX || entity_type >= MBENTITYSET ) return MB_TYPE_OUT_OF_RANGE;
1708 
1709  EntitySequence* seq = NULL;
1710 
1711  // We know that connectivity is stored in an EntitySequence so jump straight
1712  // to the entity sequence
1713  ErrorCode rval = sequence_manager()->find( *iter, seq );
1714  if( !seq || rval != MB_SUCCESS ) return MB_ENTITY_NOT_FOUND;
1715 
1716  ElementSequence* eseq = dynamic_cast< ElementSequence* >( seq );
1717  assert( eseq != NULL );
1718 
1719  connect = eseq->get_connectivity_array();
1720  if( !connect )
1721  {
1722  MB_SET_ERR( MB_FAILURE, "Couldn't find connectivity array for start handle" );
1723  }
1724 
1725  connect += eseq->nodes_per_element() * ( *iter - eseq->start_handle() );
1726 
1727  EntityHandle real_end = std::min( eseq->end_handle(), *( iter.end_of_block() ) );
1728  if( *end ) real_end = std::min( real_end, *end );
1729  count = real_end - *iter + 1;
1730 
1731  verts_per_entity = eseq->nodes_per_element();
1732 
1733  return MB_SUCCESS;
1734 }

References moab::EntitySequence::end_handle(), moab::Range::const_iterator::end_of_block(), ErrorCode, moab::ElementSequence::get_connectivity_array(), MB_ENTITY_NOT_FOUND, MB_SET_ERR, MB_SUCCESS, MB_TYPE_OUT_OF_RANGE, MBENTITYSET, moab::ElementSequence::nodes_per_element(), moab::EntitySequence::start_handle(), and moab::TYPE_FROM_HANDLE().

◆ contains_entities()

bool moab::Core::contains_entities ( EntityHandle  meshset,
const EntityHandle entities,
int  num_entities,
const int  operation_type = Interface::INTERSECT 
)
virtual

return true if all entities are contained in set

Implements moab::Interface.

Definition at line 3449 of file Core.cpp.

3453 {
3454  if( !meshset ) // root
3455  return true;
3456  else if( MeshSet* set = get_mesh_set( sequence_manager(), meshset ) )
3457  return set->contains_entities( entities, num_entities, operation_type );
3458  else
3459  return false;
3460 }

References moab::get_mesh_set().

Referenced by moab::numAdjTriInSet().

◆ convert_entities()

ErrorCode moab::Core::convert_entities ( const EntityHandle  meshset,
const bool  mid_edge,
const bool  mid_face,
const bool  mid_region,
Interface::HONodeAddedRemoved function_object = 0 
)
virtual

Convert entities to higher-order elements by adding mid nodes.

This function causes MB to create mid-nodes on all edges, faces, and element interiors for all entities in meshset. Higher order nodes appear in an element's connectivity array according to the algorithm described in the documentation for Mesh. If HONodeAddedRemoved function is input, this function is called to notify the application of nodes being added/removed from the mesh.

Parameters
meshsetThe set of entities being converted
mid_edgeIf true, mid-edge nodes are created
mid_faceIf true, mid-face nodes are created
mid_regionIf true, mid-element nodes are created
function_objectIf non-NULL, the node_added or node_removed functions on this object are called when nodes are added or removed from an entity, respectively

Implements moab::Interface.

Definition at line 3062 of file Core.cpp.

3067 {
3068  HigherOrderFactory fact( this, function_object );
3069  return fact.convert( meshset, mid_side, mid_face, mid_volume );
3070 }

References moab::HigherOrderFactory::convert().

Referenced by main().

◆ coords_iterate()

ErrorCode moab::Core::coords_iterate ( Range::const_iterator  iter,
Range::const_iterator  end,
double *&  xcoords_ptr,
double *&  ycoords_ptr,
double *&  zcoords_ptr,
int &  count 
)
virtual

get pointers to coordinate data

Implements moab::Interface.

Definition at line 830 of file Core.cpp.

836 {
837  EntitySequence* seq;
838  ErrorCode rval = sequence_manager()->find( *iter, seq );
839  if( MB_SUCCESS != rval )
840  {
841  xcoords_ptr = ycoords_ptr = zcoords_ptr = NULL;
842  MB_SET_ERR( rval, "Couldn't find sequence for start handle" );
843  }
844  VertexSequence* vseq = dynamic_cast< VertexSequence* >( seq );
845  if( !vseq )
846  {
847  MB_SET_ERR( MB_ENTITY_NOT_FOUND, "Couldn't find sequence for start handle" );
848  }
849 
850  unsigned int offset = *iter - vseq->data()->start_handle();
851  xcoords_ptr = reinterpret_cast< double* >( vseq->data()->get_sequence_data( 0 ) ) + offset;
852  ycoords_ptr = reinterpret_cast< double* >( vseq->data()->get_sequence_data( 1 ) ) + offset;
853  zcoords_ptr = reinterpret_cast< double* >( vseq->data()->get_sequence_data( 2 ) ) + offset;
854 
855  EntityHandle real_end = std::min( seq->end_handle(), *( iter.end_of_block() ) );
856  if( *end ) real_end = std::min( real_end, *end );
857  count = real_end - *iter + 1;
858 
859  return MB_SUCCESS;
860 }

References moab::EntitySequence::data(), moab::EntitySequence::end_handle(), moab::Range::const_iterator::end_of_block(), ErrorCode, moab::SequenceData::get_sequence_data(), MB_ENTITY_NOT_FOUND, MB_SET_ERR, MB_SUCCESS, and moab::SequenceData::start_handle().

Referenced by main().

◆ create_element()

ErrorCode moab::Core::create_element ( const EntityType  type,
const EntityHandle connectivity,
const int  num_nodes,
EntityHandle element_handle 
)
virtual

Creates an element based on the type and connectivity.

creates an element based on the type and connectivity. returns a handle and error code

If connectivity vector is not correct for EntityType type (ie, a vector with 3 vertices is passed in to make an MBQUAD), the function returns MB_FAILURE.

Parameters
typeType of element to create. (MBTET, MBTRI, MBKNIFE, etc.)
connectivityVector containing connectivity of element to create.
handleEntityHandle representing the newly created element in the database.

Example:

EntityType type = MBQUAD;
std::vector<EntityHandle> connectivity(4);
quad_conn[0] = vertex0;
quad_conn[1] = vertex1;
quad_conn[2] = vertex2;
quad_conn[3] = vertex3;
EntityHandle element_handle;
create_element( type, connectivity, element_handle );

Implements moab::Interface.

Examples
mbex1.cpp.

Definition at line 2699 of file Core.cpp.

2703 {
2704  // make sure we have enough vertices for this entity type
2705  if( num_nodes < CN::VerticesPerEntity( entity_type ) ) return MB_FAILURE;
2706 
2707  ErrorCode status = sequence_manager()->create_element( entity_type, connectivity, num_nodes, element_handle );
2708  if( MB_SUCCESS == status ) status = aEntityFactory->notify_create_entity( element_handle, connectivity, num_nodes );
2709 
2710 #ifdef MOAB_HAVE_AHF
2711  mesh_modified = true;
2712 #endif
2713 
2714  return status;
2715 }

References ErrorCode, MB_SUCCESS, and moab::CN::VerticesPerEntity().

Referenced by moab::AEntityFactory::get_down_adjacency_elements_poly(), moab::AEntityFactory::get_element(), main(), and obbvis_create().

◆ create_meshset()

ErrorCode moab::Core::create_meshset ( const unsigned int  options,
EntityHandle ms_handle,
int  start_id = 0 
)
virtual

creates a mesh set

Implements moab::Interface.

Examples
CoupleMGen.cpp.

Definition at line 3325 of file Core.cpp.

3326 {
3327  return sequence_manager()->create_mesh_set( setoptions, ms_handle );
3328 }

Referenced by moab::ReadUtil::create_gather_set(), moab::NestedRefine::create_hm_storage_single_level(), main(), process_partition_file(), and RuntimeContext::RuntimeContext().

◆ create_scd_sequence()

ErrorCode moab::Core::create_scd_sequence ( const HomCoord coord_min,
const HomCoord coord_max,
EntityType  type,
EntityID  start_id_hint,
EntityHandle first_handle_out,
EntitySequence *&  sequence_out 
)

create structured sequence

Definition at line 4310 of file Core.cpp.

4316 {
4317  // NR: Previously, the structured element sequences were created via direct call to
4318  // the sequence manager instead of using the same from the ScdInterface which
4319  // creates the associated scd bounding box after element sequence creation.
4320 
4321  if( !scdInterface ) scdInterface = new ScdInterface( this );
4322  ScdBox* newBox = NULL;
4323  MB_CHK_SET_ERR( scdInterface->create_scd_sequence( coord_min, coord_max, entity_type,
4324  /*starting_id*/ (int)start_id_hint, newBox ),
4325  "can't create scd sequence" );
4326 
4327  if( MBVERTEX == entity_type )
4328  first_handle_out = newBox->get_vertex( coord_min );
4329  else
4330  first_handle_out = newBox->get_element( coord_min );
4331  return sequence_manager()->find( first_handle_out, sequence_out );
4332 }

References moab::ScdBox::get_element(), moab::ScdBox::get_vertex(), MB_CHK_SET_ERR, and MBVERTEX.

◆ create_set_iterator()

ErrorCode moab::Core::create_set_iterator ( EntityHandle  meshset,
EntityType  ent_type,
int  ent_dim,
int  chunk_size,
bool  check_valid,
SetIterator *&  set_iter 
)
virtual

Create an iterator over the set Create a new iterator that iterates over entities with the specified type or dimension. Only one of ent_type or dim can be set; use dim=-1 or ent_type=MBMAXTYPE for the other. Iterators for list-type (ordered) sets are stable over set modification, unless entity removed or deleted is the one at the current position of the iterator. If the check_valid parameter is passed as true, entities are checked for validity before being passed back by get_next_entities function (checking entity validity can have a non-negligible cost).

Iterators returned by this function can be deleted using the normal C++ delete function. After creating the iterator through this function, further interactions are through methods on the SetIterator class.

Parameters
meshsetThe entity set associated with this iterator (use 0 for whole instance)
ent_typeEntity type associated with this iterator
ent_dimDimension associated with this iterator
chunk_sizeChunk size of the iterator
check_validIf true, entities are checked for validity before being returned
set_iterOutput parameter for the created set iterator

Implements moab::Interface.

Definition at line 3942 of file Core.cpp.

3948 {
3949  // check the type of set
3950  unsigned int setoptions;
3951  if( meshset )
3952  {
3953  MB_CHK_SET_ERR( get_meshset_options( meshset, setoptions ), "can't get meshset options" );
3954  }
3955 
3956  if( !meshset || ( setoptions & MESHSET_SET ) )
3957  set_iter = new( std::nothrow ) RangeSetIterator( this, meshset, chunk_size, ent_type, ent_dim, check_valid );
3958  else
3959  set_iter = new( std::nothrow ) VectorSetIterator( this, meshset, chunk_size, ent_type, ent_dim, check_valid );
3960 
3961  setIterators.push_back( set_iter );
3962  return MB_SUCCESS;
3963 }

References MB_CHK_SET_ERR, MB_SUCCESS, and MESHSET_SET.

◆ create_vertex()

ErrorCode moab::Core::create_vertex ( const double  coords[3],
EntityHandle entity_handle 
)
virtual

Creates a vertex based on coordinates.

creates a vertex based on coordinates, returns a handle and error code

Parameters
coordinatesArray that has 3 doubles in it.
entity_handleEntityHandle representing the newly created vertex in the database.

Example:

double *coordinates = double[3];
coordinates[0] = 1.034;
coordinates[1] = 23.23;
coordinates[2] = -0.432;
EntityHandle entity_handle = 0;
create_vertex( coordinates, entity_handle );

Implements moab::Interface.

Definition at line 2718 of file Core.cpp.

2719 {
2720  // get an available vertex handle
2721  return sequence_manager()->create_vertex( coords, entity_handle );
2722 }

Referenced by moab::HigherOrderFactory::add_mid_edge_nodes(), moab::HigherOrderFactory::add_mid_face_nodes(), and moab::HigherOrderFactory::add_mid_volume_nodes().

◆ create_vertices()

ErrorCode moab::Core::create_vertices ( const double *  coordinates,
const int  nverts,
Range entity_handles 
)
virtual

Create a set of vertices with the specified coordinates.

Parameters
coordinatesArray that has 3*n doubles in it.
nvertsNumber of vertices to create
entity_handlesRange passed back with new vertex handles

Implements moab::Interface.

Examples
mbex1.cpp.

Definition at line 2724 of file Core.cpp.

2725 {
2726  // Create vertices
2727  ReadUtilIface* read_iface;
2728  ErrorCode result = Interface::query_interface( read_iface );
2729  MB_CHK_ERR( result );
2730 
2731  std::vector< double* > arrays;
2732  EntityHandle start_handle_out = 0;
2733  result = read_iface->get_node_coords( 3, nverts, MB_START_ID, start_handle_out, arrays );
2734  Interface::release_interface( read_iface );
2735  MB_CHK_ERR( result );
2736  // Cppcheck warning (false positive): variable arrays is assigned a value that is never used
2737  for( int i = 0; i < nverts; i++ )
2738  {
2739  arrays[0][i] = coordinates[3 * i];
2740  arrays[1][i] = coordinates[3 * i + 1];
2741  arrays[2][i] = coordinates[3 * i + 2];
2742  }
2743 
2744  entity_handles.clear();
2745  entity_handles.insert( start_handle_out, start_handle_out + nverts - 1 );
2746 
2747  return MB_SUCCESS;
2748 }

References moab::Range::clear(), ErrorCode, moab::ReadUtilIface::get_node_coords(), moab::Range::insert(), MB_CHK_ERR, MB_START_ID, MB_SUCCESS, moab::Interface::query_interface(), and moab::Interface::release_interface().

Referenced by main(), obbvis_create(), and TestErrorHandling_4().

◆ deinitialize()

void moab::Core::deinitialize ( )
private

Definition at line 261 of file Core.cpp.

262 {
263 
264 #ifdef MOAB_HAVE_MPI
265  std::vector< ParallelComm* > pc_list;
266  ParallelComm::get_all_pcomm( this, pc_list );
267  for( std::vector< ParallelComm* >::iterator vit = pc_list.begin(); vit != pc_list.end(); ++vit )
268  delete *vit;
269 #endif
270 
271 #ifdef MOAB_HAVE_AHF
272  delete ahfRep;
273  ahfRep = 0;
274 #endif
275 
276  if( aEntityFactory ) delete aEntityFactory;
277 
278  aEntityFactory = 0;
279 
280  while( !tagList.empty() )
281  tag_delete( tagList.front() );
282 
283  if( sequenceManager ) delete sequenceManager;
284 
285  sequenceManager = 0;
286 
287  delete readerWriterSet;
288  readerWriterSet = 0;
289 
290  if( mError ) delete mError;
291  mError = 0;
292 
293 #ifdef MOAB_HAVE_MPI
294  if( writeMPELog )
295  {
296  const char* default_log = MOAB_MPE_LOG;
297  const char* logfile = getenv( "MPE_LOG_FILE" );
298  if( !logfile ) logfile = default_log;
299  MPE_Finish_log( logfile );
300  }
301 #endif
302 
304 }

References moab::ParallelComm::get_all_pcomm(), moab::MBErrorHandler_Finalize(), MOAB_MPE_LOG, and MPE_Finish_log.

◆ delete_entities() [1/2]

ErrorCode moab::Core::delete_entities ( const EntityHandle entities,
const int  num_entities 
)
virtual

Removes entities in a vector from the data base.

deletes an entity vector

If any of the entities are contained in any meshsets, it is removed from those meshsets which were created with MESHSET_TRACK_OWNER option bit set. Tags for entity< > are removed as part of this function.

Parameters
entities1d vector of entities to delete
num_entitiesNumber of entities in 1d vector

Implements moab::Interface.

Definition at line 2856 of file Core.cpp.

2857 {
2858  ErrorCode result = MB_SUCCESS, temp_result;
2859  Range failed_ents;
2860 
2861  for( std::list< TagInfo* >::iterator i = tagList.begin(); i != tagList.end(); ++i )
2862  {
2863  temp_result = ( *i )->remove_data( sequenceManager, mError, entities, num_entities );
2864  // ok if the error is tag_not_found, some ents may not have every tag on them
2865  if( MB_SUCCESS != temp_result && MB_TAG_NOT_FOUND != temp_result ) result = temp_result;
2866  }
2867 
2868  for( int i = 0; i < num_entities; i++ )
2869  {
2870 
2871  // tell AEntityFactory that this element is going away
2872  bool failed = false;
2873  temp_result = aEntityFactory->notify_delete_entity( entities[i] );
2874  if( MB_SUCCESS != temp_result )
2875  {
2876  result = temp_result;
2877  failed = true;
2878  }
2879 
2880  if( TYPE_FROM_HANDLE( entities[i] ) == MBENTITYSET )
2881  {
2882  if( MeshSet* ptr = get_mesh_set( sequence_manager(), entities[i] ) )
2883  {
2884  int j, count;
2885  const EntityHandle* rel;
2886  ptr->clear( entities[i], a_entity_factory() );
2887  rel = ptr->get_parents( count );
2888  for( j = 0; j < count; ++j )
2889  remove_child_meshset( rel[j], entities[i] );
2890  rel = ptr->get_children( count );
2891  for( j = 0; j < count; ++j )
2892  remove_parent_meshset( rel[j], entities[i] );
2893  }
2894  }
2895 
2896  if( failed )
2897  // don't test for success, since we'll return failure in this case
2898  sequence_manager()->delete_entity( mError, entities[i] );
2899  else
2900  {
2901  // now delete the entity
2902  temp_result = sequence_manager()->delete_entity( mError, entities[i] );
2903  if( MB_SUCCESS != temp_result ) result = temp_result;
2904  }
2905  }
2906 
2907  return result;
2908 }

References moab::Range::clear(), ErrorCode, moab::get_mesh_set(), MB_SUCCESS, MB_TAG_NOT_FOUND, MBENTITYSET, and moab::TYPE_FROM_HANDLE().

Referenced by moab::HigherOrderFactory::convert_sequence(), and main().

◆ delete_entities() [2/2]

ErrorCode moab::Core::delete_entities ( const Range range)
virtual

Removes entities in a range from the data base.

deletes an entity range

If any of the entities are contained in any meshsets, it is removed from those meshsets which were created with MESHSET_TRACK_OWNER option bit set. Tags for entity< > are removed as part of this function.

Parameters
entitiesRange of entities to delete

Implements moab::Interface.

Definition at line 2801 of file Core.cpp.

2802 {
2803  ErrorCode result = MB_SUCCESS, temp_result;
2804  Range failed_ents;
2805 
2806  for( std::list< TagInfo* >::iterator i = tagList.begin(); i != tagList.end(); ++i )
2807  {
2808  temp_result = ( *i )->remove_data( sequenceManager, mError, range );
2809  // ok if the error is tag_not_found, some ents may not have every tag on them
2810  if( MB_SUCCESS != temp_result && MB_TAG_NOT_FOUND != temp_result ) result = temp_result;
2811  }
2812 
2813  for( Range::const_reverse_iterator rit = range.rbegin(); rit != range.rend(); ++rit )
2814  {
2815 
2816  // tell AEntityFactory that this element is going away
2817  temp_result = aEntityFactory->notify_delete_entity( *rit );
2818  if( MB_SUCCESS != temp_result )
2819  {
2820  result = temp_result;
2821  failed_ents.insert( *rit );
2822  continue;
2823  }
2824 
2825  if( TYPE_FROM_HANDLE( *rit ) == MBENTITYSET )
2826  {
2827  if( MeshSet* ptr = get_mesh_set( sequence_manager(), *rit ) )
2828  {
2829  int j, count;
2830  const EntityHandle* rel;
2831  ptr->clear( *rit, a_entity_factory() );
2832  rel = ptr->get_parents( count );
2833  for( j = 0; j < count; ++j )
2834  remove_child_meshset( rel[j], *rit );
2835  rel = ptr->get_children( count );
2836  for( j = 0; j < count; ++j )
2837  remove_parent_meshset( rel[j], *rit );
2838  }
2839  }
2840  }
2841 
2842  if( !failed_ents.empty() )
2843  {
2844  Range dum_range = subtract( range, failed_ents );
2845  // don't test for success, since we'll return failure in this case
2846  sequence_manager()->delete_entities( mError, dum_range );
2847  }
2848  else
2849  // now delete the entities
2850  result = sequence_manager()->delete_entities( mError, range );
2851 
2852  return result;
2853 }

References moab::Range::empty(), ErrorCode, moab::get_mesh_set(), moab::Range::insert(), MB_SUCCESS, MB_TAG_NOT_FOUND, MBENTITYSET, moab::Range::rbegin(), moab::Range::rend(), moab::subtract(), and moab::TYPE_FROM_HANDLE().

◆ delete_mesh()

ErrorCode moab::Core::delete_mesh ( )
virtual

deletes all mesh entities from this datastore

Implements moab::Interface.

Definition at line 747 of file Core.cpp.

748 {
749 
750  ErrorCode result = MB_SUCCESS;
751 
752  // perform all deinitialization procedures to clean up
753  if( aEntityFactory ) delete aEntityFactory;
754  aEntityFactory = new AEntityFactory( this );
755 
756  for( std::list< TagInfo* >::iterator i = tagList.begin(); i != tagList.end(); ++i )
757  {
758  result = ( *i )->release_all_data( sequenceManager, mError, false );
759  MB_CHK_ERR( result );
760  }
761 
763 
764  return MB_SUCCESS;
765 }

References ErrorCode, MB_CHK_ERR, and MB_SUCCESS.

Referenced by main().

◆ dimension_from_handle()

int moab::Core::dimension_from_handle ( const  handle) const
virtual

Returns the topological dimension of an entity.

Returns the topological dimension of an entity.

Parameters
handleThe EntityHandle you want to find the dimension of.
Returns
type The topological dimension of handle.

Example:

int dim = dimension_from_handle( handle);
if( dim == 0 ) ...

Implements moab::Interface.

Definition at line 400 of file Core.cpp.

401 {
402  if( !handle ) // root set
403  return 4;
404  else
405  return CN::Dimension( TYPE_FROM_HANDLE( handle ) );
406 }

References moab::CN::Dimension(), and moab::TYPE_FROM_HANDLE().

Referenced by moab::AEntityFactory::check_equiv_entities(), moab::AEntityFactory::create_explicit_adjs(), moab::HalfFacetRep::get_adjacencies(), moab::HalfFacetRep::get_down_adjacencies(), moab::AEntityFactory::get_element(), moab::HalfFacetRep::get_neighbor_adjacencies(), moab::HalfFacetRep::get_up_adjacencies(), and moab::HigherOrderFactory::tag_for_deletion().

◆ dirichletBC_tag()

Tag moab::Core::dirichletBC_tag ( )

Definition at line 2672 of file Core.cpp.

2673 {
2674  const int negone = -1;
2675  if( 0 == dirichletBCTag )
2677  &negone );
2678  return dirichletBCTag;
2679 }

References DIRICHLET_SET_TAG_NAME, MB_TAG_CREAT, MB_TAG_SPARSE, and MB_TYPE_INTEGER.

◆ estimated_memory_use() [1/2]

void moab::Core::estimated_memory_use ( const EntityHandle ent_array = 0,
unsigned long  num_ents = 0,
unsigned long long *  total_storage = 0,
unsigned long long *  total_amortized_storage = 0,
unsigned long long *  entity_storage = 0,
unsigned long long *  amortized_entity_storage = 0,
unsigned long long *  adjacency_storage = 0,
unsigned long long *  amortized_adjacency_storage = 0,
const Tag tag_array = 0,
unsigned  num_tags = 0,
unsigned long long *  tag_storage = 0,
unsigned long long *  amortized_tag_storage = 0 
)
virtual

Calculate amount of memory used to store MOAB data.

This function calculates the amount of memory used to store MOAB data.

There are two possible values for each catagory of memory use. The exact value and the amortized value. The exact value is the amount of memory used to store the data for the specified entities. The amortized value includes the exact value and an amortized estimate of the memory consumed in overhead for storing the values (indexing structures, access structures, etc.)

Note: If ent_array is NULL, the total memory used by MOAB for storing data will be returned in the address pointed to by total_amortized_storage, if total_amortized_storage is not NULL.

Parameters
ent_arrayArray of entities for which to estimate the memory use. If NULL, estimate is done for all entities.
num_entsThe length of ent_array. Not used if ent_rray is NULL.
total_(amortized_)storageThe sum of the memory entity, adjacency, and all tag storage.
(amortized_)entity_storageThe storage for the entity definitions (connectivity arrays for elements, coordinates for vertices, list storage within sets, etc.)
(amortized_)adjacency_storageThe storage for adjacency data.
tag_arrayAn array of tags for which to calculate the memory use.
num_tagsThe lenght of tag_array
(amortized_)tag_storageIf tag_array is not NULL, then one value for each tag specifying the memory used for storing that tag. If tag_array is NULL and this value is not, the location at which to store the total memory used for all tags.

Implements moab::Interface.

Definition at line 4145 of file Core.cpp.

4157 {
4158  Range range;
4159 
4160  // If non-empty entity list, call range version of function
4161  if( ent_array )
4162  {
4163  if( num_ents > 20 )
4164  {
4165  std::vector< EntityHandle > list( num_ents );
4166  std::copy( ent_array, ent_array + num_ents, list.begin() );
4167  std::sort( list.begin(), list.end() );
4168  Range::iterator j = range.begin();
4169  for( std::vector< EntityHandle >::reverse_iterator i = list.rbegin(); i != list.rend(); ++i )
4170  j = range.insert( j, *i, *i );
4171  }
4172  else
4173  {
4174  std::copy( ent_array, ent_array + num_ents, range_inserter( range ) );
4175  }
4176  }
4177 
4178  estimated_memory_use_internal( ent_array ? &range : 0, total_storage, total_amortized_storage, entity_storage,
4179  amortized_entity_storage, adjacency_storage, amortized_adjacency_storage, tag_array,
4180  num_tags, tag_storage, amortized_tag_storage );
4181 }

References moab::Range::begin(), and moab::Range::insert().

◆ estimated_memory_use() [2/2]

void moab::Core::estimated_memory_use ( const Range ents,
unsigned long long *  total_storage = 0,
unsigned long long *  total_amortized_storage = 0,
unsigned long long *  entity_storage = 0,
unsigned long long *  amortized_entity_storage = 0,
unsigned long long *  adjacency_storage = 0,
unsigned long long *  amortized_adjacency_storage = 0,
const Tag tag_array = 0,
unsigned  num_tags = 0,
unsigned long long *  tag_storage = 0,
unsigned long long *  amortized_tag_storage = 0 
)
virtual

Calculate amount of memory used to store MOAB data.

This function calculates the amount of memory used to store MOAB data.

There are two possible values for each catagory of memory use. The exact value and the amortized value. The exact value is the amount of memory used to store the data for the specified entities. The amortized value includes the exact value and an amortized estimate of the memory consumed in overhead for storing the values (indexing structures, access structures, etc.)

Parameters
entsEntities for which to estimate the memory use.
total_(amortized_)storageThe sum of the memory entity, adjacency, and all tag storage.
(amortized_)entity_storageThe storage for the entity definitions (connectivity arrays for elements, coordinates for vertices, list storage within sets, etc.)
(amortized_)adjacency_storageThe storage for adjacency data.
tag_arrayAn array of tags for which to calculate the memory use.
num_tagsThe lenght of tag_array
(amortized_)tag_storageIf tag_array is not NULL, then one value for each tag specifying the memory used for storing that tag. If tag_array is NULL and this value is not, the location at which to store the total memory used for all tags.

Implements moab::Interface.

Definition at line 4183 of file Core.cpp.

4194 {
4195  estimated_memory_use_internal( &ents, total_storage, total_amortized_storage, entity_storage,
4196  amortized_entity_storage, adjacency_storage, amortized_adjacency_storage, tag_array,
4197  num_tags, tag_storage, amortized_tag_storage );
4198 }

◆ estimated_memory_use_internal()

void moab::Core::estimated_memory_use_internal ( const Range ents,
unsigned long long *  total_storage,
unsigned long long *  total_amortized_storage,
unsigned long long *  entity_storage,
unsigned long long *  amortized_entity_storage,
unsigned long long *  adjacency_storage,
unsigned long long *  amortized_adjacency_storage,
const Tag tag_array,
unsigned  num_tags,
unsigned long long *  tag_storage,
unsigned long long *  amortized_tag_storage 
)
private

Definition at line 3994 of file Core.cpp.

4005 {
4006  // Figure out which values we need to calculate
4007  type_memstorage i_entity_storage, ia_entity_storage, i_adjacency_storage, ia_adjacency_storage, i_tag_storage,
4008  ia_tag_storage;
4009  type_memstorage *total_tag_storage = 0, *amortized_total_tag_storage = 0;
4010  if( !tag_array )
4011  {
4012  total_tag_storage = tag_storage;
4013  amortized_total_tag_storage = amortized_tag_storage;
4014  }
4015  if( total_storage || total_amortized_storage )
4016  {
4017  if( !entity_storage ) entity_storage = &i_entity_storage;
4018  if( !amortized_entity_storage ) amortized_entity_storage = &ia_entity_storage;
4019  if( !adjacency_storage ) adjacency_storage = &i_adjacency_storage;
4020  if( !amortized_adjacency_storage ) amortized_adjacency_storage = &ia_adjacency_storage;
4021  }
4022  else
4023  {
4024  if( entity_storage || amortized_entity_storage )
4025  {
4026  if( !amortized_entity_storage )
4027  amortized_entity_storage = &ia_entity_storage;
4028  else if( !entity_storage )
4029  entity_storage = &i_entity_storage;
4030  }
4031  if( adjacency_storage || amortized_adjacency_storage )
4032  {
4033  if( !amortized_adjacency_storage )
4034  amortized_adjacency_storage = &ia_adjacency_storage;
4035  else if( !adjacency_storage )
4036  adjacency_storage = &i_adjacency_storage;
4037  }
4038  }
4039  if( !total_tag_storage && total_storage ) total_tag_storage = &i_tag_storage;
4040  if( !amortized_total_tag_storage && total_amortized_storage ) amortized_total_tag_storage = &ia_tag_storage;
4041 
4042  // get entity storage
4043  if( amortized_entity_storage )
4044  {
4045  if( ents )
4046  sequenceManager->get_memory_use( *ents, *entity_storage, *amortized_entity_storage );
4047  else
4048  sequenceManager->get_memory_use( *entity_storage, *amortized_entity_storage );
4049  }
4050 
4051  // get adjacency storage
4052  if( amortized_adjacency_storage )
4053  {
4054  if( ents )
4055  aEntityFactory->get_memory_use( *ents, *adjacency_storage, *amortized_adjacency_storage );
4056  else
4057 #ifdef MOAB_HAVE_AHF
4058  ahfRep->get_memory_use( *adjacency_storage, *amortized_adjacency_storage );
4059 #else
4060  aEntityFactory->get_memory_use( *adjacency_storage, *amortized_adjacency_storage );
4061 #endif
4062  }
4063 
4064  // get storage for requested list of tags
4065  if( tag_array )
4066  {
4067  for( unsigned i = 0; i < num_tags; ++i )
4068  {
4069  if( !valid_tag_handle( tag_array[i] ) ) continue;
4070 
4071  unsigned long total = 0, per_ent = 0;
4072  tag_array[i]->get_memory_use( sequenceManager, total, per_ent );
4073 
4074  if( ents )
4075  {
4076  size_t count = 0, count2 = 0;
4077  tag_array[i]->num_tagged_entities( sequenceManager, count, MBMAXTYPE, ents );
4078  if( tag_storage ) tag_storage[i] = count * per_ent;
4079  if( amortized_tag_storage )
4080  {
4081  tag_array[i]->num_tagged_entities( sequenceManager, count2 );
4082  if( count2 )
4083  amortized_tag_storage[i] = static_cast< type_memstorage >( total * count * 1.0 / count2 );
4084  }
4085  }
4086  else
4087  {
4088  size_t count = 0;
4089  if( tag_storage )
4090  {
4091  tag_array[i]->num_tagged_entities( sequenceManager, count );
4092  tag_storage[i] = count * per_ent;
4093  }
4094  if( amortized_tag_storage ) amortized_tag_storage[i] = total;
4095  }
4096  }
4097  }
4098 
4099  // get storage for all tags
4100  if( total_tag_storage || amortized_total_tag_storage )
4101  {
4102  if( amortized_total_tag_storage ) *amortized_total_tag_storage = 0;
4103  if( total_tag_storage ) *total_tag_storage = 0;
4104 
4105  std::vector< Tag > tags;
4106  tag_get_tags( tags );
4107  for( std::list< TagInfo* >::const_iterator i = tagList.begin(); i != tagList.end(); ++i )
4108  {
4109  unsigned long total = 0, per_ent = 0;
4110  ( *i )->get_memory_use( sequenceManager, total, per_ent );
4111 
4112  if( ents )
4113  {
4114  size_t count = 0, count2 = 0;
4115  ( *i )->num_tagged_entities( sequenceManager, count, MBMAXTYPE, ents );
4116  if( total_tag_storage ) *total_tag_storage += count * per_ent;
4117  if( amortized_total_tag_storage )
4118  {
4119  ( *i )->num_tagged_entities( sequenceManager, count2 );
4120  if( count2 )
4121  *amortized_total_tag_storage += static_cast< type_memstorage >( total * count * 1.0 / count2 );
4122  }
4123  }
4124  else
4125  {
4126  size_t count = 0;
4127  if( total_tag_storage )
4128  {
4129  ( *i )->num_tagged_entities( sequenceManager, count );
4130  *total_tag_storage += count * per_ent;
4131  }
4132  if( amortized_total_tag_storage ) *amortized_total_tag_storage += total;
4133  }
4134  }
4135  }
4136 
4137  // calculate totals
4138  if( total_storage ) *total_storage = *entity_storage + *adjacency_storage + *total_tag_storage;
4139 
4140  if( total_amortized_storage )
4141  *total_amortized_storage =
4142  *amortized_entity_storage + *amortized_adjacency_storage + *amortized_total_tag_storage;
4143 }

References moab::TagInfo::get_memory_use(), MBMAXTYPE, and moab::TagInfo::num_tagged_entities().

◆ geom_dimension_tag()

Tag moab::Core::geom_dimension_tag ( )

Definition at line 2689 of file Core.cpp.

2690 {
2691  const int negone = -1;
2692  if( 0 == geomDimensionTag )
2694  &negone );
2695  return geomDimensionTag;
2696 }

References GEOM_DIMENSION_TAG_NAME, MB_TAG_CREAT, MB_TAG_SPARSE, and MB_TYPE_INTEGER.

◆ get_adjacencies() [1/3]

ErrorCode moab::Core::get_adjacencies ( const EntityHandle from_entities,
const int  num_entities,
const int  to_dimension,
const bool  create_if_missing,
Range adj_entities,
const int  operation_type = Interface::INTERSECT 
)
virtual

Get the adjacencies associated with a vector of entities to entities of a specfied dimension.

Identical to vector-based get_adjacencies function, except results are returned in a range instead of a vector.

Implements moab::Interface.

Definition at line 1623 of file Core.cpp.

1629 {
1630  if( operation_type == Interface::INTERSECT )
1631  return get_adjacencies_intersection( this, from_entities, from_entities + num_entities, to_dimension,
1632  create_if_missing, adj_entities );
1633  else if( operation_type == Interface::UNION )
1634  return get_adjacencies_union( this, from_entities, from_entities + num_entities, to_dimension,
1635  create_if_missing, adj_entities );
1636  else
1637  return MB_FAILURE;
1638 }

References moab::get_adjacencies_intersection(), moab::get_adjacencies_union(), moab::Interface::INTERSECT, and moab::Interface::UNION.

◆ get_adjacencies() [2/3]

ErrorCode moab::Core::get_adjacencies ( const EntityHandle from_entities,
const int  num_entities,
const int  to_dimension,
const bool  create_if_missing,
std::vector< EntityHandle > &  adj_entities,
const int  operation_type = Interface::INTERSECT 
)
virtual

get the adjacencies associated with a set of entities

Parameters
from_entitiesvector of EntityHandle to get adjacencies of.
to_dimensionDimension of desired adjacency information.
adj_entitiesVector in which adjacent EntityHandles are returned.
operation_typeenum of INTERSECT or UNION. Defines whether to take the intersection or union of the set of adjacencies recovered for the from_entities.

The adjacent entities in vector adjacencies are not in any particular order.

Example:

// get the set of edges that are adjacent to all entities in the from_entities list
std::vector<EntityHandle> from_entities = {hex1, hex2};
std::vector<EntityHandle> adjacencies;
get_adjacencies( from_entities, MB_1D_ENTITY, adjacencies );

Implements moab::Interface.

Examples
CoupleMGen.cpp.

Definition at line 1526 of file Core.cpp.

1532 {
1533 
1534 #ifdef MOAB_HAVE_AHF
1535  bool can_handle = true;
1536 
1537  if( to_dimension == 4 )
1538  can_handle = false; // NOT SUPPORTED: meshsets
1539  else if( create_if_missing )
1540  can_handle = false; // NOT SUPPORTED: create_if_missing
1541 
1542  bool mixed = ahfRep->check_mixed_entity_type(); // NOT SUPPORTED: mixed entity types or
1543  // polygonal/hedrals types
1544  if( mixed ) can_handle = false;
1545 
1546  if( mesh_modified ) // NOT SUPPORTED: modified mesh
1547  can_handle = false;
1548 
1549  if( can_handle )
1550  {
1551  ErrorCode result;
1552  if( operation_type == Interface::INTERSECT )
1553  return get_adjacencies_intersection_ahf( this, from_entities, from_entities + num_entities, to_dimension,
1554  adj_entities );
1555  else if( operation_type != Interface::UNION )
1556  return MB_FAILURE;
1557 
1558  // do union
1559 
1560  std::vector< EntityHandle > tmp_storage;
1561  const EntityHandle* conn;
1562  int len;
1563  for( int i = 0; i < num_entities; ++i )
1564  {
1565  if( to_dimension == 0 && TYPE_FROM_HANDLE( from_entities[0] ) != MBPOLYHEDRON )
1566  {
1567  result = get_connectivity( from_entities[i], conn, len, false, &tmp_storage );
1568  adj_entities.insert( adj_entities.end(), conn, conn + len );
1569  if( MB_SUCCESS != result ) return result;
1570  }
1571  else
1572  {
1573  result = ahfRep->get_adjacencies( from_entities[i], to_dimension, adj_entities );
1574  if( MB_SUCCESS != result ) return result;
1575  }
1576  }
1577  std::sort( adj_entities.begin(), adj_entities.end() );
1578  adj_entities.erase( std::unique( adj_entities.begin(), adj_entities.end() ), adj_entities.end() );
1579  }
1580  else
1581  {
1582 
1583 #endif
1584 
1585  if( operation_type == Interface::INTERSECT )
1586  return get_adjacencies_intersection( this, from_entities, from_entities + num_entities, to_dimension,
1587  create_if_missing, adj_entities );
1588  else if( operation_type != Interface::UNION )
1589  return MB_FAILURE;
1590 
1591  // do union
1592  ErrorCode result;
1593  std::vector< EntityHandle > tmp_storage;
1594  const EntityHandle* conn;
1595  int len;
1596  for( int i = 0; i < num_entities; ++i )
1597  {
1598  if( to_dimension == 0 && TYPE_FROM_HANDLE( from_entities[0] ) != MBPOLYHEDRON )
1599  {
1600  result = get_connectivity( from_entities[i], conn, len, false, &tmp_storage );
1601  MB_CHK_ERR( result );
1602  adj_entities.insert( adj_entities.end(), conn, conn + len );
1603  }
1604  else
1605  {
1606  result =
1607  aEntityFactory->get_adjacencies( from_entities[i], to_dimension, create_if_missing, adj_entities );
1608  MB_CHK_ERR( result );
1609  }
1610  }
1611  std::sort( adj_entities.begin(), adj_entities.end() );
1612  adj_entities.erase( std::unique( adj_entities.begin(), adj_entities.end() ), adj_entities.end() );
1613 
1614  // return MB_SUCCESS;
1615 
1616 #ifdef MOAB_HAVE_AHF
1617  }
1618 #endif
1619 
1620  return MB_SUCCESS;
1621 }

References ErrorCode, moab::get_adjacencies_intersection(), moab::Interface::INTERSECT, MB_CHK_ERR, MB_SUCCESS, MBPOLYHEDRON, moab::TYPE_FROM_HANDLE(), and moab::Interface::UNION.

Referenced by moab::DualTool::check_dual_equiv_edges(), moab::AEntityFactory::check_equiv_entities(), moab::AEntityFactory::create_explicit_adjs(), moab::NestedRefine::exchange_ghosts(), moab::ReadUtil::gather_related_ents(), gather_set_stats(), get_adjacent_elems(), moab::AEntityFactory::get_down_adjacency_elements_poly(), moab::AEntityFactory::get_polyhedron_vertices(), moab::AEntityFactory::get_up_adjacency_elements(), moab::AEntityFactory::get_vertices(), hcFilter(), moab::ReorderTool::int_order_from_sets_and_adj(), laplacianFilter(), main(), moab::AEntityFactory::merge_adjust_adjacencies(), moab::numAdjTriInSet(), perform_lloyd_relaxation(), tag_depth(), and moab::HiReconstruction::vertex_get_incident_elements().

◆ get_adjacencies() [3/3]

ErrorCode moab::Core::get_adjacencies ( const Range from_entities,
const int  to_dimension,
const bool  create_if_missing,
Range adj_entities,
const int  operation_type = Interface::INTERSECT 
)
virtual

Get the adjacencies associated with a range of entities to entities of a specfied dimension.

Identical to vector-based get_adjacencies function, except "from" entities specified in a range instead of a vector.

Implements moab::Interface.

Definition at line 1759 of file Core.cpp.

1764 {
1765  if( operation_type == Interface::INTERSECT )
1766  return get_adjacencies_intersection( this, from_entities.begin(), from_entities.end(), to_dimension,
1767  create_if_missing, adj_entities );
1768  else if( operation_type != Interface::UNION )
1769  return MB_FAILURE;
1770  else if( to_dimension == 0 )
1771  return get_vertices( from_entities, adj_entities );
1772  else
1773  return get_adjacencies_union( this, from_entities.begin(), from_entities.end(), to_dimension, create_if_missing,
1774  adj_entities );
1775 }

References moab::Range::begin(), moab::Range::end(), moab::get_adjacencies_intersection(), moab::get_adjacencies_union(), moab::Interface::INTERSECT, and moab::Interface::UNION.

◆ get_child_meshsets() [1/2]

ErrorCode moab::Core::get_child_meshsets ( const EntityHandle  meshset,
Range children,
const int  num_hops = 1 
) const
virtual

get child meshsets

Implements moab::Interface.

Definition at line 3515 of file Core.cpp.

3516 {
3517  if( 0 == meshset ) return MB_ENTITY_NOT_FOUND;
3518 
3519  std::vector< EntityHandle > child_vec;
3520  ErrorCode result = get_child_meshsets( meshset, child_vec, num_hops );
3521  MB_CHK_ERR( result );
3522  std::sort( child_vec.begin(), child_vec.end() );
3523  std::copy( child_vec.rbegin(), child_vec.rend(), range_inserter( children ) );
3524  return MB_SUCCESS;
3525 }

References ErrorCode, MB_CHK_ERR, MB_ENTITY_NOT_FOUND, and MB_SUCCESS.

◆ get_child_meshsets() [2/2]

ErrorCode moab::Core::get_child_meshsets ( const EntityHandle  meshset,
std::vector< EntityHandle > &  children,
const int  num_hops = 1 
) const
virtual

get child meshsets

Implements moab::Interface.

Definition at line 3501 of file Core.cpp.

3504 {
3505  if( 0 == meshset ) return MB_ENTITY_NOT_FOUND;
3506 
3507  const EntitySequence* seq;
3508  ErrorCode rval = sequence_manager()->find( meshset, seq );
3509  if( MB_SUCCESS != rval ) return MB_ENTITY_NOT_FOUND;
3510  const MeshSetSequence* mseq = reinterpret_cast< const MeshSetSequence* >( seq );
3511 
3512  return mseq->get_children( sequence_manager(), meshset, children, num_hops );
3513 }

References ErrorCode, moab::MeshSetSequence::get_children(), MB_ENTITY_NOT_FOUND, and MB_SUCCESS.

Referenced by moab::ReadUtil::gather_related_ents().

◆ get_connectivity() [1/4]

ErrorCode moab::Core::get_connectivity ( const EntityHandle entity_handles,
const int  num_handles,
Range connectivity,
bool  corners_only = false 
) const
virtual

Gets the connectivity for a vector of elements.

get the connectivity for element /handles. For non-element handles, return an error

Same as vector-based version except range is returned (unordered!)

Implements moab::Interface.

Definition at line 1149 of file Core.cpp.

1153 {
1154  std::vector< EntityHandle > tmp_connect;
1155  ErrorCode result = get_connectivity( entity_handles, num_handles, tmp_connect, corners_only );
1156  MB_CHK_ERR( result );
1157 
1158  std::sort( tmp_connect.begin(), tmp_connect.end() );
1159  std::copy( tmp_connect.rbegin(), tmp_connect.rend(), range_inserter( connectivity ) );
1160  return result;
1161 }

References ErrorCode, and MB_CHK_ERR.

◆ get_connectivity() [2/4]

ErrorCode moab::Core::get_connectivity ( const EntityHandle entity_handles,
const int  num_handles,
std::vector< EntityHandle > &  connectivity,
bool  corners_only = false,
std::vector< int > *  offsets = NULL 
) const
virtual

Gets the connectivity for an element EntityHandle.

get the connectivity for element /handles. For non-element handles, return an error

For non-element handles (ie, MeshSets), returns an error. Connectivity data is copied from the database into the vector connectivity. The nodes in connectivity are properly ordered.

Parameters
entity_handleEntityHandle to get connectivity of.
connectivityVector in which connectivity of entity_handle is returned. Should contain MeshVertices.
corners_onlyIf true, returns only corner vertices, otherwise returns all of them (including any higher-order vertices)

Example:

std::vector<EntityHandle> conn;
get_connectivity( entity_handle, conn );

Implements moab::Interface.

Examples
CoupleMGen.cpp.

Definition at line 1164 of file Core.cpp.

1169 {
1170  connectivity.clear(); // this seems wrong as compared to other API functions,
1171  // but changing it breaks lost of code, so I'm leaving
1172  // it in. - j.kraftcheck 2009-11-06
1173 
1174  std::vector< EntityHandle > tmp_storage; // used only for structured mesh
1175  const EntityHandle* conn;
1176  int len;
1177  if( offsets ) offsets->push_back( 0 );
1178  for( int i = 0; i < num_handles; ++i )
1179  {
1180  MB_CHK_SET_ERR( get_connectivity( entity_handles[i], conn, len, corners_only, &tmp_storage ),
1181  "can't get connectivity" );
1182  connectivity.insert( connectivity.end(), conn, conn + len );
1183  if( offsets ) offsets->push_back( connectivity.size() );
1184  }
1185  return MB_SUCCESS;
1186 }

References MB_CHK_SET_ERR, and MB_SUCCESS.

Referenced by moab::HalfFacetRep::add_cells_of_single_component(), moab::HalfFacetRep::another_halfedge(), moab::HiReconstruction::average_vertex_normal(), moab::HiReconstruction::average_vertex_tangent(), moab::HigherOrderFactory::center_node_exist(), moab::HalfFacetRep::collect_and_compare(), moab::HalfFacetRep::determine_border_vertices(), moab::HalfFacetRep::determine_incident_halfedges(), moab::HalfFacetRep::determine_incident_halffaces(), moab::HalfFacetRep::determine_incident_halfverts(), moab::HalfFacetRep::determine_sibling_halfedges(), moab::HalfFacetRep::determine_sibling_halffaces(), moab::HalfFacetRep::determine_sibling_halfverts(), moab::AEntityFactory::entities_equivalent(), moab::NestedRefine::exchange_ghosts(), moab::HalfFacetRep::find_matching_halfedge(), moab::HalfFacetRep::find_matching_halfface(), moab::HalfFacetRep::find_matching_implicit_edge_in_cell(), moab::WriteUtil::gather_nodes_from_elements(), gather_set_stats(), moab::AEntityFactory::get_adjacencies(), moab::NestedRefine::get_connectivity(), moab::HalfFacetRep::get_down_adjacencies_2d(), moab::HalfFacetRep::get_down_adjacencies_edg_3d(), moab::HalfFacetRep::get_down_adjacencies_face_3d(), moab::AEntityFactory::get_down_adjacency_elements(), moab::AEntityFactory::get_down_adjacency_elements_poly(), moab::HalfFacetRep::get_face_edges(), moab::HalfFacetRep::get_half_facet_in_comp(), moab::ReadUtil::get_ordered_vertices(), moab::AEntityFactory::get_polyhedron_vertices(), moab::HalfFacetRep::get_up_adjacencies_2d(), moab::HalfFacetRep::get_up_adjacencies_edg_3d(), moab::HalfFacetRep::get_up_adjacencies_edg_3d_comp(), moab::HalfFacetRep::get_up_adjacencies_vert_3d(), moab::AEntityFactory::get_up_adjacency_elements(), moab::AEntityFactory::get_vertices(), hcFilter(), moab::HiReconstruction::hiproj_walf_in_element(), laplacianFilter(), main(), moab::HalfFacetRep::mark_halfedges(), moab::AEntityFactory::merge_adjust_adjacencies(), moab::HiReconstruction::obtain_nring_ngbvs(), perform_laplacian_smoothing(), perform_lloyd_relaxation(), moab::ReorderTool::reorder_entities(), moab::HigherOrderFactory::tag_for_deletion(), test_spectral_quad(), moab::NestedRefine::update_global_ahf_3D(), and moab::NestedRefine::update_special_tags().

◆ get_connectivity() [3/4]

ErrorCode moab::Core::get_connectivity ( const EntityHandle  entity_handle,
const EntityHandle *&  connectivity,
int &  number_nodes,
bool  corners_only = false,
std::vector< EntityHandle > *  storage = 0 
) const
virtual

Gets a pointer to constant connectivity data of entity_handle

get the connectivity for element handles. For non-element handles, return an error

Sets number_nodes equal to the number of nodes of the entity_handle . Faster then the other get_connectivity function. The nodes in 'connectivity' are properly ordered.

Parameters
entity_handleEntityHandle to get connectivity of.
connectivityArray in which connectivity of entity_handle is returned. Should contain MBVERTEX's.
num_nodesNumber of MeshVertices in array connectivity.

Example:

const EntityHandle* conn;
int number_nodes = 0;
get_connectivity( entity_handle, conn, number_nodes );

Example2:

std::vector<EntityHandle> sm_storage;
const EntityHandle* conn;
int number_nodes;
get_connectivity( handle, conn, number_nodes, false, &sm_storage );
if (conn == &sm_storage[0])
std::cout << "Structured mesh element" << std::endl;

Implements moab::Interface.

Definition at line 1189 of file Core.cpp.

1194 {
1195  ErrorCode status;
1196 
1197  // Make sure the entity should have a connectivity.
1198  EntityType entity_type = TYPE_FROM_HANDLE( entity_handle );
1199 
1200  // WARNING: This is very dependent on the ordering of the EntityType enum
1201  if( entity_type < MBVERTEX || entity_type >= MBENTITYSET )
1202  return MB_TYPE_OUT_OF_RANGE;
1203 
1204  else if( entity_type == MBVERTEX )
1205  {
1206  return MB_FAILURE;
1207  }
1208 
1209  const EntitySequence* seq = 0;
1210 
1211  // We know that connectivity is stored in an EntitySequence so jump straight
1212  // to the entity sequence
1213  status = sequence_manager()->find( entity_handle, seq );
1214  if( seq == 0 || status != MB_SUCCESS ) return MB_ENTITY_NOT_FOUND;
1215 
1216  return static_cast< const ElementSequence* >( seq )->get_connectivity( entity_handle, connectivity, number_nodes,
1217  corners_only, storage );
1218 }

References ErrorCode, MB_ENTITY_NOT_FOUND, MB_SUCCESS, MB_TYPE_OUT_OF_RANGE, MBENTITYSET, MBVERTEX, and moab::TYPE_FROM_HANDLE().

◆ get_connectivity() [4/4]

ErrorCode moab::Core::get_connectivity ( const Range from_entities,
Range adj_entities,
bool  corners_only = false 
) const
virtual

Gets the connectivity for elements.

Same as vector-based version except range is returned (unordered!)

Implements moab::Interface.

Definition at line 1640 of file Core.cpp.

1641 {
1642  const size_t DEFAULT_MAX_BLOCKS_SIZE = 4000;
1643  const size_t MAX_OUTER_ITERATIONS = 100;
1644 
1645  std::vector< EntityHandle > temp_vec, storage;
1646  std::vector< EntityHandle >::const_iterator ti;
1647  ErrorCode result = MB_SUCCESS, tmp_result;
1648  Range::const_iterator i = from_entities.begin();
1649  Range::iterator ins;
1650  const EntityHandle* conn;
1651  int conn_len;
1652 
1653  // Just copy any vertices from the input range into the output
1654  size_t remaining = from_entities.size();
1655  for( ; i != from_entities.end() && TYPE_FROM_HANDLE( *i ) == MBVERTEX; ++i )
1656  --remaining;
1657  adj_entities.merge( from_entities.begin(), i );
1658 
1659  // How many entities to work with at once? 2000 or so shouldn't require
1660  // too much memory, but don't iterate in outer loop more than a
1661  // 1000 times (make it bigger if many input entiites.)
1662  const size_t block_size = std::max( DEFAULT_MAX_BLOCKS_SIZE, remaining / MAX_OUTER_ITERATIONS );
1663  while( remaining > 0 )
1664  {
1665  const size_t count = remaining > block_size ? block_size : remaining;
1666  remaining -= count;
1667  temp_vec.clear();
1668  for( size_t j = 0; j < count; ++i, ++j )
1669  {
1670  tmp_result = get_connectivity( *i, conn, conn_len, corners_only, &storage );
1671  if( MB_SUCCESS != tmp_result )
1672  {
1673  result = tmp_result;
1674  continue;
1675  }
1676 
1677  const size_t oldsize = temp_vec.size();
1678  temp_vec.resize( oldsize + conn_len );
1679  memcpy( &temp_vec[oldsize], conn, sizeof( EntityHandle ) * conn_len );
1680  }
1681 
1682  std::sort( temp_vec.begin(), temp_vec.end() );
1683  ins = adj_entities.begin();
1684  ti = temp_vec.begin();
1685  while( ti != temp_vec.end() )
1686  {
1687  EntityHandle first = *ti;
1688  EntityHandle second = *ti;
1689  for( ++ti; ti != temp_vec.end() && ( *ti - second <= 1 ); ++ti )
1690  second = *ti;
1691  ins = adj_entities.insert( ins, first, second );
1692  }
1693  }
1694  return result;
1695 }

References moab::Range::begin(), moab::Range::end(), ErrorCode, moab::GeomUtil::first(), moab::Range::insert(), MB_SUCCESS, MBVERTEX, moab::Range::merge(), moab::Range::size(), and moab::TYPE_FROM_HANDLE().

◆ get_connectivity_by_type()

ErrorCode moab::Core::get_connectivity_by_type ( const EntityType  entity_type,
std::vector< EntityHandle > &  connect 
) const
virtual

get global connectivity array for specified entity type

Assumes just vertices, no higher order nodes

Implements moab::Interface.

Definition at line 1125 of file Core.cpp.

1126 {
1127  // inefficient implementation until we get blocked tag access
1128 
1129  // get the range of entities of this type
1130  Range this_range;
1131  ErrorCode result = get_entities_by_type( 0, entity_type, this_range );
1132 
1133  int num_ents = this_range.size();
1134  connect.reserve( num_ents * CN::VerticesPerEntity( entity_type ) );
1135 
1136  // now loop over these entities, getting connectivity for each
1137  for( Range::iterator this_it = this_range.begin(); this_it != this_range.end(); ++this_it )
1138  {
1139  const EntityHandle* connect_vec = NULL;
1140  result = get_connectivity( *this_it, connect_vec, num_ents, true );
1141  MB_CHK_ERR( result );
1142  connect.insert( connect.end(), &connect_vec[0], &connect_vec[num_ents] );
1143  }
1144 
1145  return MB_SUCCESS;
1146 }

References moab::Range::begin(), moab::Range::end(), ErrorCode, MB_CHK_ERR, MB_SUCCESS, moab::Range::size(), and moab::CN::VerticesPerEntity().

◆ get_contained_meshsets() [1/2]

ErrorCode moab::Core::get_contained_meshsets ( const EntityHandle  meshset,
Range children,
const int  num_hops = 1 
) const
virtual

get contained meshsets

Implements moab::Interface.

Definition at line 3544 of file Core.cpp.

3545 {
3546  if( 0 == meshset )
3547  {
3548  return get_entities_by_type( meshset, MBENTITYSET, children );
3549  }
3550 
3551  std::vector< EntityHandle > child_vec;
3552  ErrorCode result = get_contained_meshsets( meshset, child_vec, num_hops );
3553  MB_CHK_ERR( result );
3554  std::sort( child_vec.begin(), child_vec.end() );
3555  std::copy( child_vec.rbegin(), child_vec.rend(), range_inserter( children ) );
3556  return MB_SUCCESS;
3557 }

References ErrorCode, MB_CHK_ERR, MB_SUCCESS, and MBENTITYSET.

◆ get_contained_meshsets() [2/2]

ErrorCode moab::Core::get_contained_meshsets ( const EntityHandle  meshset,
std::vector< EntityHandle > &  children,
const int  num_hops = 1 
) const
virtual

get contained meshsets

Implements moab::Interface.

Definition at line 3527 of file Core.cpp.

3530 {
3531  if( 0 == meshset )
3532  {
3533  return get_entities_by_type( meshset, MBENTITYSET, children );
3534  }
3535 
3536  const EntitySequence* seq;
3537  ErrorCode rval = sequence_manager()->find( meshset, seq );
3538  if( MB_SUCCESS != rval ) return MB_ENTITY_NOT_FOUND;
3539  const MeshSetSequence* mseq = reinterpret_cast< const MeshSetSequence* >( seq );
3540 
3541  return mseq->get_contained_sets( sequence_manager(), meshset, children, num_hops );
3542 }

References ErrorCode, moab::MeshSetSequence::get_contained_sets(), MB_ENTITY_NOT_FOUND, MB_SUCCESS, and MBENTITYSET.

◆ get_coords() [1/4]

ErrorCode moab::Core::get_coords ( const EntityHandle entity_handles,
const int  num_entities,
double *  coords 
) const
virtual

Gets xyz coordinate information for vector of vertices.

Identical to range-based function, except entity handles are specified using a 1d vector and vector length.

Implements moab::Interface.

Definition at line 977 of file Core.cpp.

978 {
979  const EntitySequence* seq = NULL;
980  const VertexSequence* vseq = NULL;
981  const EntityHandle* const end = entities + num_entities;
982  const EntityHandle* iter = entities;
983  ErrorCode status = MB_SUCCESS;
984 
985  while( iter != end )
986  {
987  if( TYPE_FROM_HANDLE( *iter ) == MBVERTEX )
988  {
989  if( !seq )
990  {
992  vseq = static_cast< const VertexSequence* >( seq );
993  }
994  if( !vseq )
995  return MB_ENTITY_NOT_FOUND;
996  else if( vseq->start_handle() > *iter || vseq->end_handle() < *iter )
997  {
998  if( MB_SUCCESS != sequence_manager()->find( *iter, seq ) ) return MB_ENTITY_NOT_FOUND;
999  vseq = static_cast< const VertexSequence* >( seq );
1000  }
1001  vseq->get_coordinates( *iter, coords );
1002  }
1003  else
1004  {
1005  static std::vector< EntityHandle > dum_conn( CN::MAX_NODES_PER_ELEMENT );
1006  static std::vector< double > dum_pos( 3 * CN::MAX_NODES_PER_ELEMENT );
1007  static const EntityHandle* conn;
1008  static int num_conn;
1009  status = get_connectivity( *iter, conn, num_conn, false, &dum_conn );
1010  MB_CHK_ERR( status );
1011  status = get_coords( conn, num_conn, &dum_pos[0] );
1012  MB_CHK_ERR( status );
1013  coords[0] = coords[1] = coords[2] = 0.0;
1014  for( int i = 0; i < num_conn; i++ )
1015  {
1016  coords[0] += dum_pos[3 * i];
1017  coords[1] += dum_pos[3 * i + 1];
1018  coords[2] += dum_pos[3 * i + 2];
1019  }
1020  coords[0] /= num_conn;
1021  coords[1] /= num_conn;
1022  coords[2] /= num_conn;
1023  }
1024  coords += 3;
1025  ++iter;
1026  }
1027 
1028  return status;
1029 }

References moab::EntitySequence::end_handle(), ErrorCode, moab::VertexSequence::get_coordinates(), moab::CN::MAX_NODES_PER_ELEMENT, MB_CHK_ERR, MB_ENTITY_NOT_FOUND, MB_SUCCESS, MBVERTEX, moab::EntitySequence::start_handle(), and moab::TYPE_FROM_HANDLE().

◆ get_coords() [2/4]

ErrorCode moab::Core::get_coords ( const EntityHandle  entity_handle,
const double *&  x,
const double *&  y,
const double *&  z 
) const
virtual

Definition at line 1031 of file Core.cpp.

1035 {
1037 
1038  if( TYPE_FROM_HANDLE( entity_handle ) == MBVERTEX )
1039  {
1040  const EntitySequence* seq = 0;
1041  status = sequence_manager()->find( entity_handle, seq );
1042 
1043  if( seq == 0 || status != MB_SUCCESS ) return MB_ENTITY_NOT_FOUND;
1044 
1045  status = static_cast< const VertexSequence* >( seq )->get_coordinates_ref( entity_handle, x, y, z );
1046  }
1047 
1048  return status;
1049 }

References ErrorCode, MB_ENTITY_NOT_FOUND, MB_SUCCESS, MB_TYPE_OUT_OF_RANGE, MBVERTEX, and moab::TYPE_FROM_HANDLE().

◆ get_coords() [3/4]

ErrorCode moab::Core::get_coords ( const Range entities,
double *  coords 
) const
virtual

get the coordinate information for this handle if it is of type Vertex otherwise, return an error

Implements moab::Interface.

Examples
CoupleMGen.cpp, and ExchangeHalos.cpp.

Definition at line 862 of file Core.cpp.

863 {
864  const TypeSequenceManager& vert_data = sequence_manager()->entity_map( MBVERTEX );
866 
867  Range::const_pair_iterator i = entities.const_pair_begin();
868  EntityHandle first = i->first;
869  while( i != entities.const_pair_end() && TYPE_FROM_HANDLE( i->first ) == MBVERTEX )
870  {
871 
872  seq_iter = vert_data.lower_bound( first );
873  if( seq_iter == vert_data.end() || first < ( *seq_iter )->start_handle() ) return MB_ENTITY_NOT_FOUND;
874  const VertexSequence* vseq = reinterpret_cast< const VertexSequence* >( *seq_iter );
875 
876  EntityID offset = first - vseq->start_handle();
877  EntityID count;
878  if( i->second <= vseq->end_handle() )
879  {
880  count = i->second - first + 1;
881  ++i;
882  if( i != entities.const_pair_end() ) first = i->first;
883  }
884  else
885  {
886  count = vseq->end_handle() - first + 1;
887  first = vseq->end_handle() + 1;
888  }
889 
890  double const *x, *y, *z;
891  MB_CHK_SET_ERR( vseq->get_coordinate_arrays( x, y, z ), "can't get coordinate arrays" );
892  x += offset;
893  y += offset;
894  z += offset;
895  for( EntityID j = 0; j < count; ++j )
896  {
897  coords[3 * j] = x[j];
898  coords[3 * j + 1] = y[j];
899  coords[3 * j + 2] = z[j];
900  }
901  coords = &coords[3 * count];
902  }
903 
904  // for non-vertices...
905  ErrorCode rval = MB_SUCCESS;
906  for( Range::const_iterator rit( &( *i ), i->first ); rit != entities.end(); ++rit )
907  {
908  MB_CHK_SET_ERR( get_coords( &( *rit ), 1, coords ), "can't get coords" );
909  coords += 3;
910  }
911 
912  return rval;
913 }

References moab::Range::const_pair_begin(), moab::Range::const_pair_end(), moab::Range::end(), moab::TypeSequenceManager::end(), moab::EntitySequence::end_handle(), ErrorCode, moab::GeomUtil::first(), moab::VertexSequence::get_coordinate_arrays(), moab::TypeSequenceManager::lower_bound(), MB_CHK_SET_ERR, MB_ENTITY_NOT_FOUND, MB_SUCCESS, MBVERTEX, moab::EntitySequence::start_handle(), and moab::TYPE_FROM_HANDLE().

Referenced by moab::HiReconstruction::average_vertex_normal(), moab::HiReconstruction::average_vertex_tangent(), RuntimeContext::compute_centroids(), moab::NestedRefine::copy_vertices_from_prev_level(), gather_set_stats(), moab::NestedRefine::get_coordinates(), moab::WriteUtil::get_node_coords(), moab::HiReconstruction::hiproj_walf_around_vertex(), moab::HiReconstruction::hiproj_walf_in_element(), main(), perform_laplacian_smoothing(), perform_lloyd_relaxation(), moab::HiReconstruction::polyfit3d_walf_curve_vertex(), moab::HiReconstruction::polyfit3d_walf_surf_vertex(), moab::ReorderTool::reorder_entities(), and test_spectral_quad().

◆ get_coords() [4/4]

ErrorCode moab::Core::get_coords ( const Range entities,
double *  x_coords,
double *  y_coords,
double *  z_coords 
) const
virtual
Author
Jason Kraftcheck kraft.nosp@m.che@.nosp@m.cae.w.nosp@m.isc..nosp@m.edu - 2007-5-15

Implements moab::Interface.

Definition at line 916 of file Core.cpp.

917 {
918  const TypeSequenceManager& vert_data = sequence_manager()->entity_map( MBVERTEX );
920 
921  Range::const_pair_iterator i = entities.const_pair_begin();
922  EntityHandle first = i->first;
923  while( i != entities.const_pair_end() && TYPE_FROM_HANDLE( i->first ) == MBVERTEX )
924  {
925 
926  seq_iter = vert_data.lower_bound( first );
927  if( seq_iter == vert_data.end() || first < ( *seq_iter )->start_handle() ) return MB_ENTITY_NOT_FOUND;
928  const VertexSequence* vseq = reinterpret_cast< const VertexSequence* >( *seq_iter );
929 
930  EntityID offset = first - vseq->start_handle();
931  EntityID count;
932  if( i->second <= vseq->end_handle() )
933  {
934  count = i->second - first + 1;
935  ++i;
936  if( i != entities.const_pair_end() ) first = i->first;
937  }
938  else
939  {
940  count = vseq->end_handle() - first + 1;
941  first = vseq->end_handle() + 1;
942  }
943 
944  double const *x, *y, *z;
945  MB_CHK_SET_ERR( vseq->get_coordinate_arrays( x, y, z ), "can't get coordinate arrays" );
946  if( x_coords )
947  {
948  memcpy( x_coords, x + offset, count * sizeof( double ) );
949  x_coords += count;
950  }
951  if( y_coords )
952  {
953  memcpy( y_coords, y + offset, count * sizeof( double ) );
954  y_coords += count;
955  }
956  if( z_coords )
957  {
958  memcpy( z_coords, z + offset, count * sizeof( double ) );
959  z_coords += count;
960  }
961  }
962 
963  // for non-vertices...
964  ErrorCode rval = MB_SUCCESS;
965  double xyz[3];
966  for( Range::const_iterator rit( &( *i ), i->first ); rit != entities.end(); ++rit )
967  {
968  MB_CHK_SET_ERR( get_coords( &( *rit ), 1, xyz ), "can't get coords" );
969  *x_coords++ = xyz[0];
970  *y_coords++ = xyz[1];
971  *z_coords++ = xyz[2];
972  }
973 
974  return rval;
975 }

References moab::Range::const_pair_begin(), moab::Range::const_pair_end(), moab::Range::end(), moab::TypeSequenceManager::end(), moab::EntitySequence::end_handle(), ErrorCode, moab::GeomUtil::first(), moab::VertexSequence::get_coordinate_arrays(), moab::TypeSequenceManager::lower_bound(), MB_CHK_SET_ERR, MB_ENTITY_NOT_FOUND, MB_SUCCESS, MBVERTEX, moab::EntitySequence::start_handle(), and moab::TYPE_FROM_HANDLE().

◆ get_dimension()

ErrorCode moab::Core::get_dimension ( int &  dim) const
virtual

get overall geometric dimension

Implements moab::Interface.

Definition at line 768 of file Core.cpp.

769 {
770  dim = geometricDimension;
771  return MB_SUCCESS;
772 }

References MB_SUCCESS.

◆ get_entities_by_dimension() [1/2]

ErrorCode moab::Core::get_entities_by_dimension ( const EntityHandle  meshset,
const int  dimension,
Range entities,
const bool  recursive = false 
) const
virtual

Adds adjacencies.

Parameters
from_handleentities
both_waysadd the adjacency information to both the to_handle and and the from_from :handle

Example:

/
virtual ErrorCode add_adjacencies( const EntityHandle entity_handle,
const EntityHandle* adjacencies,
const int num_handles,
bool both_ways );
//! Adds adjacencies; same as vector-based, but with range instead
virtual ErrorCode add_adjacencies( const EntityHandle entity_handle, Range& adjacencies, bool both_ways );
//! Removes adjacencies
/** \param handle EntityHandle to get adjacencies of.
Example: \code
*/
virtual ErrorCode remove_adjacencies( const EntityHandle entity_handle,
const EntityHandle* adjacencies,
const int num_handles );
//! Retrieves all entities in the database of given dimension.
/** \param dimension Dimension of entities desired.
\param entities Range in which entities of dimension <em>dimension</em> are returned.
Example: \code
int dimension = 2;
Range entities;
get_entities_by_dimension( dimension, entities ); //get 2D EntityHandles in the database

Implements moab::Interface.

Examples
ExtractLand.cpp.

Definition at line 1872 of file Core.cpp.

1876 {
1877  ErrorCode result = MB_SUCCESS;
1878  if( meshset )
1879  {
1880  const EntitySequence* seq;
1881  result = sequence_manager()->find( meshset, seq );
1882  MB_CHK_ERR( result );
1883  const MeshSetSequence* mseq = reinterpret_cast< const MeshSetSequence* >( seq );
1884  result = mseq->get_dimension( sequence_manager(), meshset, dimension, entities, recursive );
1885  MB_CHK_ERR( result );
1886  }
1887  else if( dimension > 3 )
1888  {
1889  sequence_manager()->get_entities( MBENTITYSET, entities );
1890  }
1891  else
1892  {
1893  for( EntityType this_type = CN::TypeDimensionMap[dimension].first;
1894  this_type <= CN::TypeDimensionMap[dimension].second; this_type++ )
1895  {
1896  sequence_manager()->get_entities( this_type, entities );
1897  }
1898  }
1899 
1900  return MB_SUCCESS;
1901 }

References ErrorCode, moab::GeomUtil::first(), moab::MeshSetSequence::get_dimension(), MB_CHK_ERR, MB_SUCCESS, MBENTITYSET, and moab::CN::TypeDimensionMap.

Referenced by moab::HalfFacetRep::check_mixed_entity_type(), moab::NestedRefine::count_subentities(), moab::NestedRefine::exchange_ghosts(), moab::HalfFacetRep::initialize(), moab::HiReconstruction::initialize(), moab::ReorderTool::int_order_from_sets_and_adj(), main(), process_partition_file(), tag_depth(), test_spectral_hex(), and moab::HalfFacetRep::update_entity_ranges().

◆ get_entities_by_dimension() [2/2]

ErrorCode moab::Core::get_entities_by_dimension ( const EntityHandle  meshset,
const int  dimension,
std::vector< EntityHandle > &  entities,
const bool  recursive = false 
) const
virtual

Retrieves all entities of a given topological dimension in the database or meshset.

Appends entities to list passed in.

Parameters
meshsetMeshset whose entities are being queried (zero if query is for entire mesh).
dimensionTopological dimension of entities desired.
entitiesRange in which entities of dimension dimension are returned.
recursiveIf true, meshsets containing meshsets are queried recursively. Returns the contents of meshsets, but not the meshsets themselves if true.

Example:

// get 1d (edge) elements in the entire mesh
Range edges;

Implements moab::Interface.

Definition at line 1903 of file Core.cpp.

1907 {
1908  ErrorCode result = MB_SUCCESS;
1909  if( meshset )
1910  {
1911  const EntitySequence* seq;
1912  result = sequence_manager()->find( meshset, seq );
1913  MB_CHK_ERR( result );
1914  const MeshSetSequence* mseq = reinterpret_cast< const MeshSetSequence* >( seq );
1915  result = mseq->get_dimension( sequence_manager(), meshset, dimension, entities, recursive );
1916  MB_CHK_ERR( result );
1917  }
1918  else if( dimension > 3 )
1919  {
1920  sequence_manager()->get_entities( MBENTITYSET, entities );
1921  }
1922  else
1923  {
1924  for( EntityType this_type = CN::TypeDimensionMap[dimension].first;
1925  this_type <= CN::TypeDimensionMap[dimension].second; this_type++ )
1926  {
1927  sequence_manager()->get_entities( this_type, entities );
1928  }
1929  }
1930 
1931  return MB_SUCCESS;
1932 }

References ErrorCode, moab::GeomUtil::first(), moab::MeshSetSequence::get_dimension(), MB_CHK_ERR, MB_SUCCESS, MBENTITYSET, and moab::CN::TypeDimensionMap.

◆ get_entities_by_handle() [1/2]

ErrorCode moab::Core::get_entities_by_handle ( const EntityHandle  meshset,
Range entities,
const bool  recursive = false 
) const
virtual

Retrieves all entities in the data base.

Parameters
entitiesRange in which entities of EntityType type are returned.

Example:

Range entities;
get_entities( entities ); //get MBTET type EntityHandles in the database

Implements moab::Interface.

Definition at line 2042 of file Core.cpp.

2043 {
2044  ErrorCode result = MB_SUCCESS;
2045  if( meshset )
2046  {
2047  const EntitySequence* seq;
2048  result = sequence_manager()->find( meshset, seq );
2049  MB_CHK_ERR( result );
2050  const MeshSetSequence* mseq = reinterpret_cast< const MeshSetSequence* >( seq );
2051  result = mseq->get_entities( sequence_manager(), meshset, entities, recursive );
2052  MB_CHK_ERR( result );
2053  }
2054  else
2055  {
2056  // iterate backwards so range insertion is quicker
2057  for( EntityType entity_type = MBENTITYSET; entity_type >= MBVERTEX; --entity_type )
2058  sequence_manager()->get_entities( entity_type, entities );
2059  }
2060 
2061  return MB_SUCCESS;
2062 }

References ErrorCode, moab::MeshSetSequence::get_entities(), MB_CHK_ERR, MB_SUCCESS, MBENTITYSET, and MBVERTEX.

Referenced by moab::RangeSetIterator::build_pair_vec(), moab::HigherOrderFactory::convert(), moab::WriteUtil::gather_entities(), moab::ReadUtil::gather_related_ents(), get_max_volume(), main(), moab::ReorderTool::update_set_contents(), and moab::NestedRefine::update_special_tags().

◆ get_entities_by_handle() [2/2]

ErrorCode moab::Core::get_entities_by_handle ( const EntityHandle  meshset,
std::vector< EntityHandle > &  entities,
const bool  recursive = false 
) const
virtual

Retrieves all entities in the data base.

Parameters
entitiesRange in which entities of EntityType type are returned.

Example:

Range entities;
get_entities( entities ); //get MBTET type EntityHandles in the database

Implements moab::Interface.

Definition at line 2064 of file Core.cpp.

2067 {
2068  ErrorCode result;
2069  if( recursive || !meshset )
2070  {
2071  Range tmp_range;
2072  result = get_entities_by_handle( meshset, tmp_range, recursive );
2073  size_t offset = entities.size();
2074  entities.resize( offset + tmp_range.size() );
2075  std::copy( tmp_range.begin(), tmp_range.end(), entities.begin() + offset );
2076  }
2077  else
2078  {
2079  const EntitySequence* seq;
2080  result = sequence_manager()->find( meshset, seq );
2081  MB_CHK_ERR( result );
2082  const MeshSetSequence* mseq = reinterpret_cast< const MeshSetSequence* >( seq );
2083  result = mseq->get_entities( meshset, entities );
2084  MB_CHK_ERR( result );
2085  }
2086  return MB_SUCCESS;
2087 }

References moab::Range::begin(), moab::Range::end(), ErrorCode, moab::MeshSetSequence::get_entities(), MB_CHK_ERR, MB_SUCCESS, and moab::Range::size().

◆ get_entities_by_type() [1/2]

ErrorCode moab::Core::get_entities_by_type ( const EntityHandle  meshset,
const EntityType  type,
Range entities,
const bool  recursive = false 
) const
virtual

Retrieves all entities in the data base of given type.

Parameters
typeEntityType of entities desired (ie, MBHEX, MBEDGE, MBTRI, etc )
entitiesRange in which entities of EntityType type are returned.

Example:

EntityType type = MBTET;
Range entities;
get_entities_by_dimension( type, entities ); //get MBTET type EntityHandles in the database

Implements moab::Interface.

Definition at line 1934 of file Core.cpp.

1938 {
1939  ErrorCode result = MB_SUCCESS;
1940  if( meshset )
1941  {
1942  const EntitySequence* seq;
1943  result = sequence_manager()->find( meshset, seq );
1944  MB_CHK_ERR( result );
1945  const MeshSetSequence* mseq = reinterpret_cast< const MeshSetSequence* >( seq );
1946  result = mseq->get_type( sequence_manager(), meshset, entity_type, entities, recursive );
1947  MB_CHK_ERR( result );
1948  }
1949  else
1950  {
1951  sequence_manager()->get_entities( entity_type, entities );
1952  }
1953 
1954  return MB_SUCCESS;
1955 }

References ErrorCode, moab::MeshSetSequence::get_type(), MB_CHK_ERR, and MB_SUCCESS.

Referenced by moab::AEntityFactory::create_vert_elem_adjacencies(), dot_contained(), dot_nodes(), moab::ReadUtil::gather_related_ents(), gather_set_stats(), main(), test_spectral_quad(), and moab::ReorderTool::update_set_contents().

◆ get_entities_by_type() [2/2]

ErrorCode moab::Core::get_entities_by_type ( const EntityHandle  meshset,
const EntityType  type,
std::vector< EntityHandle > &  entities,
const bool  recursive = false 
) const
virtual

Retrieves all entities in the data base of given type.

Parameters
typeEntityType of entities desired (ie, MBHEX, MBEDGE, MBTRI, etc )
entitiesRange in which entities of EntityType type are returned.

Example:

EntityType type = MBTET;
Range entities;
get_entities_by_dimension( type, entities ); //get MBTET type EntityHandles in the database

Implements moab::Interface.

Definition at line 1957 of file Core.cpp.

1961 {
1962  ErrorCode result = MB_SUCCESS;
1963  if( meshset )
1964  {
1965  const EntitySequence* seq;
1966  result = sequence_manager()->find( meshset, seq );
1967  MB_CHK_ERR( result );
1968  const MeshSetSequence* mseq = reinterpret_cast< const MeshSetSequence* >( seq );
1969  result = mseq->get_type( sequence_manager(), meshset, entity_type, entities, recursive );
1970  MB_CHK_ERR( result );
1971  }
1972  else
1973  {
1974  sequence_manager()->get_entities( entity_type, entities );
1975  }
1976 
1977  return MB_SUCCESS;
1978 }

References ErrorCode, moab::MeshSetSequence::get_type(), MB_CHK_ERR, and MB_SUCCESS.

◆ get_entities_by_type_and_tag()

ErrorCode moab::Core::get_entities_by_type_and_tag ( const EntityHandle  meshset,
const EntityType  type,
const Tag tag_handles,
const void *const *  values,
const int  num_tags,
Range entities,
const int  condition = Interface::INTERSECT,
const bool  recursive = false 
) const
virtual

Retrieve entities in the database or meshset which have any or all of the tag(s) and (optionally) value(s) specified.

Parameters
meshsetMeshset whose entities are being queried (zero if query is for entire mesh).
typeType of entities to be returned
tag_handlesVector of tag handles entities must have
valuesVector of pointers to values of tags in tag_handles
num_tagsNumber of tags and values in tag_handles and values
entitiesRange in which entities are returned.
conditionBoolean condition, either Interface::UNION or Interface::INTERSECT
recursiveIf true, meshsets containing meshsets are queried recursively. Returns the contents of meshsets, but not the meshsets themselves. Specifying both recursive=true and type=MBENTITYSET is an error, as it would always result in an empty list.

If Interface::UNION is specified as the condition, entities with any of the tags and values specified are returned. If Interface::INTERSECT is specified, only entities with all of the tags/values are returned.

If values is NULL, entities with the specified tags and any corresponding values are returned. Note that if values is non-NULL, it is a vector of pointers to tag values.

Example:

// get the dirichlet sets in a mesh
Range dir_sets;
Tag dir_tag;
get_entities_by_type_and_tag(0, MBENTITYSET, &dir_tag, NULL, 1, dir_sets,

Implements moab::Interface.

Definition at line 1980 of file Core.cpp.

1988 {
1989  ErrorCode result;
1990  Range range;
1991 
1992  result = get_entities_by_type( meshset, entity_type, range, recursive );
1993  MB_CHK_ERR( result );
1994  if( !entities.empty() && Interface::INTERSECT == condition ) range = intersect( entities, range );
1995 
1996  // For each tag:
1997  // if operation is INTERSECT remove from 'range' any non-tagged entities
1998  // if operation is UNION add to 'entities' any tagged entities
1999  for( int it = 0; it < num_tags && !range.empty(); it++ )
2000  {
2001  if( !valid_tag_handle( tags[it] ) ) return MB_TAG_NOT_FOUND;
2002 
2003  // Of the entities in 'range', put in 'tmp_range' the subset
2004  // that are tagged as requested for this tag.
2005  Range tmp_range;
2006 
2007  // get the entities with this tag/value combo
2008  if( NULL == values || NULL == values[it] )
2009  {
2010  result = tags[it]->get_tagged_entities( sequenceManager, tmp_range, entity_type, &range );
2011  MB_CHK_ERR( result );
2012  }
2013  else
2014  {
2015  result = tags[it]->find_entities_with_value( sequenceManager, mError, tmp_range, values[it], 0, entity_type,
2016  &range );
2017  MB_CHK_ERR( result );
2018  // if there is a default value, then we should return all entities
2019  // that are untagged
2020  if( tags[it]->equals_default_value( values[it] ) )
2021  {
2022  Range all_tagged, untagged;
2023  result = tags[it]->get_tagged_entities( sequenceManager, all_tagged, entity_type, &range );
2024  MB_CHK_ERR( result );
2025  // add to 'tmp_range' any untagged entities in 'range'
2026  tmp_range.merge( subtract( range, all_tagged ) );
2027  }
2028  }
2029 
2030  // The above calls should have already done the intersect for us.
2031  if( Interface::INTERSECT == condition )
2032  range.swap( tmp_range );
2033  else
2034  entities.merge( tmp_range );
2035  }
2036 
2037  if( Interface::INTERSECT == condition ) entities.swap( range );
2038 
2039  return MB_SUCCESS;
2040 }

References moab::Range::empty(), ErrorCode, moab::TagInfo::find_entities_with_value(), moab::TagInfo::get_tagged_entities(), moab::intersect(), moab::Interface::INTERSECT, MB_CHK_ERR, MB_SUCCESS, MB_TAG_NOT_FOUND, moab::Range::merge(), moab::subtract(), and moab::Range::swap().

Referenced by moab::HigherOrderFactory::convert_sequence(), dot_get_sets(), moab::ReadUtil::get_gather_set(), moab::ReadParallel::load_file(), main(), process_partition_file(), moab::ReorderTool::reorder_tag_data(), test_spectral_hex(), and moab::NestedRefine::update_special_tags().

◆ get_error_string()

std::string moab::Core::get_error_string ( const ErrorCode  code) const
virtual

Return string representation of given error code.

Parameters
codeError code for which string is wanted

Implements moab::Interface.

Definition at line 3688 of file Core.cpp.

3689 {
3690  return (unsigned)code <= (unsigned)MB_FAILURE ? ErrorCodeStr[code] : "INVALID ERROR CODE";
3691 }

Referenced by main().

◆ get_last_error()

ErrorCode moab::Core::get_last_error ( std::string &  info) const
virtual

Return information about the last error.

Parameters
infostd::string into which information on the last error is written.

Implements moab::Interface.

Definition at line 3682 of file Core.cpp.

3683 {
3685  return MB_SUCCESS;
3686 }

References MB_SUCCESS, and moab::MBErrorHandler_GetLastError().

Referenced by main().

◆ get_meshset_options()

ErrorCode moab::Core::get_meshset_options ( const EntityHandle  ms_handle,
unsigned int &  options 
) const
virtual

get the options of a mesh set

Implements moab::Interface.

Definition at line 3330 of file Core.cpp.

3331 {
3332  if( !ms_handle )
3333  { // root set
3334  setoptions = MESHSET_SET | MESHSET_TRACK_OWNER;
3335  return MB_SUCCESS;
3336  }
3337 
3338  const MeshSet* set = get_mesh_set( sequence_manager(), ms_handle );
3339  if( !set ) return MB_ENTITY_NOT_FOUND;
3340 
3341  setoptions = set->flags();
3342  return MB_SUCCESS;
3343 }

References moab::MeshSet::flags(), moab::get_mesh_set(), MB_ENTITY_NOT_FOUND, MB_SUCCESS, MESHSET_SET, and MESHSET_TRACK_OWNER.

Referenced by moab::ReorderTool::update_set_contents().

◆ get_number_entities_by_dimension()

ErrorCode moab::Core::get_number_entities_by_dimension ( const EntityHandle  meshset,
const int  dimension,
int &  number,
const bool  recursive = false 
) const
virtual

Retrieves all entities in the database of given dimension.

get # entities of a given dimension

Parameters
dimensionDimension of entities desired.
entitiesRange in which entities of dimension dimension are returned.

Example:

int dimension = 2;
Range entities;
get_entities_by_dimension( dimension, entities ); //get 2D EntityHandles in the database

Implements moab::Interface.

Definition at line 2090 of file Core.cpp.

2094 {
2095  ErrorCode result = MB_SUCCESS;
2096 
2097  if( !meshset )
2098  {
2099  number = 0;
2100  for( EntityType this_type = CN::TypeDimensionMap[dim].first; this_type <= CN::TypeDimensionMap[dim].second;
2101  this_type++ )
2102  {
2103  number += sequence_manager()->get_number_entities( this_type );
2104  }
2105  }
2106  else
2107  {
2108  const EntitySequence* seq;
2109  result = sequence_manager()->find( meshset, seq );
2110  MB_CHK_ERR( result );
2111  const MeshSetSequence* mseq = reinterpret_cast< const MeshSetSequence* >( seq );
2112  result = mseq->num_dimension( sequence_manager(), meshset, dim, number, recursive );
2113  MB_CHK_ERR( result );
2114  }
2115 
2116  return MB_SUCCESS;
2117 }

References ErrorCode, moab::GeomUtil::first(), MB_CHK_ERR, MB_SUCCESS, moab::MeshSetSequence::num_dimension(), and moab::CN::TypeDimensionMap.

Referenced by main().

◆ get_number_entities_by_handle()

ErrorCode moab::Core::get_number_entities_by_handle ( const EntityHandle  meshset,
int &  num_entities,
const bool  recursive = false 
) const
virtual

Retrieves all entities in the data base.

Parameters
entitiesRange in which entities of EntityType type are returned.

Example:

Range entities;
get_entities( entities ); //get MBTET type EntityHandles in the database

Implements moab::Interface.

Definition at line 2163 of file Core.cpp.

2164 {
2165  ErrorCode result;
2166  if( meshset )
2167  {
2168  const EntitySequence* seq;
2169  result = sequence_manager()->find( meshset, seq );
2170  MB_CHK_ERR( result );
2171  const MeshSetSequence* mseq = reinterpret_cast< const MeshSetSequence* >( seq );
2172  return mseq->num_entities( sequence_manager(), meshset, num_ent, recursive );
2173  }
2174 
2175  num_ent = 0;
2176  for( EntityType this_type = MBVERTEX; this_type < MBMAXTYPE; this_type++ )
2177  {
2178  int dummy = 0;
2179  result = get_number_entities_by_type( 0, this_type, dummy );
2180  if( result != MB_SUCCESS )
2181  {
2182  num_ent = 0;
2183  return result;
2184  }
2185  num_ent += dummy;
2186  }
2187 
2188  return MB_SUCCESS;
2189 }

References ErrorCode, MB_CHK_ERR, MB_SUCCESS, MBMAXTYPE, MBVERTEX, and moab::MeshSetSequence::num_entities().

◆ get_number_entities_by_type()

ErrorCode moab::Core::get_number_entities_by_type ( const EntityHandle  meshset,
const EntityType  type,
int &  num_entities,
const bool  recursive = false 
) const
virtual

Retrieves all entities in the data base of given type.

returns the number of entities with a given type and tag

Parameters
typeEntityType of entities desired (ie, MBHEX, MBEDGE, MBTRI, etc )
entitiesRange in which entities of EntityType type are returned.

Example:

EntityType type = MBTET;
Range entities;
get_entities_by_dimension( type, entities ); //get MBTET type EntityHandles in the database

Implements moab::Interface.

Definition at line 2120 of file Core.cpp.

2124 {
2125  ErrorCode result = MB_SUCCESS;
2126 
2127  if( recursive && entity_type == MBENTITYSET ) // will never return anything
2128  return MB_TYPE_OUT_OF_RANGE;
2129 
2130  if( meshset )
2131  {
2132  const EntitySequence* seq;
2133  result = sequence_manager()->find( meshset, seq );
2134  MB_CHK_ERR( result );
2135  const MeshSetSequence* mseq = reinterpret_cast< const MeshSetSequence* >( seq );
2136  result = mseq->num_type( sequence_manager(), meshset, entity_type, num_ent, recursive );
2137  MB_CHK_ERR( result );
2138  }
2139  else
2140  {
2141  num_ent = sequence_manager()->get_number_entities( entity_type );
2142  }
2143 
2144  return MB_SUCCESS;
2145 }

References ErrorCode, MB_CHK_ERR, MB_SUCCESS, MB_TYPE_OUT_OF_RANGE, MBENTITYSET, and moab::MeshSetSequence::num_type().

Referenced by gather_set_stats().

◆ get_number_entities_by_type_and_tag()

ErrorCode moab::Core::get_number_entities_by_type_and_tag ( const EntityHandle  meshset,
const EntityType  type,
const Tag tag_handles,
const void *const *  values,
const int  num_tags,
int &  num_entities,
const int  condition = Interface::INTERSECT,
const bool  recursive = false 
) const
virtual

Retrieve number of entities in the database or meshset which have any or all of the tag(s) and (optionally) value(s) specified.

Identical to get_entities_by_type_and_tag, except number instead of entities are returned

Parameters
meshsetMeshset whose entities are being queried (zero if query is for entire mesh).
typeType of entities to be returned
tag_handlesVector of tag handles entities must have
valuesVector of pointers to values of tags in tag_handles
num_tagsNumber of tags and values in tag_handles and values
num_entitiesRange in which number of entities are returned.
recursiveIf true, meshsets containing meshsets are queried recursively. Returns the contents of meshsets, but not the meshsets themselves. Specifying both recursive=true and type=MBENTITYSET is an error, as it would always result in an empty list.

Implements moab::Interface.

Definition at line 2147 of file Core.cpp.

2155 {
2156  Range dum_ents;
2157  ErrorCode result = get_entities_by_type_and_tag( meshset, entity_type, tag_handles, values, num_tags, dum_ents,
2158  condition, recursive );
2159  num_entities = dum_ents.size();
2160  return result;
2161 }

References ErrorCode, and moab::Range::size().

Referenced by gather_tag_counts().

◆ get_parent_meshsets() [1/2]

ErrorCode moab::Core::get_parent_meshsets ( const EntityHandle  meshset,
Range parents,
const int  num_hops = 1 
) const
virtual

get parent meshsets

Implements moab::Interface.

Definition at line 3489 of file Core.cpp.

3490 {
3491  if( 0 == meshset ) return MB_ENTITY_NOT_FOUND;
3492 
3493  std::vector< EntityHandle > parent_vec;
3494  ErrorCode result = get_parent_meshsets( meshset, parent_vec, num_hops );
3495  MB_CHK_ERR( result );
3496  std::sort( parent_vec.begin(), parent_vec.end() );
3497  std::copy( parent_vec.rbegin(), parent_vec.rend(), range_inserter( parents ) );
3498  return MB_SUCCESS;
3499 }

References ErrorCode, MB_CHK_ERR, MB_ENTITY_NOT_FOUND, and MB_SUCCESS.

◆ get_parent_meshsets() [2/2]

ErrorCode moab::Core::get_parent_meshsets ( const EntityHandle  meshset,
std::vector< EntityHandle > &  parents,
const int  num_hops = 1 
) const
virtual

get parent meshsets

Implements moab::Interface.

Definition at line 3475 of file Core.cpp.

3478 {
3479  if( 0 == meshset ) return MB_ENTITY_NOT_FOUND;
3480 
3481  const EntitySequence* seq;
3482  ErrorCode rval = sequence_manager()->find( meshset, seq );
3483  if( MB_SUCCESS != rval ) return MB_ENTITY_NOT_FOUND;
3484  const MeshSetSequence* mseq = reinterpret_cast< const MeshSetSequence* >( seq );
3485 
3486  return mseq->get_parents( sequence_manager(), meshset, parents, num_hops );
3487 }

References ErrorCode, moab::MeshSetSequence::get_parents(), MB_ENTITY_NOT_FOUND, and MB_SUCCESS.

Referenced by dot_children(), and moab::ReadUtil::gather_related_ents().

◆ get_root_set()

EntityHandle moab::Core::get_root_set ( )
privatevirtual

return the entity set representing the whole mesh

Implements moab::Interface.

Definition at line 256 of file Core.cpp.

257 {
258  return 0;
259 }

◆ get_sequence_multiplier()

double moab::Core::get_sequence_multiplier ( ) const
virtual

Interface to control memory allocation for sequences Provide a factor that controls the size of the sequence that gets allocated. This is typically useful in the parallel setting when a-priori, the number of ghost entities and the memory required for them within the same sequence as the owned entities are unknown. The default factor is 1.0 but this can be appropriately updated at runtime so that we do not have broken sequences.

Implements moab::Interface.

Definition at line 1111 of file Core.cpp.

1112 {
1114 }

◆ get_set_iterators()

ErrorCode moab::Core::get_set_iterators ( EntityHandle  meshset,
std::vector< SetIterator * > &  set_iters 
)

Get all set iterators associated with the set passed in.

Parameters
meshsetMeshset for which iterators are requested
set_itersSet iterators for the set

Definition at line 3987 of file Core.cpp.

3988 {
3989  for( std::vector< SetIterator* >::const_iterator vit = setIterators.begin(); vit != setIterators.end(); ++vit )
3990  if( ( *vit )->ent_set() == meshset ) set_iters.push_back( *vit );
3991  return MB_SUCCESS;
3992 }

References MB_SUCCESS.

◆ get_vertex_coordinates()

ErrorCode moab::Core::get_vertex_coordinates ( std::vector< double > &  coords) const
virtual

get blocked vertex coordinates for all vertices

Blocked = all x, then all y, etc.

Implements moab::Interface.

Definition at line 802 of file Core.cpp.

803 {
804  // INEFFICIENT implementation for now, until we get blocked tag access
805  Range vertices;
806  ErrorCode result = get_entities_by_type( 0, MBVERTEX, vertices );
807  MB_CHK_ERR( result );
808 
809  // the least we can do is resize the vector and only go through the
810  // vertex list once
811  int num_verts = vertices.size();
812  int vec_pos = 0;
813  double xyz[3];
814  coords.resize( geometricDimension * num_verts );
815  for( Range::iterator it = vertices.begin(); it != vertices.end(); ++it )
816  {
817  result = get_coords( &( *it ), 1, xyz );
818  MB_CHK_ERR( result );
819 
820  coords[vec_pos] = xyz[0];
821  coords[num_verts + vec_pos] = xyz[1];
822  coords[2 * num_verts + vec_pos] = xyz[2];
823 
824  vec_pos++;
825  }
826 
827  return MB_SUCCESS;
828 }

References moab::Range::begin(), moab::Range::end(), ErrorCode, MB_CHK_ERR, MB_SUCCESS, MBVERTEX, and moab::Range::size().

◆ get_vertices()

ErrorCode moab::Core::get_vertices ( const Range from_entities,
Range vertices 
)
virtual

Get all vertices for input entities.

Special case of get_adjacencies where to_dimension == 0 and operation_type == Interface::UNION.

Note
This is not a variation of get_connectivity because the behavior is different for polyhedra.

Definition at line 1736 of file Core.cpp.

1737 {
1738  Range range;
1739  MB_CHK_SET_ERR( get_connectivity( from_entities, range ), "can't get connectivity" );
1740 
1741  // If input contained polyhedra, connectivity will contain faces.
1742  // Get vertices from faces.
1743  if( !range.all_of_dimension( 0 ) )
1744  {
1745  Range::iterator it = range.upper_bound( MBVERTEX );
1746  Range polygons;
1747  polygons.merge( it, range.end() );
1748  range.erase( it, range.end() );
1749  MB_CHK_SET_ERR( get_connectivity( polygons, range ), "can't get connectivity" );
1750  }
1751 
1752  if( vertices.empty() )
1753  vertices.swap( range );
1754  else
1755  vertices.merge( range );
1756  return MB_SUCCESS;
1757 }

References moab::Range::all_of_dimension(), moab::Range::empty(), moab::Range::end(), moab::Range::erase(), MB_CHK_SET_ERR, MB_SUCCESS, MBVERTEX, moab::Range::merge(), moab::Range::swap(), and moab::Range::upper_bound().

◆ globalId_tag()

Tag moab::Core::globalId_tag ( )
virtual

Get parent mesh sets of a mesh set.

If num_hops is 1, only immediate parents are returned. If num_hops is zero, all ancenstors are returned. Otherwise, num_hops specifies the maximum number of generations to traverse.

Parameters
meshsetThe mesh set whose parents are being queried
parentsSTL vector holding the parents returned by this function
num_hopsNumber of generations to traverse (0 = all)

Implements moab::Interface.

Examples
ExtractLand.cpp.

Definition at line 2681 of file Core.cpp.

2682 {
2683  const int negone = -1;
2684  if( 0 == globalIdTag )
2686  return globalIdTag;
2687 }

References GLOBAL_ID_TAG_NAME, MB_TAG_CREAT, MB_TAG_DENSE, and MB_TYPE_INTEGER.

Referenced by moab::WriteUtil::assign_ids(), and main().

◆ handle_from_id()

ErrorCode moab::Core::handle_from_id ( const EntityType  type,
const EntityID  id,
EntityHandle handle 
) const
virtual

get a handle from an id and type

Implements moab::Interface.

Definition at line 389 of file Core.cpp.

390 {
391  int err;
392  handle = CREATE_HANDLE( entity_type, id, err );
393 
394  // check to see if handle exists
395  const EntitySequence* dummy_seq = 0;
396  ErrorCode error_code = sequence_manager()->find( handle, dummy_seq );
397  return error_code;
398 }

References moab::CREATE_HANDLE(), and ErrorCode.

Referenced by moab::HalfFacetRep::fid_from_halfacet().

◆ high_order_node()

ErrorCode moab::Core::high_order_node ( const EntityHandle  parent_handle,
const EntityHandle subfacet_conn,
const EntityType  subfacet_type,
EntityHandle hon 
) const
virtual

given an entity and the connectivity and type of one of its subfacets, find the high order node on that subfacet, if any

Implements moab::Interface.

Definition at line 3199 of file Core.cpp.

3203 {
3204  hon = 0;
3205 
3206  EntityType parent_type = TYPE_FROM_HANDLE( parent_handle );
3207 
3208  // get the parent's connectivity
3209  const EntityHandle* parent_conn = NULL;
3210  int num_parent_vertices = 0;
3211  ErrorCode result = get_connectivity( parent_handle, parent_conn, num_parent_vertices, false );
3212  MB_CHK_ERR( result );
3213 
3214  // find whether this entity has ho nodes
3215  int mid_nodes[4];
3216  CN::HasMidNodes( parent_type, num_parent_vertices, mid_nodes );
3217 
3218  // check whether this entity has mid nodes on this dimension subfacet;
3219  // use dimension-1 because vertices don't have mid nodes
3220  if( !mid_nodes[CN::Dimension( subfacet_type )] ) return MB_SUCCESS;
3221 
3222  // ok, we have mid nodes; now must compute expected index in connectivity array;
3223  // ho nodes stored for edges, faces then entity
3224 
3225  // offset starts with # corner vertices
3226  int offset = CN::VerticesPerEntity( parent_type );
3227  int i;
3228 
3229  for( i = 0; i < CN::Dimension( subfacet_type ) - 1; i++ )
3230  // for each dimension lower than that of the subfacet we're looking for,
3231  // if this entity has midnodes in that dimension, increment offset by #
3232  // of subfacets of that dimension; use dimension-1 in loop because
3233  // canon numbering table only has 2 positions, for edges and faces;
3234  if( mid_nodes[i + 1] ) offset += CN::mConnectivityMap[parent_type][i].num_sub_elements;
3235 
3236  // now add the index of this subfacet; only need to if it's not the highest dimension
3237  if( subfacet_type != parent_type )
3238  {
3239 
3240  // find indices into parent_conn for each entry in child_conn
3241  unsigned subfacet_size = CN::VerticesPerEntity( subfacet_type );
3242  int subfacet_indices[10];
3243  assert( subfacet_size <= sizeof( subfacet_indices ) / sizeof( subfacet_indices[0] ) );
3244  for( unsigned j = 0; j < subfacet_size; ++j )
3245  {
3246  subfacet_indices[j] =
3247  std::find( parent_conn, parent_conn + num_parent_vertices, subfacet_conn[j] ) - parent_conn;
3248  if( subfacet_indices[j] >= num_parent_vertices )
3249  {
3250  return MB_FAILURE;
3251  }
3252  }
3253 
3254  int dum, side_no, temp_offset;
3255  int temp_result =
3256  CN::SideNumber( parent_type, subfacet_indices, subfacet_size, subfacet_type, side_no, dum, temp_offset );
3257  if( temp_result != 0 ) return MB_FAILURE;
3258 
3259  offset += side_no;
3260  }
3261 
3262  // offset shouldn't be off the end of the connectivity vector
3263  if( offset >= num_parent_vertices ) return MB_INDEX_OUT_OF_RANGE;
3264 
3265  hon = parent_conn[offset];
3266 
3267  return MB_SUCCESS;
3268 }

References moab::CN::Dimension(), moab::dum, ErrorCode, moab::CN::HasMidNodes(), MB_CHK_ERR, MB_INDEX_OUT_OF_RANGE, MB_SUCCESS, moab::CN::mConnectivityMap, moab::CN::ConnMap::num_sub_elements, moab::CN::SideNumber(), moab::TYPE_FROM_HANDLE(), and moab::CN::VerticesPerEntity().

◆ id_from_handle()

EntityID moab::Core::id_from_handle ( const EntityHandle  handle) const
virtual

get the id from a handle, returns id

Implements moab::Interface.

Definition at line 383 of file Core.cpp.

384 {
385  return ID_FROM_HANDLE( handle );
386 }

References moab::ID_FROM_HANDLE().

Referenced by dot_down_link(), dot_nodes(), dot_write_node(), main(), and perform_laplacian_smoothing().

◆ impl_version()

float moab::Core::impl_version ( std::string *  version_string = NULL)
virtual

Returns the major.minor version number of the implementation.

Parameters
iface_nameIf non-NULL, will be filled in with a string, possibly containing implementation-specific information

Implements moab::Interface.

Definition at line 366 of file Core.cpp.

367 {
368  if( version_string ) *version_string = MOAB_PACKAGE_VERSION_STRING;
369 
371 }

References MOAB_PACKAGE_VERSION_MAJOR, MOAB_PACKAGE_VERSION_MINOR, and MOAB_PACKAGE_VERSION_STRING.

◆ initialize()

ErrorCode moab::Core::initialize ( )
private

database init and de-init routines

Definition at line 193 of file Core.cpp.

194 {
195 #ifdef MOAB_HAVE_MPI
196  int flag;
197  if( MPI_SUCCESS == MPI_Initialized( &flag ) )
198  {
199  if( flag )
200  {
202  if( writeMPELog ) (void)MPE_Init_log();
203  }
204  }
205 #endif
206 
207  initErrorHandlerInCore = false;
209  {
211  initErrorHandlerInCore = true;
212  }
213 
214  geometricDimension = 3;
215  materialTag = 0;
216  neumannBCTag = 0;
217  dirichletBCTag = 0;
218  geomDimensionTag = 0;
219  globalIdTag = 0;
220 
221  sequenceManager = new( std::nothrow ) SequenceManager;
223 
224  aEntityFactory = new( std::nothrow ) AEntityFactory( this );
226 
227  mError = new( std::nothrow ) Error;
228  if( !mError ) return MB_MEMORY_ALLOCATION_FAILED;
229 
230  mMBWriteUtil = NULL;
231  mMBReadUtil = NULL;
232  scdInterface = NULL;
233 
234  // Readers and writers try to get pointers to above utils.
235  // Do this after pointers are initialized. (Pointers should
236  // really be initialized in constructor to avoid this kind
237  // of thing -- j.kraftcheck.)
238  readerWriterSet = new( std::nothrow ) ReaderWriterSet( this );
240 
241  material_tag();
242  neumannBC_tag();
243  dirichletBC_tag();
245  globalId_tag();
246 
247 #ifdef MOAB_HAVE_AHF
248  ahfRep = new HalfFacetRep( this );
249  if( !ahfRep ) return MB_MEMORY_ALLOCATION_FAILED;
250  mesh_modified = false;
251 #endif
252 
253  return MB_SUCCESS;
254 }

References MB_MEMORY_ALLOCATION_FAILED, MB_SUCCESS, moab::MBErrorHandler_Init(), moab::MBErrorHandler_Initialized(), MPE_Init_log, and MPE_Initialized_logging.

◆ intersect_meshset()

ErrorCode moab::Core::intersect_meshset ( EntityHandle  meshset1,
const EntityHandle  meshset2 
)
virtual

intersects meshset2 with meshset1 - modifies meshset1

Implements moab::Interface.

Definition at line 3392 of file Core.cpp.

3393 {
3394  MeshSet* set1 = get_mesh_set( sequence_manager(), meshset1 );
3395  MeshSet* set2 = get_mesh_set( sequence_manager(), meshset2 );
3396  if( !set1 || !set2 ) return MB_ENTITY_NOT_FOUND;
3397 
3398  return set1->intersect( set2, meshset1, a_entity_factory() );
3399 }

References moab::get_mesh_set(), moab::MeshSet::intersect(), and MB_ENTITY_NOT_FOUND.

◆ is_valid()

bool moab::Core::is_valid ( const EntityHandle  this_ent) const

return whether the input handle is valid or not

Definition at line 3935 of file Core.cpp.

3936 {
3937  const EntitySequence* seq = 0;
3938  ErrorCode result = sequence_manager()->find( this_ent, seq );
3939  return seq != 0 && result == MB_SUCCESS;
3940 }

References ErrorCode, and MB_SUCCESS.

Referenced by moab::RangeSetIterator::get_next_arr(), moab::VectorSetIterator::get_next_arr(), and moab::ScdBox::~ScdBox().

◆ list_entities() [1/2]

ErrorCode moab::Core::list_entities ( const EntityHandle entities,
const int  num_entities 
) const
virtual

List entities, or number of entities in database, to standard output.

Lists data pertaining to entities to standard output. If entities is NULL and num_entities is zero, lists only the number of entities of each type in the database. If entities is NULL and num_entities is non-zero, lists all information for all entities in the database.

Parameters
entities1d vector of entities to list
num_entitiesNumber of entities in 1d vector

Implements moab::Interface.

Definition at line 2910 of file Core.cpp.

2911 {
2912  Range temp_range;
2913  ErrorCode result = MB_SUCCESS;
2914  if( NULL == entities && num_entities == 0 )
2915  {
2916  // just list the numbers of each entity type
2917  int num_ents;
2918  std::cout << std::endl;
2919  std::cout << "Number of entities per type: " << std::endl;
2920  for( EntityType this_type = MBVERTEX; this_type < MBMAXTYPE; this_type++ )
2921  {
2922  result = get_number_entities_by_type( 0, this_type, num_ents );
2923  std::cout << CN::EntityTypeName( this_type ) << ": " << num_ents << std::endl;
2924  }
2925  std::cout << std::endl;
2926 
2927  return MB_SUCCESS;
2928  }
2929  else if( NULL == entities && num_entities < 0 )
2930  {
2931 
2932  // list all entities of all types
2933  std::cout << std::endl;
2934  for( EntityType this_type = MBVERTEX; this_type < MBMAXTYPE; this_type++ )
2935  {
2936  result = get_entities_by_type( 0, this_type, temp_range );
2937  }
2938 
2939  return list_entities( temp_range );
2940  }
2941  else if( NULL == entities && num_entities > 0 )
2942  {
2943 
2944  // list all entities of type == num_entities
2945  std::cout << std::endl;
2946  result = get_entities_by_type( 0, (EntityType)num_entities, temp_range );
2947 
2948  return list_entities( temp_range );
2949  }
2950  else
2951  {
2952  ErrorCode tmp_result;
2953  for( int i = 0; i < num_entities; i++ )
2954  {
2955  EntityType this_type = TYPE_FROM_HANDLE( entities[i] );
2956  std::cout << CN::EntityTypeName( this_type ) << " " << ID_FROM_HANDLE( entities[i] ) << ":" << endl;
2957 
2958  tmp_result = ( const_cast< Core* >( this ) )->list_entity( entities[i] );
2959  if( MB_SUCCESS != tmp_result ) result = tmp_result;
2960  }
2961  }
2962 
2963  return result;
2964 }

References moab::CN::EntityTypeName(), ErrorCode, moab::ID_FROM_HANDLE(), MB_SUCCESS, MBMAXTYPE, MBVERTEX, and moab::TYPE_FROM_HANDLE().

◆ list_entities() [2/2]

ErrorCode moab::Core::list_entities ( const Range entities) const
virtual

List entities to standard output.

Lists all data pertaining to entities (i.e. vertex coordinates if vertices, connectivity if elements, set membership if set). Useful for debugging, but output can become quite long for large databases.

Implements moab::Interface.

Definition at line 2966 of file Core.cpp.

2967 {
2968  ErrorCode result = MB_SUCCESS, tmp_result;
2969 
2970  for( Range::const_iterator rit = temp_range.begin(); rit != temp_range.end(); ++rit )
2971  {
2972  EntityType this_type = TYPE_FROM_HANDLE( *rit );
2973  std::cout << CN::EntityTypeName( this_type ) << " " << ID_FROM_HANDLE( *rit ) << ":" << endl;
2974 
2975  tmp_result = ( const_cast< Core* >( this ) )->list_entity( *rit );
2976  if( MB_SUCCESS != tmp_result ) result = tmp_result;
2977  }
2978 
2979  return result;
2980 }

References moab::Range::begin(), moab::Range::end(), moab::CN::EntityTypeName(), ErrorCode, moab::ID_FROM_HANDLE(), MB_SUCCESS, and moab::TYPE_FROM_HANDLE().

Referenced by main().

◆ list_entity()

ErrorCode moab::Core::list_entity ( const EntityHandle  entity) const
virtual

List a single entity; no header printed.

Lists a single entity, including its connectivity and its adjacencies. No header is printed, because calling function might print information between header and information printed by this function.

Parameters
entityThe entity to be listed.

Implements moab::Interface.

Definition at line 2982 of file Core.cpp.

2983 {
2984  ErrorCode result;
2985  HandleVec adj_vec;
2986 
2987  if( !is_valid( entity ) )
2988  {
2989  std::cout << "(invalid)" << std::endl;
2990  return MB_SUCCESS;
2991  }
2992 
2993  if( 0 != globalIdTag )
2994  {
2995  int dum;
2996  result = tag_get_data( globalIdTag, &entity, 1, &dum );
2997  if( MB_SUCCESS == result ) std::cout << "Global id = " << dum << std::endl;
2998  }
2999 
3000  // list entity
3001  EntityType this_type = TYPE_FROM_HANDLE( entity );
3002  if( this_type == MBVERTEX )
3003  {
3004  double coords[3];
3005  result = get_coords( &( entity ), 1, coords );
3006  MB_CHK_ERR( result );
3007  std::cout << "Coordinates: (" << coords[0] << ", " << coords[1] << ", " << coords[2] << ")" << std::endl;
3008  }
3009  else if( this_type == MBENTITYSET )
3010  this->print( entity, "" );
3011 
3012  std::cout << " Adjacencies:" << std::endl;
3013  bool some = false;
3014  int multiple = 0;
3015  for( int dim = 0; dim <= 3; dim++ )
3016  {
3017  if( dim == CN::Dimension( this_type ) ) continue;
3018  adj_vec.clear();
3019  // use const_cast here 'cuz we're in a const function and we're passing 'false' for
3020  // create_if_missing, so we know we won't change anything
3021  result = ( const_cast< Core* >( this ) )->get_adjacencies( &( entity ), 1, dim, false, adj_vec );
3022  if( MB_FAILURE == result ) continue;
3023  for( HandleVec::iterator adj_it = adj_vec.begin(); adj_it != adj_vec.end(); ++adj_it )
3024  {
3025  if( adj_it != adj_vec.begin() )
3026  std::cout << ", ";
3027  else
3028  std::cout << " ";
3029  std::cout << CN::EntityTypeName( TYPE_FROM_HANDLE( *adj_it ) ) << " " << ID_FROM_HANDLE( *adj_it );
3030  }
3031  if( !adj_vec.empty() )
3032  {
3033  std::cout << std::endl;
3034  some = true;
3035  }
3036  if( MB_MULTIPLE_ENTITIES_FOUND == result ) multiple += dim;
3037  }
3038  if( !some ) std::cout << "(none)" << std::endl;
3039  const EntityHandle* explicit_adjs;
3040  int num_exp;
3041  aEntityFactory->get_adjacencies( entity, explicit_adjs, num_exp );
3042  if( NULL != explicit_adjs && 0 != num_exp )
3043  {
3044  std::cout << " Explicit adjacencies: ";
3045  for( int i = 0; i < num_exp; i++ )
3046  {
3047  if( i != 0 ) std::cout << ", ";
3048  std::cout << CN::EntityTypeName( TYPE_FROM_HANDLE( explicit_adjs[i] ) ) << " "
3049  << ID_FROM_HANDLE( explicit_adjs[i] );
3050  }
3051  std::cout << std::endl;
3052  }
3053  if( multiple != 0 ) std::cout << " (MULTIPLE = " << multiple << ")" << std::endl;
3054 
3055  result = print_entity_tags( std::string(), entity, MB_TAG_DENSE );
3056 
3057  std::cout << std::endl;
3058 
3059  return result;
3060 }

References moab::CN::Dimension(), moab::dum, moab::CN::EntityTypeName(), ErrorCode, moab::ID_FROM_HANDLE(), MB_CHK_ERR, MB_MULTIPLE_ENTITIES_FOUND, MB_SUCCESS, MB_TAG_DENSE, MBENTITYSET, MBVERTEX, and moab::TYPE_FROM_HANDLE().

◆ load_file()

ErrorCode moab::Core::load_file ( const char *  file_name,
const EntityHandle file_set = 0,
const char *  options = 0,
const char *  set_tag_name = 0,
const int *  set_tag_vals = 0,
int  num_set_tag_vals = 0 
)
virtual

Load or import a file.

Implements moab::Interface.

Examples
ExchangeHalos.cpp, and ExtractLand.cpp.

Definition at line 416 of file Core.cpp.

422 {
423  FileOptions opts( setoptions );
424  ErrorCode rval;
425  ReaderIface::IDTag t = { set_tag_name, set_tag_vals, num_set_tag_vals };
426  ReaderIface::SubsetList sl = { &t, 1, 0, 0 };
427 
428  assert( !file_set || ( *file_set && is_valid( *file_set ) ) );
429  if( file_set && !*file_set )
430  {
431  MB_SET_GLB_ERR( MB_FAILURE, "Non-NULL file set pointer should point to non-NULL set" );
432  }
433 
434  // if reading in parallel, call a different reader
435  std::string parallel_opt;
436  rval = opts.get_option( "PARALLEL", parallel_opt );
437  if( MB_SUCCESS == rval )
438  {
439 #ifdef MOAB_HAVE_MPI
440  ParallelComm* pcomm = 0;
441  int pcomm_id;
442  rval = opts.get_int_option( "PARALLEL_COMM", pcomm_id );
443  if( MB_ENTITY_NOT_FOUND == rval ) rval = opts.get_int_option( "PCOMM", pcomm_id );
444  if( rval == MB_SUCCESS )
445  {
446  pcomm = ParallelComm::get_pcomm( this, pcomm_id );
447  if( !pcomm ) return MB_ENTITY_NOT_FOUND;
448  }
449  else if( rval != MB_ENTITY_NOT_FOUND )
450  return rval;
451  if( set_tag_name && num_set_tag_vals )
452  {
453  MB_CHK_SET_ERR( ReadParallel( this, pcomm ).load_file( file_name, file_set, opts, &sl ),
454  "can't load subset file in parallel" );
455  }
456  else
457  {
458  MB_CHK_SET_ERR( ReadParallel( this, pcomm ).load_file( file_name, file_set, opts ),
459  "can't load file in parallel" );
460  }
461 #else
462  MB_SET_GLB_ERR( MB_FAILURE, "PARALLEL option not valid, this instance compiled for serial execution" );
463 #endif
464  }
465  else
466  {
467  if( set_tag_name && num_set_tag_vals )
468  {
469  MB_CHK_SET_ERR( serial_load_file( file_name, file_set, opts, &sl ), "can't load subset file in serial" );
470  }
471  else
472  {
473  MB_CHK_SET_ERR( serial_load_file( file_name, file_set, opts ), "can't load file in serial" );
474  }
475  }
476 
477  if( MB_SUCCESS == rval && !opts.all_seen() )
478  {
479  std::string bad_opt;
480  if( MB_SUCCESS == opts.get_unseen_option( bad_opt ) )
481  {
482  MB_SET_ERR( MB_UNHANDLED_OPTION, "Unrecognized option: \"" << bad_opt << "\"" );
483  }
484  else
485  {
486  MB_SET_ERR( MB_UNHANDLED_OPTION, "Unrecognized option" );
487  }
488  }
489 
490  return MB_SUCCESS;
491 }

References moab::FileOptions::all_seen(), ErrorCode, moab::FileOptions::get_int_option(), moab::FileOptions::get_option(), moab::ParallelComm::get_pcomm(), moab::FileOptions::get_unseen_option(), MB_CHK_SET_ERR, MB_ENTITY_NOT_FOUND, MB_SET_ERR, MB_SET_GLB_ERR, MB_SUCCESS, and MB_UNHANDLED_OPTION.

Referenced by RuntimeContext::load_file(), main(), TestErrorHandling_1(), TestErrorHandling_2(), TestErrorHandling_3(), TestErrorHandlingPar_1(), and TestErrorHandlingPar_2().

◆ load_mesh()

ErrorCode moab::Core::load_mesh ( const char *  file_name,
const int *  active_block_id_list = NULL,
const int  num_blocks = 0 
)
virtual

load mesh from data in file NOTE: if there is mesh already present, the new mesh will be added

Implements moab::Interface.

Definition at line 410 of file Core.cpp.

411 {
412  const char* name = block_id_list ? MATERIAL_SET_TAG_NAME : 0;
413  return load_file( file_name, 0, 0, name, block_id_list, num_blocks );
414 }

References MATERIAL_SET_TAG_NAME.

Referenced by main(), test_spectral_hex(), and test_spectral_quad().

◆ material_tag()

Tag moab::Core::material_tag ( )

return various specific tag handles

Definition at line 2656 of file Core.cpp.

2657 {
2658  const int negone = -1;
2659  if( 0 == materialTag )
2661  return materialTag;
2662 }

References MATERIAL_SET_TAG_NAME, MB_TAG_CREAT, MB_TAG_SPARSE, and MB_TYPE_INTEGER.

◆ merge_entities()

ErrorCode moab::Core::merge_entities ( EntityHandle  entity_to_keep,
EntityHandle  entity_to_remove,
bool  auto_merge,
bool  delete_removed_entity 
)
virtual

merges two entities

Implements moab::Interface.

Definition at line 2751 of file Core.cpp.

2755 {
2756  if( auto_merge ) return MB_FAILURE;
2757 
2758  // The two entities to merge must not be the same entity.
2759  if( entity_to_keep == entity_to_remove ) return MB_FAILURE;
2760 
2761  // The two entities to merge must be of the same type
2762  EntityType type_to_keep = TYPE_FROM_HANDLE( entity_to_keep );
2763 
2764  if( type_to_keep != TYPE_FROM_HANDLE( entity_to_remove ) ) return MB_TYPE_OUT_OF_RANGE;
2765 
2766  // Make sure both entities exist before trying to merge.
2767  EntitySequence* seq = 0;
2768  ErrorCode result, status;
2769  status = sequence_manager()->find( entity_to_keep, seq );
2770  if( seq == 0 || status != MB_SUCCESS ) return MB_ENTITY_NOT_FOUND;
2771  status = sequence_manager()->find( entity_to_remove, seq );
2772  if( seq == 0 || status != MB_SUCCESS ) return MB_ENTITY_NOT_FOUND;
2773 
2774  // If auto_merge is not set, all sub-entities should
2775  // be merged if the entities are to be merged.
2776  int ent_dim = CN::Dimension( type_to_keep );
2777  if( ent_dim > 0 )
2778  {
2779  std::vector< EntityHandle > conn, conn2;
2780 
2781  result = get_connectivity( &entity_to_keep, 1, conn );
2782  MB_CHK_ERR( result );
2783  result = get_connectivity( &entity_to_remove, 1, conn2 );
2784  MB_CHK_ERR( result );
2785 
2786  // Check to see if we can merge before pulling adjacencies.
2787  int dum1, dum2;
2788  if( !auto_merge &&
2789  ( conn.size() != conn2.size() || !CN::ConnectivityMatch( &conn[0], &conn2[0], conn.size(), dum1, dum2 ) ) )
2790  return MB_FAILURE;
2791  }
2792 
2793  result = aEntityFactory->merge_adjust_adjacencies( entity_to_keep, entity_to_remove );
2794 
2795  if( MB_SUCCESS == result && delete_removed_entity ) result = delete_entities( &entity_to_remove, 1 );
2796 
2797  return result;
2798 }

References moab::CN::ConnectivityMatch(), moab::CN::Dimension(), ErrorCode, MB_CHK_ERR, MB_ENTITY_NOT_FOUND, MB_SUCCESS, MB_TYPE_OUT_OF_RANGE, and moab::TYPE_FROM_HANDLE().

◆ neumannBC_tag()

Tag moab::Core::neumannBC_tag ( )

Definition at line 2664 of file Core.cpp.

2665 {
2666  const int negone = -1;
2667  if( 0 == neumannBCTag )
2669  return neumannBCTag;
2670 }

References MB_TAG_CREAT, MB_TAG_SPARSE, MB_TYPE_INTEGER, and NEUMANN_SET_TAG_NAME.

◆ num_child_meshsets()

ErrorCode moab::Core::num_child_meshsets ( const EntityHandle  meshset,
int *  number,
const int  num_hops = 1 
) const
virtual

gets number of child meshsets

Implements moab::Interface.

Definition at line 3571 of file Core.cpp.

3572 {
3573  if( 0 == meshset ) return MB_ENTITY_NOT_FOUND;
3574 
3575  const EntitySequence* seq;
3576  ErrorCode rval = sequence_manager()->find( meshset, seq );
3577  if( MB_SUCCESS != rval ) return MB_ENTITY_NOT_FOUND;
3578  const MeshSetSequence* mseq = reinterpret_cast< const MeshSetSequence* >( seq );
3579 
3580  return mseq->num_children( sequence_manager(), meshset, *number, num_hops );
3581 }

References ErrorCode, MB_ENTITY_NOT_FOUND, MB_SUCCESS, and moab::MeshSetSequence::num_children().

◆ num_contained_meshsets()

ErrorCode moab::Core::num_contained_meshsets ( const EntityHandle  meshset,
int *  number,
const int  num_hops = 1 
) const
virtual

gets number of contained meshsets

Implements moab::Interface.

Definition at line 3583 of file Core.cpp.

3584 {
3585  if( 0 == meshset )
3586  {
3587  return get_number_entities_by_type( 0, MBENTITYSET, *number );
3588  }
3589 
3590  const EntitySequence* seq;
3591  ErrorCode rval = sequence_manager()->find( meshset, seq );
3592  if( MB_SUCCESS != rval ) return MB_ENTITY_NOT_FOUND;
3593  const MeshSetSequence* mseq = reinterpret_cast< const MeshSetSequence* >( seq );
3594 
3595  return mseq->num_contained_sets( sequence_manager(), meshset, *number, num_hops );
3596 }

References ErrorCode, MB_ENTITY_NOT_FOUND, MB_SUCCESS, MBENTITYSET, and moab::MeshSetSequence::num_contained_sets().

◆ num_parent_meshsets()

ErrorCode moab::Core::num_parent_meshsets ( const EntityHandle  meshset,
int *  number,
const int  num_hops = 1 
) const
virtual

gets number of parent meshsets

Implements moab::Interface.

Definition at line 3559 of file Core.cpp.

3560 {
3561  if( 0 == meshset ) return MB_ENTITY_NOT_FOUND;
3562 
3563  const EntitySequence* seq;
3564  ErrorCode rval = sequence_manager()->find( meshset, seq );
3565  if( MB_SUCCESS != rval ) return MB_ENTITY_NOT_FOUND;
3566  const MeshSetSequence* mseq = reinterpret_cast< const MeshSetSequence* >( seq );
3567 
3568  return mseq->num_parents( sequence_manager(), meshset, *number, num_hops );
3569 }

References ErrorCode, MB_ENTITY_NOT_FOUND, MB_SUCCESS, and moab::MeshSetSequence::num_parents().

◆ operator=()

Core& moab::Core::operator= ( const Core copy)
private

Do not allow copying.

◆ print()

void moab::Core::print ( const EntityHandle  handle,
const char *  prefix,
bool  first_call = true 
) const

Definition at line 3693 of file Core.cpp.

3694 {
3695  // get the entities
3696  Range entities;
3697 
3698  if( 0 != ms_handle )
3699  {
3700  get_entities_by_handle( ms_handle, entities );
3701  std::cout << prefix << "MBENTITYSET " << ID_FROM_HANDLE( ms_handle ) << std::endl;
3702  }
3703  else
3704  {
3705  get_entities_by_dimension( 0, 3, entities );
3706  if( entities.empty() ) get_entities_by_dimension( 0, 2, entities );
3707  if( entities.empty() ) get_entities_by_dimension( 0, 1, entities );
3708  get_entities_by_dimension( 0, 0, entities );
3709  get_entities_by_type( 0, MBENTITYSET, entities );
3710  std::cout << prefix << "--: " << std::endl;
3711  }
3712 
3713  std::string indent_prefix = prefix;
3714  indent_prefix += " ";
3715  entities.print( indent_prefix.c_str() );
3716 
3717  if( !first_call || !ms_handle ) return;
3718 
3719  // print parent/children
3720  Range temp;
3721  this->get_parent_meshsets( ms_handle, temp );
3722  std::cout << " Parent sets: ";
3723  if( temp.empty() )
3724  std::cout << "(none)" << std::endl;
3725  else
3726  {
3727  for( Range::iterator rit = temp.begin(); rit != temp.end(); ++rit )
3728  {
3729  if( rit != temp.begin() ) std::cout << ", ";
3730  std::cout << ID_FROM_HANDLE( *rit );
3731  }
3732  std::cout << std::endl;
3733  }
3734 
3735  temp.clear();
3736  this->get_child_meshsets( ms_handle, temp );
3737  std::cout << " Child sets: ";
3738  if( temp.empty() )
3739  std::cout << "(none)" << std::endl;
3740  else
3741  {
3742  for( Range::iterator rit = temp.begin(); rit != temp.end(); ++rit )
3743  {
3744  if( rit != temp.begin() ) std::cout << ", ";
3745  std::cout << ID_FROM_HANDLE( *rit );
3746  }
3747  std::cout << std::endl;
3748  }
3749 
3750  // print all sparse tags
3751  print_entity_tags( indent_prefix, ms_handle, MB_TAG_SPARSE );
3752 }

References moab::Range::begin(), moab::Range::clear(), moab::Range::empty(), moab::Range::end(), moab::ID_FROM_HANDLE(), MB_TAG_SPARSE, MBENTITYSET, and moab::Range::print().

◆ print_database()

void moab::Core::print_database ( ) const

Definition at line 4200 of file Core.cpp.

4201 {
4202  ErrorCode rval;
4204  const TypeSequenceManager& verts = sequence_manager()->entity_map( MBVERTEX );
4205  if( !verts.empty() )
4206  printf( " Vertex ID X Y Z Adjacencies \n"
4207  " ---------- -------- -------- -------- -----------...\n" );
4208  const EntityHandle* adj;
4209  int nadj;
4210  for( i = verts.begin(); i != verts.end(); ++i )
4211  {
4212  const VertexSequence* seq = static_cast< const VertexSequence* >( *i );
4213  printf( "(Sequence [%d,%d] in SequenceData [%d,%d])\n", (int)ID_FROM_HANDLE( seq->start_handle() ),
4214  (int)ID_FROM_HANDLE( seq->end_handle() ), (int)ID_FROM_HANDLE( seq->data()->start_handle() ),
4215  (int)ID_FROM_HANDLE( seq->data()->end_handle() ) );
4216 
4217  double c[3];
4218  for( EntityHandle h = seq->start_handle(); h <= seq->end_handle(); ++h )
4219  {
4220  rval = seq->get_coordinates( h, c );
4221  if( MB_SUCCESS == rval )
4222  printf( " %10d %8g %8g %8g", (int)ID_FROM_HANDLE( h ), c[0], c[1], c[2] );
4223  else
4224  printf( " %10d < ERROR %4d >", (int)ID_FROM_HANDLE( h ), (int)rval );
4225 
4226  rval = a_entity_factory()->get_adjacencies( h, adj, nadj );
4227  if( MB_SUCCESS != rval )
4228  {
4229  printf( " <ERROR %d>\n", (int)rval );
4230  continue;
4231  }
4232  EntityType pt = MBMAXTYPE;
4233  for( int j = 0; j < nadj; ++j )
4234  {
4235  if( TYPE_FROM_HANDLE( adj[j] ) != pt )
4236  {
4237  pt = TYPE_FROM_HANDLE( adj[j] );
4238  printf( " %s", pt >= MBMAXTYPE ? "INVALID TYPE" : CN::EntityTypeName( pt ) );
4239  }
4240  printf( " %d", (int)ID_FROM_HANDLE( adj[j] ) );
4241  }
4242  printf( "\n" );
4243  }
4244  }
4245 
4246  for( EntityType t = MBEDGE; t < MBENTITYSET; ++t )
4247  {
4248  const TypeSequenceManager& elems = sequence_manager()->entity_map( t );
4249  if( elems.empty() ) continue;
4250 
4251  int clen = 0;
4252  for( i = elems.begin(); i != elems.end(); ++i )
4253  {
4254  int n = static_cast< const ElementSequence* >( *i )->nodes_per_element();
4255  if( n > clen ) clen = n;
4256  }
4257 
4258  clen *= 5;
4259  if( clen < (int)strlen( "Connectivity" ) ) clen = strlen( "Connectivity" );
4260  std::vector< char > dashes( clen, '-' );
4261  dashes.push_back( '\0' );
4262  printf( " %7s ID %-*s Adjacencies\n", CN::EntityTypeName( t ), clen, "Connectivity" );
4263  printf( " ---------- %s -----------...\n", &dashes[0] );
4264 
4265  std::vector< EntityHandle > storage;
4266  const EntityHandle* conn;
4267  int nconn;
4268  for( i = elems.begin(); i != elems.end(); ++i )
4269  {
4270  const ElementSequence* seq = static_cast< const ElementSequence* >( *i );
4271  printf( "(Sequence [%d,%d] in SequenceData [%d,%d])\n", (int)ID_FROM_HANDLE( seq->start_handle() ),
4272  (int)ID_FROM_HANDLE( seq->end_handle() ), (int)ID_FROM_HANDLE( seq->data()->start_handle() ),
4273  (int)ID_FROM_HANDLE( seq->data()->end_handle() ) );
4274 
4275  for( EntityHandle h = seq->start_handle(); h <= seq->end_handle(); ++h )
4276  {
4277  printf( " %10d", (int)ID_FROM_HANDLE( h ) );
4278  rval = get_connectivity( h, conn, nconn, false, &storage );
4279  if( MB_SUCCESS != rval )
4280  printf( " <ERROR %2d>%*s", (int)rval, clen - 10, "" );
4281  else
4282  {
4283  for( int j = 0; j < nconn; ++j )
4284  printf( " %4d", (int)ID_FROM_HANDLE( conn[j] ) );
4285  printf( "%*s", clen - 5 * nconn, "" );
4286  }
4287 
4288  rval = a_entity_factory()->get_adjacencies( h, adj, nadj );
4289  if( MB_SUCCESS != rval )
4290  {
4291  printf( " <ERROR %d>\n", (int)rval );
4292  continue;
4293  }
4294  EntityType pt = MBMAXTYPE;
4295  for( int j = 0; j < nadj; ++j )
4296  {
4297  if( TYPE_FROM_HANDLE( adj[j] ) != pt )
4298  {
4299  pt = TYPE_FROM_HANDLE( adj[j] );
4300  printf( " %s", pt >= MBMAXTYPE ? "INVALID TYPE" : CN::EntityTypeName( pt ) );
4301  }
4302  printf( " %d", (int)ID_FROM_HANDLE( adj[j] ) );
4303  }
4304  printf( "\n" );
4305  }
4306  }
4307  }
4308 }

References moab::TypeSequenceManager::begin(), dashes(), moab::EntitySequence::data(), moab::TypeSequenceManager::empty(), moab::TypeSequenceManager::end(), moab::EntitySequence::end_handle(), moab::SequenceData::end_handle(), moab::CN::EntityTypeName(), ErrorCode, moab::VertexSequence::get_coordinates(), moab::ID_FROM_HANDLE(), MB_SUCCESS, MBEDGE, MBENTITYSET, MBMAXTYPE, MBVERTEX, moab::ElementSequence::nodes_per_element(), moab::EntitySequence::start_handle(), moab::SequenceData::start_handle(), and moab::TYPE_FROM_HANDLE().

◆ print_entity_tags()

ErrorCode moab::Core::print_entity_tags ( std::string  indent_prefix,
const EntityHandle  handle,
TagType  tp 
) const

Definition at line 3754 of file Core.cpp.

3755 {
3756  std::vector< Tag > set_tags;
3757  ErrorCode result = this->tag_get_tags_on_entity( handle, set_tags );
3758  std::cout << indent_prefix << ( tp == MB_TAG_SPARSE ? "Sparse tags:" : "Dense tags:" ) << std::endl;
3759  indent_prefix += " ";
3760 
3761  for( std::vector< Tag >::iterator vit = set_tags.begin(); vit != set_tags.end(); ++vit )
3762  {
3763  TagType this_type;
3764  result = this->tag_get_type( *vit, this_type );
3765  if( MB_SUCCESS != result || tp != this_type ) continue;
3766  DataType this_data_type;
3767  result = this->tag_get_data_type( *vit, this_data_type );
3768  if( MB_SUCCESS != result ) continue;
3769  int this_size;
3770  result = this->tag_get_length( *vit, this_size );
3771  if( MB_SUCCESS != result ) continue;
3772  // use double since this is largest single-valued tag
3773  std::vector< double > dbl_vals( this_size );
3774  std::vector< int > int_vals( this_size );
3775  std::vector< EntityHandle > hdl_vals( this_size );
3776  std::string tag_name;
3777  result = this->tag_get_name( *vit, tag_name );
3778  if( MB_SUCCESS != result ) continue;
3779  switch( this_data_type )
3780  {
3781  case MB_TYPE_INTEGER:
3782  result = this->tag_get_data( *vit, &handle, 1, &int_vals[0] );
3783  if( MB_SUCCESS != result ) continue;
3784  std::cout << indent_prefix << tag_name << " = ";
3785  if( this_size < 10 )
3786  for( int i = 0; i < this_size; i++ )
3787  std::cout << int_vals[i] << " ";
3788  else
3789  std::cout << int_vals[0] << "... (mult values)";
3790  std::cout << std::endl;
3791  break;
3792  case MB_TYPE_DOUBLE:
3793  result = this->tag_get_data( *vit, &handle, 1, &dbl_vals[0] );
3794  if( MB_SUCCESS != result ) continue;
3795  std::cout << indent_prefix << tag_name << " = ";
3796  if( this_size < 10 )
3797  for( int i = 0; i < this_size; i++ )
3798  std::cout << dbl_vals[i] << " ";
3799  else
3800  std::cout << dbl_vals[0] << "... (mult values)";
3801  std::cout << std::endl;
3802  break;
3803  case MB_TYPE_HANDLE:
3804  result = this->tag_get_data( *vit, &handle, 1, &hdl_vals[0] );
3805  if( MB_SUCCESS != result ) continue;
3806  std::cout << indent_prefix << tag_name << " = ";
3807  if( this_size < 10 )
3808  for( int i = 0; i < this_size; i++ )
3809  std::cout << hdl_vals[i] << " ";
3810  else
3811  std::cout << hdl_vals[0] << "... (mult values)";
3812  std::cout << std::endl;
3813  break;
3814  case MB_TYPE_OPAQUE:
3815  if( NAME_TAG_SIZE == this_size )
3816  {
3817  char dum_tag[NAME_TAG_SIZE];
3818  result = this->tag_get_data( *vit, &handle, 1, &dum_tag );
3819  if( MB_SUCCESS != result ) continue;
3820  // insert NULL just in case there isn't one
3821  dum_tag[NAME_TAG_SIZE - 1] = '\0';
3822  std::cout << indent_prefix << tag_name << " = " << dum_tag << std::endl;
3823  }
3824  break;
3825  case MB_TYPE_BIT:
3826  break;
3827  }
3828  }
3829 
3830  return MB_SUCCESS;
3831 }

References ErrorCode, MB_SUCCESS, MB_TAG_SPARSE, MB_TYPE_BIT, MB_TYPE_DOUBLE, MB_TYPE_HANDLE, MB_TYPE_INTEGER, MB_TYPE_OPAQUE, NAME_TAG_SIZE, and TagType.

◆ query_interface_type()

ErrorCode moab::Core::query_interface_type ( const std::type_info &  interface_type,
void *&  ptr 
)
virtual

Get a pointer to an internal MOAB interface.

Returns
NULL if not found, iterface pointer otherwise

Implements moab::Interface.

Definition at line 306 of file Core.cpp.

307 {
308  if( interface_type == typeid( ReadUtilIface ) )
309  {
310  if( !mMBReadUtil ) mMBReadUtil = new ReadUtil( this, mError );
311  ptr = static_cast< ReadUtilIface* >( mMBReadUtil );
312  }
313  else if( interface_type == typeid( WriteUtilIface ) )
314  {
315  if( !mMBWriteUtil ) mMBWriteUtil = new WriteUtil( this );
316  ptr = static_cast< WriteUtilIface* >( mMBWriteUtil );
317  }
318  else if( interface_type == typeid( ReaderWriterSet ) )
319  {
320  ptr = reader_writer_set();
321  }
322  else if( interface_type == typeid( Error ) )
323  {
324  ptr = mError;
325  }
326  else if( interface_type == typeid( ExoIIInterface ) )
327  {
328  ptr = static_cast< ExoIIInterface* >( new ExoIIUtil( this ) );
329  }
330  else if( interface_type == typeid( ScdInterface ) )
331  {
332  if( !scdInterface ) scdInterface = new ScdInterface( this );
333  ptr = scdInterface;
334  }
335  else
336  {
337  ptr = 0;
338  return MB_FAILURE;
339  }
340  return MB_SUCCESS;
341 }

References MB_SUCCESS.

◆ QueryInterface()

int moab::Core::QueryInterface ( const MBuuid uuid,
UnknownInterface **  iface 
)
virtual

Implements moab::UnknownInterface.

Definition at line 355 of file Core.cpp.

356 {
357  *iface = 0;
358  if( uuid == IDD_MBUnknown ) *iface = this;
359  if( uuid == IDD_MBCore )
360  *iface = this;
361  else
362  return 0;
363  return 1;
364 }

References moab::IDD_MBCore, moab::IDD_MBUnknown, and iface.

Referenced by moab::ComponentFactory::QueryInterface().

◆ reader_writer_set()

ReaderWriterSet* moab::Core::reader_writer_set ( )
inline

return set of registered IO tools

Definition at line 1090 of file Core.hpp.

1091  {
1092  return readerWriterSet;
1093  }

References readerWriterSet.

◆ release_interface_type()

ErrorCode moab::Core::release_interface_type ( const std::type_info &  interface_type,
void *  iface 
)
virtual

Release reference to MB interface.

Implements moab::Interface.

Definition at line 343 of file Core.cpp.

344 {
345  if( interface_type == typeid( ExoIIInterface ) )
346  delete static_cast< ExoIIInterface* >( iface );
347  else if( interface_type != typeid( ReadUtilIface ) && interface_type != typeid( WriteUtilIface ) &&
348  interface_type != typeid( ReaderWriterSet ) && interface_type != typeid( Error ) &&
349  interface_type != typeid( ScdInterface ) )
350  return MB_FAILURE;
351 
352  return MB_SUCCESS;
353 }

References iface, and MB_SUCCESS.

◆ remove_child_meshset()

ErrorCode moab::Core::remove_child_meshset ( EntityHandle  meshset,
const EntityHandle  child_meshset 
)
virtual

remove child meshset

Implements moab::Interface.

Definition at line 3674 of file Core.cpp.

3675 {
3676  MeshSet* set_ptr = get_mesh_set( sequence_manager(), meshset );
3677  if( !set_ptr ) return MB_ENTITY_NOT_FOUND;
3678  set_ptr->remove_child( child_meshset );
3679  return MB_SUCCESS;
3680 }

References moab::get_mesh_set(), MB_ENTITY_NOT_FOUND, MB_SUCCESS, and moab::MeshSet::remove_child().

◆ remove_entities() [1/2]

ErrorCode moab::Core::remove_entities ( EntityHandle  meshset,
const EntityHandle entities,
const int  num_entities 
)
virtual

remove entities from meshset

remove a vector of entities from a meshset

Implements moab::Interface.

Definition at line 3439 of file Core.cpp.

3440 {
3441  MeshSet* set = get_mesh_set( sequence_manager(), meshset );
3442  if( set )
3443  return set->remove_entities( entities, num_entities, meshset, a_entity_factory() );
3444  else
3445  return MB_ENTITY_NOT_FOUND;
3446 }

References moab::get_mesh_set(), MB_ENTITY_NOT_FOUND, and moab::MeshSet::remove_entities().

◆ remove_entities() [2/2]

ErrorCode moab::Core::remove_entities ( EntityHandle  meshset,
const Range entities 
)
virtual

remove entities from meshset

remove a range of entities from a meshset

Implements moab::Interface.

Definition at line 3429 of file Core.cpp.

3430 {
3431  MeshSet* set = get_mesh_set( sequence_manager(), meshset );
3432  if( set )
3433  return set->remove_entities( entities, meshset, a_entity_factory() );
3434  else
3435  return MB_ENTITY_NOT_FOUND;
3436 }

References moab::get_mesh_set(), MB_ENTITY_NOT_FOUND, and moab::MeshSet::remove_entities().

Referenced by main(), moab::AEntityFactory::remove_adjacency(), moab::ReorderTool::update_set_contents(), and moab::NestedRefine::update_special_tags().

◆ remove_parent_child()

ErrorCode moab::Core::remove_parent_child ( EntityHandle  parent,
EntityHandle  child 
)
virtual

removes 'parent' to child's parent list and removes 'child' to parent's child list

Implements moab::Interface.

Definition at line 3655 of file Core.cpp.

3656 {
3657  MeshSet* parent_ptr = get_mesh_set( sequence_manager(), parent );
3658  MeshSet* child_ptr = get_mesh_set( sequence_manager(), child );
3659  if( !parent_ptr || !child_ptr ) return MB_ENTITY_NOT_FOUND;
3660 
3661  parent_ptr->remove_child( child );
3662  child_ptr->remove_parent( parent );
3663  return MB_SUCCESS;
3664 }

References moab::get_mesh_set(), MB_ENTITY_NOT_FOUND, MB_SUCCESS, moab::MeshSet::remove_child(), and moab::MeshSet::remove_parent().

◆ remove_parent_meshset()

ErrorCode moab::Core::remove_parent_meshset ( EntityHandle  meshset,
const EntityHandle  parent_meshset 
)
virtual

remove parent meshset

Implements moab::Interface.

Definition at line 3666 of file Core.cpp.

3667 {
3668  MeshSet* set_ptr = get_mesh_set( sequence_manager(), meshset );
3669  if( !set_ptr ) return MB_ENTITY_NOT_FOUND;
3670  set_ptr->remove_parent( parent_meshset );
3671  return MB_SUCCESS;
3672 }

References moab::get_mesh_set(), MB_ENTITY_NOT_FOUND, MB_SUCCESS, and moab::MeshSet::remove_parent().

◆ remove_set_iterator()

ErrorCode moab::Core::remove_set_iterator ( SetIterator set_iter)

Remove the set iterator from the instance's list.

Remove the set iterator from the instance's list This function is called from the SetIterator destructor, and should not be called directly from anywhere else.

Parameters
set_iterSet iterator being removed

Definition at line 3970 of file Core.cpp.

3971 {
3972  std::vector< SetIterator* >::iterator vit = std::find( setIterators.begin(), setIterators.end(), set_iter );
3973  if( vit == setIterators.end() )
3974  {
3975  MB_SET_ERR( MB_FAILURE, "Didn't find that iterator" );
3976  }
3977 
3978  setIterators.erase( vit );
3979 
3980  return MB_SUCCESS;
3981 }

References MB_SET_ERR, and MB_SUCCESS.

Referenced by moab::SetIterator::~SetIterator().

◆ replace_entities()

ErrorCode moab::Core::replace_entities ( EntityHandle  meshset,
const EntityHandle old_entities,
const EntityHandle new_entities,
int  num_entities 
)
virtual

replace entities

Implements moab::Interface.

Definition at line 3463 of file Core.cpp.

3467 {
3468  MeshSet* set = get_mesh_set( sequence_manager(), meshset );
3469  if( set )
3470  return set->replace_entities( meshset, old_entities, new_entities, num_entities, a_entity_factory() );
3471  else
3472  return MB_ENTITY_NOT_FOUND;
3473 }

References moab::get_mesh_set(), MB_ENTITY_NOT_FOUND, and moab::MeshSet::replace_entities().

Referenced by moab::AEntityFactory::merge_adjust_adjacencies().

◆ sequence_manager() [1/2]

◆ sequence_manager() [2/2]

const SequenceManager* moab::Core::sequence_manager ( ) const
inline

Definition at line 1043 of file Core.hpp.

1044  {
1045  return sequenceManager;
1046  }

References sequenceManager.

◆ serial_load_file()

ErrorCode moab::Core::serial_load_file ( const char *  file_name,
const EntityHandle file_set,
const FileOptions opts,
const ReaderIface::SubsetList subsets = 0,
const Tag file_id_tag = 0 
)

Load or import a file.

Definition at line 513 of file Core.cpp.

518 {
519  int status;
520 #if defined( WIN32 ) || defined( WIN64 ) || defined( MSC_VER )
521  struct _stat stat_data;
522  status = _stat( file_name, &stat_data );
523 #else
524  struct stat stat_data;
525  status = stat( file_name, &stat_data );
526 #endif
527  if( status )
528  {
529  MB_SET_GLB_ERR( MB_FILE_DOES_NOT_EXIST, file_name << ": " << strerror( errno ) );
530  }
531 #if defined( WIN32 ) || defined( WIN64 ) || defined( MSC_VER )
532  else if( stat_data.st_mode & _S_IFDIR )
533  {
534 #else
535  else if( S_ISDIR( stat_data.st_mode ) )
536  {
537 #endif
538  MB_SET_GLB_ERR( MB_FILE_DOES_NOT_EXIST, file_name << ": Cannot read directory/folder" );
539  }
540 
541  const ReaderWriterSet* set = reader_writer_set();
542 
543  Range initial_ents;
544  MB_CHK_SET_ERR( get_entities_by_handle( 0, initial_ents ), "can't get entities by handle" );
545 
546  std::vector< Tag > initial_tags;
547  MB_CHK_SET_ERR( tag_get_tags( initial_tags ), "can't get tags" );
548 
549  // otherwise try using the file extension to select a reader
550  std::string ext = set->extension_from_filename( file_name );
551 
552  // Try all the readers
554  ErrorCode rval = MB_FAILURE;
555  bool tried_one = false;
556  for( iter = set->begin(); iter != set->end(); ++iter )
557  {
558  if( !iter->reads_extension( ext.c_str() ) ) continue;
559 
560  ReaderIface* reader = iter->make_reader( this );
561  if( NULL != reader )
562  {
563  tried_one = true;
564  rval = reader->load_file( file_name, file_set, opts, subsets, id_tag );
565  delete reader;
566  if( MB_SUCCESS == rval ) break;
567  clean_up_failed_read( initial_ents, initial_tags );
568  }
569  }
570 
571  if( MB_SUCCESS != rval && !tried_one )
572  {
573  // didn't recognize the extension; try all of them now
574  for( iter = set->begin(); iter != set->end(); ++iter )
575  {
576  ReaderIface* reader = iter->make_reader( this );
577  if( !reader ) continue;
578  rval = reader->load_file( file_name, file_set, opts, subsets, id_tag );
579  delete reader;
580  if( MB_SUCCESS == rval ) break;
581  clean_up_failed_read( initial_ents, initial_tags );
582  }
583  }
584 
585  if( MB_SUCCESS != rval )
586  {
587  clean_up_failed_read( initial_ents, initial_tags );
588  MB_SET_ERR( rval, "Failed to load file after trying all possible readers" );
589  }
590  else if( file_set )
591  {
592  Range new_ents;
593  get_entities_by_handle( 0, new_ents );
594  new_ents = subtract( new_ents, initial_ents );
595 
596  // Check if gather set exists
597  EntityHandle gather_set;
598  rval = mMBReadUtil->get_gather_set( gather_set );
599  if( MB_SUCCESS == rval )
600  {
601  // Exclude gather set itself
602  new_ents.erase( gather_set );
603 
604  // Exclude gather set entities
605  Range gather_ents;
606  rval = get_entities_by_handle( gather_set, gather_ents );
607  if( MB_SUCCESS == rval ) new_ents = subtract( new_ents, gather_ents );
608  }
609 
610  rval = add_entities( *file_set, new_ents );
611  }
612 
613  return rval;
614 } // namespace moab

References moab::ReaderWriterSet::begin(), moab::ReaderWriterSet::end(), moab::Range::erase(), ErrorCode, moab::ReaderWriterSet::extension_from_filename(), moab::ReaderIface::load_file(), MB_CHK_SET_ERR, MB_FILE_DOES_NOT_EXIST, MB_SET_ERR, MB_SET_GLB_ERR, MB_SUCCESS, and moab::subtract().

Referenced by moab::ReadParallel::load_file().

◆ serial_read_tag()

ErrorCode moab::Core::serial_read_tag ( const char *  file_name,
const char *  tag_name,
const FileOptions opts,
std::vector< int > &  tag_vals,
const ReaderIface::SubsetList subsets = 0 
)

Definition at line 616 of file Core.cpp.

621 {
622  ErrorCode rval = MB_FAILURE;
623  const ReaderWriterSet* set = reader_writer_set();
624 
625  // otherwise try using the file extension to select a reader
626  ReaderIface* reader = set->get_file_extension_reader( file_name );
627  if( reader )
628  {
629  rval = reader->read_tag_values( file_name, tag_name, opts, vals, subsets );
630  delete reader;
631  }
632  else
633  {
634  // Try all the readers
636  for( iter = set->begin(); iter != set->end(); ++iter )
637  {
638  reader = iter->make_reader( this );
639  if( NULL != reader )
640  {
641  rval = reader->read_tag_values( file_name, tag_name, opts, vals, subsets );
642  delete reader;
643  if( MB_SUCCESS == rval ) break;
644  }
645  }
646  }
647 
648  return rval;
649 }

References moab::ReaderWriterSet::begin(), moab::ReaderWriterSet::end(), ErrorCode, moab::ReaderWriterSet::get_file_extension_reader(), MB_SUCCESS, and moab::ReaderIface::read_tag_values().

◆ set_connectivity()

ErrorCode moab::Core::set_connectivity ( const EntityHandle  entity_handle,
EntityHandle connect,
const int  num_connect 
)
virtual

Sets the connectivity for an EntityHandle. For non-element handles, return an error.

set the connectivity for element handles. For non-element handles, return an error

Connectivity is stored exactly as it is ordered in vector connectivity.

Parameters
entity_handleEntityHandle to set connectivity of.
connectVector containing new connectivity of entity_handle.
num_connectNumber of vertices in connect

Example:

std::vector<EntityHandle> conn(3);
conn[0] = node1;
conn[1] = node2;
conn[2] = node3;
set_connectivity( entity_handle, conn, 3 );

Implements moab::Interface.

Definition at line 1221 of file Core.cpp.

1222 {
1223  ErrorCode status = MB_FAILURE;
1224 
1225  // Make sure the entity should have a connectivity.
1226  // WARNING: This is very dependent on the ordering of the EntityType enum
1227  EntityType entity_type = TYPE_FROM_HANDLE( entity_handle );
1228 
1229  EntitySequence* seq = 0;
1230 
1231  if( entity_type < MBVERTEX || entity_type > MBENTITYSET ) return MB_TYPE_OUT_OF_RANGE;
1232 
1233  status = sequence_manager()->find( entity_handle, seq );
1234  if( seq == 0 || status != MB_SUCCESS ) return ( status != MB_SUCCESS ? status : MB_ENTITY_NOT_FOUND );
1235 
1236  const EntityHandle* old_conn;
1237  int len;
1238  status = static_cast< ElementSequence* >( seq )->get_connectivity( entity_handle, old_conn, len );
1239  MB_CHK_ERR( status );
1240 
1241  aEntityFactory->notify_change_connectivity( entity_handle, old_conn, connect, num_connect );
1242 
1243  status = static_cast< ElementSequence* >( seq )->set_connectivity( entity_handle, connect, num_connect );
1244  if( status != MB_SUCCESS )
1245  aEntityFactory->notify_change_connectivity( entity_handle, connect, old_conn, num_connect );
1246 
1247  return status;
1248 }

References ErrorCode, MB_CHK_ERR, MB_ENTITY_NOT_FOUND, MB_SUCCESS, MB_TYPE_OUT_OF_RANGE, MBENTITYSET, and moab::TYPE_FROM_HANDLE().

Referenced by moab::AEntityFactory::merge_adjust_adjacencies(), and moab::ReorderTool::reorder_entities().

◆ set_coords() [1/2]

ErrorCode moab::Core::set_coords ( const EntityHandle entity_handles,
const int  num_entities,
const double *  coords 
)
virtual

set the coordinate information for this handle if it is of type Vertex otherwise, return an error

Implements moab::Interface.

Examples
mbex4.cpp.

Definition at line 1053 of file Core.cpp.

1054 {
1055 
1056  ErrorCode status = MB_SUCCESS;
1057 
1058  int i, j = 0;
1059 
1060  for( i = 0; i < num_entities; i++ )
1061  {
1062  if( TYPE_FROM_HANDLE( entity_handles[i] ) == MBVERTEX )
1063  {
1064  EntitySequence* seq = 0;
1065  status = sequence_manager()->find( entity_handles[i], seq );
1066 
1067  if( seq != 0 && status == MB_SUCCESS )
1068  {
1069  status = static_cast< VertexSequence* >( seq )->set_coordinates( entity_handles[i], coords[j],
1070  coords[j + 1], coords[j + 2] );
1071  j += 3;
1072  }
1073  }
1074  else if( status == MB_SUCCESS )
1075  status = MB_TYPE_OUT_OF_RANGE;
1076  }
1077 
1078  return status;
1079 }

References ErrorCode, MB_SUCCESS, MB_TYPE_OUT_OF_RANGE, MBVERTEX, and moab::TYPE_FROM_HANDLE().

Referenced by main(), perform_laplacian_smoothing(), perform_lloyd_relaxation(), and moab::ReorderTool::reorder_entities().

◆ set_coords() [2/2]

ErrorCode moab::Core::set_coords ( Range  entity_handles,
const double *  coords 
)
virtual

set the coordinate information for this handle if it is of type Vertex otherwise, return an error

Implements moab::Interface.

Definition at line 1083 of file Core.cpp.

1084 {
1085 
1086  ErrorCode status = MB_SUCCESS;
1087 
1088  int j = 0;
1089 
1090  for( Range::iterator rit = entity_handles.begin(); rit != entity_handles.end(); ++rit )
1091  {
1092  if( TYPE_FROM_HANDLE( *rit ) == MBVERTEX )
1093  {
1094  EntitySequence* seq = 0;
1095  status = sequence_manager()->find( *rit, seq );
1096 
1097  if( seq != 0 && status == MB_SUCCESS )
1098  {
1099  status = static_cast< VertexSequence* >( seq )->set_coordinates( *rit, coords[j], coords[j + 1],
1100  coords[j + 2] );
1101  j += 3;
1102  }
1103  }
1104  else if( status == MB_SUCCESS )
1105  status = MB_TYPE_OUT_OF_RANGE;
1106  }
1107 
1108  return status;
1109 }

References moab::Range::begin(), moab::Range::end(), ErrorCode, MB_SUCCESS, MB_TYPE_OUT_OF_RANGE, MBVERTEX, and moab::TYPE_FROM_HANDLE().

◆ set_dimension()

ErrorCode moab::Core::set_dimension ( const int  dim)
virtual

set overall geometric dimension

Returns error if setting to 3 dimensions, mesh has been created, and there are only 2 dimensions on that mesh

Implements moab::Interface.

Definition at line 778 of file Core.cpp.

779 {
780  // check to see if current dimension is smaller
781  if( geometricDimension < dim )
782  {
783  // need to check the number of entities
784  int num;
785  /*ErrorCode result = */ get_number_entities_by_dimension( 0, geometricDimension, num );
786 
787  // test written to be more readable but possibly less efficient
788  // if (MB_SUCCESS != result) return MB_FAILURE;
789  // else if (0 != num && dim == 2 && ycoordTag == 0) return MB_FAILURE;
790  // else if (0 != num && dim == 3 && (ycoordTag == 0 || zcoordTag == 0)) return MB_FAILURE;
791  // TODO -- replace this with not using xcoordTag, etc...
792  }
793 
794  // if we got here, it's ok to set dimension
795  geometricDimension = dim;
796  return MB_SUCCESS;
797 }

References MB_SUCCESS.

◆ set_meshset_options()

ErrorCode moab::Core::set_meshset_options ( const EntityHandle  ms_handle,
const unsigned int  options 
)
virtual

set the options of a mesh set

Implements moab::Interface.

Definition at line 3345 of file Core.cpp.

3346 {
3347  MeshSet* set = get_mesh_set( sequence_manager(), ms_handle );
3348  if( !set ) return MB_ENTITY_NOT_FOUND;
3349 
3350  return set->set_flags( setoptions, ms_handle, a_entity_factory() );
3351 }

References moab::get_mesh_set(), MB_ENTITY_NOT_FOUND, and moab::MeshSet::set_flags().

◆ set_sequence_multiplier()

void moab::Core::set_sequence_multiplier ( double  factor)
virtual

Interface to control memory allocation for sequences Provide a factor that controls the size of the sequence that gets allocated. This is typically useful in the parallel setting when a-priori, the number of ghost entities and the memory required for them within the same sequence as the owned entities are unknown. The default factor is 1.0 but this can be appropriately updated at runtime so that we do not have broken sequences.

Parameters
meshsetUser specified multiplier (should be greater than 1.0)

Implements moab::Interface.

Definition at line 1116 of file Core.cpp.

1117 {
1118  assert( factor >= 1.0 );
1120 }

◆ side_element()

ErrorCode moab::Core::side_element ( const EntityHandle  source_entity,
const int  dim,
const int  sd_number,
EntityHandle target_entity 
) const
virtual

given an entity and a target dimension & side number, get that entity

Implements moab::Interface.

Definition at line 3271 of file Core.cpp.

3275 {
3276  // get a handle on the connectivity
3277  const EntityHandle* verts;
3278  int num_verts;
3279  ErrorCode result = get_connectivity( source_entity, verts, num_verts );
3280  MB_CHK_ERR( result );
3281 
3282  // special case for vertices
3283  if( dim == 0 )
3284  {
3285  if( sd_number < num_verts )
3286  {
3287  target_entity = verts[sd_number];
3288  return MB_SUCCESS;
3289  }
3290 
3291  else
3292  return MB_INDEX_OUT_OF_RANGE;
3293  }
3294 
3295  // get the vertices comprising the target entity
3296  Range side_verts, target_ents;
3297  const EntityType source_type = TYPE_FROM_HANDLE( source_entity );
3298  // first get the indices
3299  std::vector< int > vertex_indices;
3300 
3301  int temp_result = CN::AdjacentSubEntities( source_type, &sd_number, 1, dim, 0, vertex_indices );
3302  if( 0 != temp_result ) return MB_FAILURE;
3303  // now get the actual vertices
3304  for( unsigned int i = 0; i < vertex_indices.size(); i++ )
3305  side_verts.insert( verts[vertex_indices[i]] );
3306 
3307  // now look for an entity of the correct type
3308  // use const_cast here 'cuz we're in a const function and we're passing 'false' for
3309  // create_if_missing, so we know we won't change anything
3310  result = ( const_cast< Core* >( this ) )->get_adjacencies( side_verts, dim, false, target_ents );
3311  if( MB_SUCCESS != result && MB_MULTIPLE_ENTITIES_FOUND != result ) return result;
3312 
3313  if( !target_ents.empty() && TYPE_FROM_HANDLE( *( target_ents.begin() ) ) != MBVERTEX &&
3314  TYPE_FROM_HANDLE( *( target_ents.begin() ) ) !=
3315  CN::mConnectivityMap[source_type][dim - 1].target_type[sd_number] )
3316  return MB_ENTITY_NOT_FOUND;
3317 
3318  if( !target_ents.empty() ) target_entity = *( target_ents.begin() );
3319 
3320  return result;
3321 }

References moab::CN::AdjacentSubEntities(), moab::Range::begin(), moab::Range::empty(), ErrorCode, moab::Range::insert(), MB_CHK_ERR, MB_ENTITY_NOT_FOUND, MB_INDEX_OUT_OF_RANGE, MB_MULTIPLE_ENTITIES_FOUND, MB_SUCCESS, MBVERTEX, moab::CN::mConnectivityMap, moab::CN::ConnMap::target_type, and moab::TYPE_FROM_HANDLE().

Referenced by moab::HigherOrderFactory::tag_for_deletion().

◆ side_number()

ErrorCode moab::Core::side_number ( const EntityHandle  parent,
const EntityHandle  child,
int &  sd_number,
int &  sense,
int &  offset 
) const
virtual

function to get the side number given two elements; returns MB_FAILURE if child not related to parent; does not create adjacencies between parent and child

Implements moab::Interface.

Definition at line 3075 of file Core.cpp.

3080 {
3081  // get the connectivity of parent and child
3082  const EntityHandle *parent_conn = NULL, *child_conn = NULL;
3083  int num_parent_vertices = 0, num_child_vertices = 0;
3084  ErrorCode result = get_connectivity( parent, parent_conn, num_parent_vertices, true );
3085  if( MB_NOT_IMPLEMENTED == result )
3086  {
3087  static std::vector< EntityHandle > tmp_connect( CN::MAX_NODES_PER_ELEMENT );
3088  result = get_connectivity( parent, parent_conn, num_parent_vertices, true, &tmp_connect );
3089  }
3090  if( MB_SUCCESS != result ) return result;
3091 
3092  if( TYPE_FROM_HANDLE( child ) == MBVERTEX )
3093  {
3094  int child_index = std::find( parent_conn, parent_conn + num_parent_vertices, child ) - parent_conn;
3095  if( child_index == num_parent_vertices )
3096  {
3097  sd_number = -1;
3098  sense = 0;
3099  return MB_FAILURE;
3100  }
3101  else
3102  {
3103  sd_number = child_index;
3104  sense = 1;
3105  return MB_SUCCESS;
3106  }
3107  }
3108 
3109  if( TYPE_FROM_HANDLE( parent ) == MBPOLYHEDRON )
3110  {
3111  // find the child in the parent_conn connectivity list, and call it a day ..
3112  // it should work only for faces within a conn list
3113  for( int i = 0; i < num_parent_vertices; i++ )
3114  if( child == parent_conn[i] )
3115  {
3116  sd_number = i;
3117  sense = 1; // always
3118  offset = 0;
3119  return MB_SUCCESS;
3120  }
3121  return MB_FAILURE;
3122  }
3123  result = get_connectivity( child, child_conn, num_child_vertices, true );
3124  MB_CHK_ERR( result );
3125 
3126  // call handle vector-based function
3127  if( TYPE_FROM_HANDLE( parent ) != MBPOLYGON && TYPE_FROM_HANDLE( parent ) != MBPOLYHEDRON )
3128  {
3129 
3130  // find indices into parent_conn for each entry in child_conn
3131  int child_conn_indices[10];
3132  assert( (unsigned)num_child_vertices <= sizeof( child_conn_indices ) / sizeof( child_conn_indices[0] ) );
3133  for( int i = 0; i < num_child_vertices; ++i )
3134  {
3135  child_conn_indices[i] =
3136  std::find( parent_conn, parent_conn + num_parent_vertices, child_conn[i] ) - parent_conn;
3137  if( child_conn_indices[i] >= num_parent_vertices )
3138  {
3139  sd_number = -1;
3140  return MB_FAILURE;
3141  }
3142  }
3143 
3144  int temp_result = CN::SideNumber( TYPE_FROM_HANDLE( parent ), child_conn_indices, num_child_vertices,
3145  CN::Dimension( TYPE_FROM_HANDLE( child ) ), sd_number, sense, offset );
3146  return ( 0 == temp_result ? MB_SUCCESS : MB_FAILURE );
3147  }
3148  else if( TYPE_FROM_HANDLE( parent ) == MBPOLYGON )
3149  {
3150  // find location of 1st vertex; this works even for padded vertices
3151  const EntityHandle* first_v = std::find( parent_conn, parent_conn + num_parent_vertices, child_conn[0] );
3152  if( first_v == parent_conn + num_parent_vertices ) return MB_ENTITY_NOT_FOUND;
3153  sd_number = first_v - parent_conn;
3154  offset = sd_number;
3155  if( TYPE_FROM_HANDLE( child ) == MBVERTEX )
3156  {
3157  sense = 0;
3158  return MB_SUCCESS;
3159  }
3160  else if( TYPE_FROM_HANDLE( child ) == MBPOLYGON )
3161  {
3162  bool match = CN::ConnectivityMatch( parent_conn, child_conn, num_parent_vertices, sense, offset );
3163  sd_number = 0;
3164  if( match )
3165  return MB_SUCCESS;
3166  else
3167  return MB_ENTITY_NOT_FOUND;
3168  }
3169  else if( TYPE_FROM_HANDLE( child ) == MBEDGE )
3170  {
3171  // determine the actual number of vertices, for the padded case
3172  // the padded case could be like ABCDEFFF; num_parent_vertices=8,
3173  // actual_num_parent_vertices=6
3174  int actual_num_parent_vertices = num_parent_vertices;
3175  while( actual_num_parent_vertices >= 3 &&
3176  ( parent_conn[actual_num_parent_vertices - 2] == parent_conn[actual_num_parent_vertices - 1] ) )
3177  actual_num_parent_vertices--;
3178 
3179  if( parent_conn[( sd_number + 1 ) % num_parent_vertices] == child_conn[1] )
3180  sense = 1;
3181  else if( parent_conn[( sd_number + num_parent_vertices - 1 ) % num_parent_vertices] ==
3182  child_conn[1] ) // this will also cover edge AF for padded case, side will
3183  // be 0, sense -1
3184  sense = -1;
3185  // if edge FA in above example, we should return sd_number = 5, sense 1
3186  else if( ( sd_number == actual_num_parent_vertices - 1 ) && ( child_conn[1] == parent_conn[0] ) )
3187  sense = 1;
3188  else
3189  return MB_ENTITY_NOT_FOUND;
3190  return MB_SUCCESS;
3191  }
3192  }
3193 
3194  return MB_FAILURE;
3195 }

References moab::CN::ConnectivityMatch(), moab::CN::Dimension(), ErrorCode, moab::CN::MAX_NODES_PER_ELEMENT, MB_CHK_ERR, MB_ENTITY_NOT_FOUND, MB_NOT_IMPLEMENTED, MB_SUCCESS, MBEDGE, MBPOLYGON, MBPOLYHEDRON, MBVERTEX, moab::CN::SideNumber(), and moab::TYPE_FROM_HANDLE().

◆ subtract_meshset()

ErrorCode moab::Core::subtract_meshset ( EntityHandle  meshset1,
const EntityHandle  meshset2 
)
virtual

subtracts meshset2 from meshset1 - modifies meshset1

Implements moab::Interface.

Definition at line 3383 of file Core.cpp.

3384 {
3385  MeshSet* set1 = get_mesh_set( sequence_manager(), meshset1 );
3386  MeshSet* set2 = get_mesh_set( sequence_manager(), meshset2 );
3387  if( !set1 || !set2 ) return MB_ENTITY_NOT_FOUND;
3388 
3389  return set1->subtract( set2, meshset1, a_entity_factory() );
3390 }

References moab::get_mesh_set(), MB_ENTITY_NOT_FOUND, and moab::MeshSet::subtract().

◆ tag_clear_data() [1/2]

ErrorCode moab::Core::tag_clear_data ( Tag  tag_handle,
const EntityHandle entity_handles,
int  num_entities,
const void *  tag_data,
int  tag_size = 0 
)
virtual

Set tag data given value.

set the data for given EntityHandles and Tag

For a tag, set the values for a list of passed entity handles to the same, specified value.

Parameters
tag_handleThe tag
entity_handlesThe entity handles for which to set tag values.
tag_dataA pointer to the tag value.
tag_sizesFor variable-length tags, the lenght of the tag value. This argument will be ignored for fixed-length tags.

Implements moab::Interface.

Definition at line 2305 of file Core.cpp.

2310 {
2311  assert( valid_tag_handle( tag_handle ) );
2313  return tag_handle->clear_data( sequenceManager, mError, entity_handles, num_entities, tag_data,
2314  tag_size * TagInfo::size_from_data_type( tag_handle->get_data_type() ) );
2315 }

References CHECK_MESH_NULL, moab::TagInfo::clear_data(), moab::TagInfo::get_data_type(), and moab::TagInfo::size_from_data_type().

◆ tag_clear_data() [2/2]

ErrorCode moab::Core::tag_clear_data ( Tag  tag_handle,
const Range entity_handles,
const void *  tag_data,
int  tag_size = 0 
)
virtual

Set tag data given value.

set the data for given EntityHandles and Tag

For a tag, set the values for a list of passed entity handles to the same, specified value.

Parameters
tag_handleThe tag
entity_handlesThe entity handles for which to set tag values.
tag_dataA pointer to the tag value.
tag_sizesFor variable-length tags, the lenght of the tag value. This argument will be ignored for fixed-length tags.

Implements moab::Interface.

Definition at line 2318 of file Core.cpp.

2319 {
2320  assert( valid_tag_handle( tag_handle ) );
2321  return tag_handle->clear_data( sequenceManager, mError, entity_handles, tag_data,
2322  tag_size * TagInfo::size_from_data_type( tag_handle->get_data_type() ) );
2323 }

References moab::TagInfo::clear_data(), moab::TagInfo::get_data_type(), and moab::TagInfo::size_from_data_type().

◆ tag_delete()

ErrorCode moab::Core::tag_delete ( Tag  tag_handle)
virtual

Removes the tag from the database and deletes all of its associated data.

removes the tag from MB

Implements moab::Interface.

Definition at line 2523 of file Core.cpp.

2524 {
2525  std::list< TagInfo* >::iterator i = std::find( tagList.begin(), tagList.end(), tag_handle );
2526  if( i == tagList.end() ) return MB_TAG_NOT_FOUND;
2527 
2528  MB_CHK_SET_ERR( tag_handle->release_all_data( sequenceManager, mError, true ), "can't release all data" );
2529 
2530  tagList.erase( i );
2531  delete tag_handle;
2532  return MB_SUCCESS;
2533 }

References MB_CHK_SET_ERR, MB_SUCCESS, MB_TAG_NOT_FOUND, and moab::TagInfo::release_all_data().

Referenced by moab::HigherOrderFactory::convert_sequence(), moab::WriteUtil::gather_nodes_from_elements(), moab::ReorderTool::handle_order_from_int_tag(), moab::ReorderTool::handle_order_from_sets_and_adj(), main(), and perform_lloyd_relaxation().

◆ tag_delete_data() [1/2]

ErrorCode moab::Core::tag_delete_data ( Tag  tag_handle,
const EntityHandle entity_handles,
int  num_entities 
)
virtual

Delete the data of a vector of entity handles and sparse tag.

removes the tag from the entity

Delete the data of a tag on a vector of entity handles. Only sparse tag data are deleted with this function; dense tags are deleted by deleting the tag itself using tag_delete.

Parameters
tag_handleHandle of the (sparse) tag being deleted from entity
entity_handles1d vector of entity handles from which the tag is being deleted
num_handlesNumber of entity handles in 1d vector

Implements moab::Interface.

Definition at line 2508 of file Core.cpp.

2509 {
2510  assert( valid_tag_handle( tag_handle ) );
2512  return tag_handle->remove_data( sequenceManager, mError, entity_handles, num_entities );
2513 }

References CHECK_MESH_NULL, and moab::TagInfo::remove_data().

Referenced by process_partition_file(), and moab::ReorderTool::reorder_tag_data().

◆ tag_delete_data() [2/2]

ErrorCode moab::Core::tag_delete_data ( Tag  tag_handle,
const Range entity_handles 
)
virtual

Delete the data of a range of entity handles and sparse tag.

removes the tag from the entity

Delete the data of a tag on a range of entity handles. Only sparse tag data are deleted with this function; dense tags are deleted by deleting the tag itself using tag_delete.

Parameters
tag_handleHandle of the (sparse) tag being deleted from entity
entity_rangeRange of entities from which the tag is being deleted

Implements moab::Interface.

Definition at line 2516 of file Core.cpp.

2517 {
2518  assert( valid_tag_handle( tag_handle ) );
2519  return tag_handle->remove_data( sequenceManager, mError, entity_handles );
2520 }

References moab::TagInfo::remove_data().

◆ tag_get_by_ptr() [1/2]

ErrorCode moab::Core::tag_get_by_ptr ( const Tag  tag_handle,
const EntityHandle entity_handles,
int  num_entities,
const void **  tag_data,
int *  tag_sizes = 0 
) const
virtual

Get pointers to tag data.

return the tag data for a given EntityHandle and Tag

For a tag, get the values for a list of passed entity handles.

Note
This function may not be used for bit tags.
Parameters
tag_handleThe tag
entity_handlesAn array of entity handles for which to retreive tag values.
num_entitiesThe length of the 'entity_handles' array.
tag_dataAn array of 'const void*'. Array must be at least 'num_entitities' long. Array is populated (output) with pointers to the internal storage for the tag value corresponding to each entity handle.
tag_sizesThe length of each tag value. Optional for fixed-length tags. Required for variable-length tags.

Implements moab::Interface.

Definition at line 2228 of file Core.cpp.

2233 {
2234  assert( valid_tag_handle( tag_handle ) );
2236  ErrorCode result =
2237  tag_handle->get_data( sequenceManager, mError, entity_handles, num_entities, tag_data, tag_sizes );
2238  int typesize = TagInfo::size_from_data_type( tag_handle->get_data_type() );
2239  if( tag_sizes && typesize != 1 )
2240  for( int i = 0; i < num_entities; ++i )
2241  tag_sizes[i] /= typesize;
2242  return result;
2243 }

References CHECK_MESH_NULL, ErrorCode, moab::TagInfo::get_data(), moab::TagInfo::get_data_type(), and moab::TagInfo::size_from_data_type().

Referenced by moab::ReorderTool::reorder_tag_data(), and test_spectral_hex().

◆ tag_get_by_ptr() [2/2]

ErrorCode moab::Core::tag_get_by_ptr ( const Tag  tag_handle,
const Range entity_handles,
const void **  tag_data,
int *  tag_sizes = 0 
) const
virtual

Get pointers to tag data.

return the tag data for a given EntityHandle and Tag

For a tag, get the values for a list of passed entity handles.

Note
This function may not be used for bit tags.
Parameters
tag_handleThe tag
entity_handlesThe entity handles for which to retreive tag values.
tag_dataAn array of 'const void*'. Array is populated (output) with pointers to the internal storage for the tag value corresponding to each entity handle.
tag_sizesThe length of each tag value. Optional for fixed-length tags. Required for variable-length tags.

Implements moab::Interface.

Definition at line 2246 of file Core.cpp.

2250 {
2251  assert( valid_tag_handle( tag_handle ) );
2252  ErrorCode result = tag_handle->get_data( sequenceManager, mError, entity_handles, tag_data, tag_sizes );
2253  int typesize = TagInfo::size_from_data_type( tag_handle->get_data_type() );
2254  if( tag_sizes && typesize != 1 )
2255  {
2256  int num_entities = entity_handles.size();
2257  for( int i = 0; i < num_entities; ++i )
2258  tag_sizes[i] /= typesize;
2259  }
2260  return result;
2261 }

References ErrorCode, moab::TagInfo::get_data(), moab::TagInfo::get_data_type(), moab::Range::size(), and moab::TagInfo::size_from_data_type().

◆ tag_get_bytes()

ErrorCode moab::Core::tag_get_bytes ( const Tag  tag,
int &  tag_size 
) const
virtual

Get the size of the specified tag in bytes.

get size of tag in bytes

Implements moab::Interface.

Definition at line 2563 of file Core.cpp.

2564 {
2565  if( !valid_tag_handle( tag_handle ) ) return MB_TAG_NOT_FOUND;
2566 
2567  if( tag_handle->variable_length() )
2568  {
2569  tag_size = MB_VARIABLE_LENGTH;
2570  return MB_VARIABLE_DATA_LENGTH;
2571  }
2572  else if( tag_handle->get_storage_type() == MB_TAG_BIT )
2573  {
2574  tag_size = 1;
2575  return MB_SUCCESS;
2576  }
2577  else
2578  {
2579  tag_size = tag_handle->get_size();
2580  return MB_SUCCESS;
2581  }
2582 }

References moab::TagInfo::get_size(), moab::TagInfo::get_storage_type(), MB_SUCCESS, MB_TAG_BIT, MB_TAG_NOT_FOUND, MB_VARIABLE_DATA_LENGTH, MB_VARIABLE_LENGTH, and moab::TagInfo::variable_length().

Referenced by moab::check_int_tag(), main(), and moab::ReorderTool::reorder_tag_data().

◆ tag_get_data() [1/2]

◆ tag_get_data() [2/2]

ErrorCode moab::Core::tag_get_data ( const Tag  tag_handle,
const Range entity_handles,
void *  tag_data 
) const
virtual

return the tag data for a given EntityHandle and Tag

Implements moab::Interface.

Definition at line 2203 of file Core.cpp.

2204 {
2205  assert( valid_tag_handle( tag_handle ) );
2206  return tag_handle->get_data( sequenceManager, mError, entity_handles, tag_data );
2207 }

References moab::TagInfo::get_data().

◆ tag_get_data_type()

ErrorCode moab::Core::tag_get_data_type ( const Tag  handle,
DataType type 
) const
virtual

Get data type of tag.

Get the type of the tag data. The tag is data is assumed to be a vector of this type. If the tag data vetcor contains more than one value, then the tag size must be a multiple of the size of this type.

Parameters
tagThe tag
typeThe type of the specified tag (output).

Implements moab::Interface.

Definition at line 2601 of file Core.cpp.

2602 {
2603  if( !valid_tag_handle( handle ) ) return MB_TAG_NOT_FOUND;
2604 
2605  data_type = handle->get_data_type();
2606  return MB_SUCCESS;
2607 }

References moab::TagInfo::get_data_type(), MB_SUCCESS, and MB_TAG_NOT_FOUND.

Referenced by moab::check_int_tag(), main(), and moab::ReorderTool::reorder_tag_data().

◆ tag_get_default_value() [1/2]

ErrorCode moab::Core::tag_get_default_value ( const Tag  tag,
void *  def_val 
) const
virtual

Get the default value of the specified tag.

get default value of the tag

Implements moab::Interface.

Definition at line 2610 of file Core.cpp.

2611 {
2612  if( !valid_tag_handle( tag_handle ) ) return MB_TAG_NOT_FOUND;
2613 
2614  if( tag_handle->variable_length() ) return MB_VARIABLE_DATA_LENGTH;
2615 
2616  if( !tag_handle->get_default_value() ) return MB_ENTITY_NOT_FOUND;
2617 
2618  memcpy( def_value, tag_handle->get_default_value(), tag_handle->get_default_value_size() );
2619  return MB_SUCCESS;
2620 }

References moab::TagInfo::get_default_value(), moab::TagInfo::get_default_value_size(), MB_ENTITY_NOT_FOUND, MB_SUCCESS, MB_TAG_NOT_FOUND, MB_VARIABLE_DATA_LENGTH, and moab::TagInfo::variable_length().

Referenced by main(), and moab::ReorderTool::reorder_entities().

◆ tag_get_default_value() [2/2]

ErrorCode moab::Core::tag_get_default_value ( Tag  tag,
const void *&  def_val,
int &  size 
) const
virtual

Get a tag handle, possibly creating the tag.

Get a handle used to associate application-defined values with MOAB entities. If the tag does not already exist then flags should contain exactly one of MB_TAG_SPARSE, MB_TAG_DENSE, MB_TAG_MESH unless type is MB_TYPE_BIT, which implies MB_TAG_BIT storage.

Parameters
nameThe tag name
sizeTag size as number of values of of data type per entity (or number of bytes if MB_TAG_BYTES is passed in flags). If MB_TAG_VARLEN is specified, this value is taken to be the size of the default value if one is specified and is otherwise ignored.
typeThe type of the data (used for IO)
tag_handleOutput: the resulting tag handle.
flagsBitwise OR of values from TagType
default_valueOptional default value for tag.
createdOptional returned boolean indicating that the tag was created.
Returns
- MB_ALREADY_ALLOCATED if tag exists and MB_TAG_EXCL is specified, or default values do not match (and MB_TAG_ANY or MB_TAG_DFTOK not specified).
  • MB_TAG_NOT_FOUND if tag does not exist and MB_TAG_CREAT is not specified
  • MB_INVALID_SIZE if tag value size is not a multiple of the size of the data type (and MB_TAG_ANY not specified).
  • MB_TYPE_OUT_OF_RANGE invalid or inconsistent parameter
  • MB_VARIABLE_DATA_LENGTH if MB_TAG_VARLEN and default_value is non-null and default_value_size is not specified.
Note
A call to tag_get_handle that includes a default value will fail if the tag already exists with a different default value. A call without a default value will succeed if the tag already exists, regardless of whether or not the existing tag has a default value.

Examples:

Retrieve a handle for an existing tag, returning a non-success error code if the tag does not exist or does not store 1 integer value per entity:

Tag git_tag;
mb.tag_get_handle( GLOBAL_ID_TAG_NAME, 1, MB_TYPE_INTEGER, gid_tag );

Get the tag handle, or create it as a dense tag if it does not already exist:

Tag gid_tag;
);

Create the tag or fail if it already exists:

Tag gid_tag;
);

Get an existing variable length tag, failing if it does not exist or is not variable-length or does not contain double values.

Tag vtag; mb.tag_get_handle(
*tag_name, 0, MB_TYPE_DOUBLE, vtag );

Get the same variable-length tag, but create it with a default value if it doesn't exist. Note that if the tag already exists this call will return a non-success error code if the existing tag has a different default value.

*vtag; const double default_val = M_PI; const int def_val_len = 1; mb.tag_get_handle( tag_name,
*def_val_len, MB_TYPE_DOUBLE, vtag, MB_TAG_SPARSE|MB_TAG_VARLEN|MB_TAG_CREAT, &default_val );

Implements moab::Interface.

Definition at line 2622 of file Core.cpp.

2623 {
2624  if( !valid_tag_handle( tag ) ) return MB_ENTITY_NOT_FOUND;
2625 
2626  if( !tag->get_default_value() ) return MB_ENTITY_NOT_FOUND;
2627 
2628  ptr = tag->get_default_value();
2630  return MB_SUCCESS;
2631 }

References moab::TagInfo::get_data_type(), moab::TagInfo::get_default_value(), moab::TagInfo::get_default_value_size(), MB_ENTITY_NOT_FOUND, MB_SUCCESS, and moab::TagInfo::size_from_data_type().

◆ tag_get_handle() [1/3]

ErrorCode moab::Core::tag_get_handle ( const char *  name,
int  size,
DataType  type,
Tag tag_handle,
unsigned  flags = 0,
const void *  default_value = 0 
) const
virtual

same as non-const version, except that TAG_CREAT flag is ignored.

Implements moab::Interface.

Definition at line 2473 of file Core.cpp.

2479 {
2480  // If caller specified MB_TAG_EXCL, then we must fail because
2481  // this const function can never create a tag. We need to test
2482  // this here because the non-const version of this function
2483  // assumes MB_TAG_CREAT if MB_TAG_EXCL is specified.
2484  if( flags & MB_TAG_EXCL )
2485  {
2486  // anonymous tag?
2487  if( !name || !*name ) return MB_TAG_NOT_FOUND;
2488 
2489  // search for an existing tag
2490  tag_handle = 0;
2491  for( std::list< Tag >::const_iterator i = tagList.begin(); i != tagList.end(); ++i )
2492  {
2493  if( ( *i )->get_name() == name )
2494  {
2495  tag_handle = *i;
2496  return MB_ALREADY_ALLOCATED;
2497  }
2498  }
2499 
2500  return MB_TAG_NOT_FOUND;
2501  }
2502 
2503  return const_cast< Core* >( this )->tag_get_handle( name, size, data_type, tag_handle,
2504  flags & ~(unsigned)MB_TAG_CREAT, default_value );
2505 }

References MB_ALREADY_ALLOCATED, MB_TAG_CREAT, MB_TAG_EXCL, and MB_TAG_NOT_FOUND.

◆ tag_get_handle() [2/3]

ErrorCode moab::Core::tag_get_handle ( const char *  name,
int  size,
DataType  type,
Tag tag_handle,
unsigned  flags = 0,
const void *  default_value = 0,
bool *  created = 0 
)
virtual

Get a tag handle, possibly creating the tag.

Get a handle used to associate application-defined values with MOAB entities. If the tag does not already exist then flags should contain exactly one of MB_TAG_SPARSE, MB_TAG_DENSE, MB_TAG_MESH unless type is MB_TYPE_BIT, which implies MB_TAG_BIT storage.

Parameters
nameThe tag name
sizeTag size as number of values of of data type per entity (or number of bytes if MB_TAG_BYTES is passed in flags). If MB_TAG_VARLEN is specified, this value is taken to be the size of the default value if one is specified and is otherwise ignored.
typeThe type of the data (used for IO)
tag_handleOutput: the resulting tag handle.
flagsBitwise OR of values from TagType
default_valueOptional default value for tag.
createdOptional returned boolean indicating that the tag was created.
Returns
- MB_ALREADY_ALLOCATED if tag exists and MB_TAG_EXCL is specified, or default values do not match (and MB_TAG_ANY or MB_TAG_DFTOK not specified).
  • MB_TAG_NOT_FOUND if tag does not exist and MB_TAG_CREAT is not specified
  • MB_INVALID_SIZE if tag value size is not a multiple of the size of the data type (and MB_TAG_ANY not specified).
  • MB_TYPE_OUT_OF_RANGE invalid or inconsistent parameter
  • MB_VARIABLE_DATA_LENGTH if MB_TAG_VARLEN and default_value is non-null and default_value_size is not specified.

Implements moab::Interface.

Examples
CoupleMGen.cpp, ExchangeHalos.cpp, and mbex4.cpp.

Definition at line 2334 of file Core.cpp.

2341 {
2342  if( created ) *created = false;
2343 
2344  // we always work with sizes in bytes internally
2345  if( !( ( flags & MB_TAG_VARLEN ) && size == MB_VARIABLE_LENGTH ) )
2346  {
2347  if( flags & MB_TAG_BYTES )
2348  {
2349  if( size % TagInfo::size_from_data_type( data_type ) ) return MB_INVALID_SIZE;
2350  }
2351  else
2352  {
2353  size *= TagInfo::size_from_data_type( data_type );
2354  }
2355  }
2356 
2357  const TagType storage = static_cast< TagType >( flags & 3 );
2358 
2359  // search for an existing tag
2360  tag_handle = 0;
2361  if( name && *name )
2362  { // not anonymous tag
2363  for( std::list< Tag >::iterator i = tagList.begin(); i != tagList.end(); ++i )
2364  {
2365  if( ( *i )->get_name() == name )
2366  {
2367  tag_handle = *i;
2368  break;
2369  }
2370  }
2371  }
2372 
2373  if( tag_handle )
2374  {
2375  if( flags & MB_TAG_EXCL ) return MB_ALREADY_ALLOCATED;
2376  // user asked that we not check anything
2377  if( flags & MB_TAG_ANY ) return MB_SUCCESS;
2378  // user asked that we also match storage types
2379  if( ( flags & MB_TAG_STORE ) && tag_handle->get_storage_type() != storage ) return MB_TYPE_OUT_OF_RANGE;
2380  // check if data type matches
2381  const DataType extype = tag_handle->get_data_type();
2382  if( extype != data_type )
2383  {
2384  if( flags & MB_TAG_NOOPQ )
2385  return MB_TYPE_OUT_OF_RANGE;
2386  else if( extype != MB_TYPE_OPAQUE && data_type != MB_TYPE_OPAQUE )
2387  return MB_TYPE_OUT_OF_RANGE;
2388  }
2389 
2390  // Require that the size value be zero or MB_VARIABLE_LENGTH
2391  // for variable length tags. The caller passing such a size
2392  // value is sufficient to indicate that the caller is aware
2393  // that it is requesting a variable-length tag, so no need
2394  // to also require/check the MB_TAG_VARLEN bit in the flags.
2395  if( tag_handle->variable_length() )
2396  {
2397  if( size != 0 && size != MB_VARIABLE_LENGTH && !( flags & MB_TAG_VARLEN ) ) return MB_INVALID_SIZE;
2398  }
2399  // But /do/ fail if MB_TAG_VARLEN flag is set and tag is
2400  // not variable length.
2401  else if( flags & MB_TAG_VARLEN )
2402  return MB_TYPE_OUT_OF_RANGE;
2403  // check size for fixed-length tag
2404  else if( tag_handle->get_size() != size )
2405  return MB_INVALID_SIZE;
2406 
2407  // If user passed a default value, check that it matches.
2408  // If user did not pass a default value, assume they're OK
2409  // with the existing one.
2410  // If tag does not have a default value but the user passed
2411  // one, allow it only if the tag is dense and the passed value
2412  // is all zero bytes because dense tags have an implicit default
2413  // value of all zeros in some cases.
2414  if( default_value && !( flags & MB_TAG_DFTOK ) &&
2415  !( tag_handle->equals_default_value( default_value, size ) ||
2416  ( !tag_handle->get_default_value() && tag_handle->get_storage_type() == MB_TAG_DENSE &&
2417  is_zero_bytes( default_value, size ) ) ) )
2418  return MB_ALREADY_ALLOCATED;
2419 
2420  return MB_SUCCESS;
2421  }
2422 
2423  // MB_TAG_EXCL implies MB_TAG_CREAT
2424  if( !( flags & ( MB_TAG_CREAT | MB_TAG_EXCL ) ) ) return MB_TAG_NOT_FOUND;
2425 
2426  // if a non-opaque non-bit type was specified, then the size
2427  // must be multiple of the size of the type
2428  if( ( !( flags & MB_TAG_VARLEN ) || default_value ) &&
2429  ( size <= 0 || ( size % TagInfo::size_from_data_type( data_type ) ) != 0 ) )
2430  return MB_INVALID_SIZE;
2431 
2432  // if MB_TYPE_BIT may be used only with MB_TAG_BIT
2433  // if (storage != MB_TAG_BIT && data_type == MB_TYPE_BIT)
2434  // return MB_INVALID_ARG;
2435  if( data_type == MB_TYPE_BIT ) flags &= ~(unsigned)( MB_TAG_DENSE | MB_TAG_SPARSE );
2436 
2437  // create the tag
2438  switch( flags & ( MB_TAG_DENSE | MB_TAG_SPARSE | MB_TAG_MESH | MB_TAG_VARLEN ) )
2439  {
2440  case MB_TAG_DENSE | MB_TAG_VARLEN:
2441  tag_handle = VarLenDenseTag::create_tag( sequenceManager, mError, name, data_type, default_value, size );
2442  break;
2443  case MB_TAG_DENSE:
2444  tag_handle = DenseTag::create_tag( sequenceManager, mError, name, size, data_type, default_value );
2445  break;
2447  tag_handle = new VarLenSparseTag( name, data_type, default_value, size );
2448  break;
2449  case MB_TAG_SPARSE:
2450  tag_handle = new SparseTag( name, size, data_type, default_value );
2451  break;
2452  case MB_TAG_MESH | MB_TAG_VARLEN:
2453  tag_handle = new MeshTag( name, MB_VARIABLE_LENGTH, data_type, default_value, size );
2454  break;
2455  case MB_TAG_MESH:
2456  tag_handle = new MeshTag( name, size, data_type, default_value, size );
2457  break;
2458  case MB_TAG_BIT:
2459  if( MB_TYPE_BIT != data_type && MB_TYPE_OPAQUE != data_type ) return MB_TYPE_OUT_OF_RANGE;
2460  tag_handle = BitTag::create_tag( name, size, default_value );
2461  break;
2462  default: // some illegal combination (multiple storage types, variable-length bit tag, etc.)
2463  return MB_TYPE_OUT_OF_RANGE;
2464  }
2465 
2466  if( !tag_handle ) return MB_INVALID_SIZE;
2467 
2468  if( created ) *created = true;
2469  tagList.push_back( tag_handle );
2470  return MB_SUCCESS;
2471 }

References moab::BitTag::create_tag(), moab::DenseTag::create_tag(), moab::VarLenDenseTag::create_tag(), moab::TagInfo::equals_default_value(), moab::TagInfo::get_data_type(), moab::TagInfo::get_default_value(), moab::TagInfo::get_size(), moab::TagInfo::get_storage_type(), moab::is_zero_bytes(), MB_ALREADY_ALLOCATED, MB_INVALID_SIZE, MB_SUCCESS, MB_TAG_ANY, MB_TAG_BIT, MB_TAG_BYTES, MB_TAG_CREAT, MB_TAG_DENSE, MB_TAG_EXCL, MB_TAG_MESH, MB_TAG_NOOPQ, MB_TAG_NOT_FOUND, MB_TAG_SPARSE, MB_TAG_STORE, MB_TAG_VARLEN, MB_TYPE_BIT, MB_TYPE_OPAQUE, MB_TYPE_OUT_OF_RANGE, MB_VARIABLE_LENGTH, moab::TagInfo::size_from_data_type(), TagType, and moab::TagInfo::variable_length().

Referenced by moab::HigherOrderFactory::convert_sequence(), moab::ReadUtil::create_gather_set(), moab::NestedRefine::create_hm_storage_single_level(), RuntimeContext::create_sv_tags(), moab::WriteUtil::gather_nodes_from_elements(), moab::NestedRefine::generate_hm(), moab::ReadUtil::get_gather_set(), moab::ReorderTool::handle_order_from_int_tag(), moab::ReorderTool::handle_order_from_sets_and_adj(), moab::ReadParallel::load_file(), main(), obbvis_create(), perform_laplacian_smoothing(), perform_lloyd_relaxation(), process_partition_file(), test_spectral_hex(), TestErrorHandling_4(), and moab::NestedRefine::update_special_tags().

◆ tag_get_handle() [3/3]

ErrorCode moab::Core::tag_get_handle ( const char *  tag_name,
Tag tag_handle 
) const
virtual

Gets the tag handle corresponding to a name.

If a tag of that name does not exist, returns MB_TAG_NOT_FOUND

Parameters
tag_nameName of the desired tag.
tag_handleTag handle corresponding to tag_name

Implements moab::Interface.

Definition at line 2557 of file Core.cpp.

2558 {
2559  return tag_get_handle( tag_name, 0, MB_TYPE_OPAQUE, tag_handle, MB_TAG_ANY );
2560 }

References MB_TAG_ANY, and MB_TYPE_OPAQUE.

◆ tag_get_length()

ErrorCode moab::Core::tag_get_length ( const Tag  tag,
int &  tag_size 
) const
virtual

Get the array length of a tag.

get size of tag in $values

Implements moab::Interface.

Definition at line 2585 of file Core.cpp.

2586 {
2587  if( !valid_tag_handle( tag_handle ) ) return MB_TAG_NOT_FOUND;
2588 
2589  if( tag_handle->variable_length() )
2590  {
2591  tag_size = MB_VARIABLE_LENGTH;
2592  return MB_VARIABLE_DATA_LENGTH;
2593  }
2594  else
2595  {
2596  tag_size = tag_handle->get_size() / TagInfo::size_from_data_type( tag_handle->get_data_type() );
2597  return MB_SUCCESS;
2598  }
2599 }

References moab::TagInfo::get_data_type(), moab::TagInfo::get_size(), MB_SUCCESS, MB_TAG_NOT_FOUND, MB_VARIABLE_DATA_LENGTH, MB_VARIABLE_LENGTH, moab::TagInfo::size_from_data_type(), and moab::TagInfo::variable_length().

Referenced by moab::WriteUtil::get_tag_list(), and main().

◆ tag_get_name()

ErrorCode moab::Core::tag_get_name ( const Tag  tag_handle,
std::string &  tag_name 
) const
virtual

Gets the tag name string of the tag_handle.

gets the tag name string for the tag_handle

Parameters
tag_handleTag you want the name of.
tag_nameName string of tag_handle.

Example:

Tag tag_handle = 0;
std::string tag_name = "my_special_tag";
tag_get_name( tag_handle, tag_name ); //gets the Tag from the tag's name string

Implements moab::Interface.

Definition at line 2550 of file Core.cpp.

2551 {
2552  if( !valid_tag_handle( tag_handle ) ) return MB_TAG_NOT_FOUND;
2553  tag_name = tag_handle->get_name();
2554  return MB_SUCCESS;
2555 }

References moab::TagInfo::get_name(), MB_SUCCESS, and MB_TAG_NOT_FOUND.

Referenced by gather_tag_counts(), moab::WriteUtil::get_tag_list(), and main().

◆ tag_get_tags()

ErrorCode moab::Core::tag_get_tags ( std::vector< Tag > &  tag_handles) const
virtual

get handles for all tags defined

Implements moab::Interface.

Definition at line 2642 of file Core.cpp.

2643 {
2644  std::copy( tagList.begin(), tagList.end(), std::back_inserter( tag_handles ) );
2645  return MB_SUCCESS;
2646 }

References MB_SUCCESS.

Referenced by gather_tag_counts(), moab::WriteUtil::get_tag_list(), main(), and moab::ReorderTool::reorder_entities().

◆ tag_get_tags_on_entity()

ErrorCode moab::Core::tag_get_tags_on_entity ( const EntityHandle  entity,
std::vector< Tag > &  tag_handles 
) const
virtual

Get handles for all tags defined on this entity.

Implements moab::Interface.

Definition at line 2649 of file Core.cpp.

2650 {
2651  for( std::list< TagInfo* >::const_iterator i = tagList.begin(); i != tagList.end(); ++i )
2652  if( ( *i )->is_tagged( sequenceManager, entity ) ) tag_handles.push_back( *i );
2653  return MB_SUCCESS;
2654 }

References MB_SUCCESS.

◆ tag_get_type()

ErrorCode moab::Core::tag_get_type ( const Tag  tag_handle,
TagType tag_type 
) const
virtual

get type of tag (sparse, dense, etc.; 0 = dense, 1 = sparse, 2 = bit, 3 = mesh)

get type of tag (sparse, dense, etc.; 0 = dense, 1 = sparse, 2 = bit, 3 = static)

Implements moab::Interface.

Definition at line 2634 of file Core.cpp.

2635 {
2636  assert( valid_tag_handle( tag_handle ) );
2637  tag_type = tag_handle->get_storage_type();
2638  return MB_SUCCESS;
2639 }

References moab::TagInfo::get_storage_type(), and MB_SUCCESS.

Referenced by main().

◆ tag_iterate()

ErrorCode moab::Core::tag_iterate ( Tag  tag_handle,
Range::const_iterator  iter,
Range::const_iterator  end,
int &  count,
void *&  data_ptr,
bool  allocate = true 
)
virtual

Access tag data via direct pointer into contiguous blocks.

Iteratively obtain direct access to contiguous blocks of tag storage. This function cannot be used with bit tags because of the compressed bit storage. This function cannot be used with variable length tags because it does not provide a mechanism to determine the length of the value for each entity. This function may be used with sparse tags, but if it is used, it will return data for a single entity at a time.

Parameters
tag_handleThe handle of the tag for which to access data
iterThe first entity for which to return data.
endOne past the last entity for which data is desired.
countThe number of entities for which data was returned
data_ptrOutput: pointer to tag storage.
allocateIf true, space for this tag will be allocated, if not it wont
Note
If this function is called for entities for which no tag value has been set, but for which a default value exists, it will force the allocation of explicit storage for each such entity even though MOAB would normally not explicitly store tag values for such entities.

\Example:

Range ents; // range to iterate over
Tag tag; // tag for which to access data
int bytes;
ErrorCode err = mb.tag_get_size( tag, bytes );
if (err) { ... }
...
Range::iterator iter = ents.begin();
while (iter != ents.end()) {
int count;
// get contiguous block of tag dat
void* ptr;
err = mb.tag_iterate( tag, iter, ents.end(), count, ptr );
if (err) { ... }
// do something with tag data
process_Data( ptr, count );
// advance to next block of data
iter += count;
}

Implements moab::Interface.

Definition at line 2535 of file Core.cpp.

2541 {
2542  Range::const_iterator init = iter;
2543  assert( valid_tag_handle( tag_handle ) );
2544  ErrorCode result = tag_handle->tag_iterate( sequenceManager, mError, iter, end, data_ptr, allocate );
2545  if( MB_SUCCESS == result ) count = iter - init;
2546  return result;
2547 }

References ErrorCode, MB_SUCCESS, and moab::TagInfo::tag_iterate().

Referenced by main(), and TestErrorHandling_4().

◆ tag_set_by_ptr() [1/2]

ErrorCode moab::Core::tag_set_by_ptr ( Tag  tag_handle,
const EntityHandle entity_handles,
int  num_entities,
void const *const *  tag_data,
const int *  tag_sizes = 0 
)
virtual

Set tag data given an array of pointers to tag values.

set the data for given EntityHandles and Tag

For a tag, set the values for a list of passed entity handles.

Note
This function may not be used for bit tags.
Parameters
tag_handleThe tag
entity_handlesAn array of entity handles for which to set tag values.
num_entitiesThe length of the 'entity_handles' array.
tag_dataAn array of 'const void*'. Array must be at least 'num_entitities' long. Array is expected to contain pointers to tag values for the corresponding EntityHandle in 'entity_handles'.
tag_sizesThe length of each tag value. Optional for fixed-length tags. Required for variable-length tags.

Implements moab::Interface.

Definition at line 2264 of file Core.cpp.

2269 {
2270  assert( valid_tag_handle( tag_handle ) );
2272  std::vector< int > tmp_sizes;
2273  int typesize = TagInfo::size_from_data_type( tag_handle->get_data_type() );
2274  if( typesize != 1 && tag_sizes )
2275  {
2276  tmp_sizes.resize( num_entities );
2277  for( int i = 0; i < num_entities; ++i )
2278  tmp_sizes[i] = tag_sizes[i] * typesize;
2279  tag_sizes = &tmp_sizes[0];
2280  }
2281  return tag_handle->set_data( sequenceManager, mError, entity_handles, num_entities, tag_data, tag_sizes );
2282 }

References CHECK_MESH_NULL, moab::TagInfo::get_data_type(), moab::TagInfo::set_data(), and moab::TagInfo::size_from_data_type().

Referenced by moab::ReorderTool::reorder_tag_data().

◆ tag_set_by_ptr() [2/2]

ErrorCode moab::Core::tag_set_by_ptr ( Tag  tag_handle,
const Range entity_handles,
void const *const *  tag_data,
const int *  tag_sizes = 0 
)
virtual

Set tag data given an array of pointers to tag values.

set the data for given EntityHandles and Tag

For a tag, set the values for a list of passed entity handles.

Note
This function may not be used for bit tags.
Parameters
tag_handleThe tag
entity_handlesThe entity handles for which to set tag values.
tag_dataAn array of 'const void*'. Array is expected to contain pointers to tag values for the corresponding EntityHandle in 'entity_handles'.
tag_sizesThe length of each tag value. Optional for fixed-length tags. Required for variable-length tags.

Implements moab::Interface.

Definition at line 2285 of file Core.cpp.

2289 {
2290  assert( valid_tag_handle( tag_handle ) );
2291  std::vector< int > tmp_sizes;
2292  int typesize = TagInfo::size_from_data_type( tag_handle->get_data_type() );
2293  if( typesize != 1 && tag_sizes )
2294  {
2295  int num_entities = entity_handles.size();
2296  tmp_sizes.resize( num_entities );
2297  for( int i = 0; i < num_entities; ++i )
2298  tmp_sizes[i] = tag_sizes[i] * typesize;
2299  tag_sizes = &tmp_sizes[0];
2300  }
2301  return tag_handle->set_data( sequenceManager, mError, entity_handles, tag_data, tag_sizes );
2302 }

References moab::TagInfo::get_data_type(), moab::TagInfo::set_data(), moab::Range::size(), and moab::TagInfo::size_from_data_type().

◆ tag_set_data() [1/2]

ErrorCode moab::Core::tag_set_data ( Tag  tag_handle,
const EntityHandle entity_handles,
int  num_entities,
const void *  tag_data 
)
virtual

Sets the data of a given EntityHandle and Tag.

set the data for given EntityHandles and Tag

If the tag_handle and the entity type of entity_handle are not compatible, data of entity_handle never existed and MB_FAILURE is returned.

Parameters
tag_handleTag indicating what data is to be set.
entity_handleEntityHandle on which to set tag's data.
tag_dataData to set the entity_handle's tag data to.

Example:

int tag_data = 1004;
tag_set_data( tag_handle, entity_handle, &tag_data );

Implements moab::Interface.

Examples
CoupleMGen.cpp, ExchangeHalos.cpp, and mbex4.cpp.

Definition at line 2210 of file Core.cpp.

2214 {
2215  assert( valid_tag_handle( tag_handle ) );
2217  return tag_handle->set_data( sequenceManager, mError, entity_handles, num_entities, tag_data );
2218 }

References CHECK_MESH_NULL, and moab::TagInfo::set_data().

Referenced by moab::WriteUtil::assign_ids(), moab::ReadUtil::assign_ids(), moab::ReadUtil::create_gather_set(), RuntimeContext::create_sv_tags(), moab::HalfFacetRep::determine_border_vertices(), moab::WriteUtil::gather_nodes_from_elements(), moab::WriteUtil::get_element_connect(), moab::WriteUtil::get_node_coords(), moab::ReorderTool::handle_order_from_int_tag(), moab::ReorderTool::int_order_from_sets_and_adj(), main(), obbvis_create(), perform_laplacian_smoothing(), perform_lloyd_relaxation(), process_partition_file(), moab::HigherOrderFactory::remove_ho_nodes(), moab::ReorderTool::reorder_tag_data(), and tag_depth().

◆ tag_set_data() [2/2]

ErrorCode moab::Core::tag_set_data ( Tag  tag_handle,
const Range entity_handles,
const void *  tag_data 
)
virtual

set the data for given EntityHandles and Tag

Implements moab::Interface.

Definition at line 2221 of file Core.cpp.

2222 {
2223  assert( valid_tag_handle( tag_handle ) );
2224  return tag_handle->set_data( sequenceManager, mError, entity_handles, tag_data );
2225 }

References moab::TagInfo::set_data().

◆ type_from_handle()

EntityType moab::Core::type_from_handle ( const EntityHandle  handle) const
virtual

get the type from a handle, returns type

Implements moab::Interface.

Definition at line 374 of file Core.cpp.

375 {
376  if( !handle ) // root set
377  return MBENTITYSET;
378  else
379  return TYPE_FROM_HANDLE( handle );
380 }

References MBENTITYSET, and moab::TYPE_FROM_HANDLE().

Referenced by moab::HalfFacetRep::add_cells_of_single_component(), moab::HalfFacetRep::another_halfedge(), moab::NestedRefine::child_to_parent(), moab::HalfFacetRep::collect_and_compare(), moab::NestedRefine::compute_coordinates(), moab::NestedRefine::construct_hm_2D(), moab::NestedRefine::construct_hm_3D(), moab::NestedRefine::create_hm_storage_single_level(), moab::HalfFacetRep::determine_border_vertices(), moab::HalfFacetRep::determine_incident_halfedges(), moab::HalfFacetRep::determine_sibling_halfedges(), moab::HalfFacetRep::determine_sibling_halffaces(), moab::NestedRefine::estimate_hm_storage(), moab::HalfFacetRep::find_matching_halfedge(), moab::HalfFacetRep::find_matching_halfface(), moab::HalfFacetRep::find_matching_implicit_edge_in_cell(), moab::HalfFacetRep::find_total_edges_2d(), moab::WriteUtil::gather_nodes_from_elements(), moab::NestedRefine::get_connectivity(), moab::HalfFacetRep::get_down_adjacencies_2d(), moab::HalfFacetRep::get_face_edges(), moab::HalfFacetRep::get_half_facet_in_comp(), moab::HalfFacetRep::get_index_in_lmap(), moab::HalfFacetRep::get_neighbor_adjacencies_2d(), moab::HalfFacetRep::get_neighbor_adjacencies_3d(), moab::HalfFacetRep::get_up_adjacencies_2d(), moab::HalfFacetRep::get_up_adjacencies_edg_3d(), moab::HalfFacetRep::get_up_adjacencies_edg_3d_comp(), moab::HalfFacetRep::get_up_adjacencies_face_3d(), moab::HalfFacetRep::get_up_adjacencies_vert_2d(), moab::HalfFacetRep::get_up_adjacencies_vert_3d(), moab::HalfFacetRep::init_surface(), moab::NestedRefine::initialize(), moab::NestedRefine::is_entity_on_boundary(), main(), moab::HalfFacetRep::mark_halfedges(), moab::NestedRefine::parent_to_child(), perform_laplacian_smoothing(), moab::HalfFacetRep::print_tags(), moab::HalfFacetRep::resize_hf_maps(), moab::NestedRefine::update_global_ahf_2D(), moab::NestedRefine::update_global_ahf_2D_sub(), moab::NestedRefine::update_global_ahf_3D(), moab::NestedRefine::update_special_tags(), and moab::NestedRefine::update_tracking_verts().

◆ unite_meshset()

ErrorCode moab::Core::unite_meshset ( EntityHandle  meshset1,
const EntityHandle  meshset2 
)
virtual

unites meshset2 with meshset1 - modifies meshset1

Implements moab::Interface.

Definition at line 3401 of file Core.cpp.

3402 {
3403  MeshSet* set1 = get_mesh_set( sequence_manager(), meshset1 );
3404  MeshSet* set2 = get_mesh_set( sequence_manager(), meshset2 );
3405  if( !set1 || !set2 ) return MB_ENTITY_NOT_FOUND;
3406 
3407  return set1->unite( set2, meshset1, a_entity_factory() );
3408 }

References moab::get_mesh_set(), MB_ENTITY_NOT_FOUND, and moab::MeshSet::unite().

◆ valid_tag_handle()

bool moab::Core::valid_tag_handle ( const TagInfo t) const
inlineprivate

Definition at line 1316 of file Core.hpp.

1317  {
1318  return std::find( tagList.begin(), tagList.end(), t ) != tagList.end();
1319  }

References tagList.

◆ write_file() [1/2]

ErrorCode moab::Core::write_file ( const char *  file_name,
const char *  file_type,
const char *  options,
const Range output_sets,
const Tag tag_list = 0,
int  num_tags = 0 
)
virtual

Write or export a file

Implements moab::Interface.

Definition at line 669 of file Core.cpp.

675 {
676  // convert range to vector
677  std::vector< EntityHandle > list( output_sets.size() );
678  std::copy( output_sets.begin(), output_sets.end(), list.begin() );
679 
680  // parse some options
681  FileOptions opts( options_string );
682  ErrorCode rval;
683 
684  rval = opts.get_null_option( "CREATE" );
685  if( rval == MB_TYPE_OUT_OF_RANGE )
686  {
687  MB_SET_GLB_ERR( MB_FAILURE, "Unexpected value for CREATE option" );
688  }
689  bool overwrite = ( rval == MB_ENTITY_NOT_FOUND );
690 
691  // Get the file writer
692  std::string ext = ReaderWriterSet::extension_from_filename( file_name );
693  std::vector< std::string > qa_records;
694  const EntityHandle* list_ptr = list.empty() ? (EntityHandle*)0 : &list[0];
695 
696  rval = MB_TYPE_OUT_OF_RANGE;
697 
698  // Try all possible writers
700  {
701 
702  if( ( file_type && !i->name().compare( file_type ) ) || i->writes_extension( ext.c_str() ) )
703  {
704 
705  WriterIface* writer = i->make_writer( this );
706 
707  // write the file
708  rval =
709  writer->write_file( file_name, overwrite, opts, list_ptr, list.size(), qa_records, tag_list, num_tags );
710  delete writer;
711  if( MB_SUCCESS == rval ) break;
712  printf( "Writer with name %s for file %s using extension %s (file type \"%s\") was "
713  "unsuccessful\n",
714  i->name().c_str(), file_name, ext.c_str(), file_type );
715  }
716  }
717 
718  if( file_type && rval == MB_TYPE_OUT_OF_RANGE )
719  {
720  MB_SET_ERR( rval, "Unrecognized file type \"" << file_type << "\"" );
721  }
722  // Should we use default writer (e.g. HDF5)?
723  else if( MB_SUCCESS != rval )
724  {
725  DefaultWriter writer( this );
726  printf( "Using default writer %s for file %s \n", DefaultWriterName, file_name );
727  rval = writer.write_file( file_name, overwrite, opts, list_ptr, list.size(), qa_records, tag_list, num_tags );
728  }
729 
730  if( MB_SUCCESS == rval && !opts.all_seen() )
731  {
732  std::string bad_opt;
733  if( MB_SUCCESS == opts.get_unseen_option( bad_opt ) )
734  {
735  MB_SET_ERR( MB_UNHANDLED_OPTION, "Unrecognized option: \"" << bad_opt << "\"" );
736  }
737  else
738  {
739  MB_SET_ERR( MB_UNHANDLED_OPTION, "Unrecognized option" );
740  }
741  }
742 
743  return MB_SUCCESS;
744 }

References moab::FileOptions::all_seen(), moab::Range::begin(), DefaultWriterName, moab::Range::end(), ErrorCode, moab::ReaderWriterSet::extension_from_filename(), moab::FileOptions::get_null_option(), moab::FileOptions::get_unseen_option(), MB_ENTITY_NOT_FOUND, MB_SET_ERR, MB_SET_GLB_ERR, MB_SUCCESS, MB_TYPE_OUT_OF_RANGE, MB_UNHANDLED_OPTION, moab::FileOptions::size(), moab::Range::size(), moab::WriterIface::write_file(), and moab::WriteHDF5::write_file().

◆ write_file() [2/2]

ErrorCode moab::Core::write_file ( const char *  file_name,
const char *  file_type = 0,
const char *  options = 0,
const EntityHandle output_sets = 0,
int  num_output_sets = 0,
const Tag tag_list = 0,
int  num_tags = 0 
)
virtual

Write or export a file.

Implements moab::Interface.

Examples
CoupleMGen.cpp, mbex1.cpp, mbex3.cpp, and mbex4.cpp.

Definition at line 656 of file Core.cpp.

663 {
664  Range range;
665  std::copy( output_sets, output_sets + num_output_sets, range_inserter( range ) );
666  return write_file( file_name, file_type, options_string, range, tag_list, num_tags );
667 }

Referenced by main(), obbvis_create(), and perform_laplacian_smoothing().

◆ write_mesh()

ErrorCode moab::Core::write_mesh ( const char *  file_name,
const EntityHandle output_list = NULL,
const int  num_sets = 0 
)
virtual

Writes mesh to a file.

Write mesh to file 'file_name'; if output_list is non-NULL, only material sets contained in that list will be written.

Parameters
file_nameName of file to write.
output_list1d array of material set handles to write; if NULL, all sets are written
num_setsNumber of sets in output_list array

Example:

EntityHandle output_list[] = {meshset1, meshset2, meshset3};
write_mesh( "output_file.gen", output_list, 3 );

Implements moab::Interface.

Definition at line 651 of file Core.cpp.

652 {
653  return write_file( file_name, 0, 0, output_list, num_sets );
654 }

Referenced by main().

Friends And Related Function Documentation

◆ SetIterator

friend class SetIterator
friend

Definition at line 53 of file Core.hpp.

Member Data Documentation

◆ aEntityFactory

AEntityFactory* moab::Core::aEntityFactory
private

Definition at line 1323 of file Core.hpp.

Referenced by a_entity_factory().

◆ dirichletBCTag

Tag moab::Core::dirichletBCTag
private

Definition at line 1310 of file Core.hpp.

◆ geomDimensionTag

Tag moab::Core::geomDimensionTag
private

Definition at line 1311 of file Core.hpp.

◆ geometricDimension

int moab::Core::geometricDimension
private

store the total number of elements defined in this interface

store the total number of nodes defined in this interface the overall geometric dimension of this mesh

Definition at line 1306 of file Core.hpp.

◆ globalIdTag

Tag moab::Core::globalIdTag
private

Definition at line 1312 of file Core.hpp.

◆ initErrorHandlerInCore

bool moab::Core::initErrorHandlerInCore
private

Definition at line 1330 of file Core.hpp.

◆ materialTag

Tag moab::Core::materialTag
private

Definition at line 1308 of file Core.hpp.

◆ mError

Error* moab::Core::mError
private

Definition at line 1327 of file Core.hpp.

◆ mMBReadUtil

ReadUtil* moab::Core::mMBReadUtil
private

Definition at line 1296 of file Core.hpp.

◆ mMBWriteUtil

WriteUtil* moab::Core::mMBWriteUtil
private

Definition at line 1295 of file Core.hpp.

◆ mpiFinalize

bool moab::Core::mpiFinalize
private

Definition at line 1328 of file Core.hpp.

◆ neumannBCTag

Tag moab::Core::neumannBCTag
private

Definition at line 1309 of file Core.hpp.

◆ readerWriterSet

ReaderWriterSet* moab::Core::readerWriterSet
private

Definition at line 1325 of file Core.hpp.

Referenced by reader_writer_set().

◆ scdInterface

ScdInterface* moab::Core::scdInterface
private

Definition at line 1297 of file Core.hpp.

◆ sequenceManager

SequenceManager* moab::Core::sequenceManager
private

Definition at line 1321 of file Core.hpp.

Referenced by sequence_manager().

◆ setIterators

std::vector< SetIterator* > moab::Core::setIterators
private

list of iterators

Definition at line 1333 of file Core.hpp.

◆ tagList

std::list< TagInfo* > moab::Core::tagList
private

tag server for this interface

Definition at line 1315 of file Core.hpp.

Referenced by valid_tag_handle().

◆ writeMPELog

int moab::Core::writeMPELog
private

Definition at line 1329 of file Core.hpp.


The documentation for this class was generated from the following files: