Mesh Oriented datABase  (version 5.5.1)
An array-based unstructured mesh library
StructuredElementSeq.hpp
Go to the documentation of this file.
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 STRUCTURED_ELEMENT_SEQUENCE
17 #define STRUCTURED_ELEMENT_SEQUENCE
18 
19 //
20 // Class: StructuredElementSeq
21 //
22 // Purpose: represent a rectangular element of mesh
23 //
24 // A ScdElement represents a rectangular element of mesh, including both vertices and
25 // elements, and the parametric space used to address that element. Vertex data,
26 // i.e. coordinates, may not be stored directly in the element, but the element returns
27 // information about the vertex handles of vertices in the element. Vertex and element
28 // handles associated with the element are each contiguous.
29 
30 #include "ElementSequence.hpp"
31 #include "ScdElementData.hpp"
32 
33 namespace moab
34 {
35 
37 {
38  public:
39  //! constructor
41  const int imin,
42  const int jmin,
43  const int kmin,
44  const int imax,
45  const int jmax,
46  const int kmax,
47  int* is_periodic = NULL );
48 
49  virtual ~StructuredElementSeq();
50 
52  {
53  return reinterpret_cast< ScdElementData* >( data() );
54  }
55  ScdElementData const* sdata() const
56  {
57  return reinterpret_cast< const ScdElementData* >( data() );
58  }
59 
60  //! get handle of vertex at i, j, k
61  EntityHandle get_vertex( const int i, const int j, const int k ) const
62  {
63  return get_vertex( HomCoord( i, j, k ) );
64  }
65 
66  //! get handle of vertex at homogeneous coords
67  inline EntityHandle get_vertex( const HomCoord& coords ) const
68  {
69  return sdata()->get_vertex( coords );
70  }
71 
72  //! get handle of element at i, j, k
73  EntityHandle get_element( const int i, const int j, const int k ) const
74  {
75  return sdata()->get_element( i, j, k );
76  }
77 
78  //! get handle of element at homogeneous coords
79  EntityHandle get_element( const HomCoord& coords ) const
80  {
81  return sdata()->get_element( coords.i(), coords.j(), coords.k() );
82  }
83 
84  //! get min params for this element
85  const HomCoord& min_params() const
86  {
87  return sdata()->min_params();
88  }
89  void min_params( HomCoord& coords ) const
90  {
91  coords = min_params();
92  }
93  void min_params( int& i, int& j, int& k ) const
94  {
95  i = min_params().i();
96  j = min_params().j();
97  k = min_params().k();
98  }
99 
100  //! get max params for this element
101  const HomCoord& max_params() const
102  {
103  return sdata()->max_params();
104  }
105  void max_params( HomCoord& coords ) const
106  {
107  coords = max_params();
108  }
109  void max_params( int& i, int& j, int& k ) const
110  {
111  i = max_params().i();
112  j = max_params().j();
113  k = max_params().k();
114  }
115 
116  //! get the number of vertices in each direction, inclusive
117  void param_extents( int& di, int& dj, int& dk ) const
118  {
119  sdata()->param_extents( di, dj, dk );
120  }
121 
122  //! given a handle, get the corresponding parameters
123  ErrorCode get_params( const EntityHandle ehandle, int& i, int& j, int& k ) const
124  {
125  return sdata()->get_params( ehandle, i, j, k );
126  }
127 
128  //! convenience functions for parameter extents
129  int i_min() const
130  {
131  return min_params().i();
132  }
133  int j_min() const
134  {
135  return min_params().j();
136  }
137  int k_min() const
138  {
139  return min_params().k();
140  }
141  int i_max() const
142  {
143  return max_params().i();
144  }
145  int j_max() const
146  {
147  return max_params().j();
148  }
149  int k_max() const
150  {
151  return max_params().k();
152  }
153 
154  //! test the bounding vertex sequences and determine whether they fully
155  //! define the vertices covering this element block's parameter space
156  inline bool boundary_complete() const
157  {
158  return sdata()->boundary_complete();
159  }
160 
161  //! test whether this sequence contains these parameters
162  bool contains( const int i, const int j, const int k ) const
163  {
164  return sdata()->contains( HomCoord( i, j, k ) );
165  }
166  inline bool contains( const HomCoord& coords ) const
167  {
168  return sdata()->contains( coords );
169  }
170 
171  //! get connectivity of an entity given entity's parameters
173  const int j,
174  const int k,
175  std::vector< EntityHandle >& connectivity ) const
176  {
177  return sdata()->get_params_connectivity( i, j, k, connectivity );
178  }
179 
180  //! Return whether box is periodic in i
181  /** Return whether box is periodic in i
182  * \return True if box is periodic in i direction
183  */
184  int is_periodic_i() const
185  {
186  return sdata()->is_periodic_i();
187  };
188 
189  //! Return whether box is periodic in j
190  /** Return whether box is periodic in j
191  * \return True if box is periodic in j direction
192  */
193  int is_periodic_j() const
194  {
195  return sdata()->is_periodic_j();
196  };
197 
198  //! Return whether box is periodic in i and j
199  /** Return whether box is periodic in i and j
200  * \param is_periodic_ij Non-zero if periodic in i [0] or j [1]
201  */
202  void is_periodic( int is_periodic_ij[2] ) const
203  {
204  sdata()->is_periodic( is_periodic_ij );
205  };
206 
207  /***************** Methods from ElementSequence *****************/
208 
209  virtual ErrorCode get_connectivity( EntityHandle handle,
210  std::vector< EntityHandle >& connect,
211  bool topological = false ) const;
212 
213  virtual ErrorCode get_connectivity( EntityHandle handle,
214  EntityHandle const*& connect,
215  int& connect_length,
216  bool topological = false,
217  std::vector< EntityHandle >* storage = 0 ) const;
218 
219  virtual ErrorCode set_connectivity( EntityHandle handle, EntityHandle const* connect, int connect_length );
220 
222 
223  /***************** Methods from EntitySequence *****************/
224 
225  /* Replace the ElementSequence implementation of this method with
226  * one that always returns zero, because we cannot re-use handles
227  * that are within a ScdElementData
228  */
229  virtual int values_per_entity() const;
230 
231  virtual EntitySequence* split( EntityHandle here );
232 
234 
235  virtual void get_const_memory_use( unsigned long& bytes_per_entity, unsigned long& size_of_sequence ) const;
236 
237  protected:
238  StructuredElementSeq( StructuredElementSeq& split_from, EntityHandle here ) : ElementSequence( split_from, here ) {}
239 };
240 
241 } // namespace moab
242 
243 #endif