Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:22:34

0001 #ifndef HarmBasis3DCyl_h
0002 #define HarmBasis3DCyl_h
0003 
0004 #include "rz_harm_poly.h"
0005 
0006 namespace magfieldparam {
0007 
0008   typedef std::vector<rz_harm_poly> harm_poly_vec;
0009   typedef std::vector<harm_poly_vec> harm_poly_arr;
0010 
0011   /////////////////////////////////////////////////////////////////////////////////
0012   //                                                                             //
0013   //  HarmBasis3DCyl: set of basis harmonic polynomials in cylindrical CS        //
0014   //                                                                             //
0015   /////////////////////////////////////////////////////////////////////////////////
0016 
0017   class HarmBasis3DCyl {
0018   private:
0019     unsigned Dim;  //Dimension of the basis
0020     unsigned Len;  //Length of the basis, accounting negative M's
0021 
0022     int *L_k, *M_k;                      //Translation arrays from linear to (L,M) address;
0023     double *P_k, *Br_k, *Bz_k, *Bphi_k;  //Calculated values for (r,z) terms
0024 
0025     harm_poly_arr PtB;    //Potential basis
0026     harm_poly_arr BrB;    //Br basis
0027     harm_poly_arr BzB;    //Bz basis
0028     harm_poly_arr BphiB;  //phi basis
0029 
0030     void EvalRZ(harm_poly_arr &B, double *val);
0031     double GetVal(double *coeff, double *basis);
0032 
0033     void Print(harm_poly_arr &B, std::ostream &out = std::cout);
0034 
0035   public:
0036     HarmBasis3DCyl(const unsigned N = 18);  //The only legal constructor
0037     virtual ~HarmBasis3DCyl();
0038 
0039     unsigned GetDim() { return Dim; }
0040     unsigned GetLen() { return Len; }
0041     void GetLM(const unsigned j, int &Lj, int &Mj) {
0042       Lj = L_k[j];
0043       Mj = M_k[j];
0044     }
0045 
0046     //Sets point for the basis components evaluation
0047     void SetPoint(const double r, const double z, const double phi) { rz_harm_poly::SetPoint(r, z, phi); }
0048 
0049     //Fill tables with the basis component values. SetPoint(r,z,phi)
0050     //must be called before EvalXXX() calls.
0051     void EvalPtn() { EvalRZ(PtB, P_k); }
0052     void EvalBr() { EvalRZ(BrB, Br_k); }
0053     void EvalBz() { EvalRZ(BzB, Bz_k); }
0054     void EvalBphi();
0055 
0056     //Return the basis component value for the linear address k.
0057     //EvalXXX() must be called before GetXXX_k() call
0058     double GetPtn_k(const unsigned k) { return P_k[k]; }
0059     double GetBr_k(const unsigned k) { return Br_k[k]; }
0060     double GetBz_k(const unsigned k) { return Bz_k[k]; }
0061     double GetBphi_k(const unsigned k) { return Bphi_k[k]; }
0062 
0063     //Return the the potential and the field component values
0064     //resulted by the basis expansion with coefficients in <coeff>
0065     //EvalXXX() must be called before GetXXX() call
0066     double GetPtn(double *coeff) { return GetVal(coeff, P_k); }
0067     double GetBr(double *coeff) { return GetVal(coeff, Br_k); }
0068     double GetBz(double *coeff) { return GetVal(coeff, Bz_k); }
0069     double GetBphi(double *coeff) { return GetVal(coeff, Bphi_k); }
0070 
0071     void PrintPtB(std::ostream &out = std::cout) { Print(PtB, out); }
0072     void PrintBrB(std::ostream &out = std::cout) { Print(BrB, out); }
0073     void PrintBzB(std::ostream &out = std::cout) { Print(BzB, out); }
0074     void PrintBphiB(std::ostream &out = std::cout) { Print(BphiB, out); }
0075     void Print(std::ostream &out = std::cout);
0076 
0077   };  //class HarmBasis3DCyl
0078 }  // namespace magfieldparam
0079 
0080 #endif