aboutsummaryrefslogtreecommitdiff
path: root/Carpet/CarpetLib/src
diff options
context:
space:
mode:
Diffstat (limited to 'Carpet/CarpetLib/src')
-rw-r--r--Carpet/CarpetLib/src/defs.cc4
-rw-r--r--Carpet/CarpetLib/src/gh.cc17
-rw-r--r--Carpet/CarpetLib/src/gh.hh4
-rw-r--r--Carpet/CarpetLib/src/th.cc17
-rw-r--r--Carpet/CarpetLib/src/th.hh4
5 files changed, 33 insertions, 13 deletions
diff --git a/Carpet/CarpetLib/src/defs.cc b/Carpet/CarpetLib/src/defs.cc
index fcbbace14..d83b6e0a5 100644
--- a/Carpet/CarpetLib/src/defs.cc
+++ b/Carpet/CarpetLib/src/defs.cc
@@ -150,14 +150,18 @@ ostream& output (ostream& os, const vector<T>& v) {
#include "bbox.hh"
#include "bboxset.hh"
+#include "vect.hh"
template int ipow (int x, int y);
template CCTK_REAL ipow (CCTK_REAL x, int y);
+template vect<int,3> ipow (vect<int,3> x, int y);
+template istream& input (istream& os, vector<int>& v);
template istream& input (istream& os, vector<bbox<int,3> >& v);
template istream& input (istream& os, vector<bbox<CCTK_REAL,3> >& v);
template istream& input (istream& os, vector<vector<bbox<int,3> > >& v);
template istream& input (istream& os, vector<vector<bbox<CCTK_REAL,3> > >& v);
+template istream& input (istream& os, vector<vect<int,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);
diff --git a/Carpet/CarpetLib/src/gh.cc b/Carpet/CarpetLib/src/gh.cc
index 55c23def9..2a0a631f5 100644
--- a/Carpet/CarpetLib/src/gh.cc
+++ b/Carpet/CarpetLib/src/gh.cc
@@ -1,6 +1,7 @@
#include <cassert>
#include <cstdlib>
#include <iostream>
+#include <vector>
#include "cctk.h"
#include "cctk_Parameters.h"
@@ -8,6 +9,7 @@
#include "defs.hh"
#include "dh.hh"
#include "th.hh"
+#include "vect.hh"
#include "gh.hh"
@@ -16,13 +18,19 @@ using namespace std;
// Constructors
-gh::gh (const int reffact_, const centering refcent_,
+gh::gh (const vector<ivect> & reffacts_, const centering refcent_,
const int mgfact_, const centering mgcent_,
const ibbox baseextent_)
- : reffact(reffact_), refcent(refcent_),
+ : reffacts(reffacts_), refcent(refcent_),
mgfact(mgfact_), mgcent(mgcent_),
baseextent(baseextent_)
{
+ assert (reffacts.size() >= 1);
+ assert (all (reffacts.front() == 1));
+ for (size_t n = 1; n < reffacts.size(); ++ n) {
+ assert (all (reffacts.at(n) >= reffacts.at(n-1)));
+ assert (all (reffacts.at(n) % reffacts.at(n-1) == 0));
+ }
}
// Destructors
@@ -136,7 +144,8 @@ void gh::check_refinement_levels ()
for (int ml=0; ml<mglevels(); ++ml) {
for (int rl=1; rl<reflevels(); ++rl) {
assert (all(extents().at(ml).at(rl-1).at(0).stride()
- == ivect(reffact) * extents().at(ml).at(rl).at(0).stride()));
+ == ((reffacts.at(rl) / reffacts.at(rl-1))
+ * extents().at(ml).at(rl).at(0).stride())));
// Check contained-ness:
// first take all coarse grids ...
ibset all;
@@ -240,7 +249,7 @@ void gh::do_output_bases (ostream& os) const
ostream& gh::output (ostream& os) const
{
os << "gh:"
- << "reffactor=" << reffact << ",refcentering=" << refcent << ","
+ << "reffacts=" << reffacts << ",refcentering=" << refcent << ","
<< "mgfactor=" << mgfact << ",mgcentering=" << mgcent << ","
<< "extents=" << extents() << ","
<< "outer_boundaries=" << outer_boundaries() << ","
diff --git a/Carpet/CarpetLib/src/gh.hh b/Carpet/CarpetLib/src/gh.hh
index ee7b86844..f46fd5c34 100644
--- a/Carpet/CarpetLib/src/gh.hh
+++ b/Carpet/CarpetLib/src/gh.hh
@@ -46,7 +46,7 @@ public:
public: // should be readonly
// Fields
- const int reffact; // refinement factor
+ const vector<ivect> reffacts; // refinement factors
const centering refcent; // vertex or cell centered
const int mgfact; // default multigrid factor
@@ -68,7 +68,7 @@ private:
public:
// Constructors
- gh (const int reffact, const centering refcent,
+ gh (const vector<ivect> & reffacts, const centering refcent,
const int mgfact, const centering mgcent,
const ibbox baseextent);
diff --git a/Carpet/CarpetLib/src/th.cc b/Carpet/CarpetLib/src/th.cc
index 84b896b55..0751a03e1 100644
--- a/Carpet/CarpetLib/src/th.cc
+++ b/Carpet/CarpetLib/src/th.cc
@@ -1,6 +1,7 @@
#include <cassert>
#include <cmath>
#include <iostream>
+#include <vector>
#include "cctk.h"
@@ -14,9 +15,15 @@ using namespace std;
// Constructors
-th::th (gh& h_, const CCTK_REAL basedelta)
- : h(h_), delta(basedelta)
+th::th (gh& h_, const vector<int> & reffacts_, const CCTK_REAL basedelta)
+ : h(h_), reffacts(reffacts_), delta(basedelta)
{
+ assert (reffacts.size() >= 1);
+ assert (reffacts.front() == 1);
+ for (size_t n = 1; n < reffacts.size(); ++ n) {
+ assert (reffacts.at(n) >= reffacts.at(n-1));
+ assert (reffacts.at(n) % reffacts.at(n-1) == 0);
+ }
h.add(this);
}
@@ -44,10 +51,8 @@ void th::recompose ()
} else {
times.at(ml).at(rl) = times.at(ml).at(rl-1);
}
- if (ml==0 and rl==0) {
- deltas.at(ml).at(rl) = delta;
- } else if (ml==0) {
- deltas.at(ml).at(rl) = deltas.at(ml).at(rl-1) / h.reffact;
+ if (ml==0) {
+ deltas.at(ml).at(rl) = delta / reffacts.at(rl);
} else {
deltas.at(ml).at(rl) = deltas.at(ml-1).at(rl) * h.mgfact;
}
diff --git a/Carpet/CarpetLib/src/th.hh b/Carpet/CarpetLib/src/th.hh
index 42bd6504e..3c24c227c 100644
--- a/Carpet/CarpetLib/src/th.hh
+++ b/Carpet/CarpetLib/src/th.hh
@@ -32,6 +32,8 @@ public: // should be readonly
private:
+ const vector<int> reffacts;
+
CCTK_REAL delta; // time step
vector<vector<CCTK_REAL> > times; // current times [ml][rl]
vector<vector<CCTK_REAL> > deltas; // time steps [ml][rl]
@@ -39,7 +41,7 @@ private:
public:
// Constructors
- th (gh& h, const CCTK_REAL basedelta);
+ th (gh& h, const vector<int> & reffacts, const CCTK_REAL basedelta);
// Destructors
~th ();