Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MesqPane_1_1.h
Go to the documentation of this file.
1 /* *******************************************************************
2  * Rocstar Simulation Suite *
3  * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4  * *
5  * Illinois Rocstar LLC *
6  * Champaign, IL *
7  * www.illinoisrocstar.com *
8  * sales@illinoisrocstar.com *
9  * *
10  * License: See LICENSE file in top level of distribution package or *
11  * http://opensource.org/licenses/NCSA *
12  *********************************************************************/
13 /* *******************************************************************
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17  * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21  * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22  *********************************************************************/
23 // $Id: MesqPane_1_1.h,v 1.3 2008/12/06 08:45:24 mtcampbe Exp $
38 #ifndef MESQPANE_H
39 #define MESQPANE_H
40 
41 #ifndef USE_STD_INCLUDES
42 #define USE_STD_INCLUDES 1
43 #endif
44 
45 #ifndef USE_C_PREFIX_INCLUDES
46 #define USE_C_PREFIX_INCLUDES 1
47 #endif
48 
49 // MESQUITE INCLUDES
50 #include "Mesquite.hpp"
51 #include "TopologyInfo.hpp"
52 
53 // ROCCOM INCLUDES
54 #include "roccom_devel.h"
55 #include "Pane.h"
56 #include "Pane_boundary.h"
57 #include "Dual_connectivity.h"
58 #include "roccom_devel.h"
59 
60 // ROCMOP INCLUDES
61 #include "mopbasic.h"
62 
63 #ifdef MSQ_USE_OLD_C_HEADERS
64 # include <stddef.h>
65 #else
66 # include <cstddef>
67 #endif
68 
69 #include <string>
70 
71 #define MESQUITE_BEGIN_NAMESPACE namespace Mesquite{
72 #define MESQUITE_END_NAMESPACE }
73 
74 #include "Mesquite.hpp"
75 #include "MeshInterface.hpp"
76 
77 //using namespace Mesquite;
78 using namespace std;
79 using std::string;
82 
83 class EntityIterator;
84 class MsqError;
85 class MsqVertex;
86 class Vector3D;
87 typedef EntityIterator VertexIterator;
88 typedef EntityIterator ElementIterator;
89 
90 
93 class MesqPane : public Mesquite::Mesh {
94 
95  inline size_t vertices_in_topology(EntityTopology);
96 
97 public:
98  //************ Type Definitions **************
100  typedef void* EntityHandle;
101  typedef void* TagHandle;
102 
103  // We typedef specific types of EntityHandles just
104  // to make it clear what kind of entity is to be
105  // returned or used as a function parameter, but the
106  // different handle types are not actually distinct.
109 
111 
117  void invert(int conn_type);
118 
120 
127  MesqPane(COM::Pane* p, bool with_ghost = true)
128  : _pane(p), _verb(0), _with_ghost(with_ghost){
129  init();
130  }
131 
133  void set_verb(int verb){
134  _verb = verb;
135  }
136 
138  virtual ~MesqPane();
139 
141 
145  void init();
146 
147  //************ Operations on entire mesh ****************
149  virtual int get_geometric_dimension(MsqError &err) {
150  if(_verb >1)
151  std::cout << "MesqPane::get_geometric_dimension\n";
152  return 3;
153  }
154 
159  // NEW
160  virtual void get_all_elements( msq_std::vector<ElementHandle>& elements,
161  MsqError& err );
162 
167  // NEW
168  virtual void get_all_vertices( msq_std::vector<VertexHandle>& vertices,
169  MsqError& err );
170 
181  virtual void get_all_sizes( size_t& vertex_count,
182  size_t& element_count,
183  size_t& vertex_use_count,
184  MsqError& err ){
185  vertex_count = _with_ghost ? _pane->size_of_nodes() :
186  _pane->size_of_real_nodes();
187  element_count = _with_ghost ? _pane->size_of_elements() :
188  _pane->size_of_real_elements();
189  std::vector<const COM::Connectivity*> conns;
190  _pane->connectivities(conns);
191  vertex_use_count = 0;
192  for(int i=0, ni = conns.size(); i<ni; ++i){
193  vertex_use_count += conns[i]->size_of_nodes_pe() *
194  (_with_ghost ? conns[i]->size_of_elements() :
195  conns[i]->size_of_real_elements());
196  }
197  }
198 
217  virtual void get_all_mesh( VertexHandle* vert_array, size_t vert_len,
218  ElementHandle* elem_array, size_t elem_len,
219  size_t* elem_conn_offsets, size_t offset_len,
220  size_t* elem_conn_indices, size_t index_len,
221  MsqError& err );
222 
228  virtual VertexIterator* vertex_iterator(MsqError &err);
229 
235  virtual ElementIterator* element_iterator(MsqError &err);
236 
237  //************ Vertex Properties ********************
238 
239  // NEW
245  virtual void vertices_get_fixed_flag( const VertexHandle vert_array[],
246  bool fixed_flag_array[],
247  size_t num_vtx,
248  MsqError &err );
249 
255  virtual bool vertex_is_fixed(VertexHandle vertex, MsqError &err);
256 
263  virtual void vertices_are_on_boundary(VertexHandle vert_array[], bool on_bnd[],
264  size_t num_vtx, MsqError &err);
265 
267  virtual void vertices_get_coordinates(const VertexHandle vert_array[],
268  MsqVertex* coordinates,
269  size_t num_vtx,
270  MsqError &err);
271 
272  virtual void vertex_set_coordinates(VertexHandle vertex,
273  const Vector3D &coordinates,
274  MsqError &err);
275 
280  virtual void vertex_set_byte (VertexHandle vertex,
281  unsigned char byte, MsqError &err);
282 
283  virtual void vertices_set_byte (VertexHandle *vert_array,
284  unsigned char *byte_array,
285  size_t array_size, MsqError &err);
286 
287  // NEW
288  virtual void vertices_set_byte( const VertexHandle *vert_array,
289  const unsigned char *byte_array,
290  size_t array_size,
291  MsqError &err );
292 
296  virtual void vertex_get_byte(VertexHandle vertex,
297  unsigned char *byte, MsqError &err);
298  virtual void vertices_get_byte(VertexHandle *vertex,
299  unsigned char *byte_array,
300  size_t array_size, MsqError &err);
301 
302  // NEW
303  virtual void vertices_get_byte( const VertexHandle *vertex,
304  unsigned char *byte_array,
305  size_t array_size,
306  MsqError &err ){;}
307 
308 
309  //**************** Vertex Topology *****************
313  virtual size_t vertex_get_attached_element_count(VertexHandle vertex,
314  MsqError &err);
315 
317  virtual void vertex_get_attached_elements(VertexHandle vertex,
318  ElementHandle* elem_array,
319  size_t sizeof_elem_array,
320  MsqError &err);
321 
322  // NEW
339  virtual void
340  vertices_get_attached_elements(const VertexHandle* vertex_array,
341  size_t num_vertex,
342  msq_std::vector<ElementHandle>& elements,
343  msq_std::vector<size_t>& offsets,
344  MsqError& err );
345 
346  //*************** Element Topology *************
347 
352 
353  virtual size_t element_get_attached_vertex_count(ElementHandle elem,
354  MsqError &err);
355 
356  virtual size_t get_vertex_use_count( ElementHandle* handle_array,
357  size_t num_handles,
358  MsqError& err );
359 
360  // NEW
361 
377  virtual void elements_get_attached_vertices(
378  const ElementHandle *elem_handles,
379  size_t num_elems,
380  msq_std::vector<VertexHandle>& vert_handles,
381  msq_std::vector<size_t>& offsets,
382  MsqError &err);
383 
420  virtual void elements_get_attached_vertices(ElementHandle *elem_handles,
421  size_t num_elems,
422  VertexHandle *vert_handles,
423  size_t &sizeof_vert_handles,
424  size_t *csr_data,
425  size_t &sizeof_csr_data,
426  size_t *csr_offsets,
427  MsqError &err);
428 
430  virtual EntityTopology element_get_topology(ElementHandle entity_handle,
431  MsqError &err);
432 
435  virtual void elements_get_topologies(ElementHandle *element_handle_array,
436  EntityTopology *element_topologies,
437  size_t num_elements, MsqError &err);
438 
439  //NEW
440 
443  virtual void elements_get_topologies(const ElementHandle *element_handle_array,
444  EntityTopology *element_topologies,
445  size_t num_elements, MsqError &err);
446 
447  //*************** Tags ***********
448 
461  virtual TagHandle tag_create( const msq_std::string& tag_name,
462  TagType type, unsigned length,
463  const void* default_value,
464  MsqError &err);
465 
470  virtual void tag_delete( TagHandle handle, MsqError& err );
471 
472 
480  virtual TagHandle tag_get( const msq_std::string& name,
481  MsqError& err );
482 
491  virtual void tag_properties( TagHandle handle,
492  msq_std::string& name_out,
493  TagType& type_out,
494  unsigned& length_out,
495  MsqError& err );
496 
507  virtual void tag_set_element_data( TagHandle handle,
508  size_t num_elems,
509  const ElementHandle* elem_array,
510  const void* tag_data,
511  MsqError& err );
512 
523  virtual void tag_set_vertex_data ( TagHandle handle,
524  size_t num_elems,
525  const VertexHandle* node_array,
526  const void* tag_data,
527  MsqError& err );
528 
529 
540  virtual void tag_get_element_data( TagHandle handle,
541  size_t num_elems,
542  const ElementHandle* elem_array,
543  void* tag_data,
544  MsqError& err );
545 
556  virtual void tag_get_vertex_data ( TagHandle handle,
557  size_t num_elems,
558  const VertexHandle* node_array,
559  void* tag_data,
560  MsqError& err );
561 
562 
563 
564  //**************** Memory Management ****************
565 
566  // NEW
569  virtual void release_entity_handles( const EntityHandle *handle_array,
570  size_t num_handles,
571  MsqError &err);
572 
575  virtual void release_entity_handles(EntityHandle *handle_array,
576  size_t num_handles, MsqError &err);
577 
583  virtual void release();
584 
585 protected:
586  COM::Pane* _pane;
587  MAP::Pane_dual_connectivity* _dc;
588  std::vector<bool> _is_border;
589  std::vector<unsigned char> _vertexBytes;
590 
591  int _verb; // 1 for function start/end
592  // 2 for all information
593  // 0 = nothing
594 
595  bool _with_ghost; // If true(default), then use ghost information.
596 
597  struct tagStruct {
598  unsigned size; // tag size: # of values per entity
599  TagType type; // tag type
600  void * edata; // elemental data
601  void * ndata; // nodal data
602  msq_std::string name;
603  };
604 
605 #if 0
606  tagStruct::tagStruct()
607  : size(0), type(0), edata(NULL), ndata(NULL), dval(NULL)
608  {
609  ;
610  }
611 #endif
612 
613  std::map<msq_std::string,tagStruct> s_to_t;
614 
615 };
616 
617 
618 #if 0
620 {
621  return TopologyInfo::corners( topo );
622 }
623 #endif
624 
627 public:
628 
630  MyEntityIterator(uint size){ _cur = 1; _size = size;}
631 
634  {_cur = 0;
635  _size = 0;
636  }
637 
639  virtual void restart(){
640  _cur = 1;
641  };
642 
644  virtual Mesh::EntityHandle operator*() const {
645  if (_cur > _size)
646  return 0;
647  else
648  return (char*)NULL+_cur;
649  }
650 
652  virtual void operator++(){
653  _cur ++;
654  }
655 
657 
661  virtual bool is_at_end() const{
662  if (_cur <= _size) return 0;
663  else return 1;
664  }
665 private:
666  uint _cur; // The current node's position.
667  uint _size;// The size of the element array
668 };
669 
671 
672 #endif
673 
674 
675 
676 
677 
678 
std::map< msq_std::string, tagStruct > s_to_t
Definition: MesqPane_1_1.h:613
Iterates through a set of entities. An EntityIterator is typically obtained via Mesh::vertex_iterator...
EntityIterator VertexIterator
void set_verb(int verb)
Set the MesqPane verbose level (int, &gt;= 0)
Definition: MesqPane_1_1.h:133
EntityHandle VertexHandle
Definition: MesqPane_1_1.h:107
subroutine invert(a, nrow, det)
Definition: v3d8_me.f90:1392
Contains the prototypes for the Pane object.
TagType
The type of a tag.
EntityTopology
Definition: Mesquite.hpp:92
A class for iterating through a Panes vertices or elements.
Definition: MesqPane.h:495
virtual ~MyEntityIterator()
Destructor.
Definition: MesqPane_1_1.h:633
EntityHandle VertexHandle
This file contains the Mesquite mesh interface. Many users will want to implement a concrete class de...
#define MESQUITE_BEGIN_NAMESPACE
Definition: MesqPane_1_1.h:71
void * TagHandle
Definition: MesqPane_1_1.h:101
void * EntityHandle
Opaque EntityHandle type and tag type.
Definition: MesqPane_1_1.h:100
virtual Mesh::EntityHandle operator*() const
Return the handle currently being pointed to by the iterator.
Definition: MesqPane_1_1.h:644
void * EntityHandle
Opaque EntityHandle type and tag type.
virtual int get_geometric_dimension(MsqError &err)
Returns whether this mesh lies in a 2D or 3D coordinate system.
Definition: MesqPane_1_1.h:149
EntityIterator ElementIterator
Definition: MesqPane.h:86
EntityIterator VertexIterator
Definition: MesqPane.h:84
MesqPane(COM::Pane *p, bool with_ghost=true)
Construct from a pane.
Definition: MesqPane_1_1.h:127
#define MESQUITE_END_NAMESPACE
Definition: MesqPane_1_1.h:72
virtual void operator++()
Move to the next entity.
Definition: MesqPane_1_1.h:652
EntityHandle ElementHandle
Definition: MesqPane_1_1.h:108
double length(Vector3D *const v, int n)
msq_std::string name
Definition: MesqPane_1_1.h:602
NVec< 3, double > Vector3D
A class enabling Mesquite calls on Rocmop panes.
Definition: MesqPane.h:95
blockLoc i
Definition: read.cpp:79
size_t vertices_in_topology(EntityTopology)
A Mesquite::Mesh is a collection of mesh elements which are composed of mesh vertices. Intermediate objects are not accessible through this interface (where intermediate objects include things like the faces of a hex, or an element&#39;s edges).
virtual void restart()
Moves the iterator back to the first entity in the list.
Definition: MesqPane_1_1.h:639
MyEntityIterator(uint size)
Constructor.
Definition: MesqPane_1_1.h:630
virtual bool is_at_end() const
Check if we are at the end of the entites.
Definition: MesqPane_1_1.h:661
virtual void vertices_get_byte(const VertexHandle *vertex, unsigned char *byte_array, size_t array_size, MsqError &err)
Definition: MesqPane_1_1.h:303
void * TagHandle
Type used to refer to a tag defintion.
void int int REAL REAL REAL *z blockDim dim * ni
Definition: read.cpp:77
virtual void get_all_sizes(size_t &vertex_count, size_t &element_count, size_t &vertex_use_count, MsqError &err)
get sizes for calling get_all_mesh
Definition: MesqPane_1_1.h:181
EntityIterator ElementIterator
Utility for detecting boundaries of a pane.
USE_MOP_NAMESPACE
Definition: metric_demo.C:33