Branch data Line data Source code
1 : : /**
2 : : * MOAB, a Mesh-Oriented datABase, is a software component for creating,
3 : : * storing and accessing finite element mesh data.
4 : : *
5 : : * Copyright 2004 Sandia Corporation. Under the terms of Contract
6 : : * DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
7 : : * retains certain rights in this software.
8 : : *
9 : : * This library is free software; you can redistribute it and/or
10 : : * modify it under the terms of the GNU Lesser General Public
11 : : * License as published by the Free Software Foundation; either
12 : : * version 2.1 of the License, or (at your option) any later version.
13 : : *
14 : : */
15 : :
16 : : #ifndef MOAB_IMPL_GENERAL_HPP
17 : : #define MOAB_IMPL_GENERAL_HPP
18 : :
19 : : #include "moab/Interface.hpp"
20 : : #include "moab/ReaderIface.hpp"
21 : : #include <map>
22 : : #include <list>
23 : :
24 : : namespace moab
25 : : {
26 : :
27 : : class WriteUtil;
28 : : class ReadUtil;
29 : : class ScdInterface;
30 : : class AEntityFactory;
31 : : class SequenceManager;
32 : : class Error;
33 : : class HomCoord;
34 : : class ReaderWriterSet;
35 : : class EntitySequence;
36 : : class FileOptions;
37 : : class SetIterator;
38 : :
39 : : #ifdef MOAB_HAVE_AHF
40 : : class HalfFacetRep;
41 : : #endif
42 : :
43 : : /**\class Core
44 : : * \brief Implementation of MOAB Interface
45 : : * Implementation of the MOAB Interface class. You shouldn't call functions directly
46 : : * on an object of type Core (use Interface instead), unless you really have to access
47 : : * non-API functionality.
48 : : */
49 : : class Core : public Interface
50 : : {
51 : :
52 : : public:
53 : : friend class SetIterator;
54 : :
55 : : //! constructor
56 : : Core();
57 : :
58 : : //! destructor
59 : : ~Core();
60 : :
61 : : //! Get a pointer to an internal MOAB interface
62 : : //!\return NULL if not found, iterface pointer otherwise
63 : : virtual ErrorCode query_interface_type( const std::type_info& iface_type, void*& iface );
64 : :
65 : : //! Release reference to MB interface
66 : : virtual ErrorCode release_interface_type( const std::type_info& iface_type, void* iface );
67 : :
68 : : virtual int QueryInterface( const MBuuid& uuid, UnknownInterface** iface );
69 : :
70 : : //! Returns the major.minor version number of the implementation
71 : : /**
72 : : \param iface_name If non-NULL, will be filled in with a string, possibly
73 : : containing implementation-specific information
74 : : */
75 : : virtual float impl_version( std::string* version_string = NULL );
76 : :
77 : : //! get the type from a handle, returns type
78 : : virtual EntityType type_from_handle( const EntityHandle handle ) const;
79 : :
80 : : //! get the id from a handle, returns id
81 : : virtual EntityID id_from_handle( const EntityHandle handle ) const;
82 : :
83 : : //! get a handle from an id and type
84 : : virtual ErrorCode handle_from_id( const EntityType type, const EntityID id, EntityHandle& handle ) const;
85 : :
86 : : virtual int dimension_from_handle( const EntityHandle ) const;
87 : :
88 : : //! load mesh from data in file
89 : : //! NOTE: if there is mesh already present, the new mesh will be added
90 : : virtual ErrorCode load_mesh( const char* file_name, const int* active_block_id_list = NULL,
91 : : const int num_blocks = 0 );
92 : :
93 : : /**Load or import a file. */
94 : : virtual ErrorCode load_file( const char* file_name, const EntityHandle* file_set = 0, const char* options = 0,
95 : : const char* set_tag_name = 0, const int* set_tag_values = 0,
96 : : int num_set_tag_values = 0 );
97 : :
98 : : /**Load or import a file. */
99 : : ErrorCode serial_load_file( const char* file_name, const EntityHandle* file_set, const FileOptions& opts,
100 : : const ReaderIface::SubsetList* subset_list = 0, const Tag* file_id_tag = 0 );
101 : :
102 : : ErrorCode serial_read_tag( const char* file_name, const char* tag_name, const FileOptions& opts,
103 : : std::vector< int >& tag_vals, const ReaderIface::SubsetList* subset_list = 0 );
104 : :
105 : : virtual ErrorCode write_mesh( const char* file_name, const EntityHandle* output_list = NULL,
106 : : const int num_sets = 0 );
107 : : /** Write or export a file. */
108 : : virtual ErrorCode write_file( const char* file_name, const char* file_type = 0, const char* options = 0,
109 : : const EntityHandle* output_sets = 0, int num_output_sets = 0, const Tag* tag_list = 0,
110 : : int num_tags = 0 );
111 : :
112 : : /** Write or export a file */
113 : : virtual ErrorCode write_file( const char* file_name, const char* file_type, const char* options,
114 : : const Range& output_sets, const Tag* tag_list = 0, int num_tags = 0 );
115 : :
116 : : //! deletes all mesh entities from this datastore
117 : : virtual ErrorCode delete_mesh();
118 : :
119 : : //! get overall geometric dimension
120 : : virtual ErrorCode get_dimension( int& dim ) const;
121 : :
122 : : //! set overall geometric dimension
123 : : /** Returns error if setting to 3 dimensions, mesh has been created, and
124 : : * there are only 2 dimensions on that mesh
125 : : */
126 : : virtual ErrorCode set_dimension( const int dim );
127 : :
128 : : //! get blocked vertex coordinates for all vertices
129 : : /** Blocked = all x, then all y, etc.
130 : : */
131 : : virtual ErrorCode get_vertex_coordinates( std::vector< double >& coords ) const;
132 : :
133 : : //! get pointers to coordinate data
134 : : virtual ErrorCode coords_iterate( Range::const_iterator iter, Range::const_iterator end, double*& xcoords_ptr,
135 : : double*& ycoords_ptr, double*& zcoords_ptr, int& count );
136 : :
137 : : //! get the coordinate information for this handle if it is of type Vertex
138 : : //! otherwise, return an error
139 : : virtual ErrorCode get_coords( const Range& entity_handles, double* coords ) const;
140 : :
141 : : virtual ErrorCode get_coords( const EntityHandle* entity_handles, const int num_entities, double* coords ) const;
142 : :
143 : : virtual ErrorCode get_coords( const EntityHandle entity_handle, const double*& x, const double*& y,
144 : : const double*& z ) const;
145 : :
146 : : virtual ErrorCode get_coords( const Range& entity_handles, double* x_coords, double* y_coords,
147 : : double* z_coords ) const;
148 : :
149 : : //! set the coordinate information for this handle if it is of type Vertex
150 : : //! otherwise, return an error
151 : : virtual ErrorCode set_coords( const EntityHandle* entity_handles, const int num_entities, const double* coords );
152 : :
153 : : //! set the coordinate information for this handle if it is of type Vertex
154 : : //! otherwise, return an error
155 : : virtual ErrorCode set_coords( Range entity_handles, const double* coords );
156 : :
157 : : //! get global connectivity array for specified entity type
158 : : /** Assumes just vertices, no higher order nodes
159 : : */
160 : : virtual ErrorCode get_connectivity_by_type( const EntityType type, std::vector< EntityHandle >& connect ) const;
161 : :
162 : : //! get pointer to connectivity data
163 : : virtual ErrorCode connect_iterate( Range::const_iterator iter, Range::const_iterator end, EntityHandle*& connect,
164 : : int& verts_per_entity, int& count );
165 : :
166 : : //! Gets the connectivity for an element EntityHandle.
167 : : /** For non-element handles (ie, MeshSets),
168 : : * returns an error. Connectivity data is copied from the database into the vector
169 : : * <em>connectivity</em>. The nodes in <em>connectivity</em> are properly ordered.
170 : : * \param entity_handle EntityHandle to get connectivity of.
171 : : * \param connectivity Vector in which connectivity of <em>entity_handle</em> is returned.
172 : : * Should contain MeshVertices.
173 : : * \param corners_only If true, returns only corner vertices, otherwise returns all of them
174 : : * (including any higher-order vertices)
175 : : *
176 : : * Example: \code
177 : : * std::vector<EntityHandle> conn;
178 : : * get_connectivity( entity_handle, conn ); \endcode
179 : : */
180 : : virtual ErrorCode get_connectivity( const EntityHandle* entity_handles, const int num_handles,
181 : : std::vector< EntityHandle >& connectivity, bool corners_only = false,
182 : : std::vector< int >* offsets = NULL ) const;
183 : :
184 : : //! Gets the connectivity for a vector of elements
185 : : /** Same as vector-based version except range is returned (unordered!)
186 : : */
187 : : virtual ErrorCode get_connectivity( const EntityHandle* entity_handles, const int num_handles, Range& connectivity,
188 : : bool corners_only = false ) const;
189 : :
190 : : //! Gets the connectivity for elements
191 : : /** Same as vector-based version except range is returned (unordered!)
192 : : */
193 : : virtual ErrorCode get_connectivity( const Range& entity_handles, Range& connectivity,
194 : : bool corners_only = false ) const;
195 : :
196 : : //! Gets a pointer to constant connectivity data of <em>entity_handle</em>
197 : : /** Sets <em>number_nodes</em> equal to the number of nodes of the <em>
198 : : entity_handle </em>. Faster then the other <em>get_connectivity</em> function.
199 : : The nodes in 'connectivity' are properly ordered.
200 : : \param entity_handle EntityHandle to get connectivity of.
201 : : \param connectivity Array in which connectivity of <em>entity_handle</em> is returned.
202 : : Should contain MBVERTEX's.
203 : : \param num_nodes Number of MeshVertices in array <em>connectivity</em>.
204 : :
205 : : Example: \code
206 : : const EntityHandle* conn;
207 : : int number_nodes = 0;
208 : : get_connectivity( entity_handle, conn, number_nodes ); \endcode
209 : :
210 : : Example2: \code
211 : : std::vector<EntityHandle> sm_storage;
212 : : const EntityHandle* conn;
213 : : int number_nodes;
214 : : get_connectivity( handle, conn, number_nodes, false, &sm_storage );
215 : : if (conn == &sm_storage[0])
216 : : std::cout << "Structured mesh element" << std::endl;
217 : : \endcode
218 : : */
219 : : virtual ErrorCode get_connectivity( const EntityHandle entity_handle, const EntityHandle*& connectivity,
220 : : int& num_nodes, bool corners_only = false,
221 : : std::vector< EntityHandle >* storage = 0 ) const;
222 : :
223 : : //! Sets the connectivity for an EntityHandle. For non-element handles, return an error.
224 : : /** Connectivity is stored exactly as it is ordered in vector <em>connectivity</em>.
225 : : \param entity_handle EntityHandle to set connectivity of.
226 : : \param connect Vector containing new connectivity of <em>entity_handle</em>.
227 : : \param num_connect Number of vertices in <em>connect</em>
228 : :
229 : : Example: \code
230 : : std::vector<EntityHandle> conn(3);
231 : : conn[0] = node1;
232 : : conn[1] = node2;
233 : : conn[2] = node3;
234 : : set_connectivity( entity_handle, conn, 3 ); \endcode */
235 : : virtual ErrorCode set_connectivity( const EntityHandle entity_handle, EntityHandle* connect,
236 : : const int num_connect );
237 : :
238 : : //! get the adjacencies associated with a set of entities
239 : : /** \param from_entities vector of EntityHandle to get adjacencies of.
240 : : \param to_dimension Dimension of desired adjacency information.
241 : : \param adj_entities Vector in which adjacent EntityHandles are returned.
242 : : \param operation_type enum of INTERSECT or UNION. Defines whether to take
243 : : the intersection or union of the set of adjacencies recovered for the from_entities.
244 : :
245 : : The adjacent entities in vector <em>adjacencies</em> are not in any particular
246 : : order.
247 : :
248 : : Example: \code
249 : : // get the set of edges that are adjacent to all entities in the from_entities list
250 : : std::vector<EntityHandle> from_entities = {hex1, hex2};
251 : : std::vector<EntityHandle> adjacencies;
252 : : get_adjacencies( from_entities, MB_1D_ENTITY, adjacencies );
253 : : \endcode */
254 : :
255 : : virtual ErrorCode get_adjacencies( const EntityHandle* from_entities, const int num_entities,
256 : : const int to_dimension, const bool create_if_missing,
257 : : std::vector< EntityHandle >& adj_entities,
258 : : const int operation_type = Interface::INTERSECT );
259 : :
260 : : virtual ErrorCode get_adjacencies( const EntityHandle* from_entities, const int num_entities,
261 : : const int to_dimension, const bool create_if_missing, Range& adj_entities,
262 : : const int operation_type = Interface::INTERSECT );
263 : :
264 : : virtual ErrorCode get_adjacencies( const Range& from_entities, const int to_dimension, const bool create_if_missing,
265 : : Range& adj_entities, const int operation_type = Interface::INTERSECT );
266 : :
267 : : /**\brief Get a ptr to adjacency lists
268 : : * Get a pointer to adjacency lists. These lists are std::vector<EntityHandle>, which are
269 : : * pointed to by adjs[i]. Adjacencies are not guaranteed to be in order of increasing
270 : : * dimension. Only a const version of this function is given, because adjacency data is managed
271 : : * more carefully in MOAB and should be treated as read-only by applications. If adjacencies
272 : : * have not yet been initialized, adjs_ptr will be NULL (i.e. adjs_ptr == NULL). There may also
273 : : * be NULL entries for individual entities, i.e. adjs_ptr[i] == NULL. \param iter Iterator to
274 : : * beginning of entity range desired \param end End iterator for which adjacencies are requested
275 : : * \param adjs_ptr Pointer to pointer to const std::vector<EntityHandle>; each member of that
276 : : * array is the vector of adjacencies for this entity \param count Number of entities in the
277 : : * contiguous chunk starting from *iter
278 : : */
279 : : ErrorCode adjacencies_iterate( Range::const_iterator iter, Range::const_iterator end,
280 : : const std::vector< EntityHandle >**& adjs_ptr, int& count );
281 : :
282 : : /**\brief Get all vertices for input entities
283 : : *
284 : : * Special case of get_adjacencies where to_dimension == 0
285 : : * and operation_type == Interface::UNION.
286 : : *\Note This is not a variation of get_connectivity because
287 : : * the behavior is different for polyhedra.
288 : : */
289 : : virtual ErrorCode get_vertices( const Range& from_entities, Range& vertices );
290 : :
291 : : //! Adds adjacencies
292 : : /** \param from_handle entities
293 : : \param both_ways add the adjacency information to both the
294 : : to_handle and and the from_from :handle
295 : :
296 : : Example: \code
297 : : */
298 : : virtual ErrorCode add_adjacencies( const EntityHandle from_handle, const EntityHandle* to_handles,
299 : : const int num_handles, bool both_ways );
300 : :
301 : : //! Adds adjacencies; same as vector-based, but with range instead
302 : : virtual ErrorCode add_adjacencies( const EntityHandle from_handle, Range& adjacencies, bool both_ways );
303 : :
304 : : //! Removes adjacencies
305 : : /** \param handle EntityHandle to get adjacencies of.
306 : :
307 : : Example: \code
308 : : */
309 : : virtual ErrorCode remove_adjacencies( const EntityHandle from_handle, const EntityHandle* to_handles,
310 : : const int num_handles );
311 : :
312 : : //! Retrieves all entities in the database of given dimension.
313 : : /** \param dimension Dimension of entities desired.
314 : : \param entities Range in which entities of dimension <em>dimension</em> are returned.
315 : :
316 : : Example: \code
317 : : int dimension = 2;
318 : : Range entities;
319 : : get_entities_by_dimension( dimension, entities ); //get 2D EntityHandles in the database
320 : : \endcode */
321 : : virtual ErrorCode get_entities_by_dimension( const EntityHandle meshset, const int dimension, Range& entities,
322 : : const bool recursive = false ) const;
323 : :
324 : : virtual ErrorCode get_entities_by_dimension( const EntityHandle meshset, const int dimension,
325 : : std::vector< EntityHandle >& entities,
326 : : const bool recursive = false ) const;
327 : :
328 : : //! Retrieves all entities in the data base of given type.
329 : : /** \param type EntityType of entities desired (ie, MBHEX, MBEDGE, MBTRI, etc )
330 : : \param entities Range in which entities of EntityType <em>type</em> are returned.
331 : :
332 : : Example: \code
333 : : EntityType type = MBTET;
334 : : Range entities;
335 : : get_entities_by_dimension( type, entities ); //get MBTET type EntityHandles in the database
336 : : \endcode */
337 : : virtual ErrorCode get_entities_by_type( const EntityHandle meshset, const EntityType type, Range& entities,
338 : : const bool recursive = false ) const;
339 : :
340 : : //! Retrieves all entities in the data base of given type.
341 : : /** \param type EntityType of entities desired (ie, MBHEX, MBEDGE, MBTRI, etc )
342 : : \param entities Range in which entities of EntityType <em>type</em> are returned.
343 : :
344 : : Example: \code
345 : : EntityType type = MBTET;
346 : : Range entities;
347 : : get_entities_by_dimension( type, entities ); //get MBTET type EntityHandles in the database
348 : : \endcode */
349 : : virtual ErrorCode get_entities_by_type( const EntityHandle meshset, const EntityType type,
350 : : std::vector< EntityHandle >& entities, const bool recursive = false ) const;
351 : :
352 : : virtual ErrorCode get_entities_by_type_and_tag( const EntityHandle meshset, const EntityType type,
353 : : const Tag* tag_handles, const void* const* values,
354 : : const int num_tags, Range& entities,
355 : : const int condition = Interface::INTERSECT,
356 : : const bool recursive = false ) const;
357 : :
358 : : //! Retrieves all entities in the data base
359 : : /** \param entities Range in which entities of EntityType <em>type</em> are returned.
360 : :
361 : : Example: \code
362 : : Range entities;
363 : : get_entities( entities ); //get MBTET type EntityHandles in the database
364 : : \endcode */
365 : : virtual ErrorCode get_entities_by_handle( const EntityHandle meshset, Range& entities,
366 : : const bool recursive = false ) const;
367 : :
368 : : //! Retrieves all entities in the data base
369 : : /** \param entities Range in which entities of EntityType <em>type</em> are returned.
370 : :
371 : : Example: \code
372 : : Range entities;
373 : : get_entities( entities ); //get MBTET type EntityHandles in the database
374 : : \endcode */
375 : : virtual ErrorCode get_entities_by_handle( const EntityHandle meshset, std::vector< EntityHandle >& entities,
376 : : const bool recursive = false ) const;
377 : :
378 : : //! Retrieves all entities in the database of given dimension.
379 : : /** \param dimension Dimension of entities desired.
380 : : \param entities Range in which entities of dimension <em>dimension</em> are returned.
381 : :
382 : : Example: \code
383 : : int dimension = 2;
384 : : Range entities;
385 : : get_entities_by_dimension( dimension, entities ); //get 2D EntityHandles in the database
386 : : \endcode */
387 : : virtual ErrorCode get_number_entities_by_dimension( const EntityHandle meshset, const int dimension,
388 : : int& num_entities, const bool recursive = false ) const;
389 : :
390 : : //! Retrieves all entities in the data base of given type.
391 : : /** \param type EntityType of entities desired (ie, MBHEX, MBEDGE, MBTRI, etc )
392 : : \param entities Range in which entities of EntityType <em>type</em> are returned.
393 : :
394 : : Example: \code
395 : : EntityType type = MBTET;
396 : : Range entities;
397 : : get_entities_by_dimension( type, entities ); //get MBTET type EntityHandles in the database
398 : : \endcode */
399 : : virtual ErrorCode get_number_entities_by_type( const EntityHandle meshset, const EntityType type, int& num_entities,
400 : : const bool recursive = false ) const;
401 : :
402 : : virtual ErrorCode get_number_entities_by_type_and_tag( const EntityHandle meshset, const EntityType type,
403 : : const Tag* tag_handles, const void* const* values,
404 : : const int num_tags, int& num_entities,
405 : : const int condition = Interface::INTERSECT,
406 : : const bool recursive = false ) const;
407 : :
408 : : //! Retrieves all entities in the data base
409 : : /** \param entities Range in which entities of EntityType <em>type</em> are returned.
410 : :
411 : : Example: \code
412 : : Range entities;
413 : : get_entities( entities ); //get MBTET type EntityHandles in the database
414 : : \endcode */
415 : : virtual ErrorCode get_number_entities_by_handle( const EntityHandle meshset, int& num_entities,
416 : : const bool recursive = false ) const;
417 : :
418 : : //! Creates an element based on the type and connectivity.
419 : : /** If connectivity vector is not correct for EntityType <em>type</em> (ie, a vector with
420 : : 3 vertices is passed in to make an MBQUAD), the function returns MB_FAILURE.
421 : : \param type Type of element to create. (MBTET, MBTRI, MBKNIFE, etc.)
422 : : \param connectivity Vector containing connectivity of element to create.
423 : : \param handle EntityHandle representing the newly created element in the database.
424 : :
425 : : Example: \code
426 : : EntityType type = MBQUAD;
427 : : std::vector<EntityHandle> connectivity(4);
428 : : quad_conn[0] = vertex0;
429 : : quad_conn[1] = vertex1;
430 : : quad_conn[2] = vertex2;
431 : : quad_conn[3] = vertex3;
432 : : EntityHandle element_handle;
433 : : create_element( type, connectivity, element_handle ); \endcode */
434 : : virtual ErrorCode create_element( const EntityType type, const EntityHandle* connectivity, const int num_nodes,
435 : : EntityHandle& element_handle );
436 : :
437 : : //! Creates a vertex based on coordinates.
438 : : /**
439 : : \param coordinates Array that has 3 doubles in it.
440 : : \param entity_handle EntityHandle representing the newly created vertex in the database.
441 : :
442 : : Example: \code
443 : : double *coordinates = double[3];
444 : : coordinates[0] = 1.034;
445 : : coordinates[1] = 23.23;
446 : : coordinates[2] = -0.432;
447 : : EntityHandle entity_handle = 0;
448 : : create_vertex( coordinates, entity_handle ); \endcode */
449 : : virtual ErrorCode create_vertex( const double coordinates[3], EntityHandle& entity_handle );
450 : :
451 : : //! Create a set of vertices with the specified coordinates
452 : : /**
453 : : \param coordinates Array that has 3*n doubles in it.
454 : : \param nverts Number of vertices to create
455 : : \param entity_handles Range passed back with new vertex handles
456 : : */
457 : : virtual ErrorCode create_vertices( const double* coordinates, const int nverts, Range& entity_handles );
458 : :
459 : : //! merges two entities
460 : : virtual ErrorCode merge_entities( EntityHandle entity_to_keep, EntityHandle entity_to_remove, bool auto_merge,
461 : : bool delete_removed_entity );
462 : :
463 : : //! Removes entities in a vector from the data base.
464 : : /** If any of the entities are contained in any meshsets, it is removed from those meshsets
465 : : which were created with MESHSET_TRACK_OWNER option bit set. Tags for <em>entity<\em> are
466 : : removed as part of this function.
467 : : \param entities 1d vector of entities to delete
468 : : \param num_entities Number of entities in 1d vector
469 : : */
470 : : virtual ErrorCode delete_entities( const EntityHandle* entities, const int num_entities );
471 : :
472 : : //! Removes entities in a range from the data base.
473 : : /** If any of the entities are contained in any meshsets, it is removed from those meshsets
474 : : which were created with MESHSET_TRACK_OWNER option bit set. Tags for <em>entity<\em> are
475 : : removed as part of this function.
476 : : \param entities Range of entities to delete
477 : : */
478 : : virtual ErrorCode delete_entities( const Range& entities );
479 : :
480 : : virtual ErrorCode list_entities( const Range& entities ) const;
481 : :
482 : : virtual ErrorCode list_entities( const EntityHandle* entities, const int num_entities ) const;
483 : :
484 : : virtual ErrorCode list_entity( const EntityHandle entity ) const;
485 : :
486 : : typedef unsigned long long type_memstorage;
487 : :
488 : : //! function object for recieving events from MB of higher order nodes
489 : : //! added to entities
490 : : class HONodeAddedRemoved
491 : : {
492 : : public:
493 : : HONodeAddedRemoved() {}
494 : : virtual ~HONodeAddedRemoved() {}
495 : : //! node_added called when a node was added to an element's connectivity array
496 : : //! note: connectivity array of element may be incomplete (corner nodes will exist always)
497 : : virtual void node_added( EntityHandle node, EntityHandle element );
498 : : virtual void node_removed( EntityHandle node );
499 : : };
500 : :
501 : : virtual ErrorCode convert_entities( const EntityHandle meshset, const bool mid_side, const bool mid_face,
502 : : const bool mid_volume, Interface::HONodeAddedRemoved* function_object = 0 );
503 : :
504 : : //! function to get the side number given two elements; returns
505 : : //! MB_FAILURE if child not related to parent; does *not* create adjacencies
506 : : //! between parent and child
507 : : virtual ErrorCode side_number( const EntityHandle parent, const EntityHandle child, int& side_number, int& sense,
508 : : int& offset ) const;
509 : :
510 : : //! given an entity and the connectivity and type of one of its subfacets, find the
511 : : //! high order node on that subfacet, if any
512 : : virtual ErrorCode high_order_node( const EntityHandle parent_handle, const EntityHandle* subfacet_conn,
513 : : const EntityType subfacet_type, EntityHandle& high_order_node ) const;
514 : :
515 : : //! given an entity and a target dimension & side number, get that entity
516 : : virtual ErrorCode side_element( const EntityHandle source_entity, const int dim, const int side_number,
517 : : EntityHandle& target_entity ) const;
518 : :
519 : : //-------------------------Tag Stuff-------------------------------------//
520 : :
521 : : /**\brief Get a tag handle, possibly creating the tag
522 : : *
523 : : * Get a handle used to associate application-defined values
524 : : * with MOAB entities. If the tag does not already exist then
525 : : * \c flags should contain exactly one of \c MB_TAG_SPARSE,
526 : : * \c MB_TAG_DENSE, \c MB_TAG_MESH unless \c type is MB_TYPE_BIT,
527 : : * which implies \c MB_TAG_BIT storage.
528 : : * .
529 : : *\param name The tag name
530 : : *\param size Tag size as number of values of of data type per entity
531 : : * (or number of bytes if \c MB_TAG_BYTES is passed in flags). If \c
532 : : *MB_TAG_VARLEN is specified, this value is taken to be the size of the default value if one is
533 : : *specified and is otherwise ignored. \param type The type of the data (used for IO)
534 : : *\param tag_handle Output: the resulting tag handle.
535 : : *\param flags Bitwise OR of values from \c TagType
536 : : *\param default_value Optional default value for tag.
537 : : *\param created Optional returned boolean indicating that the tag
538 : : * was created.
539 : : *\return - \c MB_ALREADY_ALLOCATED if tag exists and \c MB_TAG_EXCL is specified, or
540 : : *default values do not match (and \c MB_TAG_ANY or \c MB_TAG_DFTOK not specified).
541 : : * - \c MB_TAG_NOT_FOUND if tag does not exist and \c MB_TAG_CREAT is not
542 : : *specified
543 : : * - \c MB_INVALID_SIZE if tag value size is not a multiple of the size of the
544 : : *data type (and \c MB_TAG_ANY not specified).
545 : : * - \c MB_TYPE_OUT_OF_RANGE invalid or inconsistent parameter
546 : : * - \c MB_VARIABLE_DATA_LENGTH if \c MB_TAG_VARLEN and \c default_value is non-null and
547 : : * \c default_value_size is not specified.
548 : : */
549 : : virtual ErrorCode tag_get_handle( const char* name, int size, DataType type, Tag& tag_handle, unsigned flags = 0,
550 : : const void* default_value = 0, bool* created = 0 );
551 : :
552 : : /**\brief same as non-const version, except that TAG_CREAT flag is ignored. */
553 : : virtual ErrorCode tag_get_handle( const char* name, int size, DataType type, Tag& tag_handle, unsigned flags = 0,
554 : : const void* default_value = 0 ) const;
555 : :
556 : : //! Gets the tag name string of the tag_handle.
557 : : /** \param tag_handle Tag you want the name of.
558 : : \param tag_name Name string of <em>tag_handle</em>.
559 : :
560 : : Example: \code
561 : : Tag tag_handle = 0;
562 : : std::string tag_name = "my_special_tag";
563 : : tag_get_name( tag_handle, tag_name ); //gets the Tag from the tag's name string
564 : : \endcode */
565 : : virtual ErrorCode tag_get_name( const Tag tag_handle, std::string& tag_name ) const;
566 : :
567 : : /**\brief Gets the tag handle corresponding to a name
568 : : *
569 : : * If a tag of that name does not exist, returns MB_TAG_NOT_FOUND
570 : : * \param tag_name Name of the desired tag.
571 : : * \param tag_handle Tag handle corresponding to <em>tag_name</em>
572 : : */
573 : : virtual ErrorCode tag_get_handle( const char* tag_name, Tag& tag_handle ) const;
574 : :
575 : : //! Get handles for all tags defined on this entity
576 : : virtual ErrorCode tag_get_tags_on_entity( const EntityHandle entity, std::vector< Tag >& tag_handles ) const;
577 : :
578 : : //! Get the size of the specified tag in bytes
579 : : virtual ErrorCode tag_get_bytes( const Tag tag, int& bytes_per_tag ) const;
580 : :
581 : : //! Get the array length of a tag
582 : : virtual ErrorCode tag_get_length( const Tag tag, int& length ) const;
583 : :
584 : : //! Get the default value of the specified tag
585 : : virtual ErrorCode tag_get_default_value( const Tag tag, void* def_val ) const;
586 : : virtual ErrorCode tag_get_default_value( Tag tag, const void*& def_val, int& size ) const;
587 : :
588 : : //! get type of tag (sparse, dense, etc.; 0 = dense, 1 = sparse, 2 = bit, 3 = mesh)
589 : : virtual ErrorCode tag_get_type( const Tag, TagType& tag_type ) const;
590 : :
591 : : /** \brief Get data type of tag.
592 : : *
593 : : * Get the type of the tag data. The tag is data is assumed to
594 : : * be a vector of this type. If the tag data vetcor contains
595 : : * more than one value, then the tag size must be a multiple of
596 : : * the size of this type.
597 : : * \param tag The tag
598 : : * \param type The type of the specified tag (output).
599 : : */
600 : : virtual ErrorCode tag_get_data_type( const Tag tag, DataType& type ) const;
601 : :
602 : : //! get handles for all tags defined
603 : : virtual ErrorCode tag_get_tags( std::vector< Tag >& tag_handles ) const;
604 : :
605 : : virtual ErrorCode tag_get_data( const Tag tag_handle, const EntityHandle* entity_handles, const int num_entities,
606 : : void* tag_data ) const;
607 : :
608 : : virtual ErrorCode tag_get_data( const Tag tag_handle, const Range& entity_handles, void* tag_data ) const;
609 : :
610 : : //! Sets the data of a given EntityHandle and Tag.
611 : : /** If the <em>tag_handle</em> and the entity type of <em>entity_handle</em> are not
612 : : compatible, data of <em>entity_handle</em> never existed and MB_FAILURE
613 : : is returned.
614 : : \param tag_handle Tag indicating what data is to be set.
615 : : \param entity_handle EntityHandle on which to set tag's data.
616 : : \param tag_data Data to set the <em>entity_handle</em>'s tag data to.
617 : :
618 : : Example: \code
619 : : int tag_data = 1004;
620 : : tag_set_data( tag_handle, entity_handle, &tag_data ); \endcode */
621 : : virtual ErrorCode tag_set_data( Tag tag_handle, const EntityHandle* entity_handles, int num_entities,
622 : : const void* tag_data );
623 : :
624 : : virtual ErrorCode tag_set_data( Tag tag_handle, const Range& entity_handles, const void* tag_data );
625 : :
626 : : /**\brief Get pointers to tag data
627 : : *
628 : : * For a tag, get the values for a list of passed entity handles.
629 : : *\note This function may not be used for bit tags.
630 : : *\param tag_handle The tag
631 : : *\param entity_handles An array of entity handles for which to retreive tag values.
632 : : *\param num_entities The length of the 'entity_handles' array.
633 : : *\param tag_data An array of 'const void*'. Array must be at least
634 : : * 'num_entitities' long. Array is populated (output)
635 : : * with pointers to the internal storage for the
636 : : * tag value corresponding to each entity handle.
637 : : *\param tag_sizes The length of each tag value. Optional for
638 : : * fixed-length tags. Required for variable-length tags.
639 : : */
640 : : virtual ErrorCode tag_get_by_ptr( const Tag tag_handle, const EntityHandle* entity_handles, int num_entities,
641 : : const void** tag_data, int* tag_sizes = 0 ) const;
642 : :
643 : : /**\brief Get pointers to tag data
644 : : *
645 : : * For a tag, get the values for a list of passed entity handles.
646 : : *\note This function may not be used for bit tags.
647 : : *\param tag_handle The tag
648 : : *\param entity_handles The entity handles for which to retreive tag values.
649 : : *\param tag_data An array of 'const void*'. Array is populated (output)
650 : : * with pointers to the internal storage for the
651 : : * tag value corresponding to each entity handle.
652 : : *\param tag_sizes The length of each tag value. Optional for
653 : : * fixed-length tags. Required for variable-length tags.
654 : : */
655 : : virtual ErrorCode tag_get_by_ptr( const Tag tag_handle, const Range& entity_handles, const void** tag_data,
656 : : int* tag_sizes = 0 ) const;
657 : :
658 : : /**\brief Set tag data given an array of pointers to tag values.
659 : : *
660 : : * For a tag, set the values for a list of passed entity handles.
661 : : *\note This function may not be used for bit tags.
662 : : *\param tag_handle The tag
663 : : *\param entity_handles An array of entity handles for which to set tag values.
664 : : *\param num_entities The length of the 'entity_handles' array.
665 : : *\param tag_data An array of 'const void*'. Array must be at least
666 : : * 'num_entitities' long. Array is expected to
667 : : * contain pointers to tag values for the corresponding
668 : : * EntityHandle in 'entity_handles'.
669 : : *\param tag_sizes The length of each tag value. Optional for
670 : : * fixed-length tags. Required for variable-length tags.
671 : : */
672 : : virtual ErrorCode tag_set_by_ptr( Tag tag_handle, const EntityHandle* entity_handles, int num_entities,
673 : : void const* const* tag_data, const int* tag_sizes = 0 );
674 : :
675 : : /**\brief Set tag data given an array of pointers to tag values.
676 : : *
677 : : * For a tag, set the values for a list of passed entity handles.
678 : : *\note This function may not be used for bit tags.
679 : : *\param tag_handle The tag
680 : : *\param entity_handles The entity handles for which to set tag values.
681 : : *\param tag_data An array of 'const void*'. Array is expected to
682 : : * contain pointers to tag values for the corresponding
683 : : * EntityHandle in 'entity_handles'.
684 : : *\param tag_sizes The length of each tag value. Optional for
685 : : * fixed-length tags. Required for variable-length tags.
686 : : */
687 : : virtual ErrorCode tag_set_by_ptr( Tag tag_handle, const Range& entity_handles, void const* const* tag_data,
688 : : const int* tag_sizes = 0 );
689 : :
690 : : /**\brief Set tag data given value.
691 : : *
692 : : * For a tag, set the values for a list of passed entity handles to
693 : : * the same, specified value.
694 : : *
695 : : *\param tag_handle The tag
696 : : *\param entity_handles The entity handles for which to set tag values.
697 : : *\param tag_data A pointer to the tag value.
698 : : *\param tag_sizes For variable-length tags, the lenght of the
699 : : * tag value. This argument will be ignored for
700 : : * fixed-length tags.
701 : : */
702 : : virtual ErrorCode tag_clear_data( Tag tag_handle, const Range& entity_handles, const void* value,
703 : : int value_size = 0 );
704 : :
705 : : /**\brief Set tag data given value.
706 : : *
707 : : * For a tag, set the values for a list of passed entity handles to
708 : : * the same, specified value.
709 : : *
710 : : *\param tag_handle The tag
711 : : *\param entity_handles The entity handles for which to set tag values.
712 : : *\param tag_data A pointer to the tag value.
713 : : *\param tag_sizes For variable-length tags, the lenght of the
714 : : * tag value. This argument will be ignored for
715 : : * fixed-length tags.
716 : : */
717 : : virtual ErrorCode tag_clear_data( Tag tag_handle, const EntityHandle* entity_handles, int num_entity_handles,
718 : : const void* value, int value_size = 0 );
719 : :
720 : : //! Delete the data of a vector of entity handles and sparse tag
721 : : /** Delete the data of a tag on a vector of entity handles. Only sparse tag data are deleted
722 : : with this function; dense tags are deleted by deleting the tag itself using tag_delete.
723 : : \param tag_handle Handle of the (sparse) tag being deleted from entity
724 : : \param entity_handles 1d vector of entity handles from which the tag is being deleted
725 : : \param num_handles Number of entity handles in 1d vector
726 : : */
727 : : virtual ErrorCode tag_delete_data( Tag tag_handle, const EntityHandle* entity_handles, int num_handles );
728 : :
729 : : //! Delete the data of a range of entity handles and sparse tag
730 : : /** Delete the data of a tag on a range of entity handles. Only sparse tag data are deleted
731 : : with this function; dense tags are deleted by deleting the tag itself using tag_delete.
732 : : \param tag_handle Handle of the (sparse) tag being deleted from entity
733 : : \param entity_range Range of entities from which the tag is being deleted
734 : : */
735 : : virtual ErrorCode tag_delete_data( Tag tag_handle, const Range& entity_range );
736 : :
737 : : //! Removes the tag from the database and deletes all of its associated data.
738 : : virtual ErrorCode tag_delete( Tag tag_handle );
739 : :
740 : : /**\brief Access tag data via direct pointer into contiguous blocks
741 : : *
742 : : * Iteratively obtain direct access to contiguous blocks of tag
743 : : * storage. This function cannot be used with bit tags because
744 : : * of the compressed bit storage. This function cannot be used
745 : : * with variable length tags because it does not provide a mechanism
746 : : * to determine the length of the value for each entity. This
747 : : * function may be used with sparse tags, but if it is used, it
748 : : * will return data for a single entity at a time.
749 : : *
750 : : *\param tag_handle The handle of the tag for which to access data
751 : : *\param iter The first entity for which to return data.
752 : : *\param end One past the last entity for which data is desired.
753 : : *\param count The number of entities for which data was returned
754 : : *\param data_ptr Output: pointer to tag storage.
755 : : *\param allocate If true, space for this tag will be allocated, if not it wont
756 : : *
757 : : *\Note If this function is called for entities for which no tag value
758 : : * has been set, but for which a default value exists, it will
759 : : * force the allocation of explicit storage for each such entity
760 : : * even though MOAB would normally not explicitly store tag values
761 : : * for such entities.
762 : : *
763 : : *\Example:
764 : : *\code
765 : : * Range ents; // range to iterate over
766 : : * Tag tag; // tag for which to access data
767 : : * int bytes;
768 : : * ErrorCode err = mb.tag_get_size( tag, bytes );
769 : : * if (err) { ... }
770 : : *
771 : : * ...
772 : : * Range::iterator iter = ents.begin();
773 : : * while (iter != ents.end()) {
774 : : * int count;
775 : : * // get contiguous block of tag dat
776 : : * void* ptr;
777 : : * err = mb.tag_iterate( tag, iter, ents.end(), count, ptr );
778 : : * if (err) { ... }
779 : : * // do something with tag data
780 : : * process_Data( ptr, count );
781 : : * // advance to next block of data
782 : : * iter += count;
783 : : * }
784 : : *\endcode
785 : : */
786 : : virtual ErrorCode tag_iterate( Tag tag_handle, Range::const_iterator begin, Range::const_iterator end, int& count,
787 : : void*& data_ptr, bool allocate = true );
788 : :
789 : : //! creates a mesh set
790 : : virtual ErrorCode create_meshset( const unsigned int options, EntityHandle& ms_handle, int start_id = 0 );
791 : :
792 : : //! Empty a vector of mesh set
793 : : /** Empty a mesh set.
794 : : \param ms_handles 1d vector of handles of sets being emptied
795 : : \param num_meshsets Number of entities in 1d vector
796 : : */
797 : : virtual ErrorCode clear_meshset( const EntityHandle* ms_handles, const int num_meshsets );
798 : :
799 : : //! Empty a range of mesh set
800 : : /** Empty a mesh set.
801 : : \param ms_handles Range of handles of sets being emptied
802 : : */
803 : : virtual ErrorCode clear_meshset( const Range& ms_handles );
804 : :
805 : : //! get the options of a mesh set
806 : : virtual ErrorCode get_meshset_options( const EntityHandle ms_handle, unsigned int& options ) const;
807 : :
808 : : //! set the options of a mesh set
809 : : virtual ErrorCode set_meshset_options( const EntityHandle ms_handle, const unsigned int options );
810 : :
811 : : //! subtracts meshset2 from meshset1 - modifies meshset1
812 : : virtual ErrorCode subtract_meshset( EntityHandle meshset1, const EntityHandle meshset2 );
813 : :
814 : : //! intersects meshset2 with meshset1 - modifies meshset1
815 : : virtual ErrorCode intersect_meshset( EntityHandle meshset1, const EntityHandle meshset2 );
816 : :
817 : : //! unites meshset2 with meshset1 - modifies meshset1
818 : : virtual ErrorCode unite_meshset( EntityHandle meshset1, const EntityHandle meshset2 );
819 : :
820 : : //! add entities to meshset
821 : : virtual ErrorCode add_entities( EntityHandle meshset, const Range& entities );
822 : :
823 : : //! add entities to meshset
824 : : virtual ErrorCode add_entities( EntityHandle meshset, const EntityHandle* entities, const int num_entities );
825 : :
826 : : //! remove entities from meshset
827 : : virtual ErrorCode remove_entities( EntityHandle meshset, const Range& entities );
828 : :
829 : : //! remove entities from meshset
830 : : virtual ErrorCode remove_entities( EntityHandle meshset, const EntityHandle* entities, const int num_entities );
831 : :
832 : : //! return true if all entities are contained in set
833 : : virtual bool contains_entities( EntityHandle meshset, const EntityHandle* entities, int num_entities,
834 : : const int operation_type = Interface::INTERSECT );
835 : :
836 : : //! replace entities
837 : : virtual ErrorCode replace_entities( EntityHandle meshset, const EntityHandle* old_entities,
838 : : const EntityHandle* new_entities, int num_entities );
839 : :
840 : : //------MeshSet Parent/Child functions------
841 : :
842 : : //! get parent meshsets
843 : : virtual ErrorCode get_parent_meshsets( const EntityHandle meshset, std::vector< EntityHandle >& parents,
844 : : const int num_hops = 1 ) const;
845 : :
846 : : //! get parent meshsets
847 : : virtual ErrorCode get_parent_meshsets( const EntityHandle meshset, Range& parents, const int num_hops = 1 ) const;
848 : :
849 : : //! get child meshsets
850 : : virtual ErrorCode get_child_meshsets( const EntityHandle meshset, std::vector< EntityHandle >& children,
851 : : const int num_hops = 1 ) const;
852 : :
853 : : //! get child meshsets
854 : : virtual ErrorCode get_child_meshsets( const EntityHandle meshset, Range& children, const int num_hops = 1 ) const;
855 : :
856 : : //! get contained meshsets
857 : : virtual ErrorCode get_contained_meshsets( const EntityHandle meshset, std::vector< EntityHandle >& contained,
858 : : const int num_hops = 1 ) const;
859 : :
860 : : //! get contained meshsets
861 : : virtual ErrorCode get_contained_meshsets( const EntityHandle meshset, Range& contained,
862 : : const int num_hops = 1 ) const;
863 : :
864 : : //! gets number of parent meshsets
865 : : virtual ErrorCode num_parent_meshsets( const EntityHandle meshset, int* number, const int num_hops = 1 ) const;
866 : :
867 : : //! gets number of child meshsets
868 : : virtual ErrorCode num_child_meshsets( const EntityHandle meshset, int* number, const int num_hops = 1 ) const;
869 : :
870 : : //! gets number of contained meshsets
871 : : virtual ErrorCode num_contained_meshsets( const EntityHandle meshset, int* number, const int num_hops = 1 ) const;
872 : :
873 : : //! add a parent meshset
874 : : virtual ErrorCode add_parent_meshset( EntityHandle meshset, const EntityHandle parent_meshset );
875 : :
876 : : //! add parent meshsets
877 : : virtual ErrorCode add_parent_meshsets( EntityHandle meshset, const EntityHandle* parent_meshsets,
878 : : int num_parent_meshsets );
879 : :
880 : : //! add a child meshset
881 : : virtual ErrorCode add_child_meshset( EntityHandle meshset, const EntityHandle child_meshset );
882 : :
883 : : //! add parent meshsets
884 : : virtual ErrorCode add_child_meshsets( EntityHandle meshset, const EntityHandle* child_meshsets,
885 : : int num_child_meshsets );
886 : :
887 : : //! adds 'parent' to child's parent list and adds 'child' to parent's child list
888 : : virtual ErrorCode add_parent_child( EntityHandle parent, EntityHandle child );
889 : :
890 : : //! removes 'parent' to child's parent list and removes 'child' to parent's child list
891 : : virtual ErrorCode remove_parent_child( EntityHandle parent, EntityHandle child );
892 : :
893 : : //! remove parent meshset
894 : : virtual ErrorCode remove_parent_meshset( EntityHandle meshset, const EntityHandle parent_meshset );
895 : :
896 : : //! remove child meshset
897 : : virtual ErrorCode remove_child_meshset( EntityHandle meshset, const EntityHandle child_meshset );
898 : :
899 : : // ************************ tag information ***************
900 : :
901 : : //! return various specific tag handles
902 : : Tag material_tag();
903 : : Tag neumannBC_tag();
904 : : Tag dirichletBC_tag();
905 : : Tag globalId_tag();
906 : : Tag geom_dimension_tag();
907 : :
908 : : //! get/set the number of nodes
909 : : // int total_num_nodes() const;
910 : : // void total_num_nodes(const int val);
911 : :
912 : : //! get/set the number of elements
913 : : // int total_num_elements() const;
914 : : // void total_num_elements(const int val);
915 : :
916 : : // ************************ structured sequence information ***************
917 : :
918 : : //! return a reference to the sequence manager
919 : 8751212 : SequenceManager* sequence_manager()
920 : : {
921 : 8751212 : return sequenceManager;
922 : : }
923 : 49915511 : const SequenceManager* sequence_manager() const
924 : : {
925 : 49915511 : return sequenceManager;
926 : : }
927 : :
928 : : /// create structured sequence
929 : : ErrorCode create_scd_sequence( const HomCoord& coord_min, const HomCoord& coord_max, EntityType type,
930 : : EntityID start_id_hint, EntityHandle& first_handle_out,
931 : : EntitySequence*& sequence_out );
932 : :
933 : : ErrorCode add_vsequence( EntitySequence* vert_seq, EntitySequence* elem_seq, const HomCoord& p1, const HomCoord& q1,
934 : : const HomCoord& p2, const HomCoord& q2, const HomCoord& p3, const HomCoord& q3,
935 : : bool bb_input = false, const HomCoord* bb_min = NULL, const HomCoord* bb_max = NULL );
936 : :
937 : : //! return the a_entity_factory pointer
938 : 1973222 : AEntityFactory* a_entity_factory()
939 : : {
940 : 1973222 : return aEntityFactory;
941 : : }
942 : 0 : const AEntityFactory* a_entity_factory() const
943 : : {
944 : 0 : return aEntityFactory;
945 : : }
946 : :
947 : : #ifdef MOAB_HAVE_AHF
948 : : HalfFacetRep* a_half_facet_rep()
949 : : {
950 : : return ahfRep;
951 : : }
952 : : const HalfFacetRep* a_half_facet_rep() const
953 : : {
954 : : return ahfRep;
955 : : }
956 : : #endif
957 : :
958 : : //! return set of registered IO tools
959 : 747 : ReaderWriterSet* reader_writer_set()
960 : : {
961 : 747 : return readerWriterSet;
962 : : }
963 : :
964 : : //-----------------MeshSet Interface Functions------------------//
965 : :
966 : : void print( const EntityHandle handle, const char* prefix, bool first_call = true ) const;
967 : :
968 : : ErrorCode print_entity_tags( std::string indent_prefix, const EntityHandle handle, TagType tp ) const;
969 : :
970 : : virtual ErrorCode get_last_error( std::string& info ) const;
971 : :
972 : : virtual std::string get_error_string( const ErrorCode code ) const;
973 : :
974 : : //! check all adjacencies for consistency
975 : : ErrorCode check_adjacencies();
976 : :
977 : : //! check some adjacencies for consistency
978 : : ErrorCode check_adjacencies( const EntityHandle* ents, int num_ents );
979 : :
980 : : //! return whether the input handle is valid or not
981 : : bool is_valid( const EntityHandle this_ent ) const;
982 : :
983 : : /** \brief Create an iterator over the set
984 : : * Create a new iterator that iterates over entities with the specified type or dimension.
985 : : * Only one of ent_type or dim can be set; use dim=-1 or ent_type=MBMAXTYPE for the other.
986 : : * Iterators for list-type (ordered) sets are stable over set modification, unless entity
987 : : * removed or deleted is the one at the current position of the iterator. If the check_valid
988 : : * parameter is passed as true, entities are checked for validity before being passed back by
989 : : * get_next_entities function (checking entity validity can have a non-negligible cost).
990 : : *
991 : : * Iterators returned by this function can be deleted using the normal C++ delete function.
992 : : * After creating the iterator through this function, further interactions are through methods
993 : : * on the SetIterator class.
994 : : * \param meshset The entity set associated with this iterator (use 0 for whole instance)
995 : : * \param ent_type Entity type associated with this iterator
996 : : * \param ent_dim Dimension associated with this iterator
997 : : * \param chunk_size Chunk size of the iterator
998 : : * \param check_valid If true, entities are checked for validity before being returned
999 : : */
1000 : : virtual ErrorCode create_set_iterator( EntityHandle meshset, EntityType ent_type, int ent_dim, int chunk_size,
1001 : : bool check_valid, SetIterator*& set_iter );
1002 : :
1003 : : /** \brief Remove the set iterator from the instance's list
1004 : : * \param set_iter Set iterator being removed
1005 : : */
1006 : : ErrorCode remove_set_iterator( SetIterator* set_iter );
1007 : :
1008 : : /** \brief Get all set iterators associated with the set passed in
1009 : : * \param meshset Meshset for which iterators are requested
1010 : : * \param set_iters Set iterators for the set
1011 : : */
1012 : : ErrorCode get_set_iterators( EntityHandle meshset, std::vector< SetIterator* >& set_iters );
1013 : :
1014 : : //-----------------Memory Functions------------------//
1015 : :
1016 : : /**\brief Calculate amount of memory used to store MOAB data
1017 : : *
1018 : : * This function calculates the amount of memory used to store
1019 : : * MOAB data.
1020 : : *
1021 : : * There are two possible values for each catagory of memory use.
1022 : : * The exact value and the amortized value. The exact value is the
1023 : : * amount of memory used to store the data for the specified entities.
1024 : : * The amortized value includes the exact value and an amortized
1025 : : * estimate of the memory consumed in overhead for storing the values
1026 : : * (indexing structures, access structures, etc.)
1027 : : *
1028 : : * Note: If ent_array is NULL, the total memory used by MOAB for storing
1029 : : * data will be returned in the address pointed to by
1030 : : * total_amortized_storage, if total_amortized_storage is not NULL.
1031 : : *
1032 : : *\param ent_array Array of entities for which to estimate the memory use.
1033 : : * If NULL, estimate is done for all entities.
1034 : : *\param num_ents The length of ent_array. Not used if ent_rray is NULL.
1035 : : *\param total_(amortized_)storage The sum of the memory entity, adjacency, and all tag storage.
1036 : : *\param (amortized_)entity_storage The storage for the entity definitions
1037 : : * (connectivity arrays for elements, coordinates for vertices,
1038 : : * list storage within sets, etc.)
1039 : : *\param (amortized_)adjacency_storage The storage for adjacency data.
1040 : : *\param tag_array An array of tags for which to calculate the memory use.
1041 : : *\param num_tags The lenght of tag_array
1042 : : *\param (amortized_)tag_storage If tag_array is not NULL, then one value
1043 : : * for each tag specifying the memory used for storing that
1044 : : * tag. If tag_array is NULL and this value is not, the
1045 : : * location at which to store the total memory used for
1046 : : * all tags.
1047 : : */
1048 : : void estimated_memory_use( const EntityHandle* ent_array = 0, unsigned long num_ents = 0,
1049 : : unsigned long long* total_storage = 0, unsigned long long* total_amortized_storage = 0,
1050 : : unsigned long long* entity_storage = 0, unsigned long long* amortized_entity_storage = 0,
1051 : : unsigned long long* adjacency_storage = 0,
1052 : : unsigned long long* amortized_adjacency_storage = 0, const Tag* tag_array = 0,
1053 : : unsigned num_tags = 0, unsigned long long* tag_storage = 0,
1054 : : unsigned long long* amortized_tag_storage = 0 );
1055 : :
1056 : : /**\brief Calculate amount of memory used to store MOAB data
1057 : : *
1058 : : * This function calculates the amount of memory used to store
1059 : : * MOAB data.
1060 : : *
1061 : : * There are two possible values for each catagory of memory use.
1062 : : * The exact value and the amortized value. The exact value is the
1063 : : * amount of memory used to store the data for the specified entities.
1064 : : * The amortized value includes the exact value and an amortized
1065 : : * estimate of the memory consumed in overhead for storing the values
1066 : : * (indexing structures, access structures, etc.)
1067 : : *
1068 : : *\param ents Entities for which to estimate the memory use.
1069 : : *\param total_(amortized_)storage The sum of the memory entity, adjacency, and all tag storage.
1070 : : *\param (amortized_)entity_storage The storage for the entity definitions
1071 : : * (connectivity arrays for elements, coordinates for vertices,
1072 : : * list storage within sets, etc.)
1073 : : *\param (amortized_)adjacency_storage The storage for adjacency data.
1074 : : *\param tag_array An array of tags for which to calculate the memory use.
1075 : : *\param num_tags The lenght of tag_array
1076 : : *\param (amortized_)tag_storage If tag_array is not NULL, then one value
1077 : : * for each tag specifying the memory used for storing that
1078 : : * tag. If tag_array is NULL and this value is not, the
1079 : : * location at which to store the total memory used for
1080 : : * all tags.
1081 : : */
1082 : : void estimated_memory_use( const Range& ents, unsigned long long* total_storage = 0,
1083 : : unsigned long long* total_amortized_storage = 0, unsigned long long* entity_storage = 0,
1084 : : unsigned long long* amortized_entity_storage = 0,
1085 : : unsigned long long* adjacency_storage = 0,
1086 : : unsigned long long* amortized_adjacency_storage = 0, const Tag* tag_array = 0,
1087 : : unsigned num_tags = 0, unsigned long long* tag_storage = 0,
1088 : : unsigned long long* amortized_tag_storage = 0 );
1089 : :
1090 : : void print_database() const;
1091 : :
1092 : : /** \name Sequence Option controllers */
1093 : :
1094 : : /**@{*/
1095 : :
1096 : : /** \brief Interface to control memory allocation for sequences
1097 : : * Provide a factor that controls the size of the sequence that gets allocated.
1098 : : * This is typically useful in the parallel setting when a-priori, the number of ghost entities
1099 : : * and the memory required for them within the same sequence as the owned entities are unknown.
1100 : : * The default factor is 1.0 but this can be appropriately updated at runtime so that we do not
1101 : : * have broken sequences.
1102 : : */
1103 : : virtual double get_sequence_multiplier() const;
1104 : :
1105 : : /** \brief Interface to control memory allocation for sequences
1106 : : * Provide a factor that controls the size of the sequence that gets allocated.
1107 : : * This is typically useful in the parallel setting when a-priori, the number of ghost entities
1108 : : * and the memory required for them within the same sequence as the owned entities are unknown.
1109 : : * The default factor is 1.0 but this can be appropriately updated at runtime so that we do not
1110 : : * have broken sequences.
1111 : : *
1112 : : * \param meshset User specified multiplier (should be greater than 1.0)
1113 : : */
1114 : : virtual void set_sequence_multiplier( double factor );
1115 : :
1116 : : /**@}*/
1117 : :
1118 : : private:
1119 : : /**\brief Do not allow copying */
1120 : : Core( const Core& copy );
1121 : : /**\brief Do not allow copying */
1122 : : Core& operator=( const Core& copy );
1123 : :
1124 : : void estimated_memory_use_internal( const Range* ents, unsigned long long* total_storage,
1125 : : unsigned long long* total_amortized_storage, unsigned long long* entity_storage,
1126 : : unsigned long long* amortized_entity_storage,
1127 : : unsigned long long* adjacency_storage,
1128 : : unsigned long long* amortized_adjacency_storage, const Tag* tag_array,
1129 : : unsigned num_tags, unsigned long long* tag_storage,
1130 : : unsigned long long* amortized_tag_storage );
1131 : :
1132 : : //! database init and de-init routines
1133 : : ErrorCode initialize();
1134 : : void deinitialize();
1135 : :
1136 : : //! return the entity set representing the whole mesh
1137 : : EntityHandle get_root_set();
1138 : :
1139 : : //!\brief Clean up after a file reader returns failure.
1140 : : //!
1141 : : //! Delete all entities not contained in initial_entities
1142 : : //! and all tags not contained in initial_tags.
1143 : : void clean_up_failed_read( const Range& initial_entities, std::vector< Tag > initial_tags );
1144 : :
1145 : : // other interfaces for MB
1146 : : WriteUtil* mMBWriteUtil;
1147 : : ReadUtil* mMBReadUtil;
1148 : : ScdInterface* scdInterface;
1149 : :
1150 : : //! store the total number of elements defined in this interface
1151 : : // int totalNumElements;
1152 : :
1153 : : //! store the total number of nodes defined in this interface
1154 : : // int totalNumNodes;
1155 : :
1156 : : //! the overall geometric dimension of this mesh
1157 : : int geometricDimension;
1158 : :
1159 : : Tag materialTag;
1160 : : Tag neumannBCTag;
1161 : : Tag dirichletBCTag;
1162 : : Tag geomDimensionTag;
1163 : : Tag globalIdTag;
1164 : :
1165 : : //! tag server for this interface
1166 : : std::list< TagInfo* > tagList;
1167 : 12909805 : inline bool valid_tag_handle( const TagInfo* t ) const
1168 : : {
1169 [ + - ][ + - ]: 12909805 : return std::find( tagList.begin(), tagList.end(), t ) != tagList.end();
1170 : : }
1171 : :
1172 : : SequenceManager* sequenceManager;
1173 : :
1174 : : AEntityFactory* aEntityFactory;
1175 : :
1176 : : ReaderWriterSet* readerWriterSet;
1177 : :
1178 : : Error* mError;
1179 : : bool mpiFinalize;
1180 : : int writeMPELog;
1181 : : bool initErrorHandlerInCore;
1182 : :
1183 : : //! list of iterators
1184 : : std::vector< SetIterator* > setIterators;
1185 : :
1186 : : #ifdef MOAB_HAVE_AHF
1187 : : HalfFacetRep* ahfRep;
1188 : : bool mesh_modified;
1189 : : #endif
1190 : : };
1191 : :
1192 : : } // namespace moab
1193 : :
1194 : : #endif // MOAB_IMPL_GENERAL_HPP
|