CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/MagneticField/Interpolation/src/VectorFieldInterpolation.cc

Go to the documentation of this file.
00001 // include header for VectorFieldInterpolation
00002 #include "VectorFieldInterpolation.h"
00003 
00004 
00005 void VectorFieldInterpolation::defineCellPoint000(double X1, double X2, double X3, double F1, double F2, double F3){
00006   CellPoint000[0] = X1;
00007   CellPoint000[1] = X2;
00008   CellPoint000[2] = X3;
00009   CellPoint000[3] = F1;
00010   CellPoint000[4] = F2;
00011   CellPoint000[5] = F3;
00012   return;
00013 }
00014 
00015 
00016 void VectorFieldInterpolation::defineCellPoint100(double X1, double X2, double X3, double F1, double F2, double F3){
00017   CellPoint100[0] = X1;
00018   CellPoint100[1] = X2;
00019   CellPoint100[2] = X3;
00020   CellPoint100[3] = F1;
00021   CellPoint100[4] = F2;
00022   CellPoint100[5] = F3;
00023   return;
00024 }
00025 
00026 
00027 void VectorFieldInterpolation::defineCellPoint010(double X1, double X2, double X3, double F1, double F2, double F3){
00028   CellPoint010[0] = X1;
00029   CellPoint010[1] = X2;
00030   CellPoint010[2] = X3;
00031   CellPoint010[3] = F1;
00032   CellPoint010[4] = F2;
00033   CellPoint010[5] = F3;
00034   return;
00035 }
00036 
00037 
00038 void VectorFieldInterpolation::defineCellPoint110(double X1, double X2, double X3, double F1, double F2, double F3){
00039   CellPoint110[0] = X1;
00040   CellPoint110[1] = X2;
00041   CellPoint110[2] = X3;
00042   CellPoint110[3] = F1;
00043   CellPoint110[4] = F2;
00044   CellPoint110[5] = F3;
00045   return;
00046 }
00047 
00048 
00049 void VectorFieldInterpolation::defineCellPoint001(double X1, double X2, double X3, double F1, double F2, double F3){
00050   CellPoint001[0] = X1;
00051   CellPoint001[1] = X2;
00052   CellPoint001[2] = X3;
00053   CellPoint001[3] = F1;
00054   CellPoint001[4] = F2;
00055   CellPoint001[5] = F3;
00056   return;
00057 }
00058 
00059 
00060 void VectorFieldInterpolation::defineCellPoint101(double X1, double X2, double X3, double F1, double F2, double F3){
00061   CellPoint101[0] = X1;
00062   CellPoint101[1] = X2;
00063   CellPoint101[2] = X3;
00064   CellPoint101[3] = F1;
00065   CellPoint101[4] = F2;
00066   CellPoint101[5] = F3;
00067   return;
00068 }
00069 
00070 
00071 void VectorFieldInterpolation::defineCellPoint011(double X1, double X2, double X3, double F1, double F2, double F3){
00072   CellPoint011[0] = X1;
00073   CellPoint011[1] = X2;
00074   CellPoint011[2] = X3;
00075   CellPoint011[3] = F1;
00076   CellPoint011[4] = F2;
00077   CellPoint011[5] = F3;
00078   return;
00079 }
00080 
00081 
00082 void VectorFieldInterpolation::defineCellPoint111(double X1, double X2, double X3, double F1, double F2, double F3){
00083   CellPoint111[0] = X1;
00084   CellPoint111[1] = X2;
00085   CellPoint111[2] = X3;
00086   CellPoint111[3] = F1;
00087   CellPoint111[4] = F2;
00088   CellPoint111[5] = F3;
00089   return;
00090 }
00091 
00092 
00093 void VectorFieldInterpolation::putSCoordGetVField(double X1, double X2, double X3, double &F1, double &F2, double &F3){
00094   SC[0] = X1;
00095   SC[1] = X2;
00096   SC[2] = X3;
00097 
00098   // values describing 4 help points after interpolation step of variables X1
00099   // 5 dimensions: 2 space dimensions + 3 field dimensions
00100   //                        X2' , X3' , F1' , F2' , F3'
00101   double HelpPoint00[5]; // {0.0 , 0.0 , 0.0 , 0.0 , 0.0};
00102   double HelpPoint10[5];
00103   double HelpPoint01[5];
00104   double HelpPoint11[5];
00105 
00106   // values describing 2 help points after interpolation step of variables X2'
00107   // 4 dimensions: 1 space dimensions + 3 field dimensions
00108   //                       X3" , F1" , F2" , F3"
00109   double HelpPoint0[4]; // {0.0 , 0.0 , 0.0 , 0.0};
00110   double HelpPoint1[4];
00111 
00112 
00113   // 1. iteration *****
00114   // prepare interpolation between CellPoint000 and CellPoint100
00115   double DeltaX100X000 = CellPoint100[0] - CellPoint000[0];
00116   double DeltaSC0X000overDeltaX100X000 = 0.;
00117   if (DeltaX100X000 != 0.) DeltaSC0X000overDeltaX100X000 = (SC[0] - CellPoint000[0]) / DeltaX100X000;
00118 
00119   // prepare interpolation between CellPoint010 and CellPoint110
00120   double DeltaX110X010 = CellPoint110[0] - CellPoint010[0];
00121   double DeltaSC0X010overDeltaX110X010 = 0.;
00122   if (DeltaX110X010 != 0.) DeltaSC0X010overDeltaX110X010 = (SC[0] - CellPoint010[0]) / DeltaX110X010;
00123 
00124   // prepare interpolation between CellPoint001 and CellPoint101
00125   double DeltaX101X001 = CellPoint101[0] - CellPoint001[0];
00126   double DeltaSC0X001overDeltaX101X001 = 0.;
00127   if (DeltaX101X001 != 0.) DeltaSC0X001overDeltaX101X001 = (SC[0] - CellPoint001[0]) / DeltaX101X001;
00128 
00129   // prepare interpolation between CellPoint011 and CellPoint111
00130   double DeltaX111X011 = CellPoint111[0] - CellPoint011[0];
00131   double DeltaSC0X011overDeltaX111X011 = 0.;
00132   if (DeltaX111X011 != 0.) DeltaSC0X011overDeltaX111X011 = (SC[0] - CellPoint011[0]) / DeltaX111X011;
00133 
00134   for (int i=0; i<5; ++i){
00135     int ip = i+1; 
00136 
00137     // interpolate between CellPoint000 and CellPoint100
00138     HelpPoint00[i] = CellPoint000[ip] + DeltaSC0X000overDeltaX100X000 * (CellPoint100[ip] - CellPoint000[ip]);
00139 
00140     // interpolate between CellPoint010 and CellPoint110
00141     HelpPoint10[i] = CellPoint010[ip] + DeltaSC0X010overDeltaX110X010 * (CellPoint110[ip] - CellPoint010[ip]);
00142 
00143     // interpolate between CellPoint001 and CellPoint101
00144     HelpPoint01[i] = CellPoint001[ip] + DeltaSC0X001overDeltaX101X001 * (CellPoint101[ip] - CellPoint001[ip]);
00145 
00146     // interpolate between CellPoint011 and CellPoint111
00147     HelpPoint11[i] = CellPoint011[ip] + DeltaSC0X011overDeltaX111X011 * (CellPoint111[ip] - CellPoint011[ip]);
00148   }
00149 
00150   // 2. iteration *****
00151   // prepare interpolation between HelpPoint00 and HelpPoint10
00152   double DeltaX10X00 = HelpPoint10[0] - HelpPoint00[0];
00153   double DeltaSC1X00overDeltaX10X00 = 0.;
00154   if (DeltaX10X00 != 0.) DeltaSC1X00overDeltaX10X00 = (SC[1] - HelpPoint00[0]) / DeltaX10X00;
00155   // prepare interpolation between HelpPoint01 and HelpPoint11
00156   double DeltaX11X01 = HelpPoint11[0] - HelpPoint01[0];
00157   double DeltaSC1X01overDeltaX11X01 = 0.;
00158   if (DeltaX11X01 != 0.) DeltaSC1X01overDeltaX11X01 = (SC[1] - HelpPoint01[0]) / DeltaX11X01;
00159 
00160   for (int i=0; i<4; ++i){
00161     int ip = i+1; 
00162 
00163     // interpolate between HelpPoint00 and HelpPoint10
00164     HelpPoint0[i] = HelpPoint00[ip] + DeltaSC1X00overDeltaX10X00 * (HelpPoint10[ip] - HelpPoint00[ip]);
00165 
00166     // interpolate between HelpPoint01 and HelpPoint11
00167     HelpPoint1[i] = HelpPoint01[ip] + DeltaSC1X01overDeltaX11X01 * (HelpPoint11[ip] - HelpPoint01[ip]);
00168   }
00169 
00170   // 3. iteration *****
00171   // prepare interpolation between HelpPoint0 and HelpPoint1
00172   double DeltaX1X0 = HelpPoint1[0] - HelpPoint0[0];
00173   double DeltaSC2X0overDeltaX1X0 = 0.;
00174   if (DeltaX1X0 != 0.) DeltaSC2X0overDeltaX1X0 = (SC[2] - HelpPoint0[0]) / DeltaX1X0;
00175 
00176   for (int i=0; i<3; ++i){
00177     int ip = i+1; 
00178 
00179     // interpolate between HelpPoint0 and HelpPoint1
00180     VF[i] = HelpPoint0[ip] + DeltaSC2X0overDeltaX1X0 * (HelpPoint1[ip] - HelpPoint0[ip]);
00181   }
00182 
00183   F1 = VF[0];
00184   F2 = VF[1];
00185   F3 = VF[2];
00186 
00187   return;
00188 }