diff options
author | Erik Schnetter <schnetter@gmail.com> | 2012-02-25 11:01:40 -0500 |
---|---|---|
committer | Barry Wardell <barry.wardell@gmail.com> | 2012-09-11 18:23:06 +0100 |
commit | 487280c1b638d05f4bbc2bc41c81d1fdb424cd4d (patch) | |
tree | d4ea7557f7cd42f74ce6f7a92b906e6401c69c97 /Carpet/CarpetLib/src/gf.hh | |
parent | ae44c5e6d86a65cce382e313e2a10b214e9645da (diff) |
CarpetLib: Change API to obtain pointer to grid function data
Change the API to obtain a pointer to grid function data:
- Use a function "typed_data_pointer" instead of overloading the ()
operator (because this looks nicer)
- Don't use a virtual function (because this isn't needed)
- Update all uses
Diffstat (limited to 'Carpet/CarpetLib/src/gf.hh')
-rw-r--r-- | Carpet/CarpetLib/src/gf.hh | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/Carpet/CarpetLib/src/gf.hh b/Carpet/CarpetLib/src/gf.hh index a610ea46f..bf58ac7ff 100644 --- a/Carpet/CarpetLib/src/gf.hh +++ b/Carpet/CarpetLib/src/gf.hh @@ -37,7 +37,7 @@ public: th& t, dh& d, const int prolongation_order_time, const int vectorlength, const int vectorindex, - gf* const vectorleader); + ggf* const vectorleader); // Destructors virtual ~gf (); @@ -50,7 +50,7 @@ public: { data<T>* const vl = this->vectorleader - ? (data<T>*)(*this->vectorleader)(tl,rl,lc,ml) + ? ((gf<T>*)this->vectorleader)->typed_data_pointer(tl,rl,lc,ml) : NULL; return new data<T>(this->varindex, h.refcent, this->transport_operator, @@ -58,8 +58,7 @@ public: vl); } - virtual gdata* - new_typed_data () const + virtual gdata* new_typed_data () const { return new data<T>(this->varindex, h.refcent, this->transport_operator, @@ -70,9 +69,29 @@ public: // Access to the data - virtual const data<T>* operator() (int tl, int rl, int lc, int ml) const; +#if 0 + virtual const data<T>* operator() (int tl, int rl, int lc, int ml) const + CCTK_MEMBER_ATTRIBUTE_PURE; + virtual data<T>* operator() (int tl, int rl, int lc, int ml) + CCTK_MEMBER_ATTRIBUTE_PURE; +#endif - virtual data<T>* operator() (int tl, int rl, int lc, int ml); + data<T> const* typed_data_pointer (int tl, int rl, int lc, int ml) const + { + assert (rl>=0 and rl<h.reflevels()); + assert (lc>=0 and lc<h.local_components(rl)); + assert (ml>=0 and ml<h.mglevels()); + assert (tl>=0 and tl<timelevels(ml, rl)); + return (data<T> const*)storage.AT(ml).AT(rl).AT(lc).AT(tl); + } + data<T>* typed_data_pointer (int tl, int rl, int lc, int ml) + { + assert (rl>=0 and rl<h.reflevels()); + assert (lc>=0 and lc<h.local_components(rl)); + assert (ml>=0 and ml<h.mglevels()); + assert (tl>=0 and tl<timelevels(ml, rl)); + return (data<T>*)storage.AT(ml).AT(rl).AT(lc).AT(tl); + } |