Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)

bem/kernel.hh
Go to the documentation of this file.
00001 /* Kernel functions for integral equations
00002  */
00003 
00004 #ifndef bemKernel_hh
00005 #define bemKernel_hh
00006 
00007 #include "basics/vectorsMatrices.hh"
00008 
00009 #include <cmath>
00010 #ifndef M_1_PI
00011 #  define M_1_PI         0.31830988618379067154  /* 1/pi */
00012 #endif
00013 
00014 namespace bem {
00015 
00016 #define KrnlEPS 1e-10
00017 
00018   // ****************************************************************** Cnst **
00019 
00022   class Cnst {
00023     friend std::ostream& operator<<(std::ostream& os, const Cnst& c);
00024     concepts::Real c_;
00025 
00026   public:
00027     typedef concepts::Real F;
00028 
00029     Cnst(concepts::Real c) : c_(c) {}
00030 
00031     concepts::Real operator()(const concepts::Real3d&, const concepts::Real3d&)
00032       { return c_; }
00033   };
00034 
00035   // ****************************************************************** Poly **
00036 
00039   class Poly {
00040     friend std::ostream& operator<<(std::ostream& os, const Poly& p);
00041     bool var_;
00042     uint idx_;
00043     uint exp_;
00044 
00045   public:
00046     typedef concepts::Real F;
00047 
00048     Poly(bool var, uint idx, uint e)
00049       : var_(var), idx_((idx > 2 ? 2 : idx)), exp_(e) {}
00050 
00051     concepts::Real operator()(const concepts::Real3d& x,
00052             const concepts::Real3d& y) {
00053       concepts::Real vari = var_ ? y[idx_] : x[idx_];
00054       concepts::Real krnl = 1.0;
00055       for(uint i = 0; i < exp_; i++)  krnl *= vari;
00056       return krnl;
00057     }
00058   };
00059 
00060   // ***************************************************************** ExpR2 **
00061 
00064   class ExpR2 {
00065     friend std::ostream& operator<<(std::ostream& os, const ExpR2& e);
00066     concepts::MapReal3d gamma_;
00067 
00068   public:
00069     typedef concepts::Real F;
00070 
00071     ExpR2(concepts::MapReal3d& gamma) : gamma_(gamma) {}
00072 
00073     concepts::Real operator()(const concepts::Real3d& x,
00074             const concepts::Real3d& y) {
00075       concepts::Real3d r(x-y);
00076       concepts::Real   e = r * (gamma_ * r);
00077 
00078       return std::exp(-e);
00079     }
00080   };
00081 
00082   // ****************************************************************** ExpR **
00083 
00086   class ExpR {
00087     friend std::ostream& operator<<(std::ostream& os, const ExpR& e);
00088 
00089     concepts::Real gamma_;
00090 
00091   public:
00092     typedef concepts::Real F;
00093     ExpR(concepts::Real gamma) : gamma_(gamma) {}
00094 
00095     concepts::Real operator()(const concepts::Real3d& x,
00096             const concepts::Real3d& y) {
00097       concepts::Real r = (x - y).l2();
00098       return std::exp(-gamma_ * r);
00099     }
00100   };
00101 
00102   // **************************************************************** Inv1Rn **
00103 
00106   class Inv1Rn {
00107     friend std::ostream& operator<<(std::ostream& os, const Inv1Rn& krnl);
00108     concepts::Real gamma_;
00109     uint n_;
00110 
00111   public:
00112     typedef concepts::Real F;
00113 
00114     Inv1Rn(concepts::Real gamma, uint n) : gamma_(gamma), n_(n) {}
00115 
00116     concepts::Real operator()(const concepts::Real3d& x,
00117             const concepts::Real3d& y) {
00118       concepts::Real r = (x - y).l2();
00119       return (r < KrnlEPS) ? 1.0
00120   : 1.0 / (1.0 + gamma_*std::exp(n_ * std::log(r)));
00121     }
00122   };
00123 
00124   // *************************************************************** Laplace **
00125 
00128   class Laplace {
00129     friend std::ostream& operator<<(std::ostream& os, const Laplace& lpl);
00130     const concepts::Real sc_;
00131 
00132   public:
00133     typedef concepts::Real F;
00134 
00135     Laplace() : sc_(0.25 * M_1_PI) {}
00136 
00137     concepts::Real operator()(const concepts::Real3d& x,
00138             const concepts::Real3d& y) {
00139       concepts::Real r = (x - y).l2();
00140       return sc_ / r;
00141     }
00142   };
00143 
00144 } // namespace bem
00145 
00146 #endif // bemKernel_hh

Home | Doxygen Documentation | Tutorials | Developer Tools (restricted)