00001 /* _______ __ 00002 / ___/ / ___ __ _ / / ___ 00003 / /__/ _ \/ _ \/ ' \/ _ \/ _ \ 00004 \___/_//_/\___/_/_/_/_.__/\___/ 00005 */ 00006 // 00007 // This software is copyright (C) by the Lawrence Berkeley 00008 // National Laboratory. Permission is granted to reproduce 00009 // this software for non-commercial purposes provided that 00010 // this notice is left intact. 00011 // 00012 // It is acknowledged that the U.S. Government has rights to 00013 // this software under Contract DE-AC03-765F00098 between 00014 // the U.S. Department of Energy and the University of 00015 // California. 00016 // 00017 // This software is provided as a professional and academic 00018 // contribution for joint exchange. Thus it is experimental, 00019 // is provided ``as is'', with no warranties of any kind 00020 // whatsoever, no support, no promise of updates, or printed 00021 // documentation. By using this software, you acknowledge 00022 // that the Lawrence Berkeley National Laboratory and 00023 // Regents of the University of California shall have no 00024 // liability with respect to the infringement of other 00025 // copyrights by any part of this software. 00026 // 00027 00028 #ifndef Scalar_H 00029 #define Scalar_H 00030 00031 #ifndef WRAPPER 00032 #include "LevelData.H" 00033 #include "FArrayBox.H" 00034 #include "RefCountedPtr.H" 00035 #endif 00036 00037 00038 class Scalar 00039 { 00040 public: 00041 Scalar(); 00042 00043 ~Scalar(); 00044 00045 Scalar(const Scalar& scalar); // ref-counted copy. 00046 00047 void define(const DisjointBoxLayout& dp, const IntVect& ghost, 00048 const Box& domain); 00049 00050 //actual define function that pulls the data off the disk. not 00051 // used in interpretive interface (interpreter doesn't have HDF5Handle 00052 // object 00053 int define(HDF5Handle& handle, std::string& group, int component, 00054 const IntVect& ghost); 00055 00056 ~Scalar(); 00057 00058 void exchange(); 00059 00060 Scalar copy() const; //actual deep copy, not refcopy. 00061 00062 IntVect ghostVect() const; 00063 00064 const DisjointBoxLayout& getBoxes() const; 00065 00066 const DisjointBoxLayout& disjointBoxLayout() const; 00067 00068 Box box(int index) const ; 00069 00070 FArrayBox& get(int index) ; 00071 00072 int size() const ; //returns the number of FArrayBox objects. 00073 00074 const LevelData<FArrayBox>* dataPtr() const ; 00075 00076 int refCount() const; 00077 00078 bool isNull() const; 00079 00080 Real norm (int p) const; 00081 00082 Real min (int& box, IntVect& index) const; 00083 00084 Real max (int& box, IntVect& index) const; 00085 00086 void abs (); 00087 00088 Real sum (); 00089 00090 void scale (Real v); 00091 00092 void add (Real v); 00093 00094 Scalar neg() const ; // return negative of Scalar 00095 00096 void mult(const Scalar& rhs); // in-place *= 00097 00098 void plus(const Scalar& rhs); // in place += 00099 00100 void call(PyObject *PyFunc); // callback function 00101 00102 private: 00103 RefCountedPtr<LevelData<FArrayBox> > m_ptr; 00104 Box m_domain; 00105 }; 00106 00107 #endif