aboutsummaryrefslogtreecommitdiff
path: root/Carpet
diff options
context:
space:
mode:
authorschnetter <>2003-11-13 15:03:00 +0000
committerschnetter <>2003-11-13 15:03:00 +0000
commit4acb869d0acc7ad83517f9253de7babe8b0e215b (patch)
tree67462d62ba3c81b6951e4e60e9dfc32394db5d47 /Carpet
parent7ee4027639763fbe3e00a97d996bd312ee04ba66 (diff)
Allow bboxes of CCTK_REALs.
darcs-hash:20031113150358-07bb3-427886aab7c861fe53bf7fef96ec2a31e1d155f5.gz
Diffstat (limited to 'Carpet')
-rw-r--r--Carpet/CarpetLib/src/bbox.cc11
-rw-r--r--Carpet/CarpetLib/src/defs.cc6
-rw-r--r--Carpet/CarpetLib/src/vect.cc3
-rw-r--r--Carpet/CarpetLib/src/vect.hh22
4 files changed, 33 insertions, 9 deletions
diff --git a/Carpet/CarpetLib/src/bbox.cc b/Carpet/CarpetLib/src/bbox.cc
index d86136043..bbfcc3df5 100644
--- a/Carpet/CarpetLib/src/bbox.cc
+++ b/Carpet/CarpetLib/src/bbox.cc
@@ -1,4 +1,4 @@
-// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/bbox.cc,v 1.17 2003/09/19 16:06:41 schnetter Exp $
+// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/bbox.cc,v 1.18 2003/11/13 16:03:58 schnetter Exp $
#include <assert.h>
@@ -16,7 +16,7 @@ using namespace std;
// Constructors
template<class T, int D>
-bbox<T,D>::bbox (): _lower(1), _upper(0), _stride(1) { }
+bbox<T,D>::bbox (): _lower(T(1)), _upper(T(0)), _stride(T(1)) { }
template<class T, int D>
bbox<T,D>::bbox (const bbox& b)
@@ -35,7 +35,7 @@ bbox<T,D>::bbox (const vect<T,D>& lower, const vect<T,D>& upper,
: _lower(lower), _upper(upper), _stride(stride)
{
assert (all(stride>=1));
- assert (all((upper-lower)%stride==0));
+ assert (all((upper-lower)%stride == T(0)));
}
// Accessors
@@ -128,14 +128,14 @@ bool bbox<T,D>::is_contained_in (const bbox& b) const {
// Alignment check
template<class T, int D>
bool bbox<T,D>::is_aligned_with (const bbox& b) const {
- return all(stride()==b.stride() && (lower()-b.lower()) % stride() == 0);
+ return all(stride()==b.stride() && (lower()-b.lower()) % stride() == T(0));
}
// Expand the bbox a little by multiples of the stride
template<class T, int D>
bbox<T,D> bbox<T,D>::expand (const vect<T,D>& lo, const vect<T,D>& hi) const {
// Allow expansion only into directions where the extent is not negative
- assert (all(lower()<=upper() || (lo==0 && hi==0)));
+ assert (all(lower()<=upper() || (lo==T(0) && hi==T(0))));
const vect<T,D> str = stride();
const vect<T,D> lb = lower() - lo * str;
const vect<T,D> ub = upper() + hi * str;
@@ -279,3 +279,4 @@ void bbox<T,D>::output (ostream& os) const {
template class bbox<int,1>;
template class bbox<int,2>;
template class bbox<int,3>;
+template class bbox<double,3>;
diff --git a/Carpet/CarpetLib/src/defs.cc b/Carpet/CarpetLib/src/defs.cc
index 71e82f605..b525578ef 100644
--- a/Carpet/CarpetLib/src/defs.cc
+++ b/Carpet/CarpetLib/src/defs.cc
@@ -1,4 +1,4 @@
-// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/defs.cc,v 1.16 2003/05/20 10:26:27 shawley Exp $
+// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/defs.cc,v 1.17 2003/11/13 16:03:58 schnetter Exp $
#include <assert.h>
#include <ctype.h>
@@ -103,7 +103,9 @@ ostream& output (ostream& os, const vector<T>& v) {
#include "bboxset.hh"
template istream& input (istream& os, vector<bbox<int,3> >& v);
+template istream& input (istream& os, vector<bbox<double,3> >& v);
template istream& input (istream& os, vector<vector<bbox<int,3> > >& v);
+template istream& input (istream& os, vector<vector<bbox<double,3> > >& v);
template istream& input (istream& os, vector<vect<vect<bool,2>,3> >& v);
template istream& input (istream& os, vector<vector<vect<vect<bool,2>,3> > >& v);
@@ -113,9 +115,11 @@ template ostream& output (ostream& os, const set<bboxset<int,3> >& s);
template ostream& output (ostream& os, const stack<bbox<int,3> >& s);
template ostream& output (ostream& os, const vector<int>& v);
template ostream& output (ostream& os, const vector<bbox<int,3> >& v);
+template ostream& output (ostream& os, const vector<bbox<double,3> >& v);
template ostream& output (ostream& os, const vector<list<bbox<int,3> > >& v);
template ostream& output (ostream& os, const vector<vector<int> >& v);
template ostream& output (ostream& os, const vector<vector<bbox<int,3> > >& v);
+template ostream& output (ostream& os, const vector<vector<bbox<double,3> > >& v);
template ostream& output (ostream& os, const vector<vector<vect<vect<bool,2>,3> > >& v);
template ostream& output (ostream& os, const vector<vect<vect<bool,2>,3> >& v);
template ostream& output (ostream& os, const vector<vector<vector<bbox<int,3> > > >& v);
diff --git a/Carpet/CarpetLib/src/vect.cc b/Carpet/CarpetLib/src/vect.cc
index a80d2688f..7fe311fdb 100644
--- a/Carpet/CarpetLib/src/vect.cc
+++ b/Carpet/CarpetLib/src/vect.cc
@@ -1,4 +1,4 @@
-// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/vect.cc,v 1.11 2003/04/30 12:39:40 schnetter Exp $
+// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/vect.cc,v 1.12 2003/11/13 16:03:58 schnetter Exp $
#include <assert.h>
@@ -58,3 +58,4 @@ template void vect<bool,2>::output (ostream& os) const;
template void vect<bool,3>::output (ostream& os) const;
template void vect<double,3>::output (ostream& os) const;
template void vect<vect<bool,2>,3>::output (ostream& os) const;
+template void vect<vect<int,2>,3>::output (ostream& os) const;
diff --git a/Carpet/CarpetLib/src/vect.hh b/Carpet/CarpetLib/src/vect.hh
index dfb724694..5271626d2 100644
--- a/Carpet/CarpetLib/src/vect.hh
+++ b/Carpet/CarpetLib/src/vect.hh
@@ -1,4 +1,4 @@
-// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/vect.hh,v 1.20 2003/11/05 16:18:39 schnetter Exp $
+// $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/vect.hh,v 1.21 2003/11/13 16:03:58 schnetter Exp $
#ifndef VECT_HH
#define VECT_HH
@@ -23,6 +23,18 @@ ostream& operator<< (ostream& os, const vect<T,D>& a);
+template<typename T>
+struct integral {
+ typedef T substitute;
+};
+
+template<>
+struct integral<double> {
+ typedef int substitute;
+};
+
+
+
/**
* A short vector with a size that is specified at compile time.
*/
@@ -232,7 +244,13 @@ public:
}
vect& operator%=(const vect& a) {
- for (int d=0; d<D; ++d) elt[d]%=a[d];
+ for (int d=0; d<D; ++d) {
+// elt[d]%=a[d];
+ typename integral<T>::substitute se, sa;
+ se = elt[d]; sa = a[d];
+ se %= sa;
+ elt[d] = se;
+ }
return *this;
}