SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VMesh.h
Go to the documentation of this file.
1 /*
2  For more information, please see: http://software.sci.utah.edu
3 
4  The MIT License
5 
6  Copyright (c) 2009 Scientific Computing and Imaging Institute,
7  University of Utah.
8 
9 
10  Permission is hereby granted, free of charge, to any person obtaining a
11  copy of this software and associated documentation files (the "Software"),
12  to deal in the Software without restriction, including without limitation
13  the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  and/or sell copies of the Software, and to permit persons to whom the
15  Software is furnished to do so, subject to the following conditions:
16 
17  The above copyright notice and this permission notice shall be included
18  in all copies or substantial portions of the Software.
19 
20  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21  OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26  DEALINGS IN THE SOFTWARE.
27 */
28 
29 
30 #ifndef CORE_DATATYPES_VMESH_H
31 #define CORE_DATATYPES_VMESH_H
32 
39 
41 
43 
45 
46 namespace SCIRun {
47 
48 class VMesh;
50 
51 typedef boost::shared_ptr<VMesh> VMeshHandle;
52 
53 class SCISHARE VMesh {
54 public:
55 
56  /// VIRTUAL INTERFACE
57 
58  /// typedefs for Node, Edge, Face and Cell
59  /// These are the basic types that we use, they are typedefed
60  /// so we can alter the underlying type easily
61 
62  /// All indices are always of index_type
64  /// Weights for interpolation
65  typedef double weight_type;
66  /// size_type and index_type need to be the same
67  /// but they have their own type to make the code more readable
69  /// Array of indices
70  typedef std::vector<index_type> array_type;
71  /// Array of points
72  typedef std::vector<Core::Geometry::Point> points_type;
73  /// Dimensions of a mesh, these are used for the regular grids
74  /// Irregular grids only have one dimension, namely the number
75  /// of nodes or elements
76  typedef std::vector<size_type> dimension_type;
77  /// A stack vector is a faster class than vector but is limited
78  /// to a maximum number of entries
79  /// coords_type is used to denote the location inside an element
80  /// in local coordinates
82  /// An array of coords
83  typedef std::vector<StackVector<double,3> > coords_array_type;
84  /// 2D array of coords
85  typedef std::vector<std::vector<StackVector<double,3> > > coords_array2_type;
86  /// Derivative of points each component contains the x,y, and z
87  /// derivative of the point. This is used in higher order elements
89  /// Mask type for setting bits. This one is set to special type
90  /// to remind the user that only bit operations asre valid on masks
91  typedef unsigned int mask_type;
92 
93  /// A dual vector will store the first entries on the stack,
94  /// if extra space is needed it will create vector to store
95  /// data on. This way most operations are done directly from
96  /// the stack, only in less common situations memory is allocated
97  /// and is used to store data. Here we allow 12 spaces to be on the
98  /// stack which should be enough.
101 
102  /// Virtual indices, iterators, and arrays
103  /// Class for indexing nodes
104  class Node {
105  public:
110  };
111 
112  typedef std::vector<Node::array_type> nodes_array_type;
113 
114  /// Class for indexing edge nodes
115  /// These are used in quadratic approaches
116  class ENode {
117  public:
122  };
123 
124  /// Class for indexing edges
125  class Edge {
126  public:
131  };
132 
133  /// Class for indexing faces
134  class Face {
135  public:
140  };
141 
142  /// Class for indexing cells
143  /// Note: this is one is here for completion, but one should in most cases
144  /// use Elem which denotes the elements of the mesh. Elem indices can be used
145  /// in more function calls and are therefore more useful
146  class Cell {
147  public:
152  };
153 
154  /// Class for indexing elements
155  /// Elements denote the highest topology in the mesh.
156  /// For example for TriSurfMeshes it denotes the faces of the surface, however
157  /// for the HexVolMesh it denotes the volumetric elements
158 
159  /// Elem has become a replacement for most Edge, Face, and Cell index types
160  /// and can be used in more functions. The reason this one is preferred is that
161  /// it allows the user to write code that works on any type of mesh without
162  /// having to think about the dimensionality of the elements.
163  /// Only when dimensionality is important the Edge, Face, and Cell indices
164  /// should be used.
165  class Elem {
166  public:
171  };
172 
173 
174  /// Class for indexing topological derivative of elements
175  /// Hence for a TriSurfMesh these are the edges of the mesh, and
176  /// for a HexVolMesh these are the faces of the mesh.
177  /// This class is generally used to do neighborhood and boundary
178  /// algorithms. Note that for a PointCloudMesh the derivative is defined
179  /// as a Node and both Elem, Node, and DElem are in fact the same.
180  class DElem {
181  public:
186  };
187 
188 
189  /// All information needed to do one interpolation inside an element
190  /// This class is mostly for internal use in interpolation functions.
191  /// It is used sporadically in algorithms to speed up the code by preallocating
192  /// this structure
194  public:
197  int basis_order; // which order was created
198  index_type elem_index; // which element
199  StackVector<index_type,8> node_index; // nodes that span the element
200  StackVector<index_type,12> edge_index; // edges that span the element
201  size_type num_hderivs; // number of derivatives per node
202  StackBasedVector<double,64> weights; // weights for given points and derivatives
203  };
204 
205  /// We have special code for doing multiple interpolations at the same time
206  /// all for speeding up the code and limit the number of virtual function
207  /// calls.
208  typedef std::vector<ElemInterpolate> MultiElemInterpolate;
209 
210  // All information needed to do one interpolation inside
211  // one element to determine the gradient.
212  class ElemGradient {
213  public:
216  int basis_order; // which order was created
217  index_type elem_index; // which element
218  StackBasedVector<index_type,8> node_index; // nodes that span the element
219  StackVector<index_type,12> edge_index; // edges that span the element
220  size_type num_hderivs; // Number of derivatives per point
221  StackBasedVector<double,64> weights; // weights for given points
222 
223  size_type num_derivs; // Number of derivatives in topology
224  StackVector<double,9> inverse_jacobian; // Inverse jacobian, for local to global transformation
226  };
227 
228  /// Multiple gradient calculations in parallel.
229  typedef std::vector<ElemGradient> MultiElemGradient;
230 
231  /// instantiate the element information
232  /// as these are protected the various derived constructors can fill
233  /// these out.
234  VMesh() :
235  basis_order_(0),
236  dimension_(0),
237  has_normals_(false),
238  is_editable_(false),
239  is_regular_(false),
240  is_structured_(false),
241  num_nodes_per_elem_(0),
242  num_enodes_per_elem_(0),
243  num_edges_per_elem_(0),
244  num_faces_per_elem_(0),
245  num_nodes_per_face_(0),
246  num_edges_per_face_(0)
247  {
248  /// This call is only made in DEBUG mode, to keep a record of all the
249  /// objects that are being allocated and freed.
250  DEBUG_CONSTRUCTOR("VMesh")
251  }
252 
253  /// Destructor needs to be virtual to ensure that we can delete the full
254  /// virtual interface from the VMesh interface
255  virtual ~VMesh()
256  {
257  /// This call is only made in DEBUG mode, to keep a record of all the
258  /// objects that are being allocated and freed.
259  DEBUG_DESTRUCTOR("VMesh")
260  }
261 
262  /// iterators for the virtual topology indices. These are not strictly needed
263  /// but make the concepts in line with previous version. All iterators now
264  /// go from 0 to number of elements, using consecutive unique numbers
265 
266  inline void begin(Node::iterator &it) const
267  { it = 0; }
268  inline void begin(ENode::iterator &it) const
269  { it = 0; }
270  inline void begin(Edge::iterator &it) const
271  { it = 0; }
272  inline void begin(Face::iterator &it) const
273  { it = 0; }
274  inline void begin(Cell::iterator &it) const
275  { it = 0; }
276  inline void begin(Elem::iterator &it) const
277  { it = 0; }
278  inline void begin(DElem::iterator &it) const
279  { it = 0; }
280 
281  inline void end(Node::iterator &it) const
282  { Node::size_type s; size(s); it = static_cast<index_type>(s); }
283  inline void end(ENode::iterator &it) const
284  { Node::size_type s; size(s); it = static_cast<index_type>(s); }
285  inline void end(Edge::iterator &it) const
286  { Edge::size_type s; size(s); it = static_cast<index_type>(s); }
287  inline void end(Face::iterator &it) const
288  { Face::size_type s; size(s); it = static_cast<index_type>(s); }
289  inline void end(Cell::iterator &it) const
290  { Cell::size_type s; size(s); it = static_cast<index_type>(s); }
291  inline void end(Elem::iterator &it) const
292  { Elem::size_type s; size(s); it = static_cast<index_type>(s); }
293  inline void end(DElem::iterator &it) const
294  { DElem::size_type s; size(s); it = static_cast<index_type>(s); }
295 
296 
297  /// Get the number of elements in the mesh of the specified type
298  /// Note: that for any size other then the number of nodes or
299  /// elements, one has to synchronize that part of the mesh.
300  virtual void size(Node::size_type& size) const;
301  virtual void size(ENode::size_type& size) const;
302  virtual void size(Edge::size_type& size) const;
303  virtual void size(Face::size_type& size) const;
304  virtual void size(Cell::size_type& size) const;
305  virtual void size(Elem::size_type& size) const;
306  virtual void size(DElem::size_type& size) const;
307 
308  /// We have been using the num_#type#() in other functions as well to
309  /// determine the number of nodes, edges etc. These are just shortcuts to
310  /// make programs more readable
311  inline size_type num_nodes() const
312  { Node::index_type s; size(s); return(static_cast<size_t>(s)); }
313  inline size_type num_enodes() const
314  { ENode::index_type s; size(s); return(static_cast<size_t>(s)); }
315  inline size_type num_edges() const
316  { Edge::index_type s; size(s); return(static_cast<size_t>(s)); }
317  inline size_type num_faces() const
318  { Face::index_type s; size(s); return(static_cast<size_t>(s)); }
319  inline size_type num_cells() const
320  { Cell::index_type s; size(s); return(static_cast<size_t>(s)); }
321  inline size_type num_elems() const
322  { Elem::index_type s; size(s); return(static_cast<size_t>(s)); }
323  inline size_type num_delems() const
324  { DElem::index_type s; size(s); return(static_cast<size_t>(s)); }
325 
326  /// NOTE NOT VALID FOR EACH MESH:
327  virtual boost::shared_ptr<SearchGridT<SCIRun::index_type> > get_elem_search_grid();
328  virtual boost::shared_ptr<SearchGridT<SCIRun::index_type> > get_node_search_grid();
329 
330  /// test for special case where the mesh is empty
331  /// empty meshes may need a special treatment
332  inline bool is_empty() const
333  { Node::index_type s; size(s); return (s == 0); }
334 
335  /// Topological functions: note that currently most meshes have an incomplete
336  /// set implemented. Currently each mesh has:
337  /// Getting cell, face, edge indices from node indices
338  /// Getting the indices of the elements that are topologically building up the
339  /// the element: e.g. one can derive faces from a cell index but not YET
340  /// vice versa.
341 
342  /// Get the nodes that make up an element
343  /// Depending on the geometry not every function may be available
344  virtual void get_nodes(Node::array_type& nodes, Node::index_type i) const;
345  virtual void get_nodes(Node::array_type& nodes, Edge::index_type i) const;
346  virtual void get_nodes(Node::array_type& nodes, Face::index_type i) const;
347  virtual void get_nodes(Node::array_type& nodes, Cell::index_type i) const;
348  virtual void get_nodes(Node::array_type& nodes, Elem::index_type i) const;
349  virtual void get_nodes(Node::array_type& nodes, DElem::index_type i) const;
350 
351 
352  /// Get the nodes that make up an element
353  /// Depending on the geometry not every function may be available
354  virtual void get_enodes(ENode::array_type& nodes, Node::index_type i) const;
355  virtual void get_enodes(ENode::array_type& nodes, Edge::index_type i) const;
356  virtual void get_enodes(ENode::array_type& nodes, Face::index_type i) const;
357  virtual void get_enodes(ENode::array_type& nodes, Cell::index_type i) const;
358  virtual void get_enodes(ENode::array_type& nodes, Elem::index_type i) const;
359  virtual void get_enodes(ENode::array_type& nodes, DElem::index_type i) const;
360 
361 
362  /// Get the edges that make up an element
363  /// or get the edges that contain certain nodes
364  /// Depending on the geometry not every function may be available
365  virtual void get_edges(Edge::array_type& edges, Node::index_type i) const;
366  virtual void get_edges(Edge::array_type& edges, Edge::index_type i) const;
367  virtual void get_edges(Edge::array_type& edges, Face::index_type i) const;
368  virtual void get_edges(Edge::array_type& edges, Cell::index_type i) const;
369  virtual void get_edges(Edge::array_type& edges, Elem::index_type i) const;
370  virtual void get_edges(Edge::array_type& edges, DElem::index_type i) const;
371 
372 
373  /// Get the faces that make up an element
374  /// or get the faces that contain certain nodes or edges
375  /// Depending on the geometry not every function may be available
376  virtual void get_faces(Face::array_type& faces, Node::index_type i) const;
377  virtual void get_faces(Face::array_type& faces, Edge::index_type i) const;
378  virtual void get_faces(Face::array_type& faces, Face::index_type i) const;
379  virtual void get_faces(Face::array_type& faces, Cell::index_type i) const;
380  virtual void get_faces(Face::array_type& faces, Elem::index_type i) const;
381  virtual void get_faces(Face::array_type& faces, DElem::index_type i) const;
382 
383  /// Get the cell index that contains the specified component
384  /// Depending on the geometry not every function may be available
385  virtual void get_cells(Cell::array_type& cells, Node::index_type i) const;
386  virtual void get_cells(Cell::array_type& cells, Edge::index_type i) const;
387  virtual void get_cells(Cell::array_type& cells, Face::index_type i) const;
388  virtual void get_cells(Cell::array_type& cells, Cell::index_type i) const;
389  virtual void get_cells(Cell::array_type& cells, Elem::index_type i) const;
390  virtual void get_cells(Cell::array_type& cells, DElem::index_type i) const;
391 
392  /// Get the element index that contains the specified component
393  /// Depending on the geometry not every function may be available
394  virtual void get_elems(Elem::array_type& elems, Node::index_type i) const;
395  virtual void get_elems(Elem::array_type& elems, Edge::index_type i) const;
396  virtual void get_elems(Elem::array_type& elems, Face::index_type i) const;
397  virtual void get_elems(Elem::array_type& elems, Cell::index_type i) const;
398  virtual void get_elems(Elem::array_type& elems, Elem::index_type i) const;
399  virtual void get_elems(Elem::array_type& elems, DElem::index_type i) const;
400 
401  /// Get the derived element index that contains the specified component
402  /// Depending on the geometry not every function may be available
403  virtual void get_delems(DElem::array_type& delems, Node::index_type i) const;
404  virtual void get_delems(DElem::array_type& delems, Edge::index_type i) const;
405  virtual void get_delems(DElem::array_type& delems, Face::index_type i) const;
406  virtual void get_delems(DElem::array_type& delems, Cell::index_type i) const;
407  virtual void get_delems(DElem::array_type& delems, Elem::index_type i) const;
408  virtual void get_delems(DElem::array_type& delems, DElem::index_type i) const;
409 
410  /// Get the topology index from the vertex indices
411  virtual bool get_elem(Elem::index_type& elem, Node::array_type& nodes) const;
412  virtual bool get_delem(DElem::index_type& delem, Node::array_type& nodes) const;
413  virtual bool get_cell(Cell::index_type& cell, Node::array_type& nodes) const;
414  virtual bool get_face(Face::index_type& face, Node::array_type& nodes) const;
415  virtual bool get_edge(Edge::index_type& edge, Node::array_type& nodes) const;
416 
417  /// Get the center of a certain mesh element
418  virtual void get_center(Core::Geometry::Point &point, Node::index_type i) const;
419  virtual void get_center(Core::Geometry::Point &point, ENode::index_type i) const;
420  virtual void get_center(Core::Geometry::Point &point, Edge::index_type i) const;
421  virtual void get_center(Core::Geometry::Point &point, Face::index_type i) const;
422  virtual void get_center(Core::Geometry::Point &point, Cell::index_type i) const;
423  virtual void get_center(Core::Geometry::Point &point, Elem::index_type i) const;
424  virtual void get_center(Core::Geometry::Point &point, DElem::index_type i) const;
425 
426  /// Get the centers of a series of nodes
427  virtual void get_centers(Core::Geometry::Point* points, Node::array_type& array) const;
428  virtual void get_centers(Core::Geometry::Point* points, Elem::array_type& array) const;
429 
430  /// Get the centers of a series of nodes, with points in an STL vector
431  /// These just overload the function calls defined above.
432  inline void get_centers(points_type &points, Node::array_type& array) const
433  { points.resize(array.size()); get_centers(&(points[0]),array); }
434  inline void get_centers(points_type &points, Elem::array_type& array) const
435  { points.resize(array.size()); get_centers(&(points[0]),array); }
436 
437 
438  inline void get_all_node_centers(points_type &points) const
439  {
440  Node::size_type sz = num_nodes();
441  Node::array_type array(sz);
442  for (Node::index_type k=0;k<sz;k++) array[k] = k;
443  points.resize(array.size()); get_centers(&(points[0]),array);
444  }
445  inline void get_all_elem_centers(points_type &points) const
446  {
447  Elem::size_type sz = num_elems();
448  Elem::array_type array(sz);
449  for (Elem::index_type k=0;k<sz;k++) array[k] = k;
450  points.resize(array.size()); get_centers(&(points[0]),array);
451  }
452 
453 
454  /// Get the geometrical sizes of the mesh elements
455  /// For nodes and enodes there is no size, hence predefine them in case
456  /// some makes the call
457  inline double get_size(Node::index_type /*i*/) const
458  { return (0.0); }
459  inline double get_size(ENode::index_type /*i*/) const
460  { return (0.0); }
461 
462  /// Get the geometrical size of topological mesh components
463  virtual double get_size(Edge::index_type i) const;
464  virtual double get_size(Face::index_type i) const;
465  virtual double get_size(Cell::index_type i) const;
466  virtual double get_size(Elem::index_type i) const;
467  virtual double get_size(DElem::index_type i) const;
468 
469  /// Get the size of an element. This function is intended to check for
470  /// zero volume elements before adding an element to a mesh.
471  virtual double get_size(Node::array_type& array) const;
472 
473  /// alternative ways to get the size values
474  /// Again these are all defined inline so we do not get additional virtual
475  /// calls in the interface an to reduce the overhead in the actual implementation
476  /// of the virtual interface mesh classes.
477  inline double get_length(Edge::index_type i) const
478  { return (get_size(i)); }
479  inline double get_area(Face::index_type i) const
480  { return (get_size(i)); }
481  inline double get_volume(Cell::index_type i) const
482  { return (get_size(i)); }
483 
484  inline double get_length(Elem::index_type i) const
485  { return (get_size(i)); }
486  inline double get_area(Elem::index_type i) const
487  { return (get_size(i)); }
488  inline double get_volume(Elem::index_type i) const
489  { return (get_size(i)); }
490 
491  /// Specialized functions to get weights for the interpolation
492  /// One should use these instead of get_weights
493 
494  /// These functions fill out the interpolation structure, so that one can
495  /// used in the code. The interpolation structures know about basis order
496  /// and hence will do the right interpolation when given to a function of
497  /// VField for interpolation
498  virtual void get_interpolate_weights(const Core::Geometry::Point& p,
499  ElemInterpolate& ei,
500  int basis_order) const;
501 
502  virtual void get_interpolate_weights(const coords_type& coords,
503  Elem::index_type elem,
504  ElemInterpolate& ei,
505  int basis_order) const;
506 
507  virtual void get_minterpolate_weights(const std::vector<Core::Geometry::Point>& p,
508  MultiElemInterpolate& ei,
509  int basis_order) const;
510 
511  virtual void get_minterpolate_weights(const std::vector<coords_type>& coords,
512  Elem::index_type elem,
513  MultiElemInterpolate& ei,
514  int basis_order) const;
515 
516  /// Same functions but now for determining gradients
517  virtual void get_gradient_weights(const Core::Geometry::Point& p,
518  ElemGradient& ei,
519  int basis_order) const;
520 
521  virtual void get_gradient_weights(const coords_type& coords,
522  Elem::index_type elem,
523  ElemGradient& ei,
524  int basis_order) const;
525 
526  virtual void get_mgradient_weights(const std::vector<Core::Geometry::Point>& p,
527  MultiElemGradient& ei,
528  int basis_order) const;
529 
530  virtual void get_mgradient_weights(const std::vector<coords_type>& coords,
531  Elem::index_type elem,
532  MultiElemGradient& eg,
533  int basis_order) const;
534 
535  /// Old get_weights function, in this case the user needs to know about
536  /// basis order and the basis order that is needed must be given.
537  /// Also this function implies a certain ordering of the weights and this
538  /// function only remains in order to provide a sense of backwards compatiblity.
539  virtual void get_weights(const coords_type& coords,
540  std::vector<double>& weights,
541  int basis_order) const;
542 
543  /// Old get_derivate_weights function, which returns weights but now for computing
544  /// the gradient of a field.
545  virtual void get_derivate_weights(const coords_type& coords,
546  std::vector<double>& weights,
547  int basis_order) const;
548 
549  /// These two functions specify a sampling scheme for interpolation,
550  /// intergration etc. Currently it supports 3 Gaussian schemes that define
551  /// the gaussian quadrature points for the meshes. Specify the order between
552  /// 1 and 3.
553  /// The regular sampling is intended for operations other than integration and
554  /// sample using a regular scheme inside the element. Currently an order between
555  /// 1 and 5 are supported to indicate the number of samples along one of the
556  /// edges. Hence scheme 1 only gives one point in the center and scheme 5 can
557  /// generate up to 125 sampling points depending on the topology of the element.
558 
559  virtual void get_gaussian_scheme(std::vector<VMesh::coords_type>& coords,
560  std::vector<double>& weights, int order) const;
561 
562  virtual void get_regular_scheme(std::vector<VMesh::coords_type>& coords,
563  std::vector<double>& weights, int order) const;
564 
565 ///////////////
566 
567  /// Locate where a position is in the mesh
568  /// The node version finds the closest node
569  /// The element version find the element that contains the point
570  virtual bool locate(VMesh::Node::index_type &i, const Core::Geometry::Point &point) const;
571  virtual bool locate(VMesh::Elem::index_type &i, const Core::Geometry::Point &point) const;
572  virtual bool locate(VMesh::Elem::index_type &i,
573  VMesh::coords_type &coords, const Core::Geometry::Point& point) const;
574 
575  /// multi locate functions. An 'm' in front of a function tends to denote
576  /// that this function is vectorized for convenience. Depending on the
577  /// underlying functionality it calls the single case multiple times
578  /// or adds some optimization. In this case optimization occurs by assuming
579  /// the points are close together and previous node or element indices are
580  /// tested first to see if that is the index for the next one in the array
581  /// Hence in optimal cases the search is reduced to a few points for a cloud
582  /// of points
583 
584  virtual void mlocate(std::vector<Node::index_type> &i,
585  const std::vector<Core::Geometry::Point> &point) const;
586  virtual void mlocate(std::vector<Elem::index_type> &i,
587  const std::vector<Core::Geometry::Point> &point) const;
588 
589  /// Find elements that are inside or close to the bounding box. This function
590  /// uses the underlying search structure to find candidates that are close.
591  /// This functionality is general intended to speed up searching for elements
592  /// in a certain region.
593  virtual bool locate(VMesh::Elem::array_type &a, const Core::Geometry::BBox& bbox) const;
594 
595  /// Find the closest point on a surface or a curve
596 
597  /// These functions return the closest node to a certain point
598  /// It returns the distance and the node index and the location of the
599  /// node.
600  virtual bool find_closest_node(double& dist,
601  Core::Geometry::Point& result,
603  const Core::Geometry::Point &point) const;
604 
605  /// This version uses a maximum radius for searching the node
606  /// If no nodes are within radius the function returns false.
607  virtual bool find_closest_node(double& dist,
608  Core::Geometry::Point& result,
610  const Core::Geometry::Point &point,
611  double maxdist) const;
612 
613  /// Simplified version that does not return the distance
616  const Core::Geometry::Point &point,
617  double maxdist)
618  { double dist; return(find_closest_node(dist,result,i,point,maxdist));}
619 
620  /// Simplified version that does not return the distance
623  const Core::Geometry::Point &point)
624  { double dist; return(find_closest_node(dist,result,i,point));}
625 
626  /// Find the nodes within a spherical region arounf point.
627  /// It returns the indices to the nodes
628  virtual bool find_closest_nodes(std::vector<VMesh::Node::index_type>& nodes,
629  const Core::Geometry::Point& p, double maxdist) const;
630 
631  virtual bool find_closest_nodes(std::vector<double>& distances,
632  std::vector<VMesh::Node::index_type>& nodes,
633  const Core::Geometry::Point& p,
634  double maxdist) const;
635 
636  /// Find the closest location that is part of an element
637  /// This function returns the projection point on the mesh
638  /// and the euclidian distance to the field which is the distance
639  /// between point and the projection.
640  /// It also returns the local coordinates of the element where the
641  /// projection point is located and the element index.
642  /// if no elements are found the function returns false.
643  virtual bool find_closest_elem(double &dist,
644  Core::Geometry::Point &result,
645  VMesh::coords_type &coords,
647  const Core::Geometry::Point &point) const;
648 
649  /// Same function, but now limited to a certain search ratius.
650  /// if no elements are found the function returns false.
651  virtual bool find_closest_elem(double &dist,
652  Core::Geometry::Point &result,
653  VMesh::coords_type &coords,
655  const Core::Geometry::Point &point,
656  double maxdist) const;
657 
658  /// Simplified version that does not return the local coordinates.
659  inline bool find_closest_elem(double &dist,
660  Core::Geometry::Point &result,
662  const Core::Geometry::Point &point) const
663  {
664  VMesh::coords_type coords;
665  return(find_closest_elem(dist,result,coords,i,point));
666  }
667 
668  inline bool find_closest_elem(double &dist,
669  Core::Geometry::Point &result,
671  const Core::Geometry::Point &point,
672  double maxdist) const
673  {
674  VMesh::coords_type coords;
675  return(find_closest_elem(dist,result,coords,i,point,maxdist));
676  }
677 
678 
679  /// Even more simplified version
682  const Core::Geometry::Point &point) const
683  {
684  double dist;
685  VMesh::coords_type coords;
686  return(find_closest_elem(dist,result,coords,i,point));
687  }
688 
689  /// Another simplified version
692  const Core::Geometry::Point &point) const
693  {
694  double dist;
695  Core::Geometry::Point result;
696  return(find_closest_elem(dist,result,coords,i,point));
697  }
698 
699 
700  /// @todo: Need to reformulate this one, closest element can have multiple
701  // intersection points
702  virtual bool find_closest_elems(double& dist,
703  Core::Geometry::Point& result,
705  const Core::Geometry::Point &point) const;
706 
707  /// Find the coordinates of a point in a certain element
708  virtual bool get_coords(coords_type& coords,
709  const Core::Geometry::Point &point, Elem::index_type i) const;
710 
711  /// Interpolate from local coordinates to global coordinates
712  virtual void interpolate(Core::Geometry::Point &p,
713  const coords_type& coords, Elem::index_type i) const;
714 
715  /// Multiple interpolations from local coordinates to global coordinates
716  virtual void minterpolate(std::vector<Core::Geometry::Point> &p,
717  const std::vector<coords_type>& coords,
718  Elem::index_type i) const;
719 
720  /// Interpolate from local coordinates to a derivative in local coordinates
721  virtual void derivate(dpoints_type &p,
722  const coords_type& coords, Elem::index_type i) const;
723 
724  /// Get the normal to an element if this is a valid operation.
725  /// This is only implemented for surface and volume meshes.
726  /// As elements can be curved the coordinates specify where on the
727  /// element one wants to compute the normal.
728 
729  /// This is the volumetric version where one has to specify as well which
730  /// face is involved.
731  virtual void get_normal(Core::Geometry::Vector &result, coords_type& coords,
732  Elem::index_type eidx, DElem::index_type fidx) const;
733 
734  /// This is the surface version.
735  inline void get_normal(Core::Geometry::Vector &result, coords_type& coords,
736  Elem::index_type eidx) const
737  { get_normal(result,coords,eidx,0); }
738 
739  /// Multiple normals short cut
740  inline void get_normals(std::vector<Core::Geometry::Vector> &result, std::vector<coords_type>& coords,
741  Elem::index_type eidx) const
742  { result.resize(coords.size()); for (size_t j=0; j<coords.size(); j++)get_normal(result[j],coords[j],eidx,0); }
743 
744  /// Set and get a node location.
745  /// Node set is only available for editable meshes
746 
747  /// Get the location of a random point inside the mesh
748  virtual void get_random_point(Core::Geometry::Point &p,
749  Elem::index_type i,FieldRNG &rng) const;
750 
751  /// Get the location of a point. As the old interface used both get_point and
752  /// get_center, these are short cuts to the one implementation that is done
753  /// under the name get_center.
754  inline void get_point(Core::Geometry::Point &point, Node::index_type i) const
755  { get_center(point,i); }
756  inline void get_point(Core::Geometry::Point &point, ENode::index_type i) const
757  { get_center(point,i); }
759  { Core::Geometry::Point p; get_point(p,i); return (p); }
761  { Core::Geometry::Point p; get_point(p,i); return (p); }
762 
763  /// Set the location of a point.
764  /// Note: one must be the single user of the mesh to do this
765  virtual void set_point(const Core::Geometry::Point &point, Node::index_type i);
766  virtual void set_point(const Core::Geometry::Point &point, ENode::index_type i);
767 
768 
769  /// These should only be used to speed up code within proper wrappers and
770  /// after checking the type of the underlying mesh as they allow direct
771  /// access to the mesh memory
772 
773  // Only for irregular data
774  virtual Core::Geometry::Point* get_points_pointer() const;
775  // Only for unstructured data
776  virtual VMesh::index_type* get_elems_pointer() const;
777 
778  /// Copy nodes from one mesh to another mesh
779  /// Note: currently only for irregular meshes
780  /// @todo: Add regular meshes to the mix
781  inline void copy_nodes(VMesh* imesh, Node::index_type i,
783  {
784  Core::Geometry::Point* ipoint = imesh->get_points_pointer();
785  Core::Geometry::Point* opoint = get_points_pointer();
786  for (index_type j=0; j<size; j++,i++,o++ ) opoint[o] = ipoint[i];
787  }
788 
789  inline void copy_nodes(VMesh* imesh)
790  {
791  size_type size = imesh->num_nodes();
792  resize_nodes(size);
793  Core::Geometry::Point* ipoint = imesh->get_points_pointer();
794  Core::Geometry::Point* opoint = get_points_pointer();
795  for (index_type j=0; j<size; j++) opoint[j] = ipoint[j];
796  }
797 
798  inline void copy_elems(VMesh* imesh, Elem::index_type i,
800  Elem::size_type offset)
801  {
802  VMesh::index_type* ielem = imesh->get_elems_pointer();
803  VMesh::index_type* oelem = get_elems_pointer();
804  index_type ii = i*num_nodes_per_elem_;
805  index_type oo = o*num_nodes_per_elem_;
806  size_type ss = size*num_nodes_per_elem_;
807  for (index_type j=0; j <ss; j++,ii++,oo++) oelem[oo] = ielem[ii]+offset;
808  }
809 
810  inline void copy_elems(VMesh* imesh)
811  {
812  VMesh::index_type* ielem = imesh->get_elems_pointer();
813  VMesh::index_type* oelem = get_elems_pointer();
814  size_type ss = num_elems()*num_nodes_per_elem_;
815  for (index_type j=0; j <ss; j++) oelem[j] = ielem[j];
816  }
817 
818  /// Preallocate memory for better performance
819  /// We have two versions for historic reasons
820  virtual void node_reserve(size_t size);
821  inline void reserve_nodes(size_t size)
822  { node_reserve(size); }
823 
824  /// reserve memory by specifying the number of elements that is expected
825  virtual void elem_reserve(size_t size);
826  inline void reserve_elems(size_t size)
827  { elem_reserve(size); }
828 
829  /// Actually resize the arrays.
830  /// Note: this is limited to certain meshes
831  virtual void resize_nodes(size_t size);
832  virtual void resize_elems(size_t size);
833  inline void resize_points(size_t size) { resize_nodes(size); }
834 
835  /// Add a node to a mesh
836  virtual void add_node(const Core::Geometry::Point &point,Node::index_type &i);
837  virtual void add_enode(const Core::Geometry::Point &point,ENode::index_type &i);
838 
839  /// alternative calls
840  inline void set_node(const Core::Geometry::Point &point, Node::index_type i)
841  { set_point(point,i); }
842  inline void set_enode(const Core::Geometry::Point &point, ENode::index_type i)
843  { set_point(point,i); }
844 
845  // Set the nodes that make up an element
846  virtual void set_nodes(Node::array_type& array, Edge::index_type idx);
847  virtual void set_nodes(Node::array_type& array, Face::index_type idx);
848  virtual void set_nodes(Node::array_type& array, Cell::index_type idx);
849  virtual void set_nodes(Node::array_type& array, Elem::index_type idx);
850 
852  { Node::index_type idx; add_node(point,idx); return (idx); }
853 
855  { get_point(point,i); }
857  { get_point(point,i); }
858 
859  /// Do not use this one as it is not clear whether it is a
860  /// element node or edge node
862  { Node::index_type idx; add_node(point,idx); return (idx); }
863 
864  /// Add an element to a mesh
865  virtual void add_elem(const Node::array_type &nodes,Elem::index_type &i);
866 
867  /// Alternative calls for add_elem
869  { Elem::index_type idx; add_elem(nodes,idx); return (idx); }
870 
871 
872  /// Currently only available for tetrahedra, triangles and curves
873  virtual void insert_node_into_elem(Elem::array_type& newelems,
874  Node::index_type& newnode,
875  Elem::index_type elem,
876  Core::Geometry::Point& point);
877 
878  /// Get the neighbors of a node or an element
879  virtual bool get_neighbor(Elem::index_type &neighbor,
880  Elem::index_type from, DElem::index_type delem) const;
881  virtual bool get_neighbors(Elem::array_type &elems,
882  Elem::index_type i, DElem::index_type delem) const;
883  virtual void get_neighbors(Elem::array_type &elems,
884  Elem::index_type i) const;
885  virtual void get_neighbors(Node::array_type &nodes,
886  Node::index_type i) const;
887 
888  /// Draw non linear elements
889  virtual void pwl_approx_edge(coords_array_type &coords,
890  Elem::index_type ci, unsigned int which_edge,
891  unsigned int div_per_unit) const;
892  virtual void pwl_approx_face(coords_array2_type &coords,
893  Elem::index_type ci, unsigned int which_face,
894  unsigned int div_per_unit) const;
895 
896  /// Get node normals, needed for visualization
897  virtual void get_normal(Core::Geometry::Vector& norm,Node::index_type i) const;
898 
899  /// Get the dimensions of the mesh.
900  /// This function will replace get_dim()
901  virtual void get_dimensions(dimension_type& dim);
902 
903  virtual void get_elem_dimensions(dimension_type& dim);
904 
905  /// The following functions are intended so one can do the local to global
906  /// transformation efficiently. As the transformation matrix is a constant for
907  /// certain meshes, it is precomputed and this function looks up the precomputed
908  /// jacobians, while for others it depends on the element and it is computed
909  /// on the fly. To assure that the fastest method is used, use these functions.
910 
911  /// Get the determinant of the jacobian matrix
912  /// Coords determine where the determinant needs o be evaluated
913  /// Generally LatVol, ImageMesh, TriMesh, TetMesh have a jacobian that
914  /// is independen of the local coordinate system, however HexVol, QuadSurf,
915  /// and PrismVol have values that depend on the local position within the
916  /// element
917  virtual double det_jacobian(const coords_type& coords,
918  Elem::index_type idx) const;
919 
920  /// Get the jacobian of the local to global transformation
921  /// Note J needs to be a least an array of 9 values.
922  /// Coords and idx again specify the element and the position in
923  /// local coordinates.
924  virtual void jacobian(const coords_type& coords,
925  Elem::index_type idx,
926  double* J) const;
927 
928  /// Get the inverse jacobian matrix. This gives as side product the
929  /// determinant of the inverse matrix.
930  virtual double inverse_jacobian(const coords_type& coords,
931  Elem::index_type idx,
932  double* Ji) const;
933 
934 
935  /// Element Quality metrics:
936 
937  /// Scaled jacobian of local to global transformation
938  virtual double scaled_jacobian_metric(const Elem::index_type idx) const;
939 
940  /// Jacobian of local to global transformation
941  virtual double jacobian_metric(const Elem::index_type idx) const;
942 
943  /// Volume of an element
944  inline double volume_metric(const Elem::index_type idx) const
945  { return(get_volume(idx)); }
946 
947  /// Scaled inscribed to circumscribed ratio
948  virtual double inscribed_circumscribed_radius_metric(Elem::index_type idx) const;
949 
950 
951  /// @todo: These should go: we have get_weights and get_derivate_weights
952  /// with basis_order call
953  /// Direct access to get weights functions in basis functions
954  /// These four are for interpolation
955  inline void get_constant_weights(coords_type& /*coords*/, std::vector<double>& weights)
956  { weights.resize(1); weights[0] = 1.0; }
957  virtual void get_linear_weights(coords_type& coords, std::vector<double>& weights);
958  virtual void get_quadratic_weights(coords_type& coords, std::vector<double>& weights);
959  virtual void get_cubic_weights(coords_type& coords, std::vector<double>& weights);
960 
961  /// These four are for computating gradients
962  inline void get_constant_derivate_weights(coords_type& /*coords*/, std::vector<double>& weights)
963  { weights.resize(1); weights[0] = 0.0; }
964  virtual void get_linear_derivate_weights(coords_type& coords, std::vector<double>& weights);
965  virtual void get_quadratic_derivate_weights(coords_type& coords, std::vector<double>& weights);
966  virtual void get_cubic_derivate_weights(coords_type& coords, std::vector<double>& weights);
967 
968 
969  /// Rerouting of some of the virtual mesh function calls
970 
971  virtual Core::Geometry::BBox get_bounding_box() const;
972 
973  /// This call is for synchronizing tables of precomputed elements
974  virtual bool synchronize(unsigned int sync);
975  virtual bool unsynchronize(unsigned int sync);
976 
977  // Only use this function when this is the only code that uses this mesh
978  virtual bool clear_synchronization();
979 
980  // Transform a full field, this one works on the full field
981  virtual void transform(const Core::Geometry::Transform &t);
982 
983  /// Get the transform from a regular field
984  virtual Core::Geometry::Transform get_transform() const;
985  /// Set the transform of a regular field
986  virtual void set_transform(const Core::Geometry::Transform &t);
987 
988  virtual void get_canonical_transform(Core::Geometry::Transform &t);
989  /// Get the epsilon for doing numerical computations
990  /// This one is generally 1e-7*length diagonal of the bounding box
991  virtual double get_epsilon() const;
992 
993  /// check the type of mesh
994  virtual bool is_pointcloudmesh() { return (false); }
995  virtual bool is_curvemesh() { return (false); }
996  virtual bool is_scanlinemesh() { return (false); }
997  virtual bool is_structcurvemesh() { return (false); }
998  virtual bool is_trisurfmesh() { return (false); }
999  virtual bool is_quadsurfmesh() { return (false); }
1000  virtual bool is_imagemesh() { return (false); }
1001  virtual bool is_structquadsurfmesh() { return (false); }
1002  virtual bool is_tetvolmesh() { return (false); }
1003  virtual bool is_prismvolmesh() { return (false); }
1004  virtual bool is_hexvolmesh() { return (false); }
1005  virtual bool is_latvolmesh() { return (false); }
1006  virtual bool is_structhexvolmesh() { return (false); }
1007 
1008  /// Check order of mesh
1009  inline bool is_constantmesh() { return (basis_order_ == 0); }
1010  inline bool is_linearmesh() { return (basis_order_ == 1); }
1011  inline bool is_quadraticmesh() { return (basis_order_ == 2); }
1012  inline bool is_cubicmesh() { return (basis_order_ == 3); }
1013  inline bool is_nonlinearmesh() { return (basis_order_ > 1); }
1014 
1015 
1016  //----------------------------------------------------------------------
1017 
1018  /// Used for local conversion of vector types
1019  /// At some point this function should go away
1020  template <class VEC1, class VEC2>
1021  inline void convert_vector(VEC1& v1, VEC2 v2) const
1022  {
1023  v1.resize(v2.size());
1024  for (size_t p=0; p < v2.size(); p++) v1[p] = static_cast<typename VEC1::value_type>(v2[p]);
1025  }
1026 
1027  /// Inline calls to information that is constant for a mesh and does not
1028  /// change for a mesh. These properties are stored directly in the vmesh
1029  /// data structure and hence we can replace them by simple inline calls.
1030 
1031  inline int basis_order()
1032  { return (basis_order_); }
1033 
1034  inline int dimensionality()
1035  { return (dimension_); }
1036 
1037  inline bool is_point()
1038  { return (dimension_ == 0); }
1039 
1040  inline bool is_line()
1041  { return (dimension_ == 1); }
1042 
1043  inline bool is_surface()
1044  { return (dimension_ == 2); }
1045 
1046  inline bool is_volume()
1047  { return (dimension_ == 3); }
1048 
1049  inline unsigned int num_nodes_per_elem()
1050  { return (num_nodes_per_elem_); }
1051 
1052  inline unsigned int num_enodes_per_elem()
1053  { return (num_enodes_per_elem_); }
1054 
1055  inline unsigned int num_edges_per_elem()
1056  { return (num_edges_per_elem_); }
1057 
1058  inline unsigned int num_faces_per_elem()
1059  { return (num_faces_per_elem_); }
1060 
1061  inline unsigned int num_nodes_per_face()
1062  { return (num_nodes_per_face_); }
1063 
1064  inline unsigned int num_nodes_per_edge()
1065  { return (2); }
1066 
1067  inline unsigned int num_edges_per_face()
1068  { return (num_edges_per_face_); }
1069 
1070  inline unsigned int num_gradients_per_node()
1071  { return (num_gradients_per_node_); }
1072 
1073  inline bool has_normals()
1074  { return (has_normals_); }
1075 
1076  inline bool is_editable()
1077  { return (is_editable_); }
1078 
1079  inline bool is_regularmesh()
1080  { return (is_regular_); }
1081 
1082  inline bool is_irregularmesh()
1083  { return (!is_regular_); }
1084 
1085  inline bool is_structuredmesh()
1086  { return (is_structured_); }
1087 
1088  inline bool is_unstructuredmesh()
1089  { return (!is_structured_); }
1090 
1091  inline size_type get_ni() const
1092  { return ni_; }
1093  inline size_type get_nj() const
1094  { return nj_; }
1095  inline size_type get_nk() const
1096  { return nk_; }
1097 
1098  inline int generation() const
1099  { return (generation_); }
1100 
1101  /// These functions help dealing with regular meshes and translate Node indices
1102  /// to coordinate indices
1103 
1104  /// From index splits up the index into parts
1106  {
1107  const index_type xidx = static_cast<const index_type>(idx);
1108  i = xidx % ni_; index_type jk = xidx / ni_;
1109  j = jk % nj_; k = jk / nj_;
1110  }
1111 
1113  {
1114  const index_type xidx = static_cast<const index_type>(idx);
1115  i = xidx % (ni_-1); index_type jk = xidx / (ni_-1);
1116  j = jk % (nj_-1); k = jk / (nj_-1);
1117  }
1118 
1120  {
1121  const index_type xidx = static_cast<const index_type>(idx);
1122  i = xidx % ni_; j = xidx / ni_;
1123  }
1124 
1126  {
1127  const index_type xidx = static_cast<const index_type>(idx);
1128  i = xidx % (ni_-1); j = xidx / (ni_-1);
1129  }
1130 
1132  {
1133  const index_type xidx = static_cast<const index_type>(idx);
1134  i = xidx % (ni_-1); index_type jk = xidx / (ni_-1);
1135  j = jk % (nj_-1); k = jk / (nj_-1);
1136  }
1137 
1139  {
1140  const index_type xidx = static_cast<const index_type>(idx);
1141  i = xidx % (ni_-1); j = xidx / (ni_-1);
1142  }
1143 
1144  /// To index generates a new successive index
1146  {
1147  idx = Node::index_type(i+ni_*j+ni_*nj_*k);
1148  }
1149 
1151  {
1152  idx = Node::index_type(i+ni_*j);
1153  }
1154 
1156  {
1157  idx = Elem::index_type(i+(ni_-1)*j+(ni_-1)*(nj_-1)*k);
1158  }
1159 
1161  {
1162  idx = Elem::index_type(i+(ni_-1)*j);
1163  }
1164 
1166  {
1167  idx = Cell::index_type(i+(ni_-1)*j+(ni_-1)*(nj_-1)*k);
1168  }
1169 
1171  {
1172  idx = Face::index_type(i+(ni_-1)*j);
1173  }
1174 
1175  /// Test for the type of elements
1176 
1177  inline bool is_pnt_element()
1178  { return (is_pointcloudmesh()); }
1179 
1180  inline bool is_crv_element()
1181  { return (is_structcurvemesh()||is_curvemesh()||is_scanlinemesh()); }
1182 
1183  inline bool is_tri_element()
1184  { return (is_trisurfmesh()); }
1185 
1186  inline bool is_quad_element()
1187  { return (is_structquadsurfmesh()||is_quadsurfmesh()||is_imagemesh()); }
1188 
1189  inline bool is_tet_element()
1190  { return (is_tetvolmesh()); }
1191 
1192  inline bool is_prism_element()
1193  { return (is_prismvolmesh()); }
1194 
1195  inline bool is_hex_element()
1196  { return (is_structhexvolmesh()||is_hexvolmesh()||is_latvolmesh()); }
1197 
1198  /// Get the unit vertex coordinates of the unit element
1200  { coords = unit_vertices_; }
1201 
1203  { edges = unit_edges_; }
1204 
1205  inline void get_element_center(coords_type& coords)
1206  { coords = unit_center_; }
1207 
1208  inline double get_element_size()
1209  { return (element_size_); }
1210 
1211 #ifdef SCIRUN4_CODE_TO_BE_ENABLED_LATER
1212  /// Shortcuts to property manager
1213  inline void copy_properties(VMesh* imesh)
1214  { pm_->copy_properties(imesh->pm_); }
1215 
1216  template<class T>
1217  inline void set_property(const std::string &name, const T &val, bool is_transient)
1218  { pm_->set_property(name,val,is_transient); }
1219 
1220  template<class T>
1221  inline bool get_property( const std::string &name, T &val)
1222  { return(pm_->get_property(name,val)); }
1223 
1224  inline bool is_property( const std::string &name)
1225  { return(pm_->is_property(name)); }
1226 #endif
1227 
1228 protected:
1229  /// Properties of meshes that do not change during the lifetime of the mesh
1230  /// and hence they can be stored for fast use.
1233 
1234  /// Mesh properties
1239 
1240  /// Mesh statistics
1241  unsigned int num_nodes_per_elem_;
1242  unsigned int num_enodes_per_elem_;
1243  unsigned int num_edges_per_elem_;
1244  unsigned int num_faces_per_elem_;
1245  unsigned int num_nodes_per_face_;
1246  unsigned int num_edges_per_face_;
1248 
1249  /// Size in local coordinate system
1251 
1252  /// Definitions of local element topology
1256 
1257  /// size of structured meshes
1258  /// unstructured mesh denote the number of nodes in ni_
1262 
1263  /// generation number of mesh
1264  unsigned int generation_;
1265 
1266 #ifdef SCIRUN4_CODE_TO_BE_ENABLED_LATER
1267  /// Add this one separately to avoid circular dependencies
1268  /// Pointer to base class of the mesh
1269  PropertyManager* pm_;
1270 #endif
1271 };
1272 
1273 } // end namespace SCIRun
1274 
1275 #endif // Datatypes_Mesh_h
unsigned int num_edges_per_elem()
Definition: VMesh.h:1055
virtual bool is_quadsurfmesh()
Definition: VMesh.h:999
bool find_closest_elem(Core::Geometry::Point &result, VMesh::Elem::index_type &i, const Core::Geometry::Point &point) const
Even more simplified version.
Definition: VMesh.h:680
unsigned int num_faces_per_elem()
Definition: VMesh.h:1058
bool find_closest_elem(VMesh::coords_type &coords, VMesh::Elem::index_type &i, const Core::Geometry::Point &point) const
Another simplified version.
Definition: VMesh.h:690
Interface to statically allocated std::vector class.
VMesh::index_type index_type
Definition: VMesh.h:214
StackBasedVector< index_type, 12 > array_type
Definition: VMesh.h:151
Definition: VMesh.h:180
void get_element_edges(nodes_array_type &edges)
Definition: VMesh.h:1202
virtual bool is_curvemesh()
Definition: VMesh.h:995
double get_length(Edge::index_type i) const
Definition: VMesh.h:477
size_type num_elems() const
Definition: VMesh.h:321
void from_index(index_type &i, index_type &j, Elem::index_type idx)
Definition: VMesh.h:1125
void reserve_nodes(size_t size)
Definition: VMesh.h:821
virtual bool is_structcurvemesh()
Definition: VMesh.h:997
std::vector< ElemInterpolate > MultiElemInterpolate
Definition: VMesh.h:208
void get_enode(Core::Geometry::Point &point, ENode::index_type i)
Definition: VMesh.h:856
Distinct type for cell Iterator.
Definition: FieldVIterator.h:163
unsigned int num_nodes_per_face()
Definition: VMesh.h:1061
double get_element_size()
Definition: VMesh.h:1208
Definition: FieldRNG.h:37
size_type get_nj() const
Definition: VMesh.h:1093
bool is_hex_element()
Definition: VMesh.h:1195
VDElemIndex< VMesh::index_type > index_type
Definition: VMesh.h:183
StackVector< Core::Geometry::Point, 3 > dpoints_type
Definition: VMesh.h:88
void resize_points(size_t size)
Definition: VMesh.h:833
nodes_array_type unit_edges_
Definition: VMesh.h:1254
Distinct type for elem index.
Definition: FieldVIndex.h:228
int dimensionality()
Definition: VMesh.h:1034
StackVector< index_type, 8 > node_index
Definition: VMesh.h:199
std::vector< StackVector< double, 3 > > coords_array_type
An array of coords.
Definition: VMesh.h:83
VElemIndex< VMesh::size_type > size_type
Definition: VMesh.h:169
bool is_quad_element()
Definition: VMesh.h:1186
void get_element_vertices(coords_array_type &coords)
Get the unit vertex coordinates of the unit element.
Definition: VMesh.h:1199
void copy_nodes(VMesh *imesh, Node::index_type i, Node::index_type o, Node::size_type size)
Definition: VMesh.h:781
Class for indexing faces.
Definition: VMesh.h:134
double get_volume(Cell::index_type i) const
Definition: VMesh.h:481
virtual bool is_pointcloudmesh()
check the type of mesh
Definition: VMesh.h:994
void get_normal(Core::Geometry::Vector &result, coords_type &coords, Elem::index_type eidx) const
This is the surface version.
Definition: VMesh.h:735
bool is_quadraticmesh()
Definition: VMesh.h:1011
VMesh::Elem::index_type add_elem(const Node::array_type nodes)
Alternative calls for add_elem.
Definition: VMesh.h:868
bool is_linearmesh()
Definition: VMesh.h:1010
void copy_nodes(VMesh *imesh)
Definition: VMesh.h:789
VNodeIndex< VMesh::index_type > index_type
Definition: VMesh.h:107
Definition: VMesh.h:212
StackVector< double, 9 > inverse_jacobian
Definition: VMesh.h:224
double get_volume(Elem::index_type i) const
Definition: VMesh.h:488
size_type get_ni() const
Definition: VMesh.h:1091
Core::Geometry::Point get_point(ENode::index_type i) const
Definition: VMesh.h:760
Definition: VMesh.h:165
void get_point(Core::Geometry::Point &point, Node::index_type i) const
Definition: VMesh.h:754
index_type elem_index
Definition: VMesh.h:198
Distinct type for cell Iterator.
Definition: FieldVIterator.h:150
bool find_closest_node(Core::Geometry::Point &result, VMesh::Node::index_type &i, const Core::Geometry::Point &point, double maxdist)
Simplified version that does not return the distance.
Definition: VMesh.h:614
StackVector< double, 3 > coords_type
Definition: VMesh.h:81
VMesh::Node::index_type add_point(const Core::Geometry::Point &point)
Definition: VMesh.h:861
Definition: Point.h:49
StackBasedVector< double, 64 > weights
Definition: VMesh.h:202
void set_enode(const Core::Geometry::Point &point, ENode::index_type i)
Definition: VMesh.h:842
Definition: TypeDescription.h:45
virtual Core::Geometry::Point * get_points_pointer() const
Definition: VMesh.cc:649
#define SCISHARE
Definition: share.h:39
void end(Face::iterator &it) const
Definition: VMesh.h:287
std::vector< Core::Geometry::Point > points_type
Array of points.
Definition: VMesh.h:72
void end(DElem::iterator &it) const
Definition: VMesh.h:293
Distinct type for face index.
Definition: FieldVIndex.h:210
Definition: BBox.h:46
bool is_tri_element()
Definition: VMesh.h:1183
VFaceIterator< VMesh::index_type > iterator
Definition: VMesh.h:136
Distinct type for edge index.
Definition: FieldVIndex.h:200
StackBasedVector< index_type, 12 > array_type
Definition: VMesh.h:130
Distinct type for lagrangian node FieldIterator.
Definition: FieldVIterator.h:92
void get_constant_derivate_weights(coords_type &, std::vector< double > &weights)
These four are for computating gradients.
Definition: VMesh.h:962
void begin(ENode::iterator &it) const
Definition: VMesh.h:268
Definition: StackBasedVector.h:47
VMesh::index_type index_type
Definition: VMesh.h:195
Distinct type for elem index.
Definition: FieldVIndex.h:237
VEdgeIndex< VMesh::index_type > index_type
Definition: VMesh.h:128
void begin(Cell::iterator &it) const
Definition: VMesh.h:274
void get_constant_weights(coords_type &, std::vector< double > &weights)
Definition: VMesh.h:955
void to_index(Elem::index_type &idx, index_type i, index_type j, index_type k)
Definition: VMesh.h:1155
bool is_pnt_element()
Test for the type of elements.
Definition: VMesh.h:1177
std::vector< Node::array_type > nodes_array_type
Definition: VMesh.h:112
Definition: VMesh.h:193
int dimension_
Definition: VMesh.h:1232
VEdgeIndex< VMesh::size_type > size_type
Definition: VMesh.h:129
Core::Geometry::Point get_point(Node::index_type i) const
Definition: VMesh.h:758
size_type ni_
Definition: VMesh.h:1259
unsigned int num_nodes_per_edge()
Definition: VMesh.h:1064
VCellIndex< VMesh::index_type > index_type
Definition: VMesh.h:149
size_type get_nk() const
Definition: VMesh.h:1095
bool is_point()
Definition: VMesh.h:1037
Distinct type for node index.
Definition: FieldVIndex.h:181
VENodeIterator< VMesh::index_type > iterator
Definition: VMesh.h:118
void begin(Elem::iterator &it) const
Definition: VMesh.h:276
StackBasedVector< index_type, 12 > array_type
Definition: VMesh.h:170
void to_index(Node::index_type &idx, index_type i, index_type j)
Definition: VMesh.h:1150
Definition: Vector.h:63
void get_centers(points_type &points, Elem::array_type &array) const
Definition: VMesh.h:434
void begin(DElem::iterator &it) const
Definition: VMesh.h:278
VENodeIndex< VMesh::index_type > index_type
Definition: VMesh.h:119
virtual bool is_imagemesh()
Definition: VMesh.h:1000
size_type num_edges() const
Definition: VMesh.h:315
boost::shared_ptr< VMesh > VMeshHandle
Definition: VMesh.h:49
StackBasedVector< index_type, 8 > array_type
Definition: VMesh.h:109
bool is_cubicmesh()
Definition: VMesh.h:1012
bool is_editable_
Definition: VMesh.h:1236
VNodeIndex< VMesh::size_type > size_type
Definition: VMesh.h:108
StackBasedVector< double, 12 > weight_array_type
Definition: VMesh.h:100
double volume_metric(const Elem::index_type idx) const
Volume of an element.
Definition: VMesh.h:944
bool is_prism_element()
Definition: VMesh.h:1192
void get_normals(std::vector< Core::Geometry::Vector > &result, std::vector< coords_type > &coords, Elem::index_type eidx) const
Multiple normals short cut.
Definition: VMesh.h:740
VMesh::size_type size_type
Definition: VMesh.h:196
bool find_closest_elem(double &dist, Core::Geometry::Point &result, VMesh::Elem::index_type &i, const Core::Geometry::Point &point, double maxdist) const
Definition: VMesh.h:668
void end(Edge::iterator &it) const
Definition: VMesh.h:285
bool is_nonlinearmesh()
Definition: VMesh.h:1013
virtual bool is_latvolmesh()
Definition: VMesh.h:1005
size_type num_hderivs
Definition: VMesh.h:220
coords_type coords
Definition: VMesh.h:225
bool is_tet_element()
Definition: VMesh.h:1189
void get_centers(points_type &points, Node::array_type &array) const
Definition: VMesh.h:432
bool has_normals_
Mesh properties.
Definition: VMesh.h:1235
virtual bool is_hexvolmesh()
Definition: VMesh.h:1004
Class for indexing edges.
Definition: VMesh.h:125
const char * name[]
Definition: BoostGraphExampleTests.cc:87
unsigned int num_edges_per_face()
Definition: VMesh.h:1067
VDElemIterator< VMesh::index_type > iterator
Definition: VMesh.h:182
unsigned int num_gradients_per_node()
Definition: VMesh.h:1070
Distinct type for additional lagrangian node.
Definition: FieldVIndex.h:190
long long size_type
Definition: Types.h:40
StackBasedVector< index_type, 12 > array_type
Definition: VMesh.h:121
VFaceIndex< VMesh::size_type > size_type
Definition: VMesh.h:138
StackBasedVector< double, 64 > weights
Definition: VMesh.h:221
virtual bool is_structquadsurfmesh()
Definition: VMesh.h:1001
void from_index(index_type &i, index_type &j, index_type &k, Node::index_type idx)
From index splits up the index into parts.
Definition: VMesh.h:1105
Node::index_type add_node(const Core::Geometry::Point &point)
Definition: VMesh.h:851
bool is_editable()
Definition: VMesh.h:1076
VMesh::size_type size_type
Definition: VMesh.h:215
void to_index(Node::index_type &idx, index_type i, index_type j, index_type k)
To index generates a new successive index.
Definition: VMesh.h:1145
void to_index(Face::index_type &idx, index_type i, index_type j)
Definition: VMesh.h:1170
virtual bool is_tetvolmesh()
Definition: VMesh.h:1002
double weight_type
Weights for interpolation.
Definition: VMesh.h:65
size_type num_enodes() const
Definition: VMesh.h:313
Distinct type for edge Iterator.
Definition: FieldVIterator.h:105
virtual bool is_structhexvolmesh()
Definition: VMesh.h:1006
void from_index(index_type &i, index_type &j, index_type &k, Elem::index_type idx)
Definition: VMesh.h:1112
VFaceIndex< VMesh::index_type > index_type
Definition: VMesh.h:137
size_type num_nodes() const
Definition: VMesh.h:311
bool is_constantmesh()
Check order of mesh.
Definition: VMesh.h:1009
size_type num_faces() const
Definition: VMesh.h:317
Definition: VMesh.h:146
Definition: Transform.h:53
coords_array_type unit_vertices_
Definitions of local element topology.
Definition: VMesh.h:1253
std::vector< index_type > array_type
Array of indices.
Definition: VMesh.h:70
bool is_line()
Definition: VMesh.h:1040
void get_all_elem_centers(points_type &points) const
Definition: VMesh.h:445
bool is_regular_
Definition: VMesh.h:1237
void begin(Edge::iterator &it) const
Definition: VMesh.h:270
unsigned int num_enodes_per_elem()
Definition: VMesh.h:1052
bool is_surface()
Definition: VMesh.h:1043
unsigned int num_nodes_per_elem_
Mesh statistics.
Definition: VMesh.h:1241
SCIRun::index_type size_type
Definition: MeshTraits.h:57
int generation() const
Definition: VMesh.h:1098
Definition: VMesh.h:104
size_type num_delems() const
Definition: VMesh.h:323
double get_size(Node::index_type) const
Definition: VMesh.h:457
void get_point(Core::Geometry::Point &point, ENode::index_type i) const
Definition: VMesh.h:756
void end(ENode::iterator &it) const
Definition: VMesh.h:283
virtual VMesh::index_type * get_elems_pointer() const
Definition: VMesh.cc:655
virtual bool is_trisurfmesh()
Definition: VMesh.h:998
VENodeIndex< VMesh::size_type > size_type
Definition: VMesh.h:120
Definition: VMesh.h:116
bool is_unstructuredmesh()
Definition: VMesh.h:1088
bool is_regularmesh()
Definition: VMesh.h:1079
unsigned int num_gradients_per_node_
Definition: VMesh.h:1247
void end(Cell::iterator &it) const
Definition: VMesh.h:289
unsigned int num_edges_per_elem_
Definition: VMesh.h:1243
bool is_empty() const
Definition: VMesh.h:332
StackVector< index_type, 12 > edge_index
Definition: VMesh.h:200
VDElemIndex< VMesh::size_type > size_type
Definition: VMesh.h:184
bool is_irregularmesh()
Definition: VMesh.h:1082
unsigned int num_faces_per_elem_
Definition: VMesh.h:1244
bool is_structured_
Definition: VMesh.h:1238
Distinct type for cell index.
Definition: FieldVIndex.h:219
unsigned int num_edges_per_face_
Definition: VMesh.h:1246
double element_size_
Size in local coordinate system.
Definition: VMesh.h:1250
void reserve_elems(size_t size)
Definition: VMesh.h:826
double get_size(ENode::index_type) const
Definition: VMesh.h:459
coords_type unit_center_
Definition: VMesh.h:1255
long long index_type
Definition: Types.h:39
unsigned int num_nodes_per_face_
Definition: VMesh.h:1245
Definition: ParallelLinearAlgebraTests.cc:751
void get_all_node_centers(points_type &points) const
Definition: VMesh.h:438
void copy_elems(VMesh *imesh)
Definition: VMesh.h:810
void get_node(Core::Geometry::Point &point, Node::index_type i)
Definition: VMesh.h:854
bool is_crv_element()
Definition: VMesh.h:1180
void from_index(index_type &i, index_type &j, Node::index_type idx)
Definition: VMesh.h:1119
StackBasedVector< index_type, 12 > array_type
Definition: VMesh.h:185
size_type nj_
Definition: VMesh.h:1260
int basis_order()
Definition: VMesh.h:1031
VEdgeIterator< VMesh::index_type > iterator
Definition: VMesh.h:127
Distinct type for cell Iterator.
Definition: FieldVIterator.h:137
void get_element_center(coords_type &coords)
Definition: VMesh.h:1205
bool has_normals()
Definition: VMesh.h:1073
VNodeIterator< VMesh::index_type > iterator
Definition: VMesh.h:106
VCellIterator< VMesh::index_type > iterator
Definition: VMesh.h:148
size_type nk_
Definition: VMesh.h:1261
int basis_order_
Definition: VMesh.h:1231
void from_index(index_type &i, index_type &j, Face::index_type idx)
Definition: VMesh.h:1138
size_type num_derivs
Definition: VMesh.h:223
void convert_vector(VEC1 &v1, VEC2 v2) const
Definition: VMesh.h:1021
Distinct type for node FieldIterator.
Definition: FieldVIterator.h:73
size_type num_cells() const
Definition: VMesh.h:319
VElemIndex< VMesh::index_type > index_type
Definition: VMesh.h:168
void end(Node::iterator &it) const
Definition: VMesh.h:281
void to_index(Cell::index_type &idx, index_type i, index_type j, index_type k)
Definition: VMesh.h:1165
StackBasedVector< index_type, 8 > node_index
Definition: VMesh.h:218
VMesh()
Definition: VMesh.h:234
size_type num_hderivs
Definition: VMesh.h:201
unsigned int generation_
generation number of mesh
Definition: VMesh.h:1264
void copy_elems(VMesh *imesh, Elem::index_type i, Elem::index_type o, Elem::size_type size, Elem::size_type offset)
Definition: VMesh.h:798
bool is_volume()
Definition: VMesh.h:1046
double get_length(Elem::index_type i) const
Definition: VMesh.h:484
double get_area(Face::index_type i) const
Definition: VMesh.h:479
bool find_closest_node(Core::Geometry::Point &result, VMesh::Node::index_type &i, const Core::Geometry::Point &point)
Simplified version that does not return the distance.
Definition: VMesh.h:621
SCIRun::index_type index_type
Definition: MeshTraits.h:56
#define DEBUG_CONSTRUCTOR(type)
Definition: Debug.h:64
std::vector< std::vector< StackVector< double, 3 > > > coords_array2_type
2D array of coords
Definition: VMesh.h:85
std::vector< size_type > dimension_type
Definition: VMesh.h:76
VElemIterator< VMesh::index_type > iterator
Definition: VMesh.h:167
Mesh::size_type size_type
Definition: VMesh.h:68
Definition: PropertyManager.h:193
int basis_order
Definition: VMesh.h:216
void end(Elem::iterator &it) const
Definition: VMesh.h:291
StackVector< index_type, 12 > edge_index
Definition: VMesh.h:219
unsigned int num_nodes_per_elem()
Definition: VMesh.h:1049
Definition: VMesh.h:53
void begin(Face::iterator &it) const
Definition: VMesh.h:272
Distinct type for face Iterator.
Definition: FieldVIterator.h:122
int basis_order
Definition: VMesh.h:197
VCellIndex< VMesh::size_type > size_type
Definition: VMesh.h:150
void set_node(const Core::Geometry::Point &point, Node::index_type i)
alternative calls
Definition: VMesh.h:840
StackBasedVector< index_type, 12 > index_array_type
Definition: VMesh.h:99
StackBasedVector< index_type, 12 > array_type
Definition: VMesh.h:139
void begin(Node::iterator &it) const
Definition: VMesh.h:266
void from_index(index_type &i, index_type &j, index_type &k, Cell::index_type idx)
Definition: VMesh.h:1131
unsigned int mask_type
Definition: VMesh.h:91
bool is_structuredmesh()
Definition: VMesh.h:1085
index_type elem_index
Definition: VMesh.h:217
Mesh::index_type index_type
VIRTUAL INTERFACE.
Definition: VMesh.h:63
int size
Definition: eabLatVolData.py:2
void to_index(Elem::index_type &idx, index_type i, index_type j)
Definition: VMesh.h:1160
virtual bool is_prismvolmesh()
Definition: VMesh.h:1003
double get_area(Elem::index_type i) const
Definition: VMesh.h:486
unsigned int num_enodes_per_elem_
Definition: VMesh.h:1242
std::vector< ElemGradient > MultiElemGradient
Multiple gradient calculations in parallel.
Definition: VMesh.h:229
#define DEBUG_DESTRUCTOR(type)
Definition: Debug.h:65
bool find_closest_elem(double &dist, Core::Geometry::Point &result, VMesh::Elem::index_type &i, const Core::Geometry::Point &point) const
Simplified version that does not return the local coordinates.
Definition: VMesh.h:659
virtual ~VMesh()
Definition: VMesh.h:255
virtual bool is_scanlinemesh()
Definition: VMesh.h:996