Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MesqPane_95.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_95.h,v 1.5 2008/12/06 08:45:23 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 // ROCMOP INCLUDES
54 #include "mopbasic.h"
55 
56 // ROCCOM INCLUDES
57 #include "roccom_devel.h"
58 #include "Pane.h"
59 #include "Pane_boundary.h"
60 #include "Dual_connectivity.h"
61 #include "roccom_devel.h"
62 
63 
64 #ifdef MSQ_USE_OLD_C_HEADERS
65 # include <stddef.h>
66 #else
67 # include <cstddef>
68 #endif
69 
70 #include <string>
71 
72 #define MESQUITE_BEGIN_NAMESPACE namespace Mesquite{
73 #define MESQUITE_END_NAMESPACE }
74 
75 #include "Mesquite.hpp"
76 #include "MeshInterface.hpp"
77 
78 //using namespace Mesquite;
79 using namespace std;
80 using std::string;
83 
84 class EntityIterator;
85 class MsqError;
86 class MsqVertex;
87 class Vector3D;
88 typedef EntityIterator VertexIterator;
89 typedef EntityIterator ElementIterator;
90 
91 
94 class MesqPane : public Mesquite::Mesh {
95 
96  inline size_t vertices_in_topology(EntityTopology);
97 
98 public:
99  //************ Type Definitions **************
101  typedef void* EntityHandle;
102  typedef void* TagHandle;
103 
104  // We typedef specific types of EntityHandles just
105  // to make it clear what kind of entity is to be
106  // returned or used as a function parameter, but the
107  // different handle types are not actually distinct.
110 
112 
117  void invert();
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 
165  virtual void get_all_sizes( size_t& vertex_count,
166  size_t& element_count,
167  size_t& vertex_use_count,
168  MsqError& err ){
169  vertex_count = _with_ghost ? _pane->size_of_nodes() :
170  _pane->size_of_real_nodes();
171  element_count = _with_ghost ? _pane->size_of_elements() :
172  _pane->size_of_real_elements();
173  std::vector<const COM::Connectivity*> conns;
174  _pane->connectivities(conns);
175  vertex_use_count = 0;
176  for(int i=0, ni = conns.size(); i<ni; ++i){
177  vertex_use_count += conns[i]->size_of_nodes_pe() *
178  (_with_ghost ? conns[i]->size_of_elements() :
179  conns[i]->size_of_real_elements());
180  }
181  }
182 
201  virtual void get_all_mesh( VertexHandle* vert_array, size_t vert_len,
202  ElementHandle* elem_array, size_t elem_len,
203  size_t* elem_conn_offsets, size_t offset_len,
204  size_t* elem_conn_indices, size_t index_len,
205  MsqError& err );
206 
212  virtual VertexIterator* vertex_iterator(MsqError &err);
213 
219  virtual ElementIterator* element_iterator(MsqError &err);
220 
221  //************ Vertex Properties ********************
227  virtual bool vertex_is_fixed(VertexHandle vertex, MsqError &err);
228 
235  virtual void vertices_are_on_boundary(VertexHandle vert_array[], bool on_bnd[],
236  size_t num_vtx, MsqError &err);
237 
239  virtual void vertices_get_coordinates(const VertexHandle vert_array[],
240  MsqVertex* coordinates,
241  size_t num_vtx,
242  MsqError &err);
243 
244  virtual void vertex_set_coordinates(VertexHandle vertex,
245  const Vector3D &coordinates,
246  MsqError &err);
247 
252  virtual void vertex_set_byte (VertexHandle vertex,
253  unsigned char byte, MsqError &err);
254 
255  virtual void vertices_set_byte (VertexHandle *vert_array,
256  unsigned char *byte_array,
257  size_t array_size, MsqError &err);
258 
262  virtual void vertex_get_byte(VertexHandle vertex,
263  unsigned char *byte, MsqError &err);
264  virtual void vertices_get_byte(VertexHandle *vertex,
265  unsigned char *byte_array,
266  size_t array_size, MsqError &err);
267 
268  //**************** Vertex Topology *****************
272  virtual size_t vertex_get_attached_element_count(VertexHandle vertex,
273  MsqError &err);
274 
276  virtual void vertex_get_attached_elements(VertexHandle vertex,
277  ElementHandle* elem_array,
278  size_t sizeof_elem_array,
279  MsqError &err);
280 
281  //*************** Element Topology *************
282 
287 
288  virtual size_t element_get_attached_vertex_count(ElementHandle elem,
289  MsqError &err);
290 
291  virtual size_t get_vertex_use_count( ElementHandle* handle_array,
292  size_t num_handles,
293  MsqError& err );
294 
331  virtual void elements_get_attached_vertices(ElementHandle *elem_handles,
332  size_t num_elems,
333  VertexHandle *vert_handles,
334  size_t &sizeof_vert_handles,
335  size_t *csr_data,
336  size_t &sizeof_csr_data,
337  size_t *csr_offsets,
338  MsqError &err);
339 
341  virtual EntityTopology element_get_topology(ElementHandle entity_handle,
342  MsqError &err);
343 
346  virtual void elements_get_topologies(ElementHandle *element_handle_array,
347  EntityTopology *element_topologies,
348  size_t num_elements, MsqError &err);
349 
350 
351  //*************** Tags ***********
352 
365  virtual TagHandle tag_create( const msq_std::string& tag_name,
366  TagType type, unsigned length,
367  const void* default_value,
368  MsqError &err);
369 
374  virtual void tag_delete( TagHandle handle, MsqError& err );
375 
376 
384  virtual TagHandle tag_get( const msq_std::string& name,
385  MsqError& err );
386 
395  virtual void tag_properties( TagHandle handle,
396  msq_std::string& name_out,
397  TagType& type_out,
398  unsigned& length_out,
399  MsqError& err );
400 
411  virtual void tag_set_element_data( TagHandle handle,
412  size_t num_elems,
413  const ElementHandle* elem_array,
414  const void* tag_data,
415  MsqError& err );
416 
427  virtual void tag_set_vertex_data ( TagHandle handle,
428  size_t num_elems,
429  const VertexHandle* node_array,
430  const void* tag_data,
431  MsqError& err );
432 
433 
444  virtual void tag_get_element_data( TagHandle handle,
445  size_t num_elems,
446  const ElementHandle* elem_array,
447  void* tag_data,
448  MsqError& err );
449 
460  virtual void tag_get_vertex_data ( TagHandle handle,
461  size_t num_elems,
462  const VertexHandle* node_array,
463  void* tag_data,
464  MsqError& err );
465 
466 
467 
468  //**************** Memory Management ****************
471  virtual void release_entity_handles(EntityHandle *handle_array,
472  size_t num_handles, MsqError &err);
473 
479  virtual void release();
480 
481 protected:
482  COM::Pane* _pane;
483  MAP::Pane_dual_connectivity* _dc;
484  std::vector<bool> _is_border;
485  std::vector<unsigned char> _vertexBytes;
486 
487  int _verb; // 1 for function start/end
488  // 2 for all information
489  // 0 = nothing
490 
491  bool _with_ghost; // If true(default), then use ghost information.
492 
493  struct tagStruct {
494  unsigned size; // tag size: # of values per entity
495  TagType type; // tag type
496  void * edata; // elemental data
497  void * ndata; // nodal data
498  msq_std::string name;
499  };
500 
501 #if 0
502  tagStruct::tagStruct()
503  : size(0), type(0), edata(NULL), ndata(NULL), dval(NULL)
504  {
505  ;
506  }
507 #endif
508 
509  std::map<msq_std::string,tagStruct> s_to_t;
510 
511 };
512 
513 
514 #if 0
516 {
517  return TopologyInfo::corners( topo );
518 }
519 #endif
520 
523 public:
524 
526  MyEntityIterator(uint size){ _cur = 1; _size = size;}
527 
530  {_cur = 0;
531  _size = 0;
532  }
533 
535  virtual void restart(){
536  _cur = 1;
537  };
538 
540  virtual Mesh::EntityHandle operator*() const {
541  if (_cur > _size)
542  return 0;
543  else
544  return (char*)NULL+_cur;
545  }
546 
548  virtual void operator++(){
549  _cur ++;
550  }
551 
553 
557  virtual bool is_at_end() const{
558  if (_cur <= _size) return 0;
559  else return 1;
560  }
561 private:
562  uint _cur; // The current node's position.
563  uint _size;// The size of the element array
564 };
565 
567 
568 #endif
569 
570 
571 
572 
573 
574 
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_95.h:133
EntityHandle VertexHandle
Definition: MesqPane_95.h:108
subroutine invert(a, nrow, det)
Definition: v3d8_me.f90:1392
Contains the prototypes for the Pane object.
EntityTopology
Definition: Mesquite.hpp:92
A class for iterating through a Panes vertices or elements.
Definition: MesqPane.h:495
virtual ~MyEntityIterator()
Destructor.
Definition: MesqPane_95.h:529
#define MESQUITE_END_NAMESPACE
Definition: MesqPane_95.h:73
This file contains the Mesquite mesh interface. Many users will want to implement a concrete class de...
void * TagHandle
Definition: MesqPane_95.h:102
void * EntityHandle
Opaque EntityHandle type and tag type.
Definition: MesqPane_95.h:101
virtual Mesh::EntityHandle operator*() const
Return the handle currently being pointed to by the iterator.
Definition: MesqPane_95.h:540
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_95.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_95.h:127
virtual void operator++()
Move to the next entity.
Definition: MesqPane_95.h:548
EntityHandle ElementHandle
Definition: MesqPane_95.h:109
double length(Vector3D *const v, int n)
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_95.h:535
#define MESQUITE_BEGIN_NAMESPACE
Definition: MesqPane_95.h:72
MyEntityIterator(uint size)
Constructor.
Definition: MesqPane_95.h:526
virtual bool is_at_end() const
Check if we are at the end of the entites.
Definition: MesqPane_95.h:557
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_95.h:165
EntityIterator ElementIterator
Utility for detecting boundaries of a pane.
USE_MOP_NAMESPACE
Definition: metric_demo.C:33