00001
00002
00003
00004
00005
00006 #ifndef AMROC_FIXUP1_H
00007 #define AMROC_FIXUP1_H
00008
00016 #include "FixupBase.h"
00017
00024 template <class VectorType, class FixupType>
00025 class FixupOps<VectorType,FixupType,1> {
00026 public:
00027 FixupOps() {}
00028
00029 void AlignBBox(BBox &bb, const int s) {
00030 int DAGH_Base = DAGH_X;
00031 #ifdef DEBUG_PRINT
00032 assert (s>=0 && s<2*1);
00033 #endif
00034 int dim_1 = 1;
00035 if (s % 2 != 0)
00036 DAGH_Base = DAGH_Base | DAGH_Dim1ToTop;
00037 gdbAlignBBox(dim_1, bb, DAGH_Base - s/2);
00038 bb.rank = dim_1;
00039 bb.lower().rank = dim_1;
00040 bb.upper().rank = dim_1;
00041 bb.stepsize().rank = dim_1;
00042 }
00043
00044 void copy_to(GridData<FixupType,1> &target, const BBox &to,
00045 const GridData<VectorType,1> &source, const BBox &fromwhere, const int s) {
00046 BBox tobb(to * target.bbox());
00047 BBox frombb(fromwhere * source.bbox()); AlignBBox(frombb, s);
00048 equals_to(target(tobb.lower(0)),source(frombb.lower(0)));
00049 }
00050 void copy_to(GridData<FixupType,1> &target,
00051 const GridData<VectorType,1> &source, const BBox &fromwhere, const int s) {
00052 BBox tobb(target.bbox());
00053 BBox frombb(fromwhere * source.bbox()); AlignBBox(frombb, s);
00054 equals_to(target(tobb.lower(0)),source(frombb.lower(0)));
00055 }
00056
00057 void copy_from(GridData<VectorType,1> &target, const BBox &towhere,
00058 const GridData<FixupType,1> &source, const BBox &from, const int s) {
00059 BBox tobb(towhere * target.bbox()); AlignBBox(tobb, s);
00060 BBox frombb(from * source.bbox());
00061 equals_from(target(tobb.lower(0)),source(frombb.lower(0)));
00062 }
00063 void copy_from(GridData<VectorType,1> &target, const BBox &towhere,
00064 const GridData<FixupType,1> &source, const int s) {
00065 BBox tobb(towhere * target.bbox()); AlignBBox(tobb, s);
00066 BBox frombb(source.bbox());
00067 equals_from(target(tobb.lower(0)),source(frombb.lower(0)));
00068 }
00069
00070 void add_to(GridData<FixupType,1> &target, const BBox &to,
00071 const GridData<VectorType,1> &source, const BBox &fromwhere, const int s) {
00072 BBox tobb(to * target.bbox());
00073 BBox frombb(fromwhere * source.bbox()); AlignBBox(frombb, s);
00074 plus_to(target(tobb.lower(0)),source(frombb.lower(0)));
00075 }
00076 void add_to(GridData<FixupType,1> &target,
00077 const GridData<VectorType,1> &source, const BBox &fromwhere, const int s) {
00078 BBox tobb(target.bbox());
00079 BBox frombb(fromwhere * source.bbox()); AlignBBox(frombb, s);
00080 plus_to(target(tobb.lower(0)),source(frombb.lower(0)));
00081 }
00082
00083 void add_from(GridData<VectorType,1> &target, const BBox &towhere,
00084 const GridData<FixupType,1> &source, const BBox &from, const int s) {
00085 BBox tobb(towhere * target.bbox()); AlignBBox(tobb, s);
00086 BBox frombb(from * source.bbox());
00087 plus_from(target(tobb.lower(0)),source(frombb.lower(0)));
00088 }
00089 void add_from(GridData<VectorType,1> &target, const BBox &towhere,
00090 const GridData<FixupType,1> &source, const int s) {
00091 BBox tobb(towhere * target.bbox()); AlignBBox(tobb, s);
00092 BBox frombb(source.bbox());
00093 plus_from(target(tobb.lower(0)),source(frombb.lower(0)));
00094 }
00095
00096 void add_to(GridData<FixupType,1> &target, const BBox &to,
00097 const GridData<VectorType,1> &source, const BBox &from) {
00098 BBox tobb(to * target.bbox());
00099 BBox frombb(from * source.bbox());
00100 plus_to(target(tobb.lower(0)),source(frombb.lower(0)));
00101 }
00102 void add_to(GridData<FixupType,1> &target,
00103 const GridData<VectorType,1> &source, const BBox &where) {
00104 BBox tobb(target.bbox());
00105 BBox frombb(where * source.bbox());
00106 plus_to(target(tobb.lower(0)),source(frombb.lower(0)));
00107 }
00108 };
00109
00116 template <class VectorType, class FixupType>
00117 class Fixup<VectorType,FixupType,1> : public FixupBase<VectorType,FixupType,1> {
00118 typedef GridData<VectorType,1> vec_grid_data_type;
00119 typedef GridData<VectorType,minus_1<1>::dim> ld_vec_grid_data_type;
00120 typedef GridData<FixupType,minus_1<1>::dim> ld_fixup_grid_data_type;
00121
00122 public:
00123 Fixup() : FixupBase<VectorType,FixupType,1>() {}
00124
00125 protected:
00126 void debug_print(vec_grid_data_type &gd, const BBox &where) {
00127 #ifdef DEBUG_PRINT
00128 int lower = std::max(where.lower(0),gd.lower(0));
00129 int upper = std::min(where.upper(0),gd.upper(0));
00130 for (register int i=lower; i<=upper; i+=where.stepsize(0))
00131 ( comm_service::log() << "[" << i << "]="
00132 << gd(i)(0) << " " ).flush();
00133 #endif
00134 }
00135
00136 void debug_print_ldv(ld_vec_grid_data_type &gd, const BBox &where) {
00137 #ifdef DEBUG_PRINT
00138 ( comm_service::log() << "[" << gd.bbox().lower(0) << "]="
00139 << gd(gd.bbox().lower(0))(0) << " " ).flush();
00140 ( comm_service::log() << "\n" ).flush();
00141 #endif
00142 }
00143 void debug_print_ldv(ld_vec_grid_data_type &gd) {
00144 debug_print_ldv(gd, gd.bbox());
00145 }
00146
00147 void debug_print_ld(ld_fixup_grid_data_type &gd, const BBox &where) {
00148 #ifdef DEBUG_PRINT
00149 ( comm_service::log() << "[" << gd.bbox().lower(0) << "]="
00150 << gd(gd.bbox().lower(0))(0) << " " ).flush();
00151 ( comm_service::log() << "\n" ).flush();
00152 #endif
00153 }
00154 void debug_print_ld(ld_fixup_grid_data_type &gd) {
00155 debug_print_ld(gd, gd.bbox());
00156 }
00157 };
00158
00159
00160 #endif