aboutsummaryrefslogtreecommitdiff
path: root/Carpet
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@cct.lsu.edu>2008-01-14 15:12:00 +0000
committerErik Schnetter <schnetter@cct.lsu.edu>2008-01-14 15:12:00 +0000
commit0cc61c57b87d0a72532a12a98d5daeac80fe70df (patch)
treee200f531c6abe4ecda83f60e2aa0caf1c3bdfb8f /Carpet
parent9a5fe470d0801aeb56d39243a2028318b4fe2252 (diff)
CarpetLib: Add function ggf::fill, which fills all time levels
Add a new function ggf::fill, which fills all time levels from the current time level. Remove the function ggf::copy, which was unused. darcs-hash:20080114151255-dae7b-469b57d0393ba0ed22590c2eabe862e02702fde7.gz
Diffstat (limited to 'Carpet')
-rw-r--r--Carpet/CarpetLib/src/data.hh5
-rw-r--r--Carpet/CarpetLib/src/gdata.hh5
-rw-r--r--Carpet/CarpetLib/src/ggf.cc25
-rw-r--r--Carpet/CarpetLib/src/ggf.hh6
4 files changed, 26 insertions, 15 deletions
diff --git a/Carpet/CarpetLib/src/data.hh b/Carpet/CarpetLib/src/data.hh
index 39d7517c9..fa11e2852 100644
--- a/Carpet/CarpetLib/src/data.hh
+++ b/Carpet/CarpetLib/src/data.hh
@@ -96,6 +96,11 @@ private:
T dummy;
return dist::c_datatype (dummy);
}
+ // size of the C datatype
+ virtual size_t c_datatype_size () const
+ {
+ return sizeof (T);
+ }
// Data manipulators
diff --git a/Carpet/CarpetLib/src/gdata.hh b/Carpet/CarpetLib/src/gdata.hh
index 6d8cd2fef..76c1ab6fe 100644
--- a/Carpet/CarpetLib/src/gdata.hh
+++ b/Carpet/CarpetLib/src/gdata.hh
@@ -123,6 +123,10 @@ public:
return _extent;
}
+ int elementsize () const {
+ return c_datatype_size();
+ }
+
// Data accessors
int offset (const ivect& index) const {
assert (_has_storage);
@@ -136,6 +140,7 @@ private:
// Datatype accessors
// maps the C datatype of a data class object to a 0-based index
virtual unsigned int c_datatype () const = 0;
+ virtual size_t c_datatype_size () const = 0;
// Data manipulators
diff --git a/Carpet/CarpetLib/src/ggf.cc b/Carpet/CarpetLib/src/ggf.cc
index 3a81a3677..f698835ec 100644
--- a/Carpet/CarpetLib/src/ggf.cc
+++ b/Carpet/CarpetLib/src/ggf.cc
@@ -257,19 +257,20 @@ void ggf::flip (int rl, int c, int ml) {
-#if 0
-// Copy a component from the next time level
-void ggf::copy (comm_state& state, int tl, int rl, int c, int ml)
-{
- // Copy
- static Timer timer ("copy");
- timer.start ();
- transfer_from (state,
- tl ,rl,c,ml, &dh::dboxes::exterior,
- tl+1,rl, ml);
- timer.stop (0);
+// Fill all time levels from the current time level
+void ggf::fill (int rl, int c, int ml) {
+ assert (rl>=0 and rl<h.reflevels());
+ assert (c>=0 and c<h.components(rl));
+ assert (ml>=0 and ml<h.mglevels());
+ if (not h.is_local(rl,c)) return;
+ fdata const & fdatas = storage.AT(ml).AT(rl).AT(c);
+ void const * const srcptr = fdatas.AT(0)->storage();
+ size_t const size = fdatas.AT(0)->size() * fdatas.AT(0)->elementsize();
+ for (int tl=1; tl<timelevels(ml,rl); ++tl) {
+ void * const dstptr = fdatas.AT(tl)->storage();
+ memcpy (dstptr, srcptr, size);
+ }
}
-#endif
diff --git a/Carpet/CarpetLib/src/ggf.hh b/Carpet/CarpetLib/src/ggf.hh
index 624b51ef5..99eae2167 100644
--- a/Carpet/CarpetLib/src/ggf.hh
+++ b/Carpet/CarpetLib/src/ggf.hh
@@ -103,15 +103,15 @@ public:
// Flip the time levels by exchanging the data sets
void flip (int rl, int c, int ml);
+ // Fill all time levels from the current time level
+ void fill (int rl, int c, int ml);
+
// The grid boundaries have to be updated after calling mg_restrict,
// mg_prolongate, ref_restrict, or ref_prolongate.
// "Updating" means here that the boundaries have to be
// synchronised. They don't need to be prolongated.
- // Copy a component from the next time level
- void copy (comm_state& state, int tl, int rl, int c, int ml);
-
// Synchronise the boundaries of a component
void sync (comm_state& state, int tl, int rl, int c, int ml);