[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Freepooma-devel] [PATCH] Use Array<1, T>[Dim], not Vector<Dim, Array<1,
From: |
Richard Guenther |
Subject: |
[Freepooma-devel] [PATCH] Use Array<1, T>[Dim], not Vector<Dim, Array<1, T> > |
Date: |
Mon, 22 Nov 2004 17:55:14 +0100 (CET) |
Hi!
This replaces the dubious use of Vector<Dim, Array<1, T> > in
RectilinearMesh by Array<1, T>[Dim]. The change passes the
only use of the RectilinearMesh in the Particles testsuite as
well as the Field tests which I adapted to check RectilinearMesh
a moment ago.
This is necessary before we can enforce TrivialElementProperties
for the T in Vector<Dim, T>. At least Vector<Dim, Array<1, T> >
is certainly not TrivialElementProperties like we say now.
Ok?
Richard.
2004Nov22 Richard Guenther <address@hidden>
* src/Field/Mesh/RectilinearMesh.h: use Array<1, T>[Dim]
as storage, not Vector<Dim, Array<1, T> >.
Index: RectilinearMesh.h
===================================================================
RCS file: /cvsroot/freepooma/freepooma/src/Field/Mesh/RectilinearMesh.h,v
retrieving revision 1.3
diff -u -u -r1.3 RectilinearMesh.h
--- RectilinearMesh.h 1 Nov 2004 18:16:46 -0000 1.3
+++ RectilinearMesh.h 22 Nov 2004 16:55:32 -0000
@@ -49,6 +49,8 @@
{
public:
+ typedef Array<1, T> SpacingsType_t[Dim];
+
//---------------------------------------------------------------------------
// Constructors.
@@ -70,23 +72,23 @@
RectilinearMeshData(
const Layout &layout,
const Vector<Dim, T> &origin,
- const Vector<Dim, Array<1, T, EngineTag> > &spacings)
+ const SpacingsType_t &spacings)
: NoMeshData<Dim>(layout),
origin_m(origin)
//spacings_m(spacings)
{
for (int i=0; i<Dim; i++) {
- spacings_m(i).engine() = spacings(i).engine(); // init
- spacings_m(i).engine().makeOwnCopy(); // FIXME? Do we want this?
+ spacings_m[i].engine() = spacings[i].engine(); // init
+ spacings_m[i].engine().makeOwnCopy(); // FIXME? Do we want this?
Interval<1> I(layout.domain()[i]);
- positions_m(i).engine() = Engine<1, T, Brick>(I);
- positions_m(i)(0) = origin_m(i);
+ positions_m[i].engine() = Engine<1, T, Brick>(I);
+ positions_m[i](0) = origin_m(i);
// initialize from origin downward the ghost cells
for (int j=-1; j>=I.min(); j--)
- positions_m(i)(j) = positions_m(i).read(j+1) - spacings_m(i).read(j);
+ positions_m[i](j) = positions_m[i].read(j+1) - spacings_m[i].read(j);
// initialize from origin upward
for (int j=1; j<=I.max(); j++)
- positions_m(i)(j) = positions_m(i).read(j-1) +
spacings_m(i).read(j-1);
+ positions_m[i](j) = positions_m[i].read(j-1) +
spacings_m[i].read(j-1);
}
}
@@ -106,18 +108,18 @@
for (int i=0; i<Dim; i++) {
Interval<1> I(layout.domain()[i]);
// allocate and assign spacings
- spacings_m(i).engine() = Engine<1, T, Brick>(I);
- spacings_m(i)(I) = spacings(i); // no Array.all()
+ spacings_m[i].engine() = Engine<1, T, Brick>(I);
+ spacings_m[i](I) = spacings(i); // no Array.all()
Pooma::blockAndEvaluate();
// allocate positions, assign origin
- positions_m(i).engine() = Engine<1, T, Brick>(I);
- positions_m(i)(0) = origin_m(i);
+ positions_m[i].engine() = Engine<1, T, Brick>(I);
+ positions_m[i](0) = origin_m(i);
// initialize from origin downward the ghost cells
for (int j=-1; j>=I.min(); j--)
- positions_m(i)(j) = positions_m(i).read(j+1) - spacings_m(i).read(j);
+ positions_m[i](j) = positions_m[i].read(j+1) - spacings_m[i].read(j);
// initialize from origin upward
for (int j=1; j<=I.max(); j++)
- positions_m(i)(j) = positions_m(i).read(j-1) +
spacings_m(i).read(j-1);
+ positions_m[i](j) = positions_m[i].read(j-1) +
spacings_m[i].read(j-1);
}
}
@@ -130,8 +132,8 @@
//positions_m(model.positions_m)
{
for (int i=0; i<Dim; i++) {
- spacings_m(i).engine() = model.spacings_m(i).engine();
- positions_m(i).engine() = model.positions_m(i).engine();
+ spacings_m[i].engine() = model.spacings_m[i].engine();
+ positions_m[i].engine() = model.positions_m[i].engine();
}
// This space intentionally left blank.
}
@@ -153,9 +155,9 @@
for (int i = 0; i < Dim; i++) {
// FIXME: Wheeee ;) (we cant store a BrickView...
// and still dont want to copy)
- spacings_m(i).engine() = Engine<1, T,
Brick>(&model.spacings_m(i)(d[i])(0), d[i]);
- positions_m(i).engine() = Engine<1, T,
Brick>(&model.positions_m(i)(d[i])(0), d[i]);
- origin_m(i) = positions_m(i)(d[i].min());
+ spacings_m[i].engine() = Engine<1, T,
Brick>(&model.spacings_m[i](d[i])(0), d[i]);
+ positions_m[i].engine() = Engine<1, T,
Brick>(&model.positions_m[i](d[i])(0), d[i]);
+ origin_m(i) = positions_m[i](d[i].min());
}
}
@@ -174,8 +176,8 @@
{
// FIXME: what does FieldEnginePatch do???
for (int i=0; i<Dim; i++) {
- spacings_m(i).engine() = model.spacings_m(i).engine();
- positions_m(i).engine() = model.positions_m(i).engine();
+ spacings_m[i].engine() = model.spacings_m[i].engine();
+ positions_m[i].engine() = model.positions_m[i].engine();
}
}
@@ -192,8 +194,8 @@
NoMeshData<Dim>::operator=(rhs);
origin_m = rhs.origin_m;
for (int i=0; i<Dim; i++) {
- spacings_m(i).engine() = rhs.spacings_m(i).engine();
- positions_m(i).engine() = rhs.positions_m(i).engine();
+ spacings_m[i].engine() = rhs.spacings_m[i].engine();
+ positions_m[i].engine() = rhs.positions_m[i].engine();
}
}
@@ -213,14 +215,14 @@
/// The mesh spacing.
- inline const Vector<Dim, Array<1, T> > &spacings() const
+ inline const SpacingsType_t& spacings() const
{
return spacings_m;
}
/// The mesh vertex positions.
- inline const Vector<Dim, Array<1, T> > &positions() const
+ inline const SpacingsType_t& positions() const
{
return positions_m;
}
@@ -242,11 +244,11 @@
/// Spacings between vertices.
- Vector<Dim, Array<1, T> > spacings_m;
+ SpacingsType_t spacings_m;
/// Vertex positions.
- Vector<Dim, Array<1, T> > positions_m;
+ SpacingsType_t positions_m;
};
@@ -275,7 +277,7 @@
/// The type used to store spacings.
- typedef Vector<Dim, Array<1, T> > SpacingsType_t;
+ typedef Array<1, T> SpacingsType_t[Dim];
/// The type T, used to represent, for example, volumes & areas, etc.
@@ -306,7 +308,7 @@
template<class Layout, class EngineTag>
inline RectilinearMesh(const Layout &layout,
const PointType_t &origin,
- const Vector<Dim, Array<1, T, EngineTag> > &spacings)
+ const SpacingsType_t &spacings)
: data_m(new RectilinearMeshData<Dim, T>(layout, origin, spacings))
{
}
@@ -435,14 +437,14 @@
/// The mesh spacing.
- inline const Vector<Dim, Array<1, T> > &spacings() const
+ inline const SpacingsType_t &spacings() const
{
return data_m->spacings();
}
/// The mesh positions.
- inline const Vector<Dim, Array<1, T> > &positions() const
+ inline const SpacingsType_t &positions() const
{
return data_m->positions();
}
@@ -462,8 +464,8 @@
Loc<Dim> loc((0, Pooma::NoInit())); // Avoid a g++ parse error.
for (int i = 0; i < Dim; i++)
{
- const T *start = &positions()(i)(0);
- const T *finish = start + positions()(i).physicalDomain()[i].length();
+ const T *start = &positions()[i](0);
+ const T *finish = start + positions()[i].physicalDomain()[i].length();
const T *p = std::lower_bound(start, finish, point(i));
#if POOMA_BOUNDS_CHECK
PInsist(p != finish,
@@ -487,7 +489,7 @@
{
Vector<Dim, T> point;
for (int i = 0; i < Dim; i++)
- point(i) = positions()(i)(loc[i]);
+ point(i) = positions()[i](loc[i]);
return point;
}
@@ -521,8 +523,8 @@
: centering_m(c.position(0))
{
for (int i=0; i<Dim; i++) {
- positions_m(i).engine() = m.positions()(i).engine();
- spacings_m(i).engine() = m.spacings()(i).engine();
+ positions_m[i].engine() = m.positions()[i].engine();
+ spacings_m[i].engine() = m.spacings()[i].engine();
}
}
@@ -530,8 +532,8 @@
: centering_m(m.centering_m)
{
for (int i=0; i<Dim; i++) {
- positions_m(i).engine() = m.positions_m(i).engine();
- spacings_m(i).engine() = m.spacings_m(i).engine();
+ positions_m[i].engine() = m.positions_m[i].engine();
+ spacings_m[i].engine() = m.spacings_m[i].engine();
}
}
@@ -539,8 +541,8 @@
{
centering_m = m.centering_m;
for (int i=0; i<Dim; i++) {
- positions_m(i).engine() = m.positions_m(i).engine();
- spacings_m(i).engine() = m.spacings_m(i).engine();
+ positions_m[i].engine() = m.positions_m[i].engine();
+ spacings_m[i].engine() = m.spacings_m[i].engine();
}
return *this;
@@ -548,26 +550,26 @@
inline PointType_t operator()(int i0) const
{
- return PointType_t(positions_m(0).read(i0) +
spacings_m(0).read(i0)*centering_m(0));
+ return PointType_t(positions_m[0].read(i0) +
spacings_m[0].read(i0)*centering_m(0));
}
inline PointType_t operator()(int i0, int i1) const
{
- return PointType_t(positions_m(0).read(i0) +
spacings_m(0).read(i0)*centering_m(0),
- positions_m(1).read(i1) +
spacings_m(1).read(i1)*centering_m(1));
+ return PointType_t(positions_m[0].read(i0) +
spacings_m[0].read(i0)*centering_m(0),
+ positions_m[1].read(i1) +
spacings_m[1].read(i1)*centering_m(1));
}
inline PointType_t operator()(int i0, int i1, int i2) const
{
- return PointType_t(positions_m(0).read(i0) +
spacings_m(0).read(i0)*centering_m(0),
- positions_m(1).read(i1) +
spacings_m(1).read(i1)*centering_m(1),
- positions_m(2).read(i2) +
spacings_m(2).read(i2)*centering_m(2));
+ return PointType_t(positions_m[0].read(i0) +
spacings_m[0].read(i0)*centering_m(0),
+ positions_m[1].read(i1) +
spacings_m[1].read(i1)*centering_m(1),
+ positions_m[2].read(i2) +
spacings_m[2].read(i2)*centering_m(2));
}
private:
- Vector<Dim, Array<1, T> > positions_m;
- Vector<Dim, Array<1, T> > spacings_m;
+ SpacingsType_t positions_m;
+ SpacingsType_t spacings_m;
typename Centering<Dim>::Position centering_m;
};
@@ -634,39 +636,39 @@
: orientation_m(c.orientation(0))
{
for (int i=0; i<Dim; i++)
- spacings_m(i).engine() = m.spacings()(i).engine();
+ spacings_m[i].engine() = m.spacings()[i].engine();
}
GeneralVolumesFunctor(const GeneralVolumesFunctor &m)
: orientation_m(m.orientation_m)
{
for (int i=0; i<Dim; i++)
- spacings_m(i).engine() = m.spacings_m(i).engine();
+ spacings_m[i].engine() = m.spacings_m[i].engine();
}
GeneralVolumesFunctor& operator=(const GeneralVolumesFunctor &m)
{
orientation_m = m.orientation_m;
for (int i=0; i<Dim; i++)
- spacings_m(i).engine() = m.spacings_m(i).engine();
+ spacings_m[i].engine() = m.spacings_m[i].engine();
return *this;
}
inline T operator()(int i0) const
{
// It does not make sense to have a zero orientation for 1D
- return spacings_m(0).read(i0);
+ return spacings_m[0].read(i0);
}
inline T operator()(int i0, int i1) const
{
// It does not make sense to have all zero orientations for 2D
if (orientation_m[0].first() == 0)
- return spacings_m(1).read(i1);
+ return spacings_m[1].read(i1);
else if (orientation_m[1].first() == 0)
- return spacings_m(0).read(i0);
+ return spacings_m[0].read(i0);
else
- return spacings_m(0).read(i0) * spacings_m(1).read(i1);
+ return spacings_m[0].read(i0) * spacings_m[1].read(i1);
}
inline T operator()(int i0, int i1, int i2) const
@@ -674,17 +676,17 @@
// Could optimize as above
T volume = static_cast<T>(1);
if (orientation_m[0].first() != 0)
- volume *= spacings_m(0).read(i0);
+ volume *= spacings_m[0].read(i0);
if (orientation_m[1].first() != 0)
- volume *= spacings_m(1).read(i1);
+ volume *= spacings_m[1].read(i1);
if (orientation_m[2].first() != 0)
- volume *= spacings_m(2).read(i2);
+ volume *= spacings_m[2].read(i2);
return volume;
}
private:
- Vector<Dim, Array<1, T> > spacings_m;
+ SpacingsType_t spacings_m;
typename Centering<Dim>::Orientation orientation_m;
};
- [Freepooma-devel] [PATCH] Use Array<1, T>[Dim], not Vector<Dim, Array<1, T> >,
Richard Guenther <=