/*************************************************************************** gdata.hh - description ------------------- begin : Wed Jul 19 2000 copyright : (C) 2000 by Erik Schnetter email : schnetter@astro.psu.edu $Header: /home/eschnett/C/carpet/Carpet/Carpet/CarpetLib/src/gdata.hh,v 1.15 2002/09/25 15:49:16 schnetter Exp $ ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef GDATA_HH #define GDATA_HH #include #include #include #include #include "cctk.h" #include "defs.hh" #include "dgdata.hh" #include "dist.hh" #include "bbox.hh" #include "vect.hh" using namespace std; // A generic data storage without type information template class generic_data: public dimgeneric_data { // Types typedef vect ivect; typedef bbox ibbox; protected: // should be readonly // Fields ivect _shape, _stride; // shape and index order ibbox _extent; // bbox for all data public: // Constructors generic_data (); // Destructors virtual ~generic_data (); // Pseudo constructors virtual generic_data* make_typed () const = 0; // Storage management virtual void transfer_from (generic_data* src) = 0; virtual void allocate (const ibbox& extent, const int proc, void* const mem=0) = 0; virtual void free () = 0; // Accessors const ivect& shape () const { assert (_has_storage); return _shape; } const ivect& stride () const { assert (_has_storage); return _stride; } const ibbox& extent () const { assert (_has_storage); return _extent; } // Data accessors int offset (const ivect& index) const { assert (_has_storage); assert (all((index-extent().lower()) % extent().stride() == 0)); ivect ind = (index-extent().lower()) / extent().stride(); assert (all(ind>=0 && ind<=shape())); return dot(ind, stride()); } // Data manipulators void copy_from (const generic_data* src, const ibbox& box); void interpolate_from (const vector srcs, const vector times, const ibbox& box, const CCTK_REAL time, const int order_space, const int order_time); protected: virtual void copy_from_innerloop (const generic_data* src, const ibbox& box) = 0; virtual void interpolate_from_innerloop (const vector srcs, const vector times, const ibbox& box, const CCTK_REAL time, const int order_space, const int order_time) = 0; }; #endif // GDATA_HH