10#include <boost/mpl/size.hpp>
14template<
class T,
int Dim>
20template<
class T,
int Dim>
26template<
class T,
int Dim>
32template<
class T,
int Dim>
35 for (
int c = 0; c < Dim; ++c) {
37 d()->x[c].construct();
42template<
class T,
int Dim>
45 for (
int c = 0; c < Dim; ++c) {
46 if (d()->x[c].valid()) {
49 d()->x[c].construct(size);
55template<
class T,
int Dim>
62 for (
int c = 0; c < Dim; ++c) {
63 x(c)[to] = s->x(c)[from];
69template<
class T,
int Dim>
72 assert(component >= 0);
73 assert(component < Dim);
74 x(component)[idx] = value;
77template<
class T,
int Dim>
80 assert(component >= 0);
81 assert(component < Dim);
82 return static_cast<double>(x(component)[idx]);
85template<
class T,
int Dim>
88 if (
auto str = StructuredGridBase::as(grid)) {
89 auto m = guessMapping(shared_from_this());
90 for (
int c = 0; c < Dim; ++c) {
91 if (m == DataBase::Vertex) {
92 d()->x[c]->setDimensionHint(str->getNumDivisions(0), str->getNumDivisions(1), str->getNumDivisions(2));
93 }
else if (m == DataBase::Element) {
94 d()->x[c]->setDimensionHint(str->getNumDivisions(0) - 1,
95 std::max<Index>(1, str->getNumDivisions(1) - 1),
96 std::max<Index>(1, str->getNumDivisions(2) - 1));
100 for (
int c = 0; c < Dim; ++c)
101 d()->x[c]->clearDimensionHint();
105template<
class T,
int Dim>
111template<
class T,
int Dim>
114 const Data *d =
static_cast<Data *
>(m_data);
116 for (
int c = 0; c < Dim; ++c) {
117 m_x[c] = (d && d->x[c].valid()) ? d->
x[c]->
data() :
nullptr;
119 for (
int c = Dim; c < MaxDim; ++c) {
122 m_size = (d && d->x[0]) ? d->x[0]->size() : 0;
125template<
class T,
int Dim>
126bool Vec<T, Dim>::isEmpty()
const
128 return getSize() == 0;
131template<
class T,
int Dim>
132bool Vec<T, Dim>::isEmpty()
134 return getSize() == 0;
137template<
class T,
int Dim>
138bool Vec<T, Dim>::checkImpl()
const
140 size_t size = d()->x[0]->size();
141 for (
int c = 0; c < Dim; ++c) {
143 V_CHECK(d()->x[c]->size() == size);
145 V_CHECK((d()->x[c])->at(0) * (d()->x[c])->at(0) >= 0)
146 V_CHECK((d()->x[c])->at(size - 1) * (d()->x[c])->at(size - 1) >= 0)
153template<class T,
int Dim>
154void Vec<T, Dim>::updateInternals()
156 if (!d()->boundsValid())
160template<
class T,
int Dim>
163 if (d()->boundsValid()) {
164 return std::make_pair(d()->
min, d()->max);
167 T smax = std::numeric_limits<T>::max();
168 T smin = std::numeric_limits<T>::lowest();
170 Index sz = getSize();
171 for (
int c = 0; c < Dim; ++c) {
174 const T *d = &x(c)[0];
175 for (
Index i = 0; i < sz; ++i) {
182 return std::make_pair(
min, max);
185template<
class T,
int Dim>
191template<
class T,
int Dim>
192bool Vec<T, Dim>::Data::boundsValid()
const
194 for (
int c = 0; c < Dim; ++c)
200template<
class T,
int Dim>
201void Vec<T, Dim>::Data::invalidateBounds()
203 for (
int c = 0; c < Dim; ++c) {
204 min[c] = std::numeric_limits<T>::max();
205 max[c] = std::numeric_limits<T>::lowest();
209template<
class T,
int Dim>
210void Vec<T, Dim>::Data::updateBounds()
213 for (
int c = 0; c < Dim; ++c) {
214 Index sz = x[c]->size();
215 const T *d = x[c]->data();
216 for (
Index i = 0; i < sz; ++i) {
225template<
class T,
int Dim>
228 for (
int c = 0; c < Dim; ++c)
233template<
class T,
int Dim>
239 for (
int c = 0; c < Dim; ++c)
240 x[c].construct(size);
243template<
class T,
int Dim>
246 static const size_t pos = boost::mpl::find<Scalars, T>::type::pos::value;
247 static_assert(pos < boost::mpl::size<Scalars>::value,
"Scalar type not found");
251template<
class T,
int Dim>
257 for (
int c = 0; c < Dim; ++c)
258 x[c].construct(size);
261template<
class T,
int Dim>
267 for (
int c = 0; c < Dim; ++c)
271template<
class T,
int Dim>
284template<
class T,
int Dim>
290template<
class T,
int Dim>
std::shared_ptr< const Object > const_ptr
Definition: object.h:68
static void publish(const Data *d)
Definition: object.cpp:150
const Meta & meta() const
Definition: object.cpp:390
Type
Definition: object.h:84
@ UNKNOWN
Definition: object.h:89
@ VEC
Definition: object.h:114
std::string createObjectId(const std::string &name="")
Definition: shm.cpp:435
static Shm & the()
Definition: shm.cpp:315
Vec(const Index size, const Meta &meta=Meta())
Definition: vec_template.h:15
VistleVector< Scalar, Dim > Vector
Definition: vec.h:24
array & x(int c=0)
Definition: vec.h:42
void setExact(bool exact) override
Definition: vec_template.h:106
Definition: shm_reference.h:15
void resize(const size_t size)
Definition: shm_array.h:134
T * data() const
Definition: shm_array.h:91
static T min(T a, T b)
Definition: messages.cpp:28
Definition: allobjects.cpp:30
Vector3 Vector
Definition: vector.h:36
uint32_t Index
Definition: index.h:13
#define V_OBJECT_CREATE_NAMED(ObjType)
Definition: object.h:542
#define V_CHECK(true_expr)
use in checkImpl
Definition: object.h:368
static Data * createNamed(Object::Type id, const std::string &name, const Meta &meta=Meta())
Definition: vec_template.h:291
static Data * create(Index size=0, const Meta &meta=Meta())
Definition: vec_template.h:272
Data(const Index size=0, const std::string &name="", const Meta &meta=Meta())
Definition: vec_template.h:234
ShmVector< T > x[Dim]
Definition: vec.h:87
static managed_shm::segment_manager::template construct_proxy< T >::type construct(const std::string &name)
Definition: shm_impl.h:87