00001 00002 00003 00004 #ifndef included_ObjectPrinting_h 00005 #define included_ObjectPrinting_h 00006 00007 #include "printObjectX.h" 00008 00009 #include <MultiDimArrayAccess.h> 00010 00011 #include <SAMRAI_config.h> 00012 #include <tbox_Pointer.h> 00013 #include <hier_PatchHierarchyX.h> 00014 #include <hier_PatchLevelX.h> 00015 #include <hier_PatchDataX.h> 00016 #include <hier_BoxX.h> 00017 #include <pdat_ArrayDataX.h> 00018 00019 00020 using namespace SAMRAI; 00021 00022 00026 int printObjectX( 00027 ostream &os 00028 , const hier_PatchHierarchyX &hierarchy 00029 ) { 00030 int nlevels = hierarchy.getNumberLevels(); 00031 os << "\nhier_PatchHierarchyX::printClassData... " << endl; 00032 os << "Number of levels = " << nlevels << "\n"; 00033 return 0; 00034 } 00035 00036 00040 int printObjectX( 00041 ostream &os 00042 , const hier_PatchLevelX &level 00043 ) { 00044 int npatch = level.getNumberOfPatches(); 00045 os << "\nhier_PatchLevelX::printClassData... " << endl; 00046 os << "Number of patches = " << npatch << "\n"; 00047 return 0; 00048 } 00049 00050 00054 int printObjectX( 00055 ostream &os 00056 , const hier_BoxX &box 00057 ) { 00058 os << "\nhier_BoxX::printClassData... " << endl; 00059 os << "( " << box.lower(0) << ' ' << box.lower(1) 00060 << " ) to ( " 00061 << box.upper(0) << ' ' << box.upper(1) 00062 << " )\n"; 00063 return 0; 00064 } 00065 00066 00070 int printObjectX( 00071 ostream &os 00072 , const hier_PatchDataX &pdat 00073 ) { 00074 os << "\nhier_PatchX::printClassData... " << endl; 00075 const hier_BoxX &rbox = pdat.getBox(); 00076 const hier_BoxX &gbox = pdat.getGhostBox(); 00077 os << "Box = ( " 00078 << rbox.lower(0) << ' ' << rbox.lower(1) 00079 << " ) to ( " 00080 << rbox.upper(0) << ' ' << rbox.upper(1) 00081 << " )\n"; 00082 os << "Ghost Box = ( " 00083 << gbox.lower(0) << ' ' << gbox.lower(1) 00084 << " ) to ( " 00085 << gbox.upper(0) << ' ' << gbox.upper(1) 00086 << " )\n"; 00087 return 0; 00088 } 00089 00090 00094 template <class T> 00095 int printObjectX( 00096 ostream &os 00097 , const pdat_ArrayDataX<T> &adat 00098 ) { 00099 os << "\nhier_ArrayX::printClassData... " << endl; 00100 const hier_BoxX &rbox = adat.getBox(); 00101 os << "Box = ( " 00102 << rbox.lower(0) << ' ' << rbox.lower(1) 00103 << " ) to ( " 00104 << rbox.upper(0) << ' ' << rbox.upper(1) 00105 << " )\n"; 00106 printObjectX( os 00107 , adat.getPointer() 00108 , (const int*)adat.getBox().lower() 00109 , (const int*)adat.getBox().upper() 00110 ); 00111 return 0; 00112 } 00113 template int printObjectX( ostream &os , const pdat_ArrayDataX<double> &adat ); 00114 00115 00119 int printObjectX( 00120 ostream &os 00121 , const double *a_ptr , const int *a_lower , const int *a_upper 00122 , const int *lower=NULL 00123 , const int *upper=NULL 00124 ) { 00125 ConstMultiDimArrayAccess<double,NDIM> a( a_ptr , a_lower , a_upper , true ); 00126 if ( ! lower ) lower = a_lower; 00127 if ( ! upper ) upper = a_upper; 00128 os << "\narray data... " << endl; 00129 for ( int j=lower[1]; j<=upper[1]; ++j ) { 00130 for ( int i=lower[0]; i<=upper[0]; ++i ) { 00131 os << i << ' ' << j << ' ' << a(j,i) << endl; 00132 } 00133 } 00134 return 0; 00135 } 00136 00137 #endif // included_ObjectPrinting_h