00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00043 #ifndef FARFIELD_EXPANSION
00044 #define FARFIELD_EXPANSION
00045
00046 #include "fastlib/fastlib.h"
00047 #include "kernel_aux.h"
00048 #include "series_expansion_aux.h"
00049
00050 template<typename TKernelAux>
00051 class LocalExpansion;
00052
00064 template<typename TKernelAux>
00065 class FarFieldExpansion {
00066
00067 private:
00068
00070
00072 Vector center_;
00073
00075 Vector coeffs_;
00076
00078 int order_;
00079
00083 const TKernelAux *ka_;
00084
00088 const typename TKernelAux::TKernel *kernel_;
00089
00093 const typename TKernelAux::TSeriesExpansionAux *sea_;
00094
00095 OT_DEF(FarFieldExpansion) {
00096 OT_MY_OBJECT(center_);
00097 OT_MY_OBJECT(coeffs_);
00098 OT_MY_OBJECT(order_);
00099 }
00100
00101 public:
00102
00104
00110 double bandwidth_sq() const { return kernel_->bandwidth_sq(); }
00111
00116 Vector* get_center() { return ¢er_; }
00117
00118 const Vector* get_center() const { return ¢er_; }
00119
00125 const Vector& get_coeffs() const { return coeffs_; }
00126
00131 int get_order() const { return order_; }
00132
00137 int get_max_order() const { return sea_->get_max_order(); }
00138
00141 double get_weight_sum() const { return coeffs_[0]; }
00142
00147 void set_order(int new_order) { order_ = new_order; }
00148
00156 void set_center(const Vector ¢er) {
00157
00158 for(index_t i = 0; i < center.length(); i++) {
00159 center_[i] = center[i];
00160 }
00161 }
00162
00164
00185 void Accumulate(const Vector &reference_point, double weight, int order);
00186
00212 void AccumulateCoeffs(const Matrix& data, const Vector& weights,
00213 int begin, int end, int order);
00214
00218 void RefineCoeffs(const Matrix& data, const Vector& weights,
00219 int begin, int end, int order);
00220
00223 double EvaluateField(const Matrix& data, int row_num, int order) const;
00224 double EvaluateField(const double *x_q, int order) const;
00225
00229 double MixField(const Matrix &data, int node1_begin, int node1_end,
00230 int node2_begin, int node2_end, const FarFieldExpansion &fe2,
00231 const FarFieldExpansion &fe3, int order2, int order3) const;
00232
00236 double ConvolveField(const FarFieldExpansion &fe, int order) const;
00237
00241 double ConvolveField(const FarFieldExpansion &fe2,
00242 const FarFieldExpansion &fe3,
00243 int order1, int order2, int order3) const;
00244
00248 void Init(const Vector& center, const TKernelAux &ka);
00249 void Init(const TKernelAux &ka);
00250
00251 template<typename TBound>
00252 int OrderForConvolving(const TBound &far_field_region,
00253 const Vector &far_field_region_centroid,
00254 const TBound &local_field_region,
00255 const Vector &local_field_region_centroid,
00256 double min_dist_sqd_regions,
00257 double max_dist_dsqd_regons,
00258 double max_error, double *actual_error) const;
00259
00264 template<typename TBound>
00265 int OrderForEvaluating(const TBound &far_field_region,
00266 const TBound &local_field_region,
00267 double min_dist_sqd_regions,
00268 double max_dist_sqd_regions,
00269 double max_error, double *actual_error) const;
00270
00280 template<typename TBound>
00281 int OrderForConvertingToLocal(const TBound &far_field_region,
00282 const TBound &local_field_region,
00283 double min_dist_sqd_regions,
00284 double max_dist_sqd_regions,
00285 double required_bound,
00286 double *actual_error) const;
00287
00290 void PrintDebug(const char *name="", FILE *stream=stderr) const;
00291
00296 void TranslateFromFarField(const FarFieldExpansion &se);
00297
00302 void TranslateToLocal(LocalExpansion<TKernelAux> &se, int truncation_order);
00303
00304 };
00305
00306 #define INSIDE_FARFIELD_EXPANSION_H
00307 #include "farfield_expansion_impl.h"
00308 #undef INSIDE_FARFIELD_EXPANSION_H
00309
00310 #endif