From 487280c1b638d05f4bbc2bc41c81d1fdb424cd4d Mon Sep 17 00:00:00 2001 From: Erik Schnetter Date: Sat, 25 Feb 2012 11:01:40 -0500 Subject: 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 --- Carpet/CarpetLib/src/gf.hh | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'Carpet/CarpetLib/src/gf.hh') 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* const vl = this->vectorleader - ? (data*)(*this->vectorleader)(tl,rl,lc,ml) + ? ((gf*)this->vectorleader)->typed_data_pointer(tl,rl,lc,ml) : NULL; return new data(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(this->varindex, h.refcent, this->transport_operator, @@ -70,9 +69,29 @@ public: // Access to the data - virtual const data* operator() (int tl, int rl, int lc, int ml) const; +#if 0 + virtual const data* operator() (int tl, int rl, int lc, int ml) const + CCTK_MEMBER_ATTRIBUTE_PURE; + virtual data* operator() (int tl, int rl, int lc, int ml) + CCTK_MEMBER_ATTRIBUTE_PURE; +#endif - virtual data* operator() (int tl, int rl, int lc, int ml); + data const* typed_data_pointer (int tl, int rl, int lc, int ml) const + { + assert (rl>=0 and rl=0 and lc=0 and ml=0 and tl const*)storage.AT(ml).AT(rl).AT(lc).AT(tl); + } + data* typed_data_pointer (int tl, int rl, int lc, int ml) + { + assert (rl>=0 and rl=0 and lc=0 and ml=0 and tl*)storage.AT(ml).AT(rl).AT(lc).AT(tl); + } -- cgit v1.2.3