SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VFData.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_VFDATA_H
31 #define CORE_DATATYPES_VFDATA_H 1
32 
35 #include <Core/Containers/Array2.h>
36 #include <Core/Containers/Array3.h>
40 #include <string>
41 #include <vector>
42 #include <complex>
43 #include <float.h>
44 
46 
47 #define VFDATA_ACCESS_DECLARATION(type) \
48  virtual void get_value(type &val, VMesh::index_type idx) const; \
49  virtual void set_value(const type &val, VMesh::index_type idx); \
50  virtual void get_evalue(type &val, VMesh::index_type idx) const; \
51  virtual void set_evalue(const type &val, VMesh::index_type idx); \
52  virtual void get_values(type *ptr, VMesh::size_type sz, VMesh::size_type offset) const; \
53  virtual void set_values(const type *ptr, VMesh::size_type sz, VMesh::size_type offset); \
54  virtual void get_evalues(type *ptr, VMesh::size_type sz, VMesh::size_type offset) const; \
55  virtual void set_evalues(const type *ptr, VMesh::size_type sz, VMesh::size_type offset); \
56  virtual void set_all_values(const type &val); \
57  virtual void get_weighted_value(type &val, const VMesh::index_type* idx, const VMesh::weight_type* w, VMesh::size_type sz) const; \
58  virtual void get_weighted_evalue(type &val, const VMesh::index_type* idx, const VMesh::weight_type* w, VMesh::size_type sz) const; \
59  virtual void get_values(type *ptr, VMesh::Node::array_type& nodes) const; \
60  virtual void get_values(type *ptr, VMesh::Elem::array_type& elems) const; \
61  virtual void set_values(const type *ptr, VMesh::Node::array_type& nodes); \
62  virtual void set_values(const type *ptr, VMesh::Elem::array_type& elems); \
63  virtual void get_values(type *ptr, index_type* idx, size_type size) const; \
64  virtual void set_values(const type *ptr, index_type* idx, size_type size); \
65 
66 
67 #define VFDATA_ACCESS_DECLARATION2(type) \
68  virtual void interpolate(type &val, VMesh::ElemInterpolate &interp, type defval = (static_cast<type>(0))) const; \
69  virtual void minterpolate(std::vector<type> &val, VMesh::MultiElemInterpolate &interp, type defval = (static_cast<type>(0))) const; \
70  virtual void gradient(StackVector<type,3> &val, VMesh::ElemGradient &interp, type defval = (static_cast<type>(0))) const; \
71  virtual void mgradient(std::vector<StackVector<type,3> > &val, VMesh::MultiElemGradient &interp, type defval = (static_cast<type>(0))) const; \
72 
73 #define VFDATA_FUNCTION_DECLARATION(type) \
74  SCISHARE VFData* CreateVFData(std::vector<type>& fdata, std::vector<type>& lfdata, std::vector<std::vector<type> >& hfdata); \
75  SCISHARE VFData* CreateVFData(Array2<type>& fdata, std::vector<type>& lfdata, std::vector<std::vector<type> >& hfdata); \
76  SCISHARE VFData* CreateVFData(Array3<type>& fdata, std::vector<type>& lfdata, std::vector<std::vector<type> >& hfdata);
77 
78 
79 namespace SCIRun {
80 
81 /// Interface class to data stored in field.
82 /// The VField class has a pointer to this class and hence can call the
83 /// appropriate function from the table listed by this class. This class
84 /// works with references to the original class and hence the additional
85 /// overhead should be small.
87 public:
88  virtual ~VFData() {}
89 
90  virtual VMesh::size_type fdata_size() const;
91  virtual VMesh::size_type efdata_size() const;
92 
93  virtual void resize_fdata(VMesh::dimension_type dim);
94  virtual void resize_efdata(VMesh::dimension_type dim);
95 
96  virtual void* fdata_pointer() const;
97  virtual void* efdata_pointer() const;
98 
100  VFDATA_ACCESS_DECLARATION(unsigned char)
102  VFDATA_ACCESS_DECLARATION(unsigned short)
104  VFDATA_ACCESS_DECLARATION(unsigned int)
105  VFDATA_ACCESS_DECLARATION(long long)
106  VFDATA_ACCESS_DECLARATION(unsigned long long)
109  VFDATA_ACCESS_DECLARATION(Core::Geometry::Vector)
110  VFDATA_ACCESS_DECLARATION(Core::Geometry::Tensor)
111 
112 
117  VFDATA_ACCESS_DECLARATION2(Core::Geometry::Vector)
118  VFDATA_ACCESS_DECLARATION2(Core::Geometry::Tensor)
119 
120 
121  /// Copy a value without needing to know the type
122  virtual void copy_value(VFData* fdata,
123  VMesh::index_type vidx,
124  VMesh::index_type idx);
125 
126  virtual void copy_values(VFData* fdata,
127  VMesh::index_type vidx,
128  VMesh::index_type idx,
129  VMesh::size_type num);
130 
131  /// Copy a weighted value without needing to know the type
132  virtual void copy_weighted_value(VFData* fdata,
133  VMesh::index_type* vidx,
134  VMesh::weight_type* vw,
135  VMesh::size_type sz,
136  VMesh::index_type idx);
137 
138  /// Copy a edge value without needing to know the type
139  virtual void copy_evalue(VFData* fdata,
140  VMesh::index_type vidx,
141  VMesh::index_type idx);
142 
143  virtual void copy_evalues(VFData* fdata,
144  VMesh::index_type vidx,
145  VMesh::index_type idx,
146  VMesh::size_type num);
147 
148  /// Copy a weighted edge value without needing to know the type
149  virtual void copy_weighted_evalue(VFData* fdata,
150  VMesh::index_type* vidx,
151  VMesh::weight_type* vw,
152  VMesh::size_type sz,
153  VMesh::index_type idx);
154 
155  /// Copy values from one FData array to another FData array
156  virtual void copy_values(VFData* fdata);
157  virtual void copy_evalues(VFData* fdata);
158 
159  virtual bool min(double& val, VMesh::index_type& idx) const;
160  virtual bool max(double& val, VMesh::index_type& idx) const;
161  virtual bool minmax(double& min, VMesh::index_type& idxmin,
162  double& max, VMesh::index_type& idxmax) const;
163 
164  virtual VMesh::size_type size();
165 };
166 
167 
168 
169 // Functions to instantiate the FData interface
170 
171 /// In case we encounter an unknow datatype.
172 /// We could have this function return a fuly functional interface, in which
173 /// case after the field is created in the dynamic compilation process it would
174 /// have this part of the virtual interface. It would be compiled with the first
175 /// instantiation of the field. However for the moment we ignore that case and
176 /// do not provide virtual interfaces for unknown data types.
177 template<class FDATA, class LFDATA, class HFDATA>
178 inline VFData* CreateVFData(FDATA& /*fdata*/, LFDATA& /*lfdata*/, HFDATA& /*hfdata*/)
179 {
180  return (0);
181 }
182 
183 /// Pre instantiated versions, these should cover most of SCIRun needs
184 /// As these are declared as functions, dynamic compilation should not instantiate
185 /// these once more, but link agianst the dynamic library. This should reduce the
186 /// amount of time spend in dynamic compilation and keep dynamically compiled files
187 /// small while providing a full virtual framework in parallel.
188 
189 
191 VFDATA_FUNCTION_DECLARATION(unsigned char)
193 VFDATA_FUNCTION_DECLARATION(unsigned short)
195 VFDATA_FUNCTION_DECLARATION(unsigned int)
197 VFDATA_FUNCTION_DECLARATION(unsigned long long)
200 VFDATA_FUNCTION_DECLARATION(Core::Geometry::Vector)
201 VFDATA_FUNCTION_DECLARATION(Core::Geometry::Tensor)
202 
203 
204 } // end namespace
205 
206 #endif
207 
#define VFDATA_FUNCTION_DECLARATION(type)
Definition: VFData.h:73
#define VFDATA_ACCESS_DECLARATION(type)
Definition: VFData.h:47
#define SCISHARE
Definition: share.h:39
virtual ~VFData()
Definition: VFData.h:88
Definition: Vector.h:63
#define VFDATA_ACCESS_DECLARATION2(type)
Definition: VFData.h:67
Definition: ParallelLinearAlgebraTests.cc:358
long long size_type
Definition: Types.h:40
Definition: VFData.h:86
Definition: Tensor.h:65
long long index_type
Definition: Types.h:39
VFData * CreateVFData(FData2d< T, MESH > &fdata, std::vector< T > &lfdata, std::vector< std::vector< T > > &hfdata)
Definition: GenericField.h:475
Symmetric, positive definite tensors (diffusion, conductivity)
Interface to dynamic 3D array class.
std::vector< size_type > dimension_type
Definition: VMesh.h:76
Mesh::size_type size_type
Definition: VMesh.h:68
Definition: VMesh.h:53
int size
Definition: eabLatVolData.py:2
Interface to dynamic 2D array class.